hopwire 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +136 -6
- package/dist/cli.js +4 -12
- package/dist/commands/http.js +3 -2
- package/dist/commands/up.js +3 -2
- package/dist/commands/watch.js +3 -3
- package/dist/inspector/assets/{index-CIOfyIbK.js → index-CdyIIKdA.js} +1 -1
- package/dist/inspector/index.html +1 -1
- package/dist/live.js +226 -0
- package/dist/main.js +14 -3
- package/dist/output.js +19 -0
- package/dist/p2p.js +59 -1
- package/dist/serve.js +1 -0
- package/dist/shortcuts.js +217 -0
- package/dist/terminal.js +619 -0
- package/dist/version.js +12 -0
- package/dist/webhook.js +91 -0
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -1,26 +1,156 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { openBrowser } from './browser.js';
|
|
3
3
|
import { main } from './main.js';
|
|
4
|
+
import { formatExchange } from './output.js';
|
|
4
5
|
import { promptHidden, promptLine } from './prompt.js';
|
|
5
|
-
import {
|
|
6
|
+
import { copyToClipboard, replayThroughInspector, shortcutTarget, startShortcuts } from './shortcuts.js';
|
|
7
|
+
import { wantsColor } from './style.js';
|
|
8
|
+
import { LiveFeed } from './live.js';
|
|
9
|
+
import { STARTING, Spinner, TerminalScreen, hopFrames, terminalLook } from './terminal.js';
|
|
10
|
+
import { readVersion } from './version.js';
|
|
11
|
+
const argv = process.argv.slice(2);
|
|
12
|
+
const look = terminalLook(process.env);
|
|
6
13
|
const color = wantsColor(process.stdout, process.env);
|
|
14
|
+
const colorErrors = wantsColor(process.stderr, process.env);
|
|
15
|
+
// A command that runs a tunnel, not its help: only these get the spinner and the keys
|
|
16
|
+
const command = argv[0] ?? '';
|
|
17
|
+
const tunnel = command in STARTING && !argv.some((arg) => arg === '--help' || arg === '-h' || arg === '--version');
|
|
18
|
+
const keys = tunnel && process.stdin.isTTY === true && command !== 'connect';
|
|
19
|
+
// hopwire --version on a terminal shows the mark beside the version; a script reading it gets the bare version
|
|
20
|
+
const versionOnly = argv.length === 1 && argv[0] === '--version';
|
|
21
|
+
const screen = color || colorErrors
|
|
22
|
+
? new TerminalScreen({
|
|
23
|
+
look,
|
|
24
|
+
width: () => process.stdout.columns ?? 100,
|
|
25
|
+
version: readVersion(),
|
|
26
|
+
shortcuts: keys,
|
|
27
|
+
})
|
|
28
|
+
: null;
|
|
29
|
+
// Cleared before anything else is written: a prompt, a line, a failure
|
|
30
|
+
const spinner = tunnel && colorErrors && screen !== null ? new Spinner(process.stderr, look, `${STARTING[command] ?? ''}...`) : null;
|
|
31
|
+
spinner?.start();
|
|
32
|
+
const quiet = () => spinner?.stop();
|
|
33
|
+
// A tunnel's feed on a colour terminal: rows scroll above a status line that stays put
|
|
34
|
+
const live = tunnel && color && screen !== null
|
|
35
|
+
? new LiveFeed(screen, process.stdout, () => process.stdout.columns ?? 100)
|
|
36
|
+
: null;
|
|
37
|
+
process.once('exit', () => live?.stop());
|
|
38
|
+
const out = (text) => {
|
|
39
|
+
quiet();
|
|
40
|
+
if (live === null) {
|
|
41
|
+
process.stdout.write(`${text}\n`);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
live.write(text);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* The rabbit hops into its place once, about a third of a second, before the mark is drawn: on --version and after a
|
|
49
|
+
* login. Not on CI, and never where there is no colour. The wait blocks the process on purpose: nothing else runs yet.
|
|
50
|
+
*/
|
|
51
|
+
const hop = () => {
|
|
52
|
+
if (!color || process.env.CI !== undefined) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const pause = new Int32Array(new SharedArrayBuffer(4));
|
|
56
|
+
const height = 6;
|
|
57
|
+
for (const frame of hopFrames(look)) {
|
|
58
|
+
process.stdout.write(`${frame}\n`);
|
|
59
|
+
Atomics.wait(pause, 0, 0, 60);
|
|
60
|
+
// Back to the first line of the frame, and away with it
|
|
61
|
+
process.stdout.write(`\u001b[${height}A\r\u001b[J`);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
// Without the live feed (no colour), the newest exchange is still noted for the r key
|
|
65
|
+
let last = null;
|
|
66
|
+
let markShown = false;
|
|
7
67
|
await main({
|
|
8
|
-
argv
|
|
68
|
+
argv,
|
|
9
69
|
env: process.env,
|
|
10
|
-
print: (line) =>
|
|
11
|
-
|
|
70
|
+
print: (line) => {
|
|
71
|
+
if (color && screen !== null && (versionOnly || line.startsWith('Logged in '))) {
|
|
72
|
+
hop();
|
|
73
|
+
}
|
|
74
|
+
out(color && screen !== null ? (versionOnly ? screen.markBlock() : screen.render(line)) : line);
|
|
75
|
+
},
|
|
76
|
+
error: (line) => {
|
|
77
|
+
quiet();
|
|
78
|
+
const write = () => process.stderr.write(`${line}\n`);
|
|
79
|
+
if (live === null) {
|
|
80
|
+
write();
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
live.around(write);
|
|
84
|
+
}
|
|
85
|
+
},
|
|
12
86
|
on: (signal, listener) => process.on(signal, listener),
|
|
13
87
|
exit: (code) => process.exit(code),
|
|
14
88
|
// Opened only when a command reads it
|
|
15
89
|
input: () => process.stdin,
|
|
16
90
|
// Only a terminal can be asked without showing the answer
|
|
17
91
|
promptSecret: process.stdin.isTTY
|
|
18
|
-
? (question, stop) =>
|
|
92
|
+
? (question, stop) => {
|
|
93
|
+
quiet();
|
|
94
|
+
return promptHidden(question, process.stdin, process.stderr, stop);
|
|
95
|
+
}
|
|
19
96
|
: undefined,
|
|
20
97
|
// hopwire init asks its questions on standard error, so standard output keeps the lines of the result
|
|
21
98
|
promptLine: process.stdin.isTTY
|
|
22
|
-
? (question, stop) =>
|
|
99
|
+
? (question, stop) => {
|
|
100
|
+
quiet();
|
|
101
|
+
// hopwire init: the mark above its first question
|
|
102
|
+
if (colorErrors && screen !== null && !markShown) {
|
|
103
|
+
markShown = true;
|
|
104
|
+
process.stderr.write(`${screen.markBlock()}\n\n`);
|
|
105
|
+
}
|
|
106
|
+
return promptLine(question, process.stdin, process.stderr, stop);
|
|
107
|
+
}
|
|
23
108
|
: undefined,
|
|
24
109
|
// hopwire login opens its sign-in page; the URL is printed too
|
|
25
110
|
openBrowser: (url) => openBrowser(url),
|
|
111
|
+
// A row of columns on a colour terminal; the plain line otherwise, still noted for the r key
|
|
112
|
+
exchange: color || keys
|
|
113
|
+
? (exchange, label = '') => {
|
|
114
|
+
quiet();
|
|
115
|
+
if (exchange.source !== 'replay') {
|
|
116
|
+
last = exchange;
|
|
117
|
+
}
|
|
118
|
+
if (live !== null) {
|
|
119
|
+
live.exchange(exchange, label);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
out(color && screen !== null ? screen.row(exchange, label) : `${label}${formatExchange(exchange)}`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
: undefined,
|
|
126
|
+
started: (running) => {
|
|
127
|
+
quiet();
|
|
128
|
+
const target = shortcutTarget(running);
|
|
129
|
+
if (target !== null) {
|
|
130
|
+
live?.start();
|
|
131
|
+
}
|
|
132
|
+
if (!keys || target === null) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const say = (text, problem = false) => out(color && screen !== null ? screen.say(text, problem) : text);
|
|
136
|
+
startShortcuts(process.stdin, {
|
|
137
|
+
target,
|
|
138
|
+
lastExchange: () => (live === null ? last : live.target()),
|
|
139
|
+
move: live === null ? undefined : (step) => live.move(step),
|
|
140
|
+
unpick: live === null ? undefined : () => live.unpick(),
|
|
141
|
+
details: live === null ? undefined : () => live.details(target.inspectorUrl !== null),
|
|
142
|
+
say,
|
|
143
|
+
openBrowser: (url) => openBrowser(url),
|
|
144
|
+
copy: (text) => copyToClipboard(text, (escape) => process.stdout.write(escape)),
|
|
145
|
+
replay: replayThroughInspector,
|
|
146
|
+
// The same way out as Ctrl+C in a terminal that is not in raw mode: the supervisor's shutdown
|
|
147
|
+
interrupt: () => process.kill(process.pid, 'SIGINT'),
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
failure: colorErrors && screen !== null
|
|
151
|
+
? (message, hint) => {
|
|
152
|
+
quiet();
|
|
153
|
+
process.stderr.write(`${screen.failure(message, hint)}\n`);
|
|
154
|
+
}
|
|
155
|
+
: undefined,
|
|
26
156
|
});
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { randomBytes } from 'node:crypto';
|
|
2
|
-
import { readFileSync } from 'node:fs';
|
|
3
2
|
import os from 'node:os';
|
|
4
3
|
import path from 'node:path';
|
|
5
4
|
import { parseArgs } from 'node:util';
|
|
@@ -19,6 +18,7 @@ import { HopwireError, TemporaryError, UsageError, errorCode } from './errors.js
|
|
|
19
18
|
import { loadOrCreateIdentity } from './identity.js';
|
|
20
19
|
import { defaultLogName, isFollowablePath } from './log-follow.js';
|
|
21
20
|
import { DOCS_URL, printable } from './output.js';
|
|
21
|
+
import { readVersion } from './version.js';
|
|
22
22
|
import { createUpdateNotice } from './update-notice.js';
|
|
23
23
|
import { parseControlPlaneUrl, parseEdgeUrl, parseLocalTarget } from './urls.js';
|
|
24
24
|
export { UsageError };
|
|
@@ -392,6 +392,7 @@ export async function run(argv, io) {
|
|
|
392
392
|
relay: values.relay ? await relayAccess('--relay', store) : undefined,
|
|
393
393
|
dataDir,
|
|
394
394
|
print: io.print,
|
|
395
|
+
exchange: io.exchange,
|
|
395
396
|
bootstrap: parseBootstrap(io.env.HOPWIRE_DHT_BOOTSTRAP),
|
|
396
397
|
agent: values.agent ?? false,
|
|
397
398
|
signal: io.signal,
|
|
@@ -413,6 +414,7 @@ export async function run(argv, io) {
|
|
|
413
414
|
configFile: file,
|
|
414
415
|
dataDir,
|
|
415
416
|
print: io.print,
|
|
417
|
+
exchange: io.exchange,
|
|
416
418
|
// Token and account are only read when a service is public: private mode never looks at them
|
|
417
419
|
...(config.services.some((service) => service.public)
|
|
418
420
|
? update.watch(await publicAccess(shown, config, io.env, store))
|
|
@@ -482,6 +484,7 @@ export async function run(argv, io) {
|
|
|
482
484
|
dataDir,
|
|
483
485
|
serviceName: values.name ?? 'default',
|
|
484
486
|
print: io.print,
|
|
487
|
+
exchange: io.exchange,
|
|
485
488
|
share: values.share ?? false,
|
|
486
489
|
allowAgents: values['allow-agents'] ?? false,
|
|
487
490
|
allow,
|
|
@@ -983,17 +986,6 @@ function parseBootstrap(value) {
|
|
|
983
986
|
return { host: match[1], port };
|
|
984
987
|
});
|
|
985
988
|
}
|
|
986
|
-
/** The version of the package this file ships in; package.json lies next to `src` and `dist` alike. */
|
|
987
|
-
function readVersion() {
|
|
988
|
-
const manifest = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
989
|
-
if (typeof manifest === 'object' &&
|
|
990
|
-
manifest !== null &&
|
|
991
|
-
'version' in manifest &&
|
|
992
|
-
typeof manifest.version === 'string') {
|
|
993
|
-
return manifest.version;
|
|
994
|
-
}
|
|
995
|
-
throw new Error('package.json carries no version');
|
|
996
|
-
}
|
|
997
989
|
function parsePort(value, label, min) {
|
|
998
990
|
const port = Number(value);
|
|
999
991
|
if (value === undefined || value === '' || !Number.isInteger(port) || port < min || port > 65535) {
|
package/dist/commands/http.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MODE_LOCAL, MODE_P2P, MODE_P2P_TEAM, relayLine, MODE_PUBLIC, MODE_PUBLIC_P2P, MODE_PUBLIC_P2P_TEAM, AGENTS_ALLOWED_LINE, agentLine, agentOffLine,
|
|
1
|
+
import { MODE_LOCAL, MODE_P2P, MODE_P2P_TEAM, relayLine, MODE_PUBLIC, MODE_PUBLIC_P2P, MODE_PUBLIC_P2P_TEAM, AGENTS_ALLOWED_LINE, agentLine, agentOffLine, exchangeSink, formatPeerEvent, formatLimitReached, formatLogNotice, logLines, formatMeteredUsage, formatRelayEvent, formatTeamEvent, formatUsage, shareNotice, tunnelGuide, mainPublicUrl, publicUrlText, } from '../output.js';
|
|
2
2
|
import { startServing } from '../serve.js';
|
|
3
3
|
export { INSPECTOR_FILES } from '../serve.js';
|
|
4
4
|
/**
|
|
@@ -35,6 +35,7 @@ export async function startHttpTunnel(options) {
|
|
|
35
35
|
onTeamEvent: (event, organisation) => options.print(formatTeamEvent(event, organisation)),
|
|
36
36
|
relay: options.relay,
|
|
37
37
|
onRelayEvent: (event) => options.print(formatRelayEvent(event)),
|
|
38
|
+
onPeerEvent: (event) => options.print(formatPeerEvent(event)),
|
|
38
39
|
bootstrap: options.bootstrap,
|
|
39
40
|
inspectorFiles: options.inspectorFiles,
|
|
40
41
|
agent: options.agent,
|
|
@@ -42,7 +43,7 @@ export async function startHttpTunnel(options) {
|
|
|
42
43
|
signal: options.signal,
|
|
43
44
|
listenOption: '--listen <port>',
|
|
44
45
|
inspectOption: '--inspect <port> or run with --no-inspect',
|
|
45
|
-
onExchange: (exchange) => options.print(
|
|
46
|
+
onExchange: (exchange) => exchangeSink(options.print, options.exchange)(exchange),
|
|
46
47
|
onLogError: () => options.print('Could not write to the traffic log; the request was still forwarded'),
|
|
47
48
|
onBridgeEvent: (_service, event) => options.print(formatBridgeEvent(event)),
|
|
48
49
|
});
|
package/dist/commands/up.js
CHANGED
|
@@ -2,7 +2,7 @@ import { randomBytes } from 'node:crypto';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { LOCAL_ENTRY_DEFAULT_PORT, RANDOM_SUBDOMAIN_BYTES, randomSubdomain } from '@hopwire/protocol';
|
|
4
4
|
import { HopwireError } from '../errors.js';
|
|
5
|
-
import { MODE_LOCAL, MODE_P2P, MODE_P2P_TEAM, relayLine, MODE_PUBLIC, MODE_PUBLIC_P2P, MODE_PUBLIC_P2P_TEAM, AGENTS_ALLOWED_LINE, agentLine, agentOffLine,
|
|
5
|
+
import { MODE_LOCAL, MODE_P2P, MODE_P2P_TEAM, relayLine, MODE_PUBLIC, MODE_PUBLIC_P2P, MODE_PUBLIC_P2P_TEAM, AGENTS_ALLOWED_LINE, agentLine, agentOffLine, exchangeSink, formatPeerEvent, formatLogNotice, logLines, formatRelayEvent, formatTeamEvent, formatUsage, shareNotice, tunnelGuide, mainPublicUrl, publicUrlText, } from '../output.js';
|
|
6
6
|
import { startServing } from '../serve.js';
|
|
7
7
|
import { formatBridgeEvent } from './http.js';
|
|
8
8
|
/**
|
|
@@ -53,6 +53,7 @@ export async function startUp(options) {
|
|
|
53
53
|
onTeamEvent: (event, organisation) => options.print(formatTeamEvent(event, organisation)),
|
|
54
54
|
relay: options.relay,
|
|
55
55
|
onRelayEvent: (event) => options.print(formatRelayEvent(event)),
|
|
56
|
+
onPeerEvent: (event) => options.print(formatPeerEvent(event)),
|
|
56
57
|
bootstrap: options.bootstrap,
|
|
57
58
|
inspectorFiles: options.inspectorFiles,
|
|
58
59
|
agent: options.agent,
|
|
@@ -63,7 +64,7 @@ export async function startUp(options) {
|
|
|
63
64
|
signal: options.signal,
|
|
64
65
|
listenOption: 'a free port',
|
|
65
66
|
inspectOption: 'inspector.port in hopwire.yaml',
|
|
66
|
-
onExchange: (exchange) => options.print(
|
|
67
|
+
onExchange: (exchange) => exchangeSink(options.print, options.exchange)(exchange, label(exchange.serviceName)),
|
|
67
68
|
onLogError: (name) => options.print(`${label(name)}Could not write to the traffic log; the request was still forwarded`),
|
|
68
69
|
onBridgeEvent: (name, event) => options.print(several ? `${formatBridgeEvent(event)} (service ${name})` : formatBridgeEvent(event)),
|
|
69
70
|
});
|
package/dist/commands/watch.js
CHANGED
|
@@ -7,7 +7,7 @@ import { startInspectorServer } from '../inspector-server.js';
|
|
|
7
7
|
import { createInterceptor } from '../interceptor.js';
|
|
8
8
|
import { InFlightExchanges, followLogFile } from '../log-follow.js';
|
|
9
9
|
import { REMOTE_LOG_BUDGET_BYTES } from '../log.js';
|
|
10
|
-
import { MODE_P2P, MODE_P2P_RELAYED, MODE_P2P_TEAM,
|
|
10
|
+
import { MODE_P2P, MODE_P2P_RELAYED, MODE_P2P_TEAM, exchangeSink, formatLogNotice, logLines, printable, relayedLine, shortKey, watchAgentLine, watchGuide, } from '../output.js';
|
|
11
11
|
import { INSPECTOR_FILES } from '../serve.js';
|
|
12
12
|
import { Supervisor, unlessAborted } from '../supervisor.js';
|
|
13
13
|
/**
|
|
@@ -114,7 +114,7 @@ export async function startWatch(options) {
|
|
|
114
114
|
serviceName,
|
|
115
115
|
log: own,
|
|
116
116
|
inFlight,
|
|
117
|
-
onExchange: (exchange) => options.print(
|
|
117
|
+
onExchange: (exchange) => exchangeSink(options.print, options.exchange)(exchange),
|
|
118
118
|
onLogError: () => options.print('Could not write to the traffic log; the replay was still sent'),
|
|
119
119
|
});
|
|
120
120
|
interceptors.set(serviceName, interceptor);
|
|
@@ -162,7 +162,7 @@ export async function startWatch(options) {
|
|
|
162
162
|
}
|
|
163
163
|
// Stopped at the last step: nothing is reported as running
|
|
164
164
|
proceed();
|
|
165
|
-
const stopPrinting = remote.subscribe((_index, exchange) => options.print(
|
|
165
|
+
const stopPrinting = remote.subscribe((_index, exchange) => exchangeSink(options.print, options.exchange)(exchange));
|
|
166
166
|
supervisor.add('servers', async () => stopPrinting());
|
|
167
167
|
void remote.exhausted.then(() => options.print(`Watching stopped: this run has downloaded ${REMOTE_LOG_BUDGET_BYTES / (1024 * 1024)} MB of the log; new exchanges are no longer fetched until hopwire watch is started again`));
|
|
168
168
|
options.print(joined.relayed ? MODE_P2P_RELAYED : organisation === null ? MODE_P2P : MODE_P2P_TEAM);
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
`))),e[ho]=fo(i);let a=r||i.props&&i.props.type===`number`;Xa(e,t?`change`:`input`,t=>{t.target.composing||e[ho](_o(e.value,n,a))}),(n||a)&&Xa(e,`change`,()=>{e.value=_o(e.value,n,a)}),t||(Xa(e,`compositionstart`,po),Xa(e,`compositionend`,mo),Xa(e,`change`,mo))},mounted(e,{value:t,modifiers:{trim:n,number:r}}){let i=t??``,a=e[go];delete e[go],a!==void 0&&(e.type===`text`||e.type===`textarea`)&&e.value!==a?e[ho](_o(e.value,n,r)):e.value=i},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:a}},o){if(e[ho]=fo(o),e.composing)return;let s=(a||e.type===`number`)&&!/^0\d/.test(e.value)?de(e.value):e.value,c=t??``;if(s===c)return;let l=e.getRootNode();(l instanceof Document||l instanceof ShadowRoot)&&l.activeElement===e&&e.type!==`range`&&(r&&t===n||i&&e.value.trim()===c)||(e.value=c)}},yo={created(e,{value:t},n){e.checked=Ee(t,n.props.value),e[ho]=fo(n),Xa(e,`change`,()=>{e[ho](Co(e))})},beforeUpdate(e,{value:t,oldValue:n},r){e[ho]=fo(r),t!==n&&(e.checked=Ee(t,r.props.value))}},bo={deep:!0,created(e,{value:t,modifiers:{number:n}},r){e._modelValue=t,Xa(e,`change`,()=>{let t=Array.prototype.filter.call(e.options,e=>e.selected).map(e=>n?de(Co(e)):Co(e)),r=e.multiple,i=r?p(e._modelValue)?new Set(t):t:t[0],a=e._pendingValue=[r,r?d(i)?t.slice():t:i];try{e[ho](i)}finally{Cn(()=>{e._pendingValue===a&&(e._pendingValue=void 0)})}}),e[ho]=fo(r)},mounted(e,{value:t,modifiers:{number:n}}){So(e,t,n)},beforeUpdate(e,{value:t},n){e._modelValue=t,e[ho]=fo(n)},updated(e,{value:t,modifiers:{number:n}}){let r=e._pendingValue;e._pendingValue=void 0,r&&r[0]===e.multiple&&xo(t,r[1],r[0])||So(e,t,n)}};function xo(e,t,n){if(!n||d(e))return Ee(e,t);if(p(e)){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}return!1}function So(e,t,n=!1){let r=e.multiple,i=d(t);if(!r||i||p(t)){for(let a=0,o=e.options.length;a<o;a++){let o=e.options[a],s=Co(o);if(r){if(i){let e=typeof s;o.selected=e===`string`||e===`number`?t.some(e=>String(e)===String(s)):De(t,s)>-1}else o.selected=t.has(s)||n&&typeof s==`string`&&t.has(de(s))}else if(Ee(Co(o),t)){e.selectedIndex!==a&&(e.selectedIndex=a);return}}!r&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function Co(e){return`_value`in e?e._value:e.value}var wo=[`ctrl`,`shift`,`alt`,`meta`],To={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>`button`in e&&e.button!==0,middle:e=>`button`in e&&e.button!==1,right:e=>`button`in e&&e.button!==2,exact:(e,t)=>wo.some(n=>e[`${n}Key`]&&!t.includes(n))},Eo=(e,t)=>{if(!e)return e;let n=e._withMods||={},r=t.join(`.`);return n[r]||(n[r]=((n,...r)=>{for(let e=0;e<t.length;e++){let r=To[t[e]];if(r&&r(n,t))return}return e(n,...r)}))},Do=s({patchProp:co},Na),Oo;function ko(){return Oo||=Ti(Do)}var Ao=((...e)=>{let t=ko().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=Mo(e);if(!r)return;let i=t._component;h(i)||i.render||i.template||(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,jo(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a},t});function jo(e){if(e instanceof SVGElement)return`svg`;if(typeof MathMLElement==`function`&&e instanceof MathMLElement)return`mathml`}function Mo(e){return g(e)?document.querySelector(e):e}var No=`296 62 430 108`,Po=`300 62 124 110`,Fo=4.5,Io=[`M336.89 111.56C337.43 111.4 339.26 111.03 340.5 110.5C341.74 109.97 343.04 108.72 345.17 108C347.29 107.28 351.42 105.97 354.67 105.67C357.92 105.37 363.86 105.65 366.83 106C369.81 106.35 372.7 107.42 374.5 108C376.3 108.58 377.61 109.56 378.83 109.83C380.06 110.11 381.87 110.21 382.67 109.83C383.47 109.46 383.87 108.21 384.17 107.33C384.47 106.46 384.64 104.72 384.67 104C384.69 103.28 385.33 103.22 384.33 102.5C383.33 101.78 379.93 100.34 378 99.17C376.07 97.99 373.1 95.97 371.5 94.67C369.9 93.37 368.68 92.3 367.33 90.5C365.98 88.7 363.4 84.77 362.5 82.67C361.6 80.57 361.46 77.5 361.33 76.5C361.21 75.5 361.09 76.08 361.67 76C362.24 75.92 363.79 75.72 365.17 76C366.54 76.28 368.93 76.98 370.83 77.83C372.73 78.68 375.86 80.32 377.83 81.67C379.81 83.02 382.35 85.21 384 86.83C385.65 88.46 387.58 90.85 388.83 92.5C390.08 94.15 390.43 96.71 392.33 97.83C394.23 98.96 399.38 99.22 401.5 100C403.63 100.78 405.18 101.95 406.5 103C407.82 104.05 409.23 105.58 410.33 107C411.43 108.42 413.33 110.95 413.83 112.5C414.33 114.05 414.09 116.13 413.67 117.33C413.24 118.53 411.93 119.78 411 120.5C410.07 121.22 408.73 121.87 407.5 122.17C406.27 122.47 404.31 122.28 402.83 122.5C401.36 122.72 399.81 122.4 397.67 123.67C395.52 124.93 389.89 129.84 388.52 130.93`,`M388.52 130.93C389.84 131.32 394.31 131.96 397.33 133.5C400.35 135.04 406.67 139.69 408.67 141.17C410.67 142.64 410.32 142.58 410.67 143.33C411.02 144.08 411.02 145.44 411 146.17C410.98 146.89 411 147.67 410.5 148.17C410 148.67 408.54 149.4 407.67 149.5C406.79 149.6 407.19 150.08 404.67 148.83C402.14 147.58 394.86 142.99 390.83 141.17C386.81 139.34 381.46 137.54 377.83 136.67C374.21 135.79 369.24 135.46 366.67 135.33C364.09 135.21 361.57 135.76 360.67 135.83`,`M331 120.88C330.77 122.84 330.2 131.76 329.5 134C328.8 136.24 327.63 135.48 326.33 135.83C325.03 136.18 321.88 136.16 320.83 136.33C319.78 136.51 320.86 134.7 319.33 137C317.81 139.3 312.07 149.12 310.67 151.67C309.27 154.22 310.05 153.32 310 154C309.95 154.68 310.08 155.59 310.33 156.17C310.58 156.74 311.19 157.51 311.67 157.83C312.14 158.16 312.85 158.31 313.5 158.33C314.15 158.36 315.43 158.22 316 158C316.57 157.78 316.58 157.86 317.33 156.83C318.08 155.81 319.82 152.74 321 151.17C322.18 149.59 323.29 147.16 325.17 146.33C327.04 145.51 331.23 146.02 333.5 145.67C335.77 145.32 338.76 144.53 340.33 144C341.91 143.47 342.95 142.82 344 142.17C345.05 141.52 346.18 140.94 347.33 139.67C348.48 138.39 350.72 135.57 351.67 133.67C352.62 131.77 353.34 128.4 353.67 127C353.99 125.6 353.81 124.73 353.83 124.33`,`M336.89 111.56C336.46 111.1 334.91 109.08 334 108.5C333.09 107.92 331.81 107.72 330.83 107.67C329.86 107.62 328.45 107.67 327.5 108.17C326.55 108.67 325.05 110.03 324.5 111C323.95 111.97 323.81 113.67 323.83 114.67C323.86 115.67 324.24 116.89 324.67 117.67C325.09 118.44 325.72 119.35 326.67 119.83C327.62 120.31 330.35 120.72 331 120.88`,`M336.89 111.56C336.73 112.02 336.52 113.42 335.83 114.67C335.15 115.91 333.06 118.9 332.33 119.83C331.61 120.76 331.2 120.72 331 120.88`],Lo=`M454.72 144L447.01 144L447.01 94.02L454.72 94.02L454.72 115.44L475.72 115.44L475.72 94.02L483.43 94.02L483.43 144L475.72 144L475.72 122.44L454.72 122.44L454.72 144M510.56 145Q505.27 145 501.17 142.82Q497.06 140.64 494.71 136.57Q492.35 132.50 492.35 126.94L492.35 125.86Q492.35 120.30 494.71 116.26Q497.06 112.23 501.17 110.01Q505.27 107.80 510.56 107.80Q515.84 107.80 519.98 110.01Q524.12 112.23 526.48 116.26Q528.84 120.30 528.84 125.86L528.84 126.94Q528.84 132.50 526.48 136.57Q524.12 140.64 519.98 142.82Q515.84 145 510.56 145M510.56 138.43Q515.41 138.43 518.45 135.32Q521.48 132.22 521.48 126.72L521.48 126.08Q521.48 120.58 518.48 117.47Q515.48 114.37 510.56 114.37Q505.77 114.37 502.74 117.47Q499.71 120.58 499.71 126.08L499.71 126.72Q499.71 132.22 502.74 135.32Q505.77 138.43 510.56 138.43M545.33 158.28L537.98 158.28L537.98 108.80L545.19 108.80L545.19 113.87L546.33 113.87Q547.69 111.51 550.44 109.66Q553.18 107.80 558.32 107.80Q562.75 107.80 566.43 109.94Q570.11 112.08 572.35 116.12Q574.60 120.15 574.60 125.86L574.60 126.94Q574.60 132.65 572.39 136.68Q570.18 140.72 566.46 142.86Q562.75 145 558.32 145Q554.90 145 552.54 144.14Q550.19 143.29 548.76 141.97Q547.33 140.64 546.47 139.22L545.33 139.22L545.33 158.28M556.18 138.57Q561.04 138.57 564.11 135.50Q567.18 132.43 567.18 126.72L567.18 126.08Q567.18 120.44 564.07 117.37Q560.97 114.30 556.18 114.30Q551.47 114.30 548.36 117.37Q545.26 120.44 545.26 126.08L545.26 126.72Q545.26 132.43 548.36 135.50Q551.47 138.57 556.18 138.57M599.52 144L587.17 144L581.17 108.80L588.53 108.80L592.95 139.07L594.10 139.07L600.24 108.80L612.16 108.80L618.23 139.07L619.37 139.07L623.80 108.80L631.15 108.80L625.16 144L612.80 144L606.73 113.80L605.59 113.80L599.52 144M647.22 144L639.86 144L639.86 108.80L647.22 108.80L647.22 144M643.58 104.02Q641.43 104.02 639.97 102.62Q638.51 101.23 638.51 99.02Q638.51 96.80 639.97 95.41Q641.43 94.02 643.58 94.02Q645.79 94.02 647.22 95.41Q648.65 96.80 648.65 99.02Q648.65 101.23 647.22 102.62Q645.79 104.02 643.58 104.02M665.50 144L658.14 144L658.14 108.80L665.35 108.80L665.35 112.94L666.50 112.94Q667.35 110.73 669.24 109.69Q671.14 108.66 673.92 108.66L678.13 108.66L678.13 115.30L673.64 115.30Q670.07 115.30 667.78 117.26Q665.50 119.22 665.50 123.29L665.50 144M700.63 145Q695.27 145 691.27 142.75Q687.27 140.50 685.02 136.40Q682.77 132.29 682.77 126.86L682.77 126.01Q682.77 120.51 684.99 116.40Q687.20 112.30 691.16 110.05Q695.13 107.80 700.34 107.80Q705.41 107.80 709.23 110.05Q713.05 112.30 715.19 116.30Q717.33 120.30 717.33 125.65L717.33 128.43L690.27 128.43Q690.41 133.08 693.38 135.82Q696.34 138.57 700.77 138.57Q704.91 138.57 707.02 136.72Q709.12 134.86 710.26 132.43L716.33 135.57Q715.33 137.57 713.44 139.79Q711.55 142 708.48 143.50Q705.41 145 700.63 145M690.34 122.79L709.84 122.79Q709.55 118.80 706.98 116.55Q704.41 114.30 700.27 114.30Q696.13 114.30 693.52 116.55Q690.91 118.80 690.34 122.79`,Ro=[`id`],zo=[`id`],Bo=[`fill`],Vo=[`mask`],Ho={class:`hwx-wire`},Uo=[`cx`],Wo={class:`hwx-hop`},Go=[`stroke-width`],Ko=[`d`],qo=z({__name:`HopLoader`,props:{active:{type:Boolean}},setup(e){let t=Array.from({length:9},(e,t)=>-128+t*64),n=Qn(),r=Qn();return(i,a)=>(W(),G(`svg`,{viewBox:`0 0 256 150`,"aria-hidden":`true`,focusable:`false`,class:E([`block h-auto`,e.active?`hwx-run`:void 0])},[q(`defs`,null,[q(`linearGradient`,{id:P(r),x1:`0`,x2:`1`,y1:`0`,y2:`0`},[...a[0]||=[q(`stop`,{offset:`0`,"stop-color":`#000`},null,-1),q(`stop`,{offset:`.22`,"stop-color":`#fff`},null,-1),q(`stop`,{offset:`.78`,"stop-color":`#fff`},null,-1),q(`stop`,{offset:`1`,"stop-color":`#000`},null,-1)]],8,Ro),q(`mask`,{id:P(n),maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`256`,height:`150`},[q(`rect`,{width:`256`,height:`150`,fill:`url(#${P(r)})`},null,8,Bo)],8,zo)]),q(`g`,{mask:`url(#${P(n)})`},[q(`g`,Ho,[a[1]||=q(`line`,{class:`stroke-muted`,x1:`-192`,y1:`122`,x2:`448`,y2:`122`,"stroke-width":`1.5`},null,-1),(W(!0),G(U,null,B(P(t),e=>(W(),G(`circle`,{key:e,class:`fill-ground stroke-muted`,cx:e,cy:`122`,r:`3.4`,"stroke-width":`1.5`},null,8,Uo))),128))]),a[2]||=q(`circle`,{class:`hwx-lit1 fill-hop-green`,cx:`128`,cy:`122`,r:`4.6`},null,-1),a[3]||=q(`circle`,{class:`hwx-lit2 fill-hop-green`,cx:`64`,cy:`122`,r:`4.6`},null,-1),a[4]||=q(`circle`,{class:`hwx-lit3 fill-hop-green`,cx:`0`,cy:`122`,r:`4.6`},null,-1)],8,Vo),a[5]||=q(`circle`,{class:`hwx-ring stroke-green-text`,cx:`128`,cy:`122`,r:`5`,fill:`none`,"stroke-width":`1.5`},null,-1),q(`g`,Wo,[q(`g`,{transform:`translate(-132.64 10.80) scale(0.72)`,class:`stroke-mark`,fill:`none`,"stroke-width":P(Fo),"stroke-linecap":`round`,"stroke-linejoin":`round`},[(W(!0),G(U,null,B(P(Io),(e,t)=>(W(),G(`path`,{key:t,d:e},null,8,Ko))),128))],8,Go)])],2))}}),Jo={class:`flex h-full flex-col items-center justify-center gap-4 p-8 text-center`,role:`status`},Yo={class:`text-sm text-muted`},Xo=z({__name:`ConnectingState`,props:{connecting:{type:Boolean}},setup(e){return(t,n)=>(W(),G(`div`,Jo,[J(qo,{class:`w-44`,active:e.connecting},null,8,[`active`]),q(`p`,Yo,D(e.connecting?`Connecting to the tunnel`:`Not connected to the tunnel`),1)]))}}),Zo={connecting:`Connecting`,live:`Live`,reconnecting:`Reconnecting`,closed:`Disconnected`};function Qo(e,t){return e?`closed`:t?`reconnecting`:`connecting`}function $o(e){return e===`connecting`||e===`reconnecting`}function es(){let e=N(!1),t;async function n(n){try{await navigator.clipboard.writeText(n)}catch{return}e.value=!0,clearTimeout(t),t=setTimeout(()=>{e.value=!1},1500)}return gr(()=>clearTimeout(t)),{copied:e,copy:n}}var ts=[`aria-label`],ns={"aria-live":`polite`},rs=z({__name:`CopyButton`,props:{text:{},label:{}},setup(e){let{copied:t,copy:n}=es();return(r,i)=>(W(),G(`button`,{type:`button`,class:`shrink-0 cursor-pointer rounded-sm px-1.5 py-0.5 text-xs font-medium text-tag-fg transition-colors duration-150 ease-out hover:bg-ink/8 hover:text-ink`,"aria-label":e.label,onClick:i[0]||=t=>P(n)(e.text)},[q(`span`,ns,D(P(t)?`Copied`:`Copy`),1)],8,ts))}}),is={class:`flex h-full items-center justify-center overflow-y-auto p-8`},as={class:`w-full max-w-2xl`},os={key:0,class:`mt-2 text-sm text-muted`},ss={class:`mt-4 flex items-start gap-2 rounded-md border border-hairline bg-well p-3`},cs={class:`min-w-0 flex-1 text-xs leading-5 break-all text-ink`},ls={class:`mt-4 text-sm text-muted`},us={class:`font-mono text-xs text-ink`},ds={class:`font-mono text-xs text-ink`},fs={key:2,class:`mt-2 text-sm text-muted`},ps=z({__name:`EmptyState`,props:{status:{},stream:{}},setup(e){let t=e,n=Q(()=>t.status?.services.find(e=>e.entryUrl!==null)??null),r=Q(()=>n.value===null?null:`curl -X POST ${n.value.entryUrl}/hello -H 'content-type: application/json' -d '{"hello":"hopwire"}'`);return(t,i)=>(W(),G(`div`,is,[q(`div`,as,[J(qo,{class:`mb-6 w-44`,active:P($o)(e.stream)},null,8,[`active`]),i[5]||=q(`h2`,{class:`text-subheading`},`No requests yet`,-1),e.status?.watching?(W(),G(`p`,os,` This inspector follows a shared traffic log. Requests show up here as soon as your teammate's tunnel receives them. `)):n.value&&r.value?(W(),G(U,{key:1},[i[4]||=q(`p`,{class:`mt-2 text-sm text-muted`},` Send a request to the entry point and it appears here right away, no reload needed: `,-1),q(`div`,ss,[q(`code`,cs,[i[0]||=q(`span`,{class:`text-muted select-none`},`$ `,-1),Y(D(r.value),1)]),J(rs,{text:r.value,label:`Copy curl command`},null,8,[`text`])]),q(`p`,ls,[i[1]||=Y(` Everything sent to `,-1),q(`span`,us,D(n.value.entryUrl),1),i[2]||=Y(` is forwarded to `,-1),q(`span`,ds,D(n.value.target),1),i[3]||=Y(` and recorded in the traffic log. Point your webhook sender or client at the entry point instead of the service. `,-1)])],64)):(W(),G(`p`,fs,`Waiting for the tunnel.`))])]))}});function ms(e){return e.response.status===101}var hs=[[/^(emergency|alert|critical|crit|error|err|fatal)$/i,`error`],[/^(warning|warn)$/i,`warning`],[/^(notice|info)$/i,`info`],[/^(debug|trace)$/i,`debug`]];function gs(e){let t=e.slice(0,2048).split(`
|
|
3
3
|
`,1)[0]??``,n=/\.(EMERGENCY|ALERT|CRITICAL|ERROR|WARNING|NOTICE|INFO|DEBUG):/.exec(t)?.[1]??/"(?:level|level_name|severity)"\s*:\s*"([A-Za-z]+)"/.exec(t)?.[1]??/^\S*\s*\[?\b(FATAL|ERROR|ERR|WARN|WARNING|INFO|DEBUG|TRACE)\b\]?/.exec(t.replace(/^\[[^\]]*\]\s*/,``))?.[1];if(n===void 0)return null;for(let[e,t]of hs)if(e.test(n))return t;return null}var _s=class extends Error{status;code;constructor(e,t,n){super(n),this.status=e,this.code=t}},vs=`api/`;async function ys(e,t){let n;try{n=await fetch(e,t)}catch{throw new _s(0,`unreachable`,`The tunnel does not answer. Is it still running?`)}if(!n.ok){let e=await n.json().catch(()=>null);throw new _s(n.status,typeof e?.error==`string`?e.error:`unknown`,typeof e?.message==`string`?e.message:`The inspector answered ${n.status}.`)}return await n.json()}function bs(){return ys(`${vs}status`)}function xs(e){let t=new URLSearchParams({origin:e.origin,limit:String(e.limit)});return e.before!==void 0&&t.set(`before`,String(e.before)),ys(`${vs}exchanges?${t.toString()}`)}async function Ss(e,t){let n=[],r=null;for(;;){let i=new URLSearchParams({origin:e});r!==null&&i.set(`after`,String(r));let a=await ys(`${vs}ws-messages/${encodeURIComponent(t)}?${i.toString()}`);n.push(...a.blocks);let o=a.blocks.at(-1);if(!a.more||o===void 0)return n;r=o.seq}}function Cs(e){let t=new URLSearchParams;return e.exchangeId!==void 0&&t.set(`exchangeId`,e.exchangeId),e.origin!==void 0&&t.set(`origin`,e.origin),e.limit!==void 0&&t.set(`limit`,String(e.limit)),ys(`${vs}log-entries?${t.toString()}`)}function ws(e,t){let n=new URLSearchParams({origin:e.origin,index:String(e.index)});return ys(`${vs}replay/${encodeURIComponent(e.exchange.id)}?${n.toString()}`,{method:`POST`,...t===void 0?{}:{headers:{"content-type":`application/json`},body:JSON.stringify(t)}})}function Ts(e){return e>=200&&e<300?`success`:e>=300&&e<400?`info`:e>=400&&e<500?`warning`:e>=500&&e<600?`danger`:`neutral`}var Es={success:`bg-ok-bg text-ok-fg`,info:`bg-info-bg text-info-fg`,warning:`bg-warn-bg text-warn-fg`,danger:`bg-err-bg text-err-fg`,neutral:`bg-tag-bg text-tag-fg`},Ds={local:`local`,replay:`replay`,p2p_peer:`peer`,public_edge:`public`};function Os(e){return Ds[e]}function ks(e){return e<1e3?`${e} ms`:`${(e/1e3).toFixed(e<1e4?2:1)} s`}function As(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} kB`:`${(e/1048576).toFixed(1)} MB`}function js(e,t){return t?`Binary body; the log keeps its first ${As(e)}. It is not shown.`:`Binary body of ${As(e)}. It is not shown, but it is replayed as captured.`}function Ms(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function Ns(e){return e.length<=20?e:`${e.slice(0,10)}...${e.slice(-6)}`}function Ps(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Fs(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n)t+=String.fromCharCode(...e.subarray(r,r+n));return btoa(t)}function Is(e){return Fs(new TextEncoder().encode(e))}function Ls(e,t){let n=new TextDecoder(`utf-8`,{fatal:!0});for(let r=0;r<=(t?3:0)&&r<e.length;r++)try{let t=n.decode(e.subarray(0,e.length-r));return t.includes(`\0`)?null:t}catch{}return null}function Rs(e){let t=e.trim();if(t===``)return null;try{return JSON.stringify(JSON.parse(t),null,2)}catch{return null}}function zs(e,t=!1){if(e===``)return{kind:`empty`};let n=Ps(e),r=Ls(n,t);if(r===null)return{kind:`binary`,bytes:n.length};let i=Rs(r);return i!==null&&/^\s*[[{]/.test(r)?{kind:`json`,text:r,formatted:i,bytes:n.length}:{kind:`text`,text:r,bytes:n.length}}function Bs(e,t){return`${e}:${t}`}function Vs(e,t){let n=new Map;for(let r of[...e,...t])n.set(r.seq,r);return[...n.values()].sort((e,t)=>e.seq-t.seq)}function Hs(e){return{messages:e.flatMap(e=>e.messages).map((e,t)=>({...e,position:t})),close:e.find(e=>e.close!==void 0)?.close??null}}function Us(e){if(!e.binary){let t=zs(e.dataBase64,e.truncated);if(t.kind===`json`)return{kind:`json`,text:t.text,formatted:t.formatted};if(t.kind===`text`)return{kind:`text`,text:t.text};if(t.kind===`empty`)return{kind:`text`,text:``}}let t=Ps(e.dataBase64);return{kind:`binary`,hex:Array.from(t.subarray(0,256),e=>e.toString(16).padStart(2,`0`)).join(` `),more:t.length>256}}function Ws(e,t){let n=t.text.trim().toLowerCase();return e.filter(e=>{if(t.direction!==``&&e.direction!==t.direction)return!1;if(n===``)return!0;let r=Us(e);return r.kind!==`binary`&&r.text.toLowerCase().includes(n)})}function Gs(e){switch(e){case`client`:return`the client`;case`service`:return`the service`;case`hopwire`:return`Hopwire`}return e}function Ks(e){return e.some(e=>e.direction===`in`&&e.truncated)?`A client message was captured only in part. Use Edit & Replay to replace or remove it.`:null}var qs=0;function Js(e=``){return qs+=1,{key:qs,binary:!1,text:e,dataBase64:``,length:0,truncated:!1}}function Ys(e,t,n){return{path:e,headers:t.map(([e,t])=>({name:e,value:t})),messages:n.filter(e=>e.direction===`in`).map(e=>{qs+=1;let t=e.binary?null:Us(e),n=t!==null&&t.kind!==`binary`;return{key:qs,binary:!n,text:n?t.text:``,dataBase64:e.dataBase64,atMs:e.atMs,length:e.length,truncated:e.truncated}}),timing:`recorded`}}var Xs=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function Zs(e){if(!/^\/\S*$/.test(e.path))return`The path must start with / and must not contain spaces.`;for(let t of e.headers)if(t.name.trim()!==``||t.value.trim()!==``){if(!Xs.test(t.name.trim()))return`"${t.name}" is not a valid header name.`;if(/[\r\n]/.test(t.value))return`The value of ${t.name.trim()} must be a single line.`}return e.messages.some(e=>e.binary&&e.truncated)?`A binary message was captured only in part and cannot be sent. Remove it to replay the rest.`:null}function Qs(e){let t=e.messages.map(e=>({binary:e.binary,dataBase64:e.binary?e.dataBase64:Is(e.text),...e.atMs===void 0?{}:{atMs:e.atMs}}));return{path:e.path,headers:e.headers.filter(e=>e.name.trim()!==``).map(e=>[e.name.trim(),e.value.trim()]),messages:t,timing:e.timing}}var $s=[`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`HEAD`,`OPTIONS`],ec=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function tc(e){let{request:t}=e,n=zs(t.bodyBase64,t.bodyTruncated);return{method:t.method.toUpperCase(),path:t.path,headers:t.headers.map(([e,t])=>({name:e,value:t})),body:n.kind===`json`||n.kind===`text`?n.text:``,bodyEditable:n.kind!==`binary`}}function nc(e,t){if(!ec.test(e.method.trim()))return`Enter a method such as GET or POST.`;if(!/^\/\S*$/.test(e.path))return`The path must start with / and must not contain spaces.`;for(let t of e.headers)if(t.name.trim()!==``||t.value.trim()!==``){if(!ec.test(t.name.trim()))return`"${t.name}" is not a valid header name.`;if(/[\r\n]/.test(t.value))return`The value of ${t.name.trim()} must be a single line.`}return!e.bodyEditable&&t.request.bodyTruncated?`The stored body is binary and was truncated, so this request cannot be replayed.`:null}function rc(e){let t=e.headers.filter(e=>e.name.trim()!==``).map(e=>[e.name.trim(),e.value.trim()]);return{method:e.method.trim().toUpperCase(),path:e.path,headers:t,...e.bodyEditable?{bodyBase64:Is(e.body)}:{}}}function ic(e,t){return e===null?`The inspector is not connected to the tunnel.`:e.watching?e.replayTarget===null?`Replay is off because this watch has no replay target. Start hopwire watch with --replay-target <url>.`:null:e.services.some(e=>e.name===t.serviceName)?null:`The service "${t.serviceName}" is not part of this tunnel, so there is nothing to replay to.`}function ac(e,t,n=[]){let r=ic(e,t);if(r!==null)return{replay:r,editAndReplay:r};if(ms(t))return{replay:Ks(n),editAndReplay:null};let{request:i}=t;if(!i.bodyTruncated)return{replay:null,editAndReplay:null};if(zs(i.bodyBase64,!0).kind===`binary`){let e=`The stored body is binary and was truncated, so this request cannot be replayed.`;return{replay:e,editAndReplay:e}}return{replay:`The stored body was truncated. Use Edit & Replay to supply the body.`,editAndReplay:null}}function oc(e,t){return e===null?null:e.watching?e.replayTarget:e.services.find(e=>e.name===t.serviceName)?.target??null}function sc(e){return e.replayTarget===null?e.watching?{text:`none: start hopwire watch with --replay-target <url>`,missing:!0}:e.services.length>1?{text:`the local target of each service`,missing:!1}:{text:`none`,missing:!0}:{text:e.replayTarget,missing:!1}}var cc=2e3;function lc(e){return e.flatMap(({origin:e,block:t})=>t.entries.map(n=>({key:`${e}:${t.serviceName}:${t.source}:${t.seq}:${n.readAt}:${n.length}:${n.text.slice(0,200)}`,origin:e,serviceName:t.serviceName,source:t.source,entry:n,level:gs(n.text)})))}function uc(e,t,n=cc){let r=new Map(e.map(e=>[e.key,e])),i=!1;for(let e of t)r.has(e.key)||(r.set(e.key,e),i=!0);if(!i)return e;let a=[...r.values()].sort((e,t)=>e.entry.readAt-t.entry.readAt);return a.length>n?a.slice(a.length-n):a}function dc(e){return e.reduce((e,{block:t})=>({entries:e.entries+(t.omitted?.entries??0),bytes:e.bytes+(t.omitted?.bytes??0)}),{entries:0,bytes:0})}function fc(e,t,n){return e.filter(e=>e.origin===t&&e.entry.exchangeIds.includes(n))}function pc(e,t){let n=t.text.trim().toLowerCase();return e.filter(e=>(t.source===``||e.source===t.source)&&(t.level===``||e.level===t.level)&&(n===``||e.entry.text.toLowerCase().includes(n)))}var mc=/^\s*(#\d+\s|at\s)/,hc=/[/\\](vendor|node_modules|site-packages)[/\\]/;function gc(e){return e.split(`
|
|
4
4
|
`).map(e=>({text:e,appFrame:mc.test(e)&&!hc.test(e)}))}var _c={error:`Error`,warning:`Warning`,info:`Info`,debug:`Debug`},vc={class:`space-y-2`,"aria-live":`polite`},yc=[`onClick`],bc={class:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted`},xc={class:`font-mono text-tag-fg`},Sc={class:`tabular-nums`},Cc={key:1,class:`rounded-full bg-info-bg px-2 py-0.5 text-info-fg`},wc={key:2,class:`text-warn-fg`},Tc={key:3,class:`text-warn-fg`},Ec={key:4},Dc={key:0,class:`mt-2 rounded-sm bg-warn-bg px-3 py-2 text-sm text-warn-fg`,role:`note`},Oc={class:`mt-2 max-h-80 overflow-auto font-mono text-xs leading-5 break-words whitespace-pre-wrap text-muted`},kc=z({__name:`LogEntryList`,props:{items:{},exchangeId:{default:null},selectable:{type:Boolean,default:!1}},emits:[`select`],setup(e,{emit:t}){let n=t,r={error:`bg-err-bg text-err-fg`,warning:`bg-warn-bg text-warn-fg`,info:`bg-info-bg text-info-fg`,debug:`bg-tag-bg text-tag-fg`};function i(e,t){return e.entry.exchangeIds.filter(e=>e!==t).length}return(t,a)=>(W(),G(`ol`,vc,[(W(!0),G(U,null,B(e.items,t=>(W(),G(`li`,{key:t.key,class:E([`rounded-sm border border-hairline bg-surface p-3`,e.selectable&&t.entry.exchangeIds.length>0?`cursor-pointer hover:border-line-strong`:``]),onClick:r=>e.selectable&&t.entry.exchangeIds.length>0&&n(`select`,t)},[q(`div`,bc,[t.level?(W(),G(`span`,{key:0,class:E([`rounded-sm px-1.5 py-0.5 font-medium`,r[t.level]])},D(P(_c)[t.level]),3)):X(``,!0),q(`span`,xc,D(t.source),1),q(`span`,Sc,D(P(Ms)(t.entry.readAt)),1),t.origin===`remote`?(W(),G(`span`,Cc,` watching `)):X(``,!0),t.entry.ambiguous&&e.exchangeId!==null?(W(),G(`span`,wc,` also linked to `+D(i(t,e.exchangeId))+` other `+D(i(t,e.exchangeId)===1?`request`:`requests`),1)):t.entry.ambiguous?(W(),G(`span`,Tc,` logged while `+D(t.entry.exchangeIds.length)+` requests were in flight `,1)):e.selectable&&t.entry.exchangeIds.length===0?(W(),G(`span`,Ec,`not linked to a request`)):X(``,!0)]),t.entry.truncated?(W(),G(`p`,Dc,` Truncated: the log keeps the first `+D(P(As)(16384))+` of this entry of `+D(P(As)(t.entry.length))+`. `,1)):X(``,!0),q(`pre`,Oc,[(W(!0),G(U,null,B(P(gc)(t.entry.text),(e,t)=>(W(),G(`span`,{key:t,class:E(e.appFrame||t===0?`text-ink`:``)},D(e.text)+D(`
|
|
5
|
-
`),3))),128))])],10,yc))),128))]))}}),Ac={class:`space-y-6`},jc={key:0,class:`mt-2 text-sm text-muted`},Mc={key:1,class:`mt-2 w-full table-fixed border-collapse text-left font-mono text-xs`},Nc={scope:`row`,class:`w-2/5 py-1.5 pr-3 font-normal break-words text-muted`},Pc={class:`py-1.5 break-all text-ink`},Fc={class:`flex items-center gap-3`},Ic={key:0,class:`text-xs text-muted`},Lc={key:0,class:`mt-2 rounded-sm bg-warn-bg px-3 py-2 text-sm text-warn-fg`,role:`note`},Rc={key:1,class:`mt-2 text-sm text-muted`},zc={key:2,class:`mt-2 text-sm text-muted`},Bc={key:3,class:`mt-2 max-h-[60vh] overflow-auto rounded-sm border border-hairline bg-surface p-3 font-mono text-xs leading-5 break-words whitespace-pre-wrap text-ink`},Vc=z({__name:`MessageView`,props:{headers:{},bodyBase64:{},bodyTruncated:{type:Boolean}},setup(e){let t=e,n=Q(()=>zs(t.bodyBase64,t.bodyTruncated)),r=Q(()=>n.value.kind===`json`?n.value.formatted:n.value.kind===`text`?n.value.text:null),i=Q(()=>{switch(n.value.kind){case`empty`:return``;case`json`:return`JSON, ${As(n.value.bytes)}`;case`text`:return`Text, ${As(n.value.bytes)}`;case`binary`:return`Binary, ${As(n.value.bytes)}`}return``});return(t,a)=>(W(),G(`div`,Ac,[q(`section`,null,[a[1]||=q(`h3`,{class:`text-xs font-medium tracking-wider text-muted uppercase`},`Headers`,-1),e.headers.length===0?(W(),G(`p`,jc,`No headers.`)):(W(),G(`table`,Mc,[a[0]||=q(`thead`,{class:`sr-only`},[q(`tr`,null,[q(`th`,{scope:`col`},`Name`),q(`th`,{scope:`col`},`Value`)])],-1),q(`tbody`,null,[(W(!0),G(U,null,B(e.headers,(e,t)=>(W(),G(`tr`,{key:t,class:`border-b border-hairline align-top`},[q(`th`,Nc,D(e[0]),1),q(`td`,Pc,D(e[1]),1)]))),128))])]))]),q(`section`,null,[q(`div`,Fc,[a[2]||=q(`h3`,{class:`text-xs font-medium tracking-wider text-muted uppercase`},`Body`,-1),i.value?(W(),G(`span`,Ic,D(i.value),1)):X(``,!0),r.value===null?X(``,!0):(W(),K(rs,{key:1,class:`ml-auto`,text:r.value,label:`Copy body`},null,8,[`text`]))]),e.bodyTruncated?(W(),G(`p`,Lc,` Truncated: the log keeps only the first `+D(P(As)(n.value.kind===`empty`?0:n.value.bytes))+` of this body. The full body was forwarded. `,1)):X(``,!0),n.value.kind===`empty`?(W(),G(`p`,Rc,`No body.`)):n.value.kind===`binary`?(W(),G(`p`,zc,D(P(js)(n.value.bytes,e.bodyTruncated)),1)):(W(),G(`pre`,Bc,D(r.value),1))])]))}}),Hc={class:`inline-flex shrink-0 rounded-sm bg-tag-bg px-1.5 py-0.5 font-mono text-xs font-medium text-tag-fg`},Uc=z({__name:`MethodBadge`,props:{method:{}},setup(e){return(t,n)=>(W(),G(`span`,Hc,D(e.method),1))}}),Wc=[`viewBox`],Gc=[`stroke-width`],Kc=[`d`],qc=z({__name:`MarkLoader`,setup(e){return(e,t)=>(W(),G(`svg`,{viewBox:P(Po),"aria-hidden":`true`,focusable:`false`,class:`block w-auto shrink-0`},[q(`g`,{class:`stroke-current`,fill:`none`,"stroke-width":P(Fo),"stroke-linecap":`round`,"stroke-linejoin":`round`},[(W(!0),G(U,null,B(P(Io),(e,t)=>(W(),G(`path`,{key:t,d:e,pathLength:`1`,class:E(`hwl hwl-${t+1}`)},null,10,Kc))),128))],8,Gc)],8,Wc))}}),Jc=[`type`,`disabled`,`aria-busy`],$=z({__name:`UiButton`,props:{variant:{default:`secondary`},type:{default:`button`},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}},setup(e){let t={primary:`border border-transparent bg-hop-green text-on-green hover:bg-ink hover:text-ground disabled:hover:bg-hop-green disabled:hover:text-on-green`,secondary:`border border-line-strong text-ink hover:border-ink disabled:hover:border-line-strong`,quiet:`border border-transparent text-muted hover:bg-ink/8 hover:text-ink disabled:hover:bg-transparent disabled:hover:text-muted`};return(n,r)=>(W(),G(`button`,{type:e.type,disabled:e.disabled||e.loading,"aria-busy":e.loading?`true`:void 0,class:E([`inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium transition-colors duration-150 ease-out disabled:cursor-not-allowed disabled:opacity-60`,t[e.variant]])},[e.loading?(W(),K(qc,{key:0,class:`h-4`})):X(``,!0),Cr(n.$slots,`default`)],10,Jc))}}),Yc={class:`flex gap-3`},Xc={class:`w-32 shrink-0`},Zc=[`value`],Qc={class:`min-w-0 flex-1`},$c={class:`mt-1.5 space-y-1.5`},el=[`onUpdate:modelValue`,`aria-label`],tl=[`onUpdate:modelValue`,`aria-label`],nl={class:`mt-2 flex items-center gap-3`},rl={class:`flex items-center gap-3`},il={key:0,class:`mt-1.5 rounded-sm bg-warn-bg px-3 py-2 text-sm text-warn-fg`,role:`note`},al={key:2,class:`mt-1.5 text-sm text-muted`},ol={class:`sticky bottom-0 -mx-4 space-y-3 border-t border-hairline bg-ground px-4 py-3`},sl={key:0,class:`rounded-sm bg-err-bg px-3 py-2 text-sm text-err-fg`,role:`alert`},cl={class:`flex items-center gap-3`},ll={key:0,class:`truncate text-xs text-muted`},ul={class:`font-mono`},dl=`w-full rounded-sm border border-line-strong bg-well px-2.5 py-1.5 font-mono text-xs text-ink placeholder:text-muted`,fl=z({__name:`ReplayEditor`,props:{exchange:{},target:{},sending:{type:Boolean},error:{}},emits:[`send`,`cancel`],setup(e,{emit:t}){let n=e,r=t,i=Ht(tc(n.exchange)),a=N(null),o=Q(()=>{let e=n.exchange.request.method.toUpperCase();return $s.includes(e)?[...$s]:[...$s,e]}),s=Q(()=>i.bodyEditable&&Rs(i.body)!==null);function c(){i.body=Rs(i.body)??i.body}function l(){i.headers.push({name:``,value:``})}function u(e){i.headers.splice(e,1)}function d(){a.value=nc(i,n.exchange),a.value===null&&r(`send`,rc(i))}return(t,n)=>(W(),G(`form`,{class:`space-y-6 px-4 pt-4`,"aria-label":`Edit and replay`,novalidate:``,onSubmit:Eo(d,[`prevent`])},[q(`div`,Yc,[q(`div`,Xc,[n[4]||=q(`label`,{class:`text-xs font-medium tracking-wider text-muted uppercase`,for:`replay-method`},` Method `,-1),R(q(`select`,{id:`replay-method`,"onUpdate:modelValue":n[0]||=e=>i.method=e,class:E([`mt-1.5`,dl])},[(W(!0),G(U,null,B(o.value,e=>(W(),G(`option`,{key:e,value:e},D(e),9,Zc))),128))],512),[[bo,i.method]])]),q(`div`,Qc,[n[5]||=q(`label`,{class:`text-xs font-medium tracking-wider text-muted uppercase`,for:`replay-path`},`Path`,-1),R(q(`input`,{id:`replay-path`,"onUpdate:modelValue":n[1]||=e=>i.path=e,type:`text`,autocomplete:`off`,spellcheck:`false`,class:E([`mt-1.5`,dl])},null,512),[[vo,i.path]])])]),q(`fieldset`,null,[n[9]||=q(`legend`,{class:`text-xs font-medium tracking-wider text-muted uppercase`},`Headers`,-1),q(`ul`,$c,[(W(!0),G(U,null,B(i.headers,(e,t)=>(W(),G(`li`,{key:t,class:`flex gap-1.5`},[R(q(`input`,{"onUpdate:modelValue":t=>e.name=t,type:`text`,autocomplete:`off`,spellcheck:`false`,placeholder:`Name`,"aria-label":`Header ${t+1} name`,class:E([`basis-2/5`,dl])},null,8,el),[[vo,e.name]]),R(q(`input`,{"onUpdate:modelValue":t=>e.value=t,type:`text`,autocomplete:`off`,spellcheck:`false`,placeholder:`Value`,"aria-label":`Header ${t+1} value`,class:E([`basis-3/5`,dl])},null,8,tl),[[vo,e.value]]),J($,{variant:`quiet`,"aria-label":`Remove header ${e.name||t+1}`,onClick:e=>u(t)},{default:L(()=>[...n[6]||=[Y(` Remove `,-1)]]),_:1},8,[`aria-label`,`onClick`])]))),128))]),q(`div`,nl,[J($,{onClick:l},{default:L(()=>[...n[7]||=[Y(`Add header`,-1)]]),_:1}),n[8]||=q(`span`,{class:`text-xs text-muted`},`Content-Length is set to match the body.`,-1)])]),q(`div`,null,[q(`div`,rl,[n[11]||=q(`label`,{class:`text-xs font-medium tracking-wider text-muted uppercase`,for:`replay-body`},`Body`,-1),s.value?(W(),K($,{key:0,class:`ml-auto`,variant:`quiet`,onClick:c},{default:L(()=>[...n[10]||=[Y(`Format JSON`,-1)]]),_:1})):X(``,!0)]),e.exchange.request.bodyTruncated&&i.bodyEditable?(W(),G(`p`,il,` The log holds only the first part of this body. What you send is exactly the text below. `)):X(``,!0),i.bodyEditable?R((W(),G(`textarea`,{key:1,id:`replay-body`,"onUpdate:modelValue":n[2]||=e=>i.body=e,rows:`12`,spellcheck:`false`,class:E([`mt-1.5 leading-5`,dl])},null,512)),[[vo,i.body]]):(W(),G(`p`,al,` The body is binary and cannot be edited here. It is sent as captured. `))]),q(`div`,ol,[a.value||e.error?(W(),G(`p`,sl,D(a.value??e.error),1)):X(``,!0),q(`div`,cl,[J($,{type:`submit`,variant:`primary`,loading:e.sending},{default:L(()=>[Y(D(e.sending?`Sending`:`Send replay`),1)]),_:1},8,[`loading`]),J($,{disabled:e.sending,onClick:n[3]||=e=>r(`cancel`)},{default:L(()=>[...n[12]||=[Y(`Cancel`,-1)]]),_:1},8,[`disabled`]),e.target?(W(),G(`span`,ll,[n[13]||=Y(` Goes to `,-1),q(`span`,ul,D(e.target),1)])):X(``,!0)])])],32))}}),pl=z({__name:`StatusBadge`,props:{status:{}},setup(e){let t=e,n=Q(()=>Es[Ts(t.status)]);return(t,r)=>(W(),G(`span`,{class:E([`inline-flex shrink-0 rounded-sm px-1.5 py-0.5 font-mono text-xs font-medium tabular-nums`,n.value])},D(e.status),3))}}),ml={class:`space-y-3`,"aria-label":`WebSocket messages`},hl={class:`flex gap-2`},gl=[`value`],_l={key:0,class:`rounded-sm bg-err-bg px-3 py-2 text-sm text-err-fg`,role:`alert`},vl={key:1,class:`text-sm text-muted`},yl={key:2,class:`text-sm text-muted`},bl={key:3,class:`text-sm text-muted`},xl={class:`space-y-2`,"aria-live":`polite`},Sl=[`aria-label`],Cl={class:`flex items-center gap-3 text-xs text-muted`},wl={class:`tabular-nums`},Tl={class:`tabular-nums`},El={key:0,class:`mt-2 rounded-sm bg-warn-bg px-3 py-2 text-sm text-warn-fg`,role:`note`},Dl={class:`mt-2 max-h-80 overflow-auto font-mono text-xs leading-5 break-words whitespace-pre-wrap text-ink`},Ol={key:4,class:`space-y-1 rounded-sm border border-hairline px-3 py-2 text-sm text-muted`,"aria-label":`Close of the WebSocket`},kl={key:0,class:`text-warn-fg`},Al={key:5,class:`text-xs text-muted`},jl=z({__name:`WsMessages`,props:{blocks:{},failure:{}},setup(e){let t=e,n=N(``),r=N(``),i=Q(()=>Hs(t.blocks??[])),a=Q(()=>Ws(i.value.messages,{text:n.value,direction:r.value}).map(e=>({message:e,view:Us(e)}))),o=Q(()=>n.value.trim()!==``||r.value!==``),s=Q(()=>{let e=i.value.close;if(e===null)return``;let t=e.reason===``?``:` and reason "${e.reason}"`;return`Closed by ${Gs(e.by)} with code ${e.code}${t}.`}),c=[{value:``,label:`Both directions`},{value:`in`,label:`Client to service`},{value:`out`,label:`Service to client`}];return(t,l)=>(W(),G(`section`,ml,[q(`div`,hl,[l[2]||=q(`label`,{class:`sr-only`,for:`ws-filter`},`Filter messages`,-1),R(q(`input`,{id:`ws-filter`,"onUpdate:modelValue":l[0]||=e=>n.value=e,type:`search`,placeholder:`Filter by text`,autocomplete:`off`,spellcheck:`false`,class:`min-w-0 flex-1 rounded-sm border border-line-strong bg-well px-2.5 py-1.5 text-sm text-ink placeholder:text-muted`},null,512),[[vo,n.value]]),l[3]||=q(`label`,{class:`sr-only`,for:`ws-direction`},`Filter by direction`,-1),R(q(`select`,{id:`ws-direction`,"onUpdate:modelValue":l[1]||=e=>r.value=e,class:`rounded-sm border border-line-strong bg-well px-2 py-1.5 text-sm text-ink`},[(W(),G(U,null,B(c,e=>q(`option`,{key:e.value,value:e.value},D(e.label),9,gl)),64))],512),[[bo,r.value]])]),e.failure?(W(),G(`p`,_l,D(e.failure),1)):e.blocks===null?(W(),G(`p`,vl,`Loading messages.`)):i.value.messages.length===0&&i.value.close===null?(W(),G(`p`,yl,` No messages yet. New ones appear here as they pass. `)):a.value.length===0&&o.value?(W(),G(`p`,bl,`No message matches the filter.`)):X(``,!0),q(`ol`,xl,[(W(!0),G(U,null,B(a.value,({message:e,view:t})=>(W(),G(`li`,{key:e.position,class:`rounded-sm border border-hairline bg-surface p-3`,"aria-label":`Message ${e.position+1}, ${e.direction===`in`?`client to service`:`service to client`}`},[q(`div`,Cl,[q(`span`,{class:E([`font-mono font-medium`,e.direction===`in`?`text-cyan-text`:`text-green-text`]),"aria-hidden":`true`},D(e.direction===`in`?`Client → service`:`Service → client`),3),q(`span`,wl,`+`+D(e.atMs)+` ms`,1),q(`span`,Tl,D(P(As)(e.length)),1),q(`span`,null,D(t.kind===`json`?`JSON`:t.kind===`text`?`Text`:`Binary`),1),t.kind===`binary`?(W(),K(rs,{key:0,class:`ml-auto`,text:e.dataBase64,label:`Copy message as Base64`},null,8,[`text`])):(W(),K(rs,{key:1,class:`ml-auto`,text:t.kind===`json`?t.formatted:t.text,label:`Copy message`},null,8,[`text`]))]),e.truncated?(W(),G(`p`,El,` Truncated: the log keeps the first `+D(P(As)(65536))+` of this message of `+D(P(As)(e.length))+`. The full message was carried. `,1)):X(``,!0),q(`pre`,Dl,D(t.kind===`json`?t.formatted:t.kind===`text`?t.text:`${t.hex}${t.more?` ...`:``}`),1)],8,Sl))),128))]),i.value.close?(W(),G(`div`,Ol,[q(`p`,null,D(s.value),1),i.value.close.omittedMessages>0?(W(),G(`p`,kl,D(i.value.close.omittedMessages)+` `+D(i.value.close.omittedMessages===1?`message was`:`messages were`)+` not captured: the log keeps up to 2 MB or 10,000 messages per WebSocket. Every message was carried in full. `,1)):X(``,!0)])):e.blocks===null?X(``,!0):(W(),G(`p`,Al,`Open. New messages appear here as they pass.`))]))}}),Ml={class:`mt-1.5 space-y-1.5`},Nl=[`onUpdate:modelValue`,`aria-label`],Pl=[`onUpdate:modelValue`,`aria-label`],Fl={class:`mt-2 flex items-center gap-3`},Il={key:0,class:`mt-1.5 text-sm text-muted`},Ll={class:`mt-1.5 space-y-2`},Rl={class:`flex items-center gap-2 text-xs text-muted`},zl={class:`font-medium text-ink`},Bl={key:0,class:`tabular-nums`},Vl={key:1},Hl={key:0,class:`mt-2 rounded-sm bg-warn-bg px-3 py-2 text-sm text-warn-fg`,role:`note`},Ul={key:1,class:`mt-2 text-sm text-muted`},Wl=[`onUpdate:modelValue`,`aria-label`],Gl={class:`mt-1.5 space-y-1.5 text-sm text-ink`},Kl={class:`flex items-center gap-2`},ql={class:`flex items-center gap-2`},Jl={class:`sticky bottom-0 -mx-4 space-y-3 border-t border-hairline bg-ground px-4 py-3`},Yl={key:0,class:`rounded-sm bg-err-bg px-3 py-2 text-sm text-err-fg`,role:`alert`},Xl={class:`flex items-center gap-3`},Zl={key:0,class:`truncate text-xs text-muted`},Ql={class:`font-mono`},$l=`w-full rounded-sm border border-line-strong bg-well px-2.5 py-1.5 font-mono text-xs text-ink placeholder:text-muted`,eu=`text-xs font-medium tracking-wider text-muted uppercase`,tu=z({__name:`WsReplayEditor`,props:{exchange:{},messages:{},target:{},sending:{type:Boolean},error:{}},emits:[`send`,`cancel`],setup(e,{emit:t}){let n=e,r=t,i=Ht(Ys(n.exchange.request.path,n.exchange.request.headers,n.messages)),a=N(null);function o(){i.headers.push({name:``,value:``})}function s(e){i.headers.splice(e,1)}function c(){i.messages.push(Js())}function l(e){i.messages.splice(e,1)}function u(e,t){let[n]=i.messages.splice(e,1);n!==void 0&&i.messages.splice(e+t,0,n)}function d(){a.value=Zs(i),a.value===null&&r(`send`,Qs(i))}return(t,n)=>(W(),G(`form`,{class:`space-y-6 px-4 pt-4`,"aria-label":`Edit and replay the WebSocket`,novalidate:``,onSubmit:Eo(d,[`prevent`])},[q(`div`,null,[q(`label`,{class:E(eu),for:`ws-replay-path`},`Path`),R(q(`input`,{id:`ws-replay-path`,"onUpdate:modelValue":n[0]||=e=>i.path=e,type:`text`,autocomplete:`off`,spellcheck:`false`,class:E([`mt-1.5`,$l])},null,512),[[vo,i.path]])]),q(`fieldset`,null,[q(`legend`,{class:E(eu)},`Headers`),q(`ul`,Ml,[(W(!0),G(U,null,B(i.headers,(e,t)=>(W(),G(`li`,{key:t,class:`flex gap-1.5`},[R(q(`input`,{"onUpdate:modelValue":t=>e.name=t,type:`text`,autocomplete:`off`,spellcheck:`false`,placeholder:`Name`,"aria-label":`Header ${t+1} name`,class:E([`basis-2/5`,$l])},null,8,Nl),[[vo,e.name]]),R(q(`input`,{"onUpdate:modelValue":t=>e.value=t,type:`text`,autocomplete:`off`,spellcheck:`false`,placeholder:`Value`,"aria-label":`Header ${t+1} value`,class:E([`basis-3/5`,$l])},null,8,Pl),[[vo,e.value]]),J($,{variant:`quiet`,"aria-label":`Remove header ${e.name||t+1}`,onClick:e=>s(t)},{default:L(()=>[...n[4]||=[Y(` Remove `,-1)]]),_:1},8,[`aria-label`,`onClick`])]))),128))]),q(`div`,Fl,[J($,{onClick:o},{default:L(()=>[...n[5]||=[Y(`Add header`,-1)]]),_:1}),n[6]||=q(`span`,{class:`text-xs text-muted`},`The handshake headers of the WebSocket are made anew.`,-1)])]),q(`fieldset`,null,[q(`legend`,{class:E(eu)},`Messages from the client`),i.messages.length===0?(W(),G(`p`,Il,` No messages. The WebSocket opens, waits 5 s for the service and closes. `)):X(``,!0),q(`ol`,Ll,[(W(!0),G(U,null,B(i.messages,(e,t)=>(W(),G(`li`,{key:e.key,class:`rounded-sm border border-hairline bg-surface p-3`},[q(`div`,Rl,[q(`span`,zl,D(t+1),1),q(`span`,null,D(e.binary?`Binary`:`Text`),1),e.atMs===void 0?(W(),G(`span`,Vl,`Added`)):(W(),G(`span`,Bl,`+`+D(e.atMs)+` ms`,1)),J($,{class:`ml-auto`,variant:`quiet`,disabled:t===0,"aria-label":`Move message ${t+1} up`,onClick:e=>u(t,-1)},{default:L(()=>[...n[7]||=[Y(` Up `,-1)]]),_:1},8,[`disabled`,`aria-label`,`onClick`]),J($,{variant:`quiet`,disabled:t===i.messages.length-1,"aria-label":`Move message ${t+1} down`,onClick:e=>u(t,1)},{default:L(()=>[...n[8]||=[Y(` Down `,-1)]]),_:1},8,[`disabled`,`aria-label`,`onClick`]),J($,{variant:`quiet`,"aria-label":`Remove message ${t+1}`,onClick:e=>l(t)},{default:L(()=>[...n[9]||=[Y(` Remove `,-1)]]),_:1},8,[`aria-label`,`onClick`])]),e.truncated?(W(),G(`p`,Hl,[e.binary?(W(),G(U,{key:0},[Y(` Captured only in part (`+D(P(As)(e.length))+` in full), so it cannot be sent. Remove it to replay the rest. `,1)],64)):(W(),G(U,{key:1},[Y(` The log holds only the first part of this message. What you send is exactly the text below. `)],64))])):X(``,!0),e.binary&&!e.truncated?(W(),G(`p`,Ul,` Binary, `+D(P(As)(e.length))+`. It cannot be edited here and is sent as captured. `,1)):e.binary?X(``,!0):R((W(),G(`textarea`,{key:2,"onUpdate:modelValue":t=>e.text=t,rows:`3`,spellcheck:`false`,class:E([`mt-2 leading-5`,$l]),"aria-label":`Text of message ${t+1}`},null,8,Wl)),[[vo,e.text]])]))),128))]),J($,{class:`mt-2`,onClick:c},{default:L(()=>[...n[10]||=[Y(`Add text message`,-1)]]),_:1})]),q(`fieldset`,null,[q(`legend`,{class:E(eu)},`Timing`),q(`div`,Gl,[q(`label`,Kl,[R(q(`input`,{"onUpdate:modelValue":n[1]||=e=>i.timing=e,type:`radio`,name:`ws-timing`,value:`recorded`},null,512),[[yo,i.timing]]),n[11]||=Y(` As recorded: the gaps between the messages, each at most 5 s `,-1)]),q(`label`,ql,[R(q(`input`,{"onUpdate:modelValue":n[2]||=e=>i.timing=e,type:`radio`,name:`ws-timing`,value:`fast`},null,512),[[yo,i.timing]]),n[12]||=Y(` Fast: one message after the other `,-1)])]),n[13]||=q(`p`,{class:`mt-1.5 text-xs text-muted`},` After the last message the WebSocket stays open 5 s for the answers, then it is closed with 1000. `,-1)]),q(`div`,Jl,[a.value||e.error?(W(),G(`p`,Yl,D(a.value??e.error),1)):X(``,!0),q(`div`,Xl,[J($,{type:`submit`,variant:`primary`,loading:e.sending},{default:L(()=>[Y(D(e.sending?`Sending`:`Send replay`),1)]),_:1},8,[`loading`]),J($,{disabled:e.sending,onClick:n[3]||=e=>r(`cancel`)},{default:L(()=>[...n[14]||=[Y(`Cancel`,-1)]]),_:1},8,[`disabled`]),e.target?(W(),G(`span`,Zl,[n[15]||=Y(` Goes to `,-1),q(`span`,Ql,D(e.target),1)])):X(``,!0)])])],32))}}),nu={class:`flex h-full min-h-0 flex-col`,"aria-label":`Request details`},ru={class:`border-b border-hairline p-4`},iu={class:`flex items-start gap-2`},au={class:`min-w-0 flex-1 font-mono text-sm leading-5 font-normal break-all text-ink`},ou={class:`mt-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted`},su={class:`flex gap-1`},cu={class:`text-tag-fg tabular-nums`},lu={class:`flex gap-1`},uu={class:`text-tag-fg tabular-nums`},du={class:`flex gap-1`},fu={class:`text-tag-fg`},pu={class:`flex gap-1`},mu={class:`text-tag-fg`},hu={key:0,class:`flex gap-1`},gu={key:1,class:`flex gap-1`},_u={key:1,class:`font-mono text-tag-fg`},vu={key:0,class:`mt-3 flex flex-wrap items-center gap-2`},yu={key:0,class:`truncate text-xs text-muted`},bu={class:`font-mono`},xu={key:1,class:`mt-2 text-sm text-warn-fg`,role:`note`},Su={key:2,class:`mt-2 rounded-sm bg-err-bg px-3 py-2 text-sm text-err-fg`,role:`alert`},Cu={key:0,class:`min-h-0 flex-1 overflow-y-auto`},wu={class:`flex gap-1 border-b border-hairline px-4`,role:`tablist`,"aria-label":`Message`},Tu=[`id`,`aria-selected`,`onClick`],Eu=[`aria-labelledby`],Du=z({__name:`ExchangeDetail`,props:{record:{},status:{},originalLoaded:{type:Boolean},replay:{},wsBlocks:{default:null},wsFailure:{default:null},logs:{default:()=>[]}},emits:[`select`,`load-messages`,`load-logs`],setup(e,{emit:t}){let n=e,r=t,i=N(`request`),a=N(!1),o=N(!1),s=N(null),c=Q(()=>n.record.exchange),l=Q(()=>ms(c.value)),u=Q(()=>[`request`,`response`,...l.value?[`messages`]:[],...n.logs.length>0?[`logs`]:[]]),d=N(!1);function f(e){return e===`logs`?`Logs ${n.logs.length}`:e}function p(e){i.value=e,d.value=!0}let m=Q(()=>Hs(n.wsBlocks??[]).messages),h=Q(()=>oc(n.status,c.value)),g=Q(()=>{let e=ac(n.status,c.value,m.value);if(l.value&&n.wsBlocks===null&&e.replay===null){let t=`The messages of this WebSocket are still loading.`;return{replay:t,editAndReplay:e.editAndReplay??t}}return e}),_=Q(()=>g.value.replay);Vn(()=>[c.value.id,n.record.origin],()=>{a.value=!1,s.value=null,d.value=!1,u.value.includes(i.value)||(i.value=`request`),l.value&&r(`load-messages`,n.record),r(`load-logs`,n.record)},{immediate:!0}),Vn(()=>[c.value.id,n.logs.length>0],([,e])=>{e&&!d.value&&c.value.response.status>=500?i.value=`logs`:!e&&i.value===`logs`&&(i.value=`request`)},{immediate:!0});async function v(e){o.value=!0,s.value=null;try{let t=await n.replay(n.record,e);a.value=!1,i.value=l.value&&ms(t)?`messages`:`response`,r(`select`,t.id)}catch(e){s.value=e instanceof _s?e.message:`The replay could not be sent.`}finally{o.value=!1}}function y(){s.value=null,a.value=!0}return(t,n)=>(W(),G(`article`,nu,[q(`header`,ru,[q(`div`,iu,[J(Uc,{method:c.value.request.method},null,8,[`method`]),q(`h2`,au,D(c.value.request.path),1),J(pl,{status:c.value.response.status},null,8,[`status`])]),q(`dl`,ou,[q(`div`,su,[n[4]||=q(`dt`,null,`Time`,-1),q(`dd`,cu,D(P(Ms)(c.value.timestamp)),1)]),q(`div`,lu,[n[5]||=q(`dt`,null,`Duration`,-1),q(`dd`,uu,D(P(ks)(c.value.response.durationMs)),1)]),q(`div`,du,[n[6]||=q(`dt`,null,`Source`,-1),q(`dd`,fu,D(P(Os)(c.value.source)),1)]),q(`div`,pu,[n[7]||=q(`dt`,null,`Service`,-1),q(`dd`,mu,D(c.value.serviceName),1)]),e.record.origin===`remote`?(W(),G(`div`,hu,[...n[8]||=[q(`dt`,null,`Origin`,-1),q(`dd`,{class:`text-tag-fg`},`remote log`,-1)]])):X(``,!0),c.value.replayOf?(W(),G(`div`,gu,[n[9]||=q(`dt`,null,`Replay of`,-1),q(`dd`,null,[e.originalLoaded?(W(),G(`button`,{key:0,type:`button`,class:`cursor-pointer rounded-sm font-mono text-ink underline decoration-line-strong underline-offset-2 transition-colors duration-150 ease-out hover:decoration-ink`,onClick:n[0]||=e=>r(`select`,c.value.replayOf)},D(c.value.replayOf.slice(0,8)),1)):(W(),G(`span`,_u,D(c.value.replayOf.slice(0,8)),1))])])):X(``,!0)]),a.value?X(``,!0):(W(),G(`div`,vu,[J($,{variant:`primary`,loading:o.value,disabled:_.value!==null,onClick:n[1]||=e=>v()},{default:L(()=>[Y(D(o.value?`Sending`:`Replay`),1)]),_:1},8,[`loading`,`disabled`]),J($,{disabled:o.value||g.value.editAndReplay!==null,onClick:y},{default:L(()=>[...n[10]||=[Y(` Edit & Replay `,-1)]]),_:1},8,[`disabled`]),h.value&&_.value===null?(W(),G(`span`,yu,[n[11]||=Y(` Goes to `,-1),q(`span`,bu,D(h.value),1)])):X(``,!0)])),!a.value&&_.value?(W(),G(`p`,xu,D(_.value),1)):X(``,!0),!a.value&&s.value?(W(),G(`p`,Su,D(s.value),1)):X(``,!0)]),a.value?(W(),G(`div`,Cu,[l.value?(W(),K(tu,{key:`ws-${c.value.id}`,exchange:c.value,messages:m.value,target:h.value,sending:o.value,error:s.value,onSend:v,onCancel:n[2]||=e=>a.value=!1},null,8,[`exchange`,`messages`,`target`,`sending`,`error`])):(W(),K(fl,{key:c.value.id,exchange:c.value,target:h.value,sending:o.value,error:s.value,onSend:v,onCancel:n[3]||=e=>a.value=!1},null,8,[`exchange`,`target`,`sending`,`error`]))])):(W(),G(U,{key:1},[q(`div`,wu,[(W(!0),G(U,null,B(u.value,e=>(W(),G(`button`,{id:`tab-${e}`,key:e,type:`button`,role:`tab`,"aria-selected":i.value===e,"aria-controls":`message-panel`,class:E([`-mb-px cursor-pointer border-b-2 px-3 py-2 text-sm font-medium capitalize transition-colors duration-150 ease-out focus-visible:-outline-offset-2`,i.value===e?`border-ink text-ink`:`border-transparent text-muted hover:text-ink`]),onClick:t=>p(e)},D(f(e)),11,Tu))),128))]),q(`div`,{id:`message-panel`,class:`min-h-0 flex-1 overflow-y-auto p-4`,role:`tabpanel`,"aria-labelledby":`tab-${i.value}`},[i.value===`request`?(W(),K(Vc,{key:0,headers:c.value.request.headers,"body-base64":c.value.request.bodyBase64,"body-truncated":c.value.request.bodyTruncated},null,8,[`headers`,`body-base64`,`body-truncated`])):i.value===`messages`?(W(),K(jl,{key:1,blocks:e.wsBlocks,failure:e.wsFailure},null,8,[`blocks`,`failure`])):i.value===`logs`?(W(),K(kc,{key:2,items:e.logs,"exchange-id":c.value.id},null,8,[`items`,`exchange-id`])):(W(),K(Vc,{key:3,headers:c.value.response.headers,"body-base64":c.value.response.bodyBase64,"body-truncated":c.value.response.bodyTruncated},null,8,[`headers`,`body-base64`,`body-truncated`]))],8,Eu)],64))]))}});function Ou(e){return`${e.origin}:${e.index}`}function ku(e,t){let n=new Map;for(let t of e)n.set(Ou(t),t);for(let e of t)n.set(Ou(e),e);return[...n.values()].sort((e,t)=>t.exchange.timestamp-e.exchange.timestamp||t.index-e.index)}function Au(e,t){let n=t.text.toLowerCase().split(/\s+/).filter(Boolean);return e.filter(({exchange:e})=>{if(t.service!==``&&e.serviceName!==t.service)return!1;let r=`${e.request.method} ${e.request.path} ${e.response.status} ${e.serviceName} ${e.source}${ms(e)?` ws`:``}`.toLowerCase();return n.every(e=>r.includes(e))})}function ju(e,t){return[...new Set([...t,...e.map(e=>e.exchange.serviceName)])].sort()}function Mu(e){return e?[`remote`,`own`]:[`own`]}function Nu(e,t){return e.reduce((e,n)=>n.origin===t&&(e===null||n.index<e)?n.index:e,null)}function Pu(e){let t=[];for(let n of[`remote`,`own`]){let r=Nu(e,n);r!==null&&r>0&&t.push({origin:n,before:r})}return t}var Fu={class:`flex h-full min-h-0 flex-col`},Iu={class:`flex gap-2 border-b border-hairline p-2`},Lu=[`value`],Ru={key:0,class:`p-4 text-sm text-muted`},zu={class:`min-h-0 flex-1 overflow-y-auto`,"aria-label":`Requests, newest first`},Bu=[`aria-current`,`onClick`],Vu={class:`flex items-center gap-2`},Hu=[`title`],Uu={class:`mt-1 flex items-center gap-2 text-xs text-muted`},Wu={class:`tabular-nums`},Gu={class:`tabular-nums`},Ku={key:0,class:`rounded-sm bg-tag-bg px-1.5 py-px font-medium text-tag-fg`,title:`WebSocket handshake; its messages are in the Messages tab`},qu={key:1,class:`rounded-sm bg-info-bg px-1.5 py-px font-medium text-info-fg`},Ju={key:2,class:`truncate`},Yu={key:0,class:`p-2 text-center`},Xu=z({__name:`ExchangeList`,props:{records:{},services:{},selectedKey:{},hasOlder:{type:Boolean},loadingOlder:{type:Boolean}},emits:[`select`,`load-older`],setup(e,{emit:t}){let n=e,r=t,i=N(``),a=N(``),o=Q(()=>n.services.length>1),s=Q(()=>Au(n.records,{text:i.value,service:a.value})),c=Q(()=>i.value.trim()!==``||a.value!==``);return(t,n)=>(W(),G(`div`,Fu,[q(`div`,Iu,[n[5]||=q(`label`,{class:`sr-only`,for:`traffic-filter`},`Filter requests`,-1),R(q(`input`,{id:`traffic-filter`,"onUpdate:modelValue":n[0]||=e=>i.value=e,type:`search`,placeholder:`Filter by method, path or status`,autocomplete:`off`,spellcheck:`false`,class:`min-w-0 flex-1 rounded-sm border border-line-strong bg-well px-2.5 py-1.5 text-sm text-ink placeholder:text-muted`},null,512),[[vo,i.value]]),o.value?(W(),G(U,{key:0},[n[4]||=q(`label`,{class:`sr-only`,for:`traffic-service`},`Filter by service`,-1),R(q(`select`,{id:`traffic-service`,"onUpdate:modelValue":n[1]||=e=>a.value=e,class:`rounded-sm border border-line-strong bg-well px-2 py-1.5 text-sm text-ink`},[n[3]||=q(`option`,{value:``},`All services`,-1),(W(!0),G(U,null,B(e.services,e=>(W(),G(`option`,{key:e,value:e},D(e),9,Lu))),128))],512),[[bo,a.value]])],64)):X(``,!0)]),s.value.length===0?(W(),G(`p`,Ru,D(c.value?`No request matches the filter.`:`No requests yet.`),1)):X(``,!0),q(`ul`,zu,[(W(!0),G(U,null,B(s.value,t=>(W(),G(`li`,{key:P(Ou)(t)},[q(`button`,{type:`button`,class:E([`block w-full cursor-pointer border-b border-l-2 border-b-hairline px-3 py-2 text-left transition-colors duration-150 ease-out focus-visible:-outline-offset-2`,P(Ou)(t)===e.selectedKey?`border-l-ink bg-surface`:`border-l-transparent hover:bg-surface/60`]),"aria-current":P(Ou)(t)===e.selectedKey?`true`:void 0,onClick:e=>r(`select`,P(Ou)(t))},[q(`span`,Vu,[J(Uc,{method:t.exchange.request.method},null,8,[`method`]),q(`span`,{class:`min-w-0 flex-1 truncate font-mono text-sm text-ink`,title:t.exchange.request.path},D(t.exchange.request.path),9,Hu),J(pl,{status:t.exchange.response.status},null,8,[`status`])]),q(`span`,Uu,[q(`span`,Wu,D(P(Ms)(t.exchange.timestamp)),1),q(`span`,Gu,D(P(ks)(t.exchange.response.durationMs)),1),q(`span`,{class:E([`rounded-sm px-1.5 py-px font-medium`,t.exchange.source===`replay`?`bg-warn-bg text-warn-fg`:`bg-tag-bg text-tag-fg`])},D(P(Os)(t.exchange.source)),3),P(ms)(t.exchange)?(W(),G(`span`,Ku,` ws `)):X(``,!0),t.origin===`remote`?(W(),G(`span`,qu,` remote `)):X(``,!0),o.value?(W(),G(`span`,Ju,D(t.exchange.serviceName),1)):X(``,!0)])],10,Bu)]))),128)),e.hasOlder?(W(),G(`li`,Yu,[J($,{variant:`quiet`,loading:e.loadingOlder,onClick:n[2]||=e=>r(`load-older`)},{default:L(()=>[Y(D(e.loadingOlder?`Loading`:`Load older requests`),1)]),_:1},8,[`loading`])])):X(``,!0)])]))}}),Zu={class:`flex h-full min-h-0 flex-col`,"aria-label":`Application logs`},Qu={class:`flex flex-wrap gap-2 border-b border-hairline px-4 py-2`},$u=[`value`],ed=[`value`],td={key:0,class:`rounded-sm bg-warn-bg px-3 py-2 text-sm text-warn-fg`,role:`note`},nd={key:1,class:`text-sm text-muted`},rd={key:2,class:`text-sm text-muted`},id=z({__name:`LogPane`,props:{items:{},omitted:{}},emits:[`select`],setup(e,{emit:t}){let n=e,r=t,i=N(``),a=N(``),o=N(``),s=Q(()=>[...new Set(n.items.map(e=>e.source))].sort()),c=Q(()=>pc(n.items,{text:i.value,source:a.value,level:o.value})),l=Q(()=>i.value.trim()!==``||a.value!==``||o.value!==``),u=[`error`,`warning`,`info`,`debug`],d=N(null),f=!0;function p(){let e=d.value;e!==null&&(f=e.scrollHeight-e.scrollTop-e.clientHeight<40)}async function m(){await Cn(),f&&d.value!==null&&(d.value.scrollTop=d.value.scrollHeight)}return pr(m),Vn(()=>c.value.length,m),(t,n)=>(W(),G(`section`,Zu,[q(`div`,Qu,[n[6]||=q(`label`,{class:`sr-only`,for:`log-filter`},`Filter log entries`,-1),R(q(`input`,{id:`log-filter`,"onUpdate:modelValue":n[0]||=e=>i.value=e,type:`search`,placeholder:`Filter by text`,autocomplete:`off`,spellcheck:`false`,class:`min-w-0 flex-1 rounded-sm border border-line-strong bg-well px-2.5 py-1.5 text-sm text-ink placeholder:text-muted`},null,512),[[vo,i.value]]),n[7]||=q(`label`,{class:`sr-only`,for:`log-source`},`Filter by file`,-1),R(q(`select`,{id:`log-source`,"onUpdate:modelValue":n[1]||=e=>a.value=e,class:`rounded-sm border border-line-strong bg-well px-2 py-1.5 text-sm text-ink`},[n[4]||=q(`option`,{value:``},`All files`,-1),(W(!0),G(U,null,B(s.value,e=>(W(),G(`option`,{key:e,value:e},D(e),9,$u))),128))],512),[[bo,a.value]]),n[8]||=q(`label`,{class:`sr-only`,for:`log-level`},`Filter by level`,-1),R(q(`select`,{id:`log-level`,"onUpdate:modelValue":n[2]||=e=>o.value=e,class:`rounded-sm border border-line-strong bg-well px-2 py-1.5 text-sm text-ink`},[n[5]||=q(`option`,{value:``},`All levels`,-1),(W(),G(U,null,B(u,e=>q(`option`,{key:e,value:e},D(P(_c)[e]),9,ed)),64))],512),[[bo,o.value]])]),q(`div`,{ref_key:`scroller`,ref:d,class:`min-h-0 flex-1 space-y-3 overflow-y-auto p-4`,onScroll:p},[e.omitted.entries>0?(W(),G(`p`,td,D(e.omitted.entries)+` `+D(e.omitted.entries===1?`entry was`:`entries were`)+` (`+D(P(As)(e.omitted.bytes))+`) not captured: a log file is captured up to 200 entries per second and 10 MB per run. `,1)):X(``,!0),e.items.length===0?(W(),G(`p`,nd,` No log entries yet. Start the tunnel with --log <path> (or logs: in hopwire.yaml) and new entries of the file appear here as they are written. `)):c.value.length===0&&l.value?(W(),G(`p`,rd,`No entry matches the filter.`)):X(``,!0),J(kc,{items:c.value,selectable:``,onSelect:n[3]||=e=>r(`select`,e)},null,8,[`items`])],544)]))}}),ad=`hopwire-inspector-theme`;function od(){try{return localStorage.getItem(ad)===`light`?`light`:`dark`}catch{return`dark`}}var sd=N(od());Vn(sd,e=>{document.documentElement.classList.toggle(`dark`,e===`dark`);try{localStorage.setItem(ad,e)}catch{}},{immediate:!0});function cd(){function e(){sd.value=sd.value===`dark`?`light`:`dark`}return{theme:sd,toggleTheme:e}}var ld=[`viewBox`],ud=[`stroke-width`],dd=[`d`,`pathLength`],fd=[`d`],pd=z({__name:`BrandLogo`,props:{animated:{type:Boolean,default:!1}},setup(e){return(t,n)=>(W(),G(`svg`,{viewBox:P(No),role:`img`,"aria-label":`Hopwire`,class:`block w-auto`},[q(`g`,{class:`stroke-mark`,fill:`none`,"stroke-width":P(Fo),"stroke-linecap":`round`,"stroke-linejoin":`round`},[(W(!0),G(U,null,B(P(Io),(t,n)=>(W(),G(`path`,{key:n,d:t,pathLength:e.animated?1:void 0,class:E(e.animated?`hwd-s hwd-s${n+1}`:void 0)},null,10,dd))),128))],8,ud),q(`g`,{class:E(e.animated?`hwd-w`:void 0)},[q(`path`,{class:`fill-ink`,d:P(Lo)},null,8,fd)],2)],8,ld))}}),md={class:`flex flex-wrap items-center gap-x-5 gap-y-2 border-b border-hairline bg-surface px-4 py-2.5 text-sm`},hd={class:`flex items-center gap-2.5 font-normal`},gd={key:0,class:`inline-flex items-center gap-1.5 rounded-full bg-tag-bg px-2 py-0.5 text-xs font-medium text-tag-fg`},_d={key:1,class:`rounded-full bg-info-bg px-2 py-0.5 text-xs font-medium text-info-fg`},vd={key:2,class:`order-last flex w-full min-w-0 flex-wrap items-center gap-x-5 gap-y-1 lg:order-none lg:w-auto lg:flex-1`},yd={class:`truncate font-mono text-xs text-ink`},bd={key:0,class:`flex items-center gap-1.5`},xd=[`title`],Sd={class:`flex items-center gap-1.5`},Cd=[`title`],wd={class:`flex min-w-0 items-center gap-1.5`},Td={key:0,class:`truncate font-mono text-xs text-ink`},Ed={class:`ml-auto flex items-center gap-3`},Dd={class:`flex items-center gap-1.5 text-xs text-tag-fg`,role:`status`},Od=z({__name:`StatusBar`,props:{status:{},stream:{},logCount:{default:0},logsOpen:{type:Boolean,default:!1}},emits:[`toggle-logs`],setup(e,{emit:t}){let n=e,r=t,{theme:i,toggleTheme:a}=cd(),o=Q(()=>n.status===null?null:sc(n.status));return(t,n)=>(W(),G(`header`,md,[q(`h1`,hd,[J(pd,{class:`h-6`}),n[1]||=q(`span`,{class:`text-muted`},`Inspector`,-1)]),e.status?(W(),G(`span`,gd,[q(`span`,{class:E([`size-2 rounded-full border-[1.5px]`,e.status.mode===`public`?`border-link-blue bg-link-blue`:`border-cyan-text bg-wire-cyan`]),"aria-hidden":`true`},null,2),Y(` `+D(e.status.mode===`public`?`Public mode`:`Private mode`),1)])):X(``,!0),e.status?.watching?(W(),G(`span`,_d,` Watching a shared log `)):X(``,!0),e.status?(W(),G(`dl`,vd,[(W(!0),G(U,null,B(e.status.publicUrls,e=>(W(),G(`div`,{key:e,class:`flex min-w-0 items-center gap-1.5`},[n[2]||=q(`dt`,{class:`text-muted`},`Public URL`,-1),q(`dd`,yd,D(e),1),J(rs,{text:e,label:`Copy public URL`},null,8,[`text`])]))),128)),e.status.peerKey?(W(),G(`div`,bd,[n[3]||=q(`dt`,{class:`text-muted`},`Peer key`,-1),q(`dd`,{class:`font-mono text-xs text-ink`,title:e.status.peerKey},D(P(Ns)(e.status.peerKey)),9,xd),J(rs,{text:e.status.peerKey,label:`Copy peer key`},null,8,[`text`])])):X(``,!0),q(`div`,Sd,[n[4]||=q(`dt`,{class:`text-muted`},`Log key`,-1),q(`dd`,{class:`font-mono text-xs text-ink`,title:e.status.logKey},D(P(Ns)(e.status.logKey)),9,Cd),J(rs,{text:e.status.logKey,label:`Copy log key`},null,8,[`text`])]),q(`div`,wd,[n[5]||=q(`dt`,{class:`text-muted`},`Replay target`,-1),e.status.replayTarget?(W(),G(`dd`,Td,D(e.status.replayTarget),1)):o.value?(W(),G(`dd`,{key:1,class:E([`text-xs`,o.value.missing?`text-warn-fg`:`text-tag-fg`])},D(o.value.text),3)):X(``,!0)])])):X(``,!0),q(`div`,Ed,[q(`span`,Dd,[P($o)(e.stream)?(W(),K(qc,{key:0,class:`h-3.5`})):(W(),G(`span`,{key:1,class:E([`size-2 rounded-full`,e.stream===`live`?`bg-hop-green`:`border-[1.5px] border-muted`]),"aria-hidden":`true`},null,2)),Y(` `+D(P(Zo)[e.stream]),1)]),e.logCount>0||e.logsOpen?(W(),K($,{key:0,variant:`quiet`,"aria-pressed":e.logsOpen,"aria-controls":`log-pane`,onClick:n[0]||=e=>r(`toggle-logs`)},{default:L(()=>[Y(D(e.logsOpen?`Hide logs`:`Logs ${e.logCount}`),1)]),_:1},8,[`aria-pressed`])):X(``,!0),J($,{variant:`quiet`,"aria-label":`Switch to ${P(i)===`dark`?`light`:`dark`} mode`,onClick:P(a)},{default:L(()=>[Y(D(P(i)===`dark`?`Light`:`Dark`),1)]),_:1},8,[`aria-label`,`onClick`])])]))}}),kd=100;function Ad(){let e=N(null),t=$t([]),n=N(`connecting`),r=N(!1),i=N(!1),a=N(null),o=null,s=!1,c=$t(new Map),l=$t(new Map),u=$t([]),d=N({entries:0,bytes:0});function f(e){u.value=uc(u.value,lc(e));let t=dc(e);t.entries>0&&(d.value={entries:d.value.entries+t.entries,bytes:d.value.bytes+t.bytes})}async function p(e){try{let t=await Cs({exchangeId:e.exchange.id,origin:e.origin});u.value=uc(u.value,lc(t.blocks))}catch{}}async function m(){try{let e=await Cs({limit:500});u.value=uc(u.value,lc(e.blocks))}catch{}}function h(e,t){let n=new Map(c.value);n.set(e,t),c.value=n}async function g(e){let t=Bs(e.origin,e.exchange.id);c.value.has(t)||h(t,[]);try{let n=await Ss(e.origin,e.exchange.id);if(h(t,Vs(c.value.get(t)??[],n)),l.value.has(t)){let e=new Map(l.value);e.delete(t),l.value=e}}catch(e){let n=new Map(l.value);n.set(t,e instanceof _s?e.message:`The messages could not be loaded.`),l.value=n}}let _=Q(()=>Pu(t.value).length>0),v=Q(()=>a.value??(n.value===`closed`?`The connection to the tunnel is closed. Reload the page to connect again.`:null)),y=Q(()=>!r.value&&v.value===null);async function b(){r.value||(a.value=null);try{let n=await bs(),i=(await Promise.all(Mu(n.watching).map(e=>xs({origin:e,limit:kd})))).flat(),o=e.value===null||e.value.logKey===n.logKey;e.value=n,t.value=ku(o?t.value:[],i),r.value=!0,a.value=null,o||(c.value=new Map,u.value=[],d.value={entries:0,bytes:0}),m();for(let e of c.value.keys()){let n=t.value.find(t=>Bs(t.origin,t.exchange.id)===e);n!==void 0&&g(n)}}catch(e){a.value=e instanceof _s?e.message:`The traffic could not be loaded.`}}function x(){let e=new EventSource(`${vs}stream`);o=e,e.addEventListener(`open`,()=>{s=!0,n.value=`live`,b()}),e.addEventListener(`exchange`,e=>{let n=JSON.parse(e.data);t.value=ku(t.value,[n])}),e.addEventListener(`ws_messages`,e=>{let{origin:t,block:n}=JSON.parse(e.data),r=Bs(t,n.exchangeId),i=c.value.get(r);i!==void 0&&h(r,Vs(i,[n]))}),e.addEventListener(`log_entries`,e=>{f([JSON.parse(e.data)])}),e.addEventListener(`error`,()=>{n.value=Qo(e.readyState===EventSource.CLOSED,s)})}function ee(){o?.close(),o=null,n.value=`closed`}async function S(){let e=Pu(t.value);if(!(e.length===0||i.value)){i.value=!0;try{let n=await Promise.all(e.map(e=>xs({...e,limit:kd})));t.value=ku(t.value,n.flat())}catch(e){a.value=e instanceof _s?e.message:`Older requests could not be loaded.`}finally{i.value=!1}}}async function C(e,n){let r=await ws(e,n);return t.value.some(e=>e.exchange.id===r.id)||await b(),r}return{status:e,records:t,stream:n,connecting:y,loaded:r,loadingOlder:i,problem:v,hasOlder:_,start:x,stop:ee,loadOlder:S,replay:C,wsSessions:c,wsFailures:l,loadWsMessages:g,logs:u,logsOmitted:d,loadExchangeLogs:p}}function jd(){let e=Ad();return gr(e.stop),e}var Md={class:`flex h-dvh flex-col bg-ground text-ink`},Nd={key:0,class:`border-b border-hairline bg-err-bg px-4 py-2 text-sm text-err-fg`,role:`alert`},Pd={class:`min-h-0 flex-1`},Fd={key:2,class:`flex h-full min-h-0 flex-col md:flex-row`},Id={class:`h-2/5 min-h-0 shrink-0 border-b border-hairline md:h-full md:w-2/5 md:max-w-xl md:min-w-80 md:border-r md:border-b-0`,"aria-label":`Traffic`},Ld={class:`min-h-0 min-w-0 flex-1`},Rd={key:1,class:`flex h-full items-center justify-center p-8 text-sm text-muted`},zd={key:1,id:`log-pane`,class:`h-2/5 min-h-0 shrink-0 border-t border-hairline`};Ao(z({__name:`App`,setup(e){let{status:t,records:n,stream:r,connecting:i,loaded:a,loadingOlder:o,problem:s,hasOlder:c,start:l,loadOlder:u,replay:d,wsSessions:f,wsFailures:p,loadWsMessages:m,logs:h,logsOmitted:g,loadExchangeLogs:_}=jd(),v=N(!1),y=N(null),b=Q(()=>n.value.find(e=>Ou(e)===y.value)??null);function x(e){let t=n.value.find(t=>t.exchange.id===e);y.value=t===void 0?null:Ou(t)}let ee=Q(()=>ju(n.value,(t.value?.services??[]).map(e=>e.name))),S=Q(()=>b.value===null?null:Bs(b.value.origin,b.value.exchange.id)),C=Q(()=>S.value===null?null:f.value.get(S.value)??null),te=Q(()=>S.value===null?null:p.value.get(S.value)??null),ne=Q(()=>b.value===null?[]:fc(h.value,b.value.origin,b.value.exchange.id));function re(e){let t=n.value.find(t=>t.origin===e.origin&&e.entry.exchangeIds.includes(t.exchange.id));t!==void 0&&(y.value=Ou(t))}let ie=Q(()=>{let e=b.value?.exchange.replayOf;return e!==void 0&&n.value.some(t=>t.exchange.id===e)});return pr(l),(e,l)=>(W(),G(`div`,Md,[J(Od,{status:P(t),stream:P(r),"log-count":P(h).length,"logs-open":v.value,onToggleLogs:l[0]||=e=>v.value=!v.value},null,8,[`status`,`stream`,`log-count`,`logs-open`]),P(s)?(W(),G(`p`,Nd,D(P(s)),1)):X(``,!0),q(`main`,Pd,[P(a)?P(n).length===0?(W(),K(ps,{key:1,status:P(t),stream:P(r)},null,8,[`status`,`stream`])):(W(),G(`div`,Fd,[q(`section`,Id,[J(Xu,{records:P(n),services:ee.value,"selected-key":y.value,"has-older":P(c),"loading-older":P(o),onSelect:l[1]||=e=>y.value=e,onLoadOlder:P(u)},null,8,[`records`,`services`,`selected-key`,`has-older`,`loading-older`,`onLoadOlder`])]),q(`section`,Ld,[b.value?(W(),K(Du,{key:0,record:b.value,status:P(t),"original-loaded":ie.value,replay:P(d),"ws-blocks":C.value,"ws-failure":te.value,logs:ne.value,onSelect:x,onLoadMessages:P(m),onLoadLogs:P(_)},null,8,[`record`,`status`,`original-loaded`,`replay`,`ws-blocks`,`ws-failure`,`logs`,`onLoadMessages`,`onLoadLogs`])):(W(),G(`div`,Rd,` Select a request to see its headers and body. `))])])):(W(),K(Xo,{key:0,connecting:P(i)},null,8,[`connecting`]))]),v.value?(W(),G(`div`,zd,[J(id,{items:P(h),omitted:P(g),onSelect:re},null,8,[`items`,`omitted`])])):X(``,!0)]))}})).mount(`#app`);
|
|
5
|
+
`),3))),128))])],10,yc))),128))]))}}),Ac={class:`space-y-6`},jc={key:0,class:`mt-2 text-sm text-muted`},Mc={key:1,class:`mt-2 w-full table-fixed border-collapse text-left font-mono text-xs`},Nc={scope:`row`,class:`w-2/5 py-1.5 pr-3 font-normal break-words text-muted`},Pc={class:`py-1.5 break-all text-ink`},Fc={class:`flex items-center gap-3`},Ic={key:0,class:`text-xs text-muted`},Lc={key:0,class:`mt-2 rounded-sm bg-warn-bg px-3 py-2 text-sm text-warn-fg`,role:`note`},Rc={key:1,class:`mt-2 text-sm text-muted`},zc={key:2,class:`mt-2 text-sm text-muted`},Bc={key:3,class:`mt-2 max-h-[60vh] overflow-auto rounded-sm border border-hairline bg-surface p-3 font-mono text-xs leading-5 break-words whitespace-pre-wrap text-ink`},Vc=z({__name:`MessageView`,props:{headers:{},bodyBase64:{},bodyTruncated:{type:Boolean}},setup(e){let t=e,n=Q(()=>zs(t.bodyBase64,t.bodyTruncated)),r=Q(()=>n.value.kind===`json`?n.value.formatted:n.value.kind===`text`?n.value.text:null),i=Q(()=>{switch(n.value.kind){case`empty`:return``;case`json`:return`JSON, ${As(n.value.bytes)}`;case`text`:return`Text, ${As(n.value.bytes)}`;case`binary`:return`Binary, ${As(n.value.bytes)}`}return``});return(t,a)=>(W(),G(`div`,Ac,[q(`section`,null,[a[1]||=q(`h3`,{class:`text-xs font-medium tracking-wider text-muted uppercase`},`Headers`,-1),e.headers.length===0?(W(),G(`p`,jc,`No headers.`)):(W(),G(`table`,Mc,[a[0]||=q(`thead`,{class:`sr-only`},[q(`tr`,null,[q(`th`,{scope:`col`},`Name`),q(`th`,{scope:`col`},`Value`)])],-1),q(`tbody`,null,[(W(!0),G(U,null,B(e.headers,(e,t)=>(W(),G(`tr`,{key:t,class:`border-b border-hairline align-top`},[q(`th`,Nc,D(e[0]),1),q(`td`,Pc,D(e[1]),1)]))),128))])]))]),q(`section`,null,[q(`div`,Fc,[a[2]||=q(`h3`,{class:`text-xs font-medium tracking-wider text-muted uppercase`},`Body`,-1),i.value?(W(),G(`span`,Ic,D(i.value),1)):X(``,!0),r.value===null?X(``,!0):(W(),K(rs,{key:1,class:`ml-auto`,text:r.value,label:`Copy body`},null,8,[`text`]))]),e.bodyTruncated?(W(),G(`p`,Lc,` Truncated: the log keeps only the first `+D(P(As)(n.value.kind===`empty`?0:n.value.bytes))+` of this body. The full body was forwarded. `,1)):X(``,!0),n.value.kind===`empty`?(W(),G(`p`,Rc,`No body.`)):n.value.kind===`binary`?(W(),G(`p`,zc,D(P(js)(n.value.bytes,e.bodyTruncated)),1)):(W(),G(`pre`,Bc,D(r.value),1))])]))}}),Hc={class:`inline-flex shrink-0 rounded-sm bg-tag-bg px-1.5 py-0.5 font-mono text-xs font-medium text-tag-fg`},Uc=z({__name:`MethodBadge`,props:{method:{}},setup(e){return(t,n)=>(W(),G(`span`,Hc,D(e.method),1))}}),Wc=[`viewBox`],Gc=[`stroke-width`],Kc=[`d`],qc=z({__name:`MarkLoader`,setup(e){return(e,t)=>(W(),G(`svg`,{viewBox:P(Po),"aria-hidden":`true`,focusable:`false`,class:`block w-auto shrink-0`},[q(`g`,{class:`stroke-current`,fill:`none`,"stroke-width":P(Fo),"stroke-linecap":`round`,"stroke-linejoin":`round`},[(W(!0),G(U,null,B(P(Io),(e,t)=>(W(),G(`path`,{key:t,d:e,pathLength:`1`,class:E(`hwl hwl-${t+1}`)},null,10,Kc))),128))],8,Gc)],8,Wc))}}),Jc=[`type`,`disabled`,`aria-busy`],$=z({__name:`UiButton`,props:{variant:{default:`secondary`},type:{default:`button`},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}},setup(e){let t={primary:`border border-transparent bg-hop-green text-on-green hover:bg-ink hover:text-ground disabled:hover:bg-hop-green disabled:hover:text-on-green`,secondary:`border border-line-strong text-ink hover:border-ink disabled:hover:border-line-strong`,quiet:`border border-transparent text-muted hover:bg-ink/8 hover:text-ink disabled:hover:bg-transparent disabled:hover:text-muted`};return(n,r)=>(W(),G(`button`,{type:e.type,disabled:e.disabled||e.loading,"aria-busy":e.loading?`true`:void 0,class:E([`inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium transition-colors duration-150 ease-out disabled:cursor-not-allowed disabled:opacity-60`,t[e.variant]])},[e.loading?(W(),K(qc,{key:0,class:`h-4`})):X(``,!0),Cr(n.$slots,`default`)],10,Jc))}}),Yc={class:`flex gap-3`},Xc={class:`w-32 shrink-0`},Zc=[`value`],Qc={class:`min-w-0 flex-1`},$c={class:`mt-1.5 space-y-1.5`},el=[`onUpdate:modelValue`,`aria-label`],tl=[`onUpdate:modelValue`,`aria-label`],nl={class:`mt-2 flex items-center gap-3`},rl={class:`flex items-center gap-3`},il={key:0,class:`mt-1.5 rounded-sm bg-warn-bg px-3 py-2 text-sm text-warn-fg`,role:`note`},al={key:2,class:`mt-1.5 text-sm text-muted`},ol={class:`sticky bottom-0 -mx-4 space-y-3 border-t border-hairline bg-ground px-4 py-3`},sl={key:0,class:`rounded-sm bg-err-bg px-3 py-2 text-sm text-err-fg`,role:`alert`},cl={class:`flex items-center gap-3`},ll={key:0,class:`truncate text-xs text-muted`},ul={class:`font-mono`},dl=`w-full rounded-sm border border-line-strong bg-well px-2.5 py-1.5 font-mono text-xs text-ink placeholder:text-muted`,fl=z({__name:`ReplayEditor`,props:{exchange:{},target:{},sending:{type:Boolean},error:{}},emits:[`send`,`cancel`],setup(e,{emit:t}){let n=e,r=t,i=Ht(tc(n.exchange)),a=N(null),o=Q(()=>{let e=n.exchange.request.method.toUpperCase();return $s.includes(e)?[...$s]:[...$s,e]}),s=Q(()=>i.bodyEditable&&Rs(i.body)!==null);function c(){i.body=Rs(i.body)??i.body}function l(){i.headers.push({name:``,value:``})}function u(e){i.headers.splice(e,1)}function d(){a.value=nc(i,n.exchange),a.value===null&&r(`send`,rc(i))}return(t,n)=>(W(),G(`form`,{class:`space-y-6 px-4 pt-4`,"aria-label":`Edit and replay`,novalidate:``,onSubmit:Eo(d,[`prevent`])},[q(`div`,Yc,[q(`div`,Xc,[n[4]||=q(`label`,{class:`text-xs font-medium tracking-wider text-muted uppercase`,for:`replay-method`},` Method `,-1),R(q(`select`,{id:`replay-method`,"onUpdate:modelValue":n[0]||=e=>i.method=e,class:E([`mt-1.5`,dl])},[(W(!0),G(U,null,B(o.value,e=>(W(),G(`option`,{key:e,value:e},D(e),9,Zc))),128))],512),[[bo,i.method]])]),q(`div`,Qc,[n[5]||=q(`label`,{class:`text-xs font-medium tracking-wider text-muted uppercase`,for:`replay-path`},`Path`,-1),R(q(`input`,{id:`replay-path`,"onUpdate:modelValue":n[1]||=e=>i.path=e,type:`text`,autocomplete:`off`,spellcheck:`false`,class:E([`mt-1.5`,dl])},null,512),[[vo,i.path]])])]),q(`fieldset`,null,[n[9]||=q(`legend`,{class:`text-xs font-medium tracking-wider text-muted uppercase`},`Headers`,-1),q(`ul`,$c,[(W(!0),G(U,null,B(i.headers,(e,t)=>(W(),G(`li`,{key:t,class:`flex gap-1.5`},[R(q(`input`,{"onUpdate:modelValue":t=>e.name=t,type:`text`,autocomplete:`off`,spellcheck:`false`,placeholder:`Name`,"aria-label":`Header ${t+1} name`,class:E([`basis-2/5`,dl])},null,8,el),[[vo,e.name]]),R(q(`input`,{"onUpdate:modelValue":t=>e.value=t,type:`text`,autocomplete:`off`,spellcheck:`false`,placeholder:`Value`,"aria-label":`Header ${t+1} value`,class:E([`basis-3/5`,dl])},null,8,tl),[[vo,e.value]]),J($,{variant:`quiet`,"aria-label":`Remove header ${e.name||t+1}`,onClick:e=>u(t)},{default:L(()=>[...n[6]||=[Y(` Remove `,-1)]]),_:1},8,[`aria-label`,`onClick`])]))),128))]),q(`div`,nl,[J($,{onClick:l},{default:L(()=>[...n[7]||=[Y(`Add header`,-1)]]),_:1}),n[8]||=q(`span`,{class:`text-xs text-muted`},`Content-Length is set to match the body.`,-1)])]),q(`div`,null,[q(`div`,rl,[n[11]||=q(`label`,{class:`text-xs font-medium tracking-wider text-muted uppercase`,for:`replay-body`},`Body`,-1),s.value?(W(),K($,{key:0,class:`ml-auto`,variant:`quiet`,onClick:c},{default:L(()=>[...n[10]||=[Y(`Format JSON`,-1)]]),_:1})):X(``,!0)]),e.exchange.request.bodyTruncated&&i.bodyEditable?(W(),G(`p`,il,` The log holds only the first part of this body. What you send is exactly the text below. `)):X(``,!0),i.bodyEditable?R((W(),G(`textarea`,{key:1,id:`replay-body`,"onUpdate:modelValue":n[2]||=e=>i.body=e,rows:`12`,spellcheck:`false`,class:E([`mt-1.5 leading-5`,dl])},null,512)),[[vo,i.body]]):(W(),G(`p`,al,` The body is binary and cannot be edited here. It is sent as captured. `))]),q(`div`,ol,[a.value||e.error?(W(),G(`p`,sl,D(a.value??e.error),1)):X(``,!0),q(`div`,cl,[J($,{type:`submit`,variant:`primary`,loading:e.sending},{default:L(()=>[Y(D(e.sending?`Sending`:`Send replay`),1)]),_:1},8,[`loading`]),J($,{disabled:e.sending,onClick:n[3]||=e=>r(`cancel`)},{default:L(()=>[...n[12]||=[Y(`Cancel`,-1)]]),_:1},8,[`disabled`]),e.target?(W(),G(`span`,ll,[n[13]||=Y(` Goes to `,-1),q(`span`,ul,D(e.target),1)])):X(``,!0)])])],32))}}),pl=z({__name:`StatusBadge`,props:{status:{}},setup(e){let t=e,n=Q(()=>Es[Ts(t.status)]);return(t,r)=>(W(),G(`span`,{class:E([`inline-flex shrink-0 rounded-sm px-1.5 py-0.5 font-mono text-xs font-medium tabular-nums`,n.value])},D(e.status),3))}}),ml={class:`space-y-3`,"aria-label":`WebSocket messages`},hl={class:`flex gap-2`},gl=[`value`],_l={key:0,class:`rounded-sm bg-err-bg px-3 py-2 text-sm text-err-fg`,role:`alert`},vl={key:1,class:`text-sm text-muted`},yl={key:2,class:`text-sm text-muted`},bl={key:3,class:`text-sm text-muted`},xl={class:`space-y-2`,"aria-live":`polite`},Sl=[`aria-label`],Cl={class:`flex items-center gap-3 text-xs text-muted`},wl={class:`tabular-nums`},Tl={class:`tabular-nums`},El={key:0,class:`mt-2 rounded-sm bg-warn-bg px-3 py-2 text-sm text-warn-fg`,role:`note`},Dl={class:`mt-2 max-h-80 overflow-auto font-mono text-xs leading-5 break-words whitespace-pre-wrap text-ink`},Ol={key:4,class:`space-y-1 rounded-sm border border-hairline px-3 py-2 text-sm text-muted`,"aria-label":`Close of the WebSocket`},kl={key:0,class:`text-warn-fg`},Al={key:5,class:`text-xs text-muted`},jl=z({__name:`WsMessages`,props:{blocks:{},failure:{}},setup(e){let t=e,n=N(``),r=N(``),i=Q(()=>Hs(t.blocks??[])),a=Q(()=>Ws(i.value.messages,{text:n.value,direction:r.value}).map(e=>({message:e,view:Us(e)}))),o=Q(()=>n.value.trim()!==``||r.value!==``),s=Q(()=>{let e=i.value.close;if(e===null)return``;let t=e.reason===``?``:` and reason "${e.reason}"`;return`Closed by ${Gs(e.by)} with code ${e.code}${t}.`}),c=[{value:``,label:`Both directions`},{value:`in`,label:`Client to service`},{value:`out`,label:`Service to client`}];return(t,l)=>(W(),G(`section`,ml,[q(`div`,hl,[l[2]||=q(`label`,{class:`sr-only`,for:`ws-filter`},`Filter messages`,-1),R(q(`input`,{id:`ws-filter`,"onUpdate:modelValue":l[0]||=e=>n.value=e,type:`search`,placeholder:`Filter by text`,autocomplete:`off`,spellcheck:`false`,class:`min-w-0 flex-1 rounded-sm border border-line-strong bg-well px-2.5 py-1.5 text-sm text-ink placeholder:text-muted`},null,512),[[vo,n.value]]),l[3]||=q(`label`,{class:`sr-only`,for:`ws-direction`},`Filter by direction`,-1),R(q(`select`,{id:`ws-direction`,"onUpdate:modelValue":l[1]||=e=>r.value=e,class:`rounded-sm border border-line-strong bg-well px-2 py-1.5 text-sm text-ink`},[(W(),G(U,null,B(c,e=>q(`option`,{key:e.value,value:e.value},D(e.label),9,gl)),64))],512),[[bo,r.value]])]),e.failure?(W(),G(`p`,_l,D(e.failure),1)):e.blocks===null?(W(),G(`p`,vl,`Loading messages.`)):i.value.messages.length===0&&i.value.close===null?(W(),G(`p`,yl,` No messages yet. New ones appear here as they pass. `)):a.value.length===0&&o.value?(W(),G(`p`,bl,`No message matches the filter.`)):X(``,!0),q(`ol`,xl,[(W(!0),G(U,null,B(a.value,({message:e,view:t})=>(W(),G(`li`,{key:e.position,class:`rounded-sm border border-hairline bg-surface p-3`,"aria-label":`Message ${e.position+1}, ${e.direction===`in`?`client to service`:`service to client`}`},[q(`div`,Cl,[q(`span`,{class:E([`font-mono font-medium`,e.direction===`in`?`text-cyan-text`:`text-green-text`]),"aria-hidden":`true`},D(e.direction===`in`?`Client → service`:`Service → client`),3),q(`span`,wl,`+`+D(e.atMs)+` ms`,1),q(`span`,Tl,D(P(As)(e.length)),1),q(`span`,null,D(t.kind===`json`?`JSON`:t.kind===`text`?`Text`:`Binary`),1),t.kind===`binary`?(W(),K(rs,{key:0,class:`ml-auto`,text:e.dataBase64,label:`Copy message as Base64`},null,8,[`text`])):(W(),K(rs,{key:1,class:`ml-auto`,text:t.kind===`json`?t.formatted:t.text,label:`Copy message`},null,8,[`text`]))]),e.truncated?(W(),G(`p`,El,` Truncated: the log keeps the first `+D(P(As)(65536))+` of this message of `+D(P(As)(e.length))+`. The full message was carried. `,1)):X(``,!0),q(`pre`,Dl,D(t.kind===`json`?t.formatted:t.kind===`text`?t.text:`${t.hex}${t.more?` ...`:``}`),1)],8,Sl))),128))]),i.value.close?(W(),G(`div`,Ol,[q(`p`,null,D(s.value),1),i.value.close.omittedMessages>0?(W(),G(`p`,kl,D(i.value.close.omittedMessages)+` `+D(i.value.close.omittedMessages===1?`message was`:`messages were`)+` not captured: the log keeps up to 2 MB or 10,000 messages per WebSocket. Every message was carried in full. `,1)):X(``,!0)])):e.blocks===null?X(``,!0):(W(),G(`p`,Al,`Open. New messages appear here as they pass.`))]))}}),Ml={class:`mt-1.5 space-y-1.5`},Nl=[`onUpdate:modelValue`,`aria-label`],Pl=[`onUpdate:modelValue`,`aria-label`],Fl={class:`mt-2 flex items-center gap-3`},Il={key:0,class:`mt-1.5 text-sm text-muted`},Ll={class:`mt-1.5 space-y-2`},Rl={class:`flex items-center gap-2 text-xs text-muted`},zl={class:`font-medium text-ink`},Bl={key:0,class:`tabular-nums`},Vl={key:1},Hl={key:0,class:`mt-2 rounded-sm bg-warn-bg px-3 py-2 text-sm text-warn-fg`,role:`note`},Ul={key:1,class:`mt-2 text-sm text-muted`},Wl=[`onUpdate:modelValue`,`aria-label`],Gl={class:`mt-1.5 space-y-1.5 text-sm text-ink`},Kl={class:`flex items-center gap-2`},ql={class:`flex items-center gap-2`},Jl={class:`sticky bottom-0 -mx-4 space-y-3 border-t border-hairline bg-ground px-4 py-3`},Yl={key:0,class:`rounded-sm bg-err-bg px-3 py-2 text-sm text-err-fg`,role:`alert`},Xl={class:`flex items-center gap-3`},Zl={key:0,class:`truncate text-xs text-muted`},Ql={class:`font-mono`},$l=`w-full rounded-sm border border-line-strong bg-well px-2.5 py-1.5 font-mono text-xs text-ink placeholder:text-muted`,eu=`text-xs font-medium tracking-wider text-muted uppercase`,tu=z({__name:`WsReplayEditor`,props:{exchange:{},messages:{},target:{},sending:{type:Boolean},error:{}},emits:[`send`,`cancel`],setup(e,{emit:t}){let n=e,r=t,i=Ht(Ys(n.exchange.request.path,n.exchange.request.headers,n.messages)),a=N(null);function o(){i.headers.push({name:``,value:``})}function s(e){i.headers.splice(e,1)}function c(){i.messages.push(Js())}function l(e){i.messages.splice(e,1)}function u(e,t){let[n]=i.messages.splice(e,1);n!==void 0&&i.messages.splice(e+t,0,n)}function d(){a.value=Zs(i),a.value===null&&r(`send`,Qs(i))}return(t,n)=>(W(),G(`form`,{class:`space-y-6 px-4 pt-4`,"aria-label":`Edit and replay the WebSocket`,novalidate:``,onSubmit:Eo(d,[`prevent`])},[q(`div`,null,[q(`label`,{class:E(eu),for:`ws-replay-path`},`Path`),R(q(`input`,{id:`ws-replay-path`,"onUpdate:modelValue":n[0]||=e=>i.path=e,type:`text`,autocomplete:`off`,spellcheck:`false`,class:E([`mt-1.5`,$l])},null,512),[[vo,i.path]])]),q(`fieldset`,null,[q(`legend`,{class:E(eu)},`Headers`),q(`ul`,Ml,[(W(!0),G(U,null,B(i.headers,(e,t)=>(W(),G(`li`,{key:t,class:`flex gap-1.5`},[R(q(`input`,{"onUpdate:modelValue":t=>e.name=t,type:`text`,autocomplete:`off`,spellcheck:`false`,placeholder:`Name`,"aria-label":`Header ${t+1} name`,class:E([`basis-2/5`,$l])},null,8,Nl),[[vo,e.name]]),R(q(`input`,{"onUpdate:modelValue":t=>e.value=t,type:`text`,autocomplete:`off`,spellcheck:`false`,placeholder:`Value`,"aria-label":`Header ${t+1} value`,class:E([`basis-3/5`,$l])},null,8,Pl),[[vo,e.value]]),J($,{variant:`quiet`,"aria-label":`Remove header ${e.name||t+1}`,onClick:e=>s(t)},{default:L(()=>[...n[4]||=[Y(` Remove `,-1)]]),_:1},8,[`aria-label`,`onClick`])]))),128))]),q(`div`,Fl,[J($,{onClick:o},{default:L(()=>[...n[5]||=[Y(`Add header`,-1)]]),_:1}),n[6]||=q(`span`,{class:`text-xs text-muted`},`The handshake headers of the WebSocket are made anew.`,-1)])]),q(`fieldset`,null,[q(`legend`,{class:E(eu)},`Messages from the client`),i.messages.length===0?(W(),G(`p`,Il,` No messages. The WebSocket opens, waits 5 s for the service and closes. `)):X(``,!0),q(`ol`,Ll,[(W(!0),G(U,null,B(i.messages,(e,t)=>(W(),G(`li`,{key:e.key,class:`rounded-sm border border-hairline bg-surface p-3`},[q(`div`,Rl,[q(`span`,zl,D(t+1),1),q(`span`,null,D(e.binary?`Binary`:`Text`),1),e.atMs===void 0?(W(),G(`span`,Vl,`Added`)):(W(),G(`span`,Bl,`+`+D(e.atMs)+` ms`,1)),J($,{class:`ml-auto`,variant:`quiet`,disabled:t===0,"aria-label":`Move message ${t+1} up`,onClick:e=>u(t,-1)},{default:L(()=>[...n[7]||=[Y(` Up `,-1)]]),_:1},8,[`disabled`,`aria-label`,`onClick`]),J($,{variant:`quiet`,disabled:t===i.messages.length-1,"aria-label":`Move message ${t+1} down`,onClick:e=>u(t,1)},{default:L(()=>[...n[8]||=[Y(` Down `,-1)]]),_:1},8,[`disabled`,`aria-label`,`onClick`]),J($,{variant:`quiet`,"aria-label":`Remove message ${t+1}`,onClick:e=>l(t)},{default:L(()=>[...n[9]||=[Y(` Remove `,-1)]]),_:1},8,[`aria-label`,`onClick`])]),e.truncated?(W(),G(`p`,Hl,[e.binary?(W(),G(U,{key:0},[Y(` Captured only in part (`+D(P(As)(e.length))+` in full), so it cannot be sent. Remove it to replay the rest. `,1)],64)):(W(),G(U,{key:1},[Y(` The log holds only the first part of this message. What you send is exactly the text below. `)],64))])):X(``,!0),e.binary&&!e.truncated?(W(),G(`p`,Ul,` Binary, `+D(P(As)(e.length))+`. It cannot be edited here and is sent as captured. `,1)):e.binary?X(``,!0):R((W(),G(`textarea`,{key:2,"onUpdate:modelValue":t=>e.text=t,rows:`3`,spellcheck:`false`,class:E([`mt-2 leading-5`,$l]),"aria-label":`Text of message ${t+1}`},null,8,Wl)),[[vo,e.text]])]))),128))]),J($,{class:`mt-2`,onClick:c},{default:L(()=>[...n[10]||=[Y(`Add text message`,-1)]]),_:1})]),q(`fieldset`,null,[q(`legend`,{class:E(eu)},`Timing`),q(`div`,Gl,[q(`label`,Kl,[R(q(`input`,{"onUpdate:modelValue":n[1]||=e=>i.timing=e,type:`radio`,name:`ws-timing`,value:`recorded`},null,512),[[yo,i.timing]]),n[11]||=Y(` As recorded: the gaps between the messages, each at most 5 s `,-1)]),q(`label`,ql,[R(q(`input`,{"onUpdate:modelValue":n[2]||=e=>i.timing=e,type:`radio`,name:`ws-timing`,value:`fast`},null,512),[[yo,i.timing]]),n[12]||=Y(` Fast: one message after the other `,-1)])]),n[13]||=q(`p`,{class:`mt-1.5 text-xs text-muted`},` After the last message the WebSocket stays open 5 s for the answers, then it is closed with 1000. `,-1)]),q(`div`,Jl,[a.value||e.error?(W(),G(`p`,Yl,D(a.value??e.error),1)):X(``,!0),q(`div`,Xl,[J($,{type:`submit`,variant:`primary`,loading:e.sending},{default:L(()=>[Y(D(e.sending?`Sending`:`Send replay`),1)]),_:1},8,[`loading`]),J($,{disabled:e.sending,onClick:n[3]||=e=>r(`cancel`)},{default:L(()=>[...n[14]||=[Y(`Cancel`,-1)]]),_:1},8,[`disabled`]),e.target?(W(),G(`span`,Zl,[n[15]||=Y(` Goes to `,-1),q(`span`,Ql,D(e.target),1)])):X(``,!0)])])],32))}}),nu={class:`flex h-full min-h-0 flex-col`,"aria-label":`Request details`},ru={class:`border-b border-hairline p-4`},iu={class:`flex items-start gap-2`},au={class:`min-w-0 flex-1 font-mono text-sm leading-5 font-normal break-all text-ink`},ou={class:`mt-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted`},su={class:`flex gap-1`},cu={class:`text-tag-fg tabular-nums`},lu={class:`flex gap-1`},uu={class:`text-tag-fg tabular-nums`},du={class:`flex gap-1`},fu={class:`text-tag-fg`},pu={class:`flex gap-1`},mu={class:`text-tag-fg`},hu={key:0,class:`flex gap-1`},gu={key:1,class:`flex gap-1`},_u={key:1,class:`font-mono text-tag-fg`},vu={key:0,class:`mt-3 flex flex-wrap items-center gap-2`},yu={key:0,class:`truncate text-xs text-muted`},bu={class:`font-mono`},xu={key:1,class:`mt-2 text-sm text-warn-fg`,role:`note`},Su={key:2,class:`mt-2 rounded-sm bg-err-bg px-3 py-2 text-sm text-err-fg`,role:`alert`},Cu={key:0,class:`min-h-0 flex-1 overflow-y-auto`},wu={class:`flex gap-1 border-b border-hairline px-4`,role:`tablist`,"aria-label":`Message`},Tu=[`id`,`aria-selected`,`onClick`],Eu=[`aria-labelledby`],Du=z({__name:`ExchangeDetail`,props:{record:{},status:{},originalLoaded:{type:Boolean},replay:{},wsBlocks:{default:null},wsFailure:{default:null},logs:{default:()=>[]}},emits:[`select`,`load-messages`,`load-logs`],setup(e,{emit:t}){let n=e,r=t,i=N(`request`),a=N(!1),o=N(!1),s=N(null),c=Q(()=>n.record.exchange),l=Q(()=>ms(c.value)),u=Q(()=>[`request`,`response`,...l.value?[`messages`]:[],...n.logs.length>0?[`logs`]:[]]),d=N(!1);function f(e){return e===`logs`?`Logs ${n.logs.length}`:e}function p(e){i.value=e,d.value=!0}let m=Q(()=>Hs(n.wsBlocks??[]).messages),h=Q(()=>oc(n.status,c.value)),g=Q(()=>{let e=ac(n.status,c.value,m.value);if(l.value&&n.wsBlocks===null&&e.replay===null){let t=`The messages of this WebSocket are still loading.`;return{replay:t,editAndReplay:e.editAndReplay??t}}return e}),_=Q(()=>g.value.replay);Vn(()=>[c.value.id,n.record.origin],()=>{a.value=!1,s.value=null,d.value=!1,u.value.includes(i.value)||(i.value=`request`),l.value&&r(`load-messages`,n.record),r(`load-logs`,n.record)},{immediate:!0}),Vn(()=>[c.value.id,n.logs.length>0],([,e])=>{e&&!d.value&&c.value.response.status>=500?i.value=`logs`:!e&&i.value===`logs`&&(i.value=`request`)},{immediate:!0});async function v(e){o.value=!0,s.value=null;try{let t=await n.replay(n.record,e);a.value=!1,i.value=l.value&&ms(t)?`messages`:`response`,r(`select`,t.id)}catch(e){s.value=e instanceof _s?e.message:`The replay could not be sent.`}finally{o.value=!1}}function y(){s.value=null,a.value=!0}return(t,n)=>(W(),G(`article`,nu,[q(`header`,ru,[q(`div`,iu,[J(Uc,{method:c.value.request.method},null,8,[`method`]),q(`h2`,au,D(c.value.request.path),1),J(pl,{status:c.value.response.status},null,8,[`status`])]),q(`dl`,ou,[q(`div`,su,[n[4]||=q(`dt`,null,`Time`,-1),q(`dd`,cu,D(P(Ms)(c.value.timestamp)),1)]),q(`div`,lu,[n[5]||=q(`dt`,null,`Duration`,-1),q(`dd`,uu,D(P(ks)(c.value.response.durationMs)),1)]),q(`div`,du,[n[6]||=q(`dt`,null,`Source`,-1),q(`dd`,fu,D(P(Os)(c.value.source)),1)]),q(`div`,pu,[n[7]||=q(`dt`,null,`Service`,-1),q(`dd`,mu,D(c.value.serviceName),1)]),e.record.origin===`remote`?(W(),G(`div`,hu,[...n[8]||=[q(`dt`,null,`Origin`,-1),q(`dd`,{class:`text-tag-fg`},`remote log`,-1)]])):X(``,!0),c.value.replayOf?(W(),G(`div`,gu,[n[9]||=q(`dt`,null,`Replay of`,-1),q(`dd`,null,[e.originalLoaded?(W(),G(`button`,{key:0,type:`button`,class:`cursor-pointer rounded-sm font-mono text-ink underline decoration-line-strong underline-offset-2 transition-colors duration-150 ease-out hover:decoration-ink`,onClick:n[0]||=e=>r(`select`,c.value.replayOf)},D(c.value.replayOf.slice(0,8)),1)):(W(),G(`span`,_u,D(c.value.replayOf.slice(0,8)),1))])])):X(``,!0)]),a.value?X(``,!0):(W(),G(`div`,vu,[J($,{variant:`primary`,loading:o.value,disabled:_.value!==null,onClick:n[1]||=e=>v()},{default:L(()=>[Y(D(o.value?`Sending`:`Replay`),1)]),_:1},8,[`loading`,`disabled`]),J($,{disabled:o.value||g.value.editAndReplay!==null,onClick:y},{default:L(()=>[...n[10]||=[Y(` Edit & Replay `,-1)]]),_:1},8,[`disabled`]),h.value&&_.value===null?(W(),G(`span`,yu,[n[11]||=Y(` Goes to `,-1),q(`span`,bu,D(h.value),1)])):X(``,!0)])),!a.value&&_.value?(W(),G(`p`,xu,D(_.value),1)):X(``,!0),!a.value&&s.value?(W(),G(`p`,Su,D(s.value),1)):X(``,!0)]),a.value?(W(),G(`div`,Cu,[l.value?(W(),K(tu,{key:`ws-${c.value.id}`,exchange:c.value,messages:m.value,target:h.value,sending:o.value,error:s.value,onSend:v,onCancel:n[2]||=e=>a.value=!1},null,8,[`exchange`,`messages`,`target`,`sending`,`error`])):(W(),K(fl,{key:c.value.id,exchange:c.value,target:h.value,sending:o.value,error:s.value,onSend:v,onCancel:n[3]||=e=>a.value=!1},null,8,[`exchange`,`target`,`sending`,`error`]))])):(W(),G(U,{key:1},[q(`div`,wu,[(W(!0),G(U,null,B(u.value,e=>(W(),G(`button`,{id:`tab-${e}`,key:e,type:`button`,role:`tab`,"aria-selected":i.value===e,"aria-controls":`message-panel`,class:E([`-mb-px cursor-pointer border-b-2 px-3 py-2 text-sm font-medium capitalize transition-colors duration-150 ease-out focus-visible:-outline-offset-2`,i.value===e?`border-ink text-ink`:`border-transparent text-muted hover:text-ink`]),onClick:t=>p(e)},D(f(e)),11,Tu))),128))]),q(`div`,{id:`message-panel`,class:`min-h-0 flex-1 overflow-y-auto p-4`,role:`tabpanel`,"aria-labelledby":`tab-${i.value}`},[i.value===`request`?(W(),K(Vc,{key:0,headers:c.value.request.headers,"body-base64":c.value.request.bodyBase64,"body-truncated":c.value.request.bodyTruncated},null,8,[`headers`,`body-base64`,`body-truncated`])):i.value===`messages`?(W(),K(jl,{key:1,blocks:e.wsBlocks,failure:e.wsFailure},null,8,[`blocks`,`failure`])):i.value===`logs`?(W(),K(kc,{key:2,items:e.logs,"exchange-id":c.value.id},null,8,[`items`,`exchange-id`])):(W(),K(Vc,{key:3,headers:c.value.response.headers,"body-base64":c.value.response.bodyBase64,"body-truncated":c.value.response.bodyTruncated},null,8,[`headers`,`body-base64`,`body-truncated`]))],8,Eu)],64))]))}});function Ou(e){return`${e.origin}:${e.index}`}function ku(e,t){let n=new Map;for(let t of e)n.set(Ou(t),t);for(let e of t)n.set(Ou(e),e);return[...n.values()].sort((e,t)=>t.exchange.timestamp-e.exchange.timestamp||t.index-e.index)}function Au(e,t){let n=t.text.toLowerCase().split(/\s+/).filter(Boolean);return e.filter(({exchange:e})=>{if(t.service!==``&&e.serviceName!==t.service)return!1;let r=`${e.request.method} ${e.request.path} ${e.response.status} ${e.serviceName} ${e.source}${ms(e)?` ws`:``}`.toLowerCase();return n.every(e=>r.includes(e))})}function ju(e,t){return[...new Set([...t,...e.map(e=>e.exchange.serviceName)])].sort()}function Mu(e){return e?[`remote`,`own`]:[`own`]}function Nu(e,t){return e.reduce((e,n)=>n.origin===t&&(e===null||n.index<e)?n.index:e,null)}function Pu(e){let t=[];for(let n of[`remote`,`own`]){let r=Nu(e,n);r!==null&&r>0&&t.push({origin:n,before:r})}return t}var Fu={class:`flex h-full min-h-0 flex-col`},Iu={class:`flex gap-2 border-b border-hairline p-2`},Lu=[`value`],Ru={key:0,class:`p-4 text-sm text-muted`},zu={class:`min-h-0 flex-1 overflow-y-auto`,"aria-label":`Requests, newest first`},Bu=[`aria-current`,`onClick`],Vu={class:`flex items-center gap-2`},Hu=[`title`],Uu={class:`mt-1 flex items-center gap-2 text-xs text-muted`},Wu={class:`tabular-nums`},Gu={class:`tabular-nums`},Ku={key:0,class:`rounded-sm bg-tag-bg px-1.5 py-px font-medium text-tag-fg`,title:`WebSocket handshake; its messages are in the Messages tab`},qu={key:1,class:`rounded-sm bg-info-bg px-1.5 py-px font-medium text-info-fg`},Ju={key:2,class:`truncate`},Yu={key:0,class:`p-2 text-center`},Xu=z({__name:`ExchangeList`,props:{records:{},services:{},selectedKey:{},hasOlder:{type:Boolean},loadingOlder:{type:Boolean}},emits:[`select`,`load-older`],setup(e,{emit:t}){let n=e,r=t,i=N(``),a=N(``),o=Q(()=>n.services.length>1),s=Q(()=>Au(n.records,{text:i.value,service:a.value})),c=Q(()=>i.value.trim()!==``||a.value!==``);return(t,n)=>(W(),G(`div`,Fu,[q(`div`,Iu,[n[5]||=q(`label`,{class:`sr-only`,for:`traffic-filter`},`Filter requests`,-1),R(q(`input`,{id:`traffic-filter`,"onUpdate:modelValue":n[0]||=e=>i.value=e,type:`search`,placeholder:`Filter by method, path or status`,autocomplete:`off`,spellcheck:`false`,class:`min-w-0 flex-1 rounded-sm border border-line-strong bg-well px-2.5 py-1.5 text-sm text-ink placeholder:text-muted`},null,512),[[vo,i.value]]),o.value?(W(),G(U,{key:0},[n[4]||=q(`label`,{class:`sr-only`,for:`traffic-service`},`Filter by service`,-1),R(q(`select`,{id:`traffic-service`,"onUpdate:modelValue":n[1]||=e=>a.value=e,class:`rounded-sm border border-line-strong bg-well px-2 py-1.5 text-sm text-ink`},[n[3]||=q(`option`,{value:``},`All services`,-1),(W(!0),G(U,null,B(e.services,e=>(W(),G(`option`,{key:e,value:e},D(e),9,Lu))),128))],512),[[bo,a.value]])],64)):X(``,!0)]),s.value.length===0?(W(),G(`p`,Ru,D(c.value?`No request matches the filter.`:`No requests yet.`),1)):X(``,!0),q(`ul`,zu,[(W(!0),G(U,null,B(s.value,t=>(W(),G(`li`,{key:P(Ou)(t)},[q(`button`,{type:`button`,class:E([`block w-full cursor-pointer border-b border-l-2 border-b-hairline px-3 py-2 text-left transition-colors duration-150 ease-out focus-visible:-outline-offset-2`,P(Ou)(t)===e.selectedKey?`border-l-ink bg-surface`:`border-l-transparent hover:bg-surface/60`]),"aria-current":P(Ou)(t)===e.selectedKey?`true`:void 0,onClick:e=>r(`select`,P(Ou)(t))},[q(`span`,Vu,[J(Uc,{method:t.exchange.request.method},null,8,[`method`]),q(`span`,{class:`min-w-0 flex-1 truncate font-mono text-sm text-ink`,title:t.exchange.request.path},D(t.exchange.request.path),9,Hu),J(pl,{status:t.exchange.response.status},null,8,[`status`])]),q(`span`,Uu,[q(`span`,Wu,D(P(Ms)(t.exchange.timestamp)),1),q(`span`,Gu,D(P(ks)(t.exchange.response.durationMs)),1),q(`span`,{class:E([`rounded-sm px-1.5 py-px font-medium`,t.exchange.source===`replay`?`bg-warn-bg text-warn-fg`:`bg-tag-bg text-tag-fg`])},D(P(Os)(t.exchange.source)),3),P(ms)(t.exchange)?(W(),G(`span`,Ku,` ws `)):X(``,!0),t.origin===`remote`?(W(),G(`span`,qu,` remote `)):X(``,!0),o.value?(W(),G(`span`,Ju,D(t.exchange.serviceName),1)):X(``,!0)])],10,Bu)]))),128)),e.hasOlder?(W(),G(`li`,Yu,[J($,{variant:`quiet`,loading:e.loadingOlder,onClick:n[2]||=e=>r(`load-older`)},{default:L(()=>[Y(D(e.loadingOlder?`Loading`:`Load older requests`),1)]),_:1},8,[`loading`])])):X(``,!0)])]))}}),Zu={class:`flex h-full min-h-0 flex-col`,"aria-label":`Application logs`},Qu={class:`flex flex-wrap gap-2 border-b border-hairline px-4 py-2`},$u=[`value`],ed=[`value`],td={key:0,class:`rounded-sm bg-warn-bg px-3 py-2 text-sm text-warn-fg`,role:`note`},nd={key:1,class:`text-sm text-muted`},rd={key:2,class:`text-sm text-muted`},id=z({__name:`LogPane`,props:{items:{},omitted:{}},emits:[`select`],setup(e,{emit:t}){let n=e,r=t,i=N(``),a=N(``),o=N(``),s=Q(()=>[...new Set(n.items.map(e=>e.source))].sort()),c=Q(()=>pc(n.items,{text:i.value,source:a.value,level:o.value})),l=Q(()=>i.value.trim()!==``||a.value!==``||o.value!==``),u=[`error`,`warning`,`info`,`debug`],d=N(null),f=!0;function p(){let e=d.value;e!==null&&(f=e.scrollHeight-e.scrollTop-e.clientHeight<40)}async function m(){await Cn(),f&&d.value!==null&&(d.value.scrollTop=d.value.scrollHeight)}return pr(m),Vn(()=>c.value.length,m),(t,n)=>(W(),G(`section`,Zu,[q(`div`,Qu,[n[6]||=q(`label`,{class:`sr-only`,for:`log-filter`},`Filter log entries`,-1),R(q(`input`,{id:`log-filter`,"onUpdate:modelValue":n[0]||=e=>i.value=e,type:`search`,placeholder:`Filter by text`,autocomplete:`off`,spellcheck:`false`,class:`min-w-0 flex-1 rounded-sm border border-line-strong bg-well px-2.5 py-1.5 text-sm text-ink placeholder:text-muted`},null,512),[[vo,i.value]]),n[7]||=q(`label`,{class:`sr-only`,for:`log-source`},`Filter by file`,-1),R(q(`select`,{id:`log-source`,"onUpdate:modelValue":n[1]||=e=>a.value=e,class:`rounded-sm border border-line-strong bg-well px-2 py-1.5 text-sm text-ink`},[n[4]||=q(`option`,{value:``},`All files`,-1),(W(!0),G(U,null,B(s.value,e=>(W(),G(`option`,{key:e,value:e},D(e),9,$u))),128))],512),[[bo,a.value]]),n[8]||=q(`label`,{class:`sr-only`,for:`log-level`},`Filter by level`,-1),R(q(`select`,{id:`log-level`,"onUpdate:modelValue":n[2]||=e=>o.value=e,class:`rounded-sm border border-line-strong bg-well px-2 py-1.5 text-sm text-ink`},[n[5]||=q(`option`,{value:``},`All levels`,-1),(W(),G(U,null,B(u,e=>q(`option`,{key:e,value:e},D(P(_c)[e]),9,ed)),64))],512),[[bo,o.value]])]),q(`div`,{ref_key:`scroller`,ref:d,class:`min-h-0 flex-1 space-y-3 overflow-y-auto p-4`,onScroll:p},[e.omitted.entries>0?(W(),G(`p`,td,D(e.omitted.entries)+` `+D(e.omitted.entries===1?`entry was`:`entries were`)+` (`+D(P(As)(e.omitted.bytes))+`) not captured: a log file is captured up to 200 entries per second and 10 MB per run. `,1)):X(``,!0),e.items.length===0?(W(),G(`p`,nd,` No log entries yet. Start the tunnel with --log <path> (or logs: in hopwire.yaml) and new entries of the file appear here as they are written. `)):c.value.length===0&&l.value?(W(),G(`p`,rd,`No entry matches the filter.`)):X(``,!0),J(kc,{items:c.value,selectable:``,onSelect:n[3]||=e=>r(`select`,e)},null,8,[`items`])],544)]))}}),ad=`hopwire-inspector-theme`;function od(){try{return localStorage.getItem(ad)===`light`?`light`:`dark`}catch{return`dark`}}var sd=N(od());Vn(sd,e=>{document.documentElement.classList.toggle(`dark`,e===`dark`);try{localStorage.setItem(ad,e)}catch{}},{immediate:!0});function cd(){function e(){sd.value=sd.value===`dark`?`light`:`dark`}return{theme:sd,toggleTheme:e}}var ld=[`viewBox`],ud=[`stroke-width`],dd=[`d`,`pathLength`],fd=[`d`],pd=z({__name:`BrandLogo`,props:{animated:{type:Boolean,default:!1}},setup(e){return(t,n)=>(W(),G(`svg`,{viewBox:P(No),role:`img`,"aria-label":`Hopwire`,class:`block w-auto`},[q(`g`,{class:`stroke-mark`,fill:`none`,"stroke-width":P(Fo),"stroke-linecap":`round`,"stroke-linejoin":`round`},[(W(!0),G(U,null,B(P(Io),(t,n)=>(W(),G(`path`,{key:n,d:t,pathLength:e.animated?1:void 0,class:E(e.animated?`hwd-s hwd-s${n+1}`:void 0)},null,10,dd))),128))],8,ud),q(`g`,{class:E(e.animated?`hwd-w`:void 0)},[q(`path`,{class:`fill-ink`,d:P(Lo)},null,8,fd)],2)],8,ld))}}),md={class:`flex flex-wrap items-center gap-x-5 gap-y-2 border-b border-hairline bg-surface px-4 py-2.5 text-sm`},hd={class:`flex items-center gap-2.5 font-normal`},gd={key:0,class:`inline-flex items-center gap-1.5 rounded-full bg-tag-bg px-2 py-0.5 text-xs font-medium text-tag-fg`},_d={key:1,class:`rounded-full bg-info-bg px-2 py-0.5 text-xs font-medium text-info-fg`},vd={key:2,class:`order-last flex w-full min-w-0 flex-wrap items-center gap-x-5 gap-y-1 lg:order-none lg:w-auto lg:flex-1`},yd={class:`truncate font-mono text-xs text-ink`},bd={key:0,class:`flex items-center gap-1.5`},xd=[`title`],Sd={class:`flex items-center gap-1.5`},Cd=[`title`],wd={class:`flex min-w-0 items-center gap-1.5`},Td={key:0,class:`truncate font-mono text-xs text-ink`},Ed={class:`ml-auto flex items-center gap-3`},Dd={class:`flex items-center gap-1.5 text-xs text-tag-fg`,role:`status`},Od=z({__name:`StatusBar`,props:{status:{},stream:{},logCount:{default:0},logsOpen:{type:Boolean,default:!1}},emits:[`toggle-logs`],setup(e,{emit:t}){let n=e,r=t,{theme:i,toggleTheme:a}=cd(),o=Q(()=>n.status===null?null:sc(n.status));return(t,n)=>(W(),G(`header`,md,[q(`h1`,hd,[J(pd,{class:`h-6`}),n[1]||=q(`span`,{class:`text-muted`},`Inspector`,-1)]),e.status?(W(),G(`span`,gd,[q(`span`,{class:E([`size-2 rounded-full border-[1.5px]`,e.status.mode===`public`?`border-link-blue bg-link-blue`:`border-cyan-text bg-wire-cyan`]),"aria-hidden":`true`},null,2),Y(` `+D(e.status.mode===`public`?`Public mode`:`Private mode`),1)])):X(``,!0),e.status?.watching?(W(),G(`span`,_d,` Watching a shared log `)):X(``,!0),e.status?(W(),G(`dl`,vd,[(W(!0),G(U,null,B(e.status.publicUrls,e=>(W(),G(`div`,{key:e,class:`flex min-w-0 items-center gap-1.5`},[n[2]||=q(`dt`,{class:`text-muted`},`Public URL`,-1),q(`dd`,yd,D(e),1),J(rs,{text:e,label:`Copy public URL`},null,8,[`text`])]))),128)),e.status.peerKey?(W(),G(`div`,bd,[n[3]||=q(`dt`,{class:`text-muted`},`Peer key`,-1),q(`dd`,{class:`font-mono text-xs text-ink`,title:e.status.peerKey},D(P(Ns)(e.status.peerKey)),9,xd),J(rs,{text:e.status.peerKey,label:`Copy peer key`},null,8,[`text`])])):X(``,!0),q(`div`,Sd,[n[4]||=q(`dt`,{class:`text-muted`},`Log key`,-1),q(`dd`,{class:`font-mono text-xs text-ink`,title:e.status.logKey},D(P(Ns)(e.status.logKey)),9,Cd),J(rs,{text:e.status.logKey,label:`Copy log key`},null,8,[`text`])]),q(`div`,wd,[n[5]||=q(`dt`,{class:`text-muted`},`Replay target`,-1),e.status.replayTarget?(W(),G(`dd`,Td,D(e.status.replayTarget),1)):o.value?(W(),G(`dd`,{key:1,class:E([`text-xs`,o.value.missing?`text-warn-fg`:`text-tag-fg`])},D(o.value.text),3)):X(``,!0)])])):X(``,!0),q(`div`,Ed,[q(`span`,Dd,[P($o)(e.stream)?(W(),K(qc,{key:0,class:`h-3.5`})):(W(),G(`span`,{key:1,class:E([`size-2 rounded-full`,e.stream===`live`?`bg-hop-green`:`border-[1.5px] border-muted`]),"aria-hidden":`true`},null,2)),Y(` `+D(P(Zo)[e.stream]),1)]),e.logCount>0||e.logsOpen?(W(),K($,{key:0,variant:`quiet`,"aria-pressed":e.logsOpen,"aria-controls":`log-pane`,onClick:n[0]||=e=>r(`toggle-logs`)},{default:L(()=>[Y(D(e.logsOpen?`Hide logs`:`Logs ${e.logCount}`),1)]),_:1},8,[`aria-pressed`])):X(``,!0),J($,{variant:`quiet`,"aria-label":`Switch to ${P(i)===`dark`?`light`:`dark`} mode`,onClick:P(a)},{default:L(()=>[Y(D(P(i)===`dark`?`Light`:`Dark`),1)]),_:1},8,[`aria-label`,`onClick`])])]))}}),kd=100;function Ad(){let e=N(null),t=$t([]),n=N(`connecting`),r=N(!1),i=N(!1),a=N(null),o=null,s=!1,c=$t(new Map),l=$t(new Map),u=$t([]),d=N({entries:0,bytes:0});function f(e){u.value=uc(u.value,lc(e));let t=dc(e);t.entries>0&&(d.value={entries:d.value.entries+t.entries,bytes:d.value.bytes+t.bytes})}async function p(e){try{let t=await Cs({exchangeId:e.exchange.id,origin:e.origin});u.value=uc(u.value,lc(t.blocks))}catch{}}async function m(){try{let e=await Cs({limit:500});u.value=uc(u.value,lc(e.blocks))}catch{}}function h(e,t){let n=new Map(c.value);n.set(e,t),c.value=n}async function g(e){let t=Bs(e.origin,e.exchange.id);c.value.has(t)||h(t,[]);try{let n=await Ss(e.origin,e.exchange.id);if(h(t,Vs(c.value.get(t)??[],n)),l.value.has(t)){let e=new Map(l.value);e.delete(t),l.value=e}}catch(e){let n=new Map(l.value);n.set(t,e instanceof _s?e.message:`The messages could not be loaded.`),l.value=n}}let _=Q(()=>Pu(t.value).length>0),v=Q(()=>a.value??(n.value===`closed`?`The connection to the tunnel is closed. Reload the page to connect again.`:null)),y=Q(()=>!r.value&&v.value===null);async function b(){r.value||(a.value=null);try{let n=await bs(),i=(await Promise.all(Mu(n.watching).map(e=>xs({origin:e,limit:kd})))).flat(),o=e.value===null||e.value.logKey===n.logKey;e.value=n,t.value=ku(o?t.value:[],i),r.value=!0,a.value=null,o||(c.value=new Map,u.value=[],d.value={entries:0,bytes:0}),m();for(let e of c.value.keys()){let n=t.value.find(t=>Bs(t.origin,t.exchange.id)===e);n!==void 0&&g(n)}}catch(e){a.value=e instanceof _s?e.message:`The traffic could not be loaded.`}}function x(){let e=new EventSource(`${vs}stream`);o=e,e.addEventListener(`open`,()=>{s=!0,n.value=`live`,b()}),e.addEventListener(`exchange`,e=>{let n=JSON.parse(e.data);t.value=ku(t.value,[n])}),e.addEventListener(`ws_messages`,e=>{let{origin:t,block:n}=JSON.parse(e.data),r=Bs(t,n.exchangeId),i=c.value.get(r);i!==void 0&&h(r,Vs(i,[n]))}),e.addEventListener(`log_entries`,e=>{f([JSON.parse(e.data)])}),e.addEventListener(`error`,()=>{n.value=Qo(e.readyState===EventSource.CLOSED,s)})}function ee(){o?.close(),o=null,n.value=`closed`}async function S(){let e=Pu(t.value);if(!(e.length===0||i.value)){i.value=!0;try{let n=await Promise.all(e.map(e=>xs({...e,limit:kd})));t.value=ku(t.value,n.flat())}catch(e){a.value=e instanceof _s?e.message:`Older requests could not be loaded.`}finally{i.value=!1}}}async function C(e,n){let r=await ws(e,n);return t.value.some(e=>e.exchange.id===r.id)||await b(),r}return{status:e,records:t,stream:n,connecting:y,loaded:r,loadingOlder:i,problem:v,hasOlder:_,start:x,stop:ee,loadOlder:S,replay:C,wsSessions:c,wsFailures:l,loadWsMessages:g,logs:u,logsOmitted:d,loadExchangeLogs:p}}function jd(){let e=Ad();return gr(e.stop),e}function Md(e){let t=/^#exchange=([^&]+)$/.exec(e);if(t?.[1]===void 0)return null;try{return decodeURIComponent(t[1])}catch{return null}}var Nd={class:`flex h-dvh flex-col bg-ground text-ink`},Pd={key:0,class:`border-b border-hairline bg-err-bg px-4 py-2 text-sm text-err-fg`,role:`alert`},Fd={class:`min-h-0 flex-1`},Id={key:2,class:`flex h-full min-h-0 flex-col md:flex-row`},Ld={class:`h-2/5 min-h-0 shrink-0 border-b border-hairline md:h-full md:w-2/5 md:max-w-xl md:min-w-80 md:border-r md:border-b-0`,"aria-label":`Traffic`},Rd={class:`min-h-0 min-w-0 flex-1`},zd={key:1,class:`flex h-full items-center justify-center p-8 text-sm text-muted`},Bd={key:1,id:`log-pane`,class:`h-2/5 min-h-0 shrink-0 border-t border-hairline`};Ao(z({__name:`App`,setup(e){let{status:t,records:n,stream:r,connecting:i,loaded:a,loadingOlder:o,problem:s,hasOlder:c,start:l,loadOlder:u,replay:d,wsSessions:f,wsFailures:p,loadWsMessages:m,logs:h,logsOmitted:g,loadExchangeLogs:_}=jd(),v=N(!1),y=N(null),b=Q(()=>n.value.find(e=>Ou(e)===y.value)??null);function x(e){let t=n.value.find(t=>t.exchange.id===e);y.value=t===void 0?null:Ou(t)}let ee=Q(()=>ju(n.value,(t.value?.services??[]).map(e=>e.name))),S=Q(()=>b.value===null?null:Bs(b.value.origin,b.value.exchange.id)),C=Q(()=>S.value===null?null:f.value.get(S.value)??null),te=Q(()=>S.value===null?null:p.value.get(S.value)??null),ne=Q(()=>b.value===null?[]:fc(h.value,b.value.origin,b.value.exchange.id));function re(e){let t=n.value.find(t=>t.origin===e.origin&&e.entry.exchangeIds.includes(t.exchange.id));t!==void 0&&(y.value=Ou(t))}let ie=Q(()=>{let e=b.value?.exchange.replayOf;return e!==void 0&&n.value.some(t=>t.exchange.id===e)}),w=N(Md(window.location.hash));Vn([n,w],()=>{let e=w.value;e!==null&&n.value.some(t=>t.exchange.id===e)&&(x(e),w.value=null)},{immediate:!0});let ae=()=>{w.value=Md(window.location.hash)};return pr(()=>{window.addEventListener(`hashchange`,ae),l()}),gr(()=>window.removeEventListener(`hashchange`,ae)),(e,l)=>(W(),G(`div`,Nd,[J(Od,{status:P(t),stream:P(r),"log-count":P(h).length,"logs-open":v.value,onToggleLogs:l[0]||=e=>v.value=!v.value},null,8,[`status`,`stream`,`log-count`,`logs-open`]),P(s)?(W(),G(`p`,Pd,D(P(s)),1)):X(``,!0),q(`main`,Fd,[P(a)?P(n).length===0?(W(),K(ps,{key:1,status:P(t),stream:P(r)},null,8,[`status`,`stream`])):(W(),G(`div`,Id,[q(`section`,Ld,[J(Xu,{records:P(n),services:ee.value,"selected-key":y.value,"has-older":P(c),"loading-older":P(o),onSelect:l[1]||=e=>y.value=e,onLoadOlder:P(u)},null,8,[`records`,`services`,`selected-key`,`has-older`,`loading-older`,`onLoadOlder`])]),q(`section`,Rd,[b.value?(W(),K(Du,{key:0,record:b.value,status:P(t),"original-loaded":ie.value,replay:P(d),"ws-blocks":C.value,"ws-failure":te.value,logs:ne.value,onSelect:x,onLoadMessages:P(m),onLoadLogs:P(_)},null,8,[`record`,`status`,`original-loaded`,`replay`,`ws-blocks`,`ws-failure`,`logs`,`onLoadMessages`,`onLoadLogs`])):(W(),G(`div`,zd,` Select a request to see its headers and body. `))])])):(W(),K(Xo,{key:0,connecting:P(i)},null,8,[`connecting`]))]),v.value?(W(),G(`div`,Bd,[J(id,{items:P(h),omitted:P(g),onSelect:re},null,8,[`items`,`omitted`])])):X(``,!0)]))}})).mount(`#app`);
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<meta name="referrer" content="no-referrer" />
|
|
8
8
|
<title>Hopwire Inspector</title>
|
|
9
9
|
<link rel="icon" type="image/svg+xml" href="./favicon.svg" />
|
|
10
|
-
<script type="module" crossorigin src="./assets/index-
|
|
10
|
+
<script type="module" crossorigin src="./assets/index-CdyIIKdA.js"></script>
|
|
11
11
|
<link rel="stylesheet" crossorigin href="./assets/index-Du4-DCNN.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body class="bg-ground font-sans text-ink antialiased">
|