litepaseo 0.9.0 → 0.9.1

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.
Files changed (103) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +17 -6
  3. package/dist/server/cli.mjs +8 -2
  4. package/dist/server/{worker-CmsAgviJ.mjs → worker-Bp2G5wKD.mjs} +107 -17
  5. package/dist/web/assets/{ChangesPanel-DdtJswMt.js → ChangesPanel-DOMLIz9b.js} +1 -1
  6. package/dist/web/assets/ChangesPanel-DOMLIz9b.js.br +0 -0
  7. package/dist/web/assets/ChangesPanel-DOMLIz9b.js.gz +0 -0
  8. package/dist/web/assets/{CodeBlockNode-BOeBLCjf.js → CodeBlockNode-C5HKFqZ0.js} +1 -1
  9. package/dist/web/assets/CodeBlockNode-C5HKFqZ0.js.br +0 -0
  10. package/dist/web/assets/CodeBlockNode-C5HKFqZ0.js.gz +0 -0
  11. package/dist/web/assets/{ConversationSearch-BXfGhrtx.js → ConversationSearch-C5IiPRGV.js} +1 -1
  12. package/dist/web/assets/ConversationSearch-C5IiPRGV.js.br +0 -0
  13. package/dist/web/assets/ConversationSearch-C5IiPRGV.js.gz +0 -0
  14. package/dist/web/assets/{FileViewer-C93qu9YH.js → FileViewer-DhPj_aG0.js} +1 -1
  15. package/dist/web/assets/FileViewer-DhPj_aG0.js.br +0 -0
  16. package/dist/web/assets/FileViewer-DhPj_aG0.js.gz +0 -0
  17. package/dist/web/assets/{FilesPanel-DyqtBDO_.js → FilesPanel-C5A4T4Ea.js} +1 -1
  18. package/dist/web/assets/FilesPanel-C5A4T4Ea.js.br +0 -0
  19. package/dist/web/assets/FilesPanel-C5A4T4Ea.js.gz +0 -0
  20. package/dist/web/assets/{HostSettings-BCsvyF_3.js → HostSettings-BwY-M6Zt.js} +1 -1
  21. package/dist/web/assets/HostSettings-BwY-M6Zt.js.br +0 -0
  22. package/dist/web/assets/HostSettings-BwY-M6Zt.js.gz +0 -0
  23. package/dist/web/assets/{MarkdownMessage-CejBvgRc.js → MarkdownMessage-CCyi7hfO.js} +5 -5
  24. package/dist/web/assets/MarkdownMessage-CCyi7hfO.js.br +0 -0
  25. package/dist/web/assets/MarkdownMessage-CCyi7hfO.js.gz +0 -0
  26. package/dist/web/assets/{PreCodeBlock-BBTzkaAH.js → PreCodeBlock-h-vER4fC.js} +1 -1
  27. package/dist/web/assets/{PreCodeBlock.vue_vue_type_style_index_0_lang-4BQzC8nU.js → PreCodeBlock.vue_vue_type_style_index_0_lang-n4zE2oPI.js} +1 -1
  28. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-n4zE2oPI.js.br +0 -0
  29. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-n4zE2oPI.js.gz +0 -0
  30. package/dist/web/assets/{SubagentsPanel-D1bEm5QC.js → SubagentsPanel-DkOeuHdO.js} +1 -1
  31. package/dist/web/assets/SubagentsPanel-DkOeuHdO.js.br +0 -0
  32. package/dist/web/assets/SubagentsPanel-DkOeuHdO.js.gz +0 -0
  33. package/dist/web/assets/{TerminalPanel-wazWBZjN.js → TerminalPanel-eVKbwhAM.js} +1 -1
  34. package/dist/web/assets/TerminalPanel-eVKbwhAM.js.br +0 -0
  35. package/dist/web/assets/TerminalPanel-eVKbwhAM.js.gz +0 -0
  36. package/dist/web/assets/{Tooltip-CrG6tFax.js → Tooltip-BaxHVP4x.js} +1 -1
  37. package/dist/web/assets/Tooltip-BaxHVP4x.js.br +0 -0
  38. package/dist/web/assets/Tooltip-BaxHVP4x.js.gz +0 -0
  39. package/dist/web/assets/{index-Cmpdc3EH.js → index-CB9VixeI.js} +14 -14
  40. package/dist/web/assets/index-CB9VixeI.js.br +0 -0
  41. package/dist/web/assets/index-CB9VixeI.js.gz +0 -0
  42. package/dist/web/assets/{index10-C9Xw5wOS.js → index10-7IpT5PSM.js} +1 -1
  43. package/dist/web/assets/index10-7IpT5PSM.js.br +0 -0
  44. package/dist/web/assets/index10-7IpT5PSM.js.gz +0 -0
  45. package/dist/web/assets/index3-gjUuQ-9z.js +1 -0
  46. package/dist/web/assets/index4-HZdwIocY.js +1 -0
  47. package/dist/web/assets/{index5-Cxc_iCM3.js → index5-B6evHk72.js} +1 -1
  48. package/dist/web/assets/index5-B6evHk72.js.br +0 -0
  49. package/dist/web/assets/index5-B6evHk72.js.gz +0 -0
  50. package/dist/web/assets/{index6-DsTT-iog.js → index6-D7ieXlqa.js} +1 -1
  51. package/dist/web/assets/index6-D7ieXlqa.js.br +0 -0
  52. package/dist/web/assets/index6-D7ieXlqa.js.gz +0 -0
  53. package/dist/web/assets/{index7-Bgw61c0t.js → index7-CZ0TiU0G.js} +1 -1
  54. package/dist/web/assets/index7-CZ0TiU0G.js.br +0 -0
  55. package/dist/web/assets/index7-CZ0TiU0G.js.gz +0 -0
  56. package/dist/web/assets/{index8-DLEM8iM5.js → index8-DlTg7787.js} +1 -1
  57. package/dist/web/assets/index8-DlTg7787.js.br +0 -0
  58. package/dist/web/assets/index8-DlTg7787.js.gz +0 -0
  59. package/dist/web/assets/{index9-CUy1AFI-.js → index9-0kHMsOL6.js} +1 -1
  60. package/dist/web/assets/index9-0kHMsOL6.js.br +0 -0
  61. package/dist/web/assets/index9-0kHMsOL6.js.gz +0 -0
  62. package/dist/web/index.html +1 -1
  63. package/dist/web/index.html.br +0 -0
  64. package/dist/web/index.html.gz +0 -0
  65. package/package.json +1 -1
  66. package/dist/web/assets/ChangesPanel-DdtJswMt.js.br +0 -0
  67. package/dist/web/assets/ChangesPanel-DdtJswMt.js.gz +0 -0
  68. package/dist/web/assets/CodeBlockNode-BOeBLCjf.js.br +0 -0
  69. package/dist/web/assets/CodeBlockNode-BOeBLCjf.js.gz +0 -0
  70. package/dist/web/assets/ConversationSearch-BXfGhrtx.js.br +0 -0
  71. package/dist/web/assets/ConversationSearch-BXfGhrtx.js.gz +0 -0
  72. package/dist/web/assets/FileViewer-C93qu9YH.js.br +0 -0
  73. package/dist/web/assets/FileViewer-C93qu9YH.js.gz +0 -0
  74. package/dist/web/assets/FilesPanel-DyqtBDO_.js.br +0 -0
  75. package/dist/web/assets/FilesPanel-DyqtBDO_.js.gz +0 -0
  76. package/dist/web/assets/HostSettings-BCsvyF_3.js.br +0 -0
  77. package/dist/web/assets/HostSettings-BCsvyF_3.js.gz +0 -0
  78. package/dist/web/assets/MarkdownMessage-CejBvgRc.js.br +0 -0
  79. package/dist/web/assets/MarkdownMessage-CejBvgRc.js.gz +0 -0
  80. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-4BQzC8nU.js.br +0 -0
  81. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-4BQzC8nU.js.gz +0 -0
  82. package/dist/web/assets/SubagentsPanel-D1bEm5QC.js.br +0 -0
  83. package/dist/web/assets/SubagentsPanel-D1bEm5QC.js.gz +0 -0
  84. package/dist/web/assets/TerminalPanel-wazWBZjN.js.br +0 -0
  85. package/dist/web/assets/TerminalPanel-wazWBZjN.js.gz +0 -0
  86. package/dist/web/assets/Tooltip-CrG6tFax.js.br +0 -0
  87. package/dist/web/assets/Tooltip-CrG6tFax.js.gz +0 -0
  88. package/dist/web/assets/index-Cmpdc3EH.js.br +0 -0
  89. package/dist/web/assets/index-Cmpdc3EH.js.gz +0 -0
  90. package/dist/web/assets/index10-C9Xw5wOS.js.br +0 -0
  91. package/dist/web/assets/index10-C9Xw5wOS.js.gz +0 -0
  92. package/dist/web/assets/index3-dduGUVTy.js +0 -1
  93. package/dist/web/assets/index4-qdeznE4u.js +0 -1
  94. package/dist/web/assets/index5-Cxc_iCM3.js.br +0 -0
  95. package/dist/web/assets/index5-Cxc_iCM3.js.gz +0 -0
  96. package/dist/web/assets/index6-DsTT-iog.js.br +0 -0
  97. package/dist/web/assets/index6-DsTT-iog.js.gz +0 -0
  98. package/dist/web/assets/index7-Bgw61c0t.js.br +0 -0
  99. package/dist/web/assets/index7-Bgw61c0t.js.gz +0 -0
  100. package/dist/web/assets/index8-DLEM8iM5.js.br +0 -0
  101. package/dist/web/assets/index8-DLEM8iM5.js.gz +0 -0
  102. package/dist/web/assets/index9-CUy1AFI-.js.br +0 -0
  103. package/dist/web/assets/index9-CUy1AFI-.js.gz +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.1
4
+
5
+ - Compress live streams and larger API responses (1 KB and up) with brotli or gzip, as the browser accepts. A conversation's first rows usually shrink 3-6 times, for example 157 KB to 27 KB, which saves mobile data. Every stream event is flushed as it is written, so compression never holds one back. Turn it off with `litepaseo config set compression off` if a proxy in between mishandles compressed streams.
6
+ - Diagnose slow conversation opens on phones: browser reports now say which kind of browser it was (engine, system, installed web app; never the user agent string), the connection protocol and compression, and how the stream's body arrived (pieces, sizes, arrival times, the longest silence). The 20-second waits still seen on an iPhone web app behind a Cloudflare Tunnel delivered first bytes within about 200 ms but the rows only with the next heartbeat; these reports should show where they were held.
7
+
3
8
  ## 0.9.0
4
9
 
5
10
  - Switch back to a conversation you opened recently and it shows at once, where you left it: the last 5 conversations (3 on phones) stay rendered. Out of view they do nothing: no connection, no timers, no rendering. Coming back, only messages that changed meanwhile render again. In a test switching between real conversations at 4x CPU slowdown (an approximation of a phone), rows were on screen in 162-196 ms instead of 340-384 ms, using less than half the CPU.
package/README.md CHANGED
@@ -247,6 +247,7 @@ litepaseo restart # apply (or: litepaseo
247
247
  | `port` | `8787` | HTTP port | `LITEPASEO_PORT` |
248
248
  | `bind` | `127.0.0.1` | Listening address | `LITEPASEO_BIND` |
249
249
  | `push-subject` | `mailto:litepaseo@example.com` | Contact for push services (see below) | `LITEPASEO_PUSH_SUBJECT` |
250
+ | `compression` | `on` | Compress API responses and live streams (`on` or `off`) | `LITEPASEO_COMPRESSION` |
250
251
 
251
252
  An environment variable, when set, wins over the saved value for that run.
252
253
  `LITEPASEO_HOME` (default `~/.litepaseo`) chooses the data directory itself, so it
@@ -284,16 +285,26 @@ page had just been in the background (`backgroundMs`, `visibleForMs`). A late
284
285
  `connectedMs` with no matching `timeline_slow` means the request took that long to reach
285
286
  the server, typically a connection the browser reused after sleep or a network change. A
286
287
  late `firstByteMs` after an early `connectedMs` means something in between, such as a
287
- proxy or tunnel, held the data. Find them with
288
+ proxy or tunnel, held the data. Browser reports also name the kind of browser (`engine`,
289
+ `os`, `standalone` for an installed web app; never the user agent string), the connection
290
+ (`protocol`, such as `h2` or `h3`, and `encoding`), and how the stream's body arrived:
291
+ `chunks` and `characters` up to the rows, `arrivals` (time and size of the first 10
292
+ pieces), `lastChunkMs`, and the longest silence between pieces (`maxGapMs`, ending at
293
+ `maxGapEndMs`). A long gap ending just before the rows means the data was held back on
294
+ the way rather than slow to send. Find them with
288
295
  `litepaseo logs -n 2000 | grep timeline_slow`.
289
296
 
290
297
  While a conversation is still loading after 3 seconds, the page says whether it is still
291
298
  connecting to LitePaseo, waiting for the network to deliver data, or waiting for the host.
292
-
293
- Some proxies hold a stream's latest bytes until more arrive. LitePaseo follows each burst
294
- of live updates with a few bytes of padding, so they get through without waiting for the
295
- next heartbeat. After an upgrade, open pages offer a
296
- reload so they run the installed version.
299
+ After an upgrade, open pages offer a reload so they run the installed version.
300
+
301
+ Live streams and larger API responses (1 KB and up) are compressed with brotli or gzip
302
+ for browsers that accept it: a conversation's first rows usually shrink 3-6 times. Each
303
+ stream event is flushed as it is written, so compression never delays it. If a proxy
304
+ between you and LitePaseo mishandles compressed streams, run
305
+ `litepaseo config set compression off` and restart. Some proxies also hold a stream's
306
+ latest bytes until more arrive, so each burst of live updates is followed by a few bytes
307
+ of padding.
297
308
 
298
309
  ## How it fits together
299
310
 
@@ -8,7 +8,7 @@ import { DatabaseSync } from "node:sqlite";
8
8
  import { homedir } from "node:os";
9
9
  import { fileURLToPath } from "node:url";
10
10
  // src/server/version.ts
11
- const VERSION = "0.9.0";
11
+ const VERSION = "0.9.1";
12
12
  // src/server/rotating-log.ts
13
13
  /** One writer (the supervisor); bounded active file plus numbered archives. */
14
14
  var RotatingLog = class {
@@ -1088,6 +1088,12 @@ const CONFIG_KEYS = {
1088
1088
  } catch {}
1089
1089
  return "Use mailto:you@example.com or an https:// address you control.";
1090
1090
  }
1091
+ },
1092
+ compression: {
1093
+ env: "LITEPASEO_COMPRESSION",
1094
+ fallback: "on",
1095
+ summary: "Compress API responses and live streams (on or off)",
1096
+ check: (value) => value === "on" || value === "off" ? null : "Use on or off."
1091
1097
  }
1092
1098
  };
1093
1099
  const configKeys = Object.keys(CONFIG_KEYS);
@@ -1715,7 +1721,7 @@ async function run() {
1715
1721
  if (name === "--help" || name === "-h") return console.log(mainHelp(VERSION, displayDirectory(), out));
1716
1722
  if (name === "worker") {
1717
1723
  const paths = await dataDirectory();
1718
- const { runWorker } = await import("./worker-CmsAgviJ.mjs");
1724
+ const { runWorker } = await import("./worker-Bp2G5wKD.mjs");
1719
1725
  return runWorker(paths.directory, fileURLToPath(new URL("../web/", import.meta.url)));
1720
1726
  }
1721
1727
  const command = findCommand(name);
@@ -11,6 +11,8 @@ import { getParentAgentIdFromLabels } from "@getpaseo/protocol/agent-labels";
11
11
  import { timelineItemIdentity } from "@getpaseo/protocol/timeline-identity";
12
12
  import { z } from "zod";
13
13
  import { AgentPermissionResponseSchema, AgentSkillSelectionSchema, MutableDaemonConfigPatchSchema } from "@getpaseo/protocol/messages";
14
+ import { brotliCompress, constants as constants$1, createBrotliCompress, createGzip, gzip } from "node:zlib";
15
+ import { promisify } from "node:util";
14
16
  import { lstat, readFile, realpath } from "node:fs/promises";
15
17
  import { Hono } from "hono";
16
18
  import { bodyLimit } from "hono/body-limit";
@@ -2409,33 +2411,63 @@ var ServerSendQueue = class {
2409
2411
  // src/server/sse.ts
2410
2412
  const HEARTBEAT_MS = 2e4;
2411
2413
  /**
2412
- * Some proxies hold a stream's latest bytes until more arrive: behind a Cloudflare Tunnel, a
2413
- * conversation's rows reached the browser only with the next heartbeat, 20 s later. So every
2414
- * burst of writes is followed by a tiny comment, which pushes it through.
2414
+ * Some proxies hold a stream's latest bytes until more arrive, so every burst of writes is
2415
+ * followed by a tiny comment. It did not cure the 20 s waits seen on an iPhone behind a
2416
+ * Cloudflare Tunnel (rows arrived with the next heartbeat anyway); slow-open reports now carry
2417
+ * the browser's side of each stream to find out why.
2415
2418
  */
2416
2419
  const NUDGE_MS = 50;
2417
- /** Server-sent events over a plain fetch response, so the bearer header still authenticates. */
2418
- function eventStream(signal, open, valid = () => true) {
2420
+ /** The best encoding the request accepts, when compression is on. */
2421
+ function streamEncoding(acceptEncoding, enabled) {
2422
+ if (!enabled || !acceptEncoding) return null;
2423
+ const accepted = /* @__PURE__ */ new Set();
2424
+ for (const part of acceptEncoding.split(",")) {
2425
+ const [name, ...params] = part.trim().toLowerCase().split(";");
2426
+ const q = params.map((p) => p.trim()).find((p) => p.startsWith("q="));
2427
+ if (!q || Number(q.slice(2)) > 0) accepted.add(name.trim());
2428
+ }
2429
+ return accepted.has("br") ? "br" : accepted.has("gzip") ? "gzip" : null;
2430
+ }
2431
+ /**
2432
+ * Server-sent events over a plain fetch response, so the bearer header still authenticates.
2433
+ * With an encoding, every write is compressed and flushed at once: compression never holds an
2434
+ * event back (a sync flush costs a few bytes per write).
2435
+ */
2436
+ function eventStream(signal, open, valid = () => true, encoding = null) {
2419
2437
  const encoder = new TextEncoder();
2420
2438
  let cleanup;
2421
2439
  let nudge;
2440
+ let compressor = null;
2422
2441
  let stopped = false;
2423
2442
  const stop = () => {
2424
2443
  stopped = true;
2425
2444
  clearTimeout(nudge);
2445
+ compressor?.destroy();
2426
2446
  cleanup?.();
2427
2447
  cleanup = void 0;
2428
2448
  };
2429
2449
  const body = new ReadableStream({
2430
2450
  start(controller) {
2431
- const enqueue = (text) => {
2451
+ const output = (bytes) => {
2432
2452
  if (stopped) return;
2433
2453
  try {
2434
- controller.enqueue(encoder.encode(text));
2454
+ controller.enqueue(bytes);
2435
2455
  } catch {
2436
2456
  stop();
2437
2457
  }
2438
2458
  };
2459
+ if (encoding) {
2460
+ compressor = encoding === "br" ? createBrotliCompress({ params: { [constants$1.BROTLI_PARAM_QUALITY]: 5 } }) : createGzip({ level: 6 });
2461
+ compressor.on("data", (chunk) => output(new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength)));
2462
+ compressor.on("error", stop);
2463
+ }
2464
+ const flushMode = encoding === "br" ? constants$1.BROTLI_OPERATION_FLUSH : constants$1.Z_SYNC_FLUSH;
2465
+ const enqueue = (text) => {
2466
+ if (stopped) return;
2467
+ if (!compressor) return output(encoder.encode(text));
2468
+ compressor.write(text);
2469
+ compressor.flush(flushMode);
2470
+ };
2439
2471
  const write = (text) => {
2440
2472
  enqueue(text);
2441
2473
  if (stopped || nudge) return;
@@ -2470,9 +2502,37 @@ function eventStream(signal, open, valid = () => true) {
2470
2502
  return new Response(body, { headers: {
2471
2503
  "Content-Type": "text/event-stream",
2472
2504
  "Cache-Control": "no-cache, no-transform",
2473
- "X-Accel-Buffering": "no"
2505
+ "X-Accel-Buffering": "no",
2506
+ ...encoding ? {
2507
+ "Content-Encoding": encoding,
2508
+ Vary: "Accept-Encoding"
2509
+ } : {}
2474
2510
  } });
2475
2511
  }
2512
+ // src/server/compression.ts
2513
+ const brotli = promisify(brotliCompress);
2514
+ const gzipped = promisify(gzip);
2515
+ /**
2516
+ * Compresses JSON API responses (history pages, prompt indexes, directory reads) with brotli
2517
+ * or gzip, as the browser accepts. Live streams compress themselves (see eventStream).
2518
+ */
2519
+ function compressJson(enabled) {
2520
+ return async (c, next) => {
2521
+ await next();
2522
+ if (!enabled || c.req.method === "HEAD") return;
2523
+ const res = c.res;
2524
+ if (!res.body || res.headers.has("Content-Encoding") || !(res.headers.get("Content-Type") ?? "").startsWith("application/json")) return;
2525
+ const encoding = streamEncoding(c.req.header("Accept-Encoding"), true);
2526
+ if (!encoding) return;
2527
+ const body = new Uint8Array(await res.arrayBuffer());
2528
+ const compressed = body.byteLength < 1024 ? null : encoding === "br" ? await brotli(body, { params: { [constants$1.BROTLI_PARAM_QUALITY]: 5 } }) : await gzipped(body, { level: 6 });
2529
+ c.res = new Response(compressed ?? body, res);
2530
+ c.res.headers.delete("Content-Length");
2531
+ if (compressed) c.res.headers.set("Content-Encoding", encoding);
2532
+ const vary = c.res.headers.get("Vary");
2533
+ if (!vary || !/(?:^|,)\s*accept-encoding\s*(?:,|$)/i.test(vary)) c.res.headers.set("Vary", vary ? `${vary}, Accept-Encoding` : "Accept-Encoding");
2534
+ };
2535
+ }
2476
2536
  // src/server/media.ts
2477
2537
  /** Raster images only: an SVG opened directly could run script on this origin. */
2478
2538
  const IMAGE_MIME = {
@@ -2588,7 +2648,7 @@ const path = z.string().min(1).max(4096).refine((p) => !p.includes("\0"));
2588
2648
  * daemon, which confines file access to the workspace and owns the terminals; nothing here
2589
2649
  * keeps state beyond an open terminal stream.
2590
2650
  */
2591
- function registerWorkspaceRoutes(app, hosts, store, valid) {
2651
+ function registerWorkspaceRoutes(app, hosts, store, valid, encodingOf = () => null) {
2592
2652
  app.get("/api/hosts/:host/changes", async (c) => {
2593
2653
  const cwd = path.parse(c.req.query("cwd"));
2594
2654
  const result = await hosts.get(c.req.param("host")).driver.getCheckoutDiff(cwd, { mode: "uncommitted" });
@@ -2761,7 +2821,7 @@ function registerWorkspaceRoutes(app, hosts, store, valid) {
2761
2821
  stop();
2762
2822
  subscription.release().catch(() => {});
2763
2823
  };
2764
- }, valid(c));
2824
+ }, valid(c), encodingOf(c));
2765
2825
  });
2766
2826
  /** Every connected host's schedules; a host that fails reports its error instead. */
2767
2827
  app.get("/api/schedules", async (c) => {
@@ -4135,6 +4195,10 @@ function createApp(store, hosts, token, webRoot, options = {}) {
4135
4195
  c.header("Referrer-Policy", "no-referrer");
4136
4196
  c.header("Content-Security-Policy", "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; connect-src 'self'; img-src 'self' data: blob:; worker-src 'self'; manifest-src 'self'; frame-ancestors 'none'");
4137
4197
  });
4198
+ const compression = options.compression !== false;
4199
+ /** How a live stream to this request is compressed. */
4200
+ const encodingOf = (c) => streamEncoding(c.req.header("Accept-Encoding"), compression);
4201
+ app.use("/api/*", compressJson(compression));
4138
4202
  app.use("/api/*", (c, next) => bodyLimit({ maxSize: c.req.method !== "POST" ? 1048576 : c.req.path.endsWith("/attachments") ? MAX_FILE_BYTES : c.req.path === "/api/dictation/transcribe" ? MAX_DICTATION_BYTES : 1048576 })(c, next));
4139
4203
  app.use("/api/*", async (c, next) => {
4140
4204
  c.header("Cache-Control", "no-store");
@@ -4461,6 +4525,29 @@ function createApp(store, hosts, token, webRoot, options = {}) {
4461
4525
  rowsMs: ms,
4462
4526
  renderMs: ms,
4463
4527
  firstByteMs: ms.optional(),
4528
+ engine: z.enum([
4529
+ "webkit",
4530
+ "blink",
4531
+ "gecko",
4532
+ "other"
4533
+ ]).optional(),
4534
+ os: z.enum([
4535
+ "ios",
4536
+ "android",
4537
+ "macos",
4538
+ "windows",
4539
+ "linux",
4540
+ "other"
4541
+ ]).optional(),
4542
+ standalone: z.boolean().optional(),
4543
+ protocol: z.string().max(20).nullable().optional(),
4544
+ encoding: z.string().max(10).nullable().optional(),
4545
+ chunks: z.number().int().nonnegative().max(1e6).optional(),
4546
+ characters: z.number().int().nonnegative().max(1e9).optional(),
4547
+ lastChunkMs: ms.optional(),
4548
+ maxGapMs: z.number().int().nonnegative().max(36e5).optional(),
4549
+ maxGapEndMs: ms.optional(),
4550
+ arrivals: z.array(z.tuple([z.number().int().nonnegative().max(36e5), z.number().int().nonnegative().max(1e9)])).max(10).optional(),
4464
4551
  attempts: z.number().int().nonnegative().max(1e3),
4465
4552
  hidden: z.boolean(),
4466
4553
  pageAgeMs: long.optional(),
@@ -4508,7 +4595,7 @@ function createApp(store, hosts, token, webRoot, options = {}) {
4508
4595
  deliverAgents(stream);
4509
4596
  directoryStreams.add(stream);
4510
4597
  return () => directoryStreams.delete(stream);
4511
- }, streamValidity(c));
4598
+ }, streamValidity(c), encodingOf(c));
4512
4599
  });
4513
4600
  app.post("/api/hosts", async (c) => {
4514
4601
  const input = z.object({
@@ -4659,7 +4746,7 @@ function createApp(store, hosts, token, webRoot, options = {}) {
4659
4746
  stop();
4660
4747
  stopSubagents();
4661
4748
  };
4662
- }, streamValidity(c));
4749
+ }, streamValidity(c), encodingOf(c));
4663
4750
  });
4664
4751
  /** One provider subagent's conversation, read-only, live like an agent's. */
4665
4752
  app.get("/api/hosts/:host/agents/:agent/subagents/:subagent/timeline/stream", (c) => {
@@ -4667,7 +4754,7 @@ function createApp(store, hosts, token, webRoot, options = {}) {
4667
4754
  return eventStream(c.req.raw.signal, (send) => hosts.watchTimeline(c.req.param("host"), c.req.param("agent"), (ops) => send({
4668
4755
  type: "ops",
4669
4756
  ops
4670
- }), c.req.param("subagent")), streamValidity(c));
4757
+ }), c.req.param("subagent")), streamValidity(c), encodingOf(c));
4671
4758
  });
4672
4759
  app.get("/api/hosts/:host/agents/:agent/subagents/:subagent/timeline", async (c) => {
4673
4760
  const cursor = z.object({
@@ -4965,13 +5052,13 @@ function createApp(store, hosts, token, webRoot, options = {}) {
4965
5052
  stop();
4966
5053
  stopHosts();
4967
5054
  };
4968
- }, streamValidity(c)));
5055
+ }, streamValidity(c), encodingOf(c)));
4969
5056
  app.get("/api/hosts/:host/agents/:agent/queue/stream", (c) => eventStream(c.req.raw.signal, (send) => {
4970
5057
  const publish = () => send(sendQueue.list(c.req.param("host"), c.req.param("agent")));
4971
5058
  const stop = sendQueue.onChange(publish);
4972
5059
  publish();
4973
5060
  return stop;
4974
- }, streamValidity(c)));
5061
+ }, streamValidity(c), encodingOf(c)));
4975
5062
  app.post("/api/hosts/:host/agents/:agent/queue/:id/control", async (c) => {
4976
5063
  const { action } = z.object({ action: z.enum([
4977
5064
  "pause",
@@ -5302,7 +5389,7 @@ function createApp(store, hosts, token, webRoot, options = {}) {
5302
5389
  }
5303
5390
  });
5304
5391
  registerHostSettings(app, hosts);
5305
- registerWorkspaceRoutes(app, hosts, store, (c) => streamValidity(c));
5392
+ registerWorkspaceRoutes(app, hosts, store, (c) => streamValidity(c), encodingOf);
5306
5393
  app.get("/api/usage", async (c) => c.json(await usage.report(c.req.query("refresh") === "1")));
5307
5394
  app.get("/api/board", (c) => c.json(store.board()));
5308
5395
  app.put("/api/board", async (c) => {
@@ -5411,7 +5498,10 @@ async function runWorker(directory, webRoot) {
5411
5498
  }
5412
5499
  const config = effectiveConfig(store, process.env);
5413
5500
  const port = Number(config.port.value), hostname = config.bind.value;
5414
- const app = createApp(store, hosts, tokenFile(tokenPath), webRoot, { pushSubject: config["push-subject"].value });
5501
+ const app = createApp(store, hosts, tokenFile(tokenPath), webRoot, {
5502
+ pushSubject: config["push-subject"].value,
5503
+ compression: config.compression.value !== "off"
5504
+ });
5415
5505
  const server = serve({
5416
5506
  fetch: app.fetch,
5417
5507
  port,
@@ -1,2 +1,2 @@
1
- import{I as e,R as t,S as n,T as r,V as i,at as a,ct as o,f as s,g as c,q as l,tt as u,v as d,y as f}from"./vue.runtime.esm-bundler-4XjPOHMM.js";import{p}from"./index-Cmpdc3EH.js";var m={class:`changes-panel`},h=[`disabled`],g={key:0,role:`alert`},_={key:1},v={key:2},y=[`onToggle`],b=[`onClick`],x={key:0},S={key:1},C={class:`hunk`},w=p(r({__name:`ChangesPanel`,props:{hostId:{},cwd:{},api:{type:Function}},setup(r){let p=r,w=u([]),T=u(``),E=u(!1),D=u(!1),O=0,k=u(new Set);e(()=>O++);async function A(){let e=++O;E.value=!0,T.value=``,w.value=[],D.value=!1,k.value=new Set;try{let t=await p.api(`/hosts/${encodeURIComponent(p.hostId)}/changes?cwd=${encodeURIComponent(p.cwd)}`);if(e!==O)return;w.value=t.files,D.value=!!t.diffTooLarge}catch(t){e===O&&(T.value=t.message)}finally{e===O&&(E.value=!1)}}async function j(e){try{await navigator.clipboard.writeText(e)}catch{T.value=`Could not copy path.`}}return l(()=>[p.hostId,p.cwd],()=>{w.value=[],A()},{immediate:!0}),(e,r)=>(t(),f(`section`,m,[r[0]||=c(`p`,null,`Workspace uncommitted changes · includes changes from all contributors.`,-1),c(`button`,{class:`btn`,disabled:E.value,onClick:A},o(E.value?`Loading…`:`Refresh changes`),9,h),T.value?(t(),f(`p`,g,o(T.value),1)):d(``,!0),D.value?(t(),f(`p`,_,`Diff exceeds the host limit; some changes are omitted.`)):d(``,!0),!E.value&&!T.value&&!w.value.length?(t(),f(`p`,v,`No uncommitted changes.`)):d(``,!0),(t(!0),f(s,null,i(w.value,e=>(t(),f(`details`,{key:e.path,onToggle:t=>t.target.open?k.value.add(e.path):k.value.delete(e.path)},[c(`summary`,null,[n(o(e.oldPath?e.oldPath+` → `:``)+o(e.path)+` `,1),c(`span`,null,`+`+o(e.additions)+` −`+o(e.deletions),1)]),c(`button`,{class:`btn btn-ghost`,onClick:t=>j(e.path)},`Copy path`,8,b),e.status===`binary`?(t(),f(`p`,x,`Binary file changed.`)):e.status===`too_large`?(t(),f(`p`,S,`File diff is too large to display.`)):d(``,!0),k.value.has(e.path)?(t(!0),f(s,{key:2},i(e.hunks,(e,n)=>(t(),f(`pre`,{key:n},[c(`code`,null,[c(`span`,C,`@@ −`+o(e.oldStart)+`,`+o(e.oldCount)+` +`+o(e.newStart)+`,`+o(e.newCount)+` @@
1
+ import{I as e,R as t,S as n,T as r,V as i,at as a,ct as o,f as s,g as c,q as l,tt as u,v as d,y as f}from"./vue.runtime.esm-bundler-4XjPOHMM.js";import{p}from"./index-CB9VixeI.js";var m={class:`changes-panel`},h=[`disabled`],g={key:0,role:`alert`},_={key:1},v={key:2},y=[`onToggle`],b=[`onClick`],x={key:0},S={key:1},C={class:`hunk`},w=p(r({__name:`ChangesPanel`,props:{hostId:{},cwd:{},api:{type:Function}},setup(r){let p=r,w=u([]),T=u(``),E=u(!1),D=u(!1),O=0,k=u(new Set);e(()=>O++);async function A(){let e=++O;E.value=!0,T.value=``,w.value=[],D.value=!1,k.value=new Set;try{let t=await p.api(`/hosts/${encodeURIComponent(p.hostId)}/changes?cwd=${encodeURIComponent(p.cwd)}`);if(e!==O)return;w.value=t.files,D.value=!!t.diffTooLarge}catch(t){e===O&&(T.value=t.message)}finally{e===O&&(E.value=!1)}}async function j(e){try{await navigator.clipboard.writeText(e)}catch{T.value=`Could not copy path.`}}return l(()=>[p.hostId,p.cwd],()=>{w.value=[],A()},{immediate:!0}),(e,r)=>(t(),f(`section`,m,[r[0]||=c(`p`,null,`Workspace uncommitted changes · includes changes from all contributors.`,-1),c(`button`,{class:`btn`,disabled:E.value,onClick:A},o(E.value?`Loading…`:`Refresh changes`),9,h),T.value?(t(),f(`p`,g,o(T.value),1)):d(``,!0),D.value?(t(),f(`p`,_,`Diff exceeds the host limit; some changes are omitted.`)):d(``,!0),!E.value&&!T.value&&!w.value.length?(t(),f(`p`,v,`No uncommitted changes.`)):d(``,!0),(t(!0),f(s,null,i(w.value,e=>(t(),f(`details`,{key:e.path,onToggle:t=>t.target.open?k.value.add(e.path):k.value.delete(e.path)},[c(`summary`,null,[n(o(e.oldPath?e.oldPath+` → `:``)+o(e.path)+` `,1),c(`span`,null,`+`+o(e.additions)+` −`+o(e.deletions),1)]),c(`button`,{class:`btn btn-ghost`,onClick:t=>j(e.path)},`Copy path`,8,b),e.status===`binary`?(t(),f(`p`,x,`Binary file changed.`)):e.status===`too_large`?(t(),f(`p`,S,`File diff is too large to display.`)):d(``,!0),k.value.has(e.path)?(t(!0),f(s,{key:2},i(e.hunks,(e,n)=>(t(),f(`pre`,{key:n},[c(`code`,null,[c(`span`,C,`@@ −`+o(e.oldStart)+`,`+o(e.oldCount)+` +`+o(e.newStart)+`,`+o(e.newCount)+` @@
2
2
  `,1),(t(!0),f(s,null,i(e.lines,(e,n)=>(t(),f(`span`,{key:n,class:a(e.type)},o(e.type===`add`?`+`:e.type===`remove`?`−`:` `)+o(e.content),3))),128))])]))),128)):d(``,!0)],40,y))),128))]))}}),[[`__scopeId`,`data-v-4de9f4ce`]]);export{w as default};
@@ -1,3 +1,3 @@
1
- import{C as e,E as t,F as n,H as r,I as i,K as a,N as o,R as s,T as c,X as l,Y as u,_ as d,at as f,b as p,ct as ee,d as m,g as h,h as g,it as te,j as _,k as ne,l as re,m as v,nt as ie,q as y,st as ae,tt as b,v as oe,y as se}from"./vue.runtime.esm-bundler-4XjPOHMM.js";import{E as ce,G as le,U as ue,W as de,X as fe,Y as pe,Z as me,a as he,at as ge,b as _e,c as ve,d as ye,et as be,ft as xe,g as Se,it as Ce,lt as we,n as Te,nt as Ee,ot as De,rt as Oe,ut as ke,v as Ae,w as je,x as Me}from"./MarkdownMessage-CejBvgRc.js";import{n as Ne,r as Pe,t as Fe}from"./PreCodeBlock.vue_vue_type_style_index_0_lang-4BQzC8nU.js";import{n as Ie,t as x}from"./safeRaf-BDp3SJMs.js";import{o as Le}from"./index-Cmpdc3EH.js";var S=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())}),Re=!1,ze=null,Be=null,Ve=null;function He(){return S(this,null,function*(){if(Ve)return Ve;Ve=S(null,null,function*(){if(!Be)try{if(Be=function(e){let t=e,n=typeof t?.createCodeBlockRuntime==`function`||typeof t?.useMonaco==`function`?t:e?.default,r=n?.createCodeBlockRuntime??n?.useMonaco;return typeof r==`function`?{createCodeBlockRuntime:e=>r.call(n,e),detectLanguage:(n?.detectLanguage)?.bind(n),preloadStreamDiffs:(n?.preloadStreamDiffs)?.bind(n)}:null}(yield Le(()=>import(`./markstream_markstream-vue-Bj0UewdV.js`),[])),!Be)return null}catch{return null}try{return yield function(e){return S(this,null,function*(){if(!Re)return ze||(ze=S(null,null,function*(){let t=e?.preloadStreamDiffs;typeof t==`function`&&(yield t()),Re=!0}).finally(()=>{ze=null}),ze)})}(Be),de(),Be}catch{return null}});try{return yield Ve}finally{Ve=null}})}var Ue=Object.defineProperty,We=Object.defineProperties,C=Object.getOwnPropertyDescriptors,w=Object.getOwnPropertySymbols,Ge=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable,Ke=(e,t,n)=>t in e?Ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,E=(e,t)=>{for(var n in t||={})Ge.call(t,n)&&Ke(e,n,t[n]);if(w)for(var n of w(t))T.call(t,n)&&Ke(e,n,t[n]);return e},qe=(e,t)=>We(e,C(t)),D=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())}),O={class:`html-preview-frame__header`},Je={class:`html-preview-frame__title`},Ye={class:`html-preview-frame__label`},k=[`sandbox`,`srcdoc`],Xe=Ae(c({__name:`HtmlPreviewFrame`,props:{code:{},isDark:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},onClose:{type:Function},title:{}},setup(e){let t=e,{t:r}=Me(),a=g(()=>{let e=t.code||``,n=e.trim().toLowerCase();return n.startsWith(`<!doctype`)||n.startsWith(`<html`)||n.startsWith(`<body`)?e:`<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <style>\n html, body {\n margin: 0;\n padding: 0;\n height: 100%;\n background-color: ${t.isDark?`#020617`:`#ffffff`};\n color: ${t.isDark?`#e5e7eb`:`#020617`};\n }\n body {\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Text', ui-sans-serif, sans-serif;\n }\n </style>\n </head>\n <body>\n ${e}\n </body>\n</html>`}),o=g(()=>{return e=t.htmlPreviewSandbox,n=t.htmlPreviewAllowScripts,typeof e==`string`?e:e===void 0&&!0===n?`allow-scripts`:``;var e,n});function c(e){var n;e.key!==`Escape`&&e.key!==`Esc`||(n=t.onClose)==null||n.call(t)}return n(()=>{typeof window<`u`&&window.addEventListener(`keydown`,c)}),i(()=>{typeof window<`u`&&window.removeEventListener(`keydown`,c)}),(e,n)=>(s(),d(v,{to:`body`},[h(`div`,{class:f([`markstream-vue`,{dark:t.isDark}])},[h(`div`,{class:`html-preview-frame__backdrop`,onClick:n[2]||=e=>t.onClose?.call(t)},[h(`div`,{class:`html-preview-frame`,onClick:n[1]||=m(()=>{},[`stop`])},[h(`div`,O,[h(`div`,Je,[n[3]||=h(`span`,{class:`html-preview-frame__dot`},null,-1),h(`span`,Ye,ee(t.title||te(r)(`common.preview`)||`Preview`),1)]),h(`button`,{type:`button`,class:`html-preview-frame__close`,onClick:n[0]||=e=>t.onClose?.call(t)},` × `)]),h(`iframe`,{class:`html-preview-frame__iframe`,sandbox:o.value,referrerpolicy:`no-referrer`,srcdoc:a.value},null,8,k)])])],2)]))}}),[[`__scopeId`,`data-v-24e66176`]]),Ze=[`data-markstream-enhanced`,`data-markstream-enhancement-state`,`data-markstream-code-block-state`,`data-markstream-pending`,`data-markstream-viewport-pending`],Qe={class:`code-header-main`},$e=[`innerHTML`],et={class:`code-header-copy`},tt={class:`code-header-title`},nt={key:0,class:`code-header-caption`},rt=[`data-markstream-host-hidden`],A=Ae(c({__name:`CodeBlockNode`,props:{node:{},codeBlockOptions:{},clipboardWriter:{},showLineNumbers:{type:Boolean,default:void 0},isDark:{type:Boolean,default:!1},loading:{type:Boolean,default:!0},stream:{type:Boolean,default:!0},theme:{},darkTheme:{default:void 0},lightTheme:{default:void 0},isShowPreview:{type:Boolean,default:!0},enableFontSizeControl:{type:Boolean,default:!0},minWidth:{default:void 0},maxWidth:{default:void 0},themes:{},showPreviewButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},showTooltips:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},customId:{},showHeader:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},estimatedHeightPx:{},estimatedContentHeightPx:{},estimatedDiffInline:{type:Boolean}},emits:[`previewCode`,`copy`],setup(c,{emit:m}){let v=c,de=m,Ae=g(()=>v.showLineNumbers??!0!==v.codeBlockOptions?.disableLineNumbers),Le=a(),S=ne(fe,null),Re=ne(`markstreamHostScrollManaged`,null),ze=ne(Se,void 0),Be=g(()=>ve(v,Le)),Ve=t(),Ue=g(()=>{let e=Ve?.vnode.props;return!(!e||!e.onPreviewCode&&!e[`onPreview-code`])}),{t:We}=Me(),C=b(null),w=b(null),Ge=b(!1),T=b(Hr(v.node.language,v.node.code,Vr())),Ke=g(()=>me(T.value)),O=g(()=>Ke.value===`plaintext`?`text`:Ke.value),Je=g(()=>Ke.value===`plaintext`),Ye=b(!1),k=b(!1),A=b(!1),j=b(!1),M=b(!1),it=b(!1),N=!1,at=!1,ot=null,st=null,ct=null,lt=0,ut=!1,dt=``,ft=b(null),pt=0,mt=!1,ht=Te(),gt=ce(),_t=ye(),vt=ie(null),P=b(typeof window>`u`||!_t.value),yt=t()?.vnode.el?.textContent??``,bt=typeof window<`u`&&String(v.node.code??``).length>0&&yt.includes(String(v.node.code)),xt=b(!bt);n(()=>{xt.value=!0}),typeof window<`u`&&y([()=>w.value,_t],([e,t],n,r)=>{var i;if((i=vt.value)==null||i.destroy(),vt.value=null,!t||P.value)return void(P.value=!0);if(!e)return void(P.value=!1);let a=!0,o=gt?.value.heavyBlockMargin??gt?.value.rootMargin??`0px`,s=ht(e,{rootMargin:o,allowIdle:!1});vt.value=s,P.value=P.value||s.isVisible.value,s.whenVisible.then(()=>{a&&vt.value===s&&(P.value=!0)}).catch(()=>{}),r(()=>{a=!1,s.destroy(),vt.value===s&&(vt.value=null)})},{immediate:!0}),o(()=>{var e;N=!0,function(){let e=dt;S&&e&&(dt=``,S.markSettled(e))}(),(e=vt.value)==null||e.destroy(),vt.value=null});let F=null,St=null,Ct=()=>{},wt=()=>{},Tt=()=>{},Et=()=>{},Dt=()=>null,I=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),L=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),Ot=()=>{},kt=()=>{},At=()=>{},jt=null,R=null,Mt=null,Nt=null,Pt=()=>String(v.node.language??`plaintext`),Ft=()=>D(null,null,function*(){}),It=!1,Lt=null,Rt=[],zt=[],Bt=null,Vt=null,z=g(()=>Oe(v.node)),Ht=b({removed:0,added:0}),Ut=g(()=>`-${Ht.value.removed} +${Ht.value.added}`);function Wt(e,t){return{original:e,updated:t}}function Gt(e){return String(e??``).replace(/\r\n$|\n$|\r$/,``)}function Kt(e){return String(e?.message??e).includes(`no diff result available`)}function qt(){if(!$())try{let e=At();e&&typeof e.catch==`function`&&e.catch(e=>{Kt(e)})}catch(e){Kt(e)}}let Jt=g(()=>{let e=E({},v.codeBlockOptions||{});for(let t of[`theme`,`themes`,`themeType`,`language`,`languages`,`stream`,`disableFileHeader`,`onThemeChange`,`renderCustomHeader`,`renderHeaderMetadata`,`renderHeaderPrefix`,`maxHeight`,`padding`,`tabSize`])delete e[t];if(!z.value)return e;let t=e.parseDiffOptions&&typeof e.parseDiffOptions==`object`?e.parseDiffOptions:{},n={diffStyle:`split`,expandUnchanged:!1,collapsedContextThreshold:5,hunkSeparators:`line-info`,parseDiffOptions:{context:2}};return qe(E(E({},n),e),{parseDiffOptions:E(E({},n.parseDiffOptions),t)})}),Yt=g(()=>{return(v.theme===void 0?!fi(v.darkTheme,v.lightTheme):(e=v.theme)&&typeof e==`object`&&`light`in e&&`dark`in e)?!!v.isDark:function(e){let t=di(e)??``;return Ce(t,!0===v.isDark)}(pi());var e}),Xt=g(()=>(z.value,Yt.value?`dark`:`light`)),Zt=g(()=>z.value?Xt.value===`dark`:Yt.value),B=g(()=>ke({darkTheme:v.darkTheme,isDark:v.isDark,lightTheme:v.lightTheme,theme:v.theme,themes:v.themes})),Qt=g(()=>z.value?`diff`:`single`),$t=b(Qt.value),V=b(!1),H=b(!1),en=b(!1),U=b(!1),tn=b(null),nn=b(0),rn=b(0),an=b(!1),on=null,sn=!1,cn=null,ln=!1,un=g(()=>!!z.value&&Jt.value?.diffStyle===`unified`),dn=g(()=>De(Jt.value));function fn(e){return!0===Re?.value||!!e&&(!!e.closest(`[data-markstream-virtual-timeline="1"], .markstream-virtual-timeline`)||!!e.closest(`.vue-recycle-scroller, [data-virtualizer], [data-virtual-scroll-root]`))}let pn=g(()=>fn(w.value)),mn=g(()=>!(V.value||!U.value&&H.value)),hn=g(()=>mn.value),gn=g(()=>mn.value&&!en.value),_n=g(()=>!V.value&&!U.value&&mn.value),vn=g(()=>H.value&&!V.value?`ready`:U.value?`fallback`:`pending`),yn=b(!1),W=g(()=>Gt(v.node.code)),bn=g(()=>z.value?!0===v.node.diff?v.node:qe(E({},v.node),{diff:!0}):W.value===v.node.code?v.node:qe(E({},v.node),{code:W.value}));function xn(e){let t=e.detectLanguage;typeof t==`function`&&(Pt=t),Vt=e,Bt=gi();let n=e.createCodeBlockRuntime(Bt);return!!n&&(F=n.createEditor||F,St=n.createDiffEditor||St,Ct=n.updateCode||Ct,wt=n.updateDiff||wt,Tt=n.finalizeCode||Tt,Et=n.finalizeDiff||Et,Dt=n.getEditor||Dt,I=n.getEditorView||I,L=n.getDiffEditorView||L,Ot=n.cleanupEditor||Ot,kt=n.safeClean||n.cleanupEditor||kt,At=n.refreshDiffPresentation||At,Ft=n.setTheme||Ft,jt=n.whenVisualReady||null,it.value=!0,!0)}let G=b(typeof v.codeBlockOptions?.fontSize==`number`?v.codeBlockOptions.fontSize:NaN),K=b(G.value),Sn=b(null),Cn=b(null),wn=b(null),Tn=b(null),En=g(()=>{let e=G.value,t=K.value;return typeof e==`number`&&Number.isFinite(e)&&e>0&&typeof t==`number`&&Number.isFinite(t)&&t>0}),Dn=g(()=>{let e=v.codeBlockOptions?.fontSize;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e;let t=K.value;return typeof t==`number`&&Number.isFinite(t)&&t>0?t:12}),On=g(()=>{let e=v.codeBlockOptions?.lineHeight;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:Dn.value===12?18:Math.max(12,Math.round(1.5*Dn.value))}),kn=g(()=>On.value),An=g(()=>{let e=v.codeBlockOptions?.tabSize;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:4}),jn=g(()=>{let e=v.codeBlockOptions?.padding,t=typeof e==`number`&&Number.isFinite(e)&&e>=0?e:8;return{top:t,bottom:t}}),Mn=g(()=>qe(E({},xe(v.codeBlockOptions)),{fontSize:Dn.value,lineHeight:kn.value,maxHeight:zr(),padding:jn.value.top,paddingBottom:jn.value.bottom,tabSize:An.value})),Nn=g(()=>{let e=v.estimatedContentHeightPx;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:null});function Pn(e){if(e==null)return null;let t=Math.ceil(e);return!Number.isFinite(t)||t<=0?null:Math.min(t,Math.ceil(zr()))}function Fn(){return!z.value&&!1!==v.stream&&!1!==v.loading}let In=b(Fn());function Ln(){return Fn()||In.value}let Rn=g(()=>z.value?null:Nn.value==null||Ln()?Math.ceil((e=>{let t=String(e??``);if(!t)return 1;let n=1;for(let e=0;e<t.length;e++)t[e]===`
1
+ import{C as e,E as t,F as n,H as r,I as i,K as a,N as o,R as s,T as c,X as l,Y as u,_ as d,at as f,b as p,ct as ee,d as m,g as h,h as g,it as te,j as _,k as ne,l as re,m as v,nt as ie,q as y,st as ae,tt as b,v as oe,y as se}from"./vue.runtime.esm-bundler-4XjPOHMM.js";import{E as ce,G as le,U as ue,W as de,X as fe,Y as pe,Z as me,a as he,at as ge,b as _e,c as ve,d as ye,et as be,ft as xe,g as Se,it as Ce,lt as we,n as Te,nt as Ee,ot as De,rt as Oe,ut as ke,v as Ae,w as je,x as Me}from"./MarkdownMessage-CCyi7hfO.js";import{n as Ne,r as Pe,t as Fe}from"./PreCodeBlock.vue_vue_type_style_index_0_lang-n4zE2oPI.js";import{n as Ie,t as x}from"./safeRaf-BDp3SJMs.js";import{o as Le}from"./index-CB9VixeI.js";var S=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())}),Re=!1,ze=null,Be=null,Ve=null;function He(){return S(this,null,function*(){if(Ve)return Ve;Ve=S(null,null,function*(){if(!Be)try{if(Be=function(e){let t=e,n=typeof t?.createCodeBlockRuntime==`function`||typeof t?.useMonaco==`function`?t:e?.default,r=n?.createCodeBlockRuntime??n?.useMonaco;return typeof r==`function`?{createCodeBlockRuntime:e=>r.call(n,e),detectLanguage:(n?.detectLanguage)?.bind(n),preloadStreamDiffs:(n?.preloadStreamDiffs)?.bind(n)}:null}(yield Le(()=>import(`./markstream_markstream-vue-Bj0UewdV.js`),[])),!Be)return null}catch{return null}try{return yield function(e){return S(this,null,function*(){if(!Re)return ze||(ze=S(null,null,function*(){let t=e?.preloadStreamDiffs;typeof t==`function`&&(yield t()),Re=!0}).finally(()=>{ze=null}),ze)})}(Be),de(),Be}catch{return null}});try{return yield Ve}finally{Ve=null}})}var Ue=Object.defineProperty,We=Object.defineProperties,C=Object.getOwnPropertyDescriptors,w=Object.getOwnPropertySymbols,Ge=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable,Ke=(e,t,n)=>t in e?Ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,E=(e,t)=>{for(var n in t||={})Ge.call(t,n)&&Ke(e,n,t[n]);if(w)for(var n of w(t))T.call(t,n)&&Ke(e,n,t[n]);return e},qe=(e,t)=>We(e,C(t)),D=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())}),O={class:`html-preview-frame__header`},Je={class:`html-preview-frame__title`},Ye={class:`html-preview-frame__label`},k=[`sandbox`,`srcdoc`],Xe=Ae(c({__name:`HtmlPreviewFrame`,props:{code:{},isDark:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},onClose:{type:Function},title:{}},setup(e){let t=e,{t:r}=Me(),a=g(()=>{let e=t.code||``,n=e.trim().toLowerCase();return n.startsWith(`<!doctype`)||n.startsWith(`<html`)||n.startsWith(`<body`)?e:`<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <style>\n html, body {\n margin: 0;\n padding: 0;\n height: 100%;\n background-color: ${t.isDark?`#020617`:`#ffffff`};\n color: ${t.isDark?`#e5e7eb`:`#020617`};\n }\n body {\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Text', ui-sans-serif, sans-serif;\n }\n </style>\n </head>\n <body>\n ${e}\n </body>\n</html>`}),o=g(()=>{return e=t.htmlPreviewSandbox,n=t.htmlPreviewAllowScripts,typeof e==`string`?e:e===void 0&&!0===n?`allow-scripts`:``;var e,n});function c(e){var n;e.key!==`Escape`&&e.key!==`Esc`||(n=t.onClose)==null||n.call(t)}return n(()=>{typeof window<`u`&&window.addEventListener(`keydown`,c)}),i(()=>{typeof window<`u`&&window.removeEventListener(`keydown`,c)}),(e,n)=>(s(),d(v,{to:`body`},[h(`div`,{class:f([`markstream-vue`,{dark:t.isDark}])},[h(`div`,{class:`html-preview-frame__backdrop`,onClick:n[2]||=e=>t.onClose?.call(t)},[h(`div`,{class:`html-preview-frame`,onClick:n[1]||=m(()=>{},[`stop`])},[h(`div`,O,[h(`div`,Je,[n[3]||=h(`span`,{class:`html-preview-frame__dot`},null,-1),h(`span`,Ye,ee(t.title||te(r)(`common.preview`)||`Preview`),1)]),h(`button`,{type:`button`,class:`html-preview-frame__close`,onClick:n[0]||=e=>t.onClose?.call(t)},` × `)]),h(`iframe`,{class:`html-preview-frame__iframe`,sandbox:o.value,referrerpolicy:`no-referrer`,srcdoc:a.value},null,8,k)])])],2)]))}}),[[`__scopeId`,`data-v-24e66176`]]),Ze=[`data-markstream-enhanced`,`data-markstream-enhancement-state`,`data-markstream-code-block-state`,`data-markstream-pending`,`data-markstream-viewport-pending`],Qe={class:`code-header-main`},$e=[`innerHTML`],et={class:`code-header-copy`},tt={class:`code-header-title`},nt={key:0,class:`code-header-caption`},rt=[`data-markstream-host-hidden`],A=Ae(c({__name:`CodeBlockNode`,props:{node:{},codeBlockOptions:{},clipboardWriter:{},showLineNumbers:{type:Boolean,default:void 0},isDark:{type:Boolean,default:!1},loading:{type:Boolean,default:!0},stream:{type:Boolean,default:!0},theme:{},darkTheme:{default:void 0},lightTheme:{default:void 0},isShowPreview:{type:Boolean,default:!0},enableFontSizeControl:{type:Boolean,default:!0},minWidth:{default:void 0},maxWidth:{default:void 0},themes:{},showPreviewButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},showTooltips:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},customId:{},showHeader:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},estimatedHeightPx:{},estimatedContentHeightPx:{},estimatedDiffInline:{type:Boolean}},emits:[`previewCode`,`copy`],setup(c,{emit:m}){let v=c,de=m,Ae=g(()=>v.showLineNumbers??!0!==v.codeBlockOptions?.disableLineNumbers),Le=a(),S=ne(fe,null),Re=ne(`markstreamHostScrollManaged`,null),ze=ne(Se,void 0),Be=g(()=>ve(v,Le)),Ve=t(),Ue=g(()=>{let e=Ve?.vnode.props;return!(!e||!e.onPreviewCode&&!e[`onPreview-code`])}),{t:We}=Me(),C=b(null),w=b(null),Ge=b(!1),T=b(Hr(v.node.language,v.node.code,Vr())),Ke=g(()=>me(T.value)),O=g(()=>Ke.value===`plaintext`?`text`:Ke.value),Je=g(()=>Ke.value===`plaintext`),Ye=b(!1),k=b(!1),A=b(!1),j=b(!1),M=b(!1),it=b(!1),N=!1,at=!1,ot=null,st=null,ct=null,lt=0,ut=!1,dt=``,ft=b(null),pt=0,mt=!1,ht=Te(),gt=ce(),_t=ye(),vt=ie(null),P=b(typeof window>`u`||!_t.value),yt=t()?.vnode.el?.textContent??``,bt=typeof window<`u`&&String(v.node.code??``).length>0&&yt.includes(String(v.node.code)),xt=b(!bt);n(()=>{xt.value=!0}),typeof window<`u`&&y([()=>w.value,_t],([e,t],n,r)=>{var i;if((i=vt.value)==null||i.destroy(),vt.value=null,!t||P.value)return void(P.value=!0);if(!e)return void(P.value=!1);let a=!0,o=gt?.value.heavyBlockMargin??gt?.value.rootMargin??`0px`,s=ht(e,{rootMargin:o,allowIdle:!1});vt.value=s,P.value=P.value||s.isVisible.value,s.whenVisible.then(()=>{a&&vt.value===s&&(P.value=!0)}).catch(()=>{}),r(()=>{a=!1,s.destroy(),vt.value===s&&(vt.value=null)})},{immediate:!0}),o(()=>{var e;N=!0,function(){let e=dt;S&&e&&(dt=``,S.markSettled(e))}(),(e=vt.value)==null||e.destroy(),vt.value=null});let F=null,St=null,Ct=()=>{},wt=()=>{},Tt=()=>{},Et=()=>{},Dt=()=>null,I=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),L=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),Ot=()=>{},kt=()=>{},At=()=>{},jt=null,R=null,Mt=null,Nt=null,Pt=()=>String(v.node.language??`plaintext`),Ft=()=>D(null,null,function*(){}),It=!1,Lt=null,Rt=[],zt=[],Bt=null,Vt=null,z=g(()=>Oe(v.node)),Ht=b({removed:0,added:0}),Ut=g(()=>`-${Ht.value.removed} +${Ht.value.added}`);function Wt(e,t){return{original:e,updated:t}}function Gt(e){return String(e??``).replace(/\r\n$|\n$|\r$/,``)}function Kt(e){return String(e?.message??e).includes(`no diff result available`)}function qt(){if(!$())try{let e=At();e&&typeof e.catch==`function`&&e.catch(e=>{Kt(e)})}catch(e){Kt(e)}}let Jt=g(()=>{let e=E({},v.codeBlockOptions||{});for(let t of[`theme`,`themes`,`themeType`,`language`,`languages`,`stream`,`disableFileHeader`,`onThemeChange`,`renderCustomHeader`,`renderHeaderMetadata`,`renderHeaderPrefix`,`maxHeight`,`padding`,`tabSize`])delete e[t];if(!z.value)return e;let t=e.parseDiffOptions&&typeof e.parseDiffOptions==`object`?e.parseDiffOptions:{},n={diffStyle:`split`,expandUnchanged:!1,collapsedContextThreshold:5,hunkSeparators:`line-info`,parseDiffOptions:{context:2}};return qe(E(E({},n),e),{parseDiffOptions:E(E({},n.parseDiffOptions),t)})}),Yt=g(()=>{return(v.theme===void 0?!fi(v.darkTheme,v.lightTheme):(e=v.theme)&&typeof e==`object`&&`light`in e&&`dark`in e)?!!v.isDark:function(e){let t=di(e)??``;return Ce(t,!0===v.isDark)}(pi());var e}),Xt=g(()=>(z.value,Yt.value?`dark`:`light`)),Zt=g(()=>z.value?Xt.value===`dark`:Yt.value),B=g(()=>ke({darkTheme:v.darkTheme,isDark:v.isDark,lightTheme:v.lightTheme,theme:v.theme,themes:v.themes})),Qt=g(()=>z.value?`diff`:`single`),$t=b(Qt.value),V=b(!1),H=b(!1),en=b(!1),U=b(!1),tn=b(null),nn=b(0),rn=b(0),an=b(!1),on=null,sn=!1,cn=null,ln=!1,un=g(()=>!!z.value&&Jt.value?.diffStyle===`unified`),dn=g(()=>De(Jt.value));function fn(e){return!0===Re?.value||!!e&&(!!e.closest(`[data-markstream-virtual-timeline="1"], .markstream-virtual-timeline`)||!!e.closest(`.vue-recycle-scroller, [data-virtualizer], [data-virtual-scroll-root]`))}let pn=g(()=>fn(w.value)),mn=g(()=>!(V.value||!U.value&&H.value)),hn=g(()=>mn.value),gn=g(()=>mn.value&&!en.value),_n=g(()=>!V.value&&!U.value&&mn.value),vn=g(()=>H.value&&!V.value?`ready`:U.value?`fallback`:`pending`),yn=b(!1),W=g(()=>Gt(v.node.code)),bn=g(()=>z.value?!0===v.node.diff?v.node:qe(E({},v.node),{diff:!0}):W.value===v.node.code?v.node:qe(E({},v.node),{code:W.value}));function xn(e){let t=e.detectLanguage;typeof t==`function`&&(Pt=t),Vt=e,Bt=gi();let n=e.createCodeBlockRuntime(Bt);return!!n&&(F=n.createEditor||F,St=n.createDiffEditor||St,Ct=n.updateCode||Ct,wt=n.updateDiff||wt,Tt=n.finalizeCode||Tt,Et=n.finalizeDiff||Et,Dt=n.getEditor||Dt,I=n.getEditorView||I,L=n.getDiffEditorView||L,Ot=n.cleanupEditor||Ot,kt=n.safeClean||n.cleanupEditor||kt,At=n.refreshDiffPresentation||At,Ft=n.setTheme||Ft,jt=n.whenVisualReady||null,it.value=!0,!0)}let G=b(typeof v.codeBlockOptions?.fontSize==`number`?v.codeBlockOptions.fontSize:NaN),K=b(G.value),Sn=b(null),Cn=b(null),wn=b(null),Tn=b(null),En=g(()=>{let e=G.value,t=K.value;return typeof e==`number`&&Number.isFinite(e)&&e>0&&typeof t==`number`&&Number.isFinite(t)&&t>0}),Dn=g(()=>{let e=v.codeBlockOptions?.fontSize;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e;let t=K.value;return typeof t==`number`&&Number.isFinite(t)&&t>0?t:12}),On=g(()=>{let e=v.codeBlockOptions?.lineHeight;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:Dn.value===12?18:Math.max(12,Math.round(1.5*Dn.value))}),kn=g(()=>On.value),An=g(()=>{let e=v.codeBlockOptions?.tabSize;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:4}),jn=g(()=>{let e=v.codeBlockOptions?.padding,t=typeof e==`number`&&Number.isFinite(e)&&e>=0?e:8;return{top:t,bottom:t}}),Mn=g(()=>qe(E({},xe(v.codeBlockOptions)),{fontSize:Dn.value,lineHeight:kn.value,maxHeight:zr(),padding:jn.value.top,paddingBottom:jn.value.bottom,tabSize:An.value})),Nn=g(()=>{let e=v.estimatedContentHeightPx;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:null});function Pn(e){if(e==null)return null;let t=Math.ceil(e);return!Number.isFinite(t)||t<=0?null:Math.min(t,Math.ceil(zr()))}function Fn(){return!z.value&&!1!==v.stream&&!1!==v.loading}let In=b(Fn());function Ln(){return Fn()||In.value}let Rn=g(()=>z.value?null:Nn.value==null||Ln()?Math.ceil((e=>{let t=String(e??``);if(!t)return 1;let n=1;for(let e=0;e<t.length;e++)t[e]===`
2
2
  `?n++:t[e]===`\r`&&(n++,t[e+1]===`
3
3
  `&&e++);return n})(W.value)*kn.value+1):null),zn=g(()=>{if(z.value)return null;let e=Nn.value;return e==null||Ln()?Pn(Rn.value):Pn(e)}),Bn=g(()=>{let e=v.estimatedHeightPx;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:null}),Vn=b(null);function Hn(){let e=Vn.value;return typeof e==`number`&&Number.isFinite(e)&&e>0?Math.round(e):null}let Un=g(()=>Hn()??(!z.value&&an.value?null:mn.value||!H.value?zn.value:null));function Wn(e){let t=e?`hsl(152 42% 60%)`:`var(--diff-added-fg)`,n=e?`hsl(0 58% 58%)`:`var(--diff-removed-fg)`,r=e?`color-mix(in lab, #121212 80%, #4d9375)`:`color-mix(in lab, #ffffff 88%, #1e754f)`,i=e?`color-mix(in lab, #121212 80%, #cb7676)`:`color-mix(in lab, #ffffff 88%, #ab5959)`;return{"--markstream-diff-line-number-bg":`var(--markstream-diff-editor-bg)`,"--markstream-diff-added-fg":t,"--markstream-diff-removed-fg":n,"--markstream-diff-added-line":r,"--markstream-diff-removed-line":i,"--markstream-diff-added-line-fill":r,"--markstream-diff-added-number-fill":e?`color-mix(in lab, #121212 85%, #4d9375)`:`color-mix(in lab, #ffffff 91%, #1e754f)`,"--markstream-diff-removed-line-fill":i,"--markstream-diff-removed-number-fill":e?`color-mix(in lab, #121212 85%, #cb7676)`:`color-mix(in lab, #ffffff 91%, #ab5959)`,"--markstream-diff-added-gutter":`linear-gradient(90deg, ${t} 0 4px, transparent 4px 100%)`,"--markstream-diff-removed-gutter":`linear-gradient(90deg, ${n} 0 4px, transparent 4px 100%)`,"--markstream-diff-added-inline":e?`hsl(152 42% 60% / 0.28)`:`var(--diff-added-inline-bg)`,"--markstream-diff-removed-inline":e?`hsl(0 58% 58% / 0.28)`:`var(--diff-removed-inline-bg)`}}let Gn=g(()=>{let e=Pn(Nn.value),t=Pn(Rn.value),n=Ln(),r=E({},z.value||e==null||n?z.value||t==null?{}:{minHeight:`${t}px`}:{height:`${e}px`,minHeight:`${e}px`});if(r[`--markstream-code-fallback-bg`]=B.value.background,r[`--markstream-code-fallback-fg`]=B.value.foreground,B.value.builtin&&(r[`--markstream-code-theme-bg`]=B.value.background,r[`--markstream-code-theme-fg`]=B.value.foreground,r[`--markstream-code-theme-line-number`]=B.value.lineNumber),r[`--markstream-pre-line-number-top`]=`${jn.value.top}px`,r[`--markstream-pre-line-number-left`]=`0px`,r[`--markstream-pre-line-number-padding-left`]=`2ch`,r[`--markstream-pre-line-number-padding-right`]=`1ch`,r[`--markstream-pre-line-number-separator-width`]=`2px`,z.value){r[`--markstream-pre-diff-line-height`]=`${kn.value}px`,r[`--markstream-pre-diff-pane-bottom-padding`]=(un.value,`0px`);let e=Tn.value;e!=null&&e>0&&(r.height=`${e}px`,r.minHeight=`${e}px`,r.maxHeight=`${e}px`),Object.assign(r,Wn(Zt.value))}return r}),Kn=g(()=>Un.value!=null&&(!H.value||Hn()!=null)),qn=g(()=>{let e=Un.value;if(e==null)return null;if(z.value)return Math.ceil(e);let t=Bn.value,n=Nn.value;if(t==null||n==null)return Math.ceil(e);let r=Math.max(0,Math.ceil(t)-Math.ceil(n));return Math.ceil(e+r)}),Jn=g(()=>{if(z.value&&mn.value)return{};let e=Un.value;return Kn.value&&e!=null?{minHeight:`${e}px`}:{}});function Yn(){Vn.value=null}function Xn(){var e,t,n,r;let i=w.value?.querySelector(`pre.code-pre-fallback`),a=L(),o=i?.scrollTop??0;(t=(e=(a?.getOriginalEditor)?.call(a))?.setScrollTop)==null||t.call(e,o),(r=(n=(a?.getModifiedEditor)?.call(a))?.setScrollTop)==null||r.call(n,o)}function Zn(){return D(this,null,function*(){return z.value?(vr(),er(),X(!0),Xn(),Z(),en.value=!0,yield _(),X(!0),yield q(),X(!0),gr(),er(),!!(yield function(){return D(this,null,function*(){if(!z.value)return!0;for(let e=0;e<4;e++){let e=er();X(!0),Qn(e),$n(e),yield _(),yield q();let t=w.value?.querySelector(`pre.code-pre-fallback`);if(!t)return!1;if(e==null)return jr();let n=t.getBoundingClientRect().height;if(n>0&&Math.abs(n-e)<=2)return!0}return!1})}())&&(H.value=!0,yield _(),er(),X(!0),gr(),Z(),x(()=>{N||x(()=>{N||(function(){let e=w.value?.querySelector(`.code-block-shell-content`),t=w.value?.querySelector(`.code-editor-layer`);e&&t&&(t.style.removeProperty(`height`),t.style.removeProperty(`min-height`),e.style.removeProperty(`height`),e.style.removeProperty(`min-height`))}(),Q(!0))})}),Q(),!0)):!(jt&&!(yield jt())||(en.value=!0,yield _(),X(!0),H.value=!0,yield _(),Q(),0))})}function Qn(e){if(!z.value)return;let t=C.value,n=w.value?.querySelector(`pre.code-pre-fallback`);if(!t||!n)return;let r=e??Number.parseFloat(t.style.height||``);if(!Number.isFinite(r)||r<=0)return;let i=Math.ceil(r),a=`${i}px`;Tn.value=i;let o=w.value;o&&(o.dataset.markstreamDiffHandoffHeight=a),n.dataset.markstreamDiffHandoffHeight=a,n.style.setProperty(`height`,a),n.style.setProperty(`min-height`,a)}function $n(e){if(!z.value)return;let t=w.value?.querySelector(`.code-block-shell-content`),n=w.value?.querySelector(`.code-editor-layer`);if(!t||!n)return;let r=typeof e==`number`&&Number.isFinite(e)&&e>0?Math.ceil(e):Number.parseFloat(C.value?.style.height||``);if(!Number.isFinite(r)||r<=0)return;let i=`${r}px`;n.style.height=i,n.style.minHeight=i,t.style.height=i,t.style.minHeight=i}function er(){let e=C.value;if(e&&jr(e)){Z();let t=mr(e);if(t!=null&&t>0){let n=Math.ceil(t),r=Math.ceil(zr()),i=Math.min(n,r),a=`${i}px`;return e.style.height=a,e.style.minHeight=`0px`,e.style.maxHeight=`${r}px`,e.style.overflow=n>r+1?`auto`:`hidden`,mn.value&&(Tn.value=i,Qn(i)),Dr(),i}return Y({preferModelDiffHeight:!0}),Qn(),Dr(),Number.parseFloat(e.style.height||``)||null}return vr()}function tr(e,t=!1,n={}){let r=Math.ceil(e),i=Hn();if(i==null)return r;let a=!0===n.allowBelowEstimatedFloor;return r>=i||a?((t||a)&&M.value&&Yn(),r):i}function q(){return new Promise(e=>{let t=!1,n=null,r=null,i=()=>{t||(t=!0,r!=null&&globalThis.clearTimeout(r),n!=null&&Ie(n),e())};r=globalThis.setTimeout(i,50),n=x(i)})}function nr(){try{let e=C.value;if(!e)return null;let t=e.querySelector(`.stream-diffs-shell .stream-diffs-surface`)??e.querySelector(`.stream-diffs-shell`);if(t){let e=Math.ceil(t.getBoundingClientRect().height);if(e>0)return e}}catch{}return null}function rr(){var e;try{let t=z.value?((e=L())?.getModifiedEditor)?.call(e)??L():I(),n=Dt()?.EditorOption?.fontInfo;if(t&&n!=null){let e=t.getOption?.call(t,n)?.fontSize;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e}}catch{}try{let e=C.value;if(e){let t=e.querySelector(`.stream-diffs-shell .stream-diffs-surface`)??e.querySelector(`.stream-diffs-shell`);if(t)try{if(typeof window<`u`&&typeof window.getComputedStyle==`function`){let e=window.getComputedStyle(t).fontSize,n=e&&e.match(/^(\d+(?:\.\d+)?)/);if(n)return Number.parseFloat(n[1])}}catch{}}}catch{}return null}function ir(e){try{let t=Dt()?.EditorOption?.lineHeight;if(t!=null){let n=(e?.getOption)?.call(e,t);if(typeof n==`number`&&n>0)return n}}catch{}let t=nr();if(t&&t>0)return t;let n=Number.isFinite(K.value)&&K.value>0?K.value:14;return Math.max(12,Math.round(1.35*n))}function ar(){let e=v.codeBlockOptions?.padding;return typeof e==`number`&&Number.isFinite(e)?2*Math.max(0,e):z.value?24:0}function or(e){return!!Je.value||!!e&&($(e)||jt!=null)}function sr(){z.value?Ht.value=Ee(String(v.node.originalCode??``),String(v.node.updatedCode??``)):Ht.value={removed:0,added:0}}function cr(){if(Number.isFinite(K.value)&&K.value>0&&Number.isFinite(G.value))return K.value;if(typeof v.codeBlockOptions?.fontSize==`number`)return G.value=v.codeBlockOptions.fontSize,K.value=v.codeBlockOptions.fontSize,v.codeBlockOptions.fontSize;let e=rr();return e&&e>0?(G.value=e,K.value=e,e):(G.value=12,K.value=12,12)}function lr(){let e=cr(),t=Math.min(36,e+1);K.value=t}function ur(){let e=cr(),t=Math.max(10,e-1);K.value=t}function dr(){cr(),Number.isFinite(G.value)&&(K.value=G.value)}function fr(){var e,t,n,r,i;try{let a=z.value?L():null,o=z.value?a:I();if(!o)return null;if(a?.getOriginalEditor&&a?.getModifiedEditor){let i=a.getOriginalEditor?.call(a),o=a.getModifiedEditor?.call(a);(e=i?.layout)==null||e.call(i),(t=o?.layout)==null||t.call(o);let s=(i?.getContentHeight)?.call(i)||0,c=(o?.getContentHeight)?.call(o)||0,l=Math.max(s,c);if(l>0)return Math.ceil(l);let u=((n=(i?.getModel)?.call(i))?.getLineCount)?.call(n)||1,d=((r=(o?.getModel)?.call(o))?.getLineCount)?.call(r)||1,f=Math.max(u,d),p=Math.max(ir(i),ir(o)),ee=ar();return Math.ceil(f*p+ee+0)}if(o?.getContentHeight){(i=o?.layout)==null||i.call(o);let e=o.getContentHeight();if(e>0)return z.value||(an.value=!0),Math.ceil(e)}let s=(o?.getModel)?.call(o),c=1;s&&typeof s.getLineCount==`function`&&(c=s.getLineCount());let l=ir(o);return Math.ceil(c*(l+1.5)+0)}catch{return null}}function pr(){var e;if(z.value)return!1;try{let t=((e=I())?.getContentHeight)?.call(e),n=typeof t==`number`&&Number.isFinite(t)&&t>0;return n&&(an.value=!0),n}catch{return!1}}function mr(e){if(typeof window>`u`)return null;try{if(window.getComputedStyle(e).display===`none`)return null;let t=e.querySelector(`diffs-container`);if(t instanceof HTMLElement){let e=t.getBoundingClientRect();if(e.height>0)return Math.ceil(e.height)}let n=e.querySelector(`.stream-diffs-shell`);if(n){let e=n.getBoundingClientRect();if(e.height>0)return Math.ceil(e.height)}return null}catch{return null}}function hr(e){let t=String(e??``).trim(),n=t.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i)?.[1];if(n){let e=n.length===3?n.split(``).map(e=>`${e}${e}`).join(``):n;return .2126*Number.parseInt(e.slice(0,2),16)+.7152*Number.parseInt(e.slice(2,4),16)+.0722*Number.parseInt(e.slice(4,6),16)}let r=t.match(/\d+(?:\.\d+)?/g);if(!r||r.length<3)return null;let[i,a,o]=r.slice(0,3).map(Number);return .2126*i+.7152*a+.0722*o}function gr(){var e;if(_r())return;let t=rr();t&&t>0&&(Sn.value=t,K.value=t,G.value=t);try{let t=ir(z.value?((e=L())?.getModifiedEditor)?.call(e)??L():I());t&&t>0&&(Cn.value=t)}catch{}try{let e=nr();e&&e>0&&(Cn.value=e)}catch{}}function _r(){return z.value&&hn.value}function vr(){if(!mn.value)return null;let e=C.value,t=w.value?.querySelector(`pre.code-pre-fallback`);if(!e||!t)return null;let n=Math.ceil(t.getBoundingClientRect().height),r=z.value?mr(e):null,i=Math.max(n,r!=null&&r>0?Math.ceil(r):0),a=Math.ceil(zr()),o=Math.min(i,a);return!Number.isFinite(o)||o<=0?null:(z.value&&o>n&&(Tn.value=o),e.style.height=`${o}px`,e.style.minHeight=`${o}px`,e.style.maxHeight=`${a}px`,e.style.overflow=i>a+1?`auto`:`hidden`,o)}function yr(){let e=C.value,t=w.value;if(!e||!t)return;let n=e;n.style.setProperty(`--markstream-diff-metadata-bg`,B.value.background),n.style.setProperty(`--markstream-diff-metadata-fg`,B.value.lineNumber),n.style.setProperty(`--diffs-tab-size`,String(An.value)),n.style.setProperty(`--diffs-scrollbar-gutter-override`,`0px`),typeof v.codeBlockOptions?.padding==`number`?n.style.setProperty(`--diffs-gap-block`,`${jn.value.top}px`):n.style.removeProperty(`--diffs-gap-block`);let r=e.querySelector(`.stream-diffs-shell`)||e,i=r,a=r,o=null,s=null,c=null;try{typeof window<`u`&&typeof window.getComputedStyle==`function`&&(o=window.getComputedStyle(r),s=i===r?o:window.getComputedStyle(i),c=a===r?o:window.getComputedStyle(a))}catch{o=null,s=null,c=null}let l=String(o?.getPropertyValue(`--vscode-editor-foreground`)??``).trim(),u=String(o?.getPropertyValue(`--vscode-editor-background`)??``).trim(),d=String(o?.getPropertyValue(`--vscode-editor-selectionBackground`)??o?.getPropertyValue(`--vscode-editor-hoverHighlightBackground`)??``).trim(),f=l||String(c?.color??o?.color??``).trim(),p=u||String(s?.backgroundColor??o?.backgroundColor??``).trim(),ee=function(){var e;try{let t=z.value?((e=L())?.getModifiedEditor)?.call(e)??L():I(),n=Dt()?.EditorOption?.fontInfo;if(t&&n!=null){let e=t.getOption?.call(t,n)?.typicalHalfwidthCharacterWidth;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e}}catch{}return null}();if(ee!=null&&(wn.value=ee),z.value){let e=(e,r)=>{r?(t.style.setProperty(e,r),n.style.setProperty(e,r)):(t.style.removeProperty(e),n.style.removeProperty(e))};for(let[n,r]of Object.entries(Wn(t.classList.contains(`is-dark`))))e(n,r);f?(t.style.setProperty(`--markstream-diff-editor-fg`,f),n.style.setProperty(`--vscode-editor-foreground`,f)):(t.style.removeProperty(`--markstream-diff-editor-fg`),n.style.removeProperty(`--vscode-editor-foreground`)),p?(t.style.setProperty(`--markstream-diff-editor-bg`,p),t.style.setProperty(`--markstream-diff-panel-bg`,p),t.style.setProperty(`--markstream-diff-panel-bg-soft`,p),t.style.setProperty(`--markstream-diff-panel-bg-strong`,p),n.style.setProperty(`--vscode-editor-background`,p),n.style.backgroundColor=p):(t.style.removeProperty(`--markstream-diff-editor-bg`),t.style.removeProperty(`--markstream-diff-panel-bg`),t.style.removeProperty(`--markstream-diff-panel-bg-soft`),t.style.removeProperty(`--markstream-diff-panel-bg-strong`),n.style.removeProperty(`--vscode-editor-background`),n.style.backgroundColor=``),d?n.style.setProperty(`--vscode-editor-selectionBackground`,d):n.style.removeProperty(`--vscode-editor-selectionBackground`)}else{if(function(e,t,n){if(!Je.value)return!1;let r=hr(e),i=hr(t);return n?r!=null&&r>170||i!=null&&i<110:r!=null&&r<85||i!=null&&i>190}(p,f,t.classList.contains(`is-dark`)))return n.style.removeProperty(`--vscode-editor-foreground`),n.style.removeProperty(`--vscode-editor-background`),void n.style.removeProperty(`--vscode-editor-selectionBackground`);f&&n.style.setProperty(`--vscode-editor-foreground`,f),p&&n.style.setProperty(`--vscode-editor-background`,p),d&&n.style.setProperty(`--vscode-editor-selectionBackground`,d)}}y(()=>[v.stream,v.loading,v.node.loading,z.value],([e,t,n,r])=>{r||!1===e||!1===t||In.value?(r||!1===e)&&In.value&&(In.value=!1):(In.value=!0,Yn())},{immediate:!0});let br=0,xr=0,Sr=/auto|scroll|overlay/i;function J(e,t,n){if(typeof window>`u`||z.value||function(e){return pn.value||fn(e)}(e))return;let r=Math.ceil(n)-Math.ceil(t);if(Math.abs(r)<=1)return;let i=function(e){if(typeof window>`u`)return null;let t=e?.ownerDocument??document,n=t.scrollingElement||t.documentElement||t.body,r=e?.parentElement??null;for(;r&&r!==t.body&&r!==n;){let e=window.getComputedStyle(r),t=(e.overflowY||``).toLowerCase(),n=(e.overflow||``).toLowerCase();if(Sr.test(t)||Sr.test(n))return r;r=r.parentElement}return n}(e);if(!i)return;let a=e.ownerDocument??document,o=i===a.body||i===a.documentElement||i===a.scrollingElement,s=o?0:i.getBoundingClientRect().top;e.getBoundingClientRect().top-s>=0||(o&&typeof window.scrollBy==`function`?window.scrollBy(0,r):i.scrollTop+=r)}function Cr(){try{let e=C.value;if(!e)return;let t=e.getBoundingClientRect().height,n=fr();if(n!=null&&n>0){let r=tr(n,!0,{allowBelowEstimatedFloor:!z.value&&M.value&&pr()}),i=Hn();e.style.minHeight=i==null?`0px`:`${i}px`,e.style.height=`${r}px`,e.style.maxHeight=`none`,e.style.overflow=`visible`,J(e,t,r);return}let r=Hn();r!=null&&(e.style.minHeight=`${r}px`,e.style.height=`${r}px`,e.style.maxHeight=`none`,e.style.overflow=`visible`,J(e,t,r))}catch{}}function wr(){for(var e,t;Rt.length>0;)try{(t=(e=Rt.pop())?.dispose)==null||t.call(e)}catch{}ot!=null&&(Ie(ot),ot=null),st!=null&&(Ie(st),st=null),ct!=null&&(Ie(ct),ct=null),lt=0,ut=!1}function Tr(){for(var e;zt.length>0;)try{(e=zt.pop())==null||e()}catch{}}function Y(e=!1){k.value||(Ye.value?Cr():function(e={}){try{let t=C.value;if(!t)return;let n=t.getBoundingClientRect().height,r=Math.ceil(n||0),i=zr(),a=r,o=Number.parseFloat(t.style.height||``),s=a>0?a:Number.isFinite(o)&&o>0?Math.ceil(o):0,c=z.value?function(){var e,t;if($())return null;try{let n=L(),r=(n?.getOriginalEditor)?.call(n),i=(n?.getModifiedEditor)?.call(n);if(!r||!i)return null;let a=((e=r.getModel?.call(r))?.getLineCount)?.call(e)||1,o=((t=i.getModel?.call(i))?.getLineCount)?.call(t)||1,s=Math.max(a,o),c=Math.max(ir(r),ir(i)),l=ar(),u=Math.max(r.getContentHeight?.call(r)??0,i.getContentHeight?.call(i)??0);return Math.ceil(Math.max(u,s*c+l+0))}catch{return null}}():null,l=z.value&&jr(t);if(pt>0&&(pt--,ft.value!=null))return void J(t,n,Or(t,ft.value,i,{preserveScrollableOverflow:Ar(t)}));if(z.value&&!l&&mn.value){let e=vr();if(e!=null){let r=Or(t,e,i,{allowBelowEstimatedFloor:!0});X(!0),J(t,n,r);return}}let u=z.value&&!0===e.preferModelDiffHeight,d=z.value?mr(t):null,f=!z.value&&M.value&&pr(),p=z.value&&!1!==v.loading&&(d!=null||c!=null&&a>0&&c<a-1),ee=c!=null,m;if(z.value){if(u){let e=c!=null&&!1===v.loading&&s>0&&c<s-1;m=!1===v.loading&&d!=null?c==null?d:Math.max(d,c):e?c:d!=null&&c!=null?Math.max(d,c,!1===v.loading?0:s):Math.max(d??0,c??0,!1===v.loading?0:s)||null}else m=un.value&&d!=null||d!=null?ee?Math.max(d,c):d:z.value&&!1!==v.loading?c!=null&&s>0&&c<s-1?c:s>0?s:null:c}else m=fr();if(z.value&&m!=null&&s>0&&(!1!==v.loading||!0===e.holdCurrentDiffHeight)&&(m=Math.max(m,s)),m!=null&&m>0)return void J(t,n,Or(t,m,i,{clearEstimatedFloor:!0,allowBelowEstimatedFloor:f||p,preserveScrollableOverflow:Ar(t),renderedStreamingDiffHeight:d}));if(ft.value!=null)return void J(t,n,Or(t,ft.value,i,{preserveScrollableOverflow:Ar(t)}));let h=z.value&&!1!==v.loading?a:Math.max(a,c!=null&&c>0?c:0);if(h>0)return void J(t,n,Or(t,h,i));let g=Hn();if(!(g==null||z.value&&!1!==v.loading&&l))return void J(t,n,Or(t,g,i));let te=Number.parseFloat(t.style.height);!Number.isNaN(te)&&te>0?J(t,n,Or(t,te,i)):z.value||J(t,n,Or(t,i,i))}catch{}}(typeof e==`object`?e:{}))}function Er(){br=0,xr=0}function X(e=!1){if(k.value)return;let t=C.value;if(!t)return;let n=z.value?L():I();if(n&&typeof n.layout==`function`)try{let r=t.getBoundingClientRect?.call(t),i=Math.ceil((r?.width??0)||t.clientWidth||0),a=Math.ceil((r?.height??0)||t.clientHeight||Number.parseFloat(t.style.height||``)||0);if(i>0&&a>0){if(!e&&i===br&&a===xr)return;br=i,xr=a,n.layout({width:i,height:a})}else Er(),n.layout()}catch{}}function Z(){Tr()}function Q(e=!1){if(N||ot!=null)return;let t=()=>{N||(Z(),Y(e),X())};ot=x(()=>{ot=null,t(),st=x(()=>{st=null,t()})}),Dr()}function Dr(e=!1){if(!z.value||N||!e&&!1===v.loading||(ut||=e,lt=Math.max(lt,e?18:6),ct!=null))return;let t=()=>{if(ct=null,!z.value||N||lt<=0||!ut&&!1===v.loading)return lt=0,void(ut=!1);lt--,Z(),Y({preferModelDiffHeight:!0,holdCurrentDiffHeight:ut}),X(),lt>0?ct=x(t):ut=!1};ct=x(t)}function Or(e,t,n,r={}){var i;let a=z.value&&!1!==v.loading,o=`renderedStreamingDiffHeight`in r?a&&(i=r.renderedStreamingDiffHeight)!=null?i:null:a?mr(e):null,s=o!=null&&o>t+1?o:t,c=Math.min(s,n),l=!0===r.allowBelowEstimatedFloor,u=tr(c,!0===r.clearEstimatedFloor,{allowBelowEstimatedFloor:l}),d=Hn();e.style.minHeight=d==null||l?`0px`:`${Math.min(d,Math.ceil(n))}px`,e.style.height=`${u}px`,e.style.maxHeight=`${Math.ceil(n)}px`;let f=!0===r.preserveScrollableOverflow||s>n+1||kr(e,u);return e.style.overflow=f?`auto`:`hidden`,u}function kr(e,t=0){let n=Math.ceil(e.getBoundingClientRect?.call(e).height||0),r=Math.max(t,e.clientHeight||0,n);return r>0&&e.scrollHeight>r+1}function Ar(e){return mt||kr(e,ft.value??0)}function jr(e=C.value){return $(e)}function Mr(e=C.value){return $(e)}function Nr(){var e;if($())return!0;let t=((e=I())?.getModel)?.call(e);return typeof t?.getValue==`function`&&t.getValue()===W.value}function $(e=C.value){return!!e?.querySelector(`diffs-container`)}function Pr(){return!1!==v.loading||H.value}function Fr(){let e=L();return typeof e?.getOriginalEditor==`function`||typeof e?.getModifiedEditor==`function`||typeof e?.getLineChanges==`function`}function Ir(){return D(this,null,function*(){if(!z.value)return!0;for(let e=0;e<30;e++){if(N)return!1;if($())return yield _(),yield q(),!N&&$();yield _(),yield q()}return!1})}let Lr=``;function Rr(e,t,n){return D(this,null,function*(){let r=`${e}\0${t}\0${n}`;if(Lr!==r){try{yield wt(e,t,n),Lr=r;return}catch(e){if(!Kt(e))throw e}if(yield _(),yield q(),!N&&z.value)try{yield wt(e,t,n),Lr=r}catch(e){if(!Kt(e))throw e}}})}function zr(){return v.codeBlockOptions?.maxHeight??500}let Br=g(()=>v.isShowPreview&&(T.value===`html`||T.value===`svg`));function Vr(){return typeof v.node.loading==`boolean`?v.node.loading:!0===v.loading}function Hr(e,t,n){return!n||function(){if(!Vr())return!0;let e=String(v.node.raw??``),t=e.split(/\r\n|\n|\r/,1)[0]?.trimStart()??``;return!/^(?:`{3,}|~{3,})/.test(t)||/\r\n|\n|\r/.test(e)}()&&String(t??``)?ue(String(e??``)):`plain`}function Ur(){return Vr()}let Wr=null,Gr=!1,Kr=0;function qr(){Wr=null,Kr++}function Jr(){return D(this,arguments,function*(e=Kr){if(!Gr){Gr=!0;try{for(;Wr&&!N&&!z.value&&e===Kr;){let e=Wr;Wr=null;try{yield Promise.resolve(Ct(e.code,e.language)),yield _(),N||z.value||(Y(!1),X())}catch{}}}finally{Gr=!1,!Wr||N||z.value||Jr()}}})}function Yr(e,t){Wr={code:e,language:t},Jr(Kr)}y(()=>[v.node.language,v.node.code,v.node.raw,v.node.loading,v.loading],([e,t,n,r,i])=>{T.value=Hr(e,t,typeof r==`boolean`?r:!0===i)}),y(()=>[v.node.originalCode,v.node.updatedCode,z.value],()=>{x(()=>sr())},{immediate:!0});let Xr=0;y(()=>[v.node.originalCode,v.node.updatedCode,O.value,z.value,v.stream],e=>D(null,[e],function*([,,,e,t]){let n=++Xr;if(!e||Vr()||!1===t&&!A.value)return;if(!1!==t&&F&&!A.value&&C.value)try{yield ci(C.value)}catch{}let r=Mt;if(r&&!j.value){try{yield r}catch{}if(N||!z.value||n!==Xr)return}if(n!==Xr)return;let i=Wt(String(v.node.originalCode??``),String(v.node.updatedCode??``)),a=!1===v.loading;a&&_i();try{if(yield Rr(i.original,i.updated,O.value),N||!z.value||n!==Xr)return;yield _(),X(!0),Z(),Y(!1===v.loading||{preferModelDiffHeight:!0}),X(!0),Q(!0)}catch{return}if(a){if(N||!z.value)return;qt(),Z(),sr(),Q(),Dr(!0)}Ye.value&&x(()=>Cr())})),y(()=>v.node.code,e=>D(null,null,function*(){if(Vr()||!1===v.stream||(T.value||=ue(Pt(e)),z.value))return;let t=Mt;if(t&&!j.value){try{yield t}catch{}if(N||z.value)return}if(F&&!A.value&&C.value)try{yield ci(C.value)}catch{}Yr(Gt(v.node.code),O.value),Ye.value&&x(()=>Cr())}));let Zr=g(()=>{let e=T.value;return e?pe[e]||e.charAt(0).toUpperCase()+e.slice(1):pe[``]||`Plain Text`}),Qr=g(()=>ge(String(v.node.raw??``),Zr.value,z.value)),$r=g(()=>Qr.value.title),ei=g(()=>Qr.value.caption),ti=g(()=>(le.value,Pe(T.value||``,ze))),ni=g(()=>{let e={};e[`--markstream-code-layout-character-width`]=wn.value==null?`1ch`:`${wn.value}px`,e[`--markstream-code-fallback-bg`]=B.value.background,e[`--markstream-code-fallback-fg`]=B.value.foreground,B.value.builtin&&(e[`--markstream-code-theme-bg`]=B.value.background,e[`--markstream-code-theme-fg`]=B.value.foreground,e[`--markstream-code-theme-line-number`]=B.value.lineNumber),e[`--markstream-diff-added-line-fill`]=B.value.diffAddedLine,e[`--markstream-diff-added-number-fill`]=B.value.diffAddedNumber,e[`--markstream-diff-editor-bg`]=B.value.background,e[`--markstream-diff-removed-line-fill`]=B.value.diffRemovedLine,e[`--markstream-diff-removed-number-fill`]=B.value.diffRemovedNumber,e[`--markstream-diff-shell-bg`]=B.value.background,e[`--markstream-pre-resolved-theme-bg`]=B.value.background,e[`--markstream-pre-resolved-theme-fg`]=B.value.foreground,e[`--markstream-pre-resolved-theme-line-number`]=B.value.lineNumber;let t=e=>{if(e!=null)return typeof e==`number`?`${e}px`:String(e)},n=t(v.minWidth),r=t(v.maxWidth);if(n&&(e.minWidth=n),r&&(e.maxWidth=r),Kn.value&&!z.value&&!k.value){let t=qn.value;t!=null&&(e.minHeight=`${t}px`)}return e.color=`var(--markstream-code-fallback-fg, var(--markstream-code-theme-fg, var(--markstream-pre-resolved-theme-fg)))`,e.backgroundColor=`var(--markstream-code-fallback-bg, var(--markstream-code-theme-bg, var(--markstream-pre-resolved-theme-bg)))`,z.value||(e.borderColor=`var(--markstream-code-border-color, var(--code-border))`),e}),ri=g(()=>!1!==v.showTooltips);function ii(){return D(this,null,function*(){let e=v.node.code;try{v.clipboardWriter?yield v.clipboardWriter(e):typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`&&(yield navigator.clipboard.writeText(e)),Ge.value=!0,de(`copy`,e),setTimeout(()=>{Ge.value=!1},1e3)}catch(e){console.error(`复制失败:`,e)}})}function ai(){Ye.value=!Ye.value;let e=z.value?L():I(),t=C.value;e&&t&&(Ye.value?(t.style.maxHeight=`none`,t.style.overflow=`visible`,Y(!0)):(t.style.overflow=`auto`,Y(!0)))}function oi(){var e;if(k.value=!k.value,k.value){if(mt=!1,C.value){let t=Math.ceil((e=C.value).getBoundingClientRect?.call(e).height||0);mt=kr(C.value,t)||C.value.style.overflow===`auto`||C.value.style.overflowY===`auto`,t>0&&(ft.value=t)}}else C.value&&ft.value!=null&&(C.value.style.height=`${ft.value}px`),pt=2,_(()=>{k.value||N||(Y(!0),X(!0))})}function si(){if(!Br.value)return;let e=T.value;if(Ue.value){let t=e===`html`?`text/html`:`image/svg+xml`,n=e===`html`?We(`artifacts.htmlPreviewTitle`)||`HTML Preview`:We(`artifacts.svgPreviewTitle`)||`SVG Preview`;de(`previewCode`,{node:v.node,artifactType:t,artifactTitle:n,id:`temp-${e}-${Date.now()}`})}else e===`html`&&(yn.value=!yn.value)}function ci(e,t={}){if(!F||N||!1===v.stream&&!1!==v.loading||(Ci(),wi())||V.value||C.value!==e||Ur())return null;if(R)return R;if(A.value&&M.value)return Promise.resolve();let n=xi(),r=nn.value,i=!1;A.value=!0,function(){let e=Be.value;S&&e&&dt!==e&&(dt&&S.markSettled(dt),dt=e,S.markPending(e))}();let a=D(null,null,function*(){try{yield function(e){return D(this,null,function*(){var t;if(!F||N)return;at=!1;let n=Qt.value;if(ln=!1,U.value=!1,tn.value=null,j.value=!1,H.value=!1,en.value=!1,Sn.value=null,Cn.value=null,wn.value=null,Tn.value=null,Er(),function(){if(an.value=!1,Ln())return void(Vn.value=null);let e=zn.value;Vn.value=M.value||e==null?null:e}(),wr(),Tr(),function(e){e.replaceChildren()}(e),_i(),yield _e(hi()),N)return;let r=D(null,null,function*(){if(n===`diff`){(function(){if(It||typeof window>`u`)return;It=!0;let e=e=>{Kt(`reason`in e?e.reason:e.error??e.message)&&(e.preventDefault(),e.stopImmediatePropagation())};window.addEventListener(`error`,e,!0),window.addEventListener(`unhandledrejection`,e,!0),Lt=()=>{window.removeEventListener(`error`,e,!0),window.removeEventListener(`unhandledrejection`,e,!0),It=!1,Lt=null}})(),kt();let t=Wt(String(v.node.originalCode??``),String(v.node.updatedCode??``));St?yield St(e,t.original,t.updated,O.value):yield F(e,v.node.code,O.value)}else yield F(e,W.value,O.value);j.value=!0}).finally(()=>{Mt===r&&(Mt=null)});if(Mt=r,yield function(e){return D(this,null,function*(){if(!z.value)return void(yield e);let t,n=!1;for(e.then(()=>{n=!0},e=>{n=!0,t=e});;){if(N)return;if(n){if(t)throw t;return}if(jr()&&Fr())return;yield _(),yield q()}})}(r),N||Qt.value!==n)return;j.value=!0;let i=v.codeBlockOptions?.fontSize;if(typeof i==`number`&&Number.isFinite(i)&&i>0){let e=n===`diff`?L():I();(t=e?.updateOptions)==null||t.call(e,{fontSize:i}),G.value=i,K.value=i}else if(!_r()){let e=rr();e&&e>0?(G.value=e,K.value=e):(G.value=12,K.value=12)}for(gr();at;)if(at=!1,yield mi(),N)return;Ye.value||k.value||Y(!1),M.value=!0,$t.value=n,function(){if(wr(),z.value){let e=L(),t=(e?.getOriginalEditor)?.call(e),n=(e?.getModifiedEditor)?.call(e),r=(e,t)=>{try{let n=e?.[t];if(typeof n!=`function`)return;let r=n.call(e,()=>Q());r&&Rt.push(r)}catch{}};try{let t=(e?.onDidUpdateDiff)?.call(e,()=>{Q(),x(()=>sr())});t&&Rt.push(t)}catch{}r(t,`onDidContentSizeChange`),r(n,`onDidContentSizeChange`);let i=C.value;if(i&&typeof MutationObserver<`u`){let e=`diffs-container,.stream-diffs-shell,.stream-diffs-surface`,t=t=>{let n=t instanceof HTMLElement?t:t.parentElement;return!!(n?.closest)?.call(n,e)},n=t=>{let n=t instanceof HTMLElement?t:t.parentElement;return!!((n?.closest)?.call(n,e)||(n?.querySelector)?.call(n,e))},r=new MutationObserver(e=>{z.value&&Pr()&&e.some(e=>t(e.target)||Array.from(e.addedNodes).some(n)||Array.from(e.removedNodes).some(t))&&(Z(),Y({preferModelDiffHeight:!0}),X(),Dr())});r.observe(i,{attributeFilter:[`class`],attributes:!0,childList:!0,characterData:!0,subtree:!0}),Rt.push({dispose:()=>r.disconnect()})}if(i&&typeof ResizeObserver<`u`){let e=new ResizeObserver(()=>{if(!z.value||(X(),!Pr()))return;let e=mr(i);e!=null&&(Math.ceil(i.getBoundingClientRect().height||0)<=e+1||(Z(),Y({preferModelDiffHeight:!0}),X()))});e.observe(i),Rt.push({dispose:()=>e.disconnect()})}return}let e=I();try{let t=(e?.onDidContentSizeChange)?.call(e,()=>Q());t&&Rt.push(t)}catch{}try{let t=(e?.onDidLayoutChange)?.call(e,()=>Q());t&&Rt.push(t)}catch{}}(),yr(),gr(),Z(),sr(),Q(),yield _();let a=null;jt&&(a=yield jt(),a&&(yield _(),yield q()));let o=a??(n===`diff`?yield Ir():yield function(){return D(this,null,function*(){if($())return yield _(),yield q(),$();for(let e=0;e<30;e++){if(N||z.value)return!1;let e=C.value,t=Nr(),n=Mr(e),r=!W.value.trim()||or(e);if(t&&n&&r&&(yield _(),yield q(),!N&&!z.value&&Nr()&&Mr(C.value)&&(!W.value.trim()||or(C.value))))return!0;yield _(),yield q()}return!1})}());N||(o?(gr(),er(),(yield Zn())||Ti()):Ti())})}(e),on=null}catch(e){let a=xi(),o=r!==nn.value,s=!1!==t.allowStaleContentRetry&&o&&on!==a;if(n!==a||s)return s&&(on=a),i=!0,A.value=!1,M.value=!1,j.value=!1,void(H.value=!1);throw Ti(n),e}}).finally(()=>{R===a&&(R=null),function(){let e=dt;S&&e&&(dt=``,_(()=>{if(!N){let t=w.value?.offsetHeight??0;t>0&&S.reportHeight(e,t)}S.markSettled(e)}))}(),i&&!N&&queueMicrotask(()=>{var e;let t=C.value;t&&!N&&((e=ci(t))==null||e.catch(e=>{M.value=!1,H.value=!1,Ti()}))})});return R=a,a}y(ri,e=>{e||je()}),y(()=>K.value,(e,t)=>{var n;let r=z.value?L():I();r&&typeof e==`number`&&Number.isFinite(e)&&e>0&&((n=r.updateOptions)==null||n.call(r,{fontSize:e}),k.value||Y(!0))},{flush:`post`,immediate:!1});let li=0,ui=y(()=>[C.value,z.value,v.stream,v.loading,it.value,P.value,v.node.language,v.node.raw,v.node.code,v.node.loading],e=>D(null,[e],function*([e,t,n,r,i,a]){let o=++li;if(!e||!a||Vr()||sn||!1===n&&!1!==r||!F&&(yield function(){return D(this,null,function*(){if(typeof window>`u`||N||it.value||V.value)return;if(Nt)return Nt;let e=D(null,null,function*(){try{let e=yield He();if(N)return;if(!e)return void(V.value=!0);xn(e)}catch{if(N)return;V.value=!0}}).finally(()=>{Nt===e&&(Nt=null)});return Nt=e,e})}(),o!==li||!1===v.stream&&!1!==v.loading||Ur()||!P.value||!F||V.value||A.value||wi()||N||C.value!==e)||Ur())return;let s=ci(e);if(s){try{yield s}catch{M.value=!1,H.value=!1,Ti()}M.value&&H.value&&ui()}}));function di(e){return typeof e==`string`?e:null}function fi(e,t){if(e===t)return!0;let n=di(e),r=di(t);return!!n&&n===r}function pi(){return we({darkTheme:v.darkTheme,isDark:v.isDark,lightTheme:v.lightTheme,theme:v.theme,themes:v.themes})}function mi(){return D(this,arguments,function*(e={}){_i();let t=()=>{z.value&&qt(),x(()=>{yr(),Q()})};if(e.appearanceOnly)return void t();let n=pi();if(n)try{yield _e(hi()),yield Ft(n),t()}catch{}else t()})}function hi(){let e=v.themes;return e&&typeof e[0]==`string`&&typeof e[1]==`string`?{dark:e[0],light:e[1]}:pi()}function gi(){let e=Mn.value,t=qe(E({},Jt.value||{}),{wordWrap:e.overflow===`wrap`?`on`:`off`,overflow:e.overflow,themes:v.themes,stream:!1,MAX_HEIGHT:v.codeBlockOptions?.maxHeight??500,fontSize:Dn.value,lineHeight:kn.value,theme:pi(),themeType:v.isDark?`dark`:`light`,disableLineNumbers:!Ae.value,disableFileHeader:!0,workerManager:Jt.value?.workerManager??he()??void 0,onThemeChange(){yr()}}),n=function(){let e=Jt.value?.fontFamily;return typeof e==`string`&&e.trim()?e.trim():z.value?function(){if(typeof window>`u`)return;let e=w.value?.querySelector(`pre.code-pre-fallback`);if(e)return window.getComputedStyle(e).fontFamily.trim()||void 0}():void 0}();n&&(t.fontFamily??=n);let r=typeof t.unsafeCSS==`string`?t.unsafeCSS:``;return t.unsafeCSS=be(e.overflow,r),t}function _i(){let e=gi();if(!Bt)return Bt=e,Bt;for(let t of Object.keys(Bt))t in e||delete Bt[t];return Object.assign(Bt,e),Bt}y(Qt,(e,t)=>D(null,null,function*(){if(e===t||U.value||sn||(qr(),!F||!C.value)||!A.value||!1===v.stream&&!1!==v.loading||!P.value)return;let n=R;if(n){try{yield n}catch{}if(N||!C.value)return}if($t.value!==e||!A.value||!M.value)try{M.value=!1,H.value=!1,A.value=!1,j.value=!1,wr(),Tr(),kt(),yield _(),yield ci(C.value)}catch{M.value=!1,H.value=!1,Ti()}}));let vi=b(0),yi=g(()=>String(vi.value)),bi=!1;function xi(){let e=pi();return JSON.stringify({kind:Qt.value,language:O.value,structural:yi.value,optionsRevision:vi.value,settledContentGeneration:rn.value,theme:di(e)??(e==null?null:`custom`),isDark:v.isDark})}y(()=>v.codeBlockOptions?.fontSize,e=>{let t=typeof e==`number`&&Number.isFinite(e)&&e>0?e:12;G.value=t,K.value=t,Sn.value=null,Cn.value=null,wn.value=null}),y(()=>[v.codeBlockOptions,v.showLineNumbers],()=>{vi.value+=1,!1===v.stream&&!1!==v.loading&&(bi=!0)},{deep:!0}),y(()=>[W.value,v.node.originalCode,v.node.updatedCode],()=>{nn.value+=1,Vr()||(rn.value+=1)});let Si=g(()=>xi());function Ci(){U.value&&tn.value!==Si.value&&(U.value=!1,tn.value=null,on=null,cn=null,A.value=!1,M.value=!1,j.value=!1,H.value=!1,en.value=!1)}function wi(){return Ci(),U.value&&tn.value===Si.value}function Ti(e=Si.value){tn.value=e,U.value=!0,en.value=!1}return y(Si,()=>D(null,null,function*(){if(sn||!U.value||tn.value===Si.value||!F||!C.value||V.value||N||!P.value||!1===v.stream&&!1!==v.loading||Ur())return;let e=Si.value;sn=!0;try{if(Ci(),U.value)return;yield ci(C.value)}catch{M.value=!1,H.value=!1,Ti()}finally{cn=e,yield _(),sn=!1}})),y(()=>[v.codeBlockOptions,P.value],()=>{var e;if(_i(),!F||!P.value)return;let t=z.value?L():I(),n=typeof v.codeBlockOptions?.fontSize==`number`?v.codeBlockOptions.fontSize:Number.isFinite(K.value)?K.value:void 0;typeof n==`number`&&Number.isFinite(n)&&n>0&&((e=t?.updateOptions)==null||e.call(t,{fontSize:n})),Y(!1)},{deep:!0}),y(()=>[pi(),Xt.value,it.value,A.value,P.value],([e,t],n)=>{if(!it.value||!P.value)return;let r=n!=null&&fi(e,n[0]),i=n!=null&&t!==n[1];M.value?(at=!1,mi({appearanceOnly:r})):r&&!i||(at=!0)},{flush:`post`}),y(()=>[yi.value,it.value,P.value],(e,t)=>D(null,[e,t],function*([e,t,n],[r]){if(_i(),!t||!n||!F||!C.value||!A.value||e===r)return;if(!1===v.stream&&!1!==v.loading)return void(bi=!0);bi=!1;let i=R;if(i){try{yield i}catch{}if(N||!C.value)return}try{M.value=!1,H.value=!1,A.value=!1,j.value=!1,wr(),Tr(),kt(),Vt&&xn(Vt),yield _(),yield ci(C.value,{allowStaleContentRetry:!1})}catch{M.value=!1,H.value=!1,Ti()}}),{flush:`post`}),y(()=>[v.loading,P.value],([e,t])=>{!1===e&&t&&bi&&(bi=!1,vi.value+=1)},{flush:`post`}),y(()=>[v.loading,P.value],(e,t)=>D(null,[e,t],function*([e,t],n){if(!t)return;let r=n?.[0];if(!1===r&&!1!==e&&z.value&&A.value&&(yield _(),x(()=>{D(null,null,function*(){let e=R;if(e)try{yield e}catch{}!N&&z.value&&!1!==v.loading&&(_i(),qt(),Q())})})),e)return;let i=r!==void 0&&!1!==r;yield _(),x(()=>{D(null,null,function*(){try{if(i&&(yield function(){return D(this,null,function*(){if(!U.value||!F||!C.value||V.value||N||!P.value)return!1;if(cn===Si.value)return!0;sn=!0;try{U.value=!1,tn.value=null,on=null,A.value=!1,M.value=!1,j.value=!1,H.value=!1,wr(),Tr(),kt(),Vt&&xn(Vt),yield _();try{yield ci(C.value)}catch{M.value=!1,H.value=!1,Ti()}}finally{yield _(),sn=!1}return!0})}()))return void Y(!1);if(i&&z.value&&A.value&&ln&&C.value)return ln=!1,M.value=!1,H.value=!1,A.value=!1,j.value=!1,wr(),Tr(),kt(),yield _(),yield ci(C.value,{allowStaleContentRetry:!1}),void Dr(!0);if(i&&A.value){if(z.value&&C.value){let e=R;if(e)try{yield e}catch{}_i();let t=Wt(String(v.node.originalCode??``),String(v.node.updatedCode??``));if(yield Rr(t.original,t.updated,O.value),N||!z.value)return;yield Promise.resolve(Et()),qt(),X(!0),Xn(),Z(),sr();let n=yield Ir();N||!n||H.value||(yield Zn()),Q(),Dr(!0)}else qr(),Yr(W.value,O.value),yield new Promise(e=>{let t=()=>{N?e():Gr||Wr?setTimeout(t,16):e()};t()}),N||z.value||(yield Promise.resolve(Tt()))}i&&z.value?(Y({preferModelDiffHeight:!0,holdCurrentDiffHeight:!0}),Dr(!0)):Y(!1)}catch{}})})}),{immediate:!0,flush:`post`}),i(()=>{wr(),Tr(),Ot(),Lt?.()}),(t,n)=>{var i;return V.value?(s(),d(Fe,{key:0,style:ae(Gn.value),node:bn.value,loading:v.loading,"show-line-numbers":Ae.value,"diff-inline":un.value,"diff-hide-unchanged-regions":dn.value,"code-block-options":v.codeBlockOptions,"resolved-visual-options":Mn.value,"reserved-height-px":z.value&&(i=Tn.value)!=null?i:void 0,"is-dark":v.isDark,theme:v.theme,"dark-theme":v.darkTheme,"light-theme":v.lightTheme,themes:v.themes,"show-header":v.showHeader,"show-copy-button":v.showCopyButton,"clipboard-writer":v.clipboardWriter,"show-tooltips":v.showTooltips,onCopy:n[0]||=e=>de(`copy`,e)},p({_:2},[t.$slots[`header-left`]?{name:`header-left`,fn:u(()=>[r(t.$slots,`header-left`,{},void 0,!0)]),key:`0`}:void 0,t.$slots[`header-right`]?{name:`header-right`,fn:u(()=>[r(t.$slots,`header-right`,{},void 0,!0)]),key:`1`}:void 0]),1032,[`style`,`node`,`loading`,`show-line-numbers`,`diff-inline`,`diff-hide-unchanged-regions`,`code-block-options`,`resolved-visual-options`,`reserved-height-px`,`is-dark`,`theme`,`dark-theme`,`light-theme`,`themes`,`show-header`,`show-copy-button`,`clipboard-writer`,`show-tooltips`])):(s(),se(`div`,{key:1,ref_key:`container`,ref:w,style:ae(ni.value),class:f([`code-block-container rounded-lg border`,[{dark:v.isDark,"is-rendering":v.loading,"is-dark":Zt.value,"is-diff":z.value,"is-plain-text":Je.value}]]),"data-markstream-code-block":`1`,"data-markstream-enhanced":H.value&&!V.value?`true`:`false`,"data-markstream-enhancement-state":vn.value,"data-markstream-code-block-state":Vr()?`streaming`:`settled`,"data-markstream-pending":_n.value?`true`:void 0,"data-markstream-viewport-pending":xt.value&&te(_t)&&!P.value?`true`:void 0},[e(Ne,{"show-header":v.showHeader,"show-collapse-button":v.showCollapseButton,"show-font-size-buttons":v.showFontSizeButtons,"enable-font-size-control":v.enableFontSizeControl,"show-copy-button":v.showCopyButton,"show-expand-button":v.showExpandButton,"show-preview-button":v.showPreviewButton,"show-tooltips":v.showTooltips,"is-dark":v.isDark,loading:v.loading,stream:c.stream,"is-collapsed":k.value,"is-expanded":Ye.value,"copy-text":Ge.value,"is-previewable":Br.value,"code-font-size":K.value,"code-font-min":10,"code-font-max":36,"default-code-font-size":G.value,"font-baseline-ready":En.value,"diff-stats":z.value?Ht.value:null,"diff-stats-aria-label":Ut.value,onToggleCollapse:oi,onDecreaseFont:ur,onResetFont:dr,onIncreaseFont:lr,onCopy:ii,onToggleExpand:ai,onPreview:si},p({"header-left":u(()=>[r(t.$slots,`header-left`,{},()=>[h(`div`,Qe,[h(`span`,{class:`icon-slot h-4 w-4 flex-shrink-0`,innerHTML:ti.value},null,8,$e),h(`div`,et,[h(`div`,tt,ee($r.value),1),ei.value?(s(),se(`div`,nt,ee(ei.value),1)):oe(``,!0)])])],!0)]),loading:u(()=>[r(t.$slots,`loading`,{loading:c.loading,stream:c.stream},()=>[n[1]||=h(`div`,{class:`loading-skeleton`},[h(`div`,{class:`skeleton-line`}),h(`div`,{class:`skeleton-line`}),h(`div`,{class:`skeleton-line short`})],-1)],!0)]),default:u(()=>{var e;return[l(h(`div`,{class:f([`code-editor-layer`,{"code-editor-layer--collapsed":k.value}])},[h(`div`,{ref_key:`codeEditor`,ref:C,class:f([`code-editor-container`,c.stream?``:`code-height-placeholder`]),"data-markstream-host-hidden":gn.value?`true`:void 0,style:ae(Jn.value)},null,14,rt),hn.value?(s(),d(Fe,{key:0,style:ae(Gn.value),node:bn.value,loading:v.loading,"show-line-numbers":Ae.value,"diff-inline":un.value,"diff-hide-unchanged-regions":dn.value,"code-block-options":v.codeBlockOptions,"resolved-visual-options":Mn.value,"reserved-height-px":z.value&&(e=Tn.value)!=null?e:void 0,"is-dark":v.isDark,theme:v.theme,"dark-theme":v.darkTheme,"light-theme":v.lightTheme,themes:v.themes,"show-toolbar":!1},null,8,[`style`,`node`,`loading`,`show-line-numbers`,`diff-inline`,`diff-hide-unchanged-regions`,`code-block-options`,`resolved-visual-options`,`reserved-height-px`,`is-dark`,`theme`,`dark-theme`,`light-theme`,`themes`])):oe(``,!0)],2),[[re,!!c.stream||!c.loading]]),yn.value&&!Ue.value&&Br.value&&T.value===`html`?(s(),d(Xe,{key:0,code:v.node.code,"html-preview-allow-scripts":v.htmlPreviewAllowScripts,"html-preview-sandbox":v.htmlPreviewSandbox,"is-dark":v.isDark,"on-close":()=>yn.value=!1},null,8,[`code`,`html-preview-allow-scripts`,`html-preview-sandbox`,`is-dark`,`on-close`])):oe(``,!0)]}),_:2},[t.$slots[`header-right`]?{name:`header-right`,fn:u(()=>[r(t.$slots,`header-right`,{},void 0,!0)]),key:`0`}:void 0]),1032,[`show-header`,`show-collapse-button`,`show-font-size-buttons`,`enable-font-size-control`,`show-copy-button`,`show-expand-button`,`show-preview-button`,`show-tooltips`,`is-dark`,`loading`,`stream`,`is-collapsed`,`is-expanded`,`copy-text`,`is-previewable`,`code-font-size`,`default-code-font-size`,`font-baseline-ready`,`diff-stats`,`diff-stats-aria-label`])],14,Ze))}}}),[[`__scopeId`,`data-v-f293a87c`]]);export{A as default};
@@ -1 +1 @@
1
- import{I as e,R as t,T as n,V as r,X as i,c as a,ct as o,d as s,f as c,g as l,q as u,tt as d,v as f,y as p}from"./vue.runtime.esm-bundler-4XjPOHMM.js";import{p as m}from"./index-Cmpdc3EH.js";var h={class:`conversation-search`},g=[`disabled`],_={key:0,role:`alert`},v={key:1},y={key:2},b=[`onClick`],x=[`disabled`],S=m(n({__name:`ConversationSearch`,props:{base:{},api:{type:Function}},emits:[`jump`],setup(n,{emit:m}){let S=n,C=m,w=d(``),T=d(``),E=d(!1),D=d(!1),O=d([]),k=d(null),A=d(``),j=0,M=``;e(()=>j++);function N(){j++,O.value=[],k.value=null,D.value=!1,E.value=!1,T.value=``}u(w,N),u(()=>S.base,()=>{w.value=``,N()});async function P(e=!1){if(E.value||!w.value.trim())return;let t=++j;e||(O.value=[],k.value=null,M=w.value.trim()),E.value=!0,T.value=``;try{let n=await S.api(S.base+`/search?q=`+encodeURIComponent(M)+(e&&k.value!==null?`&cursor=`+k.value:``));if(t!==j)return;if(e&&A.value!==n.epoch)throw Error(`Conversation changed. Search again.`);A.value=n.epoch,O.value=[...new Map((e?[...O.value,...n.locations]:n.locations).map(e=>[e.seq,e])).values()],k.value=n.nextCursor,D.value=!0}catch(e){t===j&&(T.value=e.message)}finally{t===j&&(E.value=!1)}}return(e,n)=>(t(),p(`section`,h,[n[3]||=l(`p`,null,`Search user and agent messages across the full conversation history. Select a result to read it in context.`,-1),l(`form`,{onSubmit:n[1]||=s(e=>P(!1),[`prevent`])},[i(l(`input`,{"onUpdate:modelValue":n[0]||=e=>w.value=e,type:`search`,maxlength:`500`,"aria-label":`Search conversation content`,placeholder:`Search all messages…`},null,512),[[a,w.value]]),l(`button`,{class:`btn`,disabled:E.value||!w.value.trim()},`Search`,8,g)],32),T.value?(t(),p(`p`,_,o(T.value),1)):f(``,!0),D.value&&!O.value.length&&!E.value?(t(),p(`p`,v,`No matching messages.`)):f(``,!0),E.value?(t(),p(`p`,y,`Searching…`)):f(``,!0),(t(!0),p(c,null,r(O.value,e=>(t(),p(`button`,{key:e.seq,class:`btn result`,onClick:t=>C(`jump`,e.seq,A.value)},o(e.role===`assistant`?`Agent reply`:`Your message`)+` · #`+o(e.seq)+o(e.count?` · ${e.count} matches`:``)+` →`,9,b))),128)),k.value===null?f(``,!0):(t(),p(`button`,{key:3,class:`btn`,disabled:E.value,onClick:n[2]||=e=>P(!0)},`More results`,8,x))]))}}),[[`__scopeId`,`data-v-c9855449`]]);export{S as default};
1
+ import{I as e,R as t,T as n,V as r,X as i,c as a,ct as o,d as s,f as c,g as l,q as u,tt as d,v as f,y as p}from"./vue.runtime.esm-bundler-4XjPOHMM.js";import{p as m}from"./index-CB9VixeI.js";var h={class:`conversation-search`},g=[`disabled`],_={key:0,role:`alert`},v={key:1},y={key:2},b=[`onClick`],x=[`disabled`],S=m(n({__name:`ConversationSearch`,props:{base:{},api:{type:Function}},emits:[`jump`],setup(n,{emit:m}){let S=n,C=m,w=d(``),T=d(``),E=d(!1),D=d(!1),O=d([]),k=d(null),A=d(``),j=0,M=``;e(()=>j++);function N(){j++,O.value=[],k.value=null,D.value=!1,E.value=!1,T.value=``}u(w,N),u(()=>S.base,()=>{w.value=``,N()});async function P(e=!1){if(E.value||!w.value.trim())return;let t=++j;e||(O.value=[],k.value=null,M=w.value.trim()),E.value=!0,T.value=``;try{let n=await S.api(S.base+`/search?q=`+encodeURIComponent(M)+(e&&k.value!==null?`&cursor=`+k.value:``));if(t!==j)return;if(e&&A.value!==n.epoch)throw Error(`Conversation changed. Search again.`);A.value=n.epoch,O.value=[...new Map((e?[...O.value,...n.locations]:n.locations).map(e=>[e.seq,e])).values()],k.value=n.nextCursor,D.value=!0}catch(e){t===j&&(T.value=e.message)}finally{t===j&&(E.value=!1)}}return(e,n)=>(t(),p(`section`,h,[n[3]||=l(`p`,null,`Search user and agent messages across the full conversation history. Select a result to read it in context.`,-1),l(`form`,{onSubmit:n[1]||=s(e=>P(!1),[`prevent`])},[i(l(`input`,{"onUpdate:modelValue":n[0]||=e=>w.value=e,type:`search`,maxlength:`500`,"aria-label":`Search conversation content`,placeholder:`Search all messages…`},null,512),[[a,w.value]]),l(`button`,{class:`btn`,disabled:E.value||!w.value.trim()},`Search`,8,g)],32),T.value?(t(),p(`p`,_,o(T.value),1)):f(``,!0),D.value&&!O.value.length&&!E.value?(t(),p(`p`,v,`No matching messages.`)):f(``,!0),E.value?(t(),p(`p`,y,`Searching…`)):f(``,!0),(t(!0),p(c,null,r(O.value,e=>(t(),p(`button`,{key:e.seq,class:`btn result`,onClick:t=>C(`jump`,e.seq,A.value)},o(e.role===`assistant`?`Agent reply`:`Your message`)+` · #`+o(e.seq)+o(e.count?` · ${e.count} matches`:``)+` →`,9,b))),128)),k.value===null?f(``,!0):(t(),p(`button`,{key:3,class:`btn`,disabled:E.value,onClick:n[2]||=e=>P(!0)},`More results`,8,x))]))}}),[[`__scopeId`,`data-v-c9855449`]]);export{S as default};
@@ -1,2 +1,2 @@
1
- import{C as e,N as t,R as n,S as r,T as i,W as a,_ as o,ct as s,f as ee,g as c,h as l,it as u,j as d,q as f,st as p,tt as m,v as h,y as g}from"./vue.runtime.esm-bundler-4XjPOHMM.js";import{a as _,d as te,i as v,l as y,m as b,p as x,u as S}from"./index-Cmpdc3EH.js";import{n as C,t as ne}from"./highlight-BnTrj1LT.js";var re={class:`file-view`},ie={class:`file-bar`},ae=[`title`],w={key:0,class:`file-bar-meta`},T=[`title`],E=[`title`],D={key:0,class:`timeline-empty`},O={key:1,class:`file-error`},oe=[`src`,`alt`],se={key:0,class:`file-link-notice`,role:`status`},ce={key:2,class:`file-text wrap`},le={class:`code-wrap`},ue={class:`code-gutter`,"aria-hidden":`true`},de=[`innerHTML`],k={key:2,class:`file-text`},A={key:0,class:`file-note`},j={key:5,class:`file-note`},M=x(i({__name:`FileViewer`,props:{hostId:{},cwd:{},path:{},api:{type:Function},session:{},jump:{},view:{},viewKey:{}},emits:[`open`,`reveal`,`view`],setup(i,{emit:x}){let M=i,N=x,P=m(null),F=m(``),I=m(!1),L=m(M.view?.rendered??!0),R=l(()=>`/hosts/${encodeURIComponent(M.hostId)}/fs`),z=l(()=>`cwd=${encodeURIComponent(M.cwd)}&path=${encodeURIComponent(M.path)}`),B=l(()=>/\.(png|jpe?g|webp|gif|bmp|avif)$/i.test(M.path)),V=l(()=>/\.(md|markdown|mdx)$/i.test(M.path)&&P.value?.text!==void 0);async function H(){I.value=!0,F.value=``;try{P.value=await M.api(`${R.value}/read?${z.value}`),V.value&&v()}catch(e){F.value=e.message}finally{I.value=!1}}f(()=>[M.hostId,M.cwd,M.path],H,{immediate:!0});let U=l(()=>M.path.startsWith(`/`)||M.path.startsWith(`~`)?M.path:`${M.cwd.replace(/\/$/,``)}/${M.path}`),fe=l(()=>{let e=P.value?.text??``;if(!M.session)return e;let t=U.value.slice(0,U.value.lastIndexOf(`/`))||`/`,n={session:M.session,cwd:t,workspace:M.cwd};return te(S(e,{...n,rawBase:`/api${R.value}`}),n)}),W=m(``),G;function K(e){W.value=e,clearTimeout(G),G=setTimeout(()=>W.value=``,4e3)}function pe(e){let t=e.target?.closest?.(`a`),n=y(t?.getAttribute(`href`));if(n){if(n.kind===`copy`){e.preventDefault();let t=()=>K(`Can't open this here. Path: ${n.path}`);navigator.clipboard?navigator.clipboard.writeText(n.path).then(()=>K(`Copied path: ${n.path}`),t):t()}else e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),n.kind===`reveal`?N(`reveal`,n.path):N(`open`,n.path,n))}}let q=m(null),J=m(M.view?.mark??null),Y=M.view?.jumped??0,X=!1,Z=l(()=>{let e=P.value?.text??``,t=1;for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t++;return t});f([()=>M.jump?.seq,()=>P.value],async()=>{if(!P.value)return;let e=M.jump;if(e&&e.seq!==Y&&P.value.text!==void 0){Y=e.seq,X=!0,/\.(md|markdown|mdx)$/i.test(M.path)&&(L.value=!1),await d();let t=q.value?.querySelector(`.code-gutter`);if(!q.value||!t)return;let n=getComputedStyle(t),r=parseFloat(n.lineHeight)||20,i=Math.min(e.line,Z.value),a=Math.min(Math.max(e.end??i,i),Z.value);J.value={top:parseFloat(n.paddingTop)+(i-1)*r,height:(a-i+1)*r},q.value.scrollTop=Math.max(0,J.value.top-q.value.clientHeight/3);return}if(X)return;X=!0;let t=M.view?.scrollTop??0;t&&(await d(),q.value&&(q.value.scrollTop=t),requestAnimationFrame(()=>{q.value&&q.value.scrollTop<t&&(q.value.scrollTop=t)}))},{immediate:!0}),t(()=>{M.viewKey&&N(`view`,M.viewKey,{rendered:L.value,scrollTop:q.value?.scrollTop??0,mark:J.value,jumped:Y})});let me=l(()=>`/api${R.value}/raw?${z.value}`),he=l(()=>Array.from({length:Z.value},(e,t)=>t+1).join(`
1
+ import{C as e,N as t,R as n,S as r,T as i,W as a,_ as o,ct as s,f as ee,g as c,h as l,it as u,j as d,q as f,st as p,tt as m,v as h,y as g}from"./vue.runtime.esm-bundler-4XjPOHMM.js";import{a as _,d as te,i as v,l as y,m as b,p as x,u as S}from"./index-CB9VixeI.js";import{n as C,t as ne}from"./highlight-BnTrj1LT.js";var re={class:`file-view`},ie={class:`file-bar`},ae=[`title`],w={key:0,class:`file-bar-meta`},T=[`title`],E=[`title`],D={key:0,class:`timeline-empty`},O={key:1,class:`file-error`},oe=[`src`,`alt`],se={key:0,class:`file-link-notice`,role:`status`},ce={key:2,class:`file-text wrap`},le={class:`code-wrap`},ue={class:`code-gutter`,"aria-hidden":`true`},de=[`innerHTML`],k={key:2,class:`file-text`},A={key:0,class:`file-note`},j={key:5,class:`file-note`},M=x(i({__name:`FileViewer`,props:{hostId:{},cwd:{},path:{},api:{type:Function},session:{},jump:{},view:{},viewKey:{}},emits:[`open`,`reveal`,`view`],setup(i,{emit:x}){let M=i,N=x,P=m(null),F=m(``),I=m(!1),L=m(M.view?.rendered??!0),R=l(()=>`/hosts/${encodeURIComponent(M.hostId)}/fs`),z=l(()=>`cwd=${encodeURIComponent(M.cwd)}&path=${encodeURIComponent(M.path)}`),B=l(()=>/\.(png|jpe?g|webp|gif|bmp|avif)$/i.test(M.path)),V=l(()=>/\.(md|markdown|mdx)$/i.test(M.path)&&P.value?.text!==void 0);async function H(){I.value=!0,F.value=``;try{P.value=await M.api(`${R.value}/read?${z.value}`),V.value&&v()}catch(e){F.value=e.message}finally{I.value=!1}}f(()=>[M.hostId,M.cwd,M.path],H,{immediate:!0});let U=l(()=>M.path.startsWith(`/`)||M.path.startsWith(`~`)?M.path:`${M.cwd.replace(/\/$/,``)}/${M.path}`),fe=l(()=>{let e=P.value?.text??``;if(!M.session)return e;let t=U.value.slice(0,U.value.lastIndexOf(`/`))||`/`,n={session:M.session,cwd:t,workspace:M.cwd};return te(S(e,{...n,rawBase:`/api${R.value}`}),n)}),W=m(``),G;function K(e){W.value=e,clearTimeout(G),G=setTimeout(()=>W.value=``,4e3)}function pe(e){let t=e.target?.closest?.(`a`),n=y(t?.getAttribute(`href`));if(n){if(n.kind===`copy`){e.preventDefault();let t=()=>K(`Can't open this here. Path: ${n.path}`);navigator.clipboard?navigator.clipboard.writeText(n.path).then(()=>K(`Copied path: ${n.path}`),t):t()}else e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),n.kind===`reveal`?N(`reveal`,n.path):N(`open`,n.path,n))}}let q=m(null),J=m(M.view?.mark??null),Y=M.view?.jumped??0,X=!1,Z=l(()=>{let e=P.value?.text??``,t=1;for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t++;return t});f([()=>M.jump?.seq,()=>P.value],async()=>{if(!P.value)return;let e=M.jump;if(e&&e.seq!==Y&&P.value.text!==void 0){Y=e.seq,X=!0,/\.(md|markdown|mdx)$/i.test(M.path)&&(L.value=!1),await d();let t=q.value?.querySelector(`.code-gutter`);if(!q.value||!t)return;let n=getComputedStyle(t),r=parseFloat(n.lineHeight)||20,i=Math.min(e.line,Z.value),a=Math.min(Math.max(e.end??i,i),Z.value);J.value={top:parseFloat(n.paddingTop)+(i-1)*r,height:(a-i+1)*r},q.value.scrollTop=Math.max(0,J.value.top-q.value.clientHeight/3);return}if(X)return;X=!0;let t=M.view?.scrollTop??0;t&&(await d(),q.value&&(q.value.scrollTop=t),requestAnimationFrame(()=>{q.value&&q.value.scrollTop<t&&(q.value.scrollTop=t)}))},{immediate:!0}),t(()=>{M.viewKey&&N(`view`,M.viewKey,{rendered:L.value,scrollTop:q.value?.scrollTop??0,mark:J.value,jumped:Y})});let me=l(()=>`/api${R.value}/raw?${z.value}`),he=l(()=>Array.from({length:Z.value},(e,t)=>t+1).join(`
2
2
  `)),Q=l(()=>P.value?.text===void 0?null:ne(P.value.text,C(M.path))),ge=e=>e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`,$=m(!1);async function _e(){await navigator.clipboard?.writeText(U.value).catch(()=>{}),$.value=!0,setTimeout(()=>$.value=!1,1200)}return(t,l)=>(n(),g(`div`,re,[c(`div`,ie,[e(b,{name:`file`,size:14,class:`file-bar-icon`}),c(`span`,{class:`file-bar-path`,title:i.path},s(i.path),9,ae),P.value?(n(),g(`span`,w,s(ge(P.value.size)),1)):h(``,!0),V.value?(n(),g(`button`,{key:1,class:`icon-btn`,title:L.value?`Show source`:`Show rendered`,onClick:l[0]||=e=>L.value=!L.value},[e(b,{name:L.value?`terminal`:`eye`,size:14},null,8,[`name`])],8,T)):h(``,!0),c(`button`,{class:`icon-btn`,title:`Reload`,"aria-label":`Reload file`,onClick:H},[e(b,{name:`refresh`,size:14})]),c(`button`,{class:`icon-btn`,title:$.value?`Copied`:`Copy path`,"aria-label":`Copy path`,onClick:_e},[e(b,{name:$.value?`check`:`copy`,size:14},null,8,[`name`])],8,E)]),c(`div`,{ref_key:`body`,ref:q,class:`file-body`},[I.value&&!P.value?(n(),g(`div`,D,[...l[1]||=[c(`span`,{class:`spinner`},null,-1)]])):F.value?(n(),g(`p`,O,[e(b,{name:`alert`,size:13}),r(s(F.value),1)])):B.value?(n(),g(`img`,{key:2,src:me.value,alt:i.path,class:`file-image`},null,8,oe)):V.value&&L.value?(n(),g(`div`,{key:3,class:`file-markdown`,onClick:pe},[W.value?(n(),g(`p`,se,s(W.value),1)):h(``,!0),u(_)?(n(),o(a(u(_)),{key:1,content:fe.value,final:!0},null,8,[`content`])):(n(),g(`pre`,ce,s(P.value?.text),1))])):P.value?.text===void 0?P.value?(n(),g(`p`,j,s(P.value.mime||P.value.kind)+` · not shown as text`,1)):h(``,!0):(n(),g(ee,{key:4},[c(`div`,le,[J.value?(n(),g(`div`,{key:0,class:`line-mark`,style:p({top:J.value.top+`px`,height:J.value.height+`px`}),"aria-hidden":`true`},null,4)):h(``,!0),c(`pre`,ue,s(he.value),1),Q.value===null?(n(),g(`pre`,k,s(P.value.text),1)):(n(),g(`pre`,{key:1,class:`file-text hljs`,innerHTML:Q.value},null,8,de))]),P.value.truncated?(n(),g(`p`,A,`Showing the first 1 MB.`)):h(``,!0)],64))],512)]))}}),[[`__scopeId`,`data-v-b6228f15`]]);export{M as default};
@@ -1 +1 @@
1
- import{C as e,R as t,S as n,T as r,V as i,_ as a,at as o,ct as s,f as c,g as l,h as u,j as d,nt as f,q as p,st as m,tt as h,v as g,y as _}from"./vue.runtime.esm-bundler-4XjPOHMM.js";import{m as v,p as y}from"./index-Cmpdc3EH.js";var b={class:`files`},x={class:`files-head`},S=[`title`],C={key:0,class:`files-error`},w=[`data-path`,`aria-expanded`,`title`,`onClick`],T={key:1,class:`tree-caret`},E={class:`tree-name`},D={key:2,class:`spinner spinner-sm`},O={key:0,class:`files-empty`},k=y(r({__name:`FilesPanel`,props:{hostId:{},cwd:{},api:{type:Function},activePath:{},reveal:{}},emits:[`open`],setup(r,{emit:y}){let k=r,A=y,j=f(new Map),M=h(new Set),N=h(new Set),P=h(``),F=u(()=>`/hosts/${encodeURIComponent(k.hostId)}/fs`),I=e=>`cwd=${encodeURIComponent(k.cwd)}&path=${encodeURIComponent(e)}`,L=new Map;function R(e){let t=L.get(e);if(t)return t;let n=z(e).finally(()=>L.delete(e));return L.set(e,n),n}async function z(e){N.value=new Set(N.value).add(e);try{let t=await k.api(`${F.value}/list?${I(e)}`),n=new Map(j.value);n.set(e,t.entries),j.value=n,P.value=``}catch(e){P.value=e.message}finally{let t=new Set(N.value);t.delete(e),N.value=t}}p(()=>[k.hostId,k.cwd],()=>{j.value=new Map,M.value=new Set,R(`.`)},{immediate:!0});function B(e){let t=new Set(M.value);t.has(e.path)?t.delete(e.path):(t.add(e.path),j.value.has(e.path)||R(e.path)),M.value=t}let V=u(()=>{let e=[],t=(n,r)=>{for(let i of j.value.get(n)??[])e.push({entry:i,depth:r}),i.kind===`directory`&&M.value.has(i.path)&&t(i.path,r+1)};return t(`.`,0),e}),H=h(null),U=h(null);return p(()=>k.activePath,()=>U.value=null),p(()=>k.reveal?.seq,async()=>{let e=k.reveal?.path;if(!e)return;let t=e===`.`?[]:e.split(`/`).filter(Boolean);await R(`.`);for(let e=1;e<=t.length;e++){let n=t.slice(0,e).join(`/`);j.value.has(n)||await R(n),M.value=new Set(M.value).add(n)}U.value=t.join(`/`)||null,await d();let n=Array.from(H.value?.querySelectorAll(`.tree-row`)??[]).find(e=>e.dataset.path===U.value);n?.scrollIntoView({block:`center`}),n?.focus({preventScroll:!0})},{immediate:!0}),(u,d)=>(t(),_(`div`,b,[l(`div`,x,[l(`span`,{class:`files-root`,title:r.cwd},s(r.cwd.split(`/`).filter(Boolean).pop()||r.cwd),9,S),l(`button`,{class:`icon-btn`,title:`Refresh`,"aria-label":`Refresh files`,onClick:d[0]||=e=>{j.value=new Map,M.value=new Set,R(`.`)}},[e(v,{name:`refresh`,size:14})])]),P.value?(t(),_(`p`,C,[e(v,{name:`alert`,size:13}),n(s(P.value),1)])):g(``,!0),l(`div`,{ref_key:`tree`,ref:H,class:`tree`,role:`tree`},[(t(!0),_(c,null,i(V.value,n=>(t(),_(`button`,{key:n.entry.path,class:o([`tree-row`,{chosen:n.entry.path===r.activePath||n.entry.path===U.value}]),"data-path":n.entry.path,role:`treeitem`,"aria-expanded":n.entry.kind===`directory`?M.value.has(n.entry.path):void 0,style:m({paddingLeft:8+n.depth*14+`px`}),title:n.entry.path,onClick:e=>n.entry.kind===`directory`?B(n.entry):A(`open`,n.entry.path)},[n.entry.kind===`directory`?(t(),a(v,{key:0,name:`chevron`,size:11,class:o([`tree-caret`,{open:M.value.has(n.entry.path)}])},null,8,[`class`])):(t(),_(`span`,T)),e(v,{name:n.entry.kind===`directory`?`folder`:`file`,size:14,class:`tree-icon`},null,8,[`name`]),l(`span`,E,s(n.entry.name),1),N.value.has(n.entry.path)?(t(),_(`span`,D)):g(``,!0)],14,w))),128)),!V.value.length&&N.value.has(`.`)?(t(),_(`div`,O,[...d[1]||=[l(`span`,{class:`spinner`},null,-1)]])):g(``,!0)],512)]))}}),[[`__scopeId`,`data-v-4159b030`]]);export{k as default};
1
+ import{C as e,R as t,S as n,T as r,V as i,_ as a,at as o,ct as s,f as c,g as l,h as u,j as d,nt as f,q as p,st as m,tt as h,v as g,y as _}from"./vue.runtime.esm-bundler-4XjPOHMM.js";import{m as v,p as y}from"./index-CB9VixeI.js";var b={class:`files`},x={class:`files-head`},S=[`title`],C={key:0,class:`files-error`},w=[`data-path`,`aria-expanded`,`title`,`onClick`],T={key:1,class:`tree-caret`},E={class:`tree-name`},D={key:2,class:`spinner spinner-sm`},O={key:0,class:`files-empty`},k=y(r({__name:`FilesPanel`,props:{hostId:{},cwd:{},api:{type:Function},activePath:{},reveal:{}},emits:[`open`],setup(r,{emit:y}){let k=r,A=y,j=f(new Map),M=h(new Set),N=h(new Set),P=h(``),F=u(()=>`/hosts/${encodeURIComponent(k.hostId)}/fs`),I=e=>`cwd=${encodeURIComponent(k.cwd)}&path=${encodeURIComponent(e)}`,L=new Map;function R(e){let t=L.get(e);if(t)return t;let n=z(e).finally(()=>L.delete(e));return L.set(e,n),n}async function z(e){N.value=new Set(N.value).add(e);try{let t=await k.api(`${F.value}/list?${I(e)}`),n=new Map(j.value);n.set(e,t.entries),j.value=n,P.value=``}catch(e){P.value=e.message}finally{let t=new Set(N.value);t.delete(e),N.value=t}}p(()=>[k.hostId,k.cwd],()=>{j.value=new Map,M.value=new Set,R(`.`)},{immediate:!0});function B(e){let t=new Set(M.value);t.has(e.path)?t.delete(e.path):(t.add(e.path),j.value.has(e.path)||R(e.path)),M.value=t}let V=u(()=>{let e=[],t=(n,r)=>{for(let i of j.value.get(n)??[])e.push({entry:i,depth:r}),i.kind===`directory`&&M.value.has(i.path)&&t(i.path,r+1)};return t(`.`,0),e}),H=h(null),U=h(null);return p(()=>k.activePath,()=>U.value=null),p(()=>k.reveal?.seq,async()=>{let e=k.reveal?.path;if(!e)return;let t=e===`.`?[]:e.split(`/`).filter(Boolean);await R(`.`);for(let e=1;e<=t.length;e++){let n=t.slice(0,e).join(`/`);j.value.has(n)||await R(n),M.value=new Set(M.value).add(n)}U.value=t.join(`/`)||null,await d();let n=Array.from(H.value?.querySelectorAll(`.tree-row`)??[]).find(e=>e.dataset.path===U.value);n?.scrollIntoView({block:`center`}),n?.focus({preventScroll:!0})},{immediate:!0}),(u,d)=>(t(),_(`div`,b,[l(`div`,x,[l(`span`,{class:`files-root`,title:r.cwd},s(r.cwd.split(`/`).filter(Boolean).pop()||r.cwd),9,S),l(`button`,{class:`icon-btn`,title:`Refresh`,"aria-label":`Refresh files`,onClick:d[0]||=e=>{j.value=new Map,M.value=new Set,R(`.`)}},[e(v,{name:`refresh`,size:14})])]),P.value?(t(),_(`p`,C,[e(v,{name:`alert`,size:13}),n(s(P.value),1)])):g(``,!0),l(`div`,{ref_key:`tree`,ref:H,class:`tree`,role:`tree`},[(t(!0),_(c,null,i(V.value,n=>(t(),_(`button`,{key:n.entry.path,class:o([`tree-row`,{chosen:n.entry.path===r.activePath||n.entry.path===U.value}]),"data-path":n.entry.path,role:`treeitem`,"aria-expanded":n.entry.kind===`directory`?M.value.has(n.entry.path):void 0,style:m({paddingLeft:8+n.depth*14+`px`}),title:n.entry.path,onClick:e=>n.entry.kind===`directory`?B(n.entry):A(`open`,n.entry.path)},[n.entry.kind===`directory`?(t(),a(v,{key:0,name:`chevron`,size:11,class:o([`tree-caret`,{open:M.value.has(n.entry.path)}])},null,8,[`class`])):(t(),_(`span`,T)),e(v,{name:n.entry.kind===`directory`?`folder`:`file`,size:14,class:`tree-icon`},null,8,[`name`]),l(`span`,E,s(n.entry.name),1),N.value.has(n.entry.path)?(t(),_(`span`,D)):g(``,!0)],14,w))),128)),!V.value.length&&N.value.has(`.`)?(t(),_(`div`,O,[...d[1]||=[l(`span`,{class:`spinner`},null,-1)]])):g(``,!0)],512)]))}}),[[`__scopeId`,`data-v-4159b030`]]);export{k as default};