@neuralnomads/codenomad 0.4.0 → 0.6.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/background-processes/manager.js +404 -0
- package/dist/index.js +11 -10
- package/dist/opencode-config/README.md +32 -0
- package/dist/opencode-config/opencode.jsonc +3 -0
- package/dist/opencode-config/package.json +8 -0
- package/dist/opencode-config/plugin/codenomad.ts +32 -0
- package/dist/opencode-config/plugin/lib/background-process.ts +309 -0
- package/dist/opencode-config/plugin/lib/client.ts +165 -0
- package/dist/opencode-config.js +26 -0
- package/dist/plugins/channel.js +40 -0
- package/dist/plugins/handlers.js +17 -0
- package/dist/server/http-server.js +10 -0
- package/dist/server/routes/background-processes.js +60 -0
- package/dist/server/routes/plugin.js +52 -0
- package/dist/server/routes/workspaces.js +11 -4
- package/dist/workspaces/manager.js +125 -2
- package/dist/workspaces/runtime.js +60 -7
- package/package.json +4 -3
- package/public/assets/index-BC0I6SzM.js +1 -0
- package/public/assets/index-CKQiPGtF.css +1 -0
- package/public/assets/{loading-COcLzczZ.js → loading-BIWzmJ53.js} +1 -1
- package/public/assets/main-BSwx5oHC.js +184 -0
- package/public/index.html +3 -3
- package/public/loading.html +3 -3
- package/public/assets/index-CkN21HIV.css +0 -1
- package/public/assets/index-Ct9Ys2qZ.js +0 -1
- package/public/assets/main-CXiy0_wG.js +0 -184
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { PluginChannelManager } from "../../plugins/channel";
|
|
3
|
+
import { buildPingEvent, handlePluginEvent } from "../../plugins/handlers";
|
|
4
|
+
const PluginEventSchema = z.object({
|
|
5
|
+
type: z.string().min(1),
|
|
6
|
+
properties: z.record(z.unknown()).optional(),
|
|
7
|
+
});
|
|
8
|
+
export function registerPluginRoutes(app, deps) {
|
|
9
|
+
const channel = new PluginChannelManager(deps.logger.child({ component: "plugin-channel" }));
|
|
10
|
+
app.get("/workspaces/:id/plugin/events", (request, reply) => {
|
|
11
|
+
const workspace = deps.workspaceManager.get(request.params.id);
|
|
12
|
+
if (!workspace) {
|
|
13
|
+
reply.code(404).send({ error: "Workspace not found" });
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
reply.raw.setHeader("Content-Type", "text/event-stream");
|
|
17
|
+
reply.raw.setHeader("Cache-Control", "no-cache");
|
|
18
|
+
reply.raw.setHeader("Connection", "keep-alive");
|
|
19
|
+
reply.raw.flushHeaders?.();
|
|
20
|
+
reply.hijack();
|
|
21
|
+
const registration = channel.register(request.params.id, reply);
|
|
22
|
+
const heartbeat = setInterval(() => {
|
|
23
|
+
channel.send(request.params.id, buildPingEvent());
|
|
24
|
+
}, 15000);
|
|
25
|
+
const close = () => {
|
|
26
|
+
clearInterval(heartbeat);
|
|
27
|
+
registration.close();
|
|
28
|
+
reply.raw.end?.();
|
|
29
|
+
};
|
|
30
|
+
request.raw.on("close", close);
|
|
31
|
+
request.raw.on("error", close);
|
|
32
|
+
});
|
|
33
|
+
const handleWildcard = async (request, reply) => {
|
|
34
|
+
const workspaceId = request.params.id;
|
|
35
|
+
const workspace = deps.workspaceManager.get(workspaceId);
|
|
36
|
+
if (!workspace) {
|
|
37
|
+
reply.code(404).send({ error: "Workspace not found" });
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const suffix = request.params["*"] ?? "";
|
|
41
|
+
const normalized = suffix.replace(/^\/+/, "");
|
|
42
|
+
if (normalized === "event" && request.method === "POST") {
|
|
43
|
+
const parsed = PluginEventSchema.parse(request.body ?? {});
|
|
44
|
+
handlePluginEvent(workspaceId, parsed, { workspaceManager: deps.workspaceManager, eventBus: deps.eventBus, logger: deps.logger });
|
|
45
|
+
reply.code(204).send();
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
reply.code(404).send({ error: "Unknown plugin endpoint" });
|
|
49
|
+
};
|
|
50
|
+
app.all("/workspaces/:id/plugin/*", handleWildcard);
|
|
51
|
+
app.all("/workspaces/:id/plugin", handleWildcard);
|
|
52
|
+
}
|
|
@@ -23,10 +23,17 @@ export function registerWorkspaceRoutes(app, deps) {
|
|
|
23
23
|
return deps.workspaceManager.list();
|
|
24
24
|
});
|
|
25
25
|
app.post("/api/workspaces", async (request, reply) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
try {
|
|
27
|
+
const body = WorkspaceCreateSchema.parse(request.body ?? {});
|
|
28
|
+
const workspace = await deps.workspaceManager.create(body.path, body.name);
|
|
29
|
+
reply.code(201);
|
|
30
|
+
return workspace;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
request.log.error({ err: error }, "Failed to create workspace");
|
|
34
|
+
const message = error instanceof Error ? error.message : "Failed to create workspace";
|
|
35
|
+
reply.code(400).type("text/plain").send(message);
|
|
36
|
+
}
|
|
30
37
|
});
|
|
31
38
|
app.get("/api/workspaces/:id", async (request, reply) => {
|
|
32
39
|
const workspace = deps.workspaceManager.get(request.params.id);
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { spawnSync } from "child_process";
|
|
3
|
+
import { connect } from "net";
|
|
3
4
|
import { FileSystemBrowser } from "../filesystem/browser";
|
|
4
5
|
import { searchWorkspaceFiles } from "../filesystem/search";
|
|
5
6
|
import { clearWorkspaceSearchCache } from "../filesystem/search-cache";
|
|
6
7
|
import { WorkspaceRuntime } from "./runtime";
|
|
8
|
+
import { getOpencodeConfigDir } from "../opencode-config.js";
|
|
9
|
+
const STARTUP_STABILITY_DELAY_MS = 1500;
|
|
7
10
|
export class WorkspaceManager {
|
|
8
11
|
constructor(options) {
|
|
9
12
|
this.options = options;
|
|
10
13
|
this.workspaces = new Map();
|
|
11
14
|
this.runtime = new WorkspaceRuntime(this.options.eventBus, this.options.logger);
|
|
15
|
+
this.opencodeConfigDir = getOpencodeConfigDir();
|
|
12
16
|
}
|
|
13
17
|
list() {
|
|
14
18
|
return Array.from(this.workspaces.values());
|
|
@@ -63,15 +67,23 @@ export class WorkspaceManager {
|
|
|
63
67
|
}
|
|
64
68
|
this.workspaces.set(id, descriptor);
|
|
65
69
|
this.options.eventBus.publish({ type: "workspace.created", workspace: descriptor });
|
|
66
|
-
const
|
|
70
|
+
const preferences = this.options.configStore.get().preferences ?? {};
|
|
71
|
+
const userEnvironment = preferences.environmentVariables ?? {};
|
|
72
|
+
const environment = {
|
|
73
|
+
...userEnvironment,
|
|
74
|
+
OPENCODE_CONFIG_DIR: this.opencodeConfigDir,
|
|
75
|
+
CODENOMAD_INSTANCE_ID: id,
|
|
76
|
+
CODENOMAD_BASE_URL: this.options.getServerBaseUrl(),
|
|
77
|
+
};
|
|
67
78
|
try {
|
|
68
|
-
const { pid, port } = await this.runtime.launch({
|
|
79
|
+
const { pid, port, exitPromise, getLastOutput } = await this.runtime.launch({
|
|
69
80
|
workspaceId: id,
|
|
70
81
|
folder: workspacePath,
|
|
71
82
|
binaryPath: resolvedBinaryPath,
|
|
72
83
|
environment,
|
|
73
84
|
onExit: (info) => this.handleProcessExit(info.workspaceId, info),
|
|
74
85
|
});
|
|
86
|
+
await this.waitForWorkspaceReadiness({ workspaceId: id, port, exitPromise, getLastOutput });
|
|
75
87
|
descriptor.pid = pid;
|
|
76
88
|
descriptor.port = port;
|
|
77
89
|
descriptor.status = "ready";
|
|
@@ -189,6 +201,117 @@ export class WorkspaceManager {
|
|
|
189
201
|
}
|
|
190
202
|
return undefined;
|
|
191
203
|
}
|
|
204
|
+
async waitForWorkspaceReadiness(params) {
|
|
205
|
+
await Promise.race([
|
|
206
|
+
this.waitForPortAvailability(params.port),
|
|
207
|
+
params.exitPromise.then((info) => {
|
|
208
|
+
throw this.buildStartupError(params.workspaceId, "exited before becoming ready", info, params.getLastOutput());
|
|
209
|
+
}),
|
|
210
|
+
]);
|
|
211
|
+
await this.waitForInstanceHealth(params);
|
|
212
|
+
await Promise.race([
|
|
213
|
+
this.delay(STARTUP_STABILITY_DELAY_MS),
|
|
214
|
+
params.exitPromise.then((info) => {
|
|
215
|
+
throw this.buildStartupError(params.workspaceId, "exited shortly after start", info, params.getLastOutput());
|
|
216
|
+
}),
|
|
217
|
+
]);
|
|
218
|
+
}
|
|
219
|
+
async waitForInstanceHealth(params) {
|
|
220
|
+
const probeResult = await Promise.race([
|
|
221
|
+
this.probeInstance(params.workspaceId, params.port),
|
|
222
|
+
params.exitPromise.then((info) => {
|
|
223
|
+
throw this.buildStartupError(params.workspaceId, "exited during health checks", info, params.getLastOutput());
|
|
224
|
+
}),
|
|
225
|
+
]);
|
|
226
|
+
if (probeResult.ok) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
const latestOutput = params.getLastOutput().trim();
|
|
230
|
+
if (latestOutput) {
|
|
231
|
+
throw new Error(latestOutput);
|
|
232
|
+
}
|
|
233
|
+
const reason = probeResult.reason ?? "Health check failed";
|
|
234
|
+
throw new Error(`Workspace ${params.workspaceId} failed health check: ${reason}.`);
|
|
235
|
+
}
|
|
236
|
+
async probeInstance(workspaceId, port) {
|
|
237
|
+
const url = `http://127.0.0.1:${port}/project/current`;
|
|
238
|
+
try {
|
|
239
|
+
const response = await fetch(url);
|
|
240
|
+
if (!response.ok) {
|
|
241
|
+
const reason = `health probe returned HTTP ${response.status}`;
|
|
242
|
+
this.options.logger.debug({ workspaceId, status: response.status }, "Health probe returned server error");
|
|
243
|
+
return { ok: false, reason };
|
|
244
|
+
}
|
|
245
|
+
return { ok: true };
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
249
|
+
this.options.logger.debug({ workspaceId, err: error }, "Health probe failed");
|
|
250
|
+
return { ok: false, reason };
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
buildStartupError(workspaceId, phase, exitInfo, lastOutput) {
|
|
254
|
+
const exitDetails = this.describeExit(exitInfo);
|
|
255
|
+
const trimmedOutput = lastOutput.trim();
|
|
256
|
+
const outputDetails = trimmedOutput ? ` Last output: ${trimmedOutput}` : "";
|
|
257
|
+
return new Error(`Workspace ${workspaceId} ${phase} (${exitDetails}).${outputDetails}`);
|
|
258
|
+
}
|
|
259
|
+
waitForPortAvailability(port, timeoutMs = 5000) {
|
|
260
|
+
return new Promise((resolve, reject) => {
|
|
261
|
+
const deadline = Date.now() + timeoutMs;
|
|
262
|
+
let settled = false;
|
|
263
|
+
let retryTimer = null;
|
|
264
|
+
const cleanup = () => {
|
|
265
|
+
settled = true;
|
|
266
|
+
if (retryTimer) {
|
|
267
|
+
clearTimeout(retryTimer);
|
|
268
|
+
retryTimer = null;
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
const tryConnect = () => {
|
|
272
|
+
if (settled) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
const socket = connect({ port, host: "127.0.0.1" }, () => {
|
|
276
|
+
cleanup();
|
|
277
|
+
socket.end();
|
|
278
|
+
resolve();
|
|
279
|
+
});
|
|
280
|
+
socket.once("error", () => {
|
|
281
|
+
socket.destroy();
|
|
282
|
+
if (settled) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
if (Date.now() >= deadline) {
|
|
286
|
+
cleanup();
|
|
287
|
+
reject(new Error(`Workspace port ${port} did not become ready within ${timeoutMs}ms`));
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
retryTimer = setTimeout(() => {
|
|
291
|
+
retryTimer = null;
|
|
292
|
+
tryConnect();
|
|
293
|
+
}, 100);
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
};
|
|
297
|
+
tryConnect();
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
delay(durationMs) {
|
|
301
|
+
if (durationMs <= 0) {
|
|
302
|
+
return Promise.resolve();
|
|
303
|
+
}
|
|
304
|
+
return new Promise((resolve) => setTimeout(resolve, durationMs));
|
|
305
|
+
}
|
|
306
|
+
describeExit(info) {
|
|
307
|
+
if (info.signal) {
|
|
308
|
+
return `signal ${info.signal}`;
|
|
309
|
+
}
|
|
310
|
+
if (info.code !== null) {
|
|
311
|
+
return `code ${info.code}`;
|
|
312
|
+
}
|
|
313
|
+
return "unknown reason";
|
|
314
|
+
}
|
|
192
315
|
handleProcessExit(workspaceId, info) {
|
|
193
316
|
const workspace = this.workspaces.get(workspaceId);
|
|
194
317
|
if (!workspace)
|
|
@@ -11,8 +11,36 @@ export class WorkspaceRuntime {
|
|
|
11
11
|
this.validateFolder(options.folder);
|
|
12
12
|
const args = ["serve", "--port", "0", "--print-logs", "--log-level", "DEBUG"];
|
|
13
13
|
const env = { ...process.env, ...(options.environment ?? {}) };
|
|
14
|
+
let exitResolve = null;
|
|
15
|
+
const exitPromise = new Promise((resolveExit) => {
|
|
16
|
+
exitResolve = resolveExit;
|
|
17
|
+
});
|
|
18
|
+
// Store recent output for debugging - keep last 50 lines from each stream
|
|
19
|
+
const MAX_OUTPUT_LINES = 50;
|
|
20
|
+
const recentStdout = [];
|
|
21
|
+
const recentStderr = [];
|
|
22
|
+
const getLastOutput = () => {
|
|
23
|
+
const combined = [];
|
|
24
|
+
if (recentStderr.length > 0) {
|
|
25
|
+
combined.push("Error Stream");
|
|
26
|
+
combined.push(...recentStderr.slice(-10));
|
|
27
|
+
}
|
|
28
|
+
if (recentStdout.length > 0) {
|
|
29
|
+
combined.push("Output Stream");
|
|
30
|
+
combined.push(...recentStdout.slice(-10));
|
|
31
|
+
}
|
|
32
|
+
return combined.join("\n");
|
|
33
|
+
};
|
|
14
34
|
return new Promise((resolve, reject) => {
|
|
15
|
-
|
|
35
|
+
const commandLine = [options.binaryPath, ...args].join(" ");
|
|
36
|
+
this.logger.info({
|
|
37
|
+
workspaceId: options.workspaceId,
|
|
38
|
+
folder: options.folder,
|
|
39
|
+
binary: options.binaryPath,
|
|
40
|
+
args,
|
|
41
|
+
commandLine,
|
|
42
|
+
env,
|
|
43
|
+
}, "Launching OpenCode process");
|
|
16
44
|
const child = spawn(options.binaryPath, args, {
|
|
17
45
|
cwd: options.folder,
|
|
18
46
|
env,
|
|
@@ -47,12 +75,23 @@ export class WorkspaceRuntime {
|
|
|
47
75
|
cleanupStreams();
|
|
48
76
|
child.removeListener("error", handleError);
|
|
49
77
|
child.removeListener("exit", handleExit);
|
|
78
|
+
const exitInfo = {
|
|
79
|
+
workspaceId: options.workspaceId,
|
|
80
|
+
code,
|
|
81
|
+
signal,
|
|
82
|
+
requested: managed.requestedStop,
|
|
83
|
+
};
|
|
84
|
+
if (exitResolve) {
|
|
85
|
+
exitResolve(exitInfo);
|
|
86
|
+
exitResolve = null;
|
|
87
|
+
}
|
|
50
88
|
if (!portFound) {
|
|
51
|
-
const
|
|
89
|
+
const recentOutput = getLastOutput().trim();
|
|
90
|
+
const reason = recentOutput || stderrBuffer || `Process exited with code ${code}`;
|
|
52
91
|
reject(new Error(reason));
|
|
53
92
|
}
|
|
54
93
|
else {
|
|
55
|
-
options.onExit?.(
|
|
94
|
+
options.onExit?.(exitInfo);
|
|
56
95
|
}
|
|
57
96
|
};
|
|
58
97
|
const handleError = (error) => {
|
|
@@ -60,6 +99,10 @@ export class WorkspaceRuntime {
|
|
|
60
99
|
child.removeListener("exit", handleExit);
|
|
61
100
|
this.processes.delete(options.workspaceId);
|
|
62
101
|
this.logger.error({ workspaceId: options.workspaceId, err: error }, "Workspace runtime error");
|
|
102
|
+
if (exitResolve) {
|
|
103
|
+
exitResolve({ workspaceId: options.workspaceId, code: null, signal: null, requested: managed.requestedStop });
|
|
104
|
+
exitResolve = null;
|
|
105
|
+
}
|
|
63
106
|
reject(error);
|
|
64
107
|
};
|
|
65
108
|
child.on("error", handleError);
|
|
@@ -70,18 +113,23 @@ export class WorkspaceRuntime {
|
|
|
70
113
|
const lines = stdoutBuffer.split("\n");
|
|
71
114
|
stdoutBuffer = lines.pop() ?? "";
|
|
72
115
|
for (const line of lines) {
|
|
73
|
-
|
|
116
|
+
const trimmed = line.trim();
|
|
117
|
+
if (!trimmed)
|
|
74
118
|
continue;
|
|
119
|
+
recentStdout.push(trimmed);
|
|
120
|
+
if (recentStdout.length > MAX_OUTPUT_LINES) {
|
|
121
|
+
recentStdout.shift();
|
|
122
|
+
}
|
|
75
123
|
this.emitLog(options.workspaceId, "info", line);
|
|
76
124
|
if (!portFound) {
|
|
77
125
|
const portMatch = line.match(/opencode server listening on http:\/\/.+:(\d+)/i);
|
|
78
126
|
if (portMatch) {
|
|
79
127
|
portFound = true;
|
|
80
|
-
|
|
128
|
+
stopWarningTimer();
|
|
81
129
|
child.removeListener("error", handleError);
|
|
82
130
|
const port = parseInt(portMatch[1], 10);
|
|
83
131
|
this.logger.info({ workspaceId: options.workspaceId, port }, "Workspace runtime allocated port");
|
|
84
|
-
resolve({ pid: child.pid, port });
|
|
132
|
+
resolve({ pid: child.pid, port, exitPromise, getLastOutput });
|
|
85
133
|
}
|
|
86
134
|
}
|
|
87
135
|
}
|
|
@@ -92,8 +140,13 @@ export class WorkspaceRuntime {
|
|
|
92
140
|
const lines = stderrBuffer.split("\n");
|
|
93
141
|
stderrBuffer = lines.pop() ?? "";
|
|
94
142
|
for (const line of lines) {
|
|
95
|
-
|
|
143
|
+
const trimmed = line.trim();
|
|
144
|
+
if (!trimmed)
|
|
96
145
|
continue;
|
|
146
|
+
recentStderr.push(trimmed);
|
|
147
|
+
if (recentStderr.length > MAX_OUTPUT_LINES) {
|
|
148
|
+
recentStderr.shift();
|
|
149
|
+
}
|
|
97
150
|
this.emitLog(options.workspaceId, "error", line);
|
|
98
151
|
}
|
|
99
152
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neuralnomads/codenomad",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "CodeNomad Server",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Neural Nomads",
|
|
@@ -16,10 +16,11 @@
|
|
|
16
16
|
"codenomad": "dist/bin.js"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
|
-
"build": "npm run build:ui && npm run prepare-ui && tsc -p tsconfig.json",
|
|
19
|
+
"build": "npm run build:ui && npm run prepare-ui && tsc -p tsconfig.json && npm run prepare-config",
|
|
20
20
|
"build:ui": "npm run build --prefix ../ui",
|
|
21
21
|
"prepare-ui": "node ./scripts/copy-ui-dist.mjs",
|
|
22
|
-
"
|
|
22
|
+
"prepare-config": "node ./scripts/copy-opencode-config.mjs",
|
|
23
|
+
"dev": "cross-env CODENOMAD_DEV=1 CLI_UI_DEV_SERVER=http://localhost:3000 tsx src/index.ts",
|
|
23
24
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
24
25
|
},
|
|
25
26
|
"dependencies": {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();const g={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return be(this.context.count)},getNextContextId(){return be(this.context.count++)}};function be(e){const t=String(e),n=t.length-1;return g.context.id+(n?String.fromCharCode(96+n):"")+t}function Ve(e){g.context=e}const Be=!1,Ge=(e,t)=>e===t,Y=Symbol("solid-proxy"),Oe=typeof Proxy=="function",Pe=Symbol("solid-track"),Wt=Symbol("solid-dev-component"),Q={equals:Ge};let V=null,Ne=$e;const v=1,Z=2,ke={owned:null,cleanups:null,context:null,owner:null};var y=null;let oe=null,He=null,m=null,F=null,P=null,re=0;function L(e,t){const n=m,r=y,s=e.length===0,o=t===void 0?r:t,l=s?ke:{owned:null,cleanups:null,context:o?o.context:null,owner:o},i=s?e:()=>e(()=>A(()=>G(l)));y=l,m=null;try{return $(i,!0)}finally{m=n,y=r}}function K(e,t){t=t?Object.assign({},Q,t):Q;const n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},r=s=>(typeof s=="function"&&(s=s(n.value)),Te(n,s));return[Le.bind(n),r]}function Xt(e,t,n){const r=q(e,t,!0,v);R(r)}function T(e,t,n){const r=q(e,t,!1,v);R(r)}function ve(e,t,n){Ne=We;const r=q(e,t,!1,v);(!n||!n.render)&&(r.user=!0),P?P.push(r):R(r)}function p(e,t,n){n=n?Object.assign({},Q,n):Q;const r=q(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,R(r),Le.bind(r)}function Yt(e){return $(e,!1)}function A(e){if(m===null)return e();const t=m;m=null;try{return e()}finally{m=t}}function Qt(e,t,n){const r=Array.isArray(e);let s,o=n&&n.defer;return l=>{let i;if(r){i=Array(e.length);for(let a=0;a<e.length;a++)i[a]=e[a]()}else i=e();if(o)return o=!1,l;const c=A(()=>t(i,s,l));return s=i,c}}function Zt(e){ve(()=>A(e))}function B(e){return y===null||(y.cleanups===null?y.cleanups=[e]:y.cleanups.push(e)),e}function Ke(e,t){V||(V=Symbol("error")),y=q(void 0,void 0,!0),y.context={...y.context,[V]:[t]};try{return e()}catch(n){z(n)}finally{y=y.owner}}function en(){return m}function Ce(){return y}function qe(e,t){const n=y,r=m;y=e,m=null;try{return $(t,!0)}catch(s){z(s)}finally{y=n,m=r}}const[tn,nn]=K(!1);function rn(e,t){const n=Symbol("context");return{id:n,Provider:Ye(n),defaultValue:e}}function sn(e){let t;return y&&y.context&&(t=y.context[e.id])!==void 0?t:e.defaultValue}function Ie(e){const t=p(e),n=p(()=>fe(t()));return n.toArray=()=>{const r=n();return Array.isArray(r)?r:r!=null?[r]:[]},n}function Le(){if(this.sources&&this.state)if(this.state===v)R(this);else{const e=F;F=null,$(()=>te(this),!1),F=e}if(m){const e=this.observers?this.observers.length:0;m.sources?(m.sources.push(this),m.sourceSlots.push(e)):(m.sources=[this],m.sourceSlots=[e]),this.observers?(this.observers.push(m),this.observerSlots.push(m.sources.length-1)):(this.observers=[m],this.observerSlots=[m.sources.length-1])}return this.value}function Te(e,t,n){let r=e.value;return(!e.comparator||!e.comparator(r,t))&&(e.value=t,e.observers&&e.observers.length&&$(()=>{for(let s=0;s<e.observers.length;s+=1){const o=e.observers[s],l=oe&&oe.running;l&&oe.disposed.has(o),(l?!o.tState:!o.state)&&(o.pure?F.push(o):P.push(o),o.observers&&Me(o)),l||(o.state=v)}if(F.length>1e6)throw F=[],new Error},!1)),t}function R(e){if(!e.fn)return;G(e);const t=re;ze(e,e.value,t)}function ze(e,t,n){let r;const s=y,o=m;m=y=e;try{r=e.fn(t)}catch(l){return e.pure&&(e.state=v,e.owned&&e.owned.forEach(G),e.owned=null),e.updatedAt=n+1,z(l)}finally{m=o,y=s}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&"observers"in e?Te(e,r):e.value=r,e.updatedAt=n)}function q(e,t,n,r=v,s){const o={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:y,context:y?y.context:null,pure:n};return y===null||y!==ke&&(y.owned?y.owned.push(o):y.owned=[o]),o}function ee(e){if(e.state===0)return;if(e.state===Z)return te(e);if(e.suspense&&A(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<re);)e.state&&t.push(e);for(let n=t.length-1;n>=0;n--)if(e=t[n],e.state===v)R(e);else if(e.state===Z){const r=F;F=null,$(()=>te(e,t[0]),!1),F=r}}function $(e,t){if(F)return e();let n=!1;t||(F=[]),P?n=!0:P=[],re++;try{const r=e();return Je(n),r}catch(r){n||(P=null),F=null,z(r)}}function Je(e){if(F&&($e(F),F=null),e)return;const t=P;P=null,t.length&&$(()=>Ne(t),!1)}function $e(e){for(let t=0;t<e.length;t++)ee(e[t])}function We(e){let t,n=0;for(t=0;t<e.length;t++){const r=e[t];r.user?e[n++]=r:ee(r)}if(g.context){if(g.count){g.effects||(g.effects=[]),g.effects.push(...e.slice(0,n));return}Ve()}for(g.effects&&(g.done||!g.count)&&(e=[...g.effects,...e],n+=g.effects.length,delete g.effects),t=0;t<n;t++)ee(e[t])}function te(e,t){e.state=0;for(let n=0;n<e.sources.length;n+=1){const r=e.sources[n];if(r.sources){const s=r.state;s===v?r!==t&&(!r.updatedAt||r.updatedAt<re)&&ee(r):s===Z&&te(r,t)}}}function Me(e){for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t];n.state||(n.state=Z,n.pure?F.push(n):P.push(n),n.observers&&Me(n))}}function G(e){let t;if(e.sources)for(;e.sources.length;){const n=e.sources.pop(),r=e.sourceSlots.pop(),s=n.observers;if(s&&s.length){const o=s.pop(),l=n.observerSlots.pop();r<s.length&&(o.sourceSlots[l]=r,s[r]=o,n.observerSlots[r]=l)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)G(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)G(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function Xe(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function pe(e,t,n){try{for(const r of t)r(e)}catch(r){z(r,n&&n.owner||null)}}function z(e,t=y){const n=V&&t&&t.context&&t.context[V],r=Xe(e);if(!n)throw r;P?P.push({fn(){pe(r,n,t)},state:v}):pe(r,n,t)}function fe(e){if(typeof e=="function"&&!e.length)return fe(e());if(Array.isArray(e)){const t=[];for(let n=0;n<e.length;n++){const r=fe(e[n]);Array.isArray(r)?t.push.apply(t,r):t.push(r)}return t}return e}function Ye(e,t){return function(r){let s;return T(()=>s=A(()=>(y.context={...y.context,[e]:r.value},Ie(()=>r.children))),void 0),s}}const ue=Symbol("fallback");function ne(e){for(let t=0;t<e.length;t++)e[t]()}function Qe(e,t,n={}){let r=[],s=[],o=[],l=0,i=t.length>1?[]:null;return B(()=>ne(o)),()=>{let c=e()||[],a=c.length,u,f;return c[Pe],A(()=>{let h,b,w,C,x,E,O,S,I;if(a===0)l!==0&&(ne(o),o=[],r=[],s=[],l=0,i&&(i=[])),n.fallback&&(r=[ue],s[0]=L(U=>(o[0]=U,n.fallback())),l=1);else if(l===0){for(s=new Array(a),f=0;f<a;f++)r[f]=c[f],s[f]=L(d);l=a}else{for(w=new Array(a),C=new Array(a),i&&(x=new Array(a)),E=0,O=Math.min(l,a);E<O&&r[E]===c[E];E++);for(O=l-1,S=a-1;O>=E&&S>=E&&r[O]===c[S];O--,S--)w[S]=s[O],C[S]=o[O],i&&(x[S]=i[O]);for(h=new Map,b=new Array(S+1),f=S;f>=E;f--)I=c[f],u=h.get(I),b[f]=u===void 0?-1:u,h.set(I,f);for(u=E;u<=O;u++)I=r[u],f=h.get(I),f!==void 0&&f!==-1?(w[f]=s[u],C[f]=o[u],i&&(x[f]=i[u]),f=b[f],h.set(I,f)):o[u]();for(f=E;f<a;f++)f in w?(s[f]=w[f],o[f]=C[f],i&&(i[f]=x[f],i[f](f))):s[f]=L(d);s=s.slice(0,l=a),r=c.slice(0)}return s});function d(h){if(o[f]=h,i){const[b,w]=K(f);return i[f]=w,t(c[f],b)}return t(c[f])}}}function Ze(e,t,n={}){let r=[],s=[],o=[],l=[],i=0,c;return B(()=>ne(o)),()=>{const a=e()||[],u=a.length;return a[Pe],A(()=>{if(u===0)return i!==0&&(ne(o),o=[],r=[],s=[],i=0,l=[]),n.fallback&&(r=[ue],s[0]=L(d=>(o[0]=d,n.fallback())),i=1),s;for(r[0]===ue&&(o[0](),o=[],r=[],s=[],i=0),c=0;c<u;c++)c<r.length&&r[c]!==a[c]?l[c](()=>a[c]):c>=r.length&&(s[c]=L(f));for(;c<r.length;c++)o[c]();return i=l.length=o.length=u,r=a.slice(0),s=s.slice(0,i)});function f(d){o[c]=d;const[h,b]=K(a[c]);return l[c]=b,t(h,c)}}}function on(e,t){return A(()=>e(t||{}))}function W(){return!0}const ae={get(e,t,n){return t===Y?n:e.get(t)},has(e,t){return t===Y?!0:e.has(t)},set:W,deleteProperty:W,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:W,deleteProperty:W}},ownKeys(e){return e.keys()}};function ie(e){return(e=typeof e=="function"?e():e)?e:{}}function et(){for(let e=0,t=this.length;e<t;++e){const n=this[e]();if(n!==void 0)return n}}function ln(...e){let t=!1;for(let l=0;l<e.length;l++){const i=e[l];t=t||!!i&&Y in i,e[l]=typeof i=="function"?(t=!0,p(i)):i}if(Oe&&t)return new Proxy({get(l){for(let i=e.length-1;i>=0;i--){const c=ie(e[i])[l];if(c!==void 0)return c}},has(l){for(let i=e.length-1;i>=0;i--)if(l in ie(e[i]))return!0;return!1},keys(){const l=[];for(let i=0;i<e.length;i++)l.push(...Object.keys(ie(e[i])));return[...new Set(l)]}},ae);const n={},r=Object.create(null);for(let l=e.length-1;l>=0;l--){const i=e[l];if(!i)continue;const c=Object.getOwnPropertyNames(i);for(let a=c.length-1;a>=0;a--){const u=c[a];if(u==="__proto__"||u==="constructor")continue;const f=Object.getOwnPropertyDescriptor(i,u);if(!r[u])r[u]=f.get?{enumerable:!0,configurable:!0,get:et.bind(n[u]=[f.get.bind(i)])}:f.value!==void 0?f:void 0;else{const d=n[u];d&&(f.get?d.push(f.get.bind(i)):f.value!==void 0&&d.push(()=>f.value))}}}const s={},o=Object.keys(r);for(let l=o.length-1;l>=0;l--){const i=o[l],c=r[i];c&&c.get?Object.defineProperty(s,i,c):s[i]=c?c.value:void 0}return s}function tt(e,...t){const n=t.length;if(Oe&&Y in e){const s=n>1?t.flat():t[0],o=t.map(l=>new Proxy({get(i){return l.includes(i)?e[i]:void 0},has(i){return l.includes(i)&&i in e},keys(){return l.filter(i=>i in e)}},ae));return o.push(new Proxy({get(l){return s.includes(l)?void 0:e[l]},has(l){return s.includes(l)?!1:l in e},keys(){return Object.keys(e).filter(l=>!s.includes(l))}},ae)),o}const r=[];for(let s=0;s<=n;s++)r[s]={};for(const s of Object.getOwnPropertyNames(e)){let o=n;for(let c=0;c<t.length;c++)if(t[c].includes(s)){o=c;break}const l=Object.getOwnPropertyDescriptor(e,s);!l.get&&!l.set&&l.enumerable&&l.writable&&l.configurable?r[o][s]=l.value:Object.defineProperty(r[o],s,l)}return r}let nt=0;function cn(){return g.context?g.getNextContextId():`cl-${nt++}`}const De=e=>`Stale read from <${e}>.`;function fn(e){const t="fallback"in e&&{fallback:()=>e.fallback};return p(Qe(()=>e.each,e.children,t||void 0))}function un(e){const t="fallback"in e&&{fallback:()=>e.fallback};return p(Ze(()=>e.each,e.children,t||void 0))}function an(e){const t=e.keyed,n=p(()=>e.when,void 0,void 0),r=t?n:p(n,void 0,{equals:(s,o)=>!s==!o});return p(()=>{const s=r();if(s){const o=e.children;return typeof o=="function"&&o.length>0?A(()=>o(t?s:()=>{if(!A(r))throw De("Show");return n()})):o}return e.fallback},void 0,void 0)}function dn(e){const t=Ie(()=>e.children),n=p(()=>{const r=t(),s=Array.isArray(r)?r:[r];let o=()=>{};for(let l=0;l<s.length;l++){const i=l,c=s[l],a=o,u=p(()=>a()?void 0:c.when,void 0,void 0),f=c.keyed?u:p(u,void 0,{equals:(d,h)=>!d==!h});o=()=>a()||(f()?[i,u,c]:void 0)}return o});return p(()=>{const r=n()();if(!r)return e.fallback;const[s,o,l]=r,i=l.children;return typeof i=="function"&&i.length>0?A(()=>i(l.keyed?o():()=>{var a;if(((a=A(n)())==null?void 0:a[0])!==s)throw De("Match");return o()})):i},void 0,void 0)}function hn(e){return e}let X;function gn(e){let t;g.context&&g.load&&(t=g.load(g.getContextId()));const[n,r]=K(t,void 0);return X||(X=new Set),X.add(r),B(()=>X.delete(r)),p(()=>{let s;if(s=n()){const o=e.fallback;return typeof o=="function"&&o.length?A(()=>o(s,()=>r())):o}return Ke(()=>e.children,r)},void 0,void 0)}const rt=["allowfullscreen","async","alpha","autofocus","autoplay","checked","controls","default","disabled","formnovalidate","hidden","indeterminate","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","seamless","selected","adauctionheaders","browsingtopics","credentialless","defaultchecked","defaultmuted","defaultselected","defer","disablepictureinpicture","disableremoteplayback","preservespitch","shadowrootclonable","shadowrootcustomelementregistry","shadowrootdelegatesfocus","shadowrootserializable","sharedstoragewritable"],st=new Set(["className","value","readOnly","noValidate","formNoValidate","isMap","noModule","playsInline","adAuctionHeaders","allowFullscreen","browsingTopics","defaultChecked","defaultMuted","defaultSelected","disablePictureInPicture","disableRemotePlayback","preservesPitch","shadowRootClonable","shadowRootCustomElementRegistry","shadowRootDelegatesFocus","shadowRootSerializable","sharedStorageWritable",...rt]),ot=new Set(["innerHTML","textContent","innerText","children"]),it=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),lt=Object.assign(Object.create(null),{class:"className",novalidate:{$:"noValidate",FORM:1},formnovalidate:{$:"formNoValidate",BUTTON:1,INPUT:1},ismap:{$:"isMap",IMG:1},nomodule:{$:"noModule",SCRIPT:1},playsinline:{$:"playsInline",VIDEO:1},readonly:{$:"readOnly",INPUT:1,TEXTAREA:1},adauctionheaders:{$:"adAuctionHeaders",IFRAME:1},allowfullscreen:{$:"allowFullscreen",IFRAME:1},browsingtopics:{$:"browsingTopics",IMG:1},defaultchecked:{$:"defaultChecked",INPUT:1},defaultmuted:{$:"defaultMuted",AUDIO:1,VIDEO:1},defaultselected:{$:"defaultSelected",OPTION:1},disablepictureinpicture:{$:"disablePictureInPicture",VIDEO:1},disableremoteplayback:{$:"disableRemotePlayback",AUDIO:1,VIDEO:1},preservespitch:{$:"preservesPitch",AUDIO:1,VIDEO:1},shadowrootclonable:{$:"shadowRootClonable",TEMPLATE:1},shadowrootdelegatesfocus:{$:"shadowRootDelegatesFocus",TEMPLATE:1},shadowrootserializable:{$:"shadowRootSerializable",TEMPLATE:1},sharedstoragewritable:{$:"sharedStorageWritable",IFRAME:1,IMG:1}});function ct(e,t){const n=lt[e];return typeof n=="object"?n[t]?n.$:void 0:n}const ft=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),ut=new Set(["altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tref","tspan","use","view","vkern"]),at={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},yn=e=>p(()=>e());function dt(e,t,n){let r=n.length,s=t.length,o=r,l=0,i=0,c=t[s-1].nextSibling,a=null;for(;l<s||i<o;){if(t[l]===n[i]){l++,i++;continue}for(;t[s-1]===n[o-1];)s--,o--;if(s===l){const u=o<r?i?n[i-1].nextSibling:n[o-i]:c;for(;i<o;)e.insertBefore(n[i++],u)}else if(o===i)for(;l<s;)(!a||!a.has(t[l]))&&t[l].remove(),l++;else if(t[l]===n[o-1]&&n[i]===t[s-1]){const u=t[--s].nextSibling;e.insertBefore(n[i++],t[l++].nextSibling),e.insertBefore(n[--o],u),t[s]=n[o]}else{if(!a){a=new Map;let f=i;for(;f<o;)a.set(n[f],f++)}const u=a.get(t[l]);if(u!=null)if(i<u&&u<o){let f=l,d=1,h;for(;++f<s&&f<o&&!((h=a.get(t[f]))==null||h!==u+d);)d++;if(d>u-i){const b=t[l];for(;i<u;)e.insertBefore(n[i++],b)}else e.replaceChild(n[i++],t[l++])}else l++;else t[l++].remove()}}}const Ae="_$DX_DELEGATE";function mn(e,t,n,r={}){let s;return L(o=>{s=o,t===document?e():he(t,e(),t.firstChild?null:void 0,n)},r.owner),()=>{s(),t.textContent=""}}function wn(e,t,n,r){let s;const o=()=>{const i=r?document.createElementNS("http://www.w3.org/1998/Math/MathML","template"):document.createElement("template");return i.innerHTML=e,n?i.content.firstChild.firstChild:r?i.firstChild:i.content.firstChild},l=t?()=>A(()=>document.importNode(s||(s=o()),!0)):()=>(s||(s=o())).cloneNode(!0);return l.cloneNode=l,l}function ht(e,t=window.document){const n=t[Ae]||(t[Ae]=new Set);for(let r=0,s=e.length;r<s;r++){const o=e[r];n.has(o)||(n.add(o),t.addEventListener(o,xt))}}function de(e,t,n){M(e)||(n==null?e.removeAttribute(t):e.setAttribute(t,n))}function gt(e,t,n,r){M(e)||(r==null?e.removeAttributeNS(t,n):e.setAttributeNS(t,n,r))}function yt(e,t,n){M(e)||(n?e.setAttribute(t,""):e.removeAttribute(t))}function mt(e,t){M(e)||(t==null?e.removeAttribute("class"):e.className=t)}function wt(e,t,n,r){if(r)Array.isArray(n)?(e[`$$${t}`]=n[0],e[`$$${t}Data`]=n[1]):e[`$$${t}`]=n;else if(Array.isArray(n)){const s=n[0];e.addEventListener(t,n[0]=o=>s.call(e,n[1],o))}else e.addEventListener(t,n,typeof n!="function"&&n)}function bt(e,t,n={}){const r=Object.keys(t||{}),s=Object.keys(n);let o,l;for(o=0,l=s.length;o<l;o++){const i=s[o];!i||i==="undefined"||t[i]||(Fe(e,i,!1),delete n[i])}for(o=0,l=r.length;o<l;o++){const i=r[o],c=!!t[i];!i||i==="undefined"||n[i]===c||!c||(Fe(e,i,!0),n[i]=c)}return n}function Ct(e,t,n){if(!t)return n?de(e,"style"):t;const r=e.style;if(typeof t=="string")return r.cssText=t;typeof n=="string"&&(r.cssText=n=void 0),n||(n={}),t||(t={});let s,o;for(o in n)t[o]==null&&r.removeProperty(o),delete n[o];for(o in t)s=t[o],s!==n[o]&&(r.setProperty(o,s),n[o]=s);return n}function bn(e,t,n){n!=null?e.style.setProperty(t,n):e.style.removeProperty(t)}function pt(e,t={},n,r){const s={};return r||T(()=>s.children=H(e,t.children,s.children)),T(()=>typeof t.ref=="function"&&At(t.ref,e)),T(()=>Ft(e,t,n,!0,s,!0)),s}function At(e,t,n){return A(()=>e(t,n))}function he(e,t,n,r){if(n!==void 0&&!r&&(r=[]),typeof t!="function")return H(e,t,r,n);T(s=>H(e,t(),s,n),r)}function Ft(e,t,n,r,s={},o=!1){t||(t={});for(const l in s)if(!(l in t)){if(l==="children")continue;s[l]=Ee(e,l,null,s[l],n,o,t)}for(const l in t){if(l==="children")continue;const i=t[l];s[l]=Ee(e,l,i,s[l],n,o,t)}}function Et(e){let t,n;return!M()||!(t=g.registry.get(n=Ot()))?e():(g.completed&&g.completed.add(t),g.registry.delete(n),t)}function M(e){return!!g.context&&!g.done&&(!e||e.isConnected)}function St(e){return e.toLowerCase().replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function Fe(e,t,n){const r=t.trim().split(/\s+/);for(let s=0,o=r.length;s<o;s++)e.classList.toggle(r[s],n)}function Ee(e,t,n,r,s,o,l){let i,c,a,u,f;if(t==="style")return Ct(e,n,r);if(t==="classList")return bt(e,n,r);if(n===r)return r;if(t==="ref")o||n(e);else if(t.slice(0,3)==="on:"){const d=t.slice(3);r&&e.removeEventListener(d,r,typeof r!="function"&&r),n&&e.addEventListener(d,n,typeof n!="function"&&n)}else if(t.slice(0,10)==="oncapture:"){const d=t.slice(10);r&&e.removeEventListener(d,r,!0),n&&e.addEventListener(d,n,!0)}else if(t.slice(0,2)==="on"){const d=t.slice(2).toLowerCase(),h=ft.has(d);if(!h&&r){const b=Array.isArray(r)?r[0]:r;e.removeEventListener(d,b)}(h||n)&&(wt(e,d,n,h),h&&ht([d]))}else if(t.slice(0,5)==="attr:")de(e,t.slice(5),n);else if(t.slice(0,5)==="bool:")yt(e,t.slice(5),n);else if((f=t.slice(0,5)==="prop:")||(a=ot.has(t))||!s&&((u=ct(t,e.tagName))||(c=st.has(t)))||(i=e.nodeName.includes("-")||"is"in l)){if(f)t=t.slice(5),c=!0;else if(M(e))return n;t==="class"||t==="className"?mt(e,n):i&&!c&&!a?e[St(t)]=n:e[u||t]=n}else{const d=s&&t.indexOf(":")>-1&&at[t.split(":")[0]];d?gt(e,d,t,n):de(e,it[t]||t,n)}return n}function xt(e){if(g.registry&&g.events&&g.events.find(([c,a])=>a===e))return;let t=e.target;const n=`$$${e.type}`,r=e.target,s=e.currentTarget,o=c=>Object.defineProperty(e,"target",{configurable:!0,value:c}),l=()=>{const c=t[n];if(c&&!t.disabled){const a=t[`${n}Data`];if(a!==void 0?c.call(t,a,e):c.call(t,e),e.cancelBubble)return}return t.host&&typeof t.host!="string"&&!t.host._$host&&t.contains(e.target)&&o(t.host),!0},i=()=>{for(;l()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),g.registry&&!g.done&&(g.done=_$HY.done=!0),e.composedPath){const c=e.composedPath();o(c[0]);for(let a=0;a<c.length-2&&(t=c[a],!!l());a++){if(t._$host){t=t._$host,i();break}if(t.parentNode===s)break}}else i();o(r)}function H(e,t,n,r,s){const o=M(e);if(o){!n&&(n=[...e.childNodes]);let c=[];for(let a=0;a<n.length;a++){const u=n[a];u.nodeType===8&&u.data.slice(0,2)==="!$"?u.remove():c.push(u)}n=c}for(;typeof n=="function";)n=n();if(t===n)return n;const l=typeof t,i=r!==void 0;if(e=i&&n[0]&&n[0].parentNode||e,l==="string"||l==="number"){if(o||l==="number"&&(t=t.toString(),t===n))return n;if(i){let c=n[0];c&&c.nodeType===3?c.data!==t&&(c.data=t):c=document.createTextNode(t),n=D(e,n,r,c)}else n!==""&&typeof n=="string"?n=e.firstChild.data=t:n=e.textContent=t}else if(t==null||l==="boolean"){if(o)return n;n=D(e,n,r)}else{if(l==="function")return T(()=>{let c=t();for(;typeof c=="function";)c=c();n=H(e,c,n,r)}),()=>n;if(Array.isArray(t)){const c=[],a=n&&Array.isArray(n);if(ge(c,t,n,s))return T(()=>n=H(e,c,n,r,!0)),()=>n;if(o){if(!c.length)return n;if(r===void 0)return n=[...e.childNodes];let u=c[0];if(u.parentNode!==e)return n;const f=[u];for(;(u=u.nextSibling)!==r;)f.push(u);return n=f}if(c.length===0){if(n=D(e,n,r),i)return n}else a?n.length===0?Se(e,c,r):dt(e,n,c):(n&&D(e),Se(e,c));n=c}else if(t.nodeType){if(o&&t.parentNode)return n=i?[t]:t;if(Array.isArray(n)){if(i)return n=D(e,n,r,t);D(e,n,null,t)}else n==null||n===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}}return n}function ge(e,t,n,r){let s=!1;for(let o=0,l=t.length;o<l;o++){let i=t[o],c=n&&n[e.length],a;if(!(i==null||i===!0||i===!1))if((a=typeof i)=="object"&&i.nodeType)e.push(i);else if(Array.isArray(i))s=ge(e,i,c)||s;else if(a==="function")if(r){for(;typeof i=="function";)i=i();s=ge(e,Array.isArray(i)?i:[i],Array.isArray(c)?c:[c])||s}else e.push(i),s=!0;else{const u=String(i);c&&c.nodeType===3&&c.data===u?e.push(c):e.push(document.createTextNode(u))}}return s}function Se(e,t,n=null){for(let r=0,s=t.length;r<s;r++)e.insertBefore(t[r],n)}function D(e,t,n,r){if(n===void 0)return e.textContent="";const s=r||document.createTextNode("");if(t.length){let o=!1;for(let l=t.length-1;l>=0;l--){const i=t[l];if(s!==i){const c=i.parentNode===e;!o&&!l?c?e.replaceChild(s,i):e.insertBefore(s,n):c&&i.remove()}else o=!0}}else e.insertBefore(s,n);return[s]}function Ot(){return g.getNextContextId()}const Pt="http://www.w3.org/2000/svg";function je(e,t=!1,n=void 0){return t?document.createElementNS(Pt,e):document.createElement(e,{is:n})}function Cn(e){const{useShadow:t}=e,n=document.createTextNode(""),r=()=>e.mount||document.body,s=Ce();let o,l=!!g.context;return ve(()=>{l&&(Ce().user=l=!1),o||(o=qe(s,()=>p(()=>e.children)));const i=r();if(i instanceof HTMLHeadElement){const[c,a]=K(!1),u=()=>a(!0);L(f=>he(i,()=>c()?f():o(),null)),B(u)}else{const c=je(e.isSVG?"g":"div",e.isSVG),a=t&&c.attachShadow?c.attachShadow({mode:"open"}):c;Object.defineProperty(c,"_$host",{get(){return n.parentNode},configurable:!0}),he(a,o),i.appendChild(c),e.ref&&e.ref(c),B(()=>i.removeChild(c))}},void 0,{render:!l}),n}function Nt(e,t){const n=p(e);return p(()=>{const r=n();switch(typeof r){case"function":return A(()=>r(t));case"string":const s=ut.has(r),o=g.context?Et():je(r,s,A(()=>t.is));return pt(o,t,s),o}})}function pn(e){const[,t]=tt(e,["component"]);return Nt(()=>e.component,t)}function kt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ye={exports:{}},le,xe;function vt(){if(xe)return le;xe=1;var e=1e3,t=e*60,n=t*60,r=n*24,s=r*7,o=r*365.25;le=function(u,f){f=f||{};var d=typeof u;if(d==="string"&&u.length>0)return l(u);if(d==="number"&&isFinite(u))return f.long?c(u):i(u);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(u))};function l(u){if(u=String(u),!(u.length>100)){var f=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(u);if(f){var d=parseFloat(f[1]),h=(f[2]||"ms").toLowerCase();switch(h){case"years":case"year":case"yrs":case"yr":case"y":return d*o;case"weeks":case"week":case"w":return d*s;case"days":case"day":case"d":return d*r;case"hours":case"hour":case"hrs":case"hr":case"h":return d*n;case"minutes":case"minute":case"mins":case"min":case"m":return d*t;case"seconds":case"second":case"secs":case"sec":case"s":return d*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return d;default:return}}}}function i(u){var f=Math.abs(u);return f>=r?Math.round(u/r)+"d":f>=n?Math.round(u/n)+"h":f>=t?Math.round(u/t)+"m":f>=e?Math.round(u/e)+"s":u+"ms"}function c(u){var f=Math.abs(u);return f>=r?a(u,f,r,"day"):f>=n?a(u,f,n,"hour"):f>=t?a(u,f,t,"minute"):f>=e?a(u,f,e,"second"):u+" ms"}function a(u,f,d,h){var b=f>=d*1.5;return Math.round(u/d)+" "+h+(b?"s":"")}return le}function It(e){n.debug=n,n.default=n,n.coerce=c,n.disable=l,n.enable=s,n.enabled=i,n.humanize=vt(),n.destroy=a,Object.keys(e).forEach(u=>{n[u]=e[u]}),n.names=[],n.skips=[],n.formatters={};function t(u){let f=0;for(let d=0;d<u.length;d++)f=(f<<5)-f+u.charCodeAt(d),f|=0;return n.colors[Math.abs(f)%n.colors.length]}n.selectColor=t;function n(u){let f,d=null,h,b;function w(...C){if(!w.enabled)return;const x=w,E=Number(new Date),O=E-(f||E);x.diff=O,x.prev=f,x.curr=E,f=E,C[0]=n.coerce(C[0]),typeof C[0]!="string"&&C.unshift("%O");let S=0;C[0]=C[0].replace(/%([a-zA-Z%])/g,(U,_e)=>{if(U==="%%")return"%";S++;const we=n.formatters[_e];if(typeof we=="function"){const Ue=C[S];U=we.call(x,Ue),C.splice(S,1),S--}return U}),n.formatArgs.call(x,C),(x.log||n.log).apply(x,C)}return w.namespace=u,w.useColors=n.useColors(),w.color=n.selectColor(u),w.extend=r,w.destroy=n.destroy,Object.defineProperty(w,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(h!==n.namespaces&&(h=n.namespaces,b=n.enabled(u)),b),set:C=>{d=C}}),typeof n.init=="function"&&n.init(w),w}function r(u,f){const d=n(this.namespace+(typeof f>"u"?":":f)+u);return d.log=this.log,d}function s(u){n.save(u),n.namespaces=u,n.names=[],n.skips=[];const f=(typeof u=="string"?u:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const d of f)d[0]==="-"?n.skips.push(d.slice(1)):n.names.push(d)}function o(u,f){let d=0,h=0,b=-1,w=0;for(;d<u.length;)if(h<f.length&&(f[h]===u[d]||f[h]==="*"))f[h]==="*"?(b=h,w=d,h++):(d++,h++);else if(b!==-1)h=b+1,w++,d=w;else return!1;for(;h<f.length&&f[h]==="*";)h++;return h===f.length}function l(){const u=[...n.names,...n.skips.map(f=>"-"+f)].join(",");return n.enable(""),u}function i(u){for(const f of n.skips)if(o(u,f))return!1;for(const f of n.names)if(o(u,f))return!0;return!1}function c(u){return u instanceof Error?u.stack||u.message:u}function a(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}var Lt=It;(function(e,t){var n={};t.formatArgs=s,t.save=o,t.load=l,t.useColors=r,t.storage=i(),t.destroy=(()=>{let a=!1;return()=>{a||(a=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let a;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(a=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(a[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function s(a){if(a[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+a[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const u="color: "+this.color;a.splice(1,0,u,"color: inherit");let f=0,d=0;a[0].replace(/%[a-zA-Z%]/g,h=>{h!=="%%"&&(f++,h==="%c"&&(d=f))}),a.splice(d,0,u)}t.log=console.debug||console.log||(()=>{});function o(a){try{a?t.storage.setItem("debug",a):t.storage.removeItem("debug")}catch{}}function l(){let a;try{a=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch{}return!a&&typeof process<"u"&&"env"in process&&(a=n.DEBUG),a}function i(){try{return localStorage}catch{}}e.exports=Lt(t);const{formatters:c}=e.exports;c.j=function(a){try{return JSON.stringify(a)}catch(u){return"[UnexpectedJSONParseError]: "+u.message}}})(ye,ye.exports);var Tt=ye.exports;const me=kt(Tt),_=["sse","api","session","actions"],Re="opencode:logger:namespaces",ce=new Map,N=new Set,k=typeof globalThis<"u"?globalThis.console:void 0;function J(){N.size===0?me.disable():me.enable(Array.from(N).join(","))}function se(){var e;if(!(typeof window>"u"||!(window!=null&&window.localStorage)))try{window.localStorage.setItem(Re,JSON.stringify(Array.from(N)))}catch(t){(e=k==null?void 0:k.warn)==null||e.call(k,"Failed to persist logger namespaces",t)}}function $t(){var e;if(!(typeof window>"u"||!(window!=null&&window.localStorage)))try{const t=window.localStorage.getItem(Re);if(!t)return;const n=JSON.parse(t);if(!Array.isArray(n))return;for(const r of n)_.includes(r)&&N.add(r)}catch(t){(e=k==null?void 0:k.warn)==null||e.call(k,"Failed to hydrate logger namespaces",t)}}$t();J();function Mt(e){const n=me(e),r=(s,o)=>{n(s,...o)};return{log:(...s)=>n(...s),info:(...s)=>n(...s),warn:(...s)=>r("[warn]",s),error:(...s)=>r("[error]",s)}}function Dt(e){if(!_.includes(e))throw new Error(`Unknown logger namespace: ${e}`);return ce.has(e)||ce.set(e,Mt(e)),ce.get(e)}function jt(){return _.map(e=>({name:e,enabled:N.has(e)}))}function Rt(e){if(!_.includes(e))throw new Error(`Unknown logger namespace: ${e}`);N.has(e)||(N.add(e),se(),J())}function _t(e){if(!_.includes(e))throw new Error(`Unknown logger namespace: ${e}`);N.has(e)&&(N.delete(e),se(),J())}function Ut(){N.clear(),se(),J()}function Vt(){_.forEach(e=>N.add(e)),se(),J()}const Bt={listLoggerNamespaces:jt,enableLogger:Rt,disableLogger:_t,enableAllLoggers:Vt,disableAllLoggers:Ut};function Gt(){typeof window>"u"||(window.codenomadLogger=Bt)}Gt();function Ht(){if(typeof window>"u")return"web";const e=window;return typeof e.electronAPI<"u"?"electron":typeof e.__TAURI__<"u"||typeof navigator<"u"&&/tauri/i.test(navigator.userAgent)?"tauri":"web"}function Kt(){if(typeof navigator>"u")return"desktop";const e=navigator.userAgentData;if(e!=null&&e.mobile)return"mobile";const t=navigator.userAgent.toLowerCase();return/android|iphone|ipad|ipod|blackberry|mini|windows phone|mobile|silk/.test(t)?"mobile":"desktop"}const qt=Dt("actions");let j=null;function zt(){return j||(j={host:Ht(),platform:Kt()},typeof window<"u"&&qt.info(`[runtime] host=${j.host} platform=${j.platform}`),j)}const Jt=zt(),An=()=>Jt.host==="tauri";export{Pe as $,de as A,ht as B,bn as C,pn as D,Dt as E,fn as F,wt as G,Jt as H,Xt as I,Ie as J,ut as K,Wt as L,hn as M,Et as N,g as O,Cn as P,kt as Q,gn as R,an as S,un as T,mn as U,An as V,T as a,p as b,ve as c,L as d,K as e,on as f,Zt as g,Qt as h,rn as i,sn as j,yn as k,cn as l,ln as m,Y as n,B as o,Yt as p,en as q,he as r,tt as s,wn as t,A as u,Ct as v,mt as w,dn as x,pt as y,At as z};
|