@tonyclaw/agent-inspector 4.0.7 → 4.0.9
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/.output/backend/nitro.json +1 -1
- package/.output/cli.js +915 -25970
- package/.output/server/_chunks/ssr-renderer.mjs +1 -38
- package/.output/server/_libs/@opentelemetry/semantic-conventions+[...].mjs +1 -2658
- package/.output/server/_libs/agent-base.mjs +2 -234
- package/.output/server/_libs/ajv-formats.mjs +1 -330
- package/.output/server/_libs/ajv.mjs +8 -6080
- package/.output/server/_libs/anthropic-ai__sdk.mjs +19 -6021
- package/.output/server/_libs/atomically.mjs +1 -155
- package/.output/server/_libs/base64-js.mjs +1 -102
- package/.output/server/_libs/bignumber.js.mjs +1 -1353
- package/.output/server/_libs/buffer-equal-constant-time.mjs +1 -38
- package/.output/server/_libs/conf.mjs +1 -635
- package/.output/server/_libs/cookie-es.mjs +1 -44
- package/.output/server/_libs/core-util-is.mjs +1 -75
- package/.output/server/_libs/data-uri-to-buffer.mjs +1 -39
- package/.output/server/_libs/debounce-fn.mjs +1 -69
- package/.output/server/_libs/debug.mjs +5 -547
- package/.output/server/_libs/dot-prop.mjs +1 -265
- package/.output/server/_libs/ecdsa-sig-formatter.mjs +1 -162
- package/.output/server/_libs/env-paths.mjs +1 -57
- package/.output/server/_libs/extend.mjs +1 -94
- package/.output/server/_libs/fast-deep-equal.mjs +1 -38
- package/.output/server/_libs/fast-uri.mjs +1 -812
- package/.output/server/_libs/fetch-blob.mjs +1 -287
- package/.output/server/_libs/formdata-polyfill.mjs +9 -86
- package/.output/server/_libs/gaxios.mjs +5 -926
- package/.output/server/_libs/gcp-metadata.mjs +1 -322
- package/.output/server/_libs/google-auth-library.mjs +16 -6339
- package/.output/server/_libs/google-logging-utils.mjs +1 -385
- package/.output/server/_libs/google__genai.mjs +13 -18034
- package/.output/server/_libs/h3-v2.mjs +2 -287
- package/.output/server/_libs/h3.mjs +2 -408
- package/.output/server/_libs/has-flag.mjs +1 -16
- package/.output/server/_libs/https-proxy-agent.mjs +7 -280
- package/.output/server/_libs/immediate.mjs +1 -74
- package/.output/server/_libs/inherits.mjs +1 -50
- package/.output/server/_libs/isarray.mjs +1 -14
- package/.output/server/_libs/isbot.mjs +1 -20
- package/.output/server/_libs/json-bigint.mjs +8 -413
- package/.output/server/_libs/json-schema-traverse.mjs +1 -91
- package/.output/server/_libs/jszip.mjs +2 -3051
- package/.output/server/_libs/jwa.mjs +3 -233
- package/.output/server/_libs/jws.mjs +1 -298
- package/.output/server/_libs/lie.mjs +1 -273
- package/.output/server/_libs/mariozechner__pi-agent-core.mjs +1 -824
- package/.output/server/_libs/mariozechner__pi-ai.mjs +34 -22887
- package/.output/server/_libs/mimic-function.mjs +2 -47
- package/.output/server/_libs/mistralai__mistralai.mjs +7 -32045
- package/.output/server/_libs/modelcontextprotocol__core.mjs +1 -1121
- package/.output/server/_libs/modelcontextprotocol__server.mjs +13 -13205
- package/.output/server/_libs/ms.mjs +1 -120
- package/.output/server/_libs/node-domexception.mjs +1 -17
- package/.output/server/_libs/node-fetch.mjs +4 -1578
- package/.output/server/_libs/ohash.mjs +1 -1
- package/.output/server/_libs/openai.mjs +23 -6766
- package/.output/server/_libs/opentelemetry__api.mjs +1 -1678
- package/.output/server/_libs/p-retry.mjs +1 -87
- package/.output/server/_libs/pako.mjs +1 -4223
- package/.output/server/_libs/partial-json.mjs +2 -244
- package/.output/server/_libs/process-nextick-args.mjs +1 -48
- package/.output/server/_libs/react-dom.mjs +62 -10778
- package/.output/server/_libs/react.mjs +1 -519
- package/.output/server/_libs/readable-stream.mjs +1 -1518
- package/.output/server/_libs/retry.mjs +1 -236
- package/.output/server/_libs/rou3.mjs +1 -14
- package/.output/server/_libs/safe-buffer.mjs +1 -126
- package/.output/server/_libs/semver.mjs +1 -1938
- package/.output/server/_libs/seroval-plugins.mjs +1 -58
- package/.output/server/_libs/seroval.mjs +3 -1775
- package/.output/server/_libs/setimmediate.mjs +1 -152
- package/.output/server/_libs/srvx.mjs +4 -1390
- package/.output/server/_libs/stubborn-fs.mjs +1 -91
- package/.output/server/_libs/stubborn-utils.mjs +1 -66
- package/.output/server/_libs/supports-color.mjs +1 -108
- package/.output/server/_libs/tanstack__history.mjs +1 -230
- package/.output/server/_libs/tanstack__react-router.mjs +1 -848
- package/.output/server/_libs/tanstack__react-store.mjs +1 -1
- package/.output/server/_libs/tanstack__router-core.mjs +1 -4839
- package/.output/server/_libs/typebox.mjs +3 -6596
- package/.output/server/_libs/ufo.mjs +1 -54
- package/.output/server/_libs/uint8array-extras.mjs +1 -69
- package/.output/server/_libs/util-deprecate.mjs +1 -12
- package/.output/server/_libs/web-streams-polyfill.mjs +1 -4282
- package/.output/server/_libs/when-exit.mjs +1 -53
- package/.output/server/_libs/ws.mjs +7 -3715
- package/.output/server/_libs/zod-to-json-schema.mjs +5 -1207
- package/.output/server/_libs/zod.mjs +59 -9958
- package/.output/server/_ssr/empty-plugin-adapters-C3Q1xu4u.mjs +1 -0
- package/.output/server/_ssr/index.mjs +2 -1512
- package/.output/server/_ssr/publicBasePathContext--TAQS2_5.mjs +1 -0
- package/.output/server/_ssr/router-zSWaME0l.mjs +341 -0
- package/.output/server/_ssr/start-PDVGOqUN.mjs +1 -0
- package/.output/server/_tanstack-start-manifest_v-D7cKwKzM.mjs +1 -0
- package/.output/server/index.mjs +1 -320
- package/.output/ui/assets/{CompareDrawer-fWsmegqc.js → CompareDrawer-C6KvvPtJ.js} +1 -1
- package/.output/ui/assets/{InspectorPet-Z9XIA0t8.js → InspectorPet-CSH6OAhB.js} +1 -1
- package/.output/ui/assets/{ProxyViewerContainer-DhIB_ZAU.js → ProxyViewerContainer-vPd7g0Xn.js} +4 -4
- package/.output/ui/assets/{ReplayDialog-w_3PENIi.js → ReplayDialog-DbXUcT39.js} +1 -1
- package/.output/ui/assets/{RequestAnatomy-Dix0D4G6.js → RequestAnatomy-BWOCIN7J.js} +1 -1
- package/.output/ui/assets/{ResponseView-BtlbxW2o.js → ResponseView-BqDbTzFs.js} +1 -1
- package/.output/ui/assets/{StreamingChunkSequence-BqNQJASb.js → StreamingChunkSequence-UHl2g6w6.js} +1 -1
- package/.output/ui/assets/{_sessionId-DPiw4uu2.js → _sessionId-B2S61lDJ.js} +1 -1
- package/.output/ui/assets/{_sessionId-Bo9J8C5J.js → _sessionId-CS6hqj8-.js} +1 -1
- package/.output/ui/assets/{index-BL5id77_.js → index-C6V66rNI.js} +1 -1
- package/.output/ui/assets/{index-icwV1YtX.js → index-DY5xBYHr.js} +1 -1
- package/.output/ui/assets/{index-Wd6TK76x.js → index-DgyIeqyV.js} +2 -2
- package/.output/ui/assets/{index-CWSVfojK.js → index-HLs5jTyi.js} +1 -1
- package/.output/ui/assets/{json-viewer-Cpr3uw1I.js → json-viewer-i5LcN8e7.js} +1 -1
- package/.output/ui/assets/{jszip.min-Cncg6JOi.js → jszip.min-yNpb9qnf.js} +1 -1
- package/.output/ui/index.html +1 -1
- package/.output/workers/logFinalizer.worker.js +41 -17739
- package/.output/workers/sessionWorkerEntry.js +41 -17735
- package/package.json +7 -7
- package/.output/server/_ssr/empty-plugin-adapters-BFgPZ6_d.mjs +0 -6
- package/.output/server/_ssr/publicBasePathContext-IH2ilOfu.mjs +0 -176
- package/.output/server/_ssr/router-weYHAqCb.mjs +0 -27177
- package/.output/server/_ssr/start-COQu_AgD.mjs +0 -57
- package/.output/server/_tanstack-start-manifest_v-ClTaMkEj.mjs +0 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as p}from"./index.mjs";import"../_libs/seroval.mjs";import"../_libs/react.mjs";import"node:async_hooks";import"../_libs/h3-v2.mjs";import"../_libs/rou3.mjs";import"../_libs/srvx.mjs";import"node:http";import"node:stream";import"node:stream/promises";import"node:https";import"node:http2";import"../_libs/tanstack__router-core.mjs";import"../_libs/cookie-es.mjs";import"../_libs/seroval-plugins.mjs";import"../_libs/tanstack__history.mjs";import"node:stream/web";import"../_libs/tanstack__react-router.mjs";import"../_libs/react-dom.mjs";import"util";import"crypto";import"async_hooks";import"stream";import"../_libs/isbot.mjs";function a(i,t){for(let r=0,e=t.length;r<e;r++){const o=t[r];i.has(o)||(i.add(o),o.extends&&a(i,o.extends))}}var m=i=>({getOptions:async()=>{const t=await i();if(t.serializationAdapters){const r=new Set;a(r,t.serializationAdapters),t.serializationAdapters=Array.from(r)}return t},createMiddleware:p});const s=p().server(async({next:i,request:t})=>{const{runWithRequestPublicBasePath:r}=await import("./publicBasePathContext--TAQS2_5.mjs").then(e=>e.p);return r(t,()=>i())}),_=m(()=>({requestMiddleware:[s]}));export{_ as startInstance};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const s=()=>({routes:{__root__:{filePath:"C:/Users/claw/workspace/agent-inspector/src/backend/routes/__root.ts",children:["/$","/livez","/metrics","/readyz","/api/alerts","/api/config","/api/groups","/api/health","/api/instances","/api/logs","/api/mcp","/api/models","/api/pi-agent","/api/providers","/api/runs","/api/runtime","/api/sessions","/api/storage","/proxy/$","/api/ecosystem/packages","/api/ecosystem/tasks","/api/knowledge/candidates","/api/knowledge/project-context","/api/knowledge/search","/api/ecosystem/recipes/$recipeId/run","/api/knowledge/sessions/$sessionId/candidates"],preloads:["/assets/index-D4LX-sw-.js"],scripts:[{attrs:{type:"module",async:!0,src:"/assets/index-D4LX-sw-.js"}}]}}});export{s as tsrStartManifest};
|
package/.output/server/index.mjs
CHANGED
|
@@ -1,320 +1 @@
|
|
|
1
|
-
globalThis.__nitro_main__ = import.
|
|
2
|
-
import { c as NodeResponse, s as serve } from "./_libs/srvx.mjs";
|
|
3
|
-
import { d as defineHandler, H as HTTPError, t as toEventHandler, a as defineLazyEventHandler, b as H3Core } from "./_libs/h3.mjs";
|
|
4
|
-
import { d as decodePath, w as withLeadingSlash, a as withoutTrailingSlash, j as joinURL } from "./_libs/ufo.mjs";
|
|
5
|
-
import { promises } from "node:fs";
|
|
6
|
-
import { fileURLToPath } from "node:url";
|
|
7
|
-
import { dirname, resolve } from "node:path";
|
|
8
|
-
import "node:http";
|
|
9
|
-
import "node:stream";
|
|
10
|
-
import "node:stream/promises";
|
|
11
|
-
import "node:https";
|
|
12
|
-
import "node:http2";
|
|
13
|
-
import "./_libs/rou3.mjs";
|
|
14
|
-
const headers = ((m) => function headersRouteRule(event) {
|
|
15
|
-
for (const [key2, value] of Object.entries(m.options || {})) {
|
|
16
|
-
event.res.headers.set(key2, value);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const assets = {
|
|
20
|
-
"/assets/index-D4LX-sw-.js": {
|
|
21
|
-
"type": "text/javascript; charset=utf-8",
|
|
22
|
-
"etag": '"4ca46-80Birfu694YvXXxcAJa6ekM4QWE"',
|
|
23
|
-
"mtime": "2026-07-28T02:12:18.928Z",
|
|
24
|
-
"size": 313926,
|
|
25
|
-
"path": "../backend-public/assets/index-D4LX-sw-.js"
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
function readAsset(id) {
|
|
29
|
-
const serverDir = dirname(fileURLToPath(globalThis.__nitro_main__));
|
|
30
|
-
return promises.readFile(resolve(serverDir, assets[id].path));
|
|
31
|
-
}
|
|
32
|
-
const publicAssetBases = {};
|
|
33
|
-
function isPublicAssetURL(id = "") {
|
|
34
|
-
if (assets[id]) {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
for (const base in publicAssetBases) {
|
|
38
|
-
if (id.startsWith(base)) {
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
function getAsset(id) {
|
|
45
|
-
return assets[id];
|
|
46
|
-
}
|
|
47
|
-
const METHODS = /* @__PURE__ */ new Set(["HEAD", "GET"]);
|
|
48
|
-
const EncodingMap = {
|
|
49
|
-
gzip: ".gz",
|
|
50
|
-
br: ".br",
|
|
51
|
-
zstd: ".zst"
|
|
52
|
-
};
|
|
53
|
-
const _TahAqH = defineHandler((event) => {
|
|
54
|
-
if (event.req.method && !METHODS.has(event.req.method)) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
let id = decodePath(withLeadingSlash(withoutTrailingSlash(event.url.pathname)));
|
|
58
|
-
let asset;
|
|
59
|
-
const encodingHeader = event.req.headers.get("accept-encoding") || "";
|
|
60
|
-
const encodings = [...encodingHeader.split(",").map((e) => EncodingMap[e.trim()]).filter(Boolean).sort(), ""];
|
|
61
|
-
for (const encoding of encodings) {
|
|
62
|
-
for (const _id of [id + encoding, joinURL(id, "index.html" + encoding)]) {
|
|
63
|
-
const _asset = getAsset(_id);
|
|
64
|
-
if (_asset) {
|
|
65
|
-
asset = _asset;
|
|
66
|
-
id = _id;
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (!asset) {
|
|
72
|
-
if (isPublicAssetURL(id)) {
|
|
73
|
-
event.res.headers.delete("Cache-Control");
|
|
74
|
-
throw new HTTPError({ status: 404 });
|
|
75
|
-
}
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
if (encodings.length > 1) {
|
|
79
|
-
event.res.headers.append("Vary", "Accept-Encoding");
|
|
80
|
-
}
|
|
81
|
-
const ifNotMatch = event.req.headers.get("if-none-match") === asset.etag;
|
|
82
|
-
if (ifNotMatch) {
|
|
83
|
-
event.res.status = 304;
|
|
84
|
-
event.res.statusText = "Not Modified";
|
|
85
|
-
return "";
|
|
86
|
-
}
|
|
87
|
-
const ifModifiedSinceH = event.req.headers.get("if-modified-since");
|
|
88
|
-
const mtimeDate = new Date(asset.mtime);
|
|
89
|
-
if (ifModifiedSinceH && asset.mtime && new Date(ifModifiedSinceH) >= mtimeDate) {
|
|
90
|
-
event.res.status = 304;
|
|
91
|
-
event.res.statusText = "Not Modified";
|
|
92
|
-
return "";
|
|
93
|
-
}
|
|
94
|
-
if (asset.type) {
|
|
95
|
-
event.res.headers.set("Content-Type", asset.type);
|
|
96
|
-
}
|
|
97
|
-
if (asset.etag && !event.res.headers.has("ETag")) {
|
|
98
|
-
event.res.headers.set("ETag", asset.etag);
|
|
99
|
-
}
|
|
100
|
-
if (asset.mtime && !event.res.headers.has("Last-Modified")) {
|
|
101
|
-
event.res.headers.set("Last-Modified", mtimeDate.toUTCString());
|
|
102
|
-
}
|
|
103
|
-
if (asset.encoding && !event.res.headers.has("Content-Encoding")) {
|
|
104
|
-
event.res.headers.set("Content-Encoding", asset.encoding);
|
|
105
|
-
}
|
|
106
|
-
if (asset.size > 0 && !event.res.headers.has("Content-Length")) {
|
|
107
|
-
event.res.headers.set("Content-Length", asset.size.toString());
|
|
108
|
-
}
|
|
109
|
-
return readAsset(id);
|
|
110
|
-
});
|
|
111
|
-
const findRouteRules = /* @__PURE__ */ (() => {
|
|
112
|
-
const $0 = [{ name: "headers", route: "/assets/**", handler: headers, options: { "cache-control": "public, max-age=31536000, immutable" } }];
|
|
113
|
-
return (m, p) => {
|
|
114
|
-
let r = [];
|
|
115
|
-
if (p.charCodeAt(p.length - 1) === 47) p = p.slice(0, -1) || "/";
|
|
116
|
-
let s = p.split("/"), l = s.length;
|
|
117
|
-
if (l > 1) {
|
|
118
|
-
if (s[1] === "assets") {
|
|
119
|
-
r.unshift({ data: $0, params: { "_": s.slice(2).join("/") } });
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return r;
|
|
123
|
-
};
|
|
124
|
-
})();
|
|
125
|
-
const _lazy_9A6hFz = defineLazyEventHandler(() => import("./_chunks/ssr-renderer.mjs"));
|
|
126
|
-
const findRoute = /* @__PURE__ */ (() => {
|
|
127
|
-
const data = { route: "/**", handler: _lazy_9A6hFz };
|
|
128
|
-
return ((_m, p) => {
|
|
129
|
-
return { data, params: { "_": p.slice(1) } };
|
|
130
|
-
});
|
|
131
|
-
})();
|
|
132
|
-
const globalMiddleware = [
|
|
133
|
-
toEventHandler(_TahAqH)
|
|
134
|
-
].filter(Boolean);
|
|
135
|
-
const errorHandler$1 = (error, event) => {
|
|
136
|
-
const res = defaultHandler(error, event);
|
|
137
|
-
return new NodeResponse(typeof res.body === "string" ? res.body : JSON.stringify(res.body, null, 2), res);
|
|
138
|
-
};
|
|
139
|
-
function defaultHandler(error, event) {
|
|
140
|
-
const unhandled = error.unhandled ?? !HTTPError.isError(error);
|
|
141
|
-
const { status = 500, statusText = "" } = unhandled ? {} : error;
|
|
142
|
-
if (status === 404) {
|
|
143
|
-
const url = event.url || new URL(event.req.url);
|
|
144
|
-
const baseURL = "/";
|
|
145
|
-
if (/^\/[^/]/.test(baseURL) && !url.pathname.startsWith(baseURL)) {
|
|
146
|
-
return {
|
|
147
|
-
status: 302,
|
|
148
|
-
headers: new Headers({ location: `${baseURL}${url.pathname.slice(1)}${url.search}` })
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
const headers2 = new Headers(unhandled ? {} : error.headers);
|
|
153
|
-
headers2.set("content-type", "application/json; charset=utf-8");
|
|
154
|
-
const jsonBody = unhandled ? {
|
|
155
|
-
status,
|
|
156
|
-
unhandled: true
|
|
157
|
-
} : typeof error.toJSON === "function" ? error.toJSON() : {
|
|
158
|
-
status,
|
|
159
|
-
statusText,
|
|
160
|
-
message: error.message
|
|
161
|
-
};
|
|
162
|
-
return {
|
|
163
|
-
status,
|
|
164
|
-
statusText,
|
|
165
|
-
headers: headers2,
|
|
166
|
-
body: {
|
|
167
|
-
error: true,
|
|
168
|
-
...jsonBody
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
const errorHandlers = [errorHandler$1];
|
|
173
|
-
async function errorHandler(error, event) {
|
|
174
|
-
for (const handler of errorHandlers) {
|
|
175
|
-
try {
|
|
176
|
-
const response = await handler(error, event, { defaultHandler });
|
|
177
|
-
if (response) {
|
|
178
|
-
return response;
|
|
179
|
-
}
|
|
180
|
-
} catch (error2) {
|
|
181
|
-
console.error(error2);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
function createNitroApp() {
|
|
186
|
-
const captureError = (error, errorCtx) => {
|
|
187
|
-
if (errorCtx?.event) {
|
|
188
|
-
const errors = errorCtx.event.req.context?.nitro?.errors;
|
|
189
|
-
if (errors) {
|
|
190
|
-
errors.push({ error, context: errorCtx });
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
const h3App = createH3App({
|
|
195
|
-
onError(error, event) {
|
|
196
|
-
return errorHandler(error, event);
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
let appHandler = (req) => {
|
|
200
|
-
req.context ||= {};
|
|
201
|
-
req.context.nitro = req.context.nitro || { errors: [] };
|
|
202
|
-
return h3App.fetch(req);
|
|
203
|
-
};
|
|
204
|
-
return {
|
|
205
|
-
fetch: appHandler,
|
|
206
|
-
h3: h3App,
|
|
207
|
-
hooks: void 0,
|
|
208
|
-
captureError
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
function createH3App(config) {
|
|
212
|
-
const h3App = new H3Core(config);
|
|
213
|
-
h3App["~findRoute"] = (event) => findRoute(event.req.method, event.url.pathname);
|
|
214
|
-
h3App["~middleware"].push(...globalMiddleware);
|
|
215
|
-
h3App["~getMiddleware"] = (event, route) => {
|
|
216
|
-
const pathname = event.url.pathname;
|
|
217
|
-
const method = event.req.method;
|
|
218
|
-
const middleware = [];
|
|
219
|
-
const routeRules = getRouteRules(method, pathname);
|
|
220
|
-
event.context.routeRules = routeRules?.routeRules;
|
|
221
|
-
if (routeRules?.routeRuleMiddleware.length) {
|
|
222
|
-
middleware.push(...routeRules.routeRuleMiddleware);
|
|
223
|
-
}
|
|
224
|
-
middleware.push(...h3App["~middleware"]);
|
|
225
|
-
if (route?.data?.middleware?.length) {
|
|
226
|
-
middleware.push(...route.data.middleware);
|
|
227
|
-
}
|
|
228
|
-
return middleware;
|
|
229
|
-
};
|
|
230
|
-
return h3App;
|
|
231
|
-
}
|
|
232
|
-
const APP_ID = "default";
|
|
233
|
-
function useNitroApp() {
|
|
234
|
-
let instance = useNitroApp._instance;
|
|
235
|
-
if (instance) {
|
|
236
|
-
return instance;
|
|
237
|
-
}
|
|
238
|
-
instance = useNitroApp._instance = createNitroApp();
|
|
239
|
-
globalThis.__nitro__ = globalThis.__nitro__ || {};
|
|
240
|
-
globalThis.__nitro__[APP_ID] = instance;
|
|
241
|
-
return instance;
|
|
242
|
-
}
|
|
243
|
-
function getRouteRules(method, pathname) {
|
|
244
|
-
const m = findRouteRules(method, pathname);
|
|
245
|
-
if (!m?.length) {
|
|
246
|
-
return { routeRuleMiddleware: [] };
|
|
247
|
-
}
|
|
248
|
-
const routeRules = {};
|
|
249
|
-
for (const layer of m) {
|
|
250
|
-
for (const rule of layer.data) {
|
|
251
|
-
const currentRule = routeRules[rule.name];
|
|
252
|
-
if (currentRule) {
|
|
253
|
-
if (rule.options === false) {
|
|
254
|
-
delete routeRules[rule.name];
|
|
255
|
-
continue;
|
|
256
|
-
}
|
|
257
|
-
if (typeof currentRule.options === "object" && typeof rule.options === "object") {
|
|
258
|
-
currentRule.options = {
|
|
259
|
-
...currentRule.options,
|
|
260
|
-
...rule.options
|
|
261
|
-
};
|
|
262
|
-
} else {
|
|
263
|
-
currentRule.options = rule.options;
|
|
264
|
-
}
|
|
265
|
-
currentRule.route = rule.route;
|
|
266
|
-
currentRule.params = {
|
|
267
|
-
...currentRule.params,
|
|
268
|
-
...layer.params
|
|
269
|
-
};
|
|
270
|
-
} else if (rule.options !== false) {
|
|
271
|
-
routeRules[rule.name] = {
|
|
272
|
-
...rule,
|
|
273
|
-
params: layer.params
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
const middleware = [];
|
|
279
|
-
const orderedRules = Object.values(routeRules).sort((a, b) => (a.handler?.order || 0) - (b.handler?.order || 0));
|
|
280
|
-
for (const rule of orderedRules) {
|
|
281
|
-
if (rule.options === false || !rule.handler) {
|
|
282
|
-
continue;
|
|
283
|
-
}
|
|
284
|
-
middleware.push(rule.handler(rule));
|
|
285
|
-
}
|
|
286
|
-
return {
|
|
287
|
-
routeRules,
|
|
288
|
-
routeRuleMiddleware: middleware
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
function _captureError(error, type) {
|
|
292
|
-
console.error(`[${type}]`, error);
|
|
293
|
-
useNitroApp().captureError?.(error, { tags: [type] });
|
|
294
|
-
}
|
|
295
|
-
function trapUnhandledErrors() {
|
|
296
|
-
process.on("unhandledRejection", (error) => _captureError(error, "unhandledRejection"));
|
|
297
|
-
process.on("uncaughtException", (error) => _captureError(error, "uncaughtException"));
|
|
298
|
-
}
|
|
299
|
-
const tracingSrvxPlugins = [];
|
|
300
|
-
const _parsedPort = Number.parseInt(process.env.NITRO_PORT ?? process.env.PORT ?? "");
|
|
301
|
-
const port = Number.isNaN(_parsedPort) ? 3e3 : _parsedPort;
|
|
302
|
-
const host = process.env.NITRO_HOST || process.env.HOST;
|
|
303
|
-
const cert = process.env.NITRO_SSL_CERT;
|
|
304
|
-
const key = process.env.NITRO_SSL_KEY;
|
|
305
|
-
const nitroApp = useNitroApp();
|
|
306
|
-
serve({
|
|
307
|
-
port,
|
|
308
|
-
hostname: host,
|
|
309
|
-
tls: cert && key ? {
|
|
310
|
-
cert,
|
|
311
|
-
key
|
|
312
|
-
} : void 0,
|
|
313
|
-
fetch: nitroApp.fetch,
|
|
314
|
-
plugins: [...tracingSrvxPlugins]
|
|
315
|
-
});
|
|
316
|
-
trapUnhandledErrors();
|
|
317
|
-
const nodeServer = {};
|
|
318
|
-
export {
|
|
319
|
-
nodeServer as default
|
|
320
|
-
};
|
|
1
|
+
import{c as T,s as b}from"./_libs/srvx.mjs";import{d as w,H as _,t as E,a as H,b as y}from"./_libs/h3.mjs";import{d as N,w as S,a as x,j as A}from"./_libs/ufo.mjs";import{promises as M}from"node:fs";import{fileURLToPath as L}from"node:url";import{dirname as j,resolve as O}from"node:path";import"node:http";import"node:stream";import"node:stream/promises";import"node:https";import"node:http2";import"./_libs/rou3.mjs";globalThis.__nitro_main__=import.meta.url;const z=(e=>function(t){for(const[r,n]of Object.entries(e.options||{}))t.res.headers.set(r,n)}),u={"/assets/index-D4LX-sw-.js":{type:"text/javascript; charset=utf-8",etag:'"4ca46-80Birfu694YvXXxcAJa6ekM4QWE"',mtime:"2026-07-28T03:22:51.879Z",size:313926,path:"../backend-public/assets/index-D4LX-sw-.js"}};function P(e){const s=j(L(globalThis.__nitro_main__));return M.readFile(O(s,u[e].path))}const C={};function D(e=""){if(u[e])return!0;for(const s in C)if(e.startsWith(s))return!0;return!1}function q(e){return u[e]}const U=new Set(["HEAD","GET"]),k={gzip:".gz",br:".br",zstd:".zst"},I=w(e=>{if(e.req.method&&!U.has(e.req.method))return;let s=N(S(x(e.url.pathname))),t;const n=[...(e.req.headers.get("accept-encoding")||"").split(",").map(i=>k[i.trim()]).filter(Boolean).sort(),""];for(const i of n)for(const l of[s+i,A(s,"index.html"+i)]){const f=q(l);if(f){t=f,s=l;break}}if(!t){if(D(s))throw e.res.headers.delete("Cache-Control"),new _({status:404});return}if(n.length>1&&e.res.headers.append("Vary","Accept-Encoding"),e.req.headers.get("if-none-match")===t.etag)return e.res.status=304,e.res.statusText="Not Modified","";const a=e.req.headers.get("if-modified-since"),o=new Date(t.mtime);return a&&t.mtime&&new Date(a)>=o?(e.res.status=304,e.res.statusText="Not Modified",""):(t.type&&e.res.headers.set("Content-Type",t.type),t.etag&&!e.res.headers.has("ETag")&&e.res.headers.set("ETag",t.etag),t.mtime&&!e.res.headers.has("Last-Modified")&&e.res.headers.set("Last-Modified",o.toUTCString()),t.encoding&&!e.res.headers.has("Content-Encoding")&&e.res.headers.set("Content-Encoding",t.encoding),t.size>0&&!e.res.headers.has("Content-Length")&&e.res.headers.set("Content-Length",t.size.toString()),P(s))}),$=(()=>{const e=[{name:"headers",route:"/assets/**",handler:z,options:{"cache-control":"public, max-age=31536000, immutable"}}];return(s,t)=>{let r=[];t.charCodeAt(t.length-1)===47&&(t=t.slice(0,-1)||"/");let n=t.split("/");return n.length>1&&n[1]==="assets"&&r.unshift({data:e,params:{_:n.slice(2).join("/")}}),r}})(),B=H(()=>import("./_chunks/ssr-renderer.mjs")),J=(()=>{const e={route:"/**",handler:B};return((s,t)=>({data:e,params:{_:t.slice(1)}}))})(),X=[E(I)].filter(Boolean),W=(e,s)=>{const t=R(e,s);return new T(typeof t.body=="string"?t.body:JSON.stringify(t.body,null,2),t)};function R(e,s){const t=e.unhandled??!_.isError(e),{status:r=500,statusText:n=""}=t?{}:e;if(r===404){const o=s.url||new URL(s.req.url),i="/";if(/^\/[^/]/.test(i)&&!o.pathname.startsWith(i))return{status:302,headers:new Headers({location:`${i}${o.pathname.slice(1)}${o.search}`})}}const c=new Headers(t?{}:e.headers);c.set("content-type","application/json; charset=utf-8");const a=t?{status:r,unhandled:!0}:typeof e.toJSON=="function"?e.toJSON():{status:r,statusText:n,message:e.message};return{status:r,statusText:n,headers:c,body:{error:!0,...a}}}const F=[W];async function Y(e,s){for(const t of F)try{const r=await t(e,s,{defaultHandler:R});if(r)return r}catch(r){console.error(r)}}function G(){const e=(r,n)=>{if(n?.event){const c=n.event.req.context?.nitro?.errors;c&&c.push({error:r,context:n})}},s=K({onError(r,n){return Y(r,n)}});return{fetch:r=>(r.context||={},r.context.nitro=r.context.nitro||{errors:[]},s.fetch(r)),h3:s,hooks:void 0,captureError:e}}function K(e){const s=new y(e);return s["~findRoute"]=t=>J(t.req.method,t.url.pathname),s["~middleware"].push(...X),s["~getMiddleware"]=(t,r)=>{const n=t.url.pathname,c=t.req.method,a=[],o=V(c,n);return t.context.routeRules=o?.routeRules,o?.routeRuleMiddleware.length&&a.push(...o.routeRuleMiddleware),a.push(...s["~middleware"]),r?.data?.middleware?.length&&a.push(...r.data.middleware),a},s}const Q="default";function d(){let e=d._instance;return e||(e=d._instance=G(),globalThis.__nitro__=globalThis.__nitro__||{},globalThis.__nitro__[Q]=e,e)}function V(e,s){const t=$(e,s);if(!t?.length)return{routeRuleMiddleware:[]};const r={};for(const a of t)for(const o of a.data){const i=r[o.name];if(i){if(o.options===!1){delete r[o.name];continue}typeof i.options=="object"&&typeof o.options=="object"?i.options={...i.options,...o.options}:i.options=o.options,i.route=o.route,i.params={...i.params,...a.params}}else o.options!==!1&&(r[o.name]={...o,params:a.params})}const n=[],c=Object.values(r).sort((a,o)=>(a.handler?.order||0)-(o.handler?.order||0));for(const a of c)a.options===!1||!a.handler||n.push(a.handler(a));return{routeRules:r,routeRuleMiddleware:n}}function h(e,s){console.error(`[${s}]`,e),d().captureError?.(e,{tags:[s]})}function Z(){process.on("unhandledRejection",e=>h(e,"unhandledRejection")),process.on("uncaughtException",e=>h(e,"uncaughtException"))}const v=[],p=Number.parseInt(process.env.NITRO_PORT??process.env.PORT??""),ee=Number.isNaN(p)?3e3:p,te=process.env.NITRO_HOST||process.env.HOST,m=process.env.NITRO_SSL_CERT,g=process.env.NITRO_SSL_KEY,se=d();b({port:ee,hostname:te,tls:m&&g?{cert:m,key:g}:void 0,fetch:se.fetch,plugins:[...v]});Z();const me={};export{me as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as p,j as t,x as f,C as z,E as ne}from"./index-Wd6TK76x.js";import{c as re,g as A,r as D,a as R,X as ae,B as oe,R as ie,C as de,M as V,b as J,d as B,e as F,f as le,h as ce,L as ue}from"./ProxyViewerContainer-DhIB_ZAU.js";const me=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],xe=re("equal",me),fe="";function y(e){if(e.length===0)return fe;let s="";for(let n=0;n<e.length;n++){const a=e[n];a!==void 0&&(typeof a=="number"?s+=`[${a}]`:n===0?s+=a:s+=`.${a}`)}return s}function pe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $(e){if(typeof e=="string")try{return C(JSON.parse(e))}catch{return{kind:"primitive",value:e}}return C(e)}function C(e){if(e===null)return{kind:"primitive",value:null};if(typeof e=="string")return{kind:"primitive",value:e};if(typeof e=="number")return{kind:"primitive",value:e};if(typeof e=="boolean")return{kind:"primitive",value:e};if(Array.isArray(e))return{kind:"array",value:e.map(s=>C(s))};if(pe(e)){const s={};for(const n of Object.keys(e).sort())s[n]=C(e[n]);return{kind:"object",value:s}}return{kind:"primitive",value:null}}function he(e,s){const n=[];return S([],e,s,n),n}function S(e,s,n,a){const c=y(e);if(q(s,n)){a.push({kind:"equal",path:c,value:s});return}if(s.kind!==n.kind){a.push({kind:"changed",path:c,left:s,right:n});return}if(s.kind==="primitive"&&n.kind==="primitive"){a.push({kind:"changed",path:c,left:s,right:n});return}if(s.kind==="object"&&n.kind==="object"){const l=Object.keys(s.value),r=Object.keys(n.value),o=new Set(r);for(const d of l){const x=s.value[d];if(x!==void 0)if(!o.has(d))a.push({kind:"removed",path:y([...e,d]),value:x});else{const h=n.value[d];if(h===void 0)continue;S([...e,d],x,h,a)}}for(const d of r){if(l.includes(d))continue;const x=n.value[d];x!==void 0&&a.push({kind:"added",path:y([...e,d]),value:x})}return}if(s.kind==="array"&&n.kind==="array"){const l=Math.min(s.value.length,n.value.length);for(let r=0;r<l;r++){const o=s.value[r],d=n.value[r];o===void 0||d===void 0||S([...e,r],o,d,a)}for(let r=l;r<n.value.length;r++){const o=n.value[r];o!==void 0&&a.push({kind:"added",path:y([...e,r]),value:o})}for(let r=l;r<s.value.length;r++){const o=s.value[r];o!==void 0&&a.push({kind:"removed",path:y([...e,r]),value:o})}}}function q(e,s){if(e.kind!==s.kind)return!1;if(e.kind==="primitive"&&s.kind==="primitive")return e.value===s.value;if(e.kind==="array"&&s.kind==="array"){if(e.value.length!==s.value.length)return!1;for(let n=0;n<e.value.length;n++){const a=e.value[n],c=s.value[n];if(a===void 0||c===void 0||!q(a,c))return!1}return!0}if(e.kind==="object"&&s.kind==="object"){const n=Object.keys(e.value),a=Object.keys(s.value);if(n.length!==a.length)return!1;for(const c of n){const l=e.value[c],r=s.value[c];if(l===void 0||r===void 0||!q(l,r))return!1}return!0}return!1}function v(e,s=80){let n;switch(e.kind){case"primitive":n=e.value===null?"null":JSON.stringify(e.value);break;case"array":n=`[… ${e.value.length} items]`;break;case"object":n=`{… ${Object.keys(e.value).length} keys}`;break}return n.length>s&&(n=`${n.slice(0,s-1)}…`),n}const be="flex flex-col gap-3 border-b border-border px-3 py-3 sm:flex-row sm:items-start sm:gap-4 sm:px-4",ge="grid min-w-0 grid-cols-1 gap-x-2 gap-y-0.5 px-3 py-2 text-xs md:grid-cols-[200px_minmax(0,1fr)_minmax(0,1fr)]";function N(e,s=2){return JSON.stringify(T(e),null,s)}function T(e){switch(e.kind){case"primitive":return e.value;case"array":return e.value.map(T);case"object":{const s={};for(const[n,a]of Object.entries(e.value))s[n]=T(a);return s}}}function w({text:e,defaultExpandDepth:s}){return t.jsx(p.Suspense,{fallback:t.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:t.jsx(ue,{text:e,defaultExpandDepth:s})})}function _(e){if(e==="")return"";for(let s=e.length-1;s>=0;s--){const n=e[s];if(n==="."||n==="[")return e.substring(0,s)}return""}function K(e){return e.kind==="equal"&&(e.value.kind==="object"||e.value.kind==="array")}function ve(e){const s=[];let n=0;for(;n<e.length;){const a=e[n];if(a!==void 0&&K(a)){const c=_(a.path);let l=n+1;for(;l<e.length;){const r=e[l];if(r===void 0||!K(r)||_(r.path)!==c)break;l++}if(l-n>1){const r=[];for(let o=n;o<l;o++){const d=e[o];d!==void 0&&d.kind==="equal"&&r.push(d)}s.push({kind:"equal-run",ops:r}),n=l;continue}}a!==void 0&&s.push({kind:"single",op:a}),n++}return s}const H={added:{icon:J,accent:"text-status-success",bg:"bg-status-success/5 hover:bg-status-success/10",border:"border-l-status-success",label:"ADDED"},removed:{icon:V,accent:"text-status-danger",bg:"bg-status-danger/5 hover:bg-status-danger/10",border:"border-l-status-danger",label:"REMOVED"},changed:{icon:B,accent:"text-status-watch",bg:"bg-status-watch/5 hover:bg-status-watch/10",border:"border-l-status-watch",label:"CHANGED"},equal:{icon:xe,accent:"text-muted-foreground/70",bg:"bg-muted/20 hover:bg-muted/30",border:"border-l-muted-foreground/20",label:"EQUAL"}};function ke({ops:e,expanded:s,onToggle:n}){const a=e[0],c=e[e.length-1];if(a===void 0||c===void 0)return t.jsx("div",{className:"text-muted-foreground/40 text-xs",children:"—"});const l=a.path,r=c.path,o=e.length===1?l:`${l} … ${r}`,d=a.value.kind==="array"?`${e.length} equal arrays`:a.value.kind==="object"?`${e.length} equal objects`:"equal",x=H.equal;return t.jsxs("div",{className:f("border-l-4 rounded-sm",x.border,x.bg),children:[t.jsxs("button",{type:"button",onClick:n,className:"w-full text-left flex items-center gap-2 px-3 py-1.5 text-xs text-muted-foreground cursor-pointer",children:[t.jsx(F,{className:f("size-3 transition-transform shrink-0",s&&"rotate-90")}),t.jsx(x.icon,{className:f("size-3 shrink-0",x.accent)}),t.jsx("span",{className:"font-mono truncate flex-1",title:`${l} … ${r}`,children:o}),t.jsx("span",{className:f("text-[10px] uppercase tracking-wider shrink-0",x.accent),children:x.label}),t.jsxs("span",{className:"text-muted-foreground/60 shrink-0",children:["(",d,")"]})]}),s&&t.jsx("div",{className:"ml-5 mt-1 mb-2 space-y-2 pr-2",children:e.map(h=>t.jsxs("div",{className:"border border-border/50 rounded p-2 bg-muted/20",children:[t.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-1",children:h.path}),t.jsx(w,{text:N(h.value),defaultExpandDepth:0})]},h.path))})]})}function je({op:e,idx:s,copiedPath:n,onCopyPath:a,expanded:c,onToggle:l}){const r=H[e.kind],o=r.icon,d=e.kind==="added"||e.kind==="removed"?e.value.kind==="object"||e.value.kind==="array":e.kind==="changed"?e.left.kind==="object"||e.left.kind==="array"||e.right.kind==="object"||e.right.kind==="array":!1,x=e.kind==="changed"?[{text:v(e.left,400),tone:"text-status-danger line-through"},{text:v(e.right,400),tone:"text-status-success"}]:e.kind==="removed"?[{text:v(e.value,400),tone:"text-status-danger line-through"}]:e.kind==="added"?[{text:v(e.value,400),tone:"text-status-success"}]:[{text:v(e.value,400),tone:"text-muted-foreground"}],h=n===e.path&&e.path!=="";return t.jsxs("div",{"data-diff-idx":s,"data-diff-kind":e.kind,className:f("border-l-4 rounded-sm px-3 py-2 my-0.5 transition-colors",r.border,r.bg),children:[t.jsxs("button",{type:"button",onClick:l,disabled:!d,className:f("w-full flex items-center gap-2 text-xs text-left rounded-sm",d?"cursor-pointer":"cursor-default"),"aria-expanded":d?c:void 0,"aria-label":d?c?`Collapse ${e.path||"root"}`:`Expand ${e.path||"root"}`:void 0,children:[d?t.jsx(F,{className:f("size-3 shrink-0 transition-transform",r.accent,c&&"rotate-90")}):t.jsx("span",{className:"size-3 shrink-0","aria-hidden":"true"}),t.jsx(o,{className:f("size-3.5 shrink-0",r.accent),strokeWidth:2.5}),t.jsx("span",{className:"font-mono truncate flex-1 min-w-0",title:e.path||"(root)",children:e.path===""?"(root)":e.path}),t.jsx("span",{className:f("text-[9px] font-bold uppercase tracking-wider shrink-0 px-1.5 py-0.5 rounded",r.accent,e.kind==="equal"?"bg-muted/40":"bg-background/60"),children:r.label}),e.path!==""&&t.jsx("span",{role:"button",tabIndex:0,onClick:b=>{b.stopPropagation(),a(e.path)},onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.stopPropagation(),b.preventDefault(),a(e.path))},className:f("shrink-0 p-1 rounded transition-colors cursor-pointer inline-flex items-center justify-center",h?"text-status-success":"text-muted-foreground/50 hover:text-foreground hover:bg-muted"),"aria-label":h?"Copied":"Copy",title:h?"Copied!":"Copy",children:h?t.jsx(le,{className:"size-3"}):t.jsx(ce,{className:"size-3"})})]}),x.map((b,E)=>t.jsx("div",{className:f("font-mono text-xs mt-1 break-all pl-5",b.tone),children:b.text},E)),t.jsx("div",{className:"overflow-hidden transition-all duration-200",style:{maxHeight:c&&d?"2000px":"0"},"aria-hidden":!c,children:c&&d&&e.kind!=="equal"?t.jsx(ye,{op:e}):null})]})}function ye({op:e}){if(e.kind==="added"||e.kind==="removed")return t.jsx("div",{className:"pl-5 mt-2 border border-border/50 rounded p-2 bg-muted/20",children:t.jsx(w,{text:N(e.value),defaultExpandDepth:0})});const s=e.left.kind==="object"||e.left.kind==="array",n=e.right.kind==="object"||e.right.kind==="array";return!s&&!n?t.jsx("div",{className:"pl-5 mt-2 text-xs text-muted-foreground/70 italic",children:"Primitive values are shown inline above."}):t.jsxs("div",{className:"pl-5 mt-2 grid grid-cols-1 md:grid-cols-2 gap-2",children:[t.jsxs("div",{className:"rounded border border-status-danger/30 bg-status-danger/5 p-2",children:[t.jsx("div",{className:"mb-1 text-[10px] uppercase tracking-wider text-status-danger",children:"Old"}),t.jsx(w,{text:N(e.left),defaultExpandDepth:0})]}),t.jsxs("div",{className:"rounded border border-status-success/30 bg-status-success/5 p-2",children:[t.jsx("div",{className:"mb-1 text-[10px] uppercase tracking-wider text-status-success",children:"New"}),t.jsx(w,{text:N(e.right),defaultExpandDepth:0})]})]})}function Ne({counts:e,onJumpTo:s}){const n=e.added+e.removed+e.changed;return t.jsxs("div",{className:"px-4 py-2 border-b border-border bg-muted/20 flex items-center gap-2 text-xs flex-wrap",children:[t.jsxs("span",{className:"text-muted-foreground font-medium",children:[n," ",n===1?"change":"changes"]}),t.jsxs("button",{type:"button",onClick:()=>s("removed"),disabled:e.removed===0,className:f("inline-flex items-center gap-1 px-2 py-0.5 rounded-full border cursor-pointer transition-colors",e.removed>0?"border-status-danger/40 bg-status-danger/10 text-status-danger hover:bg-status-danger/20":"border-border text-muted-foreground/40 cursor-not-allowed"),title:e.removed>0?"Jump to first removed":"No removals",children:[t.jsx(V,{className:"size-3"}),e.removed," removed"]}),t.jsxs("button",{type:"button",onClick:()=>s("added"),disabled:e.added===0,className:f("inline-flex items-center gap-1 px-2 py-0.5 rounded-full border cursor-pointer transition-colors",e.added>0?"border-status-success/40 bg-status-success/10 text-status-success hover:bg-status-success/20":"border-border text-muted-foreground/40 cursor-not-allowed"),title:e.added>0?"Jump to first added":"No additions",children:[t.jsx(J,{className:"size-3"}),e.added," added"]}),t.jsxs("button",{type:"button",onClick:()=>s("changed"),disabled:e.changed===0,className:f("inline-flex items-center gap-1 px-2 py-0.5 rounded-full border cursor-pointer transition-colors",e.changed>0?"border-status-watch/40 bg-status-watch/10 text-status-watch hover:bg-status-watch/20":"border-border text-muted-foreground/40 cursor-not-allowed"),title:e.changed>0?"Jump to first changed":"No changes",children:[t.jsx(B,{className:"size-3"}),e.changed," changed"]})]})}function we({mode:e,onChange:s}){return t.jsxs("div",{className:"inline-flex rounded-md border border-border overflow-hidden",children:[t.jsxs("button",{type:"button",onClick:()=>s("unified"),"aria-pressed":e==="unified",className:f("flex items-center gap-1 px-2 py-1 text-xs transition-colors cursor-pointer",e==="unified"?"bg-muted text-foreground":"hover:bg-muted/50 text-muted-foreground"),title:"Unified view (single column, emphasized diffs)",children:[t.jsx(ie,{className:"size-3"}),"Unified"]}),t.jsxs("button",{type:"button",onClick:()=>s("split"),"aria-pressed":e==="split",className:f("flex items-center gap-1 px-2 py-1 text-xs transition-colors border-l border-border cursor-pointer",e==="split"?"bg-muted text-foreground":"hover:bg-muted/50 text-muted-foreground"),title:"Split view (path | left | right)",children:[t.jsx(de,{className:"size-3"}),"Split"]})]})}function M({log:e,side:s,displayNumber:n}){const a=R(e);return t.jsxs("div",{className:"flex-1 min-w-0 space-y-1 text-xs",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(oe,{variant:"outline",className:f("text-[10px] px-1.5 py-0 h-5 font-mono shrink-0",s==="left"?"border-status-danger/40 text-status-danger":"border-status-success/40 text-status-success"),children:s==="left"?"← Left":"Right →"}),t.jsxs("span",{className:"font-mono text-status-info",title:`Log ID ${String(e.id)}`,children:["#",n]}),e.model!==null&&t.jsx("span",{className:"min-w-0 truncate font-mono leading-snug text-muted-foreground",children:e.model})]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 font-mono text-muted-foreground",children:[e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&t.jsxs("span",{className:"text-status-success",children:["KV Cache +",z(e.cacheCreationInputTokens)]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&t.jsxs("span",{className:"text-status-accent",children:["KV Cache ~",z(e.cacheReadInputTokens)]}),t.jsx("span",{className:"truncate",title:e.timestamp,children:e.timestamp})]}),t.jsxs("div",{className:"text-muted-foreground/70 font-mono truncate",title:a,children:["session: ",a]})]})}function Se({left:e,right:s,leftDisplayNumber:n,rightDisplayNumber:a,onClose:c}){const l=p.useRef(null),r=p.useRef(null),o=p.useRef(null),d=p.useMemo(()=>{const i=A(D(e)).analyzeRequest(e.rawRequestBody),u=A(D(s)).analyzeRequest(s.rawRequestBody),m=$(i.comparisonValue),g=$(u.comparisonValue);return he(m,g)},[e.apiFormat,e.path,e.rawRequestBody,s.apiFormat,s.path,s.rawRequestBody]),x=p.useMemo(()=>ve(d),[d]),h=p.useMemo(()=>{let i=0,u=0,m=0;for(const g of x)if(g.kind==="single")switch(g.op.kind){case"added":i++;break;case"removed":u++;break;case"changed":m++;break}return{added:i,removed:u,changed:m}},[x]),[b,E]=p.useState(new Set),U=i=>{E(u=>{const m=new Set(u);return m.has(i)?m.delete(i):m.add(i),m})},[G,I]=p.useState(new Set),Q=i=>{I(u=>{const m=new Set(u);return m.has(i)?m.delete(i):m.add(i),m})};p.useEffect(()=>{I(new Set)},[e.id,s.id]);const[O,W]=p.useState("unified"),P=p.useRef(null),[X,L]=p.useState(null),j=p.useRef(null),Y=i=>{ne(i).then(u=>{u&&(L(i),j.current!==null&&clearTimeout(j.current),j.current=setTimeout(()=>L(null),1500))})};p.useEffect(()=>()=>{j.current!==null&&clearTimeout(j.current)},[]);const Z=i=>{const u=x.findIndex(k=>k.kind==="single"&&k.op.kind===i);if(u===-1)return;const m=P.current;if(m===null)return;const g=m.querySelector(`[data-diff-idx="${u}"]`);g!==null&&g.scrollIntoView({behavior:"smooth",block:"center"})};p.useEffect(()=>{o.current=document.activeElement instanceof HTMLElement?document.activeElement:null,r.current?.focus();const i=m=>{m.key==="Escape"&&c()};document.addEventListener("keydown",i);const u=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",i),document.body.style.overflow=u,o.current?.focus()}},[c]);const ee=i=>{if(i.stopPropagation(),i.key!=="Tab")return;const u=l.current;if(u===null)return;const m=Array.from(u.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), [tabindex]:not([tabindex="-1"])')),g=m[0],k=m[m.length-1];if(!(g===void 0||k===void 0)){if(i.shiftKey&&document.activeElement===g){i.preventDefault(),k.focus();return}!i.shiftKey&&document.activeElement===k&&(i.preventDefault(),g.focus())}},te=R(e)===R(s),se=d.length===1&&d[0]?.kind==="equal";return t.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end",role:"dialog","aria-modal":"true","aria-label":"Compare two log requests",children:[t.jsx("button",{type:"button",onClick:c,"aria-label":"Close compare drawer",className:"absolute inset-0 bg-black/40 cursor-default",tabIndex:-1}),t.jsxs("div",{ref:l,className:f("relative overflow-x-hidden bg-background border-l border-border shadow-xl","w-full md:w-[70vw] max-w-[1100px] flex flex-col h-full"),onClick:i=>i.stopPropagation(),onKeyDown:ee,children:[t.jsxs("div",{className:be,children:[t.jsxs("div",{className:"grid min-w-0 flex-1 grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4",children:[t.jsx(M,{log:e,side:"left",displayNumber:n}),t.jsx(M,{log:s,side:"right",displayNumber:a})]}),t.jsxs("div",{className:"flex w-full shrink-0 items-center justify-between gap-2 sm:w-auto sm:justify-start",children:[t.jsx(we,{mode:O,onChange:W}),t.jsx("button",{ref:r,type:"button",onClick:c,"aria-label":"Close",className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted cursor-pointer",children:t.jsx(ae,{className:"size-4"})})]})]}),!te&&t.jsx("div",{className:"border-b border-border bg-warning/10 px-4 py-1.5 text-xs text-foreground",children:"Heads up: the two selected logs are from different sessions."}),se?t.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto flex items-center justify-center text-muted-foreground text-sm",children:"The two Request payloads are identical."}):t.jsxs(t.Fragment,{children:[t.jsx(Ne,{counts:h,onJumpTo:Z}),t.jsx("div",{ref:P,className:"flex-1 min-h-0 overflow-y-auto",children:O==="unified"?t.jsx("div",{className:"px-3 py-2 space-y-0.5",children:x.map((i,u)=>{if(i.kind==="equal-run")return t.jsx(ke,{ops:i.ops,expanded:b.has(u),onToggle:()=>U(u)},`r${u}`);const m=i.op;return t.jsx(je,{op:m,idx:u,copiedPath:X,onCopyPath:Y,expanded:G.has(u),onToggle:()=>Q(u)},`o${u}`)})}):t.jsx(Ce,{grouped:x,left:e,right:s,leftDisplayNumber:n,rightDisplayNumber:a})})]})]})]})}function Ce({grouped:e,left:s,right:n,leftDisplayNumber:a,rightDisplayNumber:c}){return t.jsxs("div",{"data-compare-layout":"responsive-split",className:ge,children:[t.jsxs("div",{className:"col-span-1 mb-2 grid grid-cols-1 gap-x-2 gap-y-1 border-b border-border pb-2 text-[10px] uppercase tracking-wider text-muted-foreground md:col-span-3 md:grid-cols-[200px_minmax(0,1fr)_minmax(0,1fr)]",children:[t.jsx("span",{children:"Path"}),t.jsxs("span",{title:`Log ID ${String(s.id)}`,children:["Left (Log #",a,")"]}),t.jsxs("span",{title:`Log ID ${String(n.id)}`,children:["Right (Log #",c,")"]})]}),e.map((l,r)=>{if(l.kind==="equal-run")return t.jsxs("div",{className:"col-span-1 px-2 py-1 text-xs text-muted-foreground/60 md:col-span-3",children:[l.ops.length," equal siblings collapsed — switch to Unified to expand"]},r);const o=l.op;return o.kind==="equal"?t.jsxs("div",{className:"col-span-1 grid min-w-0 grid-cols-1 gap-x-2 gap-y-1 px-2 py-0.5 text-muted-foreground md:col-span-3 md:grid-cols-[200px_minmax(0,1fr)_minmax(0,1fr)]",children:[t.jsx("span",{className:"font-mono text-xs truncate",title:o.path,children:o.path}),t.jsx("span",{className:"font-mono text-xs break-all opacity-60",children:v(o.value,200)}),t.jsx("span",{className:"font-mono text-xs break-all opacity-60",children:v(o.value,200)})]},r):o.kind==="added"?t.jsxs("div",{className:"col-span-1 rounded border-l-2 border-l-status-success bg-status-success/5 px-2 py-1 text-xs md:col-span-3",children:[t.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-0.5",children:o.path}),t.jsxs("div",{className:"font-mono break-all text-status-success",children:["+ ",v(o.value,400)]})]},r):o.kind==="removed"?t.jsxs("div",{className:"col-span-1 rounded border-l-2 border-l-status-danger bg-status-danger/5 px-2 py-1 text-xs md:col-span-3",children:[t.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-0.5",children:o.path}),t.jsxs("div",{className:"font-mono break-all text-status-danger line-through",children:["− ",v(o.value,400)]})]},r):t.jsxs("div",{className:"col-span-1 rounded border-l-2 border-l-status-watch bg-status-watch/5 px-2 py-1 text-xs md:col-span-3",children:[t.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-1",children:o.path}),t.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[t.jsx("div",{className:"font-mono break-all text-status-danger line-through",children:v(o.left,400)}),t.jsx("div",{className:"font-mono break-all text-status-success",children:v(o.right,400)})]})]},r)})]})}export{be as COMPARE_RESPONSIVE_HEADER_CLASS_NAME,ge as COMPARE_RESPONSIVE_SPLIT_CLASS_NAME,Se as CompareDrawer};
|
|
1
|
+
import{r as p,j as t,x as f,C as z,E as ne}from"./index-DgyIeqyV.js";import{c as re,g as A,r as D,a as R,X as ae,B as oe,R as ie,C as de,M as V,b as J,d as B,e as F,f as le,h as ce,L as ue}from"./ProxyViewerContainer-vPd7g0Xn.js";const me=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],xe=re("equal",me),fe="";function y(e){if(e.length===0)return fe;let s="";for(let n=0;n<e.length;n++){const a=e[n];a!==void 0&&(typeof a=="number"?s+=`[${a}]`:n===0?s+=a:s+=`.${a}`)}return s}function pe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $(e){if(typeof e=="string")try{return C(JSON.parse(e))}catch{return{kind:"primitive",value:e}}return C(e)}function C(e){if(e===null)return{kind:"primitive",value:null};if(typeof e=="string")return{kind:"primitive",value:e};if(typeof e=="number")return{kind:"primitive",value:e};if(typeof e=="boolean")return{kind:"primitive",value:e};if(Array.isArray(e))return{kind:"array",value:e.map(s=>C(s))};if(pe(e)){const s={};for(const n of Object.keys(e).sort())s[n]=C(e[n]);return{kind:"object",value:s}}return{kind:"primitive",value:null}}function he(e,s){const n=[];return S([],e,s,n),n}function S(e,s,n,a){const c=y(e);if(q(s,n)){a.push({kind:"equal",path:c,value:s});return}if(s.kind!==n.kind){a.push({kind:"changed",path:c,left:s,right:n});return}if(s.kind==="primitive"&&n.kind==="primitive"){a.push({kind:"changed",path:c,left:s,right:n});return}if(s.kind==="object"&&n.kind==="object"){const l=Object.keys(s.value),r=Object.keys(n.value),o=new Set(r);for(const d of l){const x=s.value[d];if(x!==void 0)if(!o.has(d))a.push({kind:"removed",path:y([...e,d]),value:x});else{const h=n.value[d];if(h===void 0)continue;S([...e,d],x,h,a)}}for(const d of r){if(l.includes(d))continue;const x=n.value[d];x!==void 0&&a.push({kind:"added",path:y([...e,d]),value:x})}return}if(s.kind==="array"&&n.kind==="array"){const l=Math.min(s.value.length,n.value.length);for(let r=0;r<l;r++){const o=s.value[r],d=n.value[r];o===void 0||d===void 0||S([...e,r],o,d,a)}for(let r=l;r<n.value.length;r++){const o=n.value[r];o!==void 0&&a.push({kind:"added",path:y([...e,r]),value:o})}for(let r=l;r<s.value.length;r++){const o=s.value[r];o!==void 0&&a.push({kind:"removed",path:y([...e,r]),value:o})}}}function q(e,s){if(e.kind!==s.kind)return!1;if(e.kind==="primitive"&&s.kind==="primitive")return e.value===s.value;if(e.kind==="array"&&s.kind==="array"){if(e.value.length!==s.value.length)return!1;for(let n=0;n<e.value.length;n++){const a=e.value[n],c=s.value[n];if(a===void 0||c===void 0||!q(a,c))return!1}return!0}if(e.kind==="object"&&s.kind==="object"){const n=Object.keys(e.value),a=Object.keys(s.value);if(n.length!==a.length)return!1;for(const c of n){const l=e.value[c],r=s.value[c];if(l===void 0||r===void 0||!q(l,r))return!1}return!0}return!1}function v(e,s=80){let n;switch(e.kind){case"primitive":n=e.value===null?"null":JSON.stringify(e.value);break;case"array":n=`[… ${e.value.length} items]`;break;case"object":n=`{… ${Object.keys(e.value).length} keys}`;break}return n.length>s&&(n=`${n.slice(0,s-1)}…`),n}const be="flex flex-col gap-3 border-b border-border px-3 py-3 sm:flex-row sm:items-start sm:gap-4 sm:px-4",ge="grid min-w-0 grid-cols-1 gap-x-2 gap-y-0.5 px-3 py-2 text-xs md:grid-cols-[200px_minmax(0,1fr)_minmax(0,1fr)]";function N(e,s=2){return JSON.stringify(T(e),null,s)}function T(e){switch(e.kind){case"primitive":return e.value;case"array":return e.value.map(T);case"object":{const s={};for(const[n,a]of Object.entries(e.value))s[n]=T(a);return s}}}function w({text:e,defaultExpandDepth:s}){return t.jsx(p.Suspense,{fallback:t.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:t.jsx(ue,{text:e,defaultExpandDepth:s})})}function _(e){if(e==="")return"";for(let s=e.length-1;s>=0;s--){const n=e[s];if(n==="."||n==="[")return e.substring(0,s)}return""}function K(e){return e.kind==="equal"&&(e.value.kind==="object"||e.value.kind==="array")}function ve(e){const s=[];let n=0;for(;n<e.length;){const a=e[n];if(a!==void 0&&K(a)){const c=_(a.path);let l=n+1;for(;l<e.length;){const r=e[l];if(r===void 0||!K(r)||_(r.path)!==c)break;l++}if(l-n>1){const r=[];for(let o=n;o<l;o++){const d=e[o];d!==void 0&&d.kind==="equal"&&r.push(d)}s.push({kind:"equal-run",ops:r}),n=l;continue}}a!==void 0&&s.push({kind:"single",op:a}),n++}return s}const H={added:{icon:J,accent:"text-status-success",bg:"bg-status-success/5 hover:bg-status-success/10",border:"border-l-status-success",label:"ADDED"},removed:{icon:V,accent:"text-status-danger",bg:"bg-status-danger/5 hover:bg-status-danger/10",border:"border-l-status-danger",label:"REMOVED"},changed:{icon:B,accent:"text-status-watch",bg:"bg-status-watch/5 hover:bg-status-watch/10",border:"border-l-status-watch",label:"CHANGED"},equal:{icon:xe,accent:"text-muted-foreground/70",bg:"bg-muted/20 hover:bg-muted/30",border:"border-l-muted-foreground/20",label:"EQUAL"}};function ke({ops:e,expanded:s,onToggle:n}){const a=e[0],c=e[e.length-1];if(a===void 0||c===void 0)return t.jsx("div",{className:"text-muted-foreground/40 text-xs",children:"—"});const l=a.path,r=c.path,o=e.length===1?l:`${l} … ${r}`,d=a.value.kind==="array"?`${e.length} equal arrays`:a.value.kind==="object"?`${e.length} equal objects`:"equal",x=H.equal;return t.jsxs("div",{className:f("border-l-4 rounded-sm",x.border,x.bg),children:[t.jsxs("button",{type:"button",onClick:n,className:"w-full text-left flex items-center gap-2 px-3 py-1.5 text-xs text-muted-foreground cursor-pointer",children:[t.jsx(F,{className:f("size-3 transition-transform shrink-0",s&&"rotate-90")}),t.jsx(x.icon,{className:f("size-3 shrink-0",x.accent)}),t.jsx("span",{className:"font-mono truncate flex-1",title:`${l} … ${r}`,children:o}),t.jsx("span",{className:f("text-[10px] uppercase tracking-wider shrink-0",x.accent),children:x.label}),t.jsxs("span",{className:"text-muted-foreground/60 shrink-0",children:["(",d,")"]})]}),s&&t.jsx("div",{className:"ml-5 mt-1 mb-2 space-y-2 pr-2",children:e.map(h=>t.jsxs("div",{className:"border border-border/50 rounded p-2 bg-muted/20",children:[t.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-1",children:h.path}),t.jsx(w,{text:N(h.value),defaultExpandDepth:0})]},h.path))})]})}function je({op:e,idx:s,copiedPath:n,onCopyPath:a,expanded:c,onToggle:l}){const r=H[e.kind],o=r.icon,d=e.kind==="added"||e.kind==="removed"?e.value.kind==="object"||e.value.kind==="array":e.kind==="changed"?e.left.kind==="object"||e.left.kind==="array"||e.right.kind==="object"||e.right.kind==="array":!1,x=e.kind==="changed"?[{text:v(e.left,400),tone:"text-status-danger line-through"},{text:v(e.right,400),tone:"text-status-success"}]:e.kind==="removed"?[{text:v(e.value,400),tone:"text-status-danger line-through"}]:e.kind==="added"?[{text:v(e.value,400),tone:"text-status-success"}]:[{text:v(e.value,400),tone:"text-muted-foreground"}],h=n===e.path&&e.path!=="";return t.jsxs("div",{"data-diff-idx":s,"data-diff-kind":e.kind,className:f("border-l-4 rounded-sm px-3 py-2 my-0.5 transition-colors",r.border,r.bg),children:[t.jsxs("button",{type:"button",onClick:l,disabled:!d,className:f("w-full flex items-center gap-2 text-xs text-left rounded-sm",d?"cursor-pointer":"cursor-default"),"aria-expanded":d?c:void 0,"aria-label":d?c?`Collapse ${e.path||"root"}`:`Expand ${e.path||"root"}`:void 0,children:[d?t.jsx(F,{className:f("size-3 shrink-0 transition-transform",r.accent,c&&"rotate-90")}):t.jsx("span",{className:"size-3 shrink-0","aria-hidden":"true"}),t.jsx(o,{className:f("size-3.5 shrink-0",r.accent),strokeWidth:2.5}),t.jsx("span",{className:"font-mono truncate flex-1 min-w-0",title:e.path||"(root)",children:e.path===""?"(root)":e.path}),t.jsx("span",{className:f("text-[9px] font-bold uppercase tracking-wider shrink-0 px-1.5 py-0.5 rounded",r.accent,e.kind==="equal"?"bg-muted/40":"bg-background/60"),children:r.label}),e.path!==""&&t.jsx("span",{role:"button",tabIndex:0,onClick:b=>{b.stopPropagation(),a(e.path)},onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.stopPropagation(),b.preventDefault(),a(e.path))},className:f("shrink-0 p-1 rounded transition-colors cursor-pointer inline-flex items-center justify-center",h?"text-status-success":"text-muted-foreground/50 hover:text-foreground hover:bg-muted"),"aria-label":h?"Copied":"Copy",title:h?"Copied!":"Copy",children:h?t.jsx(le,{className:"size-3"}):t.jsx(ce,{className:"size-3"})})]}),x.map((b,E)=>t.jsx("div",{className:f("font-mono text-xs mt-1 break-all pl-5",b.tone),children:b.text},E)),t.jsx("div",{className:"overflow-hidden transition-all duration-200",style:{maxHeight:c&&d?"2000px":"0"},"aria-hidden":!c,children:c&&d&&e.kind!=="equal"?t.jsx(ye,{op:e}):null})]})}function ye({op:e}){if(e.kind==="added"||e.kind==="removed")return t.jsx("div",{className:"pl-5 mt-2 border border-border/50 rounded p-2 bg-muted/20",children:t.jsx(w,{text:N(e.value),defaultExpandDepth:0})});const s=e.left.kind==="object"||e.left.kind==="array",n=e.right.kind==="object"||e.right.kind==="array";return!s&&!n?t.jsx("div",{className:"pl-5 mt-2 text-xs text-muted-foreground/70 italic",children:"Primitive values are shown inline above."}):t.jsxs("div",{className:"pl-5 mt-2 grid grid-cols-1 md:grid-cols-2 gap-2",children:[t.jsxs("div",{className:"rounded border border-status-danger/30 bg-status-danger/5 p-2",children:[t.jsx("div",{className:"mb-1 text-[10px] uppercase tracking-wider text-status-danger",children:"Old"}),t.jsx(w,{text:N(e.left),defaultExpandDepth:0})]}),t.jsxs("div",{className:"rounded border border-status-success/30 bg-status-success/5 p-2",children:[t.jsx("div",{className:"mb-1 text-[10px] uppercase tracking-wider text-status-success",children:"New"}),t.jsx(w,{text:N(e.right),defaultExpandDepth:0})]})]})}function Ne({counts:e,onJumpTo:s}){const n=e.added+e.removed+e.changed;return t.jsxs("div",{className:"px-4 py-2 border-b border-border bg-muted/20 flex items-center gap-2 text-xs flex-wrap",children:[t.jsxs("span",{className:"text-muted-foreground font-medium",children:[n," ",n===1?"change":"changes"]}),t.jsxs("button",{type:"button",onClick:()=>s("removed"),disabled:e.removed===0,className:f("inline-flex items-center gap-1 px-2 py-0.5 rounded-full border cursor-pointer transition-colors",e.removed>0?"border-status-danger/40 bg-status-danger/10 text-status-danger hover:bg-status-danger/20":"border-border text-muted-foreground/40 cursor-not-allowed"),title:e.removed>0?"Jump to first removed":"No removals",children:[t.jsx(V,{className:"size-3"}),e.removed," removed"]}),t.jsxs("button",{type:"button",onClick:()=>s("added"),disabled:e.added===0,className:f("inline-flex items-center gap-1 px-2 py-0.5 rounded-full border cursor-pointer transition-colors",e.added>0?"border-status-success/40 bg-status-success/10 text-status-success hover:bg-status-success/20":"border-border text-muted-foreground/40 cursor-not-allowed"),title:e.added>0?"Jump to first added":"No additions",children:[t.jsx(J,{className:"size-3"}),e.added," added"]}),t.jsxs("button",{type:"button",onClick:()=>s("changed"),disabled:e.changed===0,className:f("inline-flex items-center gap-1 px-2 py-0.5 rounded-full border cursor-pointer transition-colors",e.changed>0?"border-status-watch/40 bg-status-watch/10 text-status-watch hover:bg-status-watch/20":"border-border text-muted-foreground/40 cursor-not-allowed"),title:e.changed>0?"Jump to first changed":"No changes",children:[t.jsx(B,{className:"size-3"}),e.changed," changed"]})]})}function we({mode:e,onChange:s}){return t.jsxs("div",{className:"inline-flex rounded-md border border-border overflow-hidden",children:[t.jsxs("button",{type:"button",onClick:()=>s("unified"),"aria-pressed":e==="unified",className:f("flex items-center gap-1 px-2 py-1 text-xs transition-colors cursor-pointer",e==="unified"?"bg-muted text-foreground":"hover:bg-muted/50 text-muted-foreground"),title:"Unified view (single column, emphasized diffs)",children:[t.jsx(ie,{className:"size-3"}),"Unified"]}),t.jsxs("button",{type:"button",onClick:()=>s("split"),"aria-pressed":e==="split",className:f("flex items-center gap-1 px-2 py-1 text-xs transition-colors border-l border-border cursor-pointer",e==="split"?"bg-muted text-foreground":"hover:bg-muted/50 text-muted-foreground"),title:"Split view (path | left | right)",children:[t.jsx(de,{className:"size-3"}),"Split"]})]})}function M({log:e,side:s,displayNumber:n}){const a=R(e);return t.jsxs("div",{className:"flex-1 min-w-0 space-y-1 text-xs",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(oe,{variant:"outline",className:f("text-[10px] px-1.5 py-0 h-5 font-mono shrink-0",s==="left"?"border-status-danger/40 text-status-danger":"border-status-success/40 text-status-success"),children:s==="left"?"← Left":"Right →"}),t.jsxs("span",{className:"font-mono text-status-info",title:`Log ID ${String(e.id)}`,children:["#",n]}),e.model!==null&&t.jsx("span",{className:"min-w-0 truncate font-mono leading-snug text-muted-foreground",children:e.model})]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 font-mono text-muted-foreground",children:[e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&t.jsxs("span",{className:"text-status-success",children:["KV Cache +",z(e.cacheCreationInputTokens)]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&t.jsxs("span",{className:"text-status-accent",children:["KV Cache ~",z(e.cacheReadInputTokens)]}),t.jsx("span",{className:"truncate",title:e.timestamp,children:e.timestamp})]}),t.jsxs("div",{className:"text-muted-foreground/70 font-mono truncate",title:a,children:["session: ",a]})]})}function Se({left:e,right:s,leftDisplayNumber:n,rightDisplayNumber:a,onClose:c}){const l=p.useRef(null),r=p.useRef(null),o=p.useRef(null),d=p.useMemo(()=>{const i=A(D(e)).analyzeRequest(e.rawRequestBody),u=A(D(s)).analyzeRequest(s.rawRequestBody),m=$(i.comparisonValue),g=$(u.comparisonValue);return he(m,g)},[e.apiFormat,e.path,e.rawRequestBody,s.apiFormat,s.path,s.rawRequestBody]),x=p.useMemo(()=>ve(d),[d]),h=p.useMemo(()=>{let i=0,u=0,m=0;for(const g of x)if(g.kind==="single")switch(g.op.kind){case"added":i++;break;case"removed":u++;break;case"changed":m++;break}return{added:i,removed:u,changed:m}},[x]),[b,E]=p.useState(new Set),U=i=>{E(u=>{const m=new Set(u);return m.has(i)?m.delete(i):m.add(i),m})},[G,I]=p.useState(new Set),Q=i=>{I(u=>{const m=new Set(u);return m.has(i)?m.delete(i):m.add(i),m})};p.useEffect(()=>{I(new Set)},[e.id,s.id]);const[O,W]=p.useState("unified"),P=p.useRef(null),[X,L]=p.useState(null),j=p.useRef(null),Y=i=>{ne(i).then(u=>{u&&(L(i),j.current!==null&&clearTimeout(j.current),j.current=setTimeout(()=>L(null),1500))})};p.useEffect(()=>()=>{j.current!==null&&clearTimeout(j.current)},[]);const Z=i=>{const u=x.findIndex(k=>k.kind==="single"&&k.op.kind===i);if(u===-1)return;const m=P.current;if(m===null)return;const g=m.querySelector(`[data-diff-idx="${u}"]`);g!==null&&g.scrollIntoView({behavior:"smooth",block:"center"})};p.useEffect(()=>{o.current=document.activeElement instanceof HTMLElement?document.activeElement:null,r.current?.focus();const i=m=>{m.key==="Escape"&&c()};document.addEventListener("keydown",i);const u=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",i),document.body.style.overflow=u,o.current?.focus()}},[c]);const ee=i=>{if(i.stopPropagation(),i.key!=="Tab")return;const u=l.current;if(u===null)return;const m=Array.from(u.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), [tabindex]:not([tabindex="-1"])')),g=m[0],k=m[m.length-1];if(!(g===void 0||k===void 0)){if(i.shiftKey&&document.activeElement===g){i.preventDefault(),k.focus();return}!i.shiftKey&&document.activeElement===k&&(i.preventDefault(),g.focus())}},te=R(e)===R(s),se=d.length===1&&d[0]?.kind==="equal";return t.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end",role:"dialog","aria-modal":"true","aria-label":"Compare two log requests",children:[t.jsx("button",{type:"button",onClick:c,"aria-label":"Close compare drawer",className:"absolute inset-0 bg-black/40 cursor-default",tabIndex:-1}),t.jsxs("div",{ref:l,className:f("relative overflow-x-hidden bg-background border-l border-border shadow-xl","w-full md:w-[70vw] max-w-[1100px] flex flex-col h-full"),onClick:i=>i.stopPropagation(),onKeyDown:ee,children:[t.jsxs("div",{className:be,children:[t.jsxs("div",{className:"grid min-w-0 flex-1 grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4",children:[t.jsx(M,{log:e,side:"left",displayNumber:n}),t.jsx(M,{log:s,side:"right",displayNumber:a})]}),t.jsxs("div",{className:"flex w-full shrink-0 items-center justify-between gap-2 sm:w-auto sm:justify-start",children:[t.jsx(we,{mode:O,onChange:W}),t.jsx("button",{ref:r,type:"button",onClick:c,"aria-label":"Close",className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted cursor-pointer",children:t.jsx(ae,{className:"size-4"})})]})]}),!te&&t.jsx("div",{className:"border-b border-border bg-warning/10 px-4 py-1.5 text-xs text-foreground",children:"Heads up: the two selected logs are from different sessions."}),se?t.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto flex items-center justify-center text-muted-foreground text-sm",children:"The two Request payloads are identical."}):t.jsxs(t.Fragment,{children:[t.jsx(Ne,{counts:h,onJumpTo:Z}),t.jsx("div",{ref:P,className:"flex-1 min-h-0 overflow-y-auto",children:O==="unified"?t.jsx("div",{className:"px-3 py-2 space-y-0.5",children:x.map((i,u)=>{if(i.kind==="equal-run")return t.jsx(ke,{ops:i.ops,expanded:b.has(u),onToggle:()=>U(u)},`r${u}`);const m=i.op;return t.jsx(je,{op:m,idx:u,copiedPath:X,onCopyPath:Y,expanded:G.has(u),onToggle:()=>Q(u)},`o${u}`)})}):t.jsx(Ce,{grouped:x,left:e,right:s,leftDisplayNumber:n,rightDisplayNumber:a})})]})]})]})}function Ce({grouped:e,left:s,right:n,leftDisplayNumber:a,rightDisplayNumber:c}){return t.jsxs("div",{"data-compare-layout":"responsive-split",className:ge,children:[t.jsxs("div",{className:"col-span-1 mb-2 grid grid-cols-1 gap-x-2 gap-y-1 border-b border-border pb-2 text-[10px] uppercase tracking-wider text-muted-foreground md:col-span-3 md:grid-cols-[200px_minmax(0,1fr)_minmax(0,1fr)]",children:[t.jsx("span",{children:"Path"}),t.jsxs("span",{title:`Log ID ${String(s.id)}`,children:["Left (Log #",a,")"]}),t.jsxs("span",{title:`Log ID ${String(n.id)}`,children:["Right (Log #",c,")"]})]}),e.map((l,r)=>{if(l.kind==="equal-run")return t.jsxs("div",{className:"col-span-1 px-2 py-1 text-xs text-muted-foreground/60 md:col-span-3",children:[l.ops.length," equal siblings collapsed — switch to Unified to expand"]},r);const o=l.op;return o.kind==="equal"?t.jsxs("div",{className:"col-span-1 grid min-w-0 grid-cols-1 gap-x-2 gap-y-1 px-2 py-0.5 text-muted-foreground md:col-span-3 md:grid-cols-[200px_minmax(0,1fr)_minmax(0,1fr)]",children:[t.jsx("span",{className:"font-mono text-xs truncate",title:o.path,children:o.path}),t.jsx("span",{className:"font-mono text-xs break-all opacity-60",children:v(o.value,200)}),t.jsx("span",{className:"font-mono text-xs break-all opacity-60",children:v(o.value,200)})]},r):o.kind==="added"?t.jsxs("div",{className:"col-span-1 rounded border-l-2 border-l-status-success bg-status-success/5 px-2 py-1 text-xs md:col-span-3",children:[t.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-0.5",children:o.path}),t.jsxs("div",{className:"font-mono break-all text-status-success",children:["+ ",v(o.value,400)]})]},r):o.kind==="removed"?t.jsxs("div",{className:"col-span-1 rounded border-l-2 border-l-status-danger bg-status-danger/5 px-2 py-1 text-xs md:col-span-3",children:[t.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-0.5",children:o.path}),t.jsxs("div",{className:"font-mono break-all text-status-danger line-through",children:["− ",v(o.value,400)]})]},r):t.jsxs("div",{className:"col-span-1 rounded border-l-2 border-l-status-watch bg-status-watch/5 px-2 py-1 text-xs md:col-span-3",children:[t.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-1",children:o.path}),t.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[t.jsx("div",{className:"font-mono break-all text-status-danger line-through",children:v(o.left,400)}),t.jsx("div",{className:"font-mono break-all text-status-success",children:v(o.right,400)})]})]},r)})]})}export{be as COMPARE_RESPONSIVE_HEADER_CLASS_NAME,ge as COMPARE_RESPONSIVE_SPLIT_CLASS_NAME,Se as CompareDrawer};
|