@av-pi-studio/workbench 0.0.0-stage → 0.0.118

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 (273) hide show
  1. package/README.md +157 -2
  2. package/dist/chunks/BinaryFallbackViewer-BN-9Yvel.js +19 -0
  3. package/dist/chunks/ChatPanel-CjPUJMEs.js +2493 -0
  4. package/dist/chunks/CodeView-6kJms_MF.js +143 -0
  5. package/dist/chunks/DiffView-BqDuT3CF.js +48 -0
  6. package/dist/chunks/FilePanel-B8IXG2bj.js +92 -0
  7. package/dist/chunks/HtmlViewer-DpuVFaDo.js +490 -0
  8. package/dist/chunks/ImageViewer-BBfyA5QN.js +27 -0
  9. package/dist/chunks/MarkdownFileViewer-DPFPDS7G.js +88 -0
  10. package/dist/chunks/ModelProvidersPanel-Dsezq7Ss.js +95 -0
  11. package/dist/chunks/MoleculeViewerPanel-DEEU6Zkx.js +191 -0
  12. package/dist/chunks/PdfViewer-BdacmAu_.js +300 -0
  13. package/dist/chunks/SaveFileButton-2rOu02Xx.js +33 -0
  14. package/dist/chunks/SettingsDialog-DO1tDhMW.js +471 -0
  15. package/dist/chunks/SkillsPanel-DZDia4Pw.js +833 -0
  16. package/dist/chunks/TerminalPanel-bphwCSyW.js +242 -0
  17. package/dist/chunks/TextViewer-CVGqN6yy.js +63 -0
  18. package/dist/chunks/VideoViewer-BkB9BoOr.js +20 -0
  19. package/dist/chunks/ViewersPanel-C2E9FLf7.js +50 -0
  20. package/dist/chunks/href-resolution-jv3tpRcp.js +25 -0
  21. package/dist/chunks/index-Dlz8mEKZ.js +6258 -0
  22. package/dist/chunks/markdown-B2OXhZ-_.js +353 -0
  23. package/dist/chunks/provider-auth-store-C1GaLTlw.js +34 -0
  24. package/dist/chunks/use-file-download-CogCqTvU.js +31 -0
  25. package/dist/chunks/use-file-watch-Bb_Xzbr-.js +55 -0
  26. package/dist/chunks/use-provider-auth-list-DTjIZycd.js +16 -0
  27. package/dist/features/agent-ui/AskCard.d.ts +62 -0
  28. package/dist/features/agent-ui/agent-ui-store.d.ts +84 -0
  29. package/dist/features/agent-ui/announce.d.ts +51 -0
  30. package/dist/features/agent-ui/ask-list.d.ts +53 -0
  31. package/dist/features/agent-ui/ask-placement.d.ts +47 -0
  32. package/dist/features/agent-ui/deadline.d.ts +27 -0
  33. package/dist/features/agent-ui/keyboard.d.ts +37 -0
  34. package/dist/features/agent-ui/notify-effect.d.ts +41 -0
  35. package/dist/features/agent-ui/option-layout.d.ts +24 -0
  36. package/dist/features/agent-ui/outcome-line.d.ts +38 -0
  37. package/dist/features/agent-ui/prompt-text.d.ts +24 -0
  38. package/dist/features/chat/Attachments.d.ts +20 -0
  39. package/dist/features/chat/ChatPanel.d.ts +12 -0
  40. package/dist/features/chat/CommandMenu.d.ts +41 -0
  41. package/dist/features/chat/Composer.d.ts +58 -0
  42. package/dist/features/chat/ForkDialog.d.ts +24 -0
  43. package/dist/features/chat/ModelMenu.d.ts +54 -0
  44. package/dist/features/chat/ThinkingMenu.d.ts +39 -0
  45. package/dist/features/chat/Timeline.d.ts +30 -0
  46. package/dist/features/chat/TurnProgressBar.d.ts +14 -0
  47. package/dist/features/chat/composer-busy.d.ts +22 -0
  48. package/dist/features/chat/composer-gate.d.ts +37 -0
  49. package/dist/features/chat/composer-path-drop.d.ts +75 -0
  50. package/dist/features/chat/fork-correlation.d.ts +39 -0
  51. package/dist/features/chat/fork-gate.d.ts +27 -0
  52. package/dist/features/chat/fork-picker-nav.d.ts +14 -0
  53. package/dist/features/chat/fork-result.d.ts +43 -0
  54. package/dist/features/chat/model-menu-sort.d.ts +30 -0
  55. package/dist/features/chat/onboarding-nudge.d.ts +18 -0
  56. package/dist/features/chat/rows/AssistantRow.d.ts +24 -0
  57. package/dist/features/chat/rows/CompactionRow.d.ts +16 -0
  58. package/dist/features/chat/rows/ErrorRow.d.ts +13 -0
  59. package/dist/features/chat/rows/ReasoningRow.d.ts +16 -0
  60. package/dist/features/chat/rows/RowShell.d.ts +37 -0
  61. package/dist/features/chat/rows/SystemRow.d.ts +11 -0
  62. package/dist/features/chat/rows/ToolCard.d.ts +30 -0
  63. package/dist/features/chat/rows/UserRow.d.ts +43 -0
  64. package/dist/features/chat/slash-commands.d.ts +81 -0
  65. package/dist/features/chat/thinking-level-source.d.ts +29 -0
  66. package/dist/features/chat/todos/TodoPanel.d.ts +11 -0
  67. package/dist/features/chat/todos/agent-todos-store.d.ts +35 -0
  68. package/dist/features/chat/todos/todo-collapse-codec.d.ts +12 -0
  69. package/dist/features/chat/todos/todo-panel-model.d.ts +37 -0
  70. package/dist/features/chat/use-bottom-anchor.d.ts +33 -0
  71. package/dist/features/chat/use-fork-action.d.ts +32 -0
  72. package/dist/features/connection/ConnectionBar.d.ts +18 -0
  73. package/dist/features/connection/connection-presentation.d.ts +70 -0
  74. package/dist/features/files/BinaryFallbackViewer.d.ts +9 -0
  75. package/dist/features/files/CodeView.d.ts +15 -0
  76. package/dist/features/files/DiffView.d.ts +18 -0
  77. package/dist/features/files/FileContextMenu.d.ts +13 -0
  78. package/dist/features/files/FileExplorer.d.ts +24 -0
  79. package/dist/features/files/FilePanel.d.ts +26 -0
  80. package/dist/features/files/HtmlViewer.d.ts +22 -0
  81. package/dist/features/files/ImageViewer.d.ts +8 -0
  82. package/dist/features/files/MarkdownFileViewer.d.ts +14 -0
  83. package/dist/features/files/MoleculeViewer.d.ts +60 -0
  84. package/dist/features/files/MoleculeViewerPanel.d.ts +9 -0
  85. package/dist/features/files/PdfViewer.d.ts +14 -0
  86. package/dist/features/files/RightSidebar.d.ts +9 -0
  87. package/dist/features/files/SaveFileButton.d.ts +9 -0
  88. package/dist/features/files/TextViewer.d.ts +23 -0
  89. package/dist/features/files/TreeDraftRow.d.ts +15 -0
  90. package/dist/features/files/TreeNode.d.ts +42 -0
  91. package/dist/features/files/TreeRenameRow.d.ts +19 -0
  92. package/dist/features/files/VideoViewer.d.ts +8 -0
  93. package/dist/features/files/create-entry.d.ts +23 -0
  94. package/dist/features/files/delete-entry.d.ts +17 -0
  95. package/dist/features/files/file-tree.d.ts +92 -0
  96. package/dist/features/files/git-status-index.d.ts +37 -0
  97. package/dist/features/files/html-asset-loader.d.ts +43 -0
  98. package/dist/features/files/html-assets.d.ts +97 -0
  99. package/dist/features/files/html-sandbox.d.ts +62 -0
  100. package/dist/features/files/molecule-reload.d.ts +20 -0
  101. package/dist/features/files/molecule-source.d.ts +10 -0
  102. package/dist/features/files/molecule-theme.d.ts +31 -0
  103. package/dist/features/files/move-entry.d.ts +10 -0
  104. package/dist/features/files/move-status.d.ts +10 -0
  105. package/dist/features/files/move-target.d.ts +31 -0
  106. package/dist/features/files/open-file-tab.d.ts +32 -0
  107. package/dist/features/files/pdf-layout.d.ts +28 -0
  108. package/dist/features/files/pdfjs-runtime.d.ts +30 -0
  109. package/dist/features/files/polymer-file.d.ts +33 -0
  110. package/dist/features/files/text-viewer-state.d.ts +53 -0
  111. package/dist/features/files/upload-sources.d.ts +20 -0
  112. package/dist/features/files/viewer-registry.d.ts +81 -0
  113. package/dist/features/files/write-file.d.ts +12 -0
  114. package/dist/features/git/ChangesPanel.d.ts +13 -0
  115. package/dist/features/provider-auth/LoginDialog.d.ts +21 -0
  116. package/dist/features/provider-auth/ModelProvidersPanel.d.ts +12 -0
  117. package/dist/features/provider-auth/QrCode.d.ts +26 -0
  118. package/dist/features/provider-auth/login-flow.d.ts +55 -0
  119. package/dist/features/provider-auth/provider-auth-presentation.d.ts +31 -0
  120. package/dist/features/provider-auth/provider-auth-store.d.ts +42 -0
  121. package/dist/features/sessions/SessionContextMenu.d.ts +11 -0
  122. package/dist/features/sessions/SessionItem.d.ts +22 -0
  123. package/dist/features/sessions/SessionList.d.ts +9 -0
  124. package/dist/features/sessions/WorkspaceContextMenu.d.ts +9 -0
  125. package/dist/features/sessions/WorkspaceGroupHeader.d.ts +26 -0
  126. package/dist/features/sessions/apply-agent-deep-link.d.ts +7 -0
  127. package/dist/features/sessions/open-chat-tab.d.ts +14 -0
  128. package/dist/features/sessions/open-workspace.d.ts +20 -0
  129. package/dist/features/sessions/session-actions.d.ts +18 -0
  130. package/dist/features/sessions/session-presentation.d.ts +47 -0
  131. package/dist/features/sessions/status-map.d.ts +10 -0
  132. package/dist/features/sessions/workspace-grouping.d.ts +30 -0
  133. package/dist/features/settings/SettingsDialog.d.ts +22 -0
  134. package/dist/features/settings/ViewersPanel.d.ts +18 -0
  135. package/dist/features/settings/settings-categories.d.ts +32 -0
  136. package/dist/features/skills/InstallSkillDialog.d.ts +21 -0
  137. package/dist/features/skills/SkillsPanel.d.ts +32 -0
  138. package/dist/features/skills/skills-presentation.d.ts +159 -0
  139. package/dist/features/skills/use-skills.d.ts +215 -0
  140. package/dist/features/terminal/TerminalPanel.d.ts +37 -0
  141. package/dist/features/terminal/terminal-font.d.ts +44 -0
  142. package/dist/features/terminal/terminal-size.d.ts +52 -0
  143. package/dist/features/workspace/ContextMeter.d.ts +15 -0
  144. package/dist/features/workspace/ContextMeterPopover.d.ts +16 -0
  145. package/dist/features/workspace/DropPreview.d.ts +23 -0
  146. package/dist/features/workspace/PaneDividers.d.ts +30 -0
  147. package/dist/features/workspace/StatusBar.d.ts +16 -0
  148. package/dist/features/workspace/TabContextMenu.d.ts +15 -0
  149. package/dist/features/workspace/TabPanelHost.d.ts +30 -0
  150. package/dist/features/workspace/TabStrip.d.ts +36 -0
  151. package/dist/features/workspace/compact-action.d.ts +21 -0
  152. package/dist/features/workspace/context-meter.d.ts +26 -0
  153. package/dist/features/workspace/external-drag.d.ts +99 -0
  154. package/dist/features/workspace/pane-dnd.d.ts +70 -0
  155. package/dist/features/workspace/pane-layout-view.d.ts +73 -0
  156. package/dist/features/workspace/pane-tree.d.ts +141 -0
  157. package/dist/features/workspace/panel-registry.d.ts +13 -0
  158. package/dist/features/workspace/reopen-client-tabs.d.ts +44 -0
  159. package/dist/features/workspace/restore-active-workspace.d.ts +30 -0
  160. package/dist/features/workspace/status-bar-format.d.ts +20 -0
  161. package/dist/features/workspace/tab-attention.d.ts +35 -0
  162. package/dist/features/workspace-picker/OpenWorkspaceDialog.d.ts +11 -0
  163. package/dist/fonts/CascadiaMono.woff2 +0 -0
  164. package/dist/fonts/CascadiaMonoNF.woff2 +0 -0
  165. package/dist/fonts/LICENSE-Cascadia.txt +97 -0
  166. package/dist/fonts.css +60 -0
  167. package/dist/hooks/agent-stream-events.d.ts +20 -0
  168. package/dist/hooks/file-text-state.d.ts +31 -0
  169. package/dist/hooks/file-transfer-instance.d.ts +10 -0
  170. package/dist/hooks/use-agent-commands.d.ts +18 -0
  171. package/dist/hooks/use-agent-deep-link-boot.d.ts +9 -0
  172. package/dist/hooks/use-agent-stream.d.ts +15 -0
  173. package/dist/hooks/use-agent-todos.d.ts +10 -0
  174. package/dist/hooks/use-checkout-status.d.ts +13 -0
  175. package/dist/hooks/use-connection.d.ts +27 -0
  176. package/dist/hooks/use-explorer-tree.d.ts +20 -0
  177. package/dist/hooks/use-explorer-watch.d.ts +39 -0
  178. package/dist/hooks/use-explorer.d.ts +21 -0
  179. package/dist/hooks/use-external-pane-drop.d.ts +47 -0
  180. package/dist/hooks/use-file-diff.d.ts +9 -0
  181. package/dist/hooks/use-file-download.d.ts +18 -0
  182. package/dist/hooks/use-file-live-refresh.d.ts +31 -0
  183. package/dist/hooks/use-file-read.d.ts +31 -0
  184. package/dist/hooks/use-file-source.d.ts +16 -0
  185. package/dist/hooks/use-file-text.d.ts +21 -0
  186. package/dist/hooks/use-file-transfer.d.ts +18 -0
  187. package/dist/hooks/use-file-watch.d.ts +36 -0
  188. package/dist/hooks/use-home-dir.d.ts +14 -0
  189. package/dist/hooks/use-inline-image.d.ts +37 -0
  190. package/dist/hooks/use-is-compacting.d.ts +9 -0
  191. package/dist/hooks/use-pane-drag.d.ts +40 -0
  192. package/dist/hooks/use-pane-layout.d.ts +40 -0
  193. package/dist/hooks/use-provider-auth-list.d.ts +19 -0
  194. package/dist/hooks/use-provider-models.d.ts +14 -0
  195. package/dist/hooks/use-session-restore.d.ts +44 -0
  196. package/dist/hooks/use-session-stats.d.ts +40 -0
  197. package/dist/hooks/use-shortcuts.d.ts +6 -0
  198. package/dist/hooks/use-terminal-exit-watch.d.ts +47 -0
  199. package/dist/hooks/use-terminal-restore.d.ts +38 -0
  200. package/dist/hooks/use-thinking-levels.d.ts +13 -0
  201. package/dist/hooks/use-timeline-reset-watch.d.ts +43 -0
  202. package/dist/hooks/use-viewer-settings.d.ts +17 -0
  203. package/dist/host/browser-clipboard.d.ts +9 -0
  204. package/dist/host/browser-connection.d.ts +13 -0
  205. package/dist/host/browser-files.d.ts +9 -0
  206. package/dist/host/browser-host.d.ts +14 -0
  207. package/dist/host/browser-launch.d.ts +19 -0
  208. package/dist/host/browser-worker-timers.d.ts +29 -0
  209. package/dist/host/external-link.d.ts +14 -0
  210. package/dist/host/index.d.ts +4 -0
  211. package/dist/host/install.d.ts +21 -0
  212. package/dist/host/types.d.ts +168 -0
  213. package/dist/index.d.ts +14 -0
  214. package/dist/index.js +18 -0
  215. package/dist/lib/agent-deep-link.d.ts +29 -0
  216. package/dist/lib/connection/connection-store.d.ts +49 -0
  217. package/dist/lib/connection/files-changed.d.ts +41 -0
  218. package/dist/lib/connection/live-file-transfer.d.ts +8 -0
  219. package/dist/lib/connection/normalize-url.d.ts +16 -0
  220. package/dist/lib/connection/query-client.d.ts +3 -0
  221. package/dist/lib/connection/resolve-connect-target.d.ts +10 -0
  222. package/dist/lib/connection/resume-action.d.ts +33 -0
  223. package/dist/lib/connection/resume-handler.d.ts +6 -0
  224. package/dist/lib/connection/rpc-keys.d.ts +39 -0
  225. package/dist/lib/drag-guard.d.ts +39 -0
  226. package/dist/lib/inline-image-cache.d.ts +34 -0
  227. package/dist/lib/pane-layout-persistence.d.ts +74 -0
  228. package/dist/lib/paths.d.ts +33 -0
  229. package/dist/lib/protocol/events.d.ts +19 -0
  230. package/dist/lib/protocol/timeline-paging.d.ts +29 -0
  231. package/dist/lib/random-id.d.ts +16 -0
  232. package/dist/shell/Workbench.d.ts +6 -0
  233. package/dist/shell/WorkbenchBoot.d.ts +4 -0
  234. package/dist/shell/WorkbenchProvider.d.ts +10 -0
  235. package/dist/shell/WorkspaceShell.d.ts +12 -0
  236. package/dist/shell/context.d.ts +8 -0
  237. package/dist/shell/hooks.d.ts +32 -0
  238. package/dist/shell/regions.d.ts +17 -0
  239. package/dist/stores/compaction-store.d.ts +45 -0
  240. package/dist/stores/deep-link-store.d.ts +15 -0
  241. package/dist/stores/draft-store.d.ts +45 -0
  242. package/dist/stores/explorer-store.d.ts +63 -0
  243. package/dist/stores/fork-store.d.ts +69 -0
  244. package/dist/stores/git-store.d.ts +59 -0
  245. package/dist/stores/layout-store.d.ts +137 -0
  246. package/dist/stores/materialize.d.ts +47 -0
  247. package/dist/stores/session-store.d.ts +76 -0
  248. package/dist/stores/stats-store.d.ts +48 -0
  249. package/dist/stores/tab-store.d.ts +145 -0
  250. package/dist/stores/ui-store.d.ts +85 -0
  251. package/dist/styles.css +1 -0
  252. package/dist/timeline/FileLink.d.ts +22 -0
  253. package/dist/timeline/InlineImage.d.ts +16 -0
  254. package/dist/timeline/bottom-anchor.d.ts +77 -0
  255. package/dist/timeline/compaction.d.ts +12 -0
  256. package/dist/timeline/file-link-src.d.ts +34 -0
  257. package/dist/timeline/file-open-target.d.ts +19 -0
  258. package/dist/timeline/format-meta-time.d.ts +10 -0
  259. package/dist/timeline/highlight.d.ts +9 -0
  260. package/dist/timeline/href-resolution.d.ts +34 -0
  261. package/dist/timeline/image-src.d.ts +32 -0
  262. package/dist/timeline/inline-image-view.d.ts +34 -0
  263. package/dist/timeline/live-tail.d.ts +5 -0
  264. package/dist/timeline/markdown.d.ts +35 -0
  265. package/dist/timeline/mermaid-theme.d.ts +23 -0
  266. package/dist/timeline/reducer.d.ts +38 -0
  267. package/dist/timeline/row-model.d.ts +154 -0
  268. package/dist/timeline/streaming-split.d.ts +42 -0
  269. package/dist/timeline/tool-mapping.d.ts +60 -0
  270. package/dist/viewer-plugins/viewer-settings-store.d.ts +55 -0
  271. package/dist/vite/index.d.ts +36 -0
  272. package/dist/vite/index.js +39 -0
  273. package/package.json +81 -4
@@ -0,0 +1,95 @@
1
+ import { jsxs as l, jsx as t, Fragment as R } from "react/jsx-runtime";
2
+ import { useState as v } from "react";
3
+ import { useQueryClient as q } from "@tanstack/react-query";
4
+ import { EmptyState as g, Spinner as E, StatusBadge as p, Button as y } from "@av-pi-studio/ui-library";
5
+ import { u as I, g as T, r as L } from "./index-Dlz8mEKZ.js";
6
+ import { u as x } from "./use-provider-auth-list-DTjIZycd.js";
7
+ import { u as _ } from "./provider-auth-store-C1GaLTlw.js";
8
+ const N = "env:";
9
+ function O(n) {
10
+ return n.configured === "unknown" ? { label: "Unknown", variant: "warning" } : n.configured === !1 ? { label: "Not configured", variant: "muted" } : n.configuredSource?.startsWith(N) ? {
11
+ label: `env: ${n.configuredSource.slice(N.length)}`,
12
+ variant: "success"
13
+ } : n.configuredType === "oauth" ? { label: "OAuth", variant: "success" } : { label: "API key", variant: "success" };
14
+ }
15
+ function Q(n) {
16
+ const a = n.configured === !0 ? "Re-login" : "Log in";
17
+ if (n.authTypes.length <= 1) {
18
+ const o = n.authTypes[0] ?? "api_key";
19
+ return [{ authType: o, label: o === "oauth" ? n.oauthLoginLabel ?? a : a }];
20
+ }
21
+ return n.authTypes.map(
22
+ (o) => o === "oauth" ? { authType: o, label: n.oauthLoginLabel ?? "Log in with OAuth" } : { authType: o, label: "API key" }
23
+ );
24
+ }
25
+ const U = "piwb-ModelProvidersPanel_list_6FP0L", z = "piwb-ModelProvidersPanel_row_WP5TM", F = "piwb-ModelProvidersPanel_rowMain_73qrN", j = "piwb-ModelProvidersPanel_name_3C-ob", B = "piwb-ModelProvidersPanel_tag_l4HRQ", K = "piwb-ModelProvidersPanel_rowActions_cvRay", H = "piwb-ModelProvidersPanel_pendingNote_m8qzj", V = "piwb-ModelProvidersPanel_note_VQ824", W = "piwb-ModelProvidersPanel_errorState_tULAU", i = {
26
+ list: U,
27
+ row: z,
28
+ rowMain: F,
29
+ name: j,
30
+ tag: B,
31
+ rowActions: K,
32
+ pendingNote: H,
33
+ note: V,
34
+ errorState: W
35
+ };
36
+ function ee() {
37
+ const n = I((e) => e.client), a = q(), o = _((e) => e.pendingLogin), M = _((e) => e.requestLogin), [m, f] = v(null), [A, h] = v({}), { data: c, isLoading: S, isError: k, error: b } = x();
38
+ async function C(e) {
39
+ if (!(!n || !await T().dialogs.confirm(
40
+ `Log out of ${e.name}? Running agents keep working until their current credential use fails.`
41
+ ))) {
42
+ h((s) => ({ ...s, [e.id]: "" })), f(e.id);
43
+ try {
44
+ const s = await n.logoutProvider(e.id);
45
+ h((r) => ({
46
+ ...r,
47
+ [e.id]: s.stillConfigured ? "Removed the stored credential — still configured via an environment variable." : ""
48
+ })), await a.invalidateQueries({ queryKey: L.providerAuthList() }), a.invalidateQueries({ queryKey: L.providerModelsAll() });
49
+ } finally {
50
+ f(null);
51
+ }
52
+ }
53
+ }
54
+ return S ? /* @__PURE__ */ l(g, { children: [
55
+ /* @__PURE__ */ t(E, { size: "sm" }),
56
+ " Loading providers…"
57
+ ] }) : k ? /* @__PURE__ */ t(g, { className: i.errorState, children: b instanceof Error ? b.message : "Failed to load providers." }) : !c || c.length === 0 ? /* @__PURE__ */ t(g, { children: "No providers available." }) : /* @__PURE__ */ t("div", { className: i.list, children: c.map((e) => {
58
+ const u = O(e), s = Q(e), r = o?.provider === e.id, w = o !== null && !r, P = A[e.id];
59
+ return /* @__PURE__ */ l("div", { className: i.row, children: [
60
+ /* @__PURE__ */ l("div", { className: i.rowMain, children: [
61
+ /* @__PURE__ */ t("span", { className: i.name, children: e.name }),
62
+ e.oauthIsSubscription && /* @__PURE__ */ t(p, { label: "Subscription", variant: "muted", className: i.tag }),
63
+ /* @__PURE__ */ t(p, { label: u.label, variant: u.variant, className: i.tag })
64
+ ] }),
65
+ /* @__PURE__ */ t("div", { className: i.rowActions, children: r ? /* @__PURE__ */ t("span", { className: i.pendingNote, children: "Logging in…" }) : /* @__PURE__ */ l(R, { children: [
66
+ s.map((d) => /* @__PURE__ */ t(
67
+ y,
68
+ {
69
+ size: "xs",
70
+ variant: "secondary",
71
+ disabled: w,
72
+ onClick: () => M(e.id, e.name, d.authType),
73
+ children: d.label
74
+ },
75
+ d.authType
76
+ )),
77
+ e.configured !== !1 && /* @__PURE__ */ t(
78
+ y,
79
+ {
80
+ size: "xs",
81
+ variant: "ghost",
82
+ disabled: w || m === e.id,
83
+ loading: m === e.id,
84
+ onClick: () => void C(e),
85
+ children: "Log out"
86
+ }
87
+ )
88
+ ] }) }),
89
+ P && /* @__PURE__ */ t("div", { className: i.note, children: P })
90
+ ] }, e.id);
91
+ }) });
92
+ }
93
+ export {
94
+ ee as ModelProvidersPanel
95
+ };
@@ -0,0 +1,191 @@
1
+ import { jsx as s, jsxs as v } from "react/jsx-runtime";
2
+ import { u as U, O as W, m as j, P as k, Q as X, R as q, T as Y, U as z, v as D } from "./index-Dlz8mEKZ.js";
3
+ import { Panel as h, EmptyState as N, Spinner as G, StatusBadge as w } from "@av-pi-studio/ui-library";
4
+ import { useRef as M, useState as m, useMemo as H, useEffect as Q } from "react";
5
+ import { MolViewer as J } from "@molviewer/core";
6
+ import "@molviewer/core/style.css";
7
+ import { u as K } from "./use-file-download-CogCqTvU.js";
8
+ import { u as Z } from "./use-file-watch-Bb_Xzbr-.js";
9
+ function ee(e, r) {
10
+ return !e || !r ? null : { url: r, name: e.split("/").pop() || e };
11
+ }
12
+ function re({
13
+ changedAt: e,
14
+ lastAppliedAt: r,
15
+ modified: n
16
+ }) {
17
+ return !(e === null || n || e === r);
18
+ }
19
+ const oe = {
20
+ empty_path: "Nothing to save.",
21
+ too_large: "File is too large to save (over 5 MiB).",
22
+ not_found: "The file no longer exists.",
23
+ unreadable: "The file could not be read.",
24
+ not_a_file: "That path is not a file."
25
+ };
26
+ async function te(e, r, n) {
27
+ const a = await e.connection.request(
28
+ "file_write_request",
29
+ { path: r, content: n }
30
+ );
31
+ if (!a.ok) {
32
+ const i = a.error ?? "";
33
+ throw new Error(oe[i] ?? i ?? "Failed to save");
34
+ }
35
+ }
36
+ const ne = "mol2";
37
+ function ae(e) {
38
+ const { sourcePath: r, monomers: n, attempt: a } = e, i = a > 0 ? `_${a + 1}` : "";
39
+ return `${le(r)}_polymer_${n}${i}.${ne}`;
40
+ }
41
+ function le(e) {
42
+ return (e.split("/").pop() ?? "").replace(/\.[^.]+$/, "").trim() || "polymer";
43
+ }
44
+ const se = {
45
+ // Panel backgrounds (sidebar, toolbars, recessed panels).
46
+ "--canvas": "var(--pi-color-surface0)",
47
+ "--well": "var(--pi-color-surface0)",
48
+ "--recess": "var(--pi-color-surface1)",
49
+ "--chrome": "var(--pi-color-surface1)",
50
+ // Buttons and other controls.
51
+ "--control": "var(--pi-color-surface2)",
52
+ "--control-hover": "var(--pi-color-surface3)",
53
+ "--control-strong-hover": "var(--pi-color-surface4)",
54
+ "--border-control": "var(--pi-color-border)",
55
+ "--border-input": "var(--pi-color-border)",
56
+ // Dropdowns / menus.
57
+ "--popover": "var(--pi-color-surface1)",
58
+ "--popover-item-hover": "var(--pi-color-surface2)",
59
+ "--row-hover": "var(--pi-color-surface2)",
60
+ "--border-popover": "var(--pi-color-border)",
61
+ // Text.
62
+ "--text-primary": "var(--pi-color-foreground)",
63
+ "--text-on-control": "var(--pi-color-foreground)"
64
+ }, ie = "piwb-MoleculeViewer_wrap__5wbs", ce = "piwb-MoleculeViewer_molViewer_5-bEg", ue = "piwb-MoleculeViewer_badges_VXS4U", _ = {
65
+ wrap: ie,
66
+ molViewer: ce,
67
+ badges: ue
68
+ }, de = 50;
69
+ async function fe(e) {
70
+ const { client: r, upload: n, sourcePath: a, monomers: i, text: d } = e, p = X(a);
71
+ let t = null, l = "";
72
+ for (let c = 0; c < de && t === null; c += 1) {
73
+ l = ae({ sourcePath: a, monomers: i, attempt: c });
74
+ try {
75
+ t = await q(r, p, l, "file");
76
+ } catch (f) {
77
+ if (f instanceof Y && f.code === "exists") continue;
78
+ throw f;
79
+ }
80
+ }
81
+ if (t === null)
82
+ throw new Error(`No free name for ${l} — too many builds in this folder.`);
83
+ try {
84
+ await n(p, new File([d], l, { type: "chemical/x-mol2" }));
85
+ } catch (c) {
86
+ throw await z(r, t).catch(() => {
87
+ }), c;
88
+ }
89
+ return t;
90
+ }
91
+ function me({
92
+ path: e,
93
+ workspaceCwd: r,
94
+ tabId: n,
95
+ isActive: a,
96
+ onModifiedChange: i
97
+ }) {
98
+ const d = U((o) => o.client), { upload: p } = W(), t = K(e ?? "", !!e), { changedAt: l } = Z(e), c = M(null), f = M(!1), [A, S] = m(null), [E, $] = m(!1), [x, b] = m(null), [P, g] = m(null), [T, V] = m(null), y = M(null), R = t.data?.objectUrl ?? null, L = H(() => ee(e, R), [e, R]);
99
+ Q(() => {
100
+ re({ changedAt: l, lastAppliedAt: y.current, modified: E }) && (y.current = l, t.refetch());
101
+ }, [l, E, t.refetch]);
102
+ const O = l !== null && l !== y.current && E;
103
+ async function B(o) {
104
+ if (e) {
105
+ if (!d) {
106
+ b("Not connected — cannot save.");
107
+ return;
108
+ }
109
+ b(null);
110
+ try {
111
+ await te(d, e, o.text()), o.saved();
112
+ } catch (u) {
113
+ b(u instanceof Error ? u.message : "Failed to save");
114
+ }
115
+ }
116
+ }
117
+ async function C(o) {
118
+ if (e) {
119
+ if (!d) {
120
+ g("Not connected — cannot save the polymer.");
121
+ return;
122
+ }
123
+ g(null), V(null);
124
+ try {
125
+ const u = await fe({
126
+ client: d,
127
+ upload: p,
128
+ sourcePath: e,
129
+ monomers: o.monomers,
130
+ text: o.text()
131
+ });
132
+ o.report.clashes > 0 && V(
133
+ `${o.report.clashes} close contacts — relax the geometry before simulating`
134
+ );
135
+ const I = j.getState().paneOfTab(r, n);
136
+ k(u, r, I ?? void 0);
137
+ } catch (u) {
138
+ g(u instanceof Error ? u.message : "Failed to save the polymer");
139
+ }
140
+ }
141
+ }
142
+ const F = (t.isError ? t.error instanceof Error ? t.error.message : "download failed" : null) ?? A?.message ?? null;
143
+ return e && t.isPending ? /* @__PURE__ */ s(h, { children: /* @__PURE__ */ v(N, { children: [
144
+ /* @__PURE__ */ s(G, { size: "sm" }),
145
+ " Loading..."
146
+ ] }) }) : F ? /* @__PURE__ */ s(h, { children: /* @__PURE__ */ v(N, { children: [
147
+ "Error: ",
148
+ F
149
+ ] }) }) : /* @__PURE__ */ v(h, { className: _.wrap, "data-molecule-active": a ? "true" : "false", children: [
150
+ /* @__PURE__ */ v("div", { className: _.badges, children: [
151
+ O && /* @__PURE__ */ s(w, { label: "File changed on disk", variant: "muted" }),
152
+ x && /* @__PURE__ */ s(w, { label: `Save failed: ${x}`, variant: "error" }),
153
+ P && /* @__PURE__ */ s(w, { label: `Polymer build: ${P}`, variant: "error" }),
154
+ T && /* @__PURE__ */ s(w, { label: T, variant: "warning" })
155
+ ] }),
156
+ /* @__PURE__ */ s(
157
+ J,
158
+ {
159
+ ref: c,
160
+ className: _.molViewer,
161
+ theme: se,
162
+ source: L,
163
+ sourceMode: f.current ? "update" : "replace",
164
+ onLoad: () => {
165
+ f.current = !0, S(null);
166
+ },
167
+ onLoadError: (o) => S(o.error),
168
+ onModifiedChange: (o) => {
169
+ $(o), i?.(o);
170
+ },
171
+ onSave: e ? B : void 0,
172
+ onPolymerBuild: e ? C : void 0
173
+ }
174
+ )
175
+ ] });
176
+ }
177
+ function _e({ tab: e }) {
178
+ const { path: r } = e.data, n = D(e.id);
179
+ return /* @__PURE__ */ s(h, { children: /* @__PURE__ */ s(
180
+ me,
181
+ {
182
+ path: r,
183
+ workspaceCwd: e.workspaceCwd,
184
+ tabId: e.id,
185
+ isActive: n
186
+ }
187
+ ) });
188
+ }
189
+ export {
190
+ _e as MoleculeViewerPanel
191
+ };
@@ -0,0 +1,300 @@
1
+ import { jsxs as h, jsx as a } from "react/jsx-runtime";
2
+ import { useState as w, useEffect as x, useMemo as V, useRef as W, useLayoutEffect as te } from "react";
3
+ import { ZoomOut as re, ZoomIn as ne, MoveHorizontal as oe, Download as ae } from "lucide-react";
4
+ import { EmptyState as O, Button as y, Spinner as se } from "@av-pi-studio/ui-library";
5
+ import { g as Z, O as ie } from "./index-Dlz8mEKZ.js";
6
+ import { u as ce } from "./use-file-download-CogCqTvU.js";
7
+ import * as j from "pdfjs-dist";
8
+ class H extends Error {
9
+ name = "PdfUnavailableError";
10
+ constructor() {
11
+ super("PDF preview is not available in this application.");
12
+ }
13
+ }
14
+ function le(e, t) {
15
+ const o = new URL(
16
+ e.endsWith("/") ? e : `${e}/`,
17
+ t
18
+ );
19
+ return {
20
+ cMapUrl: new URL("cmaps/", o).href,
21
+ cMapPacked: !0,
22
+ standardFontDataUrl: new URL("standard_fonts/", o).href,
23
+ wasmUrl: new URL("wasm/", o).href,
24
+ iccUrl: new URL("iccs/", o).href
25
+ };
26
+ }
27
+ function X() {
28
+ const e = Z().pdf;
29
+ if (!e) throw new H();
30
+ return j.GlobalWorkerOptions.workerPort ??= e.createWorker(), { pdfjs: j, assetUrls: le(e.assetBaseUrl, document.baseURI) };
31
+ }
32
+ const S = [0.25, 0.5, 0.75, 1, 1.25, 1.5, 2, 3, 4], $ = S[0], K = S[S.length - 1], de = 16777216, q = 1e-6;
33
+ function fe(e) {
34
+ return S.find((t) => t > e + q) ?? K;
35
+ }
36
+ function ue(e) {
37
+ return S.findLast((t) => t < e - q) ?? $;
38
+ }
39
+ function he(e, t, o) {
40
+ const r = e - t;
41
+ return r <= 0 || o <= 0 ? 1 : Math.min(K, Math.max($, r / o));
42
+ }
43
+ function pe(e, t, o, r, l = de) {
44
+ const i = e * o * (t * o);
45
+ return i <= 0 ? r : Math.min(r, Math.sqrt(l / i));
46
+ }
47
+ function me(e, t, o, r) {
48
+ const l = [];
49
+ let i = r;
50
+ for (const v of e)
51
+ l.push(i), i += v * t + o;
52
+ return l;
53
+ }
54
+ function we(e, t, o) {
55
+ const r = t + o / 2, l = e.findIndex((i) => i > r);
56
+ return Math.max(0, (l === -1 ? e.length : l) - 1);
57
+ }
58
+ const ge = "piwb-PdfViewer_viewer_sH3mv", ve = "piwb-PdfViewer_toolbar_Q6AWP", Pe = "piwb-PdfViewer_pageIndicator_zLDYb", be = "piwb-PdfViewer_zoom_0FlDo", Ee = "piwb-PdfViewer_controls_xTwHT", _e = "piwb-PdfViewer_scroller_8Jdl-", ye = "piwb-PdfViewer_stack_u8yvK", xe = "piwb-PdfViewer_page_aMU2c", ke = "piwb-PdfViewer_canvas_gyGXw", Me = "piwb-PdfViewer_pageError_rv9FG", Fe = "piwb-PdfViewer_failure_KxAQv", Se = "piwb-PdfViewer_textLayer_02FU8", d = {
59
+ viewer: ge,
60
+ toolbar: ve,
61
+ pageIndicator: Pe,
62
+ zoom: be,
63
+ controls: Ee,
64
+ scroller: _e,
65
+ stack: ye,
66
+ page: xe,
67
+ canvas: ke,
68
+ pageError: Me,
69
+ failure: Fe,
70
+ textLayer: Se
71
+ }, De = 12, G = 16, Le = "100% 0px", ze = 120, Ae = {
72
+ invalid: "This file could not be opened as a PDF.",
73
+ password: "This PDF is password-protected.",
74
+ unavailable: "PDF preview is not available in this application.",
75
+ failed: "This PDF could not be loaded."
76
+ };
77
+ function Ue(e) {
78
+ if (e instanceof H) return "unavailable";
79
+ const t = e instanceof Error ? e.name : "";
80
+ return t === "PasswordException" ? "password" : t === "InvalidPDFException" || t === "FormatError" || t === "MissingPDFException" ? "invalid" : "failed";
81
+ }
82
+ function Ce(e) {
83
+ return e instanceof Error && /Cancelled|destroyed/i.test(`${e.name} ${e.message}`);
84
+ }
85
+ function We({ path: e }) {
86
+ const t = ce(e), { saveToDisk: o } = ie(), [r, l] = w(null), [i, v] = w(null), [c, U] = w(null), [D, p] = w(0), [f, P] = w(!0), [L, b] = w(1), [k, _] = w(0), m = t.data?.objectUrl;
87
+ x(() => {
88
+ if (!m) return;
89
+ let n = !1, g = !1, E = null;
90
+ return (async () => {
91
+ try {
92
+ const F = new Uint8Array(await (await fetch(m)).arrayBuffer());
93
+ if (n) return;
94
+ const { pdfjs: A, assetUrls: B } = X();
95
+ E = A.getDocument({ data: F, enableXfa: !1, ...B });
96
+ const N = await E.promise, Q = await Promise.all(
97
+ Array.from({ length: N.numPages }, async (Ne, J) => {
98
+ const { width: Y, height: ee } = (await N.getPage(J + 1)).getViewport({ scale: 1 });
99
+ return { width: Y, height: ee };
100
+ })
101
+ );
102
+ if (n) return;
103
+ g = !0, v(null), l({ task: E, doc: N, sizes: Q });
104
+ } catch (F) {
105
+ n || v(Ue(F));
106
+ }
107
+ })(), () => {
108
+ n = !0, g || E?.destroy();
109
+ };
110
+ }, [m]), x(() => {
111
+ const n = r?.task;
112
+ return () => void n?.destroy();
113
+ }, [r?.task]), x(() => {
114
+ if (!c) return;
115
+ let n, g = !0;
116
+ const E = new ResizeObserver(([F]) => {
117
+ const A = F?.contentRect.width ?? 0;
118
+ if (clearTimeout(n), g) {
119
+ g = !1, p(A);
120
+ return;
121
+ }
122
+ n = setTimeout(() => p(A), ze);
123
+ });
124
+ return E.observe(c), () => {
125
+ clearTimeout(n), E.disconnect();
126
+ };
127
+ }, [c]);
128
+ const u = r?.sizes, z = V(() => Math.max(0, ...(u ?? []).map((n) => n.width)), [u]), s = f ? he(D, G * 2, z) : L, M = V(
129
+ () => me(
130
+ (u ?? []).map((n) => n.height),
131
+ s,
132
+ De,
133
+ G
134
+ ),
135
+ [u, s]
136
+ ), I = () => {
137
+ c && _(we(M, c.scrollTop, c.clientHeight));
138
+ }, C = W(s);
139
+ te(() => {
140
+ c && C.current !== s && (c.scrollTop = c.scrollTop * s / C.current), C.current = s;
141
+ }, [s, c]), x(I, [M, c]);
142
+ const T = () => void o(e).catch(
143
+ (n) => Z().dialogs.alert(
144
+ `Failed to download: ${n instanceof Error ? n.message : String(n)}`
145
+ )
146
+ );
147
+ if (t.isError)
148
+ return /* @__PURE__ */ h(O, { children: [
149
+ "Error: ",
150
+ t.error instanceof Error ? t.error.message : "unknown error"
151
+ ] });
152
+ if (i && !r)
153
+ return /* @__PURE__ */ h("div", { className: d.failure, children: [
154
+ /* @__PURE__ */ a("span", { children: Ae[i] }),
155
+ /* @__PURE__ */ a(y, { size: "sm", onClick: T, children: "Download" })
156
+ ] });
157
+ if (!r)
158
+ return /* @__PURE__ */ h(O, { children: [
159
+ /* @__PURE__ */ a(se, { size: "sm" }),
160
+ " Loading PDF..."
161
+ ] });
162
+ if (r.sizes.length === 0)
163
+ return /* @__PURE__ */ h("div", { className: d.failure, children: [
164
+ /* @__PURE__ */ a("span", { children: "This PDF has no pages." }),
165
+ /* @__PURE__ */ a(y, { size: "sm", onClick: T, children: "Download" })
166
+ ] });
167
+ const R = (n) => {
168
+ b(n(s)), P(!1);
169
+ };
170
+ return /* @__PURE__ */ h("div", { className: d.viewer, children: [
171
+ /* @__PURE__ */ h("div", { className: d.toolbar, children: [
172
+ /* @__PURE__ */ h("span", { className: d.pageIndicator, "aria-live": "polite", children: [
173
+ k + 1,
174
+ " / ",
175
+ r.sizes.length
176
+ ] }),
177
+ /* @__PURE__ */ h("div", { className: d.controls, children: [
178
+ /* @__PURE__ */ a(
179
+ y,
180
+ {
181
+ size: "xs",
182
+ variant: "ghost",
183
+ iconOnly: !0,
184
+ "aria-label": "Zoom out",
185
+ onClick: () => R(ue),
186
+ children: /* @__PURE__ */ a(re, { size: 14 })
187
+ }
188
+ ),
189
+ /* @__PURE__ */ h("span", { className: d.zoom, children: [
190
+ Math.round(s * 100),
191
+ "%"
192
+ ] }),
193
+ /* @__PURE__ */ a(
194
+ y,
195
+ {
196
+ size: "xs",
197
+ variant: "ghost",
198
+ iconOnly: !0,
199
+ "aria-label": "Zoom in",
200
+ onClick: () => R(fe),
201
+ children: /* @__PURE__ */ a(ne, { size: 14 })
202
+ }
203
+ ),
204
+ /* @__PURE__ */ a(
205
+ y,
206
+ {
207
+ size: "xs",
208
+ variant: f ? "default" : "ghost",
209
+ iconOnly: !0,
210
+ "aria-label": "Fit width",
211
+ "aria-pressed": f,
212
+ onClick: () => P((n) => !n),
213
+ children: /* @__PURE__ */ a(oe, { size: 14 })
214
+ }
215
+ ),
216
+ /* @__PURE__ */ a(y, { size: "xs", variant: "ghost", iconOnly: !0, "aria-label": "Download PDF", onClick: T, children: /* @__PURE__ */ a(ae, { size: 14 }) })
217
+ ] })
218
+ ] }),
219
+ /* @__PURE__ */ a("div", { ref: U, className: d.scroller, onScroll: I, children: /* @__PURE__ */ a("div", { className: d.stack, children: r.sizes.map((n, g) => /* @__PURE__ */ a(
220
+ Te,
221
+ {
222
+ doc: r.doc,
223
+ pageNumber: g + 1,
224
+ size: n,
225
+ scale: s,
226
+ root: c
227
+ },
228
+ g
229
+ )) }) })
230
+ ] });
231
+ }
232
+ function Te({ doc: e, pageNumber: t, size: o, scale: r, root: l }) {
233
+ const i = W(null), [v, c] = w(!1), [U, D] = w(null);
234
+ return x(() => {
235
+ const p = i.current;
236
+ if (!l || !p) return;
237
+ const f = new IntersectionObserver(
238
+ ([P]) => c(P?.isIntersecting ?? !1),
239
+ {
240
+ root: l,
241
+ rootMargin: Le
242
+ }
243
+ );
244
+ return f.observe(p), () => f.disconnect();
245
+ }, [l]), x(() => {
246
+ const p = i.current;
247
+ if (!p) return;
248
+ if (!v) {
249
+ p.replaceChildren();
250
+ return;
251
+ }
252
+ let f = !1, P = null, L = null;
253
+ return (async () => {
254
+ try {
255
+ const { pdfjs: b } = X(), k = await e.getPage(t), _ = k.getViewport({ scale: r }), m = pe(
256
+ o.width,
257
+ o.height,
258
+ r,
259
+ window.devicePixelRatio || 1
260
+ ), u = document.createElement("canvas");
261
+ u.width = Math.floor(_.width * m), u.height = Math.floor(_.height * m), u.className = d.canvas ?? "";
262
+ const z = k.render({
263
+ canvas: u,
264
+ viewport: _,
265
+ transform: m === 1 ? void 0 : [m, 0, 0, m, 0, 0]
266
+ });
267
+ P = z, await z.promise;
268
+ const s = document.createElement("div");
269
+ s.className = `textLayer ${d.textLayer ?? ""}`, s.style.setProperty("--total-scale-factor", String(r));
270
+ const M = new b.TextLayer({
271
+ textContentSource: k.streamTextContent(),
272
+ container: s,
273
+ viewport: _
274
+ });
275
+ if (L = M, await M.render(), f) return;
276
+ p.replaceChildren(u, s), D(null);
277
+ } catch (b) {
278
+ !f && !Ce(b) && D(b instanceof Error ? b.message : "render failed");
279
+ }
280
+ })(), () => {
281
+ f = !0, P?.cancel(), L?.cancel();
282
+ };
283
+ }, [v, e, t, r, o.width, o.height]), /* @__PURE__ */ a(
284
+ "div",
285
+ {
286
+ ref: i,
287
+ className: d.page,
288
+ style: { width: o.width * r, height: o.height * r },
289
+ "data-page": t,
290
+ children: U && /* @__PURE__ */ h("span", { className: d.pageError, children: [
291
+ "Page ",
292
+ t,
293
+ " failed to render."
294
+ ] })
295
+ }
296
+ );
297
+ }
298
+ export {
299
+ We as PdfViewer
300
+ };
@@ -0,0 +1,33 @@
1
+ import { jsxs as o, Fragment as m, jsx as i } from "react/jsx-runtime";
2
+ import { useState as a, useRef as d, useEffect as v } from "react";
3
+ import { Spinner as p, Button as S } from "@av-pi-studio/ui-library";
4
+ import { O as g } from "./index-Dlz8mEKZ.js";
5
+ function y({ path: f }) {
6
+ const { saveToDisk: c } = g(), [l, e] = a(!1), [n, t] = a(null), r = d(!0);
7
+ v(
8
+ () => () => {
9
+ r.current = !1;
10
+ },
11
+ []
12
+ );
13
+ async function u() {
14
+ e(!0), t(null);
15
+ try {
16
+ await c(f);
17
+ } catch (s) {
18
+ r.current && t(s instanceof Error ? s.message : "download failed");
19
+ } finally {
20
+ r.current && e(!1);
21
+ }
22
+ }
23
+ return /* @__PURE__ */ o(m, { children: [
24
+ n && /* @__PURE__ */ o("div", { children: [
25
+ "Error: ",
26
+ n
27
+ ] }),
28
+ l ? /* @__PURE__ */ i(p, { size: "sm" }) : /* @__PURE__ */ i(S, { size: "sm", onClick: () => void u(), children: "Download" })
29
+ ] });
30
+ }
31
+ export {
32
+ y as S
33
+ };