litepaseo 0.13.2 → 0.13.4

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 (134) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/server/cli.mjs +2 -2
  3. package/dist/server/{worker-C-KgOZ4j.mjs → worker-Dtl_KOz9.mjs} +40 -21
  4. package/dist/web/assets/{AddProjectDialog-DqnbtCX_.js → AddProjectDialog-Da5SYnbc.js} +1 -1
  5. package/dist/web/assets/AddProjectDialog-Da5SYnbc.js.br +0 -0
  6. package/dist/web/assets/AddProjectDialog-Da5SYnbc.js.gz +0 -0
  7. package/dist/web/assets/{ArchivedWorkspaces-BVNADrnb.js → ArchivedWorkspaces-B2vUSFVW.js} +1 -1
  8. package/dist/web/assets/ArchivedWorkspaces-B2vUSFVW.js.br +0 -0
  9. package/dist/web/assets/ArchivedWorkspaces-B2vUSFVW.js.gz +0 -0
  10. package/dist/web/assets/{ChangesPanel-B_aMHOy0.js → ChangesPanel-DBlpoPYb.js} +1 -1
  11. package/dist/web/assets/ChangesPanel-DBlpoPYb.js.br +0 -0
  12. package/dist/web/assets/ChangesPanel-DBlpoPYb.js.gz +0 -0
  13. package/dist/web/assets/{CodeBlockNode-BHpMMKG-.js → CodeBlockNode-fBM-qTZY.js} +1 -1
  14. package/dist/web/assets/CodeBlockNode-fBM-qTZY.js.br +0 -0
  15. package/dist/web/assets/CodeBlockNode-fBM-qTZY.js.gz +0 -0
  16. package/dist/web/assets/{CommandCenter-CLxqHc3O.js → CommandCenter-CIwf7U03.js} +1 -1
  17. package/dist/web/assets/CommandCenter-CIwf7U03.js.br +0 -0
  18. package/dist/web/assets/CommandCenter-CIwf7U03.js.gz +0 -0
  19. package/dist/web/assets/{ConversationSearch-FTWEWSUu.js → ConversationSearch-Ckc45F45.js} +1 -1
  20. package/dist/web/assets/ConversationSearch-Ckc45F45.js.br +0 -0
  21. package/dist/web/assets/ConversationSearch-Ckc45F45.js.gz +0 -0
  22. package/dist/web/assets/{FileViewer-C5O-KMUx.js → FileViewer-DtHpEbXq.js} +1 -1
  23. package/dist/web/assets/FileViewer-DtHpEbXq.js.br +0 -0
  24. package/dist/web/assets/FileViewer-DtHpEbXq.js.gz +0 -0
  25. package/dist/web/assets/{FilesPanel-Dg9lqGBo.js → FilesPanel-DeG8VfEb.js} +1 -1
  26. package/dist/web/assets/FilesPanel-DeG8VfEb.js.br +0 -0
  27. package/dist/web/assets/FilesPanel-DeG8VfEb.js.gz +0 -0
  28. package/dist/web/assets/{HostSettings-DsUCWEUL.js → HostSettings-DoNAVnxT.js} +1 -1
  29. package/dist/web/assets/HostSettings-DoNAVnxT.js.br +0 -0
  30. package/dist/web/assets/HostSettings-DoNAVnxT.js.gz +0 -0
  31. package/dist/web/assets/{KanbanPage-CSWy9O3h.js → KanbanPage-DwZbnEwI.js} +1 -1
  32. package/dist/web/assets/KanbanPage-DwZbnEwI.js.br +0 -0
  33. package/dist/web/assets/KanbanPage-DwZbnEwI.js.gz +0 -0
  34. package/dist/web/assets/{LabelsDialog-CITuVVJW.js → LabelsDialog-CIZwN5JQ.js} +1 -1
  35. package/dist/web/assets/LabelsDialog-CIZwN5JQ.js.br +0 -0
  36. package/dist/web/assets/LabelsDialog-CIZwN5JQ.js.gz +0 -0
  37. package/dist/web/assets/{MarkdownMessage-BSPsJz2u.js → MarkdownMessage-B5JuY96x.js} +5 -5
  38. package/dist/web/assets/MarkdownMessage-B5JuY96x.js.br +0 -0
  39. package/dist/web/assets/MarkdownMessage-B5JuY96x.js.gz +0 -0
  40. package/dist/web/assets/{PreCodeBlock-CUsnJ_0J.js → PreCodeBlock-BZxij1Se.js} +1 -1
  41. package/dist/web/assets/{PreCodeBlock.vue_vue_type_style_index_0_lang-B_ZZH8sz.js → PreCodeBlock.vue_vue_type_style_index_0_lang-C8gxl3_t.js} +1 -1
  42. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-C8gxl3_t.js.br +0 -0
  43. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-C8gxl3_t.js.gz +0 -0
  44. package/dist/web/assets/{SubagentsPanel-Brk1hh5C.js → SubagentsPanel-NjiTD7SL.js} +1 -1
  45. package/dist/web/assets/SubagentsPanel-NjiTD7SL.js.br +0 -0
  46. package/dist/web/assets/SubagentsPanel-NjiTD7SL.js.gz +0 -0
  47. package/dist/web/assets/{TerminalPanel-tG9J8yCX.js → TerminalPanel-DJL_P7gn.js} +1 -1
  48. package/dist/web/assets/TerminalPanel-DJL_P7gn.js.br +0 -0
  49. package/dist/web/assets/TerminalPanel-DJL_P7gn.js.gz +0 -0
  50. package/dist/web/assets/{Tooltip-MKPYhhV1.js → Tooltip-DykA2YFi.js} +1 -1
  51. package/dist/web/assets/Tooltip-DykA2YFi.js.br +0 -0
  52. package/dist/web/assets/Tooltip-DykA2YFi.js.gz +0 -0
  53. package/dist/web/assets/index-DZm2Vxoh.js +39 -0
  54. package/dist/web/assets/index-DZm2Vxoh.js.br +0 -0
  55. package/dist/web/assets/index-DZm2Vxoh.js.gz +0 -0
  56. package/dist/web/assets/index-mcXZ0n9O.css +1 -0
  57. package/dist/web/assets/index-mcXZ0n9O.css.br +0 -0
  58. package/dist/web/assets/index-mcXZ0n9O.css.gz +0 -0
  59. package/dist/web/assets/{index10-DahGcoad.js → index10-Dg_4gqi_.js} +1 -1
  60. package/dist/web/assets/index10-Dg_4gqi_.js.br +0 -0
  61. package/dist/web/assets/index10-Dg_4gqi_.js.gz +0 -0
  62. package/dist/web/assets/index3-DvC22Kiy.js +1 -0
  63. package/dist/web/assets/index4-BKXDDv9R.js +1 -0
  64. package/dist/web/assets/{index5-CgcNfgxb.js → index5-BylgZR6g.js} +1 -1
  65. package/dist/web/assets/index5-BylgZR6g.js.br +0 -0
  66. package/dist/web/assets/index5-BylgZR6g.js.gz +0 -0
  67. package/dist/web/assets/{index6-CrSTK4tr.js → index6-BEVCQ3WX.js} +1 -1
  68. package/dist/web/assets/index6-BEVCQ3WX.js.br +0 -0
  69. package/dist/web/assets/index6-BEVCQ3WX.js.gz +0 -0
  70. package/dist/web/assets/{index7-DWSIBAjx.js → index7-D-rT0wQb.js} +1 -1
  71. package/dist/web/assets/index7-D-rT0wQb.js.br +0 -0
  72. package/dist/web/assets/index7-D-rT0wQb.js.gz +0 -0
  73. package/dist/web/assets/{index8-C-KUFSiY.js → index8-m4nMNgie.js} +1 -1
  74. package/dist/web/assets/index8-m4nMNgie.js.br +0 -0
  75. package/dist/web/assets/index8-m4nMNgie.js.gz +0 -0
  76. package/dist/web/assets/{index9-CHVI36Nl.js → index9-DQf7xduQ.js} +1 -1
  77. package/dist/web/assets/index9-DQf7xduQ.js.br +0 -0
  78. package/dist/web/assets/index9-DQf7xduQ.js.gz +0 -0
  79. package/dist/web/index.html +2 -2
  80. package/dist/web/index.html.br +0 -0
  81. package/dist/web/index.html.gz +0 -0
  82. package/package.json +1 -1
  83. package/dist/web/assets/AddProjectDialog-DqnbtCX_.js.br +0 -0
  84. package/dist/web/assets/AddProjectDialog-DqnbtCX_.js.gz +0 -0
  85. package/dist/web/assets/ArchivedWorkspaces-BVNADrnb.js.br +0 -0
  86. package/dist/web/assets/ArchivedWorkspaces-BVNADrnb.js.gz +0 -0
  87. package/dist/web/assets/ChangesPanel-B_aMHOy0.js.br +0 -0
  88. package/dist/web/assets/ChangesPanel-B_aMHOy0.js.gz +0 -0
  89. package/dist/web/assets/CodeBlockNode-BHpMMKG-.js.br +0 -0
  90. package/dist/web/assets/CodeBlockNode-BHpMMKG-.js.gz +0 -0
  91. package/dist/web/assets/CommandCenter-CLxqHc3O.js.br +0 -0
  92. package/dist/web/assets/CommandCenter-CLxqHc3O.js.gz +0 -0
  93. package/dist/web/assets/ConversationSearch-FTWEWSUu.js.br +0 -0
  94. package/dist/web/assets/ConversationSearch-FTWEWSUu.js.gz +0 -0
  95. package/dist/web/assets/FileViewer-C5O-KMUx.js.br +0 -0
  96. package/dist/web/assets/FileViewer-C5O-KMUx.js.gz +0 -0
  97. package/dist/web/assets/FilesPanel-Dg9lqGBo.js.br +0 -0
  98. package/dist/web/assets/FilesPanel-Dg9lqGBo.js.gz +0 -0
  99. package/dist/web/assets/HostSettings-DsUCWEUL.js.br +0 -0
  100. package/dist/web/assets/HostSettings-DsUCWEUL.js.gz +0 -0
  101. package/dist/web/assets/KanbanPage-CSWy9O3h.js.br +0 -0
  102. package/dist/web/assets/KanbanPage-CSWy9O3h.js.gz +0 -0
  103. package/dist/web/assets/LabelsDialog-CITuVVJW.js.br +0 -0
  104. package/dist/web/assets/LabelsDialog-CITuVVJW.js.gz +0 -0
  105. package/dist/web/assets/MarkdownMessage-BSPsJz2u.js.br +0 -0
  106. package/dist/web/assets/MarkdownMessage-BSPsJz2u.js.gz +0 -0
  107. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-B_ZZH8sz.js.br +0 -0
  108. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-B_ZZH8sz.js.gz +0 -0
  109. package/dist/web/assets/SubagentsPanel-Brk1hh5C.js.br +0 -0
  110. package/dist/web/assets/SubagentsPanel-Brk1hh5C.js.gz +0 -0
  111. package/dist/web/assets/TerminalPanel-tG9J8yCX.js.br +0 -0
  112. package/dist/web/assets/TerminalPanel-tG9J8yCX.js.gz +0 -0
  113. package/dist/web/assets/Tooltip-MKPYhhV1.js.br +0 -0
  114. package/dist/web/assets/Tooltip-MKPYhhV1.js.gz +0 -0
  115. package/dist/web/assets/index-CnAv6NUR.css +0 -1
  116. package/dist/web/assets/index-CnAv6NUR.css.br +0 -0
  117. package/dist/web/assets/index-CnAv6NUR.css.gz +0 -0
  118. package/dist/web/assets/index-DAwT50Ss.js +0 -39
  119. package/dist/web/assets/index-DAwT50Ss.js.br +0 -0
  120. package/dist/web/assets/index-DAwT50Ss.js.gz +0 -0
  121. package/dist/web/assets/index10-DahGcoad.js.br +0 -0
  122. package/dist/web/assets/index10-DahGcoad.js.gz +0 -0
  123. package/dist/web/assets/index3-C_-f4bxf.js +0 -1
  124. package/dist/web/assets/index4-Bv2X2ReP.js +0 -1
  125. package/dist/web/assets/index5-CgcNfgxb.js.br +0 -0
  126. package/dist/web/assets/index5-CgcNfgxb.js.gz +0 -0
  127. package/dist/web/assets/index6-CrSTK4tr.js.br +0 -0
  128. package/dist/web/assets/index6-CrSTK4tr.js.gz +0 -0
  129. package/dist/web/assets/index7-DWSIBAjx.js.br +0 -0
  130. package/dist/web/assets/index7-DWSIBAjx.js.gz +0 -0
  131. package/dist/web/assets/index8-C-KUFSiY.js.br +0 -0
  132. package/dist/web/assets/index8-C-KUFSiY.js.gz +0 -0
  133. package/dist/web/assets/index9-CHVI36Nl.js.br +0 -0
  134. package/dist/web/assets/index9-CHVI36Nl.js.gz +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.13.4
4
+
5
+ - **Close individual agent session tabs in a workspace**:
6
+ - When a workspace has multiple active agent sessions, each agent tab now shows a close (`×`) button and supports middle-click to close (archive) that session without archiving the entire workspace.
7
+ - Always prompts for confirmation before closing (with an active-session warning when running or waiting for input); host history is preserved, and closing the active tab immediately switches to another session in the workspace.
8
+ - Add **Close current agent session** to the Command Center when multiple sessions are open in the workspace, and raise the per-workspace displayed agent tab cap from 12 to 50.
9
+
10
+ ## 0.13.3
11
+
12
+ - **Instant 0 ms send feedback (optimistic user messages)**:
13
+ - Submitted messages (`send`, `steer`, `interrupt`) now appear in the conversation immediately at 0 ms with their text, image previews (using owned object URLs), and attachment names, scroll straight to the bottom, and transition seamlessly into the `Working…` indicator once acknowledged.
14
+ - Deduplication matches daemon `user_message` rows strictly by `clientMessageId`/`messageId` first and falls back to 1-to-1 FIFO content matching guarded by `baselineSeqEnd` (so repeating prompts like `"continue"` never dismiss new bubbles prematurely), with zero duplicate frames.
15
+ - Mobile flaky-network safety: if the real SSE row arrives before the HTTP response completes or drops, the send is confirmed positively instead of triggering a false `uncertain` warning; failed or unconfirmed sends roll back the optimistic bubble cleanly and revoke owned blob URLs.
16
+ - **Post-send fast burst in `TimelineView`**:
17
+ - Replace the idle-only 500 ms follow-up with a bounded fast-burst window (up to 6 checks at 300 ms, also active while running or on newly created empty conversations) that exits immediately as soon as the new row lands and returns to the 1.5 s steady-state cadence (0 polling when idle).
18
+ - **Cleanup**:
19
+ - Remove duplicate `turnMetrics` fallback template branches in `ConversationView.vue`.
20
+
3
21
  ## 0.13.2
4
22
 
5
23
  - **Wake + Pull single-source-of-truth timeline (`TimelineView`)**:
@@ -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.13.2";
11
+ const VERSION = "0.13.4";
12
12
  // src/server/rotating-log.ts
13
13
  /** One writer (the supervisor); bounded active file plus numbered archives. */
14
14
  var RotatingLog = class {
@@ -1764,7 +1764,7 @@ async function run() {
1764
1764
  if (name === "--help" || name === "-h") return console.log(mainHelp(VERSION, displayDirectory(), out));
1765
1765
  if (name === "worker") {
1766
1766
  const paths = await dataDirectory();
1767
- const { runWorker } = await import("./worker-C-KgOZ4j.mjs");
1767
+ const { runWorker } = await import("./worker-Dtl_KOz9.mjs");
1768
1768
  return runWorker(paths.directory, fileURLToPath(new URL("../web/", import.meta.url)));
1769
1769
  }
1770
1770
  const command = findCommand(name);
@@ -740,6 +740,10 @@ const RESET_ROWS = 200;
740
740
  const MAX_JOINERS = 64;
741
741
  /** Low-frequency pull interval while an agent is actively running and watched. */
742
742
  const DEFAULT_POLL_MS = 1500;
743
+ /** Short burst interval right after sending a message or rewind so the new row lands quickly. */
744
+ const FAST_POLL_MS = 300;
745
+ /** Max fast-burst follow-up polls (~1.8 s at 300 ms); exits early as soon as rows change. */
746
+ const FAST_BURST_POLLS = 6;
743
747
  /** Retry delay when the initial load fails. */
744
748
  const RETRY_MS = 2e3;
745
749
  /** One-shot follow-up delay after a turn ends if turnMetrics have not landed yet. */
@@ -797,7 +801,7 @@ var TimelineView = class {
797
801
  pollTimer;
798
802
  retryTimer;
799
803
  settleTimer;
800
- followUpTimer;
804
+ fastPollsLeft = 0;
801
805
  inFlight = false;
802
806
  pendingPull = false;
803
807
  pendingSettle = false;
@@ -810,11 +814,13 @@ var TimelineView = class {
810
814
  agentId;
811
815
  report;
812
816
  pollMs;
817
+ fastPollMs;
813
818
  constructor(driver, agentId, report, pollMs = DEFAULT_POLL_MS) {
814
819
  this.driver = driver;
815
820
  this.agentId = agentId;
816
821
  this.report = report;
817
822
  this.pollMs = pollMs;
823
+ this.fastPollMs = Math.min(pollMs, FAST_POLL_MS);
818
824
  }
819
825
  get watcherCount() {
820
826
  return this.watchers.size;
@@ -848,29 +854,29 @@ var TimelineView = class {
848
854
  this.schedulePoll();
849
855
  }
850
856
  } else {
851
- clearTimeout(this.pollTimer);
852
- this.pollTimer = void 0;
857
+ if (!this.inFastBurst()) {
858
+ clearTimeout(this.pollTimer);
859
+ this.pollTimer = void 0;
860
+ }
853
861
  if (wasActive && this.state === "live") this.pull(false, true);
854
862
  }
855
863
  }
856
864
  /**
857
865
  * Requests an immediate pull (e.g. after a message send, rewind, reconnect, or state update).
858
- * With `followUp = true`, schedules one short 500ms follow-up pull if idle so instant commands
859
- * or newly written prompts are never missed without starting an unbounded polling loop.
866
+ * With `followUp = true`, opens a short fast-burst window (up to 2 s at 300 ms cadence) that
867
+ * runs regardless of `active` so a newly submitted user_message lands quickly instead of
868
+ * waiting for the 1.5 s steady-state poll, and exits early as soon as rows change.
860
869
  */
861
870
  wake(followUp = false) {
862
871
  if (this.state === "disposed") return;
872
+ if (followUp) {
873
+ this.fastPollsLeft = FAST_BURST_POLLS;
874
+ clearTimeout(this.pollTimer);
875
+ this.pollTimer = void 0;
876
+ }
863
877
  if (this.state === "idle" || this.state === "failed") return this.start();
864
878
  if (this.state === "live") this.pull(false);
865
879
  else this.pendingPull = true;
866
- if (followUp) {
867
- clearTimeout(this.followUpTimer);
868
- this.followUpTimer = setTimeout(() => {
869
- this.followUpTimer = void 0;
870
- if (this.state === "live" && !this.active) this.pull(false);
871
- }, 500);
872
- this.followUpTimer.unref?.();
873
- }
874
880
  }
875
881
  /** Backwards-compatible alias for one-shot tail refresh. */
876
882
  refreshTailMetrics() {
@@ -883,7 +889,7 @@ var TimelineView = class {
883
889
  if (ops) {
884
890
  if (ops.length) watcher(ops);
885
891
  } else watcher([this.resetOp()]);
886
- if (this.active) this.schedulePoll();
892
+ if (this.active || this.inFastBurst()) this.schedulePoll();
887
893
  else if (since && now() - this.lastPullAt >= RESUME_VERIFY_MS) this.wake();
888
894
  } else if (this.state === "loading" && this.joiners.length < MAX_JOINERS) this.joiners.push(now());
889
895
  return () => {
@@ -897,21 +903,29 @@ var TimelineView = class {
897
903
  dispose() {
898
904
  this.state = "disposed";
899
905
  this.token++;
906
+ this.fastPollsLeft = 0;
900
907
  clearTimeout(this.pollTimer);
901
908
  clearTimeout(this.retryTimer);
902
909
  clearTimeout(this.settleTimer);
903
- clearTimeout(this.followUpTimer);
904
- this.pollTimer = this.retryTimer = this.settleTimer = this.followUpTimer = void 0;
910
+ this.pollTimer = this.retryTimer = this.settleTimer = void 0;
905
911
  this.watchers.clear();
906
912
  return Promise.resolve();
907
913
  }
914
+ inFastBurst() {
915
+ return this.fastPollsLeft > 0;
916
+ }
908
917
  schedulePoll() {
909
- if (this.state !== "live" || !this.active || !this.watchers.size || this.pollTimer) return;
918
+ if (this.state !== "live" || !this.watchers.size || this.pollTimer) return;
919
+ const fast = this.inFastBurst();
920
+ if (!this.active && !fast) return;
921
+ const delay = fast ? this.fastPollMs : this.pollMs;
910
922
  this.pollTimer = setTimeout(() => {
911
923
  this.pollTimer = void 0;
912
- if (this.state !== "live" || !this.active || !this.watchers.size) return;
924
+ if (this.state !== "live" || !this.watchers.size) return;
925
+ if (fast && this.fastPollsLeft > 0) this.fastPollsLeft--;
926
+ if (!this.active && !fast) return;
913
927
  this.pull(false);
914
- }, this.pollMs);
928
+ }, delay);
915
929
  this.pollTimer.unref?.();
916
930
  }
917
931
  async pull(initial, checkMetricsSettle = false) {
@@ -946,10 +960,15 @@ var TimelineView = class {
946
960
  this.replaceWith(page);
947
961
  this.state = "live";
948
962
  this.loaded();
963
+ if (initial && page.entries.length === 0 && this.watchers.size > 0) this.fastPollsLeft = Math.max(this.fastPollsLeft, FAST_BURST_POLLS);
964
+ else if (page.entries.length > 0) this.fastPollsLeft = 0;
949
965
  this.broadcast([this.resetOp()]);
950
966
  } else {
951
967
  const ops = this.mergeTail(page);
952
- if (ops.length) this.broadcast(ops);
968
+ if (ops.length) {
969
+ this.fastPollsLeft = 0;
970
+ this.broadcast(ops);
971
+ }
953
972
  }
954
973
  if (checkMetricsSettle && !this.active) {
955
974
  const latest = [...page.entries].reverse().find((e) => e.item.type === "assistant_message" || e.item.type === "tool_call");
@@ -991,7 +1010,7 @@ var TimelineView = class {
991
1010
  this.pendingPull = false;
992
1011
  this.pendingSettle = false;
993
1012
  this.pull(false, settle);
994
- } else if (this.active && this.watchers.size) this.schedulePoll();
1013
+ } else if ((this.active || this.inFastBurst()) && this.watchers.size) this.schedulePoll();
995
1014
  }
996
1015
  }
997
1016
  }
@@ -1 +1 @@
1
- import{C as e,H as t,I as ee,Q as n,S as r,T as i,Y as te,c as a,ct as o,d as s,dt as c,f as l,g as u,h as ne,it as d,s as re,st as ie,v as f,y as p,z as m}from"./vue.runtime.esm-bundler-DmQNwI70.js";import{_ as h,g as ae,h as oe}from"./index-DAwT50Ss.js";var se={class:`sheet-head`},g={class:`add-project-body`},ce={key:0,class:`field`},le=[`value`],ue={class:`segmented segmented-sm`,role:`tablist`},de=[`aria-selected`],fe=[`aria-selected`],pe={key:1,class:`setting-note is-error`,role:`alert`},me={class:`field`},he=[`disabled`],ge={class:`form-actions`},_e=[`disabled`],ve={key:0,class:`add-project-suggestions`},ye={key:0,class:`subtle`},be=[`disabled`,`onClick`],_={class:`grow`},v={class:`row-title`},y={class:`row-sub mono`},b=[`disabled`],x={key:0,class:`add-project-suggestions`},S=[`onClick`],C={class:`grow`},w={class:`row-title`},T={key:0,class:`hs-tag`},E={key:0,class:`row-sub`},D={class:`field`},O=[`disabled`],k={class:`field`},A=[`disabled`],j={class:`segmented segmented-sm`},M={class:`form-actions`},N=[`disabled`],P=i({__name:`AddProjectDialog`,props:{hosts:{},initialHostId:{},api:{type:Function}},emits:[`close`,`added`],setup(i,{emit:P}){let F=i,I=P,L=d(null);ae(L,()=>I(`close`));let R=ne(()=>F.hosts.filter(e=>e.state===`connected`)),z=d(R.value.find(e=>e.id===F.initialHostId)?.id??R.value[0]?.id??``),B=d(`path`),V=d(``),H=d([]),U=d(!1),W=d(!1),G=d(``),K=d(``),q=d([]),J=d(!1),Y=d(``),X=d(``),Z=d(`ssh`);async function Q(){if(z.value){U.value=!0;try{let e=await F.api(`/hosts/${encodeURIComponent(z.value)}/project-suggestions`);H.value=(e.suggestions??[]).map(e=>({path:e.path??e.rootPath??e.cwd??``,name:e.name??e.displayName})).filter(e=>!!e.path)}catch{H.value=[]}finally{U.value=!1}}}te(z,()=>{H.value=[],Q()},{immediate:!0});async function $(e){let t=(e??V.value).trim();if(z.value&&t){W.value=!0,G.value=``;try{await F.api(`/hosts/${encodeURIComponent(z.value)}/projects`,`POST`,{cwd:t}),I(`added`,z.value,t),I(`close`)}catch(e){G.value=e.message||`Could not add project.`}finally{W.value=!1}}}async function xe(){if(z.value&&K.value.trim()){J.value=!0,G.value=``;try{let e=await F.api(`/hosts/${encodeURIComponent(z.value)}/github/search?q=${encodeURIComponent(K.value.trim())}`);q.value=(e.repositories??[]).map(e=>({fullName:e.fullName??e.nameWithOwner??e.repo??``,description:e.description??null,isPrivate:e.isPrivate===!0||e.private===!0})).filter(e=>!!e.fullName)}catch(e){G.value=e.message||`Could not search GitHub.`}finally{J.value=!1}}}async function Se(){if(z.value&&Y.value.trim()&&X.value.trim()){W.value=!0,G.value=``;try{let e=await F.api(`/hosts/${encodeURIComponent(z.value)}/projects/clone`,`POST`,{repo:Y.value.trim(),targetDirectory:X.value.trim(),cloneProtocol:Z.value},12e4);I(`added`,z.value,e.path||X.value.trim()),I(`close`)}catch(e){G.value=e.message||`Could not clone repository.`}finally{W.value=!1}}}return ee(()=>void Q()),(ee,i)=>(m(),p(`div`,{class:`overlay`,onMousedown:i[13]||=s(e=>I(`close`),[`self`])},[u(`section`,{ref_key:`sheet`,ref:L,class:`sheet add-project-sheet`,role:`dialog`,"aria-modal":`true`,"aria-label":`Add project`,tabindex:`-1`},[u(`header`,se,[i[14]||=u(`h2`,null,`Add project`,-1),u(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Close`,onClick:i[0]||=e=>I(`close`)},[e(h,{name:`close`,size:16})])]),u(`div`,g,[R.value.length>1?(m(),p(`label`,ce,[i[15]||=u(`span`,null,`Host`,-1),n(u(`select`,{"onUpdate:modelValue":i[1]||=e=>z.value=e},[(m(!0),p(l,null,t(R.value,e=>(m(),p(`option`,{key:e.id,value:e.id},c(e.label),9,le))),128))],512),[[re,z.value]])])):f(``,!0),u(`div`,ue,[u(`button`,{type:`button`,role:`tab`,"aria-selected":B.value===`path`,class:o({chosen:B.value===`path`}),onClick:i[2]||=e=>B.value=`path`},`Host directory`,10,de),u(`button`,{type:`button`,role:`tab`,"aria-selected":B.value===`github`,class:o({chosen:B.value===`github`}),onClick:i[3]||=e=>B.value=`github`},`Clone from GitHub`,10,fe)]),G.value?(m(),p(`p`,pe,c(G.value),1)):f(``,!0),B.value===`path`?(m(),p(l,{key:2},[u(`form`,{class:`add-project-form`,onSubmit:i[6]||=s(e=>$(),[`prevent`])},[u(`label`,me,[i[16]||=u(`span`,null,`Directory path on host`,-1),n(u(`input`,{"onUpdate:modelValue":i[4]||=e=>V.value=e,placeholder:`/home/user/code/my-repo`,disabled:W.value,autofocus:``},null,8,he),[[a,V.value]])]),u(`div`,ge,[u(`button`,{type:`button`,class:`btn btn-ghost`,onClick:i[5]||=e=>I(`close`)},`Cancel`),u(`button`,{type:`submit`,class:`btn btn-primary`,disabled:W.value||!V.value.trim()},c(W.value?`Adding…`:`Add project`),9,_e)])],32),H.value.length||U.value?(m(),p(`div`,ve,[i[19]||=u(`span`,{class:`subtle`},`Recent repositories on this host`,-1),U.value&&!H.value.length?(m(),p(`p`,ye,[...i[17]||=[u(`span`,{class:`spinner spinner-sm`},null,-1),r(` Loading…`,-1)]])):f(``,!0),(m(!0),p(l,null,t(H.value.slice(0,10),t=>(m(),p(`button`,{key:t.path,type:`button`,class:`suggestion-row`,disabled:W.value,onClick:e=>$(t.path)},[e(h,{name:`folder`,size:14}),u(`span`,_,[u(`span`,v,c(t.name||t.path.split(`/`).pop()),1),u(`span`,y,c(ie(oe)(t.path)),1)]),i[18]||=u(`span`,{class:`row-sub`},`Add`,-1)],8,be))),128))])):f(``,!0)],64)):(m(),p(l,{key:3},[u(`form`,{class:`archived-search`,onSubmit:s(xe,[`prevent`])},[n(u(`input`,{"onUpdate:modelValue":i[7]||=e=>K.value=e,placeholder:`Search GitHub repos (owner/name or keyword)…`},null,512),[[a,K.value]]),u(`button`,{type:`submit`,class:`btn btn-sm btn-outline`,disabled:J.value||!K.value.trim()},c(J.value?`Searching…`:`Search`),9,b)],32),q.value.length?(m(),p(`div`,x,[(m(!0),p(l,null,t(q.value,t=>(m(),p(`button`,{key:t.fullName,type:`button`,class:o([`suggestion-row`,{chosen:Y.value===t.fullName}]),onClick:e=>Y.value=t.fullName},[e(h,{name:`branch`,size:14}),u(`span`,C,[u(`span`,w,[r(c(t.fullName)+` `,1),t.isPrivate?(m(),p(`small`,T,`private`)):f(``,!0)]),t.description?(m(),p(`span`,E,c(t.description),1)):f(``,!0)])],10,S))),128))])):f(``,!0),u(`form`,{class:`add-project-form`,onSubmit:s(Se,[`prevent`])},[u(`label`,D,[i[20]||=u(`span`,null,`Repository (owner/repo)`,-1),n(u(`input`,{"onUpdate:modelValue":i[8]||=e=>Y.value=e,placeholder:`owner/repo`,disabled:W.value},null,8,O),[[a,Y.value]])]),u(`label`,k,[i[21]||=u(`span`,null,`Target directory on host`,-1),n(u(`input`,{"onUpdate:modelValue":i[9]||=e=>X.value=e,placeholder:`/home/user/code/repo`,disabled:W.value},null,8,A),[[a,X.value]])]),u(`div`,j,[u(`button`,{type:`button`,class:o({chosen:Z.value===`ssh`}),onClick:i[10]||=e=>Z.value=`ssh`},`SSH`,2),u(`button`,{type:`button`,class:o({chosen:Z.value===`https`}),onClick:i[11]||=e=>Z.value=`https`},`HTTPS`,2)]),u(`div`,M,[u(`button`,{type:`button`,class:`btn btn-ghost`,onClick:i[12]||=e=>I(`close`)},`Cancel`),u(`button`,{type:`submit`,class:`btn btn-primary`,disabled:W.value||!Y.value.trim()||!X.value.trim()},c(W.value?`Cloning…`:`Clone & add`),9,N)])],32)],64))])],512)],32))}});export{P as default};
1
+ import{C as e,H as t,I as ee,Q as n,S as r,T as i,Y as te,c as a,ct as o,d as s,dt as c,f as l,g as u,h as ne,it as d,s as re,st as ie,v as f,y as p,z as m}from"./vue.runtime.esm-bundler-DmQNwI70.js";import{_ as h,g as ae,h as oe}from"./index-DZm2Vxoh.js";var se={class:`sheet-head`},g={class:`add-project-body`},ce={key:0,class:`field`},le=[`value`],ue={class:`segmented segmented-sm`,role:`tablist`},de=[`aria-selected`],fe=[`aria-selected`],pe={key:1,class:`setting-note is-error`,role:`alert`},me={class:`field`},he=[`disabled`],ge={class:`form-actions`},_e=[`disabled`],ve={key:0,class:`add-project-suggestions`},ye={key:0,class:`subtle`},be=[`disabled`,`onClick`],_={class:`grow`},v={class:`row-title`},y={class:`row-sub mono`},b=[`disabled`],x={key:0,class:`add-project-suggestions`},S=[`onClick`],C={class:`grow`},w={class:`row-title`},T={key:0,class:`hs-tag`},E={key:0,class:`row-sub`},D={class:`field`},O=[`disabled`],k={class:`field`},A=[`disabled`],j={class:`segmented segmented-sm`},M={class:`form-actions`},N=[`disabled`],P=i({__name:`AddProjectDialog`,props:{hosts:{},initialHostId:{},api:{type:Function}},emits:[`close`,`added`],setup(i,{emit:P}){let F=i,I=P,L=d(null);ae(L,()=>I(`close`));let R=ne(()=>F.hosts.filter(e=>e.state===`connected`)),z=d(R.value.find(e=>e.id===F.initialHostId)?.id??R.value[0]?.id??``),B=d(`path`),V=d(``),H=d([]),U=d(!1),W=d(!1),G=d(``),K=d(``),q=d([]),J=d(!1),Y=d(``),X=d(``),Z=d(`ssh`);async function Q(){if(z.value){U.value=!0;try{let e=await F.api(`/hosts/${encodeURIComponent(z.value)}/project-suggestions`);H.value=(e.suggestions??[]).map(e=>({path:e.path??e.rootPath??e.cwd??``,name:e.name??e.displayName})).filter(e=>!!e.path)}catch{H.value=[]}finally{U.value=!1}}}te(z,()=>{H.value=[],Q()},{immediate:!0});async function $(e){let t=(e??V.value).trim();if(z.value&&t){W.value=!0,G.value=``;try{await F.api(`/hosts/${encodeURIComponent(z.value)}/projects`,`POST`,{cwd:t}),I(`added`,z.value,t),I(`close`)}catch(e){G.value=e.message||`Could not add project.`}finally{W.value=!1}}}async function xe(){if(z.value&&K.value.trim()){J.value=!0,G.value=``;try{let e=await F.api(`/hosts/${encodeURIComponent(z.value)}/github/search?q=${encodeURIComponent(K.value.trim())}`);q.value=(e.repositories??[]).map(e=>({fullName:e.fullName??e.nameWithOwner??e.repo??``,description:e.description??null,isPrivate:e.isPrivate===!0||e.private===!0})).filter(e=>!!e.fullName)}catch(e){G.value=e.message||`Could not search GitHub.`}finally{J.value=!1}}}async function Se(){if(z.value&&Y.value.trim()&&X.value.trim()){W.value=!0,G.value=``;try{let e=await F.api(`/hosts/${encodeURIComponent(z.value)}/projects/clone`,`POST`,{repo:Y.value.trim(),targetDirectory:X.value.trim(),cloneProtocol:Z.value},12e4);I(`added`,z.value,e.path||X.value.trim()),I(`close`)}catch(e){G.value=e.message||`Could not clone repository.`}finally{W.value=!1}}}return ee(()=>void Q()),(ee,i)=>(m(),p(`div`,{class:`overlay`,onMousedown:i[13]||=s(e=>I(`close`),[`self`])},[u(`section`,{ref_key:`sheet`,ref:L,class:`sheet add-project-sheet`,role:`dialog`,"aria-modal":`true`,"aria-label":`Add project`,tabindex:`-1`},[u(`header`,se,[i[14]||=u(`h2`,null,`Add project`,-1),u(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Close`,onClick:i[0]||=e=>I(`close`)},[e(h,{name:`close`,size:16})])]),u(`div`,g,[R.value.length>1?(m(),p(`label`,ce,[i[15]||=u(`span`,null,`Host`,-1),n(u(`select`,{"onUpdate:modelValue":i[1]||=e=>z.value=e},[(m(!0),p(l,null,t(R.value,e=>(m(),p(`option`,{key:e.id,value:e.id},c(e.label),9,le))),128))],512),[[re,z.value]])])):f(``,!0),u(`div`,ue,[u(`button`,{type:`button`,role:`tab`,"aria-selected":B.value===`path`,class:o({chosen:B.value===`path`}),onClick:i[2]||=e=>B.value=`path`},`Host directory`,10,de),u(`button`,{type:`button`,role:`tab`,"aria-selected":B.value===`github`,class:o({chosen:B.value===`github`}),onClick:i[3]||=e=>B.value=`github`},`Clone from GitHub`,10,fe)]),G.value?(m(),p(`p`,pe,c(G.value),1)):f(``,!0),B.value===`path`?(m(),p(l,{key:2},[u(`form`,{class:`add-project-form`,onSubmit:i[6]||=s(e=>$(),[`prevent`])},[u(`label`,me,[i[16]||=u(`span`,null,`Directory path on host`,-1),n(u(`input`,{"onUpdate:modelValue":i[4]||=e=>V.value=e,placeholder:`/home/user/code/my-repo`,disabled:W.value,autofocus:``},null,8,he),[[a,V.value]])]),u(`div`,ge,[u(`button`,{type:`button`,class:`btn btn-ghost`,onClick:i[5]||=e=>I(`close`)},`Cancel`),u(`button`,{type:`submit`,class:`btn btn-primary`,disabled:W.value||!V.value.trim()},c(W.value?`Adding…`:`Add project`),9,_e)])],32),H.value.length||U.value?(m(),p(`div`,ve,[i[19]||=u(`span`,{class:`subtle`},`Recent repositories on this host`,-1),U.value&&!H.value.length?(m(),p(`p`,ye,[...i[17]||=[u(`span`,{class:`spinner spinner-sm`},null,-1),r(` Loading…`,-1)]])):f(``,!0),(m(!0),p(l,null,t(H.value.slice(0,10),t=>(m(),p(`button`,{key:t.path,type:`button`,class:`suggestion-row`,disabled:W.value,onClick:e=>$(t.path)},[e(h,{name:`folder`,size:14}),u(`span`,_,[u(`span`,v,c(t.name||t.path.split(`/`).pop()),1),u(`span`,y,c(ie(oe)(t.path)),1)]),i[18]||=u(`span`,{class:`row-sub`},`Add`,-1)],8,be))),128))])):f(``,!0)],64)):(m(),p(l,{key:3},[u(`form`,{class:`archived-search`,onSubmit:s(xe,[`prevent`])},[n(u(`input`,{"onUpdate:modelValue":i[7]||=e=>K.value=e,placeholder:`Search GitHub repos (owner/name or keyword)…`},null,512),[[a,K.value]]),u(`button`,{type:`submit`,class:`btn btn-sm btn-outline`,disabled:J.value||!K.value.trim()},c(J.value?`Searching…`:`Search`),9,b)],32),q.value.length?(m(),p(`div`,x,[(m(!0),p(l,null,t(q.value,t=>(m(),p(`button`,{key:t.fullName,type:`button`,class:o([`suggestion-row`,{chosen:Y.value===t.fullName}]),onClick:e=>Y.value=t.fullName},[e(h,{name:`branch`,size:14}),u(`span`,C,[u(`span`,w,[r(c(t.fullName)+` `,1),t.isPrivate?(m(),p(`small`,T,`private`)):f(``,!0)]),t.description?(m(),p(`span`,E,c(t.description),1)):f(``,!0)])],10,S))),128))])):f(``,!0),u(`form`,{class:`add-project-form`,onSubmit:s(Se,[`prevent`])},[u(`label`,D,[i[20]||=u(`span`,null,`Repository (owner/repo)`,-1),n(u(`input`,{"onUpdate:modelValue":i[8]||=e=>Y.value=e,placeholder:`owner/repo`,disabled:W.value},null,8,O),[[a,Y.value]])]),u(`label`,k,[i[21]||=u(`span`,null,`Target directory on host`,-1),n(u(`input`,{"onUpdate:modelValue":i[9]||=e=>X.value=e,placeholder:`/home/user/code/repo`,disabled:W.value},null,8,A),[[a,X.value]])]),u(`div`,j,[u(`button`,{type:`button`,class:o({chosen:Z.value===`ssh`}),onClick:i[10]||=e=>Z.value=`ssh`},`SSH`,2),u(`button`,{type:`button`,class:o({chosen:Z.value===`https`}),onClick:i[11]||=e=>Z.value=`https`},`HTTPS`,2)]),u(`div`,M,[u(`button`,{type:`button`,class:`btn btn-ghost`,onClick:i[12]||=e=>I(`close`)},`Cancel`),u(`button`,{type:`submit`,class:`btn btn-primary`,disabled:W.value||!Y.value.trim()||!X.value.trim()},c(W.value?`Cloning…`:`Clone & add`),9,N)])],32)],64))])],512)],32))}});export{P as default};
@@ -1 +1 @@
1
- import{C as e,H as t,I as n,Q as r,S as i,T as a,c as o,d as s,dt as c,f as l,g as u,h as d,it as f,v as p,y as m,z as h}from"./vue.runtime.esm-bundler-DmQNwI70.js";import{_ as g,g as _,t as v}from"./index-DAwT50Ss.js";var y={class:`sheet-head`},b={class:`archived-search`},x=[`disabled`],S={key:0,class:`setting-note is-error`,role:`alert`},C={class:`archived-list`},w={key:0,class:`subtle archived-empty`},T={key:1,class:`subtle archived-empty`},E={class:`grow`},D={class:`row-title`},O={class:`row-sub`},k=[`disabled`,`onClick`],A=a({__name:`ArchivedWorkspaces`,props:{hosts:{},api:{type:Function}},emits:[`close`,`restored`],setup(a,{emit:A}){let j=a,M=A,N=f(null);_(N,()=>M(`close`));let P=f(``),F=f([]),I=f(!1),L=f(``),R=f(null),z=d(()=>new Map(j.hosts.map(e=>[e.id,e.label])));async function B(){I.value=!0,L.value=``;let e=j.hosts.filter(e=>e.state===`connected`);try{let t=await Promise.allSettled(e.map(e=>{let t=P.value.trim()?`?q=${encodeURIComponent(P.value.trim())}`:``;return j.api(`/hosts/${encodeURIComponent(e.id)}/archived-workspaces${t}`)})),n=[];for(let e of t)e.status===`fulfilled`&&Array.isArray(e.value)&&n.push(...e.value);n.sort((e,t)=>Date.parse(t.archivedAt)-Date.parse(e.archivedAt)),F.value=n}catch(e){L.value=e.message||`Could not load archived workspaces.`}finally{I.value=!1}}async function V(e){if(!e.workspaceId)return;let t=`${e.hostId}:${e.workspaceId}`;R.value=t,L.value=``;try{await j.api(`/hosts/${encodeURIComponent(e.hostId)}/workspaces/${encodeURIComponent(e.workspaceId)}/restore`,`POST`,{}),F.value=F.value.filter(t=>t.hostId!==e.hostId||t.workspaceId!==e.workspaceId),M(`restored`,e.hostId,e.workspaceId)}catch(e){L.value=e.message||`Could not restore workspace.`}finally{R.value=null}}function H(e){let t=Math.max(0,(Date.now()-Date.parse(e))/1e3);return t<90?`just now`:t<3600?Math.round(t/60)+`m ago`:t<86400?Math.round(t/3600)+`h ago`:Math.round(t/86400)+`d ago`}return n(()=>void B()),(n,d)=>(h(),m(`div`,{class:`overlay`,onMousedown:d[2]||=s(e=>M(`close`),[`self`])},[u(`section`,{ref_key:`sheet`,ref:N,class:`sheet archived-sheet`,role:`dialog`,"aria-modal":`true`,"aria-label":`Archived workspaces`,tabindex:`-1`},[u(`header`,y,[d[3]||=u(`h2`,null,`Archived workspaces`,-1),u(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Close`,onClick:d[0]||=e=>M(`close`)},[e(g,{name:`close`,size:16})])]),u(`div`,b,[u(`form`,{onSubmit:s(B,[`prevent`])},[r(u(`input`,{"onUpdate:modelValue":d[1]||=e=>P.value=e,type:`search`,placeholder:`Search archived workspaces…`,"aria-label":`Search archived workspaces`},null,512),[[o,P.value]]),u(`button`,{type:`submit`,class:`btn btn-sm btn-outline`,disabled:I.value},c(I.value?`Loading…`:`Search`),9,x)],32)]),L.value?(h(),m(`p`,S,c(L.value),1)):p(``,!0),u(`div`,C,[I.value&&!F.value.length?(h(),m(`p`,w,[...d[4]||=[u(`span`,{class:`spinner spinner-sm`},null,-1),i(` Loading archived workspaces…`,-1)]])):F.value.length?p(``,!0):(h(),m(`p`,T,`No archived workspaces found.`)),(h(!0),m(l,null,t(F.value,t=>(h(),m(`div`,{key:t.hostId+`:`+(t.workspaceId||t.id),class:`archived-row`},[e(v,{provider:t.provider},null,8,[`provider`]),u(`div`,E,[u(`div`,D,c(t.name),1),u(`div`,O,[i(c(t.project)+` `,1),a.hosts.length>1?(h(),m(l,{key:0},[i(` · `+c(z.value.get(t.hostId)||t.hostId),1)],64)):p(``,!0),i(` · archived `+c(H(t.archivedAt)),1)])]),t.workspaceId?(h(),m(`button`,{key:0,type:`button`,class:`btn btn-sm btn-outline`,disabled:R.value===t.hostId+`:`+t.workspaceId,onClick:e=>V(t)},[e(g,{name:`undo`,size:13}),i(c(R.value===t.hostId+`:`+t.workspaceId?`Restoring…`:`Restore`),1)],8,k)):p(``,!0)]))),128))])],512)],32))}});export{A as default};
1
+ import{C as e,H as t,I as n,Q as r,S as i,T as a,c as o,d as s,dt as c,f as l,g as u,h as d,it as f,v as p,y as m,z as h}from"./vue.runtime.esm-bundler-DmQNwI70.js";import{_ as g,g as _,t as v}from"./index-DZm2Vxoh.js";var y={class:`sheet-head`},b={class:`archived-search`},x=[`disabled`],S={key:0,class:`setting-note is-error`,role:`alert`},C={class:`archived-list`},w={key:0,class:`subtle archived-empty`},T={key:1,class:`subtle archived-empty`},E={class:`grow`},D={class:`row-title`},O={class:`row-sub`},k=[`disabled`,`onClick`],A=a({__name:`ArchivedWorkspaces`,props:{hosts:{},api:{type:Function}},emits:[`close`,`restored`],setup(a,{emit:A}){let j=a,M=A,N=f(null);_(N,()=>M(`close`));let P=f(``),F=f([]),I=f(!1),L=f(``),R=f(null),z=d(()=>new Map(j.hosts.map(e=>[e.id,e.label])));async function B(){I.value=!0,L.value=``;let e=j.hosts.filter(e=>e.state===`connected`);try{let t=await Promise.allSettled(e.map(e=>{let t=P.value.trim()?`?q=${encodeURIComponent(P.value.trim())}`:``;return j.api(`/hosts/${encodeURIComponent(e.id)}/archived-workspaces${t}`)})),n=[];for(let e of t)e.status===`fulfilled`&&Array.isArray(e.value)&&n.push(...e.value);n.sort((e,t)=>Date.parse(t.archivedAt)-Date.parse(e.archivedAt)),F.value=n}catch(e){L.value=e.message||`Could not load archived workspaces.`}finally{I.value=!1}}async function V(e){if(!e.workspaceId)return;let t=`${e.hostId}:${e.workspaceId}`;R.value=t,L.value=``;try{await j.api(`/hosts/${encodeURIComponent(e.hostId)}/workspaces/${encodeURIComponent(e.workspaceId)}/restore`,`POST`,{}),F.value=F.value.filter(t=>t.hostId!==e.hostId||t.workspaceId!==e.workspaceId),M(`restored`,e.hostId,e.workspaceId)}catch(e){L.value=e.message||`Could not restore workspace.`}finally{R.value=null}}function H(e){let t=Math.max(0,(Date.now()-Date.parse(e))/1e3);return t<90?`just now`:t<3600?Math.round(t/60)+`m ago`:t<86400?Math.round(t/3600)+`h ago`:Math.round(t/86400)+`d ago`}return n(()=>void B()),(n,d)=>(h(),m(`div`,{class:`overlay`,onMousedown:d[2]||=s(e=>M(`close`),[`self`])},[u(`section`,{ref_key:`sheet`,ref:N,class:`sheet archived-sheet`,role:`dialog`,"aria-modal":`true`,"aria-label":`Archived workspaces`,tabindex:`-1`},[u(`header`,y,[d[3]||=u(`h2`,null,`Archived workspaces`,-1),u(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Close`,onClick:d[0]||=e=>M(`close`)},[e(g,{name:`close`,size:16})])]),u(`div`,b,[u(`form`,{onSubmit:s(B,[`prevent`])},[r(u(`input`,{"onUpdate:modelValue":d[1]||=e=>P.value=e,type:`search`,placeholder:`Search archived workspaces…`,"aria-label":`Search archived workspaces`},null,512),[[o,P.value]]),u(`button`,{type:`submit`,class:`btn btn-sm btn-outline`,disabled:I.value},c(I.value?`Loading…`:`Search`),9,x)],32)]),L.value?(h(),m(`p`,S,c(L.value),1)):p(``,!0),u(`div`,C,[I.value&&!F.value.length?(h(),m(`p`,w,[...d[4]||=[u(`span`,{class:`spinner spinner-sm`},null,-1),i(` Loading archived workspaces…`,-1)]])):F.value.length?p(``,!0):(h(),m(`p`,T,`No archived workspaces found.`)),(h(!0),m(l,null,t(F.value,t=>(h(),m(`div`,{key:t.hostId+`:`+(t.workspaceId||t.id),class:`archived-row`},[e(v,{provider:t.provider},null,8,[`provider`]),u(`div`,E,[u(`div`,D,c(t.name),1),u(`div`,O,[i(c(t.project)+` `,1),a.hosts.length>1?(h(),m(l,{key:0},[i(` · `+c(z.value.get(t.hostId)||t.hostId),1)],64)):p(``,!0),i(` · archived `+c(H(t.archivedAt)),1)])]),t.workspaceId?(h(),m(`button`,{key:0,type:`button`,class:`btn btn-sm btn-outline`,disabled:R.value===t.hostId+`:`+t.workspaceId,onClick:e=>V(t)},[e(g,{name:`undo`,size:13}),i(c(R.value===t.hostId+`:`+t.workspaceId?`Restoring…`:`Restore`),1)],8,k)):p(``,!0)]))),128))])],512)],32))}});export{A as default};
@@ -1,3 +1,3 @@
1
- import{C as e,H as t,L as n,Q as r,S as i,T as a,Y as o,c as s,ct as c,d as l,dt as u,f as d,g as f,h as ee,it as p,u as te,v as m,y as h,z as g}from"./vue.runtime.esm-bundler-DmQNwI70.js";import{_,m as v}from"./index-DAwT50Ss.js";var ne={class:`changes-panel`},re={class:`changes-top`},ie={class:`segmented segmented-sm`,role:`tablist`},ae=[`aria-selected`],oe=[`aria-selected`],se={key:0,class:`segmented segmented-sm`,role:`radiogroup`,"aria-label":`Compare mode`},ce=[`disabled`],le={key:0,class:`base-bar`},ue=[`onKeydown`],de={class:`row-sub`},fe={key:1,class:`pr-bar`},pe=[`href`],me={class:`pr-title`},he={class:`git-actions`},ge=[`disabled`],_e=[`disabled`],ve=[`disabled`],ye=[`disabled`],be={class:`form-actions`},xe=[`disabled`],Se=[`disabled`],Ce=[`disabled`],we={class:`form-actions`},Te=[`disabled`],Ee={key:4,class:`setting-note`,role:`status`},De={key:5,class:`setting-note is-error`,role:`alert`},Oe={key:6,class:`review-tray`,role:`region`,"aria-label":`Pending review comments`},ke={class:`review-tray-head`},Ae={class:`grow`},je=[`onClick`],Me={key:0,class:`row-sub`},Ne={key:1,class:`row-sub`},Pe=[`onToggle`],Fe={class:`file-sum-path`},Ie={class:`file-sum-stat`},Le={class:`stat-add`},Re={class:`stat-del`},ze={class:`file-bar`},Be=[`onClick`],Ve=[`onClick`],He=[`onSubmit`],Ue={class:`form-actions`},We=[`disabled`],Ge={key:1,class:`row-sub`},Ke={key:2,class:`row-sub`},qe={class:`hunk`},Je=[`onClick`],Ye={class:`diff-code`},Xe=[`onSubmit`],Ze={class:`form-actions`},Qe=[`disabled`],$e={key:0,class:`row-sub`},et={key:1,class:`row-sub`},tt={class:`commit-sha`},nt={class:`commit-subj`},rt={key:0,class:`hs-tag`},it={class:`row-sub`},at=[`onToggle`],ot={class:`file-sum-stat`},st={class:`stat-add`},ct={class:`stat-del`},lt={key:0,class:`row-sub`},ut={key:1,class:`setting-note is-error`},dt={class:`hunk`},y=v(a({__name:`ChangesPanel`,props:{hostId:{},cwd:{},workspaceId:{},api:{type:Function}},emits:[`sendReview`],setup(a,{emit:v}){let y=a,ft=v,b=p(`diff`),x=p(`uncommitted`),S=p(``),C=p(!1),w=p(``),T=p([]),E=p(``),D=p(``),O=p(!1),k=p(!1),A=0,j=p(new Set),M=p([]),N=p(!1),P=p({}),F=p(null),I=p(!1),L=p(!1),R=p(``),z=p(!1),B=p(``),V=p(``),H=p([]),U=p(null),W=p(``),pt=0;n(()=>A++);let G=()=>`/hosts/${encodeURIComponent(y.hostId)}`;async function K(){let e=++A;O.value=!0,E.value=``,T.value=[],k.value=!1,j.value=new Set;try{let t=new URLSearchParams({cwd:y.cwd,mode:x.value});x.value===`base`&&S.value.trim()&&t.set(`baseRef`,S.value.trim());let n=await y.api(`${G()}/changes?${t}`);if(e!==A)return;T.value=n.files??[],k.value=!!n.diffTooLarge,n.baseRef&&!S.value&&(S.value=n.baseRef)}catch(t){e===A&&(E.value=t.message)}finally{e===A&&(O.value=!1)}}async function q(){try{F.value=await y.api(`${G()}/git/pr-status?cwd=${encodeURIComponent(y.cwd)}`)}catch{F.value=null}}async function J(){N.value=!0,E.value=``;try{let e=await y.api(`${G()}/git/commits?cwd=${encodeURIComponent(y.cwd)}`);M.value=e.commits??[],e.baseRef&&!S.value&&(S.value=e.baseRef)}catch(e){E.value=e.message}finally{N.value=!1}}async function mt(e,t){let n=`${e}:${t}`;if(!P.value[n])try{let r=await y.api(`${G()}/git/commit-diff?cwd=${encodeURIComponent(y.cwd)}&sha=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`);P.value[n]=r.file??{status:`empty`,hunks:[]}}catch(e){P.value[n]={error:e.message}}}async function Y(){let e=w.value.trim();if(e){if(C.value=!1,S.value=e,y.workspaceId)try{await y.api(`${G()}/workspaces/${encodeURIComponent(y.workspaceId)}/base-branch`,`POST`,{baseRef:e})}catch{}x.value===`base`&&K()}}async function ht(){I.value=!0,E.value=D.value=``;try{await y.api(`${G()}/git/commit`,`POST`,{cwd:y.cwd,message:R.value.trim()||void 0,addAll:!0},6e4),R.value=``,L.value=!1,D.value=`Committed changes.`,await Promise.all([K(),q(),b.value===`commits`?J():Promise.resolve()])}catch(e){E.value=e.message}finally{I.value=!1}}async function X(){I.value=!0,E.value=D.value=``;try{await y.api(`${G()}/git/push`,`POST`,{cwd:y.cwd},6e4),D.value=`Pushed to remote.`,await q()}catch(e){E.value=e.message}finally{I.value=!1}}async function gt(){I.value=!0,E.value=D.value=``;try{let e=await y.api(`${G()}/git/pr`,`POST`,{cwd:y.cwd,title:B.value.trim()||void 0,body:V.value.trim()||void 0,baseRef:S.value.trim()||void 0},6e4);z.value=!1,B.value=V.value=``,D.value=e.url?`PR created: ${e.url}`:`PR created.`,await q()}catch(e){E.value=e.message}finally{I.value=!1}}async function _t(e){try{await navigator.clipboard.writeText(e)}catch{E.value=`Could not copy path.`}}function Z(e,t){let n=`${e}::${t}`;U.value===n?U.value=null:(U.value=n,W.value=``)}function Q(e,t){let n=W.value.trim();n&&(H.value.push({id:`c-${++pt}`,path:e,line:t,text:n}),W.value=``,U.value=null)}function vt(e){H.value=H.value.filter(t=>t.id!==e)}function yt(){if(!H.value.length)return;let e=[`Please address the following code review comments:`,``,...H.value.map((e,t)=>`${t+1}. \`${e.path}\` (${e.line}): ${e.text}`)];ft(`sendReview`,e.join(`
1
+ import{C as e,H as t,L as n,Q as r,S as i,T as a,Y as o,c as s,ct as c,d as l,dt as u,f as d,g as f,h as ee,it as p,u as te,v as m,y as h,z as g}from"./vue.runtime.esm-bundler-DmQNwI70.js";import{_,m as v}from"./index-DZm2Vxoh.js";var ne={class:`changes-panel`},re={class:`changes-top`},ie={class:`segmented segmented-sm`,role:`tablist`},ae=[`aria-selected`],oe=[`aria-selected`],se={key:0,class:`segmented segmented-sm`,role:`radiogroup`,"aria-label":`Compare mode`},ce=[`disabled`],le={key:0,class:`base-bar`},ue=[`onKeydown`],de={class:`row-sub`},fe={key:1,class:`pr-bar`},pe=[`href`],me={class:`pr-title`},he={class:`git-actions`},ge=[`disabled`],_e=[`disabled`],ve=[`disabled`],ye=[`disabled`],be={class:`form-actions`},xe=[`disabled`],Se=[`disabled`],Ce=[`disabled`],we={class:`form-actions`},Te=[`disabled`],Ee={key:4,class:`setting-note`,role:`status`},De={key:5,class:`setting-note is-error`,role:`alert`},Oe={key:6,class:`review-tray`,role:`region`,"aria-label":`Pending review comments`},ke={class:`review-tray-head`},Ae={class:`grow`},je=[`onClick`],Me={key:0,class:`row-sub`},Ne={key:1,class:`row-sub`},Pe=[`onToggle`],Fe={class:`file-sum-path`},Ie={class:`file-sum-stat`},Le={class:`stat-add`},Re={class:`stat-del`},ze={class:`file-bar`},Be=[`onClick`],Ve=[`onClick`],He=[`onSubmit`],Ue={class:`form-actions`},We=[`disabled`],Ge={key:1,class:`row-sub`},Ke={key:2,class:`row-sub`},qe={class:`hunk`},Je=[`onClick`],Ye={class:`diff-code`},Xe=[`onSubmit`],Ze={class:`form-actions`},Qe=[`disabled`],$e={key:0,class:`row-sub`},et={key:1,class:`row-sub`},tt={class:`commit-sha`},nt={class:`commit-subj`},rt={key:0,class:`hs-tag`},it={class:`row-sub`},at=[`onToggle`],ot={class:`file-sum-stat`},st={class:`stat-add`},ct={class:`stat-del`},lt={key:0,class:`row-sub`},ut={key:1,class:`setting-note is-error`},dt={class:`hunk`},y=v(a({__name:`ChangesPanel`,props:{hostId:{},cwd:{},workspaceId:{},api:{type:Function}},emits:[`sendReview`],setup(a,{emit:v}){let y=a,ft=v,b=p(`diff`),x=p(`uncommitted`),S=p(``),C=p(!1),w=p(``),T=p([]),E=p(``),D=p(``),O=p(!1),k=p(!1),A=0,j=p(new Set),M=p([]),N=p(!1),P=p({}),F=p(null),I=p(!1),L=p(!1),R=p(``),z=p(!1),B=p(``),V=p(``),H=p([]),U=p(null),W=p(``),pt=0;n(()=>A++);let G=()=>`/hosts/${encodeURIComponent(y.hostId)}`;async function K(){let e=++A;O.value=!0,E.value=``,T.value=[],k.value=!1,j.value=new Set;try{let t=new URLSearchParams({cwd:y.cwd,mode:x.value});x.value===`base`&&S.value.trim()&&t.set(`baseRef`,S.value.trim());let n=await y.api(`${G()}/changes?${t}`);if(e!==A)return;T.value=n.files??[],k.value=!!n.diffTooLarge,n.baseRef&&!S.value&&(S.value=n.baseRef)}catch(t){e===A&&(E.value=t.message)}finally{e===A&&(O.value=!1)}}async function q(){try{F.value=await y.api(`${G()}/git/pr-status?cwd=${encodeURIComponent(y.cwd)}`)}catch{F.value=null}}async function J(){N.value=!0,E.value=``;try{let e=await y.api(`${G()}/git/commits?cwd=${encodeURIComponent(y.cwd)}`);M.value=e.commits??[],e.baseRef&&!S.value&&(S.value=e.baseRef)}catch(e){E.value=e.message}finally{N.value=!1}}async function mt(e,t){let n=`${e}:${t}`;if(!P.value[n])try{let r=await y.api(`${G()}/git/commit-diff?cwd=${encodeURIComponent(y.cwd)}&sha=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`);P.value[n]=r.file??{status:`empty`,hunks:[]}}catch(e){P.value[n]={error:e.message}}}async function Y(){let e=w.value.trim();if(e){if(C.value=!1,S.value=e,y.workspaceId)try{await y.api(`${G()}/workspaces/${encodeURIComponent(y.workspaceId)}/base-branch`,`POST`,{baseRef:e})}catch{}x.value===`base`&&K()}}async function ht(){I.value=!0,E.value=D.value=``;try{await y.api(`${G()}/git/commit`,`POST`,{cwd:y.cwd,message:R.value.trim()||void 0,addAll:!0},6e4),R.value=``,L.value=!1,D.value=`Committed changes.`,await Promise.all([K(),q(),b.value===`commits`?J():Promise.resolve()])}catch(e){E.value=e.message}finally{I.value=!1}}async function X(){I.value=!0,E.value=D.value=``;try{await y.api(`${G()}/git/push`,`POST`,{cwd:y.cwd},6e4),D.value=`Pushed to remote.`,await q()}catch(e){E.value=e.message}finally{I.value=!1}}async function gt(){I.value=!0,E.value=D.value=``;try{let e=await y.api(`${G()}/git/pr`,`POST`,{cwd:y.cwd,title:B.value.trim()||void 0,body:V.value.trim()||void 0,baseRef:S.value.trim()||void 0},6e4);z.value=!1,B.value=V.value=``,D.value=e.url?`PR created: ${e.url}`:`PR created.`,await q()}catch(e){E.value=e.message}finally{I.value=!1}}async function _t(e){try{await navigator.clipboard.writeText(e)}catch{E.value=`Could not copy path.`}}function Z(e,t){let n=`${e}::${t}`;U.value===n?U.value=null:(U.value=n,W.value=``)}function Q(e,t){let n=W.value.trim();n&&(H.value.push({id:`c-${++pt}`,path:e,line:t,text:n}),W.value=``,U.value=null)}function vt(e){H.value=H.value.filter(t=>t.id!==e)}function yt(){if(!H.value.length)return;let e=[`Please address the following code review comments:`,``,...H.value.map((e,t)=>`${t+1}. \`${e.path}\` (${e.line}): ${e.text}`)];ft(`sendReview`,e.join(`
2
2
  `)),H.value=[]}let $=ee(()=>{let e=F.value;if(!e||!e.pr)return null;let t=Array.isArray(e.checks)?e.checks:[],n=t.filter(e=>e.conclusion===`failure`||e.state===`failure`).length,r=t.filter(e=>e.status===`in_progress`||e.status===`queued`||e.state===`pending`).length,i=t.length-n-r;return{pr:e.pr,checksCount:t.length,failed:n,pending:r,passed:i}});return o(()=>[y.hostId,y.cwd],()=>{T.value=[],M.value=[],P.value={},H.value=[],F.value=null,K(),q()},{immediate:!0}),o(x,()=>{b.value===`diff`&&K()}),o(b,e=>{e===`commits`&&!M.value.length&&J()}),(n,a)=>(g(),h(`section`,ne,[f(`div`,re,[f(`div`,ie,[f(`button`,{type:`button`,role:`tab`,"aria-selected":b.value===`diff`,class:c({chosen:b.value===`diff`}),onClick:a[0]||=e=>b.value=`diff`},`Diff`,10,ae),f(`button`,{type:`button`,role:`tab`,"aria-selected":b.value===`commits`,class:c({chosen:b.value===`commits`}),onClick:a[1]||=e=>b.value=`commits`},`Commits`,10,oe)]),b.value===`diff`?(g(),h(`div`,se,[f(`button`,{type:`button`,class:c({chosen:x.value===`uncommitted`}),onClick:a[2]||=e=>x.value=`uncommitted`},`Uncommitted`,2),f(`button`,{type:`button`,class:c({chosen:x.value===`base`}),onClick:a[3]||=e=>x.value=`base`},`vs `+u(S.value||`Base`),3)])):m(``,!0),f(`button`,{type:`button`,class:`icon-btn`,disabled:O.value||N.value,title:`Refresh`,"aria-label":`Refresh changes`,onClick:a[4]||=e=>{b.value===`diff`?K():J(),q()}},[e(_,{name:`refresh`,size:14})],8,ce)]),b.value===`diff`&&x.value===`base`?(g(),h(`div`,le,[C.value?(g(),h(d,{key:0},[r(f(`input`,{"onUpdate:modelValue":a[5]||=e=>w.value=e,placeholder:`main`,"aria-label":`Base branch`,onKeydown:te(l(Y,[`prevent`]),[`enter`])},null,40,ue),[[s,w.value]]),f(`button`,{type:`button`,class:`btn btn-sm btn-primary`,onClick:Y},`Set`),f(`button`,{type:`button`,class:`btn btn-sm btn-ghost`,onClick:a[6]||=e=>C.value=!1},`Cancel`)],64)):(g(),h(d,{key:1},[f(`span`,de,[a[19]||=i(`Base: `,-1),f(`code`,null,u(S.value||`default`),1)]),f(`button`,{type:`button`,class:`link-btn`,onClick:a[7]||=e=>{w.value=S.value,C.value=!0}},`Change base`)],64))])):m(``,!0),$.value?(g(),h(`div`,fe,[f(`a`,{href:$.value.pr.url,target:`_blank`,rel:`noopener noreferrer`,class:`pr-link`},[e(_,{name:`branch`,size:13}),f(`strong`,null,`#`+u($.value.pr.number),1),f(`span`,me,u($.value.pr.title),1),e(_,{name:`external`,size:12})],8,pe),$.value.checksCount?(g(),h(`span`,{key:0,class:c([`pr-checks`,$.value.failed?`is-danger`:$.value.pending?`is-warn`:`is-ok`])},u($.value.failed?`${$.value.failed} failed`:$.value.pending?`${$.value.pending} running`:`${$.value.passed} passed`),3)):m(``,!0)])):m(``,!0),f(`div`,he,[f(`button`,{type:`button`,class:`btn btn-sm btn-outline`,disabled:I.value,onClick:a[8]||=e=>{L.value=!L.value,z.value=!1}},`Commit`,8,ge),f(`button`,{type:`button`,class:`btn btn-sm btn-outline`,disabled:I.value,onClick:X},u(I.value?`Working…`:`Push`),9,_e),$.value?m(``,!0):(g(),h(`button`,{key:0,type:`button`,class:`btn btn-sm btn-outline`,disabled:I.value,onClick:a[9]||=e=>{z.value=!z.value,L.value=!1}},`Create PR`,8,ve))]),L.value?(g(),h(`form`,{key:2,class:`git-form`,onSubmit:l(ht,[`prevent`])},[r(f(`textarea`,{"onUpdate:modelValue":a[10]||=e=>R.value=e,rows:`2`,placeholder:`Commit message (leave blank to auto-generate)`,disabled:I.value},null,8,ye),[[s,R.value]]),f(`div`,be,[f(`button`,{type:`button`,class:`btn btn-sm btn-ghost`,onClick:a[11]||=e=>L.value=!1},`Cancel`),f(`button`,{type:`submit`,class:`btn btn-sm btn-primary`,disabled:I.value},u(I.value?`Committing…`:`Commit all`),9,xe)])],32)):m(``,!0),z.value?(g(),h(`form`,{key:3,class:`git-form`,onSubmit:l(gt,[`prevent`])},[r(f(`input`,{"onUpdate:modelValue":a[12]||=e=>B.value=e,placeholder:`PR title (leave blank to auto-generate)`,disabled:I.value},null,8,Se),[[s,B.value]]),r(f(`textarea`,{"onUpdate:modelValue":a[13]||=e=>V.value=e,rows:`2`,placeholder:`PR description (optional)`,disabled:I.value},null,8,Ce),[[s,V.value]]),f(`div`,we,[f(`button`,{type:`button`,class:`btn btn-sm btn-ghost`,onClick:a[14]||=e=>z.value=!1},`Cancel`),f(`button`,{type:`submit`,class:`btn btn-sm btn-primary`,disabled:I.value},u(I.value?`Creating…`:`Create PR`),9,Te)])],32)):m(``,!0),D.value?(g(),h(`p`,Ee,u(D.value),1)):m(``,!0),E.value?(g(),h(`p`,De,u(E.value),1)):m(``,!0),H.value.length?(g(),h(`div`,Oe,[f(`div`,ke,[f(`strong`,null,u(H.value.length)+` review `+u(H.value.length===1?`comment`:`comments`),1),f(`button`,{type:`button`,class:`btn btn-sm btn-primary`,onClick:yt},`Send to agent`)]),(g(!0),h(d,null,t(H.value,t=>(g(),h(`div`,{key:t.id,class:`review-chip`},[f(`span`,Ae,[f(`code`,null,u(t.path)+`:`+u(t.line),1),i(` — `+u(t.text),1)]),f(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Remove comment`,onClick:e=>vt(t.id)},[e(_,{name:`close`,size:12})],8,je)]))),128))])):m(``,!0),b.value===`diff`?(g(),h(d,{key:7},[k.value?(g(),h(`p`,Me,`Diff exceeds the host limit; some changes are omitted.`)):m(``,!0),!O.value&&!E.value&&!T.value.length?(g(),h(`p`,Ne,`No `+u(x.value===`uncommitted`?`uncommitted `:``)+`changes.`,1)):m(``,!0),(g(!0),h(d,null,t(T.value,e=>(g(),h(`details`,{key:e.path,onToggle:t=>t.target.open?j.value.add(e.path):j.value.delete(e.path)},[f(`summary`,null,[f(`span`,Fe,u(e.oldPath?e.oldPath+` → `:``)+u(e.path),1),f(`span`,Ie,[f(`em`,Le,`+`+u(e.additions),1),a[20]||=i(),f(`em`,Re,`−`+u(e.deletions),1)])]),f(`div`,ze,[f(`button`,{type:`button`,class:`link-btn`,onClick:t=>_t(e.path)},`Copy path`,8,Be),f(`button`,{type:`button`,class:`link-btn`,onClick:t=>Z(e.path,`file`)},`+ Comment on file`,8,Ve)]),U.value===e.path+`::file`?(g(),h(`form`,{key:0,class:`review-form`,onSubmit:l(t=>Q(e.path,`file`),[`prevent`])},[r(f(`textarea`,{"onUpdate:modelValue":a[15]||=e=>W.value=e,rows:`2`,placeholder:`Write review comment for this file…`},null,512),[[s,W.value]]),f(`div`,Ue,[f(`button`,{type:`button`,class:`btn btn-sm btn-ghost`,onClick:a[16]||=e=>U.value=null},`Cancel`),f(`button`,{type:`submit`,class:`btn btn-sm btn-primary`,disabled:!W.value.trim()},`Add comment`,8,We)])],40,He)):m(``,!0),e.status===`binary`?(g(),h(`p`,Ge,`Binary file changed.`)):e.status===`too_large`?(g(),h(`p`,Ke,`File diff is too large to display.`)):m(``,!0),j.value.has(e.path)?(g(!0),h(d,{key:3},t(e.hunks,(n,i)=>(g(),h(`div`,{key:i,class:`diff-hunk-block`},[f(`div`,qe,`@@ −`+u(n.oldStart)+`,`+u(n.oldCount)+` +`+u(n.newStart)+`,`+u(n.newCount)+` @@`,1),(g(!0),h(d,null,t(n.lines,(t,i)=>(g(),h(d,{key:i},[f(`div`,{class:c([`diff-line`,t.type])},[f(`button`,{type:`button`,class:`diff-comment-btn`,title:`Add review comment on this line`,"aria-label":`Add review comment`,onClick:r=>Z(e.path,`L${t.newLineNumber??t.oldLineNumber??n.newStart+i}`)},`+`,8,Je),f(`span`,Ye,u(t.type===`add`?`+`:t.type===`remove`?`−`:` `)+u(t.content),1)],2),U.value===`${e.path}::L${t.newLineNumber??t.oldLineNumber??n.newStart+i}`?(g(),h(`form`,{key:0,class:`review-form`,onSubmit:l(r=>Q(e.path,`L${t.newLineNumber??t.oldLineNumber??n.newStart+i}`),[`prevent`])},[r(f(`textarea`,{"onUpdate:modelValue":a[17]||=e=>W.value=e,rows:`2`,placeholder:`Write review comment on this line…`},null,512),[[s,W.value]]),f(`div`,Ze,[f(`button`,{type:`button`,class:`btn btn-sm btn-ghost`,onClick:a[18]||=e=>U.value=null},`Cancel`),f(`button`,{type:`submit`,class:`btn btn-sm btn-primary`,disabled:!W.value.trim()},`Add comment`,8,Qe)])],40,Xe)):m(``,!0)],64))),128))]))),128)):m(``,!0)],40,Pe))),128))],64)):(g(),h(d,{key:8},[N.value&&!M.value.length?(g(),h(`p`,$e,`Loading commits…`)):M.value.length?m(``,!0):(g(),h(`p`,et,`No commits found.`)),(g(!0),h(d,null,t(M.value,e=>(g(),h(`details`,{key:e.sha,class:`commit-item`},[f(`summary`,null,[f(`code`,tt,u(e.shortSha),1),f(`span`,nt,u(e.subject),1),e.isOnRemote?m(``,!0):(g(),h(`span`,rt,`unpushed`))]),f(`p`,it,u(e.authorName)+` · `+u(new Date(e.authorDate).toLocaleString()),1),(g(!0),h(d,null,t(e.files??[],n=>(g(),h(`details`,{key:n.path,class:`commit-file`,onToggle:t=>t.target.open&&mt(e.sha,n.path)},[f(`summary`,null,[i(u(n.path)+` `,1),f(`span`,ot,[f(`em`,st,`+`+u(n.additions??0),1),a[21]||=i(),f(`em`,ct,`−`+u(n.deletions??0),1)])]),P.value[e.sha+`:`+n.path]?P.value[e.sha+`:`+n.path].error?(g(),h(`p`,ut,u(P.value[e.sha+`:`+n.path].error),1)):(g(!0),h(d,{key:2},t(P.value[e.sha+`:`+n.path].hunks??[],(e,n)=>(g(),h(`pre`,{key:n},[f(`code`,null,[f(`span`,dt,`@@ −`+u(e.oldStart)+`,`+u(e.oldCount)+` +`+u(e.newStart)+`,`+u(e.newCount)+` @@
3
3
  `,1),(g(!0),h(d,null,t(e.lines,(e,t)=>(g(),h(`span`,{key:t,class:c(e.type)},u(e.type===`add`?`+`:e.type===`remove`?`−`:` `)+u(e.content),3))),128))])]))),128)):(g(),h(`p`,lt,`Loading diff…`))],40,at))),128))]))),128))],64))]))}}),[[`__scopeId`,`data-v-c13449c7`]]);export{y as default};
@@ -1,3 +1,3 @@
1
- import{C as e,E as t,I as n,L as r,M as i,P as a,Q as o,T as s,U as c,Y as l,Z as u,_ as d,at as f,b as p,ct as ee,d as m,dt as te,g as h,h as g,it as _,k as ne,l as re,m as v,q as ie,st as ae,ut as oe,v as se,y as ce,z as le}from"./vue.runtime.esm-bundler-DmQNwI70.js";import{E as ue,G as de,U as fe,W as pe,X as me,Y as he,Z as ge,a as _e,at as ve,b as ye,c as be,d as xe,et as Se,ft as Ce,g as we,it as Te,lt as Ee,n as De,nt as Oe,ot as ke,rt as Ae,ut as je,v as Me,w as Ne,x as Pe}from"./MarkdownMessage-BSPsJz2u.js";import{n as Fe,r as Ie,t as Le}from"./PreCodeBlock.vue_vue_type_style_index_0_lang-B_ZZH8sz.js";import{n as Re,t as y}from"./safeRaf-BDp3SJMs.js";import{a as ze}from"./index-DAwT50Ss.js";var b=(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())}),Be=!1,Ve=null,He=null,Ue=null;function We(){return b(this,null,function*(){if(Ue)return Ue;Ue=b(null,null,function*(){if(!He)try{if(He=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 ze(()=>import(`./markstream_markstream-vue-Bj0UewdV.js`),[])),!He)return null}catch{return null}try{return yield function(e){return b(this,null,function*(){if(!Be)return Ve||(Ve=b(null,null,function*(){let t=e?.preloadStreamDiffs;typeof t==`function`&&(yield t()),Be=!0}).finally(()=>{Ve=null}),Ve)})}(He),pe(),He}catch{return null}});try{return yield Ue}finally{Ue=null}})}var Ge=Object.defineProperty,Ke=Object.defineProperties,x=Object.getOwnPropertyDescriptors,S=Object.getOwnPropertySymbols,qe=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable,Je=(e,t,n)=>t in e?Ge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||={})qe.call(t,n)&&Je(e,n,t[n]);if(S)for(var n of S(t))C.call(t,n)&&Je(e,n,t[n]);return e},Ye=(e,t)=>Ke(e,x(t)),T=(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())}),E={class:`html-preview-frame__header`},Xe={class:`html-preview-frame__title`},D={class:`html-preview-frame__label`},O=[`sandbox`,`srcdoc`],Ze=Me(s({__name:`HtmlPreviewFrame`,props:{code:{},isDark:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},onClose:{type:Function},title:{}},setup(e){let t=e,{t:i}=Pe(),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 s(e){var n;e.key!==`Escape`&&e.key!==`Esc`||(n=t.onClose)==null||n.call(t)}return n(()=>{typeof window<`u`&&window.addEventListener(`keydown`,s)}),r(()=>{typeof window<`u`&&window.removeEventListener(`keydown`,s)}),(e,n)=>(le(),d(v,{to:`body`},[h(`div`,{class:ee([`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`,E,[h(`div`,Xe,[n[3]||=h(`span`,{class:`html-preview-frame__dot`},null,-1),h(`span`,D,te(t.title||ae(i)(`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,O)])])],2)]))}}),[[`__scopeId`,`data-v-24e66176`]]),Qe=[`data-markstream-enhanced`,`data-markstream-enhancement-state`,`data-markstream-code-block-state`,`data-markstream-pending`,`data-markstream-viewport-pending`],$e={class:`code-header-main`},et=[`innerHTML`],tt={class:`code-header-copy`},nt={class:`code-header-title`},rt={key:0,class:`code-header-caption`},it=[`data-markstream-host-hidden`],k=Me(s({__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(s,{emit:m}){let v=s,pe=m,Me=g(()=>v.showLineNumbers??!0!==v.codeBlockOptions?.disableLineNumbers),ze=ie(),b=ne(me,null),Be=ne(`markstreamHostScrollManaged`,null),Ve=ne(we,void 0),He=g(()=>be(v,ze)),Ue=t(),Ge=g(()=>{let e=Ue?.vnode.props;return!(!e||!e.onPreviewCode&&!e[`onPreview-code`])}),{t:Ke}=Pe(),x=_(null),S=_(null),qe=_(!1),C=_(Hr(v.node.language,v.node.code,Vr())),Je=g(()=>ge(C.value)),E=g(()=>Je.value===`plaintext`?`text`:Je.value),Xe=g(()=>Je.value===`plaintext`),D=_(!1),O=_(!1),k=_(!1),A=_(!1),j=_(!1),at=_(!1),M=!1,ot=!1,st=null,ct=null,lt=null,ut=0,dt=!1,ft=``,pt=_(null),mt=0,ht=!1,gt=De(),_t=ue(),vt=xe(),yt=f(null),N=_(typeof window>`u`||!vt.value),bt=t()?.vnode.el?.textContent??``,xt=typeof window<`u`&&String(v.node.code??``).length>0&&bt.includes(String(v.node.code)),St=_(!xt);n(()=>{St.value=!0}),typeof window<`u`&&l([()=>S.value,vt],([e,t],n,r)=>{var i;if((i=yt.value)==null||i.destroy(),yt.value=null,!t||N.value)return void(N.value=!0);if(!e)return void(N.value=!1);let a=!0,o=_t?.value.heavyBlockMargin??_t?.value.rootMargin??`0px`,s=gt(e,{rootMargin:o,allowIdle:!1});yt.value=s,N.value=N.value||s.isVisible.value,s.whenVisible.then(()=>{a&&yt.value===s&&(N.value=!0)}).catch(()=>{}),r(()=>{a=!1,s.destroy(),yt.value===s&&(yt.value=null)})},{immediate:!0}),a(()=>{var e;M=!0,function(){let e=ft;b&&e&&(ft=``,b.markSettled(e))}(),(e=yt.value)==null||e.destroy(),yt.value=null});let P=null,Ct=null,wt=()=>{},Tt=()=>{},Et=()=>{},Dt=()=>{},Ot=()=>null,F=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),I=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),kt=()=>{},At=()=>{},jt=()=>{},Mt=null,L=null,Nt=null,Pt=null,Ft=()=>String(v.node.language??`plaintext`),It=()=>T(null,null,function*(){}),Lt=!1,Rt=null,zt=[],Bt=[],R=null,Vt=null,z=g(()=>Ae(v.node)),Ht=_({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=jt();e&&typeof e.catch==`function`&&e.catch(e=>{Kt(e)})}catch(e){Kt(e)}}let Jt=g(()=>{let e=w({},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 Ye(w(w({},n),e),{parseDiffOptions:w(w({},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 Te(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(()=>je({darkTheme:v.darkTheme,isDark:v.isDark,lightTheme:v.lightTheme,theme:v.theme,themes:v.themes})),Qt=g(()=>z.value?`diff`:`single`),$t=_(Qt.value),V=_(!1),H=_(!1),en=_(!1),U=_(!1),tn=_(null),nn=_(0),rn=_(0),an=_(!1),on=null,sn=!1,cn=null,ln=!1,un=g(()=>!!z.value&&Jt.value?.diffStyle===`unified`),dn=g(()=>ke(Jt.value));function fn(e){return!0===Be?.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(S.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=_(!1),W=g(()=>Gt(v.node.code)),bn=g(()=>z.value?!0===v.node.diff?v.node:Ye(w({},v.node),{diff:!0}):W.value===v.node.code?v.node:Ye(w({},v.node),{code:W.value}));function xn(e){let t=e.detectLanguage;typeof t==`function`&&(Ft=t),Vt=e,R=gi();let n=e.createCodeBlockRuntime(R);return!!n&&(P=n.createEditor||P,Ct=n.createDiffEditor||Ct,wt=n.updateCode||wt,Tt=n.updateDiff||Tt,Et=n.finalizeCode||Et,Dt=n.finalizeDiff||Dt,Ot=n.getEditor||Ot,F=n.getEditorView||F,I=n.getDiffEditorView||I,kt=n.cleanupEditor||kt,At=n.safeClean||n.cleanupEditor||At,jt=n.refreshDiffPresentation||jt,It=n.setTheme||It,Mt=n.whenVisualReady||null,at.value=!0,!0)}let G=_(typeof v.codeBlockOptions?.fontSize==`number`?v.codeBlockOptions.fontSize:NaN),K=_(G.value),Sn=_(null),Cn=_(null),wn=_(null),Tn=_(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(()=>Ye(w({},Ce(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=_(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,I as n,L as r,M as i,P as a,Q as o,T as s,U as c,Y as l,Z as u,_ as d,at as f,b as p,ct as ee,d as m,dt as te,g as h,h as g,it as _,k as ne,l as re,m as v,q as ie,st as ae,ut as oe,v as se,y as ce,z as le}from"./vue.runtime.esm-bundler-DmQNwI70.js";import{E as ue,G as de,U as fe,W as pe,X as me,Y as he,Z as ge,a as _e,at as ve,b as ye,c as be,d as xe,et as Se,ft as Ce,g as we,it as Te,lt as Ee,n as De,nt as Oe,ot as ke,rt as Ae,ut as je,v as Me,w as Ne,x as Pe}from"./MarkdownMessage-B5JuY96x.js";import{n as Fe,r as Ie,t as Le}from"./PreCodeBlock.vue_vue_type_style_index_0_lang-C8gxl3_t.js";import{n as Re,t as y}from"./safeRaf-BDp3SJMs.js";import{a as ze}from"./index-DZm2Vxoh.js";var b=(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())}),Be=!1,Ve=null,He=null,Ue=null;function We(){return b(this,null,function*(){if(Ue)return Ue;Ue=b(null,null,function*(){if(!He)try{if(He=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 ze(()=>import(`./markstream_markstream-vue-Bj0UewdV.js`),[])),!He)return null}catch{return null}try{return yield function(e){return b(this,null,function*(){if(!Be)return Ve||(Ve=b(null,null,function*(){let t=e?.preloadStreamDiffs;typeof t==`function`&&(yield t()),Be=!0}).finally(()=>{Ve=null}),Ve)})}(He),pe(),He}catch{return null}});try{return yield Ue}finally{Ue=null}})}var Ge=Object.defineProperty,Ke=Object.defineProperties,x=Object.getOwnPropertyDescriptors,S=Object.getOwnPropertySymbols,qe=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable,Je=(e,t,n)=>t in e?Ge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||={})qe.call(t,n)&&Je(e,n,t[n]);if(S)for(var n of S(t))C.call(t,n)&&Je(e,n,t[n]);return e},Ye=(e,t)=>Ke(e,x(t)),T=(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())}),E={class:`html-preview-frame__header`},Xe={class:`html-preview-frame__title`},D={class:`html-preview-frame__label`},O=[`sandbox`,`srcdoc`],Ze=Me(s({__name:`HtmlPreviewFrame`,props:{code:{},isDark:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},onClose:{type:Function},title:{}},setup(e){let t=e,{t:i}=Pe(),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 s(e){var n;e.key!==`Escape`&&e.key!==`Esc`||(n=t.onClose)==null||n.call(t)}return n(()=>{typeof window<`u`&&window.addEventListener(`keydown`,s)}),r(()=>{typeof window<`u`&&window.removeEventListener(`keydown`,s)}),(e,n)=>(le(),d(v,{to:`body`},[h(`div`,{class:ee([`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`,E,[h(`div`,Xe,[n[3]||=h(`span`,{class:`html-preview-frame__dot`},null,-1),h(`span`,D,te(t.title||ae(i)(`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,O)])])],2)]))}}),[[`__scopeId`,`data-v-24e66176`]]),Qe=[`data-markstream-enhanced`,`data-markstream-enhancement-state`,`data-markstream-code-block-state`,`data-markstream-pending`,`data-markstream-viewport-pending`],$e={class:`code-header-main`},et=[`innerHTML`],tt={class:`code-header-copy`},nt={class:`code-header-title`},rt={key:0,class:`code-header-caption`},it=[`data-markstream-host-hidden`],k=Me(s({__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(s,{emit:m}){let v=s,pe=m,Me=g(()=>v.showLineNumbers??!0!==v.codeBlockOptions?.disableLineNumbers),ze=ie(),b=ne(me,null),Be=ne(`markstreamHostScrollManaged`,null),Ve=ne(we,void 0),He=g(()=>be(v,ze)),Ue=t(),Ge=g(()=>{let e=Ue?.vnode.props;return!(!e||!e.onPreviewCode&&!e[`onPreview-code`])}),{t:Ke}=Pe(),x=_(null),S=_(null),qe=_(!1),C=_(Hr(v.node.language,v.node.code,Vr())),Je=g(()=>ge(C.value)),E=g(()=>Je.value===`plaintext`?`text`:Je.value),Xe=g(()=>Je.value===`plaintext`),D=_(!1),O=_(!1),k=_(!1),A=_(!1),j=_(!1),at=_(!1),M=!1,ot=!1,st=null,ct=null,lt=null,ut=0,dt=!1,ft=``,pt=_(null),mt=0,ht=!1,gt=De(),_t=ue(),vt=xe(),yt=f(null),N=_(typeof window>`u`||!vt.value),bt=t()?.vnode.el?.textContent??``,xt=typeof window<`u`&&String(v.node.code??``).length>0&&bt.includes(String(v.node.code)),St=_(!xt);n(()=>{St.value=!0}),typeof window<`u`&&l([()=>S.value,vt],([e,t],n,r)=>{var i;if((i=yt.value)==null||i.destroy(),yt.value=null,!t||N.value)return void(N.value=!0);if(!e)return void(N.value=!1);let a=!0,o=_t?.value.heavyBlockMargin??_t?.value.rootMargin??`0px`,s=gt(e,{rootMargin:o,allowIdle:!1});yt.value=s,N.value=N.value||s.isVisible.value,s.whenVisible.then(()=>{a&&yt.value===s&&(N.value=!0)}).catch(()=>{}),r(()=>{a=!1,s.destroy(),yt.value===s&&(yt.value=null)})},{immediate:!0}),a(()=>{var e;M=!0,function(){let e=ft;b&&e&&(ft=``,b.markSettled(e))}(),(e=yt.value)==null||e.destroy(),yt.value=null});let P=null,Ct=null,wt=()=>{},Tt=()=>{},Et=()=>{},Dt=()=>{},Ot=()=>null,F=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),I=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),kt=()=>{},At=()=>{},jt=()=>{},Mt=null,L=null,Nt=null,Pt=null,Ft=()=>String(v.node.language??`plaintext`),It=()=>T(null,null,function*(){}),Lt=!1,Rt=null,zt=[],Bt=[],R=null,Vt=null,z=g(()=>Ae(v.node)),Ht=_({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=jt();e&&typeof e.catch==`function`&&e.catch(e=>{Kt(e)})}catch(e){Kt(e)}}let Jt=g(()=>{let e=w({},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 Ye(w(w({},n),e),{parseDiffOptions:w(w({},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 Te(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(()=>je({darkTheme:v.darkTheme,isDark:v.isDark,lightTheme:v.lightTheme,theme:v.theme,themes:v.themes})),Qt=g(()=>z.value?`diff`:`single`),$t=_(Qt.value),V=_(!1),H=_(!1),en=_(!1),U=_(!1),tn=_(null),nn=_(0),rn=_(0),an=_(!1),on=null,sn=!1,cn=null,ln=!1,un=g(()=>!!z.value&&Jt.value?.diffStyle===`unified`),dn=g(()=>ke(Jt.value));function fn(e){return!0===Be?.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(S.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=_(!1),W=g(()=>Gt(v.node.code)),bn=g(()=>z.value?!0===v.node.diff?v.node:Ye(w({},v.node),{diff:!0}):W.value===v.node.code?v.node:Ye(w({},v.node),{code:W.value}));function xn(e){let t=e.detectLanguage;typeof t==`function`&&(Ft=t),Vt=e,R=gi();let n=e.createCodeBlockRuntime(R);return!!n&&(P=n.createEditor||P,Ct=n.createDiffEditor||Ct,wt=n.updateCode||wt,Tt=n.updateDiff||Tt,Et=n.finalizeCode||Et,Dt=n.finalizeDiff||Dt,Ot=n.getEditor||Ot,F=n.getEditorView||F,I=n.getDiffEditorView||I,kt=n.cleanupEditor||kt,At=n.safeClean||n.cleanupEditor||At,jt=n.refreshDiffPresentation||jt,It=n.setTheme||It,Mt=n.whenVisualReady||null,at.value=!0,!0)}let G=_(typeof v.codeBlockOptions?.fontSize==`number`?v.codeBlockOptions.fontSize:NaN),K=_(G.value),Sn=_(null),Cn=_(null),wn=_(null),Tn=_(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(()=>Ye(w({},Ce(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=_(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=_(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=w({},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=S.value?.querySelector(`pre.code-pre-fallback`),a=I(),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 T(this,null,function*(){return z.value?(vr(),er(),X(!0),Xn(),Z(),en.value=!0,yield i(),X(!0),yield q(),X(!0),gr(),er(),!!(yield function(){return T(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 i(),yield q();let t=S.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 i(),er(),X(!0),gr(),Z(),y(()=>{M||y(()=>{M||(function(){let e=S.value?.querySelector(`.code-block-shell-content`),t=S.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)):!(Mt&&!(yield Mt())||(en.value=!0,yield i(),X(!0),H.value=!0,yield i(),Q(),0))})}function Qn(e){if(!z.value)return;let t=x.value,n=S.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=S.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=S.value?.querySelector(`.code-block-shell-content`),n=S.value?.querySelector(`.code-editor-layer`);if(!t||!n)return;let r=typeof e==`number`&&Number.isFinite(e)&&e>0?Math.ceil(e):Number.parseFloat(x.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=x.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)&&j.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&&Re(n),e())};r=globalThis.setTimeout(i,50),n=y(i)})}function nr(){try{let e=x.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=I())?.getModifiedEditor)?.call(e)??I():F(),n=Ot()?.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=x.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=Ot()?.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!!Xe.value||!!e&&($(e)||Mt!=null)}function sr(){z.value?Ht.value=Oe(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?I():null,o=z.value?a:F();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=F())?.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=I())?.getModifiedEditor)?.call(e)??I():F());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=x.value,t=S.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=x.value,t=S.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=I())?.getModifiedEditor)?.call(e)??I():F(),n=Ot()?.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(!Xe.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)}}l(()=>[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=x.value;if(!e)return;let t=e.getBoundingClientRect().height,n=fr();if(n!=null&&n>0){let r=tr(n,!0,{allowBelowEstimatedFloor:!z.value&&j.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;zt.length>0;)try{(t=(e=zt.pop())?.dispose)==null||t.call(e)}catch{}st!=null&&(Re(st),st=null),ct!=null&&(Re(ct),ct=null),lt!=null&&(Re(lt),lt=null),ut=0,dt=!1}function Tr(){for(var e;Bt.length>0;)try{(e=Bt.pop())==null||e()}catch{}}function Y(e=!1){O.value||(D.value?Cr():function(e={}){try{let t=x.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=I(),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(mt>0&&(mt--,pt.value!=null))return void J(t,n,Or(t,pt.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&&j.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(pt.value!=null)return void J(t,n,Or(t,pt.value,i,{preserveScrollableOverflow:Ar(t)}));let te=z.value&&!1!==v.loading?a:Math.max(a,c!=null&&c>0?c:0);if(te>0)return void J(t,n,Or(t,te,i));let h=Hn();if(!(h==null||z.value&&!1!==v.loading&&l))return void J(t,n,Or(t,h,i));let g=Number.parseFloat(t.style.height);!Number.isNaN(g)&&g>0?J(t,n,Or(t,g,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(O.value)return;let t=x.value;if(!t)return;let n=z.value?I():F();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(M||st!=null)return;let t=()=>{M||(Z(),Y(e),X())};st=y(()=>{st=null,t(),ct=y(()=>{ct=null,t()})}),Dr()}function Dr(e=!1){if(!z.value||M||!e&&!1===v.loading||(dt||=e,ut=Math.max(ut,e?18:6),lt!=null))return;let t=()=>{if(lt=null,!z.value||M||ut<=0||!dt&&!1===v.loading)return ut=0,void(dt=!1);ut--,Z(),Y({preferModelDiffHeight:!0,holdCurrentDiffHeight:dt}),X(),ut>0?lt=y(t):dt=!1};lt=y(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 ht||kr(e,pt.value??0)}function jr(e=x.value){return $(e)}function Mr(e=x.value){return $(e)}function Nr(){var e;if($())return!0;let t=((e=F())?.getModel)?.call(e);return typeof t?.getValue==`function`&&t.getValue()===W.value}function $(e=x.value){return!!e?.querySelector(`diffs-container`)}function Pr(){return!1!==v.loading||H.value}function Fr(){let e=I();return typeof e?.getOriginalEditor==`function`||typeof e?.getModifiedEditor==`function`||typeof e?.getLineChanges==`function`}function Ir(){return T(this,null,function*(){if(!z.value)return!0;for(let e=0;e<30;e++){if(M)return!1;if($())return yield i(),yield q(),!M&&$();yield i(),yield q()}return!1})}let Lr=``;function Rr(e,t,n){return T(this,null,function*(){let r=`${e}\0${t}\0${n}`;if(Lr!==r){try{yield Tt(e,t,n),Lr=r;return}catch(e){if(!Kt(e))throw e}if(yield i(),yield q(),!M&&z.value)try{yield Tt(e,t,n),Lr=r}catch(e){if(!Kt(e))throw e}}})}function zr(){return v.codeBlockOptions?.maxHeight??500}let Br=g(()=>v.isShowPreview&&(C.value===`html`||C.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??``)?fe(String(e??``)):`plain`}function Ur(){return Vr()}let Wr=null,Gr=!1,Kr=0;function qr(){Wr=null,Kr++}function Jr(){return T(this,arguments,function*(e=Kr){if(!Gr){Gr=!0;try{for(;Wr&&!M&&!z.value&&e===Kr;){let e=Wr;Wr=null;try{yield Promise.resolve(wt(e.code,e.language)),yield i(),M||z.value||(Y(!1),X())}catch{}}}finally{Gr=!1,!Wr||M||z.value||Jr()}}})}function Yr(e,t){Wr={code:e,language:t},Jr(Kr)}l(()=>[v.node.language,v.node.code,v.node.raw,v.node.loading,v.loading],([e,t,n,r,i])=>{C.value=Hr(e,t,typeof r==`boolean`?r:!0===i)}),l(()=>[v.node.originalCode,v.node.updatedCode,z.value],()=>{y(()=>sr())},{immediate:!0});let Xr=0;l(()=>[v.node.originalCode,v.node.updatedCode,E.value,z.value,v.stream],e=>T(null,[e],function*([,,,e,t]){let n=++Xr;if(!e||Vr()||!1===t&&!k.value)return;if(!1!==t&&P&&!k.value&&x.value)try{yield ci(x.value)}catch{}let r=Nt;if(r&&!A.value){try{yield r}catch{}if(M||!z.value||n!==Xr)return}if(n!==Xr)return;let a=Wt(String(v.node.originalCode??``),String(v.node.updatedCode??``)),o=!1===v.loading;o&&_i();try{if(yield Rr(a.original,a.updated,E.value),M||!z.value||n!==Xr)return;yield i(),X(!0),Z(),Y(!1===v.loading||{preferModelDiffHeight:!0}),X(!0),Q(!0)}catch{return}if(o){if(M||!z.value)return;qt(),Z(),sr(),Q(),Dr(!0)}D.value&&y(()=>Cr())})),l(()=>v.node.code,e=>T(null,null,function*(){if(Vr()||!1===v.stream||(C.value||=fe(Ft(e)),z.value))return;let t=Nt;if(t&&!A.value){try{yield t}catch{}if(M||z.value)return}if(P&&!k.value&&x.value)try{yield ci(x.value)}catch{}Yr(Gt(v.node.code),E.value),D.value&&y(()=>Cr())}));let Zr=g(()=>{let e=C.value;return e?he[e]||e.charAt(0).toUpperCase()+e.slice(1):he[``]||`Plain Text`}),Qr=g(()=>ve(String(v.node.raw??``),Zr.value,z.value)),$r=g(()=>Qr.value.title),ei=g(()=>Qr.value.caption),ti=g(()=>(de.value,Ie(C.value||``,Ve))),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&&!O.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 T(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)),qe.value=!0,pe(`copy`,e),setTimeout(()=>{qe.value=!1},1e3)}catch(e){console.error(`复制失败:`,e)}})}function ai(){D.value=!D.value;let e=z.value?I():F(),t=x.value;e&&t&&(D.value?(t.style.maxHeight=`none`,t.style.overflow=`visible`,Y(!0)):(t.style.overflow=`auto`,Y(!0)))}function oi(){var e;if(O.value=!O.value,O.value){if(ht=!1,x.value){let t=Math.ceil((e=x.value).getBoundingClientRect?.call(e).height||0);ht=kr(x.value,t)||x.value.style.overflow===`auto`||x.value.style.overflowY===`auto`,t>0&&(pt.value=t)}}else x.value&&pt.value!=null&&(x.value.style.height=`${pt.value}px`),mt=2,i(()=>{O.value||M||(Y(!0),X(!0))})}function si(){if(!Br.value)return;let e=C.value;if(Ge.value){let t=e===`html`?`text/html`:`image/svg+xml`,n=e===`html`?Ke(`artifacts.htmlPreviewTitle`)||`HTML Preview`:Ke(`artifacts.svgPreviewTitle`)||`SVG Preview`;pe(`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(!P||M||!1===v.stream&&!1!==v.loading||(Ci(),wi())||V.value||x.value!==e||Ur())return null;if(L)return L;if(k.value&&j.value)return Promise.resolve();let n=xi(),r=nn.value,a=!1;k.value=!0,function(){let e=He.value;b&&e&&ft!==e&&(ft&&b.markSettled(ft),ft=e,b.markPending(e))}();let o=T(null,null,function*(){try{yield function(e){return T(this,null,function*(){var t;if(!P||M)return;ot=!1;let n=Qt.value;if(ln=!1,U.value=!1,tn.value=null,A.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=j.value||e==null?null:e}(),wr(),Tr(),function(e){e.replaceChildren()}(e),_i(),yield ye(hi()),M)return;let r=T(null,null,function*(){if(n===`diff`){(function(){if(Lt||typeof window>`u`)return;Lt=!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),Rt=()=>{window.removeEventListener(`error`,e,!0),window.removeEventListener(`unhandledrejection`,e,!0),Lt=!1,Rt=null}})(),At();let t=Wt(String(v.node.originalCode??``),String(v.node.updatedCode??``));Ct?yield Ct(e,t.original,t.updated,E.value):yield P(e,v.node.code,E.value)}else yield P(e,W.value,E.value);A.value=!0}).finally(()=>{Nt===r&&(Nt=null)});if(Nt=r,yield function(e){return T(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(M)return;if(n){if(t)throw t;return}if(jr()&&Fr())return;yield i(),yield q()}})}(r),M||Qt.value!==n)return;A.value=!0;let a=v.codeBlockOptions?.fontSize;if(typeof a==`number`&&Number.isFinite(a)&&a>0){let e=n===`diff`?I():F();(t=e?.updateOptions)==null||t.call(e,{fontSize:a}),G.value=a,K.value=a}else if(!_r()){let e=rr();e&&e>0?(G.value=e,K.value=e):(G.value=12,K.value=12)}for(gr();ot;)if(ot=!1,yield mi(),M)return;D.value||O.value||Y(!1),j.value=!0,$t.value=n,function(){if(wr(),z.value){let e=I(),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&&zt.push(r)}catch{}};try{let t=(e?.onDidUpdateDiff)?.call(e,()=>{Q(),y(()=>sr())});t&&zt.push(t)}catch{}r(t,`onDidContentSizeChange`),r(n,`onDidContentSizeChange`);let i=x.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}),zt.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),zt.push({dispose:()=>e.disconnect()})}return}let e=F();try{let t=(e?.onDidContentSizeChange)?.call(e,()=>Q());t&&zt.push(t)}catch{}try{let t=(e?.onDidLayoutChange)?.call(e,()=>Q());t&&zt.push(t)}catch{}}(),yr(),gr(),Z(),sr(),Q(),yield i();let o=null;Mt&&(o=yield Mt(),o&&(yield i(),yield q()));let s=o??(n===`diff`?yield Ir():yield function(){return T(this,null,function*(){if($())return yield i(),yield q(),$();for(let e=0;e<30;e++){if(M||z.value)return!1;let e=x.value,t=Nr(),n=Mr(e),r=!W.value.trim()||or(e);if(t&&n&&r&&(yield i(),yield q(),!M&&!z.value&&Nr()&&Mr(x.value)&&(!W.value.trim()||or(x.value))))return!0;yield i(),yield q()}return!1})}());M||(s?(gr(),er(),(yield Zn())||Ti()):Ti())})}(e),on=null}catch(e){let i=xi(),o=r!==nn.value,s=!1!==t.allowStaleContentRetry&&o&&on!==i;if(n!==i||s)return s&&(on=i),a=!0,k.value=!1,j.value=!1,A.value=!1,void(H.value=!1);throw Ti(n),e}}).finally(()=>{L===o&&(L=null),function(){let e=ft;b&&e&&(ft=``,i(()=>{if(!M){let t=S.value?.offsetHeight??0;t>0&&b.reportHeight(e,t)}b.markSettled(e)}))}(),a&&!M&&queueMicrotask(()=>{var e;let t=x.value;t&&!M&&((e=ci(t))==null||e.catch(e=>{j.value=!1,H.value=!1,Ti()}))})});return L=o,o}l(ri,e=>{e||Ne()}),l(()=>K.value,(e,t)=>{var n;let r=z.value?I():F();r&&typeof e==`number`&&Number.isFinite(e)&&e>0&&((n=r.updateOptions)==null||n.call(r,{fontSize:e}),O.value||Y(!0))},{flush:`post`,immediate:!1});let li=0,ui=l(()=>[x.value,z.value,v.stream,v.loading,at.value,N.value,v.node.language,v.node.raw,v.node.code,v.node.loading],e=>T(null,[e],function*([e,t,n,r,i,a]){let o=++li;if(!e||!a||Vr()||sn||!1===n&&!1!==r||!P&&(yield function(){return T(this,null,function*(){if(typeof window>`u`||M||at.value||V.value)return;if(Pt)return Pt;let e=T(null,null,function*(){try{let e=yield We();if(M)return;if(!e)return void(V.value=!0);xn(e)}catch{if(M)return;V.value=!0}}).finally(()=>{Pt===e&&(Pt=null)});return Pt=e,e})}(),o!==li||!1===v.stream&&!1!==v.loading||Ur()||!N.value||!P||V.value||k.value||wi()||M||x.value!==e)||Ur())return;let s=ci(e);if(s){try{yield s}catch{j.value=!1,H.value=!1,Ti()}j.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 Ee({darkTheme:v.darkTheme,isDark:v.isDark,lightTheme:v.lightTheme,theme:v.theme,themes:v.themes})}function mi(){return T(this,arguments,function*(e={}){_i();let t=()=>{z.value&&qt(),y(()=>{yr(),Q()})};if(e.appearanceOnly)return void t();let n=pi();if(n)try{yield ye(hi()),yield It(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=Ye(w({},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:!Me.value,disableFileHeader:!0,workerManager:Jt.value?.workerManager??_e()??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=S.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=Se(e.overflow,r),t}function _i(){let e=gi();if(!R)return R=e,R;for(let t of Object.keys(R))t in e||delete R[t];return Object.assign(R,e),R}l(Qt,(e,t)=>T(null,null,function*(){if(e===t||U.value||sn||(qr(),!P||!x.value)||!k.value||!1===v.stream&&!1!==v.loading||!N.value)return;let n=L;if(n){try{yield n}catch{}if(M||!x.value)return}if($t.value!==e||!k.value||!j.value)try{j.value=!1,H.value=!1,k.value=!1,A.value=!1,wr(),Tr(),At(),yield i(),yield ci(x.value)}catch{j.value=!1,H.value=!1,Ti()}}));let vi=_(0),yi=g(()=>String(vi.value)),bi=!1;function xi(){let e=pi();return JSON.stringify({kind:Qt.value,language:E.value,structural:yi.value,optionsRevision:vi.value,settledContentGeneration:rn.value,theme:di(e)??(e==null?null:`custom`),isDark:v.isDark})}l(()=>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}),l(()=>[v.codeBlockOptions,v.showLineNumbers],()=>{vi.value+=1,!1===v.stream&&!1!==v.loading&&(bi=!0)},{deep:!0}),l(()=>[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,k.value=!1,j.value=!1,A.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 l(Si,()=>T(null,null,function*(){if(sn||!U.value||tn.value===Si.value||!P||!x.value||V.value||M||!N.value||!1===v.stream&&!1!==v.loading||Ur())return;let e=Si.value;sn=!0;try{if(Ci(),U.value)return;yield ci(x.value)}catch{j.value=!1,H.value=!1,Ti()}finally{cn=e,yield i(),sn=!1}})),l(()=>[v.codeBlockOptions,N.value],()=>{var e;if(_i(),!P||!N.value)return;let t=z.value?I():F(),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}),l(()=>[pi(),Xt.value,at.value,k.value,N.value],([e,t],n)=>{if(!at.value||!N.value)return;let r=n!=null&&fi(e,n[0]),i=n!=null&&t!==n[1];j.value?(ot=!1,mi({appearanceOnly:r})):r&&!i||(ot=!0)},{flush:`post`}),l(()=>[yi.value,at.value,N.value],(e,t)=>T(null,[e,t],function*([e,t,n],[r]){if(_i(),!t||!n||!P||!x.value||!k.value||e===r)return;if(!1===v.stream&&!1!==v.loading)return void(bi=!0);bi=!1;let a=L;if(a){try{yield a}catch{}if(M||!x.value)return}try{j.value=!1,H.value=!1,k.value=!1,A.value=!1,wr(),Tr(),At(),Vt&&xn(Vt),yield i(),yield ci(x.value,{allowStaleContentRetry:!1})}catch{j.value=!1,H.value=!1,Ti()}}),{flush:`post`}),l(()=>[v.loading,N.value],([e,t])=>{!1===e&&t&&bi&&(bi=!1,vi.value+=1)},{flush:`post`}),l(()=>[v.loading,N.value],(e,t)=>T(null,[e,t],function*([e,t],n){if(!t)return;let r=n?.[0];if(!1===r&&!1!==e&&z.value&&k.value&&(yield i(),y(()=>{T(null,null,function*(){let e=L;if(e)try{yield e}catch{}!M&&z.value&&!1!==v.loading&&(_i(),qt(),Q())})})),e)return;let a=r!==void 0&&!1!==r;yield i(),y(()=>{T(null,null,function*(){try{if(a&&(yield function(){return T(this,null,function*(){if(!U.value||!P||!x.value||V.value||M||!N.value)return!1;if(cn===Si.value)return!0;sn=!0;try{U.value=!1,tn.value=null,on=null,k.value=!1,j.value=!1,A.value=!1,H.value=!1,wr(),Tr(),At(),Vt&&xn(Vt),yield i();try{yield ci(x.value)}catch{j.value=!1,H.value=!1,Ti()}}finally{yield i(),sn=!1}return!0})}()))return void Y(!1);if(a&&z.value&&k.value&&ln&&x.value)return ln=!1,j.value=!1,H.value=!1,k.value=!1,A.value=!1,wr(),Tr(),At(),yield i(),yield ci(x.value,{allowStaleContentRetry:!1}),void Dr(!0);if(a&&k.value){if(z.value&&x.value){let e=L;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,E.value),M||!z.value)return;yield Promise.resolve(Dt()),qt(),X(!0),Xn(),Z(),sr();let n=yield Ir();M||!n||H.value||(yield Zn()),Q(),Dr(!0)}else qr(),Yr(W.value,E.value),yield new Promise(e=>{let t=()=>{M?e():Gr||Wr?setTimeout(t,16):e()};t()}),M||z.value||(yield Promise.resolve(Et()))}a&&z.value?(Y({preferModelDiffHeight:!0,holdCurrentDiffHeight:!0}),Dr(!0)):Y(!1)}catch{}})})}),{immediate:!0,flush:`post`}),r(()=>{wr(),Tr(),kt(),Rt?.()}),(t,n)=>{var r;return V.value?(le(),d(Le,{key:0,style:oe(Gn.value),node:bn.value,loading:v.loading,"show-line-numbers":Me.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&&(r=Tn.value)!=null?r: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=>pe(`copy`,e)},p({_:2},[t.$slots[`header-left`]?{name:`header-left`,fn:u(()=>[c(t.$slots,`header-left`,{},void 0,!0)]),key:`0`}:void 0,t.$slots[`header-right`]?{name:`header-right`,fn:u(()=>[c(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`])):(le(),ce(`div`,{key:1,ref_key:`container`,ref:S,style:oe(ni.value),class:ee([`code-block-container rounded-lg border`,[{dark:v.isDark,"is-rendering":v.loading,"is-dark":Zt.value,"is-diff":z.value,"is-plain-text":Xe.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":St.value&&ae(vt)&&!N.value?`true`:void 0},[e(Fe,{"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:s.stream,"is-collapsed":O.value,"is-expanded":D.value,"copy-text":qe.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(()=>[c(t.$slots,`header-left`,{},()=>[h(`div`,$e,[h(`span`,{class:`icon-slot h-4 w-4 flex-shrink-0`,innerHTML:ti.value},null,8,et),h(`div`,tt,[h(`div`,nt,te($r.value),1),ei.value?(le(),ce(`div`,rt,te(ei.value),1)):se(``,!0)])])],!0)]),loading:u(()=>[c(t.$slots,`loading`,{loading:s.loading,stream:s.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[o(h(`div`,{class:ee([`code-editor-layer`,{"code-editor-layer--collapsed":O.value}])},[h(`div`,{ref_key:`codeEditor`,ref:x,class:ee([`code-editor-container`,s.stream?``:`code-height-placeholder`]),"data-markstream-host-hidden":gn.value?`true`:void 0,style:oe(Jn.value)},null,14,it),hn.value?(le(),d(Le,{key:0,style:oe(Gn.value),node:bn.value,loading:v.loading,"show-line-numbers":Me.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`])):se(``,!0)],2),[[re,!!s.stream||!s.loading]]),yn.value&&!Ge.value&&Br.value&&C.value===`html`?(le(),d(Ze,{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`])):se(``,!0)]}),_:2},[t.$slots[`header-right`]?{name:`header-right`,fn:u(()=>[c(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,Qe))}}}),[[`__scopeId`,`data-v-f293a87c`]]);export{k as default};
@@ -1 +1 @@
1
- import{C as e,H as t,I as n,M as r,Q as i,S as a,T as o,Y as s,c,ct as l,d as u,dt as d,f,g as p,h as m,it as h,v as g,y as _,z as v}from"./vue.runtime.esm-bundler-DmQNwI70.js";import{_ as y,g as b}from"./index-DAwT50Ss.js";var x={class:`cc-input-row`},S=[`placeholder`],C={class:`cc-tabs`,role:`tablist`},w=[`aria-selected`,`disabled`,`onClick`],T={class:`cc-list`,role:`listbox`},E={key:0,class:`cc-empty`},D={key:1,class:`cc-empty`},O=[`aria-selected`,`onClick`,`onPointerenter`],k={class:`cc-item-body`},A={class:`cc-item-title`},j={key:0,class:`cc-item-sub`},M={key:0,class:`cc-badge`},N={key:1,class:`cc-kbd`},P=o({__name:`CommandCenter`,props:{workspaces:{},hosts:{},activeAgent:{},actions:{},api:{type:Function}},emits:[`close`,`selectWorkspace`,`openFile`,`restoreArchived`],setup(o,{emit:P}){let F=o,I=P,L=h(null),R=h(null);b(L,()=>I(`close`));let z=h(`workspaces`),B=h(``),V=h(0),H=m(()=>new Map(F.hosts.map(e=>[e.id,e.label]))),U=h([]),W=h(!1);async function G(){if(W.value)return;W.value=!0;let e=F.hosts.filter(e=>e.state===`connected`),t=await Promise.allSettled(e.map(e=>F.api(`/hosts/${encodeURIComponent(e.id)}/archived-workspaces`))),n=[];for(let e of t)e.status===`fulfilled`&&Array.isArray(e.value)&&n.push(...e.value);n.sort((e,t)=>Date.parse(t.archivedAt)-Date.parse(e.archivedAt)),U.value=n}let K=h([]),q=h(!1),J,Y=0;async function X(){let e=F.activeAgent;if(!e){K.value=[];return}let t=++Y;q.value=!0;try{let n=await F.api(`/hosts/${encodeURIComponent(e.hostId)}/fs/search?cwd=${encodeURIComponent(e.cwd)}&q=${encodeURIComponent(B.value.trim())}&limit=40`);t===Y&&(K.value=Array.isArray(n.files)?n.files:[])}catch{t===Y&&(K.value=[])}finally{t===Y&&(q.value=!1)}}s([z,B],([e,t])=>{V.value=0,e===`files`?(clearTimeout(J),J=setTimeout(()=>void X(),t?120:0)):e===`workspaces`&&t.trim().length>=2&&G()});let Z=m(()=>{let e=B.value.trim().toLowerCase(),t=e.split(/\s+/).filter(Boolean),n=e=>!t.length||t.every(t=>e.toLowerCase().includes(t));if(z.value===`workspaces`){let t=F.workspaces.filter(e=>n(`${e.name} ${e.project} ${e.branch??``} ${(e.labels??[]).join(` `)} ${H.value.get(e.hostId)??``}`)).slice(0,30).map(e=>({key:`ws:`+e.key,icon:`chat`,title:e.name,sub:[e.project,e.branch,F.hosts.length>1?H.value.get(e.hostId):``].filter(Boolean).join(` · `),badge:e.attention?`needs input`:e.state===`running`?`running`:void 0,run:()=>{I(`selectWorkspace`,e.key),I(`close`)}})),r=e?U.value.filter(e=>e.workspaceId&&n(`${e.name} ${e.project} ${H.value.get(e.hostId)??``}`)).slice(0,12).map(e=>({key:`arch:${e.hostId}:${e.workspaceId}`,icon:`archive`,title:e.name,sub:`${e.project} · archived`,badge:`restore`,run:()=>{e.workspaceId&&I(`restoreArchived`,e.hostId,e.workspaceId),I(`close`)}})):[];return[...t,...r]}return z.value===`files`?K.value.map(e=>({key:`file:`+e,icon:`file`,title:e.split(`/`).pop()||e,sub:e,run:()=>{I(`openFile`,e),I(`close`)}})):F.actions.filter(e=>n(`${e.label} ${e.sub??``}`)).map(e=>({key:`act:`+e.id,icon:e.icon,title:e.label,sub:e.sub??``,shortcut:e.shortcut,run:()=>{I(`close`),e.run()}}))}),Q=[{id:`workspaces`,label:`Workspaces`},{id:`files`,label:`Files`},{id:`actions`,label:`Actions`}];function $(e){if(e.key===`Tab`){e.preventDefault();let t=Q.findIndex(e=>e.id===z.value),n=Q[(t+(e.shiftKey?Q.length-1:1))%Q.length];z.value=n.id}else e.key===`ArrowDown`&&Z.value.length?(e.preventDefault(),V.value=(V.value+1)%Z.value.length):e.key===`ArrowUp`&&Z.value.length?(e.preventDefault(),V.value=(V.value-1+Z.value.length)%Z.value.length):e.key===`Enter`&&Z.value[V.value]&&(e.preventDefault(),Z.value[V.value].run())}return n(()=>{r(()=>R.value?.focus())}),(n,r)=>(v(),_(`div`,{class:`overlay cc-overlay`,onMousedown:r[1]||=u(e=>I(`close`),[`self`])},[p(`section`,{ref_key:`sheet`,ref:L,class:`sheet cc-sheet`,role:`dialog`,"aria-modal":`true`,"aria-label":`Command center`,tabindex:`-1`,onKeydown:$},[p(`div`,x,[e(y,{name:`search`,size:16,class:`cc-search-icon`}),i(p(`input`,{ref_key:`inputEl`,ref:R,"onUpdate:modelValue":r[0]||=e=>B.value=e,type:`search`,class:`cc-input`,placeholder:z.value===`workspaces`?`Jump to workspace or archived session…`:z.value===`files`?`Search files in current workspace…`:`Run an action…`,"aria-label":`Command center search`},null,8,S),[[c,B.value]]),r[2]||=p(`kbd`,{class:`cc-kbd`},`Esc`,-1)]),p(`div`,C,[(v(),_(f,null,t(Q,e=>p(`button`,{key:e.id,type:`button`,role:`tab`,class:l([`cc-tab`,{chosen:z.value===e.id}]),"aria-selected":z.value===e.id,disabled:e.id===`files`&&!o.activeAgent,onClick:t=>{z.value=e.id,R.value?.focus()}},d(e.label),11,w)),64)),r[3]||=p(`span`,{class:`cc-hint`},`Tab to switch`,-1)]),p(`div`,T,[z.value===`files`&&q.value&&!Z.value.length?(v(),_(`p`,E,[...r[4]||=[p(`span`,{class:`spinner spinner-sm`},null,-1),a(` Searching files…`,-1)]])):Z.value.length?g(``,!0):(v(),_(`p`,D,d(z.value===`files`&&!o.activeAgent?`Open a conversation to search its files.`:`No matches.`),1)),(v(!0),_(f,null,t(Z.value,(t,n)=>(v(),_(`button`,{key:t.key,type:`button`,role:`option`,class:l([`cc-item`,{active:n===V.value}]),"aria-selected":n===V.value,onClick:e=>t.run(),onPointerenter:e=>V.value=n},[e(y,{name:t.icon,size:15,class:`cc-item-icon`},null,8,[`name`]),p(`span`,k,[p(`span`,A,d(t.title),1),t.sub?(v(),_(`span`,j,d(t.sub),1)):g(``,!0)]),t.badge?(v(),_(`span`,M,d(t.badge),1)):g(``,!0),t.shortcut?(v(),_(`kbd`,N,d(t.shortcut),1)):g(``,!0)],42,O))),128))])],544)],32))}});export{P as default};
1
+ import{C as e,H as t,I as n,M as r,Q as i,S as a,T as o,Y as s,c,ct as l,d as u,dt as d,f,g as p,h as m,it as h,v as g,y as _,z as v}from"./vue.runtime.esm-bundler-DmQNwI70.js";import{_ as y,g as b}from"./index-DZm2Vxoh.js";var x={class:`cc-input-row`},S=[`placeholder`],C={class:`cc-tabs`,role:`tablist`},w=[`aria-selected`,`disabled`,`onClick`],T={class:`cc-list`,role:`listbox`},E={key:0,class:`cc-empty`},D={key:1,class:`cc-empty`},O=[`aria-selected`,`onClick`,`onPointerenter`],k={class:`cc-item-body`},A={class:`cc-item-title`},j={key:0,class:`cc-item-sub`},M={key:0,class:`cc-badge`},N={key:1,class:`cc-kbd`},P=o({__name:`CommandCenter`,props:{workspaces:{},hosts:{},activeAgent:{},actions:{},api:{type:Function}},emits:[`close`,`selectWorkspace`,`openFile`,`restoreArchived`],setup(o,{emit:P}){let F=o,I=P,L=h(null),R=h(null);b(L,()=>I(`close`));let z=h(`workspaces`),B=h(``),V=h(0),H=m(()=>new Map(F.hosts.map(e=>[e.id,e.label]))),U=h([]),W=h(!1);async function G(){if(W.value)return;W.value=!0;let e=F.hosts.filter(e=>e.state===`connected`),t=await Promise.allSettled(e.map(e=>F.api(`/hosts/${encodeURIComponent(e.id)}/archived-workspaces`))),n=[];for(let e of t)e.status===`fulfilled`&&Array.isArray(e.value)&&n.push(...e.value);n.sort((e,t)=>Date.parse(t.archivedAt)-Date.parse(e.archivedAt)),U.value=n}let K=h([]),q=h(!1),J,Y=0;async function X(){let e=F.activeAgent;if(!e){K.value=[];return}let t=++Y;q.value=!0;try{let n=await F.api(`/hosts/${encodeURIComponent(e.hostId)}/fs/search?cwd=${encodeURIComponent(e.cwd)}&q=${encodeURIComponent(B.value.trim())}&limit=40`);t===Y&&(K.value=Array.isArray(n.files)?n.files:[])}catch{t===Y&&(K.value=[])}finally{t===Y&&(q.value=!1)}}s([z,B],([e,t])=>{V.value=0,e===`files`?(clearTimeout(J),J=setTimeout(()=>void X(),t?120:0)):e===`workspaces`&&t.trim().length>=2&&G()});let Z=m(()=>{let e=B.value.trim().toLowerCase(),t=e.split(/\s+/).filter(Boolean),n=e=>!t.length||t.every(t=>e.toLowerCase().includes(t));if(z.value===`workspaces`){let t=F.workspaces.filter(e=>n(`${e.name} ${e.project} ${e.branch??``} ${(e.labels??[]).join(` `)} ${H.value.get(e.hostId)??``}`)).slice(0,30).map(e=>({key:`ws:`+e.key,icon:`chat`,title:e.name,sub:[e.project,e.branch,F.hosts.length>1?H.value.get(e.hostId):``].filter(Boolean).join(` · `),badge:e.attention?`needs input`:e.state===`running`?`running`:void 0,run:()=>{I(`selectWorkspace`,e.key),I(`close`)}})),r=e?U.value.filter(e=>e.workspaceId&&n(`${e.name} ${e.project} ${H.value.get(e.hostId)??``}`)).slice(0,12).map(e=>({key:`arch:${e.hostId}:${e.workspaceId}`,icon:`archive`,title:e.name,sub:`${e.project} · archived`,badge:`restore`,run:()=>{e.workspaceId&&I(`restoreArchived`,e.hostId,e.workspaceId),I(`close`)}})):[];return[...t,...r]}return z.value===`files`?K.value.map(e=>({key:`file:`+e,icon:`file`,title:e.split(`/`).pop()||e,sub:e,run:()=>{I(`openFile`,e),I(`close`)}})):F.actions.filter(e=>n(`${e.label} ${e.sub??``}`)).map(e=>({key:`act:`+e.id,icon:e.icon,title:e.label,sub:e.sub??``,shortcut:e.shortcut,run:()=>{I(`close`),e.run()}}))}),Q=[{id:`workspaces`,label:`Workspaces`},{id:`files`,label:`Files`},{id:`actions`,label:`Actions`}];function $(e){if(e.key===`Tab`){e.preventDefault();let t=Q.findIndex(e=>e.id===z.value),n=Q[(t+(e.shiftKey?Q.length-1:1))%Q.length];z.value=n.id}else e.key===`ArrowDown`&&Z.value.length?(e.preventDefault(),V.value=(V.value+1)%Z.value.length):e.key===`ArrowUp`&&Z.value.length?(e.preventDefault(),V.value=(V.value-1+Z.value.length)%Z.value.length):e.key===`Enter`&&Z.value[V.value]&&(e.preventDefault(),Z.value[V.value].run())}return n(()=>{r(()=>R.value?.focus())}),(n,r)=>(v(),_(`div`,{class:`overlay cc-overlay`,onMousedown:r[1]||=u(e=>I(`close`),[`self`])},[p(`section`,{ref_key:`sheet`,ref:L,class:`sheet cc-sheet`,role:`dialog`,"aria-modal":`true`,"aria-label":`Command center`,tabindex:`-1`,onKeydown:$},[p(`div`,x,[e(y,{name:`search`,size:16,class:`cc-search-icon`}),i(p(`input`,{ref_key:`inputEl`,ref:R,"onUpdate:modelValue":r[0]||=e=>B.value=e,type:`search`,class:`cc-input`,placeholder:z.value===`workspaces`?`Jump to workspace or archived session…`:z.value===`files`?`Search files in current workspace…`:`Run an action…`,"aria-label":`Command center search`},null,8,S),[[c,B.value]]),r[2]||=p(`kbd`,{class:`cc-kbd`},`Esc`,-1)]),p(`div`,C,[(v(),_(f,null,t(Q,e=>p(`button`,{key:e.id,type:`button`,role:`tab`,class:l([`cc-tab`,{chosen:z.value===e.id}]),"aria-selected":z.value===e.id,disabled:e.id===`files`&&!o.activeAgent,onClick:t=>{z.value=e.id,R.value?.focus()}},d(e.label),11,w)),64)),r[3]||=p(`span`,{class:`cc-hint`},`Tab to switch`,-1)]),p(`div`,T,[z.value===`files`&&q.value&&!Z.value.length?(v(),_(`p`,E,[...r[4]||=[p(`span`,{class:`spinner spinner-sm`},null,-1),a(` Searching files…`,-1)]])):Z.value.length?g(``,!0):(v(),_(`p`,D,d(z.value===`files`&&!o.activeAgent?`Open a conversation to search its files.`:`No matches.`),1)),(v(!0),_(f,null,t(Z.value,(t,n)=>(v(),_(`button`,{key:t.key,type:`button`,role:`option`,class:l([`cc-item`,{active:n===V.value}]),"aria-selected":n===V.value,onClick:e=>t.run(),onPointerenter:e=>V.value=n},[e(y,{name:t.icon,size:15,class:`cc-item-icon`},null,8,[`name`]),p(`span`,k,[p(`span`,A,d(t.title),1),t.sub?(v(),_(`span`,j,d(t.sub),1)):g(``,!0)]),t.badge?(v(),_(`span`,M,d(t.badge),1)):g(``,!0),t.shortcut?(v(),_(`kbd`,N,d(t.shortcut),1)):g(``,!0)],42,O))),128))])],544)],32))}});export{P as default};
@@ -1 +1 @@
1
- import{H as e,L as t,Q as n,S as r,T as i,Y as a,c as o,d as s,dt as c,f as l,g as u,it as d,v as f,y as p,z as m}from"./vue.runtime.esm-bundler-DmQNwI70.js";import{m as h}from"./index-DAwT50Ss.js";var g={class:`conversation-search`},_=[`disabled`],v={key:0,class:`form-error`,role:`alert`},y={key:1,class:`subtle small`,role:`status`},b={key:2,class:`subtle small`,role:`status`},x={key:3,class:`search-results`,"aria-label":`Search results`},S=[`onClick`],C={class:`search-result-role`},w={class:`search-result-meta`},T=[`disabled`],E=h(i({__name:`ConversationSearch`,props:{base:{},api:{type:Function}},emits:[`jump`],setup(i,{emit:h}){let E=i,D=h,O=d(``),k=d(``),A=d(!1),j=d(!1),M=d([]),N=d(null),P=d(``),F=0,I=``;t(()=>F++);function L(){F++,M.value=[],N.value=null,j.value=!1,A.value=!1,k.value=``}a(O,L),a(()=>E.base,()=>{O.value=``,L()});async function R(e=!1){if(A.value||!O.value.trim())return;let t=++F;e||(M.value=[],N.value=null,I=O.value.trim()),A.value=!0,k.value=``;try{let n=await E.api(E.base+`/search?q=`+encodeURIComponent(I)+(e&&N.value!==null?`&cursor=`+N.value:``));if(t!==F)return;if(e&&P.value!==n.epoch)throw Error(`Conversation changed. Search again.`);P.value=n.epoch,M.value=[...new Map((e?[...M.value,...n.locations]:n.locations).map(e=>[e.seq,e])).values()],N.value=n.nextCursor,j.value=!0}catch(e){t===F&&(k.value=e.message)}finally{t===F&&(A.value=!1)}}return(t,i)=>(m(),p(`section`,g,[i[6]||=u(`p`,{class:`subtle small search-intro`},`Search user and agent messages across the full conversation history. Select a result to read it in context.`,-1),u(`form`,{class:`search-form`,role:`search`,onSubmit:i[1]||=s(e=>R(!1),[`prevent`])},[n(u(`input`,{"onUpdate:modelValue":i[0]||=e=>O.value=e,type:`search`,maxlength:`500`,"aria-label":`Search conversation content`,placeholder:`Search all messages…`},null,512),[[o,O.value]]),u(`button`,{class:`btn btn-primary btn-sm`,disabled:A.value||!O.value.trim()},`Search`,8,_)],32),k.value?(m(),p(`p`,v,c(k.value),1)):f(``,!0),j.value&&!M.value.length&&!A.value?(m(),p(`p`,y,`No matching messages.`)):f(``,!0),A.value?(m(),p(`p`,b,`Searching…`)):f(``,!0),M.value.length?(m(),p(`ul`,x,[(m(!0),p(l,null,e(M.value,e=>(m(),p(`li`,{key:e.seq},[u(`button`,{type:`button`,class:`search-result`,onClick:t=>D(`jump`,e.seq,P.value)},[u(`span`,C,c(e.role===`assistant`?`Agent reply`:`Your message`),1),i[3]||=r(),u(`span`,w,`#`+c(e.seq)+c(e.count?` · ${e.count} matches`:``),1),i[4]||=r(),i[5]||=u(`span`,{class:`search-result-go`,"aria-hidden":`true`},`→`,-1)],8,S)]))),128))])):f(``,!0),N.value===null?f(``,!0):(m(),p(`button`,{key:4,type:`button`,class:`btn btn-outline btn-sm search-more`,disabled:A.value,onClick:i[2]||=e=>R(!0)},`More results`,8,T))]))}}),[[`__scopeId`,`data-v-d9291547`]]);export{E as default};
1
+ import{H as e,L as t,Q as n,S as r,T as i,Y as a,c as o,d as s,dt as c,f as l,g as u,it as d,v as f,y as p,z as m}from"./vue.runtime.esm-bundler-DmQNwI70.js";import{m as h}from"./index-DZm2Vxoh.js";var g={class:`conversation-search`},_=[`disabled`],v={key:0,class:`form-error`,role:`alert`},y={key:1,class:`subtle small`,role:`status`},b={key:2,class:`subtle small`,role:`status`},x={key:3,class:`search-results`,"aria-label":`Search results`},S=[`onClick`],C={class:`search-result-role`},w={class:`search-result-meta`},T=[`disabled`],E=h(i({__name:`ConversationSearch`,props:{base:{},api:{type:Function}},emits:[`jump`],setup(i,{emit:h}){let E=i,D=h,O=d(``),k=d(``),A=d(!1),j=d(!1),M=d([]),N=d(null),P=d(``),F=0,I=``;t(()=>F++);function L(){F++,M.value=[],N.value=null,j.value=!1,A.value=!1,k.value=``}a(O,L),a(()=>E.base,()=>{O.value=``,L()});async function R(e=!1){if(A.value||!O.value.trim())return;let t=++F;e||(M.value=[],N.value=null,I=O.value.trim()),A.value=!0,k.value=``;try{let n=await E.api(E.base+`/search?q=`+encodeURIComponent(I)+(e&&N.value!==null?`&cursor=`+N.value:``));if(t!==F)return;if(e&&P.value!==n.epoch)throw Error(`Conversation changed. Search again.`);P.value=n.epoch,M.value=[...new Map((e?[...M.value,...n.locations]:n.locations).map(e=>[e.seq,e])).values()],N.value=n.nextCursor,j.value=!0}catch(e){t===F&&(k.value=e.message)}finally{t===F&&(A.value=!1)}}return(t,i)=>(m(),p(`section`,g,[i[6]||=u(`p`,{class:`subtle small search-intro`},`Search user and agent messages across the full conversation history. Select a result to read it in context.`,-1),u(`form`,{class:`search-form`,role:`search`,onSubmit:i[1]||=s(e=>R(!1),[`prevent`])},[n(u(`input`,{"onUpdate:modelValue":i[0]||=e=>O.value=e,type:`search`,maxlength:`500`,"aria-label":`Search conversation content`,placeholder:`Search all messages…`},null,512),[[o,O.value]]),u(`button`,{class:`btn btn-primary btn-sm`,disabled:A.value||!O.value.trim()},`Search`,8,_)],32),k.value?(m(),p(`p`,v,c(k.value),1)):f(``,!0),j.value&&!M.value.length&&!A.value?(m(),p(`p`,y,`No matching messages.`)):f(``,!0),A.value?(m(),p(`p`,b,`Searching…`)):f(``,!0),M.value.length?(m(),p(`ul`,x,[(m(!0),p(l,null,e(M.value,e=>(m(),p(`li`,{key:e.seq},[u(`button`,{type:`button`,class:`search-result`,onClick:t=>D(`jump`,e.seq,P.value)},[u(`span`,C,c(e.role===`assistant`?`Agent reply`:`Your message`),1),i[3]||=r(),u(`span`,w,`#`+c(e.seq)+c(e.count?` · ${e.count} matches`:``),1),i[4]||=r(),i[5]||=u(`span`,{class:`search-result-go`,"aria-hidden":`true`},`→`,-1)],8,S)]))),128))])):f(``,!0),N.value===null?f(``,!0):(m(),p(`button`,{key:4,type:`button`,class:`btn btn-outline btn-sm search-more`,disabled:A.value,onClick:i[2]||=e=>R(!0)},`More results`,8,T))]))}}),[[`__scopeId`,`data-v-d9291547`]]);export{E as default};
@@ -1,2 +1,2 @@
1
- import{C as e,G as t,M as n,P as r,S as i,T as a,Y as o,_ as s,dt as c,f as l,g as u,h as d,it as f,st as p,ut as m,v as h,y as g,z as _}from"./vue.runtime.esm-bundler-DmQNwI70.js";import{_ as v,d as y,f as b,i as x,m as S,p as C,r as w}from"./index-DAwT50Ss.js";import{n as T,t as ee}from"./highlight-BnTrj1LT.js";var te={class:`file-view`},ne={class:`file-bar`},re=[`title`],ie={key:0,class:`file-bar-meta`},ae=[`title`],oe=[`href`],se=[`title`],ce={key:0,class:`timeline-empty`},le={key:1,class:`file-error`},ue=[`src`,`alt`],de={key:0,class:`file-link-notice`,role:`status`},fe={key:2,class:`file-text wrap`},pe={class:`code-wrap`},me={class:`code-gutter`,"aria-hidden":`true`},he=[`innerHTML`],ge={key:2,class:`file-text`},_e={key:0,class:`file-note`},ve={key:5,class:`file-note file-binary-note`},E=[`href`],D=S(a({__name:`FileViewer`,props:{hostId:{},cwd:{},path:{},api:{type:Function},session:{},jump:{},view:{},viewKey:{}},emits:[`open`,`reveal`,`view`],setup(a,{emit:S}){let D=a,O=S,k=f(null),A=f(``),j=f(!1),M=f(D.view?.rendered??!0),N=d(()=>`/hosts/${encodeURIComponent(D.hostId)}/fs`),P=d(()=>`cwd=${encodeURIComponent(D.cwd)}&path=${encodeURIComponent(D.path)}`),F=d(()=>/\.(png|jpe?g|webp|gif|bmp|avif)$/i.test(D.path)),I=d(()=>/\.(md|markdown|mdx)$/i.test(D.path)&&k.value?.text!==void 0),L=0;async function R(){let e=++L;j.value=!0,A.value=``;try{let t=await D.api(`${N.value}/read?${P.value}`);if(e!==L)return;k.value=t,I.value&&w()}catch(t){e===L&&(A.value=t.message)}finally{e===L&&(j.value=!1)}}o(()=>[D.hostId,D.cwd,D.path],R,{immediate:!0});let z=d(()=>D.path.startsWith(`/`)||D.path.startsWith(`~`)?D.path:`${D.cwd.replace(/\/$/,``)}/${D.path}`),ye=d(()=>{let e=k.value?.text??``;if(!D.session)return e;let t=z.value.slice(0,z.value.lastIndexOf(`/`))||`/`,n={session:D.session,cwd:t,workspace:D.cwd};return C(b(e,{...n,rawBase:`/api${N.value}`}),n)}),B=f(``),V;function H(e){B.value=e,clearTimeout(V),V=setTimeout(()=>B.value=``,4e3)}function be(e){let t=e.target?.closest?.(`a`),n=y(t?.getAttribute(`href`));if(n){if(n.kind===`copy`){e.preventDefault();let t=()=>H(`Can't open this here. Path: ${n.path}`);navigator.clipboard?navigator.clipboard.writeText(n.path).then(()=>H(`Copied path: ${n.path}`),t):t()}else e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),n.kind===`reveal`?O(`reveal`,n.path):O(`open`,n.path,n))}}let U=f(null),W=f(D.view?.mark??null),G=D.view?.jumped??0,K=!1,q=d(()=>{let e=k.value?.text??``,t=1;for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t++;return t});o([()=>D.jump?.seq,()=>k.value],async()=>{if(!k.value)return;let e=D.jump;if(e&&e.seq!==G&&k.value.text!==void 0){G=e.seq,K=!0,/\.(md|markdown|mdx)$/i.test(D.path)&&(M.value=!1),await n();let t=U.value?.querySelector(`.code-gutter`);if(!U.value||!t)return;let r=getComputedStyle(t),i=parseFloat(r.lineHeight)||20,a=Math.min(e.line,q.value),o=Math.min(Math.max(e.end??a,a),q.value);W.value={top:parseFloat(r.paddingTop)+(a-1)*i,height:(o-a+1)*i},U.value.scrollTop=Math.max(0,W.value.top-U.value.clientHeight/3);return}if(K)return;K=!0;let t=D.view?.scrollTop??0;t&&(await n(),U.value&&(U.value.scrollTop=t),requestAnimationFrame(()=>{U.value&&U.value.scrollTop<t&&(U.value.scrollTop=t)}))},{immediate:!0}),r(()=>{L++,clearTimeout(V),clearTimeout($),D.viewKey&&O(`view`,D.viewKey,{rendered:M.value,scrollTop:U.value?.scrollTop??0,mark:W.value,jumped:G})});let xe=d(()=>`/api${N.value}/raw?${P.value}`),J=d(()=>Array.from({length:q.value},(e,t)=>t+1).join(`
1
+ import{C as e,G as t,M as n,P as r,S as i,T as a,Y as o,_ as s,dt as c,f as l,g as u,h as d,it as f,st as p,ut as m,v as h,y as g,z as _}from"./vue.runtime.esm-bundler-DmQNwI70.js";import{_ as v,d as y,f as b,i as x,m as S,p as C,r as w}from"./index-DZm2Vxoh.js";import{n as T,t as ee}from"./highlight-BnTrj1LT.js";var te={class:`file-view`},ne={class:`file-bar`},re=[`title`],ie={key:0,class:`file-bar-meta`},ae=[`title`],oe=[`href`],se=[`title`],ce={key:0,class:`timeline-empty`},le={key:1,class:`file-error`},ue=[`src`,`alt`],de={key:0,class:`file-link-notice`,role:`status`},fe={key:2,class:`file-text wrap`},pe={class:`code-wrap`},me={class:`code-gutter`,"aria-hidden":`true`},he=[`innerHTML`],ge={key:2,class:`file-text`},_e={key:0,class:`file-note`},ve={key:5,class:`file-note file-binary-note`},E=[`href`],D=S(a({__name:`FileViewer`,props:{hostId:{},cwd:{},path:{},api:{type:Function},session:{},jump:{},view:{},viewKey:{}},emits:[`open`,`reveal`,`view`],setup(a,{emit:S}){let D=a,O=S,k=f(null),A=f(``),j=f(!1),M=f(D.view?.rendered??!0),N=d(()=>`/hosts/${encodeURIComponent(D.hostId)}/fs`),P=d(()=>`cwd=${encodeURIComponent(D.cwd)}&path=${encodeURIComponent(D.path)}`),F=d(()=>/\.(png|jpe?g|webp|gif|bmp|avif)$/i.test(D.path)),I=d(()=>/\.(md|markdown|mdx)$/i.test(D.path)&&k.value?.text!==void 0),L=0;async function R(){let e=++L;j.value=!0,A.value=``;try{let t=await D.api(`${N.value}/read?${P.value}`);if(e!==L)return;k.value=t,I.value&&w()}catch(t){e===L&&(A.value=t.message)}finally{e===L&&(j.value=!1)}}o(()=>[D.hostId,D.cwd,D.path],R,{immediate:!0});let z=d(()=>D.path.startsWith(`/`)||D.path.startsWith(`~`)?D.path:`${D.cwd.replace(/\/$/,``)}/${D.path}`),ye=d(()=>{let e=k.value?.text??``;if(!D.session)return e;let t=z.value.slice(0,z.value.lastIndexOf(`/`))||`/`,n={session:D.session,cwd:t,workspace:D.cwd};return C(b(e,{...n,rawBase:`/api${N.value}`}),n)}),B=f(``),V;function H(e){B.value=e,clearTimeout(V),V=setTimeout(()=>B.value=``,4e3)}function be(e){let t=e.target?.closest?.(`a`),n=y(t?.getAttribute(`href`));if(n){if(n.kind===`copy`){e.preventDefault();let t=()=>H(`Can't open this here. Path: ${n.path}`);navigator.clipboard?navigator.clipboard.writeText(n.path).then(()=>H(`Copied path: ${n.path}`),t):t()}else e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),n.kind===`reveal`?O(`reveal`,n.path):O(`open`,n.path,n))}}let U=f(null),W=f(D.view?.mark??null),G=D.view?.jumped??0,K=!1,q=d(()=>{let e=k.value?.text??``,t=1;for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t++;return t});o([()=>D.jump?.seq,()=>k.value],async()=>{if(!k.value)return;let e=D.jump;if(e&&e.seq!==G&&k.value.text!==void 0){G=e.seq,K=!0,/\.(md|markdown|mdx)$/i.test(D.path)&&(M.value=!1),await n();let t=U.value?.querySelector(`.code-gutter`);if(!U.value||!t)return;let r=getComputedStyle(t),i=parseFloat(r.lineHeight)||20,a=Math.min(e.line,q.value),o=Math.min(Math.max(e.end??a,a),q.value);W.value={top:parseFloat(r.paddingTop)+(a-1)*i,height:(o-a+1)*i},U.value.scrollTop=Math.max(0,W.value.top-U.value.clientHeight/3);return}if(K)return;K=!0;let t=D.view?.scrollTop??0;t&&(await n(),U.value&&(U.value.scrollTop=t),requestAnimationFrame(()=>{U.value&&U.value.scrollTop<t&&(U.value.scrollTop=t)}))},{immediate:!0}),r(()=>{L++,clearTimeout(V),clearTimeout($),D.viewKey&&O(`view`,D.viewKey,{rendered:M.value,scrollTop:U.value?.scrollTop??0,mark:W.value,jumped:G})});let xe=d(()=>`/api${N.value}/raw?${P.value}`),J=d(()=>Array.from({length:q.value},(e,t)=>t+1).join(`
2
2
  `)),Y=d(()=>k.value?.text===void 0?null:ee(k.value.text,T(D.path))),X=e=>e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`,Z=f(!1),Q=d(()=>`/api/hosts/${encodeURIComponent(D.hostId)}/fs/download?cwd=${encodeURIComponent(D.cwd)}&path=${encodeURIComponent(D.path)}`),$;async function Se(){await navigator.clipboard?.writeText(z.value).catch(()=>{}),Z.value=!0,clearTimeout($),$=setTimeout(()=>Z.value=!1,1200)}return(n,r)=>(_(),g(`div`,te,[u(`div`,ne,[e(v,{name:`file`,size:14,class:`file-bar-icon`}),u(`span`,{class:`file-bar-path`,title:a.path},c(a.path),9,re),k.value?(_(),g(`span`,ie,c(X(k.value.size)),1)):h(``,!0),I.value?(_(),g(`button`,{key:1,class:`icon-btn`,title:M.value?`Show source`:`Show rendered`,onClick:r[0]||=e=>M.value=!M.value},[e(v,{name:M.value?`terminal`:`eye`,size:14},null,8,[`name`])],8,ae)):h(``,!0),u(`a`,{href:Q.value,download:``,class:`icon-btn`,title:`Download file`,"aria-label":`Download file`},[e(v,{name:`download`,size:14})],8,oe),u(`button`,{class:`icon-btn`,title:`Reload`,"aria-label":`Reload file`,onClick:R},[e(v,{name:`refresh`,size:14})]),u(`button`,{class:`icon-btn`,title:Z.value?`Copied`:`Copy path`,"aria-label":`Copy path`,onClick:Se},[e(v,{name:Z.value?`check`:`copy`,size:14},null,8,[`name`])],8,se)]),u(`div`,{ref_key:`body`,ref:U,class:`file-body`},[j.value&&!k.value?(_(),g(`div`,ce,[...r[1]||=[u(`span`,{class:`spinner`},null,-1)]])):A.value?(_(),g(`p`,le,[e(v,{name:`alert`,size:13}),i(c(A.value),1)])):F.value?(_(),g(`img`,{key:2,src:xe.value,alt:a.path,class:`file-image`},null,8,ue)):I.value&&M.value?(_(),g(`div`,{key:3,class:`file-markdown`,onClick:be},[B.value?(_(),g(`p`,de,c(B.value),1)):h(``,!0),p(x)?(_(),s(t(p(x)),{key:1,content:ye.value,final:!0},null,8,[`content`])):(_(),g(`pre`,fe,c(k.value?.text),1))])):k.value?.text===void 0?k.value?(_(),g(`div`,ve,[u(`span`,null,c(k.value.mime||k.value.kind)+` · not shown as text (`+c(X(k.value.size))+`)`,1),u(`a`,{href:Q.value,download:``,class:`btn btn-sm btn-outline`},[e(v,{name:`download`,size:13}),r[2]||=i(`Download`,-1)],8,E)])):h(``,!0):(_(),g(l,{key:4},[u(`div`,pe,[W.value?(_(),g(`div`,{key:0,class:`line-mark`,style:m({top:W.value.top+`px`,height:W.value.height+`px`}),"aria-hidden":`true`},null,4)):h(``,!0),u(`pre`,me,c(J.value),1),Y.value===null?(_(),g(`pre`,ge,c(k.value.text),1)):(_(),g(`pre`,{key:1,class:`file-text hljs`,innerHTML:Y.value},null,8,he))]),k.value.truncated?(_(),g(`p`,_e,`Showing the first 1 MB.`)):h(``,!0)],64))],512)]))}}),[[`__scopeId`,`data-v-2841a6c4`]]);export{D as default};
@@ -1 +1 @@
1
- import{C as e,H as t,M as n,S as r,T as i,Y as a,_ as o,at as s,ct as c,dt as l,f as u,g as d,h as f,it as p,ut as m,v as h,y as g,z as _}from"./vue.runtime.esm-bundler-DmQNwI70.js";import{_ as v,m as y}from"./index-DAwT50Ss.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(i({__name:`FilesPanel`,props:{hostId:{},cwd:{},api:{type:Function},activePath:{},reveal:{}},emits:[`open`],setup(i,{emit:y}){let k=i,A=y,j=s(new Map),M=p(new Set),N=p(new Set),P=p(``),F=f(()=>`/hosts/${encodeURIComponent(k.hostId)}/fs`),I=e=>`cwd=${encodeURIComponent(k.cwd)}&path=${encodeURIComponent(e)}`,L=new Map,R=0;function z(e){let t=L.get(e);if(t)return t;let n=L,r=B(e).finally(()=>{n.get(e)===r&&n.delete(e)});return n.set(e,r),r}async function B(e){let t=R;N.value=new Set(N.value).add(e);try{let n=await k.api(`${F.value}/list?${I(e)}`);if(t!==R)return;let r=new Map(j.value);r.set(e,n.entries),j.value=r,P.value=``}catch(e){t===R&&(P.value=e.message)}finally{if(t!==R)return;let n=new Set(N.value);n.delete(e),N.value=n}}a(()=>[k.hostId,k.cwd],()=>{R++,L=new Map,N.value=new Set,P.value=``,j.value=new Map,M.value=new Set,z(`.`)},{immediate:!0});function V(e){let t=new Set(M.value);t.has(e.path)?t.delete(e.path):(t.add(e.path),j.value.has(e.path)||z(e.path)),M.value=t}let H=f(()=>{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}),U=p(null),W=p(null);return a(()=>k.activePath,()=>W.value=null),a(()=>k.reveal?.seq,async()=>{let e=k.reveal?.path;if(!e)return;let t=e===`.`?[]:e.split(`/`).filter(Boolean),r=R;await z(`.`);for(let e=1;e<=t.length;e++){if(r!==R)return;let n=t.slice(0,e).join(`/`);if(j.value.has(n)||await z(n),r!==R)return;M.value=new Set(M.value).add(n)}W.value=t.join(`/`)||null,await n();let i=Array.from(U.value?.querySelectorAll(`.tree-row`)??[]).find(e=>e.dataset.path===W.value);i?.scrollIntoView({block:`center`}),i?.focus({preventScroll:!0})},{immediate:!0}),(n,a)=>(_(),g(`div`,b,[d(`div`,x,[d(`span`,{class:`files-root`,title:i.cwd},l(i.cwd.split(`/`).filter(Boolean).pop()||i.cwd),9,S),d(`button`,{class:`icon-btn`,title:`Refresh`,"aria-label":`Refresh files`,onClick:a[0]||=e=>{j.value=new Map,M.value=new Set,z(`.`)}},[e(v,{name:`refresh`,size:14})])]),P.value?(_(),g(`p`,C,[e(v,{name:`alert`,size:13}),r(l(P.value),1)])):h(``,!0),d(`div`,{ref_key:`tree`,ref:U,class:`tree`,role:`tree`},[(_(!0),g(u,null,t(H.value,t=>(_(),g(`button`,{key:t.entry.path,class:c([`tree-row`,{chosen:t.entry.path===i.activePath||t.entry.path===W.value}]),"data-path":t.entry.path,role:`treeitem`,"aria-expanded":t.entry.kind===`directory`?M.value.has(t.entry.path):void 0,style:m({paddingLeft:8+t.depth*14+`px`}),title:t.entry.path,onClick:e=>t.entry.kind===`directory`?V(t.entry):A(`open`,t.entry.path)},[t.entry.kind===`directory`?(_(),o(v,{key:0,name:`chevron`,size:11,class:c([`tree-caret`,{open:M.value.has(t.entry.path)}])},null,8,[`class`])):(_(),g(`span`,T)),e(v,{name:t.entry.kind===`directory`?`folder`:`file`,size:14,class:`tree-icon`},null,8,[`name`]),d(`span`,E,l(t.entry.name),1),N.value.has(t.entry.path)?(_(),g(`span`,D)):h(``,!0)],14,w))),128)),!H.value.length&&N.value.has(`.`)?(_(),g(`div`,O,[...a[1]||=[d(`span`,{class:`spinner`},null,-1)]])):h(``,!0)],512)]))}}),[[`__scopeId`,`data-v-64ccc6d9`]]);export{k as default};
1
+ import{C as e,H as t,M as n,S as r,T as i,Y as a,_ as o,at as s,ct as c,dt as l,f as u,g as d,h as f,it as p,ut as m,v as h,y as g,z as _}from"./vue.runtime.esm-bundler-DmQNwI70.js";import{_ as v,m as y}from"./index-DZm2Vxoh.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(i({__name:`FilesPanel`,props:{hostId:{},cwd:{},api:{type:Function},activePath:{},reveal:{}},emits:[`open`],setup(i,{emit:y}){let k=i,A=y,j=s(new Map),M=p(new Set),N=p(new Set),P=p(``),F=f(()=>`/hosts/${encodeURIComponent(k.hostId)}/fs`),I=e=>`cwd=${encodeURIComponent(k.cwd)}&path=${encodeURIComponent(e)}`,L=new Map,R=0;function z(e){let t=L.get(e);if(t)return t;let n=L,r=B(e).finally(()=>{n.get(e)===r&&n.delete(e)});return n.set(e,r),r}async function B(e){let t=R;N.value=new Set(N.value).add(e);try{let n=await k.api(`${F.value}/list?${I(e)}`);if(t!==R)return;let r=new Map(j.value);r.set(e,n.entries),j.value=r,P.value=``}catch(e){t===R&&(P.value=e.message)}finally{if(t!==R)return;let n=new Set(N.value);n.delete(e),N.value=n}}a(()=>[k.hostId,k.cwd],()=>{R++,L=new Map,N.value=new Set,P.value=``,j.value=new Map,M.value=new Set,z(`.`)},{immediate:!0});function V(e){let t=new Set(M.value);t.has(e.path)?t.delete(e.path):(t.add(e.path),j.value.has(e.path)||z(e.path)),M.value=t}let H=f(()=>{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}),U=p(null),W=p(null);return a(()=>k.activePath,()=>W.value=null),a(()=>k.reveal?.seq,async()=>{let e=k.reveal?.path;if(!e)return;let t=e===`.`?[]:e.split(`/`).filter(Boolean),r=R;await z(`.`);for(let e=1;e<=t.length;e++){if(r!==R)return;let n=t.slice(0,e).join(`/`);if(j.value.has(n)||await z(n),r!==R)return;M.value=new Set(M.value).add(n)}W.value=t.join(`/`)||null,await n();let i=Array.from(U.value?.querySelectorAll(`.tree-row`)??[]).find(e=>e.dataset.path===W.value);i?.scrollIntoView({block:`center`}),i?.focus({preventScroll:!0})},{immediate:!0}),(n,a)=>(_(),g(`div`,b,[d(`div`,x,[d(`span`,{class:`files-root`,title:i.cwd},l(i.cwd.split(`/`).filter(Boolean).pop()||i.cwd),9,S),d(`button`,{class:`icon-btn`,title:`Refresh`,"aria-label":`Refresh files`,onClick:a[0]||=e=>{j.value=new Map,M.value=new Set,z(`.`)}},[e(v,{name:`refresh`,size:14})])]),P.value?(_(),g(`p`,C,[e(v,{name:`alert`,size:13}),r(l(P.value),1)])):h(``,!0),d(`div`,{ref_key:`tree`,ref:U,class:`tree`,role:`tree`},[(_(!0),g(u,null,t(H.value,t=>(_(),g(`button`,{key:t.entry.path,class:c([`tree-row`,{chosen:t.entry.path===i.activePath||t.entry.path===W.value}]),"data-path":t.entry.path,role:`treeitem`,"aria-expanded":t.entry.kind===`directory`?M.value.has(t.entry.path):void 0,style:m({paddingLeft:8+t.depth*14+`px`}),title:t.entry.path,onClick:e=>t.entry.kind===`directory`?V(t.entry):A(`open`,t.entry.path)},[t.entry.kind===`directory`?(_(),o(v,{key:0,name:`chevron`,size:11,class:c([`tree-caret`,{open:M.value.has(t.entry.path)}])},null,8,[`class`])):(_(),g(`span`,T)),e(v,{name:t.entry.kind===`directory`?`folder`:`file`,size:14,class:`tree-icon`},null,8,[`name`]),d(`span`,E,l(t.entry.name),1),N.value.has(t.entry.path)?(_(),g(`span`,D)):h(``,!0)],14,w))),128)),!H.value.length&&N.value.has(`.`)?(_(),g(`div`,O,[...a[1]||=[d(`span`,{class:`spinner`},null,-1)]])):h(``,!0)],512)]))}}),[[`__scopeId`,`data-v-64ccc6d9`]]);export{k as default};