@puddle-code/cli 0.4.15 → 0.4.17

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 (116) hide show
  1. package/CHANGELOG.md +33 -2
  2. package/dist/index.js +5 -3
  3. package/dist/public/assets/App-ZtJSRE8n.js +40 -0
  4. package/dist/public/assets/CompilationCommandForm-BGIgFAkM.js +1 -0
  5. package/dist/public/assets/Dashboard-B_m3VKHu.js +1 -0
  6. package/dist/public/assets/EditorTabClose-CNB0NsZQ.js +1 -0
  7. package/dist/public/assets/FileEditorSettingsMenu-JUB6GRyp.js +1 -0
  8. package/dist/public/assets/FindWidget-ET5pwkkB.js +1 -0
  9. package/dist/public/assets/LazyTerminal-SbouF2Y_.js +2 -0
  10. package/dist/public/assets/{ModelRefcount-BeuZdwWp.js → ModelRefcount-Bbr8zY_6.js} +1 -1
  11. package/dist/public/assets/{NotebookWidget-CH5zoEVV.js → NotebookWidget-9z2Xca7D.js} +1 -1
  12. package/dist/public/assets/{PaneEditorBody-DESTR4r3.js → PaneEditorBody-nc1Z681y.js} +10 -10
  13. package/dist/public/assets/{PdfViewer-BH-FXEVV.js → PdfViewer-FWSPsqTc.js} +1 -1
  14. package/dist/public/assets/{ReleaseNotesDialog-jEU0I1rq.js → ReleaseNotesDialog-sQVKJ6dm.js} +1 -1
  15. package/dist/public/assets/Ripple-B2KIWnc_.js +11 -0
  16. package/dist/public/assets/Ripple-DYosRAZ1.css +1 -0
  17. package/dist/public/assets/SettingsDialog-DKnJSEij.js +8 -0
  18. package/dist/public/assets/{Terminal-Gq862tY-.js → Terminal-B2FWGxlE.js} +6 -6
  19. package/dist/public/assets/Workspace-CiATCR9s.css +1 -0
  20. package/dist/public/assets/Workspace-DUBYqpNS.js +20 -0
  21. package/dist/public/assets/api-BwP0jv_V.js +1 -0
  22. package/dist/public/assets/{archive-i9DnVa-v.js → archive-BYp06n6i.js} +1 -1
  23. package/dist/public/assets/auth-DYEjEl0U.js +64 -0
  24. package/dist/public/assets/buffer-store-fV6iYuCU.js +1 -0
  25. package/dist/public/assets/button-D-qeQvl5.js +1 -0
  26. package/dist/public/assets/{chevron-down-HQLVE6o5.js → chevron-down--sjpQEHH.js} +1 -1
  27. package/dist/public/assets/chevron-right-DUkOv15w.js +1 -0
  28. package/dist/public/assets/code-DRWf9a5s.js +1 -0
  29. package/dist/public/assets/command-BeX8pm7h.js +1 -0
  30. package/dist/public/assets/context-B6lkZJoM.js +1 -0
  31. package/dist/public/assets/control-tray-CjoJunx1.js +1 -0
  32. package/dist/public/assets/{copy-D0Theg4Q.js → copy-CGsu8426.js} +1 -1
  33. package/dist/public/assets/createLucideIcon-DyMAgLa3.js +1 -0
  34. package/dist/public/assets/dialog-CTN-Lln6.js +41 -0
  35. package/dist/public/assets/dist-BcrNV8NP.js +1 -0
  36. package/dist/public/assets/dist-NuV8HBEc.js +1 -0
  37. package/dist/public/assets/dist-cvE69gWt.js +1 -0
  38. package/dist/public/assets/{errors-efDAjyqa.js → errors-CD96hLph.js} +1 -1
  39. package/dist/public/assets/expanding-content-UT_6Fp5v.js +1 -0
  40. package/dist/public/assets/file-editor-settings-CzybzK8S.js +1 -0
  41. package/dist/public/assets/file-links-BWU9Vnfc.js +1 -0
  42. package/dist/public/assets/{forward-link-BfAPpjGN.js → forward-link-CkdngF7C.js} +1 -1
  43. package/dist/public/assets/index-DtbUW4I4.css +2 -0
  44. package/dist/public/assets/{index-Cg9SFK_d.js → index-ncmnNFLA.js} +3 -3
  45. package/dist/public/assets/languages-MEV5hj_8.js +16 -0
  46. package/dist/public/assets/local-store-yUq3FKdV.js +1 -0
  47. package/dist/public/assets/media-refresh-store-Dxq65ATq.js +1 -0
  48. package/dist/public/assets/notification-delivery-NbIhmidu.js +1 -0
  49. package/dist/public/assets/popover-Okyclsx8.js +1 -0
  50. package/dist/public/assets/preferences-BX4iJsv8.js +1 -0
  51. package/dist/public/assets/preview-kind-CJ9RTgbs.js +1 -0
  52. package/dist/public/assets/profile-store-B54YLXa8.js +1 -0
  53. package/dist/public/assets/{protocol-support-BwRR1kRO.js → protocol-support-sBpa8MZK.js} +1 -1
  54. package/dist/public/assets/render-rich-content-BoTeqQfi.css +1 -0
  55. package/dist/public/assets/render-rich-content-cSjuhT75.js +4 -0
  56. package/dist/public/assets/{rotate-ccw-BI2k_h3A.js → rotate-ccw-CNjR2LSi.js} +1 -1
  57. package/dist/public/assets/{scroll-restoration-wdDB8mmu.js → scroll-restoration-D-jpZqdR.js} +1 -1
  58. package/dist/public/assets/search-Ct_rLLa4.js +1 -0
  59. package/dist/public/assets/select-CCBPniW9.js +1 -0
  60. package/dist/public/assets/selection-actions-C33evFaY.js +1 -0
  61. package/dist/public/assets/session-order-DilOGTOO.js +1 -0
  62. package/dist/public/assets/settings-2-CInoy48z.js +1 -0
  63. package/dist/public/assets/switch-B3zcD6GH.js +1 -0
  64. package/dist/public/assets/trash-2-DQeNROsF.js +1 -0
  65. package/dist/public/assets/use-ui-state-BLOunpIh.js +1 -0
  66. package/dist/public/assets/utils-B6KiDbIe.js +1 -0
  67. package/dist/public/assets/view-state-store-BLCtem0t.js +1 -0
  68. package/dist/public/assets/{whole-word-BJjKpISQ.js → whole-word-2m2pmAFT.js} +1 -1
  69. package/dist/public/assets/ws-DkbvXbTZ.js +1 -0
  70. package/dist/public/assets/x-CbfJFzGo.js +1 -0
  71. package/dist/public/index.html +4 -3
  72. package/package.json +1 -1
  73. package/dist/public/assets/App-Dlrlhlup.js +0 -9
  74. package/dist/public/assets/CompilationCommandForm-DQjUhaHj.js +0 -1
  75. package/dist/public/assets/Dashboard-B2o7orBK.js +0 -1
  76. package/dist/public/assets/EditorTabClose-CQnXn4Ha.js +0 -1
  77. package/dist/public/assets/FindWidget-Bh_7yWNg.js +0 -1
  78. package/dist/public/assets/LazyTerminal-D4QV7VEc.js +0 -2
  79. package/dist/public/assets/Ripple-BM7RYwkx.css +0 -1
  80. package/dist/public/assets/Ripple-DxqgViCr.js +0 -12
  81. package/dist/public/assets/SettingsDialog-BcWnMD7A.js +0 -8
  82. package/dist/public/assets/Workspace-CuAYZ1-B.css +0 -1
  83. package/dist/public/assets/Workspace-DVji-hSU.js +0 -20
  84. package/dist/public/assets/api-CULxlzTe.js +0 -1
  85. package/dist/public/assets/arrow-down-CtYa-Aya.js +0 -1
  86. package/dist/public/assets/auth-C3ruG3fE.js +0 -64
  87. package/dist/public/assets/buffer-store-Bh2IilxW.js +0 -16
  88. package/dist/public/assets/button-DtByPSFL.js +0 -1
  89. package/dist/public/assets/code-Cf4ftdOa.js +0 -1
  90. package/dist/public/assets/command--8Svn0Z-.js +0 -1
  91. package/dist/public/assets/context-D1MuDP6X.js +0 -1
  92. package/dist/public/assets/control-tray-c9uXOo-i.js +0 -1
  93. package/dist/public/assets/createLucideIcon-C9A1vLE-.js +0 -1
  94. package/dist/public/assets/dialog-DtvE8ATK.js +0 -41
  95. package/dist/public/assets/dist-B8heQ9Kq.js +0 -1
  96. package/dist/public/assets/dist-BeQvHdsz.js +0 -1
  97. package/dist/public/assets/dist-DZg8Dwbr.js +0 -1
  98. package/dist/public/assets/dist-Dac0re_p.js +0 -1
  99. package/dist/public/assets/expanding-content-CKyt4o9s.js +0 -1
  100. package/dist/public/assets/index-D_XpA70m.css +0 -2
  101. package/dist/public/assets/media-refresh-store-CYiYB60R.js +0 -1
  102. package/dist/public/assets/notification-delivery-B-zt57w8.js +0 -1
  103. package/dist/public/assets/popover-D5HmbdQ7.js +0 -1
  104. package/dist/public/assets/preferences-xuDDL7Pm.js +0 -1
  105. package/dist/public/assets/preview-kind-CPkO-rSz.js +0 -1
  106. package/dist/public/assets/render-rich-content-DAJtX81B.js +0 -4
  107. package/dist/public/assets/select-CGxTz4dh.js +0 -1
  108. package/dist/public/assets/selection-actions-DMOj1EOB.js +0 -1
  109. package/dist/public/assets/session-order-iVRWTB-C.js +0 -1
  110. package/dist/public/assets/square-terminal-CIkfNq3I.js +0 -1
  111. package/dist/public/assets/switch-DYr-iPWY.js +0 -1
  112. package/dist/public/assets/use-ui-state-TZnzSo9V.js +0 -1
  113. package/dist/public/assets/view-state-store-DVvLMbeY.js +0 -1
  114. package/dist/public/assets/waves-horizontal-CLDJf7Dd.js +0 -1
  115. package/dist/public/assets/ws-DjQ6OZLM.js +0 -1
  116. package/dist/public/assets/x-DV6-RYI2.js +0 -1
package/CHANGELOG.md CHANGED
@@ -4,10 +4,41 @@ Archived release changelog. Governance lives in CLAUDE.md §"Changelog disciplin
4
4
 
5
5
  # Changelog
6
6
 
7
- ## [0.4.15] — 2026-11-06
7
+ ## [0.4.17] — 2026-11-07
8
8
 
9
9
  ### Cockpit
10
10
 
11
+ #### Added
12
+
13
+ - Compile or run the focused source file with Command+Enter through the existing save-before-run flow.
14
+
15
+ - Add per-file editor settings for tab size, word wrap and searchable syntax language, with inherited defaults and window-local overrides.
16
+
11
17
  #### Fixed
12
18
 
13
- - Fix Ripple URLs polluted by style markers; reuse native wrapped URL/path detection, resolution and opening behavior, including Command/Ctrl-click file links. Relay Codex disclosure clicks to their current terminal cells and group indented multiline prompts, lists and paragraphs into one user bubble.
19
+ - Run CI only for release tags and explicit `ci` / `ci/**` tags, instead of every main-branch push and pull request.
20
+
21
+ - Halve the PDF zoom overlay inset, keeping equal spacing from the top and right edges.
22
+
23
+ - Suspend eager compilation while source-input save conflicts remain unresolved, including across reconnects, and resume after a checked editor resolution.
24
+
25
+ - Keep eager compilation registered across pane moves and background tabs, and restore observation and PDF refresh after idle expiry or daemon replacement.
26
+
27
+ - Move the Ripple handle into the right pane gutter on desktop and mobile without changing the terminal grid or reading width, retaining the mobile touch target.
28
+ - Remove the mobile session sidebar and move project switching, session creation and archived sessions into the title dropdown.
29
+
30
+ - Keep single-tab action trays above file details and reachable from the top-right corner, including narrow LaTeX panes.
31
+
32
+ - Keep the newest covered Ripple output visible at a high boundary by omitting older complete blocks first, preserving pinned prompts, fixed typography and original terminal click anchors. Restore omitted content when the reading area expands.
33
+ - Remove the Ripple divider line and place a vertical handle at the far-right edge, retaining the larger mobile touch target.
34
+
35
+ - Keep Ripple scrolling in the underlying CLI, reserve two terminal rows for breathing room and keep its reading view top-aligned with fixed typography. Restore the full grid for CLI-only viewing; preserve anchored clicks and normal scrollback, and clip excess output without a second vertical scroller or changing styles.
36
+ - Use primary text for non-ignored explorer names, including dotfiles, while retaining muted ignored files and Git status colours.
37
+
38
+ ### Daemon
39
+
40
+ #### Fixed
41
+
42
+ - Preserve file timestamps and skip eager rebuilds for unchanged saves; hold queued builds after stale saves until their input conflicts resolve.
43
+
44
+ - Trigger eager compilation directly after successful saves, retain source watches across incomplete dependency reports, verify missed external source changes each second, and preserve LaTeX dependencies through symlinked roots.
package/dist/index.js CHANGED
@@ -44,7 +44,7 @@ var __toESM = (mod, isNodeMode, target2) => (target2 = mod != null ? __create(__
44
44
  var define_PUDDLE_COMPONENT_VERSIONS_default;
45
45
  var init_define_PUDDLE_COMPONENT_VERSIONS = __esm({
46
46
  "<define:__PUDDLE_COMPONENT_VERSIONS__>"() {
47
- define_PUDDLE_COMPONENT_VERSIONS_default = { cockpit: "0.4.15", daemon: "0.4.13", runtime: "0.4.11" };
47
+ define_PUDDLE_COMPONENT_VERSIONS_default = { cockpit: "0.4.17", daemon: "0.4.17", runtime: "0.4.11" };
48
48
  }
49
49
  });
50
50
 
@@ -24829,7 +24829,7 @@ import { readFileSync as readFileSync4 } from "node:fs";
24829
24829
  import { dirname as dirname6, join as join10 } from "node:path";
24830
24830
  import { fileURLToPath as fileURLToPath2 } from "node:url";
24831
24831
  function cliVersion() {
24832
- if (true) return "0.4.15";
24832
+ if (true) return "0.4.17";
24833
24833
  const here = dirname6(fileURLToPath2(import.meta.url));
24834
24834
  for (const candidate of [
24835
24835
  join10(here, "..", "..", "package.json"),
@@ -25243,7 +25243,9 @@ var RELEASE_PROTOCOLS = {
25243
25243
  "0.4.12": { major: 26, minor: 6 },
25244
25244
  "0.4.13": { major: 26, minor: 6 },
25245
25245
  "0.4.14": { major: 26, minor: 6 },
25246
- "0.4.15": { major: 26, minor: 6 }
25246
+ "0.4.15": { major: 26, minor: 6 },
25247
+ "0.4.16": { major: 26, minor: 6 },
25248
+ "0.4.17": { major: 26, minor: 6 }
25247
25249
  };
25248
25250
  function validProtocol(value) {
25249
25251
  if (typeof value !== "object" || value === null) return false;
@@ -0,0 +1,40 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ReleaseNotesDialog-sQVKJ6dm.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/jsx-runtime-By8HlURe.js","assets/purify.es-D8QhFVkO.js","assets/dialog-CTN-Lln6.js","assets/react-dom-cJyBB_A4.js","assets/utils-B6KiDbIe.js","assets/x-CbfJFzGo.js","assets/createLucideIcon-DyMAgLa3.js","assets/dialog-BX0tebJL.css","assets/queue-BlrQxHDl.js","assets/markdown-it-CWoG9_Dn.js","assets/markdown-Cseepnv3.js","assets/math-CSw6sgCC.js","assets/math-delimiters-BCnTi7Ii.js","assets/SettingsDialog-DKnJSEij.js","assets/protocol-support-sBpa8MZK.js","assets/auth-DYEjEl0U.js","assets/local-store-yUq3FKdV.js","assets/api-BwP0jv_V.js","assets/LazyTerminal-SbouF2Y_.js","assets/preload-helper-Czpn1I53.js","assets/dist-NuV8HBEc.js","assets/chevron-right-DUkOv15w.js","assets/notification-delivery-NbIhmidu.js","assets/theme-swfNLod9.js","assets/ws-DkbvXbTZ.js","assets/dist-BOS6OKSE.js","assets/switch-B3zcD6GH.js","assets/dist-cvE69gWt.js","assets/profile-store-B54YLXa8.js","assets/notification-delivery-BZzMYzIP.css","assets/client-settings-BdKglwtW.js","assets/index-ncmnNFLA.js","assets/index-DtbUW4I4.css","assets/button-D-qeQvl5.js","assets/select-CCBPniW9.js","assets/chevron-down--sjpQEHH.js","assets/code-DRWf9a5s.js","assets/trash-2-DQeNROsF.js","assets/rotate-ccw-CNjR2LSi.js","assets/control-tray-CjoJunx1.js","assets/control-tray-CG26TqqQ.css","assets/errors-CD96hLph.js","assets/use-debounced-value-C86N-mOK.js","assets/popover-Okyclsx8.js","assets/preferences-BX4iJsv8.js","assets/CompilationCommandForm-BGIgFAkM.js","assets/SettingsDialog-CJX0gDhJ.css","assets/Dashboard-B_m3VKHu.js","assets/session-order-DilOGTOO.js","assets/motion-Bd_MB9cH.js","assets/dist-BcrNV8NP.js","assets/archive-BYp06n6i.js","assets/expanding-content-UT_6Fp5v.js","assets/Workspace-DUBYqpNS.js","assets/forward-link-CkdngF7C.js","assets/media-refresh-store-Dxq65ATq.js","assets/use-ui-state-BLOunpIh.js","assets/preview-kind-CJ9RTgbs.js","assets/debounce-B9DrqirV.js","assets/whole-word-2m2pmAFT.js","assets/selection-actions-C33evFaY.js","assets/copy-CGsu8426.js","assets/search-Ct_rLLa4.js","assets/view-state-store-BLCtem0t.js","assets/drafts-B_tChlzR.js","assets/buffer-logic-BAkSBQT7.js","assets/scroll-restoration-D-jpZqdR.js","assets/file-links-BWU9Vnfc.js","assets/Workspace-CiATCR9s.css"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./react-dom-cJyBB_A4.js";import{$ as r,A as i,At as a,B as o,Bt as s,C as c,E as l,Et as u,Ft as d,G as f,Gt as p,H as m,Ht as h,I as g,It as _,Jt as v,Kt as y,L as b,Lt as x,Mt as S,O as C,Ot as ee,Q as te,Rt as w,St as T,T as E,Ut as D,Vt as O,Z as k,at as ne,c as re,ct as ie,dt as ae,ft as oe,it as se,j as ce,k as le,kt as ue,lt as de,nt as fe,o as pe,q as me,qt as he,rt as ge,ut as A,vt as _e,w as ve,zt as ye}from"./protocol-support-sBpa8MZK.js";import{I as be,K as xe,M as Se,S as Ce,U as we,X as Te,Y as Ee,r as De,u as Oe}from"./auth-DYEjEl0U.js";import{a as j,c as ke,i as Ae,o as je,u as Me}from"./LazyTerminal-SbouF2Y_.js";import{C as Ne,D as Pe,E as Fe,N as Ie,P as Le,T as Re,_ as ze,a as Be,d as Ve,g as He,h as Ue,i as We,j as Ge,k as Ke,l as qe,m as Je,o as Ye,p as Xe,s as Ze,t as Qe,u as $e,w as et}from"./notification-delivery-NbIhmidu.js";import{r as M}from"./local-store-yUq3FKdV.js";import{i as tt,r as nt,t as rt}from"./client-settings-BdKglwtW.js";import{c as it,n as at,r as ot,s as st,t as ct}from"./theme-swfNLod9.js";import{t as lt}from"./jsx-runtime-By8HlURe.js";import{t as ut}from"./preload-helper-Czpn1I53.js";import{n as N}from"./api-BwP0jv_V.js";import{_ as P,a as dt,c as ft,d as pt,f as F,g as mt,h as ht,i as gt,l as _t,o as vt,p as yt,s as bt,t as I,v as xt}from"./ws-DkbvXbTZ.js";import{t as St}from"./forward-link-CkdngF7C.js";import{C as Ct,S as wt,T as Tt,a as Et,b as Dt,c as Ot,f as kt,g as At,m as jt,o as Mt,r as Nt,s as Pt,v as Ft,w as It,x as Lt,y as Rt}from"./session-order-DilOGTOO.js";import{t as zt}from"./motion-Bd_MB9cH.js";import{t as L}from"./utils-B6KiDbIe.js";import{o as Bt,r as Vt,s as Ht,t as Ut}from"./dialog-CTN-Lln6.js";import{n as R,t as Wt}from"./dist-BOS6OKSE.js";import{f as Gt,r as Kt}from"./dist-NuV8HBEc.js";import{$ as qt,G as Jt,J as Yt,K as Xt,U as Zt,W as Qt,X as $t,Y as en,Z as tn,at as z,d as nn,et as rn,f as an,h as B,i as on,it as V,m as sn,nt as cn,ot as ln,p as un,q as dn,r as fn,rt as pn,st as H,t as mn,tt as hn}from"./use-ui-state-BLOunpIh.js";import{n as gn,t as U}from"./button-D-qeQvl5.js";import{n as W,r as _n}from"./chevron-right-DUkOv15w.js";import{t as G}from"./createLucideIcon-DyMAgLa3.js";import{c as vn,d as yn,i as K,l as bn,o as xn,t as Sn,u as Cn}from"./switch-B3zcD6GH.js";import{t as wn}from"./copy-CGsu8426.js";import{n as Tn,r as En,t as Dn}from"./expanding-content-UT_6Fp5v.js";import{n as On,t as kn}from"./trash-2-DQeNROsF.js";import{t as An}from"./settings-2-CInoy48z.js";import{n as jn,r as q,t as Mn}from"./profile-store-B54YLXa8.js";import{t as Nn}from"./control-tray-CjoJunx1.js";import{n as J}from"./errors-CD96hLph.js";import{a as Pn,c as Fn,i as In,n as Ln,o as Rn,r as zn,s as Bn}from"./command-BeX8pm7h.js";import{n as Vn,r as Hn,t as Un}from"./popover-Okyclsx8.js";import{n as Wn,r as Gn,t as Kn}from"./queue-BlrQxHDl.js";var Y=e(t(),1),X=lt();function qn(){let[e,t]=(0,Y.useState)(`Opening forwarded application…`);return(0,Y.useEffect)(()=>{if(!/^\/forward\/([^/]+)\/(\d+)$/.exec(window.location.pathname)){t(`This forwarding link is invalid.`);return}let e=!0;return St(new URL(window.location.href)).then(t=>{e&&window.location.replace(t)}).catch(()=>{e&&t(`The application is unavailable. Reconnect to Puddle and open this link again.`)}),()=>{e=!1}},[]),(0,X.jsx)(`p`,{className:`p-8 text-sm text-fg-secondary`,children:e})}var Jn=class extends v{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new a({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Yn(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Yn(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Yn(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=Yn(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){_.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>s(t,e))}findAll(e={}){return this.getAll().filter(t=>s(e,t))}notify(e){_.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return _.batch(()=>Promise.all(e.map(e=>e.continue().catch(h))))}};function Yn(e){return e.options.scope?.id}var Xn=class extends v{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??ye(r,t),a=this.get(i);return a||(a=new S({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){_.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>O(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>O(e,t)):t}notify(e){_.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){_.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){_.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Zn=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Xn,this.#t=e.mutationCache||new Jn,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=he.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=d.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(p(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=x(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return _.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;_.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return _.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=_.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(h).catch(h)}invalidateQueries(e,t={}){return _.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=_.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(h)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(h)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(p(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(h).catch(h)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(h).catch(h)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return d.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(w(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{D(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(w(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{D(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=ye(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===y&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Qn=class extends Y.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidUpdate(e){this.state.error!==null&&e.resetOn!==this.props.resetOn&&this.setState({error:null})}componentDidCatch(e,t){console.error(`Puddle: the ${this.props.scope} crashed`,e,t.componentStack)}render(){let{error:e}=this.state;return e===null?this.props.children:(0,X.jsxs)(`div`,{className:`flex h-full min-h-40 flex-col items-center justify-center gap-4 px-8 py-10 text-center`,children:[(0,X.jsxs)(`p`,{className:`text-sm text-fg`,children:[`The `,this.props.scope,` stopped rendering.`]}),(0,X.jsx)(`p`,{className:`max-w-lg font-mono text-2xs leading-relaxed text-interrupted`,children:e.message||String(e)}),(0,X.jsx)(`p`,{className:`max-w-sm text-2xs leading-relaxed text-fg-muted`,children:`Your sessions and their worktrees are on the daemon and untouched; the layout is saved. The console has the full stack.`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>this.setState({error:null}),className:`text-2xs font-medium text-fg-gold transition-colors hover:underline`,children:`Try again`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Reload`})]})]})}};function $n(){return(0,X.jsx)(Wt,{theme:(0,Y.useSyncExternalStore)(st,ot),position:`bottom-right`,toastOptions:{style:{background:`var(--bg-elevated)`,border:`none`,boxShadow:`var(--ui-overlay-shadow)`,borderRadius:`var(--ui-surface-radius)`,outline:`1px solid var(--border)`,color:`var(--text-primary)`},classNames:{description:`whitespace-pre-wrap break-words font-mono text-2xs leading-snug max-h-40 overflow-y-auto`}}})}function er(){return(0,X.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-ground`,children:(0,X.jsxs)(`div`,{className:`flex w-full max-w-md flex-col gap-10 px-8 pb-24`,children:[(0,X.jsx)(`h1`,{className:`font-mono text-2xl font-semibold text-fg`,children:`Puddle`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 text-sm leading-relaxed text-fg-secondary`,children:[(0,X.jsxs)(`p`,{children:[`Authorise this browser by running`,` `,(0,X.jsx)(`span`,{className:`font-mono text-accent`,children:`puddle launch`}),` in a terminal.`]}),(0,X.jsx)(`p`,{children:`Use the link it opens. Your sessions, drafts and layouts stay in place.`})]})]})})}var tr=e(n(),1),nr=`a, button, [role="button"], [role="slider"], input, select, textarea, summary, label, [onclick], .cursor-pointer`,rr=`.monaco-editor`;function ir(e,t){return e?.closest(rr)&&!e.closest(t)?`text`:e?.closest(nr)?`interactive`:`default`}function ar(e,t=`.no-custom-caret`){(0,Y.useEffect)(()=>{let n=e.current;if(!n)return;let r=window.matchMedia(`(pointer: fine)`),i=0,a=null,o=null,s=!0,c=!1,l=new MutationObserver(()=>d()),u=()=>{a&&!i&&(i=requestAnimationFrame(p))},d=()=>{s=!0,c=!0,u()},f=()=>{cancelAnimationFrame(i),i=0,a=null,o=null,s=!0,l.disconnect(),n.style.opacity=`0`},p=()=>{if(i=0,!a)return;let{x:e,y:u}=a,d=c?document.elementFromPoint(e,u):a.target;if(a.target=d,c=!1,d instanceof HTMLIFrameElement||!r.matches){f();return}if(n.style.transform=`translate3d(${e}px, ${u}px, 0) translate(-50%, -50%)`,n.style.opacity=`1`,!s&&d===o)return;if(s=!1,o=d,l.disconnect(),d&&d!==n&&!n.contains(d)){l.observe(d,{attributes:!0,childList:!0});for(let e of d.childNodes)e.nodeType===Node.TEXT_NODE&&l.observe(e,{characterData:!0});for(let e=d.parentElement;e;e=e.parentElement)l.observe(e,{attributes:!0,childList:!0})}l.observe(document.head,{attributes:!0,childList:!0,characterData:!0,subtree:!0});let p=d?.closest(rr),m=ir(d,t),h=m===`text`,g=m===`interactive`,_=h;if(h&&p){let e=getComputedStyle(p);n.style.setProperty(`--custom-cursor-caret-height`,`${Math.round(Number.parseFloat(e.fontSize)*1.3)}px`)}else if(!g&&d&&!d.closest(t)&&Array.from(d.childNodes).some(e=>e.nodeType===Node.TEXT_NODE&&e.textContent?.trim())){let e=getComputedStyle(d);e.userSelect!==`none`&&(_=!0,n.style.setProperty(`--custom-cursor-caret-height`,`${Math.round(Number.parseFloat(e.fontSize)*1.3)}px`))}n.classList.toggle(`is-interactive`,g),n.classList.toggle(`is-text`,_)},m=e=>{if(e.pointerType===`touch`||!r.matches){f();return}a={x:e.clientX,y:e.clientY,target:e.target instanceof Element?e.target:null},c=!1,u()},h=()=>{r.matches?d():f()};return window.addEventListener(`pointermove`,m,{passive:!0}),document.documentElement.addEventListener(`pointerleave`,f),window.addEventListener(`blur`,f),window.addEventListener(`resize`,d),document.addEventListener(`scroll`,d,!0),document.addEventListener(`focusin`,d),document.addEventListener(`focusout`,d),document.addEventListener(`pointerdown`,d),document.addEventListener(`pointerup`,d),r.addEventListener(`change`,h),document.fonts.addEventListener(`loadingdone`,d),()=>{window.removeEventListener(`pointermove`,m),document.documentElement.removeEventListener(`pointerleave`,f),window.removeEventListener(`blur`,f),window.removeEventListener(`resize`,d),document.removeEventListener(`scroll`,d,!0),document.removeEventListener(`focusin`,d),document.removeEventListener(`focusout`,d),document.removeEventListener(`pointerdown`,d),document.removeEventListener(`pointerup`,d),r.removeEventListener(`change`,h),document.fonts.removeEventListener(`loadingdone`,d),f()}},[t,e])}var or=[`top`,`right`,`bottom`,`left`];function sr(){let e=(0,Y.useRef)(null);return ar(e),(0,X.jsx)(`div`,{ref:e,className:`custom-cursor drafting-cursor`,"aria-hidden":`true`,children:or.map(e=>(0,X.jsx)(`span`,{className:`drafting-cursor-tick`,"data-side":e},e))})}function cr(){let e=(0,Y.useRef)(null);return ar(e),(0,X.jsx)(`div`,{ref:e,className:`custom-cursor invert-cursor`,"aria-hidden":`true`})}var lr=`h1, h2, h3, h4, h5, h6, .no-rangefinder-caret`,Z=40.5,Q=4.05,ur=Q*Math.sqrt(3)/2;function dr(){let e=[],t=[],n=Z/2,r=Math.ceil(n/ur)+1,i=e=>Math.round(e*100)/100,a=e=>`M${e.map(([e,t])=>`${i(e)} ${i(t)}`).join(`L`)}Z`;for(let i=-r;i<r;i+=1){let o=n+i*ur,s=o+ur,c=(i%2+2)%2*(Q/2);for(let i=-r;i<r;i+=1){let r=n+i*Q+c,l=[[r+Q/2,o],[r,s],[r+Q,s]],u=[[r+Q/2,o],[r+3*Q/2,o],[r+Q,s]],d=e=>{let t=e.map(([e])=>e),n=e.map(([,e])=>e);return Math.max(...t)>0&&Math.min(...t)<Z&&Math.max(...n)>0&&Math.min(...n)<Z};d(l)&&e.push(a(l)),d(u)&&t.push(a(u))}}return{light:e.join(``),dark:t.join(``)}}var fr=dr();function pr(){let e=(0,Y.useRef)(null);return ar(e,lr),(0,X.jsx)(`div`,{ref:e,className:`custom-cursor rangefinder-cursor`,"aria-hidden":`true`,children:(0,X.jsxs)(`svg`,{className:`rangefinder-cursor-facets`,viewBox:`0 0 ${Z} ${Z}`,focusable:`false`,children:[(0,X.jsx)(`path`,{className:`rangefinder-cursor-facet-light`,d:fr.light}),(0,X.jsx)(`path`,{className:`rangefinder-cursor-facet-dark`,d:fr.dark})]})})}function mr(){let{cursorPackage:e}=tt(),t=null;switch(e){case`rangefinder`:t=(0,X.jsx)(pr,{});break;case`drafting`:t=(0,X.jsx)(sr,{});break;case`invert`:t=(0,X.jsx)(cr,{});break;case`system`:return null}return(0,tr.createPortal)(t,document.body)}var hr=G(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),gr=G(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),_r=G(`monitor-cog`,[[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`m14.305 7.53.923-.382`,key:`1mlnsw`}],[`path`,{d:`m15.228 4.852-.923-.383`,key:`82mpwg`}],[`path`,{d:`m16.852 3.228-.383-.924`,key:`ln4sir`}],[`path`,{d:`m16.852 8.772-.383.923`,key:`1dejw0`}],[`path`,{d:`m19.148 3.228.383-.924`,key:`192kgf`}],[`path`,{d:`m19.53 9.696-.382-.924`,key:`fiavlr`}],[`path`,{d:`m20.772 4.852.924-.383`,key:`1j8mgp`}],[`path`,{d:`m20.772 7.148.924.383`,key:`zix9be`}],[`path`,{d:`M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7`,key:`1tnzv8`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}]]),vr=G(`notebook-pen`,[[`path`,{d:`M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4`,key:`re6nr2`}],[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`path`,{d:`M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`pqwjuv`}]]),yr=G(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),br=G(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]);function xr(){let e=A(),t=b(),[n,r]=(0,Y.useState)(``),[i,a]=(0,Y.useState)(be),o=()=>{n.trim()&&t.mutate({name:n.trim(),branch_prefix:i.trim()},{onSuccess:e=>jn(e.id)})},s=(e.data?.length??0)>0;return(0,X.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-ground`,children:(0,X.jsxs)(`div`,{className:`flex w-full max-w-md flex-col gap-10 px-8 pb-16`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h1`,{className:`font-mono text-2xl font-semibold text-fg`,children:`Puddle`}),(0,X.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`Who is working?`})]}),s&&(0,X.jsx)(`div`,{className:`flex flex-col`,children:e.data.map(e=>(0,X.jsxs)(`button`,{onClick:()=>jn(e.id),className:`flex items-center gap-3 rounded-md px-3 py-2.5 text-left transition-colors hover:bg-elevated active:bg-border/70`,children:[(0,X.jsx)(Ke,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,X.jsx)(`span`,{className:L(`text-base`,j(e.icon_colour)||`text-fg`),style:je(e.icon_colour),children:e.name}),e.branch_prefix&&(0,X.jsxs)(`span`,{className:`ml-auto text-2xs text-fg-muted`,children:[e.branch_prefix,`…`]})]},e.id))}),(0,X.jsxs)(`form`,{className:`flex flex-col gap-5`,onSubmit:e=>{e.preventDefault(),o()},children:[s&&(0,X.jsx)(`p`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`or create a profile`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(Me,{htmlFor:`profile-name`,children:`Name`}),(0,X.jsx)(W,{id:`profile-name`,placeholder:`e.g. alice`,value:n,onChange:e=>r(e.target.value),className:`h-10`,autoFocus:!s})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(Me,{htmlFor:`branch-prefix`,children:`Branch prefix`}),(0,X.jsx)(W,{id:`branch-prefix`,placeholder:`no prefix`,value:i,onChange:e=>a(e.target.value),className:`h-10`})]}),t.error&&(0,X.jsx)(`p`,{className:`text-xs text-danger`,children:t.error.message}),(0,X.jsx)(U,{type:`submit`,size:`lg`,className:`self-start px-6`,disabled:!n.trim()||t.isPending,children:`Create profile`})]})]})})}function Sr({kind:e,colour:t,onRename:n,onColour:r,custom:i=!0,pending:a=!1,onUpdates:o}){let[s,c]=(0,Y.useState)(!1);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Mt,{children:[(0,X.jsxs)(Pt,{onSelect:n,children:[(0,X.jsx)(ke,{}),`Rename `,e]}),(0,X.jsxs)(Pt,{onSelect:()=>c(!0),children:[(0,X.jsx)(Cn,{}),`Change `,e,` colour`]}),o&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ot,{}),(0,X.jsxs)(Pt,{onSelect:o,children:[(0,X.jsx)(bn,{}),`Host updates`]})]})]}),(0,X.jsx)(Ut,{open:s,onOpenChange:c,children:(0,X.jsxs)(Vt,{children:[(0,X.jsx)(Bt,{children:(0,X.jsx)(Ht,{children:e===`host`?`Host accent`:`Profile colour`})}),(0,X.jsx)(Ae,{value:t,onChange:r,onCustomChange:i?r:void 0,disabled:a,label:e===`host`?`Host accent`:`Profile colour`})]})})]})}function Cr(){let e=k(),{icon:t}=Pe(),n=q(),r=ht()[`host.peek`],{showHostOnFocus:i}=tt(),[a,o]=(0,Y.useState)(null),s=/Mac/.test(navigator.platform),c=(0,Y.useRef)(!1),l=(0,Y.useRef)(-1/0);return(0,Y.useEffect)(()=>{let e,t=document.hidden||!document.hasFocus(),n=-1/0,a,u=()=>{clearTimeout(e),e=void 0},d=()=>{u(),c.current=!1,o(null)},f=()=>{t=!0,d()},p=()=>{if(document.hidden)return;let r=performance.now(),a=r-l.current>=(s?750:250);l.current=r;let f=t;t=!1,!(!f||!a||!i||c.current)&&(n=r,u(),o(`focus`),e=setTimeout(()=>{if(!s||zt())return d();o(`focus-closing`),e=setTimeout(d,120)},s?400:1200))},m=t=>{t instanceof KeyboardEvent&&[`Meta`,`Alt`,`Control`,`Shift`].includes(t.key)||t.type===`pointerdown`&&performance.now()-n<100||e!==void 0&&d()},h=r?.split(`+`)??[],g=h.at(-1),_={Meta:`meta`,Control:`ctrl`,Alt:`alt`,Shift:`shift`},v=e=>{c.current&&(e.key===`Escape`&&(e.preventDefault(),e.stopPropagation()),(e.type===`keyup`&&(e.code===g||h.includes(_[e.key]??_[e.code.replace(/(Left|Right)$/,``)]??``))||e.key===`Escape`||h.includes(`meta`)&&!e.metaKey||h.includes(`ctrl`)&&!e.ctrlKey||h.includes(`alt`)&&!e.altKey||h.includes(`shift`)&&!e.shiftKey)&&d())},y=()=>{document.hidden?f():p()},b=F(`host.peek`,()=>{c.current||document.hidden||(u(),c.current=!0,o(`shortcut`))});window.addEventListener(`keyup`,v,!0),window.addEventListener(`keydown`,v,!0),window.addEventListener(`blur`,f),window.addEventListener(`pagehide`,f),window.addEventListener(`focus`,p),window.addEventListener(`keydown`,m,!0),window.addEventListener(`pointerdown`,m,!0),window.addEventListener(`wheel`,m,{passive:!0,capture:!0}),document.addEventListener(`visibilitychange`,y);let x=P()?.onWindowFocusChange?.(e=>{let n=e!==a;a=e,e?n&&(t=!0,p()):f()});return()=>{x?.(),b(),window.removeEventListener(`keyup`,v,!0),window.removeEventListener(`keydown`,v,!0),window.removeEventListener(`blur`,f),window.removeEventListener(`pagehide`,f),window.removeEventListener(`focus`,p),window.removeEventListener(`keydown`,m,!0),window.removeEventListener(`pointerdown`,m,!0),window.removeEventListener(`wheel`,m,!0),document.removeEventListener(`visibilitychange`,y),d()}},[r,s,n,i]),a?(0,tr.createPortal)((0,X.jsx)(`div`,{"data-host-peek":!0,"data-state":a===`focus-closing`?`closed`:a===`focus`&&s?`instant-open`:`open`,className:`overlay-backdrop-motion fixed inset-0 z-[200] flex items-center justify-center p-8 text-fg backdrop-blur-[8px]`,style:a===`shortcut`?void 0:{pointerEvents:`none`,...a===`focus-closing`?{animationFillMode:`forwards`,opacity:0}:{}},onPointerDown:e=>e.preventDefault(),role:`status`,"aria-live":`polite`,children:(0,X.jsxs)(`div`,{className:`flex max-w-full flex-col items-center gap-6 px-12 py-10 text-center`,children:[(0,X.jsx)(Fe,{icon:t,className:`size-[clamp(4.5rem,13.5vmin,10.5rem)] shrink-0`}),(0,X.jsx)(`span`,{className:`max-w-full break-words font-sans text-[clamp(0.8333rem,1.75vw,1.75rem)] leading-tight font-medium`,children:E(e.data)??`Host`})]})}),document.body):null}function wr(){let e=m().data?.protocol,t=e!==void 0&&(e.major>25||e.major===25&&e.minor>=5),{data:n}=u({queryKey:[`storage`],queryFn:()=>N(`GET`,`/api/storage`),enabled:t&&!M(),refetchInterval:1e4,retry:!1});if(!t||M()||!n)return null;let r=n.volumes.filter(e=>e.level!==`ok`);if(!n.logs_degraded&&!n.database_degraded&&r.length===0)return null;let i=r.some(e=>e.level===`critical`);return(0,X.jsxs)(`div`,{role:`status`,className:`flex shrink-0 items-start gap-2 px-3 py-2 text-xs text-warning`,children:[(0,X.jsx)(pn,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[n.database_degraded&&(0,X.jsx)(`p`,{children:`Storage is full. Changes cannot be saved. Live session status may be unsaved.`}),n.logs_degraded&&(0,X.jsx)(`p`,{children:`Terminal history is temporarily not being saved. Live terminals remain connected.`}),i&&(0,X.jsx)(`p`,{children:`Storage is critically low. Free space or inodes before starting new sessions or worktrees.`}),r.length>0&&(0,X.jsx)(xn,{summary:`${r.length} storage ${r.length===1?`location needs`:`locations need`} attention`,children:(0,X.jsx)(`div`,{className:`max-h-32 overflow-y-auto pl-4`,children:r.map(e=>(0,X.jsxs)(`p`,{className:`break-all text-fg-secondary`,children:[e.level===`unknown`?`Could not check storage`:`Low storage`,` at`,` `,e.path,e.available_bytes!==null&&` · ${Math.round(e.available_bytes/1024**2).toLocaleString()} MiB available`,e.available_inodes!==null&&` · ${e.available_inodes.toLocaleString()} inodes available`]},e.path))})})]})]})}var Tr=new class{transport;reload;pause;phase=`idle`;pending=null;constructor(e=fetch,t=()=>window.location.reload(),n=e=>new Promise(t=>setTimeout(t,e))){this.transport=e,this.reload=t,this.pause=n}refresh(e=12e4){return this.pending||=this.run(e).finally(()=>{this.pending=null}),this.pending}async run(e){this.phase=`requesting`;let t={authorization:`Bearer ${De.get()??``}`,"content-type":`application/json`};try{let n=await this.transport(`/cockpit/refresh`,{method:`POST`,headers:t,signal:AbortSignal.timeout(1e4),body:JSON.stringify({refreshId:crypto.randomUUID()})});if(n.status!==202)throw Error(`refresh rejected`);let r=Ce.parse(await n.json());this.phase=`waiting`;let i=Date.now()+e;for(;Date.now()<i;){await this.pause(1e3);try{let e=await this.transport(`/cockpit/status`,{headers:t,cache:`no-store`,signal:AbortSignal.timeout(3e3)});if(!e.ok)continue;let n=Oe.parse(await e.json());if(n.instance===r.instance||n.refreshId!==r.refreshId||n.upstream!==`ready`)continue;return this.phase=`complete`,this.reload(),!0}catch{}}}catch{}return this.phase=`failed`,!1}},Er=null;function Dr(e){return Er=e,()=>{Er===e&&(Er=null)}}function Or(){Er?.()}var kr=new Set;function Ar(){return[...kr].flatMap(e=>e())}function jr({onNewSession:e,onNewProject:t}){let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(`commands`),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(!1),f=It(),p=Tt(),m=q(),h=p.id,g=oe(m??void 0),_=de(m??void 0),v=T(h),y=$t(),b=ht();(0,Y.useEffect)(()=>F(`palette.toggle`,()=>r(e=>!e)),[]),(0,Y.useEffect)(()=>rn(()=>r(!0)),[]),(0,Y.useEffect)(()=>{n||(a(`commands`),s(``),l(null),d(!1))},[n]);let x=(0,Y.useMemo)(()=>{let n=[],r=Nt((g.data??[]).filter(e=>!e.archived),_.data?.projectOrder??[]);for(let[e,t]of r.entries()){let r=gt[e];n.push({id:`project-${t.id}`,group:`Projects`,label:t.name,icon:En,keywords:`switch project open`,shortcut:r?bt(b[r.id]??``):void 0,run:()=>void f(`/project/${t.id}`)})}for(let e of v.data??[])e.status!==`archived`&&n.push({id:`session-${e.id}`,group:`Sessions`,label:y(e),icon:jt,keywords:`switch session ${e.branch}`,run:()=>void f(`/project/${e.project_id}/session/${e.id}`)});return h!==void 0&&e&&n.push({id:`new-agent`,group:`Actions`,label:`New agent`,icon:yn,keywords:`new agent create start session`,run:()=>e()},{id:`new-terminal`,group:`Actions`,label:`New terminal`,icon:jt,keywords:`new terminal create start shell session`,run:()=>e({kind:`terminal`})}),h!==void 0&&n.push({id:`open-path`,group:`Actions`,label:`Open path`,icon:En,keywords:`open path file directory folder editor tree browse absolute relative home`,closeOnRun:!1,run:()=>{s(``),l(null),a(`path`)}}),t&&n.push({id:`new-project`,group:`Actions`,label:`New project`,icon:On,keywords:`new project open create repository repo workspace`,run:t}),n.push({id:`theme-dark`,group:`Theme`,label:`Switch theme: dark`,icon:Ie,keywords:`switch theme dark appearance`,run:()=>void ct(`dark`)},{id:`theme-light`,group:`Theme`,label:`Switch theme: light`,icon:Ge,keywords:`switch theme light appearance`,run:()=>void ct(`light`)},{id:`theme-system`,group:`Theme`,label:`Switch theme: system`,icon:_r,keywords:`switch theme system appearance`,run:()=>void ct(`system`)},{id:`open-settings`,group:`Actions`,label:`Settings`,icon:br,keywords:`open settings preferences options configure`,run:()=>K()},{id:`switch-profile`,group:`Actions`,label:`Switch profile`,icon:vn,keywords:`switch profile identity user change`,run:()=>Mn.set(null)},{id:`refresh-connection`,group:`Actions`,label:`Refresh connection`,icon:bn,keywords:`refresh connection reconnect restart cockpit tunnel ssh daemon`,run:()=>Or()}),[...n,...Ar()]},[b,g.data,_.data?.projectOrder,v.data,h,f,e,t,y]),S=(0,Y.useMemo)(()=>{let e=new Map;for(let t of x){let n=e.get(t.group)??[];n.push(t),e.set(t.group,n)}return[...e.entries()]},[x]),C=async()=>{let e=o.trim();if(!(e===``||u)){d(!0),l(null);try{await tn(e),r(!1)}catch(e){l(e instanceof Error?e.message:`Could not open that path.`)}finally{d(!1)}}};return(0,X.jsxs)(Ln,{open:n,onOpenChange:r,children:[(0,X.jsx)(Pn,{value:o,onValueChange:e=>{s(e),l(null)},placeholder:i===`path`?`Enter a path…`:`Type a command or search…`,onKeyDown:e=>{i===`path`&&(e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),C()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),a(`commands`),s(``),l(null)))}}),i===`path`?(0,X.jsx)(Bn,{children:(0,X.jsxs)(`div`,{className:`px-3 py-3 text-xs text-fg-muted`,children:[(0,X.jsx)(`p`,{children:`Relative paths start from the bound worktree or project. Absolute and ~ paths work too.`}),(0,X.jsx)(`p`,{className:c?`mt-2 text-danger`:`mt-2`,"aria-live":`polite`,children:c??(u?`Opening…`:`Press Enter to open.`)})]})}):(0,X.jsxs)(Bn,{children:[(0,X.jsx)(zn,{children:`Nothing matches.`}),S.map(([e,t])=>(0,X.jsx)(In,{heading:e,children:t.map(e=>{let t=e.icon;return(0,X.jsxs)(Rn,{value:`${e.label} ${e.keywords??``}`,onSelect:()=>{e.closeOnRun!==!1&&r(!1),e.run()},children:[t&&(0,X.jsx)(t,{}),e.label,e.shortcut&&(0,X.jsx)(Fn,{children:e.shortcut})]},e.id)})},e))]})]})}function Mr(){let e=document.activeElement;return e instanceof Element&&e.closest(`.xterm`)!==null}function Nr(){let e=document.activeElement;return e instanceof Element&&e.closest(`.monaco-editor`)!==null}function Pr(){let e=It(),t=q(),n=oe(t??void 0),r=de(t??void 0),i=r.data?.hotkeys;return(0,Y.useEffect)(()=>{yt(i&&typeof i==`object`?i:void 0)},[i]),(0,Y.useEffect)(()=>{if(t===null)return;let i=Nt((n.data??[]).filter(e=>!e.archived),r.data?.projectOrder??[]),a=gt.map((t,n)=>F(t.id,()=>{let t=i[n];t&&e(`/project/${t.id}`)}));return()=>a.forEach(e=>e())},[e,t,n.data,r.data?.projectOrder]),(0,Y.useEffect)(()=>F(`window.close`,()=>{let e=P();e?.closeWindow?e.closeWindow():window.close()}),[]),(0,Y.useEffect)(()=>{let e=e=>{if(e.target instanceof Element&&e.target.closest(`[data-hotkey-recording]`))return;let t=vt(e);if(!t)return;let n=dt(t);if(!n)return;let r=ft(n);if(!r||!pt(r,Nr())||r.deferInTerminal&&Mr())return;let i=_t(n);i&&(e.preventDefault(),e.stopPropagation(),(!r.hold||!e.repeat)&&i())},t=e=>{let t=vt(e);if(!t)return;let n=dt(t);if(!n)return;let r=ft(n);if(!r||r.editor&&Nr()||r.deferInTerminal&&Mr())return;let i=_t(n);i&&(e.preventDefault(),i())};return window.addEventListener(`keydown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,e,!0),window.removeEventListener(`keydown`,t)}},[]),null}var Fr=4e3;function Ir(){let[e,t]=(0,Y.useState)(`hidden`),n=(0,Y.useRef)(e);n.current=e,(0,Y.useEffect)(()=>{let e=null,r=I.onConnectionChange(r=>{if(r){e!==null&&clearTimeout(e),e=null,n.current===`lost`&&t(`hidden`);return}e!==null||n.current!==`hidden`||(e=setTimeout(()=>{e=null,n.current===`hidden`&&t(`lost`)},Fr))});return()=>{r(),e!==null&&clearTimeout(e)}},[]);let r=(0,Y.useCallback)(async()=>{n.current!==`refreshing`&&(t(`refreshing`),await Tr.refresh()||(R.error(`The cockpit has not come back — it may need a terminal (ssh re-auth): puddle refresh`),t(I.isConnected()?`hidden`:`lost`)))},[]);return(0,Y.useEffect)(()=>Dr(()=>void r()),[r]),e===`hidden`?null:(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 bg-elevated px-3 py-2`,children:[(0,X.jsx)(`span`,{className:`text-xs text-fg-secondary`,children:e===`refreshing`?`Restarting the cockpit.`:`Connection to the daemon lost.`}),e===`lost`&&(0,X.jsxs)(U,{size:`sm`,className:`ml-auto`,onClick:()=>void r(),children:[(0,X.jsx)(bn,{}),`Refresh connection`]})]})}function Lr({label:e,percentage:t,hint:n}){let r=Math.max(0,Math.min(100,t));return(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`w-24 shrink-0 truncate text-2xs text-fg-muted`,title:e,children:e}),(0,X.jsx)(`span`,{className:`relative h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-border`,children:(0,X.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full ${r>=90?`bg-danger`:r>=75?`bg-warning`:`bg-action`}`,style:{width:`${r}%`}})}),(0,X.jsxs)(`span`,{className:`shrink-0 text-2xs tabular-nums text-fg-muted`,children:[Math.round(r),`%`,n?` · ${n}`:``]})]})}function Rr(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function zr(e){if(e===null)return`never`;let t=new Date(e).getTime(),n=Math.max(0,Math.round((Date.now()-t)/1e3));if(n<60)return`just now`;let r=Math.round(n/60);if(r<60)return`${r}m ago`;let i=Math.round(r/60);return i<24?`${i}h ago`:`${Math.round(i/24)}d ago`}function Br({account:e,onLogin:t,onStartSession:n,installed:r=!0}){let i=C(e.id),a=e.logged_in?n:r?t:null,o=i.data?.subscription;return(0,X.jsxs)(`div`,{className:`rounded-md px-2 py-2 transition-colors hover:bg-elevated`,children:[(0,X.jsxs)(`button`,{type:`button`,disabled:a===null,onClick:()=>a?.(),className:`flex w-full items-center gap-3 text-left disabled:cursor-default`,children:[(0,X.jsx)(`span`,{className:`size-2 shrink-0 rounded-full ${e.logged_in?`bg-success`:`bg-idle`}`,"aria-hidden":!0}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.label}),(0,X.jsxs)(`span`,{className:`block text-2xs text-fg-muted`,children:[e.logged_in?`logged in`:`logged out`,i.data&&(0,X.jsxs)(X.Fragment,{children:[` · `,i.data.session_count,` session`,i.data.session_count===1?``:`s`,i.data.active_session_count>0&&` (${i.data.active_session_count} active)`,` · `,`last `,zr(i.data.last_activity_at)]})]}),i.data?.agent_usage&&(0,X.jsxs)(`span`,{className:`block text-2xs text-fg-muted`,children:[Rr(i.data.agent_usage.input_tokens),` in ·`,` `,Rr(i.data.agent_usage.output_tokens),` out ·`,` `,Rr(i.data.agent_usage.cache_read_input_tokens),` cached ·`,` `,i.data.agent_usage.message_count,` msgs`]}),i.data?.live_usage?.context_used_percentage!=null&&(0,X.jsx)(`span`,{className:`mt-1 block`,children:(0,X.jsx)(Lr,{label:`context`,percentage:i.data.live_usage.context_used_percentage})})]}),(0,X.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted`,children:r?e.logged_in?n?`new agent`:``:(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-warning`,children:[(0,X.jsx)(Le,{className:`size-3`}),`sign in`]}):`unavailable`})]}),o!=null&&o.windows.length>0&&(0,X.jsx)(`div`,{className:`mt-2 flex flex-col gap-1 pl-5`,children:o.windows.map(e=>(0,X.jsx)(Lr,{label:e.label,percentage:e.used_percentage,hint:e.resets==null?void 0:`resets ${e.resets}`},e.key))})]})}function Vr(){let[e,t]=(0,Y.useState)(!1),[n,a]=(0,Y.useState)(!1),o=q(),s=A(),c=se(),l=s.data?.find(e=>e.id===o),u=le(o??void 0),d=i(),f=r(),{open:p,handler:m}=en(),[h,g]=(0,Y.useState)(null),_=e=>f.mutate(e.id,{onSuccess:t=>g({stream:t.stream,label:`${e.agent_type}/${e.label}`}),onError:e=>J(e)}),v=e=>{t(!1),p({accountId:e.id})},y=e=>{a(!1);let t=e.trim();!o||!t||t===l?.name||c.mutate({id:o,name:t},{onError:e=>J(e)})},b=`profile-trigger font-sans compact:h-7 compact:px-1.5`;return n&&l?(0,X.jsxs)(`div`,{className:gn({variant:`ghost`,size:`sm`,className:b}),style:je(l.icon_colour),children:[(0,X.jsx)(Ke,{icon:l.icon,colour:l.icon_colour}),(0,X.jsx)(hn,{initial:l.name,maxLength:100,fitContent:!0,className:j(l.icon_colour),onCommit:y,onCancel:()=>a(!1)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Et,{onOpenChange:e=>{e&&t(!1)},children:[(0,X.jsxs)(Un,{open:e,onOpenChange:t,children:[(0,X.jsxs)(V,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsx)(Hn,{asChild:!0,children:(0,X.jsx)(kt,{asChild:!0,children:(0,X.jsxs)(U,{variant:`ghost`,size:`sm`,className:b,children:[(0,X.jsx)(Ke,{icon:l?.icon,colour:l?.icon_colour}),(0,X.jsx)(`span`,{className:j(l?.icon_colour),style:je(l?.icon_colour),...cn(()=>{t(!1),a(!0)}),children:l?.name??`…`})]})})})}),(0,X.jsx)(z,{children:`Profile`})]}),(0,X.jsxs)(Vn,{className:`w-[28rem] max-w-[calc(100vw-1rem)]`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(d.data??[]).map(e=>{let t=u.data?.filter(t=>t.agent_type===e.id)??[];if(t.length===0)return null;let n=e.available!==!1;return(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsxs)(`span`,{className:`px-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:[e.display_name,!n&&(0,X.jsxs)(`span`,{className:`ml-2 normal-case tracking-normal text-fg-muted`,children:[`not installed — no `,e.binary??e.id,` on PATH`]})]}),t.map(e=>(0,X.jsx)(Br,{account:e,onLogin:()=>_(e),onStartSession:m&&n?()=>v(e):null,installed:n},e.id))]},e.id)}),u.data?.length===0&&(0,X.jsx)(`p`,{className:`px-2 text-sm text-fg-muted`,children:`No accounts yet — add one in settings.`})]}),(0,X.jsxs)(`div`,{className:`mt-4 flex items-center gap-2`,children:[(0,X.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:()=>{t(!1),K(`accounts`)},children:[(0,X.jsx)(On,{}),`Add account`]}),(0,X.jsxs)(U,{variant:`ghost`,size:`sm`,className:`ml-auto`,onClick:()=>{t(!1),Mn.set(null)},children:[(0,X.jsx)(An,{}),`Switch profile`]})]})]})]}),(0,X.jsx)(Sr,{kind:`profile`,colour:l?.icon_colour,onRename:()=>{t(!1),a(!0)},onColour:e=>{o&&c.mutate({id:o,icon_colour:e},{onError:J})},pending:c.isPending||!o})]}),h&&(0,X.jsx)(Ne,{stream:h.stream,label:h.label,onClose:()=>g(null)})]})}var Hr=`desktop-update`;function Ur(){let e=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{let t=P();if(t?.updateReady===void 0||t.onUpdateReady===void 0)return;let n=t=>{e.current!==t&&(e.current=t,R(`Puddle ${t} is downloaded and ready.`,{id:Hr,duration:1/0,closeButton:!0,action:{label:`Restart to update`,onClick:()=>{P()?.installUpdate?.(),R.loading(`Restarting into Puddle ${t}…`,{id:`${Hr}-restarting`,duration:1/0})}}}))};return t.updateReady().then(e=>{e!==null&&n(e)}),t.onUpdateReady(n)},[]),null}var Wr=new He;function Gr({onReview:e}={}){let t=Je(),n=Ve(),r=E(k().data),i=Ue();return Xe(),(0,Y.useEffect)(()=>{if(!(!n||!r||t.isError))for(let n of Wr.take(i,ze(t.data))){let t=n.component===`daemon`?`Daemon`:`Runtime software`,a=`host-update-${i}-${n.component}-${n.version}`;R(`${r}: ${t} ${n.version} is available.`,{id:a,duration:1/0,closeButton:!0,action:{label:`Review update`,onClick:e??(()=>K(`host`))}})}},[t.data,t.isError,r,n,i,e]),null}function Kr({hostKey:e,enabled:t=!0}){let n=u({queryKey:[`host`],queryFn:async({signal:e})=>we.parse(await N(`GET`,`/api/host`,void 0,e)),staleTime:1/0,enabled:t&&!e,retry:!1}),r=e??(n.data?Kn(n.data):void 0),i=M(),a=i?.generation,o=u({queryKey:[`release-notes`,r],queryFn:async({signal:e})=>{let t=xe.parse(await N(`GET`,`/api/release-notes`,void 0,e));if(M()!==i||i?.generation!==a)throw Error(`Release notes connection changed`);return t},enabled:t&&!!r,staleTime:1/0,retry:!1});return(0,Y.useEffect)(()=>{t&&r&&o.data&&!o.isError&&Gn(r,o.data)},[t,r,o.data,o.isError]),null}var qr=(0,Y.lazy)(()=>ut(()=>import(`./ReleaseNotesDialog-sQVKJ6dm.js`).then(e=>({default:e.ReleaseNotesDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])));function Jr({remote:e=!1}){let t=(0,Y.useSyncExternalStore)(Wn.subscribe,Wn.snapshot)[0];return(0,Y.useEffect)(()=>{let t=e?[`cockpit`,`remote`]:[`cockpit`];Wn.enqueue(`browser`,t.map(e=>({component:e,version:`0.4.17`,markdown:`## [0.4.17] — 2026-11-07
3
+
4
+ ### Cockpit
5
+
6
+ #### Added
7
+
8
+ - Compile or run the focused source file with Command+Enter through the existing save-before-run flow.
9
+
10
+ - Add per-file editor settings for tab size, word wrap and searchable syntax language, with inherited defaults and window-local overrides.
11
+
12
+ #### Fixed
13
+
14
+ - Run CI only for release tags and explicit \`ci\` / \`ci/**\` tags, instead of every main-branch push and pull request.
15
+
16
+ - Halve the PDF zoom overlay inset, keeping equal spacing from the top and right edges.
17
+
18
+ - Suspend eager compilation while source-input save conflicts remain unresolved, including across reconnects, and resume after a checked editor resolution.
19
+
20
+ - Keep eager compilation registered across pane moves and background tabs, and restore observation and PDF refresh after idle expiry or daemon replacement.
21
+
22
+ - Move the Ripple handle into the right pane gutter on desktop and mobile without changing the terminal grid or reading width, retaining the mobile touch target.
23
+ - Remove the mobile session sidebar and move project switching, session creation and archived sessions into the title dropdown.
24
+
25
+ - Keep single-tab action trays above file details and reachable from the top-right corner, including narrow LaTeX panes.
26
+
27
+ - Keep the newest covered Ripple output visible at a high boundary by omitting older complete blocks first, preserving pinned prompts, fixed typography and original terminal click anchors. Restore omitted content when the reading area expands.
28
+ - Remove the Ripple divider line and place a vertical handle at the far-right edge, retaining the larger mobile touch target.
29
+
30
+ - Keep Ripple scrolling in the underlying CLI, reserve two terminal rows for breathing room and keep its reading view top-aligned with fixed typography. Restore the full grid for CLI-only viewing; preserve anchored clicks and normal scrollback, and clip excess output without a second vertical scroller or changing styles.
31
+ - Use primary text for non-ignored explorer names, including dotfiles, while retaining muted ignored files and Git status colours.
32
+
33
+ ### Daemon
34
+
35
+ #### Fixed
36
+
37
+ - Preserve file timestamps and skip eager rebuilds for unchanged saves; hold queued builds after stale saves until their input conflicts resolve.
38
+
39
+ - Trigger eager compilation directly after successful saves, retain source watches across incomplete dependency reports, verify missed external source changes each second, and preserve LaTeX dependencies through symlinked roots.
40
+ `})))},[e]),t?(0,X.jsx)(Y.Suspense,{fallback:null,children:(0,X.jsx)(qr,{current:t})}):null}function Yr(){let e=q(),t=A().data?.find(t=>t.id===e),n=de(e??void 0),r=_e(e??void 0,void 0),i=tt(),a=Ye(),s=Ze(),c=ne(e??``),l=se(),u=o(),[d,f]=(0,Y.useReducer)(e=>e+1,0);(0,Y.useEffect)(()=>st(()=>f()),[]);let p=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{p.current=null},[t?.name]);let m=a.data?.available===!0?a.data.file:void 0,h=t!==void 0&&e!==null&&n.data!==void 0&&r.data!==void 0&&m!==void 0,g=t&&m?Be(m,t.name):void 0,_=c.isPending||l.isPending||u.isPending||s.isPending||n.isFetching||r.isFetching;(0,Y.useEffect)(()=>{if(!h||!g?.enabled||_)return;let a={client:i,theme:it(),profileSettings:n.data,profile:t,scratchpad:r.data},o={setClient:e=>nt(e),setTheme:e=>{typeof e==`string`&&ct(e)},patchProfileSettings:e=>c.mutate(e),patchProfileColumns:t=>l.mutate({id:e,...t}),createScratchpad:t=>{for(let n of t)u.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},d=JSON.stringify(g.doc);if(p.current!==d){p.current=d,qe(g.doc,o,a,g.groups);return}let f=$e(g.groups,a),m=JSON.stringify(f);m!==d&&(p.current=m,s.mutate({profile:t.name,entry:{...g,doc:f,updatedAt:new Date().toISOString()}}))})}function Xr(e){let t=t=>{let n=Te.safeParse(t);n.success&&e(n.data)},n=P()?.onNotificationClick?.((e,n)=>t(n)),r=e=>{e.data?.t===`notification-click`&&t(e.data.target)};return navigator.serviceWorker?.addEventListener(`message`,r),()=>{n?.(),navigator.serviceWorker?.removeEventListener(`message`,r)}}var Zr=5e3,Qr=`[data-notification-session]`;function $r(e){let t=null,n=()=>{t=null},r=e=>e.target instanceof Element?e.target.closest(Qr):null,i=e=>{if(!e.isTrusted)return;let n=r(e),i=n?.dataset.notificationSession;t=n&&i?{element:n,session:i,at:performance.now()}:null},a=e=>{r(e)!==t?.element&&n()},o=[`pointerdown`,`keydown`,`input`,`paste`];for(let t of o)e.addEventListener(t,i,!0);return e.addEventListener(`focusin`,a,!0),e.addEventListener(`visibilitychange`,n),e.defaultView?.addEventListener(`blur`,n),{isInteracting(n){return t!==null&&t.session===n&&performance.now()-t.at<Zr&&e.visibilityState===`visible`&&e.hasFocus()&&t.element.isConnected&&t.element.dataset.notificationSession===n&&t.element.getClientRects().length>0},dispose(){n();for(let t of o)e.removeEventListener(t,i,!0);e.removeEventListener(`focusin`,a,!0),e.removeEventListener(`visibilitychange`,n),e.defaultView?.removeEventListener(`blur`,n)}}}var ei=new Set,ti=e=>!!e&&ei.has(e),ni=Ee.parse({});function ri(e){return e.prefs.muted_projects.includes(e.projectId)?{desktop:!1,sound:!1}:{desktop:e.prefs.desktop&&(e.permission===`granted`||e.permission===`unverified`)&&(e.prefs.when_focused||!e.sessionFocused),sound:e.prefs.sound}}function ii(e,t){for(let[,n]of e.getQueriesData({queryKey:[`sessions`]})){let e=n?.find(e=>e.id===t);if(e)return e}for(let[,n]of e.getQueriesData({queryKey:[`project`]})){let e=n?.sessions.find(e=>e.id===t);if(e)return e}}function ai(e){return e.title??e.agent_title??e.osc_title??e.id.slice(0,8)}function oi(){try{let e=new AudioContext,t=e.createGain();t.gain.value=.04,t.connect(e.destination);for(let[n,r]of[[880,0],[1318.5,.09]]){let i=e.createOscillator();i.type=`sine`,i.frequency.value=n,i.connect(t),i.start(e.currentTime+r),i.stop(e.currentTime+r+.12)}setTimeout(()=>void e.close(),400)}catch{}}function si(){let e=It(),t=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{let e=$r(document);return t.current=e,()=>{t.current=null,e.dispose()}},[]),(0,Y.useEffect)(()=>Xr(t=>{t.host||e(`/project/${t.project}/session/${t.session}`,{state:{notificationSession:t.session}})}),[e]),ci(t=>{e(`/project/${t.project_id}/session/${t.id}`,{state:{notificationSession:t.id}})},e=>t.current?.isInteracting(e.id)??!1)}function ci(e,t=()=>document.hasFocus()){let n=ue(),r=(0,Y.useRef)(e);r.current=e;let i=(0,Y.useRef)(t);i.current=t;let a=E(k().data)??`Puddle`,o=(0,Y.useRef)(a);(0,Y.useEffect)(()=>{document.title===o.current&&(document.title=a),o.current=a},[a]),(0,Y.useEffect)(()=>{let e=new Set,t=()=>{document.title=e.size>0?`(${e.size}) ${o.current}`:o.current},a=!0,s=async e=>{let t=ii(n,e.session);if(!t)try{t=(await c(n)).find(t=>t.id===e.session)}catch{return}if(!a||!t)return;let s=t,l,u;try{let e=await n.fetchQuery({queryKey:[`project`,s.project_id],queryFn:()=>N(`GET`,`/api/projects/${s.project_id}`),staleTime:1e4});if(!a)return;u=e.project;let t=u.profile_id,r=await n.fetchQuery({queryKey:[`profile-settings`,t],queryFn:()=>N(`GET`,`/api/profiles/${t}/settings`),staleTime:1e4});l=Ee.catch(ni).parse(r.notifications??{})}catch{return}if(!a)return;let d=ri({prefs:l,projectId:s.project_id,sessionFocused:i.current(s),permission:We()});d.sound&&oi(),d.desktop&&!ti(M()?.scope)&&await Qe({id:e.id?`puddle-event-${e.id}`:`puddle-agent-${s.id}`,title:e.content?.title??ai(s).slice(0,160),body:e.content?.body??(e.reason===`exited`?`Agent finished running`:`Waiting for your input`),target:{project:s.project_id,session:s.id,...M()?.notificationHost?{host:M().notificationHost}:{}}},()=>{a&&r.current(s)},{host:o.current,project:u})},l=I.onAgentNotification(e=>{s(e)}),u=I.onStatus(r=>{let i=e.has(r.session);r.status===`waiting_input`?e.add(r.session):e.delete(r.session),t(),!(r.status!==`waiting_input`||i)&&n.fetchQuery({queryKey:[`version`],queryFn:()=>N(`GET`,`/api/version`),staleTime:1/0}).then(e=>{if(!(e.protocol.major>22||e.protocol.major===22&&e.protocol.minor>=3))return s({session:r.session,reason:`waiting_input`})}).catch(()=>{})});return()=>{a=!1,u(),l(),document.title=o.current}},[n])}function li({initial:e,defaultScope:t,allowProject:n=!0,agents:r,onSave:i,onCancel:a}){let[o,s]=(0,Y.useState)(e?.title??``),[c,l]=(0,Y.useState)(e?.body??``),[u,d]=(0,Y.useState)(n?e?.scope??t:`profile`),[f,p]=(0,Y.useState)((e?.tags??[]).join(`, `)),[m,h]=(0,Y.useState)(e?.agent_type??null),g=()=>{let e=c.trim();e&&i({title:o.trim()||null,body:e,scope:u,tags:f.split(`,`).map(e=>e.trim()).filter(Boolean),agent_type:m})};return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(W,{value:o,placeholder:`Title (optional)`,spellCheck:!1,onChange:e=>s(e.target.value),onKeyDown:e=>e.stopPropagation(),className:`h-9 text-sm font-medium`}),(0,X.jsx)(_n,{autoFocus:!0,value:c,placeholder:`Prompt or note…`,spellCheck:!1,rows:10,onChange:e=>l(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`?a():e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&g()},className:`resize-y text-sm leading-relaxed`}),(0,X.jsx)(W,{value:f,placeholder:`tags, comma, separated`,spellCheck:!1,onChange:e=>p(e.target.value),onKeyDown:e=>e.stopPropagation(),className:`h-8 text-xs`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,X.jsxs)(`label`,{className:`flex items-center gap-1.5 text-2xs text-fg-secondary`,children:[(0,X.jsx)(Sn,{checked:u===`profile`,onCheckedChange:e=>d(e?`profile`:`project`)}),`Profile-wide`]}),(0,X.jsx)(`div`,{className:`ml-auto flex items-center gap-1`,children:r.map(e=>(0,X.jsxs)(`button`,{type:`button`,title:e.display_name,"aria-pressed":m===e.id,onClick:()=>h(t=>t===e.id?null:e.id),className:L(`rounded-md p-1 transition-colors`,m===e.id?`bg-surface text-fg`:`text-fg-gold hover:bg-surface hover:text-fg`),children:[(0,X.jsx)(dn,{type:e.id,className:`size-3.5`}),(0,X.jsx)(`span`,{className:`sr-only`,children:e.display_name})]},e.id))})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[(0,X.jsx)(U,{variant:`ghost`,size:`sm`,onClick:a,children:`Cancel`}),(0,X.jsx)(U,{size:`sm`,disabled:!c.trim(),onClick:g,children:`Save`})]})]})}function ui(){let e=Xt(),t=q(),n=Tt().id,r=_e(t??void 0,n).data??[],a=i().data??[],s=o(),c=ie(),l=me(),u=Jt(),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(null);(0,Y.useEffect)(()=>F(`scratchpad.toggle`,Qt),[]),(0,Y.useEffect)(()=>{e||(f(null),m(null),g(null))},[e]);let x=(0,Y.useMemo)(()=>[...new Set(r.flatMap(e=>e.tags))].sort((e,t)=>e.localeCompare(t)),[r]),S=(0,Y.useMemo)(()=>[...new Set(r.map(e=>e.agent_type).filter(e=>e!==null))],[r]),C=p!==null||h!==null,ee=r.filter(e=>(p===null||e.tags.includes(p))&&(h===null||e.agent_type===h)),te=C?ee:y??r,w=e=>{t&&(s.mutate({profile_id:t,scope:e.scope,project_id:e.scope===`project`?n:void 0,title:e.title??void 0,body:e.body,tags:e.tags,agent_type:e.agent_type??void 0}),f(null))},T=(e,t)=>{c.mutate({id:e,scope:t.scope,project_id:t.scope===`project`?n??null:null,title:t.title,body:t.body,tags:t.tags,agent_type:t.agent_type}),f(null)},E=(e,t)=>{let n=y??r,i=n.findIndex(t=>t.id===e),a=n.findIndex(e=>e.id===t);if(i===-1||a===-1||i===a)return;let o=n.slice(),[s]=o.splice(i,1);o.splice(a,0,s),b(o)},D=()=>{let e=_,t=y;if(v(null),b(null),e===null||!t)return;let n=t.findIndex(t=>t.id===e);if(n===-1)return;let r=t[n-1],i=t[n+1],a=r?i?(r.position+i.position)/2:r.position+1:(i?i.position:0)-1;c.mutate({id:e,position:a})},O=e=>{navigator.clipboard?.writeText(e.body),R.success(`Copied to clipboard`)};return(0,X.jsxs)(Un,{open:e,onOpenChange:Zt,children:[(0,X.jsxs)(V,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsx)(Hn,{asChild:!0,children:(0,X.jsxs)(U,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,children:[(0,X.jsx)(vr,{}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Scratchpad`})]})})}),(0,X.jsx)(z,{children:`Scratchpad`})]}),(0,X.jsxs)(Vn,{className:`w-[34rem] max-w-[calc(100vw-1rem)] p-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-5 pb-2 pt-4`,children:[(0,X.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Scratchpad`}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>f(d===`new`?null:`new`),className:L(Kt,`ml-auto`),children:[(0,X.jsx)(On,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`New entry`})]})]}),(x.length>0||S.length>0)&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-5 pb-2`,children:[x.map(e=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>m(t=>t===e?null:e),className:L(`rounded-full px-2 py-0.5 text-2xs transition-colors`,p===e?`bg-action text-action-ink`:`bg-surface text-fg-secondary hover:text-fg`),children:e},e)),S.map(e=>(0,X.jsx)(`button`,{type:`button`,"aria-pressed":h===e,onClick:()=>g(t=>t===e?null:e),className:L(`rounded-md p-1 transition-colors`,h===e?`bg-action text-action-ink`:`text-fg-gold hover:bg-surface`),children:(0,X.jsx)(dn,{type:e,className:`size-3.5`})},e))]}),(0,X.jsxs)(`div`,{className:`no-scrollbar max-h-[65vh] overflow-y-auto px-2 pb-3`,children:[(0,X.jsx)(Dn,{expanded:d===`new`,children:d===`new`&&(0,X.jsx)(`div`,{className:`px-3 py-2`,children:(0,X.jsx)(li,{defaultScope:n?`project`:`profile`,allowProject:n!==void 0,agents:a,onSave:w,onCancel:()=>f(null)})})}),te.length===0&&d!==`new`&&(0,X.jsx)(`p`,{className:`px-3 py-3 text-sm text-fg-muted`,children:C?`Nothing matches this filter.`:`No entries yet — press + to add a reusable prompt or note.`}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:te.map(e=>(0,X.jsx)(`li`,{draggable:!C&&d===null,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,v(e.id)},onDragOver:t=>{_!==null&&(t.preventDefault(),_!==e.id&&E(_,e.id))},onDragEnd:D,className:L(`transition-opacity`,_===e.id&&`opacity-50`),children:(0,X.jsx)(Dn,{expanded:d===e.id,children:d===e.id?(0,X.jsx)(`div`,{className:`px-3 py-2`,children:(0,X.jsx)(li,{initial:e,defaultScope:e.scope,allowProject:n!==void 0||e.scope===`project`,agents:a,onSave:t=>T(e.id,t),onCancel:()=>f(null)})}):(0,X.jsx)(di,{entry:e,onInsert:u?()=>{u(e.body),Zt(!1)}:null,onCopy:()=>O(e),onEdit:()=>f(e.id),onDelete:()=>l.mutate(e.id)})})},e.id))})]})]})]})}function di({entry:e,onInsert:t,onCopy:n,onEdit:r,onDelete:i}){let[a,o]=(0,Y.useState)(!1);return(0,X.jsxs)(`div`,{onClick:e=>{e.target.closest(`button`)||r()},className:`cursor-pointer rounded-md px-3 py-2.5 transition-colors hover:bg-surface`,children:[e.title&&(0,X.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.title}),(0,X.jsx)(`p`,{className:L(`line-clamp-3 whitespace-pre-wrap text-sm text-fg-secondary`,e.title&&`mt-0.5`),children:e.body}),a?(0,X.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:`Delete this entry? This can’t be undone.`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),i()},className:L(Gt,`text-danger`),children:`Delete`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:Gt,children:`Cancel`})]}):(0,X.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:e.scope===`profile`?`Profile-wide`:`Project`}),e.agent_type&&(0,X.jsx)(dn,{type:e.agent_type,className:`size-3 text-fg-gold`}),e.tags.map(e=>(0,X.jsx)(`span`,{className:`rounded-full bg-surface px-1.5 text-2xs text-fg-secondary`,children:e},e)),(0,X.jsxs)(Nn,{label:`Scratchpad entry actions`,className:`ml-auto`,children:[t&&(0,X.jsx)(fi,{icon:hr,label:`Insert into focused terminal`,onClick:t}),(0,X.jsx)(fi,{icon:wn,label:`Copy`,onClick:n}),(0,X.jsx)(fi,{icon:ke,label:`Edit`,onClick:r}),(0,X.jsx)(fi,{icon:kn,label:`Delete`,onClick:()=>o(!0)})]})]})]})}function fi({icon:e,label:t,onClick:n}){return(0,X.jsxs)(V,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,onClick:n,className:Kt,children:[(0,X.jsx)(e,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,X.jsx)(z,{children:t})]})}var pi=Se.parse({});function mi(e,t){let[n,r]=(0,Y.useState)(null),i=ce(t).data,a=oe(e??void 0,t&&e!==null).data;return(0,Y.useEffect)(()=>{if(!t||e===null){r(null);return}let n=!1,i;try{i=mn(sessionStorage.getItem(fn(e)))}catch{i={kind:`absent`}}if(i.kind===`present`){r(i.snapshot);return}return ve(e).then(e=>{n||r(e?e.ui_state:pi)}).catch(()=>{n||r(pi)}),()=>{n=!0}},[t,e]),(0,Y.useMemo)(()=>{if(!t||e===null||n===null)return null;let o=t=>{if(!i||!a)return!1;let{patch:o,projectBased:s}=on(n,t,{alive:new Set(i.filter(e=>e.status!==`archived`).map(e=>e.id)),sessionProject:new Map(i.map(e=>[e.id,e.project_id])),projectIds:a.map(e=>e.id),currentProject:null}),c={...n,...o};r(c),l(e,c).catch(e=>console.warn(`ui-state save failed: ${e.message}`));try{sessionStorage.setItem(fn(e),JSON.stringify(c))}catch(e){console.warn(`ui-state write failed: ${e.message}`)}return rt().projectBasedLayout!==s&&nt({projectBasedLayout:s}),!0},s=Object.fromEntries(Object.entries(n.project_layouts).map(([e,t])=>[e,{layoutRef:t.layout_ref,signature:B(t.layout_tree)}]));return(n.layout_mode??`profile`)===`project`?{headless:!0,scope:`project`,projectId:``,layoutRef:null,signature:B(null),slices:s,capture:()=>({layout_tree:null,active_session:null}),apply:o}:{scope:`profile`,projectId:``,layoutRef:n.layout_ref,signature:B(n.layout_tree),slices:s,capture:()=>({layout_tree:n.layout_tree,active_session:n.active_session}),apply:o}},[t,e,n,i,a])}var hi=B(null);function gi(){let e=sn(),t=It(),n=q(),r=un(),i=mi(n,e&&r===null),a=r??i,o=te(n??void 0,void 0).data??[],s=oe(n??void 0,e&&n!==null).data??[],c=g(),l=ge(),u=f(),[d,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(null);(0,Y.useEffect)(()=>F(`layouts.toggle`,an),[]),(0,Y.useEffect)(()=>{e||(p(``),h(!1),v(null))},[e]);let y=a?.headless===!0,b=a===null||y?null:o.find(e=>e.id===a.layoutRef)??null,x=a!==null&&!y&&(b===null?a.signature!==hi:B(b.layout_tree)!==a.signature),S=e=>{let t=a?.slices?.[e];if(!t)return!1;let n=t.layoutRef===null?null:o.find(e=>e.id===t.layoutRef)??null;return n?B(n.layout_tree)!==t.signature:t.signature!==hi},C=e=>a===null?!1:e.scope===`profile`?a.scope===`profile`&&x:e.project_id===null?!1:a.scope===`project`?!y&&e.project_id===a.projectId?x:S(e.project_id):x||S(e.project_id),ee=e=>b!==null&&e.id===b.id,w=e=>(e===null?void 0:s.find(t=>t.id===e)?.name)??`Project`,T=a!==null&&!y&&a.scope===`project`?o.filter(e=>e.scope===`profile`||e.project_id===a.projectId):o,E=[...T.some(e=>e.scope===`profile`)?[{key:`profile`,name:`Profile-wide`}]:[],...[...new Set(T.flatMap(e=>e.project_id===null?[]:[e.project_id]))].map(e=>({key:e,name:w(e)})).sort((e,t)=>e.name.localeCompare(t.name))],D=_===null?T:_===`profile`?T.filter(e=>e.scope===`profile`):T.filter(e=>e.project_id===_),O=e=>a!==null&&e.scope===a.scope&&(a.scope===`profile`||e.project_id===a.projectId),k=(e,t,r)=>{!a||!n||c.mutate({profile_id:n,scope:a.scope,project_id:a.scope===`project`?a.projectId:void 0,name:e,...t},{onSuccess:e=>{r&&a.apply(e)},onError:e=>J(e)})},ne=e=>{if(!a)return;let t=O(e)?e:o.find(t=>t.name===e.name&&O(t));if(!t){k(e.name,a.capture(),!0);return}l.mutate({id:t.id,...a.capture()},{onSuccess:e=>a.apply(e),onError:e=>J(e)})},re=(e,t)=>k(t,{layout_tree:e.layout_tree,active_session:e.active_session},!1),ie=e=>{if(a){if(!a.apply(e)){R.error(`Workspace is still loading — try again in a moment`);return}e.project_id!==null&&e.project_id!==a.projectId&&t(`/project/${e.project_id}`),nn(!1)}};return(0,X.jsxs)(Un,{open:e,onOpenChange:nn,children:[(0,X.jsxs)(V,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsx)(Hn,{asChild:!0,children:(0,X.jsxs)(U,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,children:[(0,X.jsx)(gr,{}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Layouts`})]})})}),(0,X.jsx)(z,{children:`Layouts`})]}),(0,X.jsxs)(Vn,{className:`w-[26rem] max-w-[calc(100vw-1rem)] p-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-5 pb-2 pt-4`,children:[(0,X.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Layouts`}),a!==null&&!y&&(0,X.jsxs)(`button`,{type:`button`,onClick:()=>h(e=>!e),className:L(`inline-flex size-[var(--ui-control-height)] shrink-0 cursor-pointer items-center justify-center rounded-[var(--ui-radius)] text-fg transition-colors hover:bg-elevated disabled:pointer-events-none disabled:opacity-50`,`ml-auto`),children:[(0,X.jsx)(On,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Save the current layout as a new layout`})]})]}),(0,X.jsx)(Dn,{expanded:a!==null&&!y&&(b===null||m),children:a===null?(0,X.jsx)(`p`,{className:`px-5 pb-3 text-sm text-fg-muted`,children:`Loading the profile’s layout state…`}):y?(0,X.jsx)(`p`,{className:`px-5 pb-3 text-sm text-fg-muted`,children:`Project-based layout is on — every project keeps its own layout. Open a project to name or save it; loading works from here.`}):(b===null||m)&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 px-5 pb-3`,children:[b===null&&(0,X.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:`Unnamed layout`}),(0,X.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:a.scope===`profile`?`Profile-wide`:`Project`}),(0,X.jsx)(`span`,{className:`ml-auto text-2xs text-interrupted`,children:`Unsaved`})]}),(0,X.jsxs)(`form`,{className:`flex items-center gap-1.5`,onSubmit:e=>{e.preventDefault();let t=d.trim();t&&(k(t,a.capture(),!0),p(``),h(!1))},children:[(0,X.jsx)(W,{autoFocus:m,value:d,placeholder:b===null?`Name this layout…`:`Save as a new layout…`,spellCheck:!1,onChange:e=>p(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&h(!1)},className:`h-8 flex-1 text-sm`}),(0,X.jsx)(U,{size:`sm`,type:`submit`,disabled:!d.trim(),children:`Save`}),b!==null&&(0,X.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>h(!1),children:`Cancel`})]})]})}),E.length>1&&(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 px-5 pb-2`,children:E.map(e=>(0,X.jsx)(yi,{active:_===e.key,onClick:()=>v(t=>t===e.key?null:e.key),children:e.name},e.key))}),(0,X.jsxs)(`div`,{className:`no-scrollbar max-h-[60vh] overflow-y-auto px-2 pb-3`,children:[D.length===0&&(0,X.jsx)(`p`,{className:`px-3 py-3 text-sm text-fg-muted`,children:_===null?`No layouts yet — name and save the current layout to keep it.`:`Nothing matches this filter.`}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:D.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(_i,{layout:e,projectLabel:e.scope===`profile`?null:w(e.project_id),isCurrent:ee(e),dirty:x,loadable:a!==null,savable:a!==null&&!y,confirmBeforeLoad:C(e),overwrites:O(e),onLoad:()=>ie(e),onRename:t=>l.mutate({id:e.id,name:t}),onDelete:()=>u.mutate(e.id),onSaveAs:()=>ne(e),onDuplicate:t=>re(e,t)})},e.id))})]})]})]})}function _i({layout:e,projectLabel:t,isCurrent:n,dirty:r,loadable:i,savable:a,confirmBeforeLoad:o,overwrites:s,onLoad:c,onRename:l,onDelete:u,onSaveAs:d,onDuplicate:f}){let[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(e.name),y=()=>{if(!(!i||h!==null)){if(o&&p!==`load`){m(`load`);return}m(null),c()}},b=t=>{m(null),v(t===`rename`?e.name:`${e.name} copy`),g(t)},x=()=>{if(n){d();return}m(`save`)},S=n?r?`unsaved`:`active`:null;return(0,X.jsxs)(`div`,{onClick:e=>{e.target.closest(`button, input`)||y()},className:L(`rounded-md px-3 py-2.5 transition-colors`,i&&`cursor-pointer hover:bg-surface`),children:[h===null?(0,X.jsxs)(`p`,{className:L(`flex items-baseline gap-2 text-sm font-medium`,S===`active`?`text-success`:S===`unsaved`?`text-interrupted`:`text-fg`),children:[e.name,S!==null&&(0,X.jsx)(`span`,{className:`text-2xs font-normal`,children:S===`active`?`Active`:`Unsaved`})]}):(0,X.jsxs)(`form`,{className:`flex items-center gap-1.5`,onSubmit:t=>{t.preventDefault();let n=_.trim();n&&(h===`rename`?n!==e.name&&l(n):f(n)),g(null)},children:[(0,X.jsx)(W,{autoFocus:!0,value:_,spellCheck:!1,onChange:e=>v(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&g(null)},className:`h-7 flex-1 text-sm`}),(0,X.jsx)(U,{size:`sm`,type:`submit`,disabled:!_.trim(),children:h===`rename`?`Rename`:`Save`})]}),p===`save`?(0,X.jsx)(vi,{question:s?`Overwrite “${e.name}” with the current layout?`:`Save the current layout as “${e.name}” here?`,verb:s?`Overwrite`:`Save`,onConfirm:()=>{m(null),d()},onCancel:()=>m(null)}):p===`delete`?(0,X.jsx)(vi,{question:`Delete this layout? This can’t be undone.`,verb:`Delete`,onConfirm:()=>{m(null),u()},onCancel:()=>m(null)}):p===`load`?(0,X.jsx)(vi,{question:`Loading discards unsaved layout changes.`,verb:`Load`,onConfirm:y,onCancel:()=>m(null)}):(0,X.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:[t!==null&&(0,X.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:t}),(0,X.jsxs)(Nn,{label:`Layout actions`,className:`ml-auto`,children:[a&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(bi,{icon:yr,label:n?`Save`:`Save the current layout as “${e.name}”`,onClick:x}),(0,X.jsx)(bi,{icon:wn,label:`Duplicate`,onClick:()=>b(`duplicate`)})]}),(0,X.jsx)(bi,{icon:ke,label:`Rename`,onClick:()=>b(`rename`)}),(0,X.jsx)(bi,{icon:kn,label:`Delete`,onClick:()=>m(`delete`)})]})]})]})}function vi({question:e,verb:t,onConfirm:n,onCancel:r}){return(0,X.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e}),(0,X.jsx)(`button`,{type:`button`,onClick:n,className:L(Gt,`text-danger`),children:t}),(0,X.jsx)(`button`,{type:`button`,onClick:r,className:Gt,children:`Cancel`})]})}function yi({active:e,onClick:t,children:n}){return(0,X.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:t,className:L(`rounded-full px-2 py-0.5 text-2xs transition-colors`,e?`bg-action text-action-ink`:`bg-surface text-fg-secondary hover:text-fg`),children:n})}function bi({icon:e,label:t,onClick:n}){return(0,X.jsxs)(V,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,onClick:n,className:Kt,children:[(0,X.jsx)(e,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,X.jsx)(z,{children:t})]})}var $=P()!==void 0&&/Mac/.test(navigator.platform),xi=(0,Y.lazy)(()=>ut(()=>import(`./SettingsDialog-DKnJSEij.js`).then(e=>({default:e.SettingsDialog})),__vite__mapDeps([16,1,2,17,18,19,3,20,21,22,7,5,6,8,9,10,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49])));function Si(){let e=ue();(0,Y.useEffect)(()=>{let t=t=>{for(let[n,r]of e.getQueriesData({queryKey:[`sessions`]}))r&&e.setQueryData(n,r.map(t));for(let[n,r]of e.getQueriesData({queryKey:[`project`]}))r&&e.setQueryData(n,{...r,sessions:r.sessions.map(t)})},n=I.onStatus(e=>t(t=>t.id===e.session?{...t,status:e.status,last_activity_at:e.last_activity_at}:t)),r=I.onRenamed(e=>t(t=>t.id===e.session?{...t,title:e.title,agent_title:`agent_title`in e?e.agent_title:t.agent_title,osc_title:`osc_title`in e?e.osc_title:t.osc_title}:t)),i=I.onAccount(t=>{for(let[n,r]of e.getQueriesData({queryKey:[`accounts`]}))r&&e.setQueryData(n,r.map(e=>e.id===t.account_id?{...e,logged_in:t.logged_in}:e))}),a=t=>{e.invalidateQueries({queryKey:[`sessions`]});for(let n of t)e.invalidateQueries({queryKey:[`project`,n]})},o=I.onSessionsChanged(e=>a(e.project_ids)),s=I.onSessionSwitched(e=>a([e.target_project]));return()=>{n(),r(),i(),o(),s()}},[e])}function Ci(){let e=q(),t=ne(e??``),n=m().data?.protocol,r=Pe(),i=k(),a=fe(),[o,s]=(0,Y.useState)(!1),c=E(i.data),l=e=>{s(!1);let t=e.trim();t!==c&&a.mutate({displayName:t===i.data?.hostname?``:t},{onError:e=>J(e)})},u=(0,X.jsx)(Fe,{icon:r.icon}),d=L(`host-identity flex h-full shrink-0 items-center gap-2 px-4`,$&&`[-webkit-app-region:no-drag]`),f=`truncate font-sans text-xs font-normal`;return o&&c!==void 0?(0,X.jsxs)(`div`,{className:d,children:[u,(0,X.jsx)(hn,{initial:i.data?.displayName??c,maxLength:64,className:L(f,`w-40`),onCommit:l,onCancel:()=>s(!1)})]}):(0,X.jsxs)(Et,{children:[(0,X.jsx)(kt,{asChild:!0,children:(0,X.jsxs)(Rt,{to:`/`,className:L(d,`hover:bg-elevated focus-visible:bg-elevated`),title:`All projects`,children:[u,c!==void 0&&(0,X.jsx)(`span`,{className:f,...cn(()=>s(!0)),children:c})]})}),(0,X.jsx)(Sr,{kind:`host`,colour:r.colour,onRename:()=>s(!0),onColour:n=>{e&&t.mutate({hostColour:n},{onError:J})},pending:t.isPending||!e,custom:pe(n),onUpdates:()=>K(`host`)})]})}function wi(){let e=Tt(),t=mt(`palette.toggle`),n=ae(e.id).data?.project,r=n!==void 0&&n.id===e.id?n.name:void 0;return(0,X.jsx)(`button`,{type:`button`,onClick:qt,className:L(`flex h-full min-w-0 w-full cursor-pointer items-center justify-center gap-2 bg-transparent px-2 font-normal text-fg-muted transition-colors hover:bg-elevated focus-visible:bg-elevated`,$&&`[-webkit-app-region:no-drag]`),children:(0,X.jsxs)(`span`,{className:L(`pointer-events-none absolute left-1/2 top-1/2 flex max-w-[40%] -translate-x-1/2 -translate-y-1/2 items-center gap-2`,r&&j(n?.colour)),style:r?je(n?.colour):void 0,children:[(0,X.jsx)(`span`,{className:`truncate text-xs`,children:r??`Puddle`}),(0,X.jsx)(`span`,{className:`shrink-0 text-2xs`,children:t})]})})}function Ti(){let e=Pe(),{fullScreen:t,animate:n}=xt(),r=$&&!t;return(0,X.jsxs)(`header`,{"data-host-colour":e.colour??void 0,onClick:e=>{let t=e.target;e.currentTarget.contains(t)&&(t.closest(`[data-header-section], [aria-label="Workspace controls"], button, a, input`)||qt())},className:L(`host-header island-outline relative grid shrink-0 cursor-pointer grid-cols-[auto_1px_minmax(0,1fr)_1px_auto] items-center overflow-hidden rounded-[var(--ui-surface-radius)] bg-surface`,`h-9`,!$&&`mx-1.5 mt-1.5`,r&&`pl-[84px] [-webkit-app-region:drag]`,n&&`transition-[padding] duration-200 ease-out`),children:[r&&(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-[84px] top-1/2 h-5 w-px -translate-y-1/2 bg-border`}),(0,X.jsx)(`div`,{"data-header-section":!0,className:`flex h-full min-w-0 cursor-default items-center overflow-hidden`,children:(0,X.jsx)(Ci,{})}),(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`h-5 w-px bg-border`}),(0,X.jsx)(wi,{}),(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`h-5 w-px bg-border`}),(0,X.jsxs)(Nn,{label:`Workspace controls`,className:L(`shell-header-actions h-full justify-self-end rounded-none!`,$&&`[-webkit-app-region:no-drag]`),children:[(0,X.jsxs)(V,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsxs)(U,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,onClick:()=>K(),children:[(0,X.jsx)(br,{}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Settings`})]})}),(0,X.jsx)(z,{children:`Settings`})]}),(0,X.jsx)(gi,{}),(0,X.jsx)(ui,{}),(0,X.jsx)(Vr,{})]})]})}function Ei(){Si(),Yr(),si();let{handler:e}=en(),t=q(),{pathname:n}=Ct(),[r,i]=(0,Y.useState)(!1),a=m(),o=a.data!==void 0&&re(a.data.protocol);return(0,Y.useEffect)(()=>{if(!o)return;let e=()=>{let e=at();I.reportTheme(e(`--text-primary`),e(`--bg-base`))};return e(),st(e)},[o]),(0,X.jsxs)(`div`,{className:`flex h-screen flex-col overflow-hidden overscroll-y-none bg-ground`,children:[(0,X.jsx)(Re,{}),(0,X.jsx)(et,{}),(0,X.jsx)(Cr,{}),(0,X.jsx)(Ti,{}),(0,X.jsx)(`main`,{className:`min-h-0 flex-1`,children:(0,X.jsx)(Qn,{resetOn:n,scope:n.startsWith(`/project/`)?`workspace`:`view`,children:(0,X.jsx)(At,{className:`h-full`,motionKey:n.startsWith(`/project/`)?`workspace`:n,children:(0,X.jsx)(Dt,{})})})}),(0,X.jsx)(wr,{}),(0,X.jsx)(Ir,{}),(0,X.jsx)(Ur,{}),(0,X.jsx)(Gr,{}),(0,X.jsx)(Kr,{}),(0,X.jsx)(Jr,{}),(0,X.jsx)(jr,{onNewSession:e??void 0,onNewProject:()=>i(!0)}),t!==null&&(0,X.jsx)(Tn,{profileId:t,open:r,onOpenChange:i}),(0,X.jsx)(Y.Suspense,{fallback:null,children:(0,X.jsx)(xi,{})}),(0,X.jsx)(Pr,{})]})}function Di(){return(0,X.jsx)(Yt,{children:(0,X.jsx)(Ei,{})})}var Oi=(0,Y.lazy)(()=>ut(()=>import(`./Dashboard-B_m3VKHu.js`).then(e=>({default:e.Dashboard})),__vite__mapDeps([50,1,2,17,18,19,3,20,21,22,7,5,6,8,9,10,23,24,27,28,51,52,33,53,36,54,55,45,31,44]))),ki=(0,Y.lazy)(()=>ut(()=>import(`./Workspace-DUBYqpNS.js`).then(e=>({default:e.Workspace})),__vite__mapDeps([56,1,2,6,17,18,19,3,20,21,22,7,5,8,9,10,23,24,33,34,26,35,27,28,57,58,53,51,52,59,30,29,31,60,61,36,54,62,37,38,63,64,40,65,42,43,44,66,67,68,69,48,70,71]))),Ai=new Zn({defaultOptions:{queries:{retry:1,staleTime:5e3}},mutationCache:new Jn({onError:e=>J(e)})});function ji(){let e=q(),t=A(),n=e!==null&&t.data!==void 0&&!t.data.some(t=>t.id===e),r=e===null||n;return(0,X.jsx)(At,{className:`h-screen`,motionKey:r?`profiles`:`cockpit`,children:r?(0,X.jsx)(xr,{}):(0,X.jsx)(Ft,{useTransitions:!1,children:(0,X.jsx)(Y.Suspense,{fallback:null,children:(0,X.jsx)(wt,{children:(0,X.jsxs)(Lt,{element:(0,X.jsx)(Di,{}),children:[(0,X.jsx)(Lt,{path:`/`,element:(0,X.jsx)(Oi,{})}),(0,X.jsx)(Lt,{path:`/project/:id`,element:(0,X.jsx)(ki,{})}),(0,X.jsx)(Lt,{path:`/project/:id/session/:sid`,element:(0,X.jsx)(ki,{})})]})})})})})}function Mi(){let e=(0,Y.useSyncExternalStore)(De.subscribe,De.get);return(0,X.jsx)(ee,{client:Ai,children:(0,X.jsxs)(ln,{delayDuration:300,children:[(0,X.jsx)(mr,{}),(0,X.jsx)(Qn,{scope:`app`,children:e?window.location.pathname.startsWith(`/forward/`)?(0,X.jsx)(qn,{}):(0,X.jsx)(ji,{}):(0,X.jsx)(er,{})}),(0,X.jsx)($n,{})]})})}export{Mi as App};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{Et as n,Tt as r,wt as i}from"./protocol-support-sBpa8MZK.js";import{t as a}from"./jsx-runtime-By8HlURe.js";import{n as o}from"./api-BwP0jv_V.js";import{t as s}from"./button-D-qeQvl5.js";var c={agent:{baseBranch:``,separateBranch:!1,separateWorktree:!1},terminal:{baseBranch:``,separateBranch:!1,separateWorktree:!1}};function l(e,t){let n=t?.sessionDefaults?.[e],r=c[e],i=n?.separateBranch??r.separateBranch;return{baseBranch:n?.baseBranch??r.baseBranch,separateBranch:i,separateWorktree:i?!0:n?.separateWorktree??r.separateWorktree}}var u=i(750);function d(e){return n({queryKey:[`compilation-capabilities`],queryFn:()=>o(`GET`,`/api/compilation/capabilities`),enabled:e,staleTime:3e4,refetchOnWindowFocus:!0})}function f(){return r({mutationFn:e=>o(`POST`,`/api/compilation/run`,e)})}function p(e){return o(`PUT`,`/api/compilation/mode`,e)}function m(e){return o(`POST`,`/api/compilation/status`,e)}function h(e,t){return n({queryKey:[`compilation-status`,e],queryFn:()=>m(e),enabled:t,refetchInterval:()=>typeof document<`u`&&document.visibilityState===`hidden`?6e4:u(),refetchIntervalInBackground:!0,retry:2})}function g(e){return n({queryKey:[`compilation-settings`,e],queryFn:()=>o(`POST`,`/api/compilation/settings`,e),enabled:e!==null,staleTime:3e4})}function _(e){return o(`PUT`,`/api/compilation/settings`,e)}function v(e){return n({queryKey:[`compilation-defaults`,e],queryFn:()=>o(`POST`,`/api/compilation/defaults`,e),enabled:e!==null,staleTime:3e4})}function y(e){return o(`PUT`,`/api/compilation/defaults`,e)}var b=e(t(),1);function x(e){return e.inherited_command??e.default_command}function S(e){return e.override_command??x(e)??``}function C(e,t){let n=t.trim();return n===``||n===x(e)?null:n}var w=a();function T({settings:e,onSave:t,onCancel:n}){let[r,i]=(0,b.useState)({}),[a,o]=(0,b.useState)(!1),[c,l]=(0,b.useState)(null),u=e.commands.flatMap(e=>{let t=r[e.mode];if(t===void 0)return[];let n=C(e,t);return n===e.override_command?[]:[{mode:e.mode,command:n}]}),d=async()=>{let n=e.commands.find(e=>(r[e.mode]??S(e)).trim()===``&&x(e)!==null);if(n){l(`${E(n.mode)} needs a command or its default.`);return}o(!0),l(null);try{await t(u),i({})}catch(e){l(e instanceof Error?e.message:`Couldn’t save compilation settings`)}finally{o(!1)}};return(0,w.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),a||d()},children:[e.commands.map(e=>{let t=r[e.mode]??S(e),n=x(e),o=t===(n??``);return(0,w.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,w.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,w.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:E(e.mode)}),(0,w.jsx)(`span`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.mode===`on_demand`?`Runs when you click the play icon.`:`Runs when eager mode starts, then after the file or a discovered dependency changes on disk.`}),(0,w.jsx)(`textarea`,{rows:3,spellCheck:!1,disabled:a,value:t,onChange:t=>i(n=>({...n,[e.mode]:t.target.value})),className:`resize-y rounded-md bg-surface px-2.5 py-2 font-mono text-xs leading-relaxed text-fg outline-none transition-colors hover:bg-ground focus:bg-ground disabled:opacity-50`,"aria-label":`${E(e.mode)} command`})]}),(0,w.jsxs)(`div`,{className:`flex min-h-6 items-center justify-between gap-3 text-xs text-fg-muted`,children:[(0,w.jsx)(`span`,{children:o?e.inherited_command?`Using the language default`:n?`Using the provider default`:`No provider default available on this host`:`Custom command`}),(!o||e.override_command!==null)&&(0,w.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>i(t=>({...t,[e.mode]:n??``})),className:`cursor-pointer rounded-sm px-1.5 py-0.5 text-fg-secondary transition-colors hover:bg-surface hover:text-fg disabled:cursor-default disabled:opacity-50`,children:`Use default`})]})]},e.mode)}),e.variables.length>0&&(0,w.jsxs)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:[`Available values:`,` `,e.variables.map((e,t)=>(0,w.jsxs)(`span`,{title:e.description,children:[t>0&&` · `,(0,w.jsx)(`code`,{className:`font-mono text-fg-secondary`,children:e.placeholder})]},e.placeholder))]}),c&&(0,w.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:c}),(0,w.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[n&&(0,w.jsx)(s,{type:`button`,variant:`ghost`,disabled:a,onClick:n,children:`Cancel`}),(0,w.jsx)(s,{type:`submit`,disabled:a||!n&&Object.keys(r).length===0,children:a?`Saving…`:`Save`})]})]})}function E(e){return e===`on_demand`?`When clicked`:`Upon file change`}export{d as a,h as c,_ as i,f as l,p as n,v as o,y as r,g as s,T as t,l as u};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{H as n,St as r,_t as i,at as a,ft as o,lt as s,ot as c,s as l,y as u}from"./protocol-support-sBpa8MZK.js";import{_ as d}from"./auth-DYEjEl0U.js";import{a as f,c as p,f as m,i as h,l as g,o as _,p as v,t as y,u as b}from"./LazyTerminal-SbouF2Y_.js";import{t as x}from"./jsx-runtime-By8HlURe.js";import{g as S,t as C}from"./ws-DkbvXbTZ.js";import{a as w,f as T,i as E,m as D,o as O,r as k,s as A,y as j}from"./session-order-DilOGTOO.js";import{t as M}from"./utils-B6KiDbIe.js";import{a as N,o as ee,r as P,s as F,t as I}from"./dialog-CTN-Lln6.js";import{t as L}from"./button-D-qeQvl5.js";import{n as R,t as z}from"./chevron-right-DUkOv15w.js";import{n as B,t as V}from"./archive-BYp06n6i.js";import{n as H,r as U,t as W}from"./expanding-content-UT_6Fp5v.js";import{r as G}from"./profile-store-B54YLXa8.js";import{n as K}from"./errors-CD96hLph.js";var q=e(t(),1),J=x(),Y=!1;function X(){let[e,t]=(0,q.useState)(Y),[n,r]=(0,q.useState)(null);(0,q.useEffect)(()=>{if(!e)return;let t=!1;return C.spawnShell(d).then(e=>{t||r(e)}),()=>{t=!0}},[e]);let i=()=>{Y=!1,t(!1),r(null)};return{open:e,term:n,toggle:()=>{e?(n&&C.killShell(d,n),i()):(Y=!0,t(!0))},onExit:i}}function te({term:e,onExit:t}){return(0,J.jsx)(`div`,{className:`h-72 shrink-0 pb-6`,children:(0,J.jsx)(`div`,{className:`mx-auto size-full max-w-4xl px-6`,children:(0,J.jsx)(`div`,{className:`workspace-surface island-outline size-full bg-surface p-1`,children:(0,J.jsx)(`div`,{className:`size-full overflow-hidden rounded-[var(--ui-radius)] bg-ground p-1`,children:e!==null&&(0,J.jsx)(y,{stream:`home`,term:e,onExit:t})})})})})}var ne=`group block w-full island-outline rounded-[var(--ui-surface-radius)] bg-surface p-4 text-left transition-colors hover:bg-elevated`,re=[{status:`running`,colour:`bg-running`},{status:`waiting_input`,colour:`bg-waiting`},{status:`interrupted`,colour:`bg-interrupted`}];function ie({project:e,repoPath:t,sessions:n}){let r=n.filter(e=>e.status!==`archived`);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`h2`,{style:_(e.colour),className:M(`truncate pr-16 text-base font-semibold`,f(e.colour)||`text-fg group-hover:text-accent`),children:e.name}),(0,J.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:t??`…`}),(0,J.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3 text-2xs text-fg-muted tabular-nums`,children:[(0,J.jsxs)(`span`,{children:[r.length,` session`,r.length===1?``:`s`]}),re.map(({status:e,colour:t})=>{let n=r.filter(t=>t.status===e).length;return n>0?(0,J.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(`span`,{className:`size-1.5 rounded-full ${t}`}),n,` `,e.replace(`_`,` `)]},e):null})]})]})}function Z({icon:e,label:t,onClick:n}){return(0,J.jsx)(`button`,{type:`button`,"aria-label":t,title:t,onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},className:`flex items-center rounded-md p-1.5 text-fg-muted transition-colors hover:bg-ground hover:text-fg`,children:(0,J.jsx)(e,{className:`size-4`})})}function Q({project:e,repoPath:t,draggable:i,dragging:a,onDragStart:o,onDragEnd:s,onDragOver:d}){let g=c(),y=n().data?.protocol,x=u(y),S=r(e.id),[C,E]=(0,q.useState)(!1),[D,k]=(0,q.useState)(e.name),[z,H]=(0,q.useState)(v(e)),[U,W]=(0,q.useState)(e.colour??null),G=t=>g.mutate({id:e.id,archived:t},{onError:e=>K(e)}),Y=()=>{k(e.name),W(e.colour??null),H(v(e)),E(!0)},X=()=>{let t=D.trim(),n=m(z);if(!t){E(!1);return}let r={...t===e.name?{}:{name:t},...n&&n!==v(e)?{abbrev:n}:{},...x&&U!==(e.colour??null)?{colour:U}:{}};if(Object.keys(r).length===0){E(!1);return}g.mutate({id:e.id,...r},{onSuccess:()=>E(!1),onError:e=>K(e)})};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(w,{children:[(0,J.jsx)(T,{asChild:!0,children:(0,J.jsxs)(`div`,{draggable:i,onDragStart:o,onDragEnd:s,onDragOver:d,className:M(`group relative transition-opacity`,a&&`opacity-50`),children:[(0,J.jsx)(j,{draggable:!1,to:`/project/${e.id}`,className:ne,children:(0,J.jsx)(ie,{project:e,repoPath:t,sessions:S.data??[]})}),(0,J.jsx)(`div`,{className:`absolute right-2 top-2 hidden gap-0.5 group-hover:flex has-[[data-state=open]]:flex pointer-coarse:flex`,children:e.archived?(0,J.jsx)(Z,{icon:B,label:`Reopen project`,onClick:()=>G(!1)}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{icon:p,label:`Edit project`,onClick:Y}),(0,J.jsx)(Z,{icon:V,label:`Archive project`,onClick:()=>G(!0)})]})})]})}),(0,J.jsx)(O,{children:e.archived?(0,J.jsxs)(A,{onSelect:()=>G(!1),children:[(0,J.jsx)(B,{}),` Reopen`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(A,{onSelect:Y,children:[(0,J.jsx)(p,{}),` Edit`]}),(0,J.jsxs)(A,{onSelect:()=>G(!0),children:[(0,J.jsx)(V,{}),` Archive`]})]})})]}),(0,J.jsx)(I,{open:C,onOpenChange:E,children:(0,J.jsxs)(P,{children:[(0,J.jsx)(ee,{children:(0,J.jsx)(F,{children:`Edit project`})}),(0,J.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),X()},children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(b,{htmlFor:`project-name-${e.id}`,children:`Name`}),(0,J.jsx)(R,{id:`project-name-${e.id}`,value:D,className:f(U),style:_(U),onChange:e=>k(e.target.value),autoFocus:!0})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(b,{htmlFor:`project-abbrev-${e.id}`,children:`Abbreviation`}),(0,J.jsx)(R,{id:`project-abbrev-${e.id}`,maxLength:5,value:z,onChange:e=>H(m(e.target.value)),className:`w-24 uppercase`}),(0,J.jsxs)(`p`,{className:`text-2xs text-fg-muted`,children:[`Up to `,5,` characters — the label on the collapsed sidebar rail.`]})]}),x&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,J.jsx)(`span`,{className:`text-xs text-fg-secondary`,children:`Colour`}),(0,J.jsx)(h,{value:U,onChange:W,onCustomChange:l(y)?W:void 0,label:`Project colour`})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(b,{className:`text-fg-muted`,children:`Path`}),(0,J.jsx)(`p`,{className:`truncate text-2xs text-fg-muted`,children:t??`…`})]}),(0,J.jsxs)(N,{children:[(0,J.jsx)(L,{type:`button`,variant:`ghost`,onClick:()=>E(!1),children:`Cancel`}),(0,J.jsx)(L,{type:`submit`,disabled:!D.trim()||g.isPending,children:`Save`})]})]})]})})]})}function $({icon:e,label:t,hint:n,onClick:r}){return(0,J.jsxs)(`button`,{type:`button`,onClick:r,className:`group flex flex-col island-outline rounded-[var(--ui-surface-radius)] bg-surface p-4 text-left transition-colors hover:bg-elevated`,children:[(0,J.jsxs)(`h2`,{className:`flex items-center gap-2 truncate text-base font-semibold text-fg group-hover:text-accent`,children:[(0,J.jsx)(e,{className:`size-4 shrink-0`}),t]}),(0,J.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:n})]})}function ae(){let e=G(),t=o(e??void 0),n=i(),r=s(e??void 0),c=a(e??``),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(null),[p,m]=(0,q.useState)(!1),h=X(),_=S(`palette.toggle`),v=e=>n.data?.find(t=>t.id===e)?.path,y=t.data??[],b=r.data?.projectOrder??[],x=k(y.filter(e=>!e.archived),b),C=y.filter(e=>e.archived),w=(e,t)=>{e!==t&&c.mutate({projectOrder:E(x.map(e=>e.id),e,t)})};return(0,J.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,J.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[y.length===0&&(0,J.jsxs)(`div`,{className:`mb-8 mt-16 flex flex-col items-center gap-3 text-center`,children:[(0,J.jsx)(g,{className:`size-8 text-fg-muted`}),(0,J.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[`No projects yet — open one below, or press `,_,`.`]})]}),(0,J.jsxs)(`div`,{className:`grid auto-rows-fr grid-cols-1 gap-3 sm:grid-cols-2`,children:[x.map(e=>(0,J.jsx)(Q,{project:e,repoPath:v(e.repo_id),draggable:!0,dragging:d===e.id,onDragStart:()=>f(e.id),onDragEnd:()=>f(null),onDragOver:t=>{t.preventDefault(),d&&d!==e.id&&w(d,e.id)}},e.id)),(0,J.jsx)($,{icon:U,label:`Open project`,hint:`Point at a repository on this host`,onClick:()=>u(!0)}),(0,J.jsx)($,{icon:D,label:h.open?`Close terminal`:`Open terminal`,hint:h.open?`End the shell below`:`A shell at ~ for cloning repositories`,onClick:h.toggle})]}),C.length>0&&(0,J.jsxs)(`div`,{className:`mt-6`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>m(e=>!e),className:`flex items-center gap-1.5 px-1 py-1.5 text-2xs uppercase tracking-wide text-fg-muted transition-colors hover:text-fg`,children:[(0,J.jsx)(z,{className:M(`size-3 transition-transform`,p&&`rotate-90`)}),(0,J.jsx)(V,{className:`size-3`}),(0,J.jsx)(`span`,{children:`Archived`}),(0,J.jsx)(`span`,{className:`tabular-nums`,children:C.length})]}),p&&(0,J.jsx)(`div`,{className:`mt-2 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:C.map(e=>(0,J.jsx)(Q,{project:e,repoPath:v(e.repo_id),draggable:!1,dragging:!1,onDragStart:()=>{},onDragEnd:()=>{},onDragOver:()=>{}},e.id))})]})]})}),(0,J.jsx)(W,{expanded:h.open,children:h.open&&(0,J.jsx)(te,{term:h.term,onExit:h.onExit})}),e!==null&&(0,J.jsx)(H,{profileId:e,open:l,onOpenChange:u})]})}export{ae as Dashboard};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-By8HlURe.js";import{a as r,i,o as a,r as o,s,t as c}from"./dialog-CTN-Lln6.js";import{t as l}from"./x-CbfJFzGo.js";import{t as u}from"./button-D-qeQvl5.js";import{t as d}from"./createLucideIcon-DyMAgLa3.js";import{t as f}from"./drafts-B_tChlzR.js";import{i as p,t as m,u as h}from"./buffer-store-fV6iYuCU.js";import{t as g}from"./editor-sync-W1bamxAP.js";var _=d(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),v=e(t(),1),y=n();function b(e,t,n){let r=m(e,t,n);return(0,v.useSyncExternalStore)((0,v.useCallback)(e=>h(r,e),[r]),()=>p(r))}function x({session:e,path:t,kind:n,root:r}){return b(e,t,r)&&n!==`commit`?(0,y.jsx)(_,{"aria-hidden":!0,className:`size-2 shrink-0 fill-current text-fg-muted group-hover:invisible group-focus-visible:invisible group-has-[:focus-visible]:invisible`}):null}function S({session:e,path:t,kind:n,root:d,label:p,onClose:m}){let h=b(e,t,d)&&n!==`commit`,[_,x]=(0,v.useState)(!1),S=()=>h?x(!0):m();return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`button`,{onClick:e=>{e.stopPropagation(),S()},className:`flex size-4 items-center justify-center rounded-sm text-fg-muted transition-colors hover:text-fg`,"aria-label":`Close ${p}`,children:(0,y.jsx)(l,{className:`size-3`})}),(0,y.jsx)(c,{open:_,onOpenChange:e=>!e&&x(!1),children:(0,y.jsxs)(o,{children:[(0,y.jsxs)(a,{children:[(0,y.jsxs)(s,{children:[`Discard changes to `,p,`?`]}),(0,y.jsx)(i,{children:`This file has unsaved changes. Closing the tab will discard them.`})]}),(0,y.jsxs)(r,{children:[(0,y.jsx)(u,{variant:`ghost`,onClick:()=>x(!1),children:`Keep editing`}),(0,y.jsx)(u,{variant:`danger`,onClick:()=>{f(e,t,d),g(e,t,d),x(!1),m()},children:`Discard`})]})]})})]})}export{x as EditorDirtyDot,S as EditorTabClose};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{i as n}from"./client-settings-BdKglwtW.js";import{t as r}from"./jsx-runtime-By8HlURe.js";import{a as i,i as a,n as o,o as s,r as c,t as l}from"./select-CCBPniW9.js";import{t as u}from"./chevron-down--sjpQEHH.js";import{t as d}from"./settings-2-CInoy48z.js";import{a as f,o as p,r as m,s as h,t as g}from"./command-BeX8pm7h.js";import{n as _,r as v,t as y}from"./popover-Okyclsx8.js";import{n as b,t as x}from"./languages-MEV5hj_8.js";import{i as S,r as C}from"./file-editor-settings-CzybzK8S.js";var w=e(t(),1),T=r();function E({tab:e,onOpenChange:t}){let{key:r,overrides:E}=C(e),D=n(),[O,k]=(0,w.useState)(!1),A=x(),j=b(e.path),M=e=>A.find(t=>t.id===e)?.label??e,N=E.language?M(E.language):`Automatic (${M(j)})`;return(0,T.jsxs)(y,{onOpenChange:t,children:[(0,T.jsx)(v,{asChild:!0,children:(0,T.jsx)(`button`,{type:`button`,"aria-label":`Editor settings`,title:`Editor settings`,onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:`inline-flex cursor-pointer p-0.5 text-fg-muted transition-colors hover:text-fg`,children:(0,T.jsx)(d,{className:`size-3`})})}),(0,T.jsxs)(_,{"aria-label":`Editor settings for this file`,className:`w-72 space-y-3 p-3 text-xs`,onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`p`,{className:`font-medium`,children:`Editor settings`}),(0,T.jsx)(`p`,{className:`mt-1 truncate text-fg-muted`,title:e.path,children:e.path.split(`/`).pop()})]}),(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(`p`,{children:`Tab size`}),(0,T.jsxs)(l,{value:E.tabSize?.toString()??`default`,onValueChange:e=>S.update(r,{tabSize:e==="default"?void 0:Number(e)}),children:[(0,T.jsx)(a,{"aria-label":`Tab size`,children:(0,T.jsx)(i,{})}),(0,T.jsxs)(o,{children:[(0,T.jsxs)(c,{value:`default`,children:[`Default (`,D.editorTabSize,`)`]}),Array.from({length:8},(e,t)=>t+1).map(e=>(0,T.jsx)(c,{value:String(e),children:e},e))]})]})]}),(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(`p`,{children:`Word wrap`}),(0,T.jsxs)(l,{value:E.wordWrap===void 0?`default`:E.wordWrap?`on`:`off`,onValueChange:e=>S.update(r,{wordWrap:e==="default"?void 0:e===`on`}),children:[(0,T.jsx)(a,{"aria-label":`Word wrap`,children:(0,T.jsx)(i,{})}),(0,T.jsxs)(o,{children:[(0,T.jsxs)(c,{value:`default`,children:[`Default (`,D.editorWordWrap?`on`:`off`,`)`]}),(0,T.jsx)(c,{value:`on`,children:`On`}),(0,T.jsx)(c,{value:`off`,children:`Off`})]})]})]}),(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(`p`,{children:`Syntax highlighting`}),(0,T.jsxs)(y,{open:O,onOpenChange:k,children:[(0,T.jsx)(v,{asChild:!0,children:(0,T.jsxs)(`button`,{type:`button`,"aria-label":`Syntax highlighting`,className:`flex w-full cursor-pointer items-center justify-between gap-2 rounded-md bg-elevated px-2.5 py-2 text-left hover:text-fg`,children:[(0,T.jsx)(`span`,{className:`truncate`,children:N}),(0,T.jsx)(u,{className:`size-3.5 shrink-0`})]})}),(0,T.jsx)(_,{className:`w-64 p-0`,align:`end`,children:(0,T.jsxs)(g,{children:[(0,T.jsx)(f,{"aria-label":`Find a language`,placeholder:`Find a language…`}),(0,T.jsxs)(h,{children:[(0,T.jsx)(m,{children:`No matching languages`}),[{id:`automatic`,label:`Automatic (${M(j)})`,keywords:[]},...A].map(e=>(0,T.jsxs)(p,{value:e.id,keywords:[e.label,...e.keywords],onSelect:()=>{S.update(r,{language:e.id===`automatic`?void 0:e.id}),k(!1)},children:[(0,T.jsx)(`span`,{className:`flex-1`,children:e.label}),(E.language??`automatic`)===e.id&&(0,T.jsx)(s,{className:`size-3.5`})]},e.id))]})]})})]})]}),(0,T.jsxs)(`p`,{className:`text-fg-muted`,children:[`Only this file, in this window.`,e.path.toLowerCase().endsWith(`.ipynb`)&&` Syntax highlighting applies to the JSON source; cells keep their own languages.`]})]})]})}export{E as FileEditorSettingsMenu};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-By8HlURe.js";import{t as r}from"./utils-B6KiDbIe.js";import{t as i}from"./x-CbfJFzGo.js";import{t as a}from"./createLucideIcon-DyMAgLa3.js";import{n as o,r as s,t as c}from"./whole-word-2m2pmAFT.js";import{t as l}from"./chevron-down--sjpQEHH.js";var u=a(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),d=e(t(),1),f=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform);function p(e,t=f){return e.key.toLowerCase()===`f`&&!e.altKey&&!e.shiftKey&&(t?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey)}var m={index:-1,count:0},h={caseSensitive:!1,wholeWord:!1,regex:!1};function g({shortcutEnabled:e,onFind:t,onClear:n,onCloseFocus:r}){let[i,a]=(0,d.useState)(!1),[o,s]=(0,d.useState)(0),[c,l]=(0,d.useState)(``),[u,f]=(0,d.useState)(h),[g,_]=(0,d.useState)(m),v=(0,d.useRef)({open:i,query:c,options:u});v.current={open:i,query:c,options:u};let y=(0,d.useRef)(t);y.current=t;let b=(0,d.useRef)(n);b.current=n;let x=(0,d.useRef)(r);x.current=r;let S=(0,d.useCallback)(e=>{let t=v.current;if(!t.open)return;let n=y.current(t.query,t.options,e);n&&_(n)},[]),C=(0,d.useCallback)(()=>{a(!0),s(e=>e+1)},[]),w=(0,d.useCallback)(()=>{a(!1),b.current(),x.current?.()},[]),T=(0,d.useCallback)(()=>S(`next`),[S]),E=(0,d.useCallback)(()=>S(`previous`),[S]),D=(0,d.useCallback)(()=>S(`reset`),[S]);return(0,d.useEffect)(()=>{i&&S(`reset`)},[i,c,u,S]),(0,d.useEffect)(()=>{if(!e)return;let t=e=>{p(e)&&(e.preventDefault(),e.stopPropagation(),C())};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[e,C]),(0,d.useEffect)(()=>()=>{b.current()},[]),{open:i,focusKey:o,query:c,options:u,result:g,openFind:C,close:w,next:T,previous:E,refresh:D,setQuery:l,setOptions:f,setResult:_}}var _=/[.*+?^${}()|[\]\\]/g;function v(e,t){if(e.length===0)return null;try{let n=t.regex?e:e.replace(_,`\\$&`);return t.wholeWord&&(n=`\\b(?:${n})\\b`),new RegExp(n,t.caseSensitive?`g`:`gi`)}catch{return null}}function y(e,t){return e.length===0||v(e,t)!==null}function b(e,t,n,r=1e3){let i=v(t,n);if(t.length>0&&i===null)return{matches:[],invalid:!0,limited:!1};if(!i)return{matches:[],invalid:!1,limited:!1};let a=[],o;for(;(o=i.exec(e))!==null;){if(o[0].length===0){i.lastIndex++;continue}if(a.length===r)return{matches:a,invalid:!1,limited:!0};a.push({start:o.index,end:o.index+o[0].length})}return{matches:a,invalid:!1,limited:!1}}var x=n();function S({active:e,label:t,onClick:n,children:i}){return(0,x.jsx)(`button`,{type:`button`,"aria-label":t,"aria-pressed":e,title:t,onClick:n,className:r(`rounded-sm p-1 transition-colors`,e?`bg-surface text-accent`:`text-fg-muted hover:bg-surface hover:text-fg`),children:i})}function C({query:e,result:t}){return e.length===0?null:t.invalid?(0,x.jsx)(x.Fragment,{children:`Invalid expression`}):t.count===0?(0,x.jsx)(x.Fragment,{children:`No results`}):t.limited?(0,x.jsxs)(x.Fragment,{children:[t.count,`+ results`]}):t.index<0?(0,x.jsxs)(x.Fragment,{children:[t.count,` results`]}):(0,x.jsxs)(x.Fragment,{children:[t.index+1,` of `,t.count]})}function w({query:e,focusKey:t,options:n,result:r,onQueryChange:a,onOptionsChange:f,onNext:m,onPrevious:h,onClose:g}){let _=(0,d.useRef)(null);(0,d.useEffect)(()=>{_.current?.focus(),_.current?.select()},[t]);let v=r.count>0&&!r.invalid;return(0,x.jsxs)(`div`,{role:`search`,"aria-label":`Find in view`,className:`absolute right-2 top-0 z-30 flex h-10 w-[min(34rem,calc(100%-0.5rem))] items-center gap-1.5 rounded-b-md bg-surface px-1.5 shadow-lg`,onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),g();return}if(e.key===`Enter`){e.preventDefault(),e.stopPropagation(),e.shiftKey?h():m();return}p(e.nativeEvent)&&(e.preventDefault(),e.stopPropagation(),_.current?.select())},children:[(0,x.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center rounded-md bg-elevated pl-2 pr-0.5`,children:[(0,x.jsx)(`input`,{ref:_,value:e,onChange:e=>a(e.target.value),placeholder:`Find`,spellCheck:!1,autoComplete:`off`,"aria-label":`Find`,className:`h-7 min-w-0 flex-1 bg-transparent text-sm text-fg outline-none placeholder:text-fg-muted`}),(0,x.jsx)(S,{active:n.caseSensitive,label:`Match case`,onClick:()=>f({...n,caseSensitive:!n.caseSensitive}),children:(0,x.jsx)(s,{className:`size-3.5`})}),(0,x.jsx)(S,{active:n.wholeWord,label:`Match whole word`,onClick:()=>f({...n,wholeWord:!n.wholeWord}),children:(0,x.jsx)(c,{className:`size-3.5`})}),(0,x.jsx)(S,{active:n.regex,label:`Use regular expression`,onClick:()=>f({...n,regex:!n.regex}),children:(0,x.jsx)(o,{className:`size-3.5`})})]}),(0,x.jsx)(`div`,{className:`w-20 shrink-0 text-center text-xs text-fg-muted`,children:(0,x.jsx)(C,{query:e,result:r})}),(0,x.jsx)(`button`,{type:`button`,"aria-label":`Previous match`,title:`Previous match (Shift+Enter)`,disabled:!v,onClick:h,className:`rounded-sm p-1 text-fg-muted transition-colors hover:bg-elevated hover:text-fg disabled:cursor-default disabled:opacity-40`,children:(0,x.jsx)(u,{className:`size-4`})}),(0,x.jsx)(`button`,{type:`button`,"aria-label":`Next match`,title:`Next match (Enter)`,disabled:!v,onClick:m,className:`rounded-sm p-1 text-fg-muted transition-colors hover:bg-elevated hover:text-fg disabled:cursor-default disabled:opacity-40`,children:(0,x.jsx)(l,{className:`size-4`})}),(0,x.jsx)(`button`,{type:`button`,"aria-label":`Close find`,title:`Close (Escape)`,onClick:g,className:`rounded-sm p-1 text-fg-muted transition-colors hover:bg-elevated hover:text-fg`,children:(0,x.jsx)(i,{className:`size-4`})})]})}export{g as a,y as i,v as n,m as o,b as r,p as s,w as t};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Terminal-B2FWGxlE.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/react-dom-cJyBB_A4.js","assets/protocol-support-sBpa8MZK.js","assets/auth-DYEjEl0U.js","assets/local-store-yUq3FKdV.js","assets/jsx-runtime-By8HlURe.js","assets/api-BwP0jv_V.js","assets/client-settings-BdKglwtW.js","assets/theme-swfNLod9.js","assets/preload-helper-Czpn1I53.js","assets/ws-DkbvXbTZ.js","assets/dist-BOS6OKSE.js","assets/forward-link-CkdngF7C.js","assets/motion-Bd_MB9cH.js","assets/utils-B6KiDbIe.js","assets/FindWidget-ET5pwkkB.js","assets/x-CbfJFzGo.js","assets/createLucideIcon-DyMAgLa3.js","assets/whole-word-2m2pmAFT.js","assets/chevron-down--sjpQEHH.js","assets/selection-actions-C33evFaY.js","assets/index-ncmnNFLA.js","assets/index-DtbUW4I4.css","assets/button-D-qeQvl5.js","assets/copy-CGsu8426.js","assets/code-DRWf9a5s.js","assets/profile-store-B54YLXa8.js","assets/errors-CD96hLph.js","assets/preferences-BX4iJsv8.js","assets/file-links-BWU9Vnfc.js","assets/render-rich-content-cSjuhT75.js","assets/math-delimiters-BCnTi7Ii.js","assets/render-rich-content-BoTeqQfi.css","assets/Terminal-BrP-ENHg.css"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{V as n}from"./auth-DYEjEl0U.js";import{t as r}from"./jsx-runtime-By8HlURe.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{t as a}from"./utils-B6KiDbIe.js";import{C as o}from"./dialog-CTN-Lln6.js";import"./dist-NuV8HBEc.js";import{n as s}from"./chevron-right-DUkOv15w.js";import{t as c}from"./createLucideIcon-DyMAgLa3.js";function l(e){return e.trim().slice(0,5).toUpperCase()}function u(e){return e.abbrev??l(e.name)}function d(e){return e.trim().toUpperCase().slice(0,5)}var f=e(t(),1),p=r(),m=`Label`,h=f.forwardRef((e,t)=>(0,p.jsx)(o.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));h.displayName=m;var g=h;function _({className:e,...t}){return(0,p.jsx)(g,{className:a(`text-xs font-medium text-fg-secondary peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var v=c(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),y=c(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),b=c(`pipette`,[[`path`,{d:`m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12`,key:`1y3wsu`}],[`path`,{d:`m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z`,key:`110lr1`}],[`path`,{d:`m2 22 .414-.414`,key:`jhxm08`}]]),x={navy:`text-identity-navy`,gold:`text-identity-gold`,blue:`text-icon-blue`,green:`text-icon-green`,amber:`text-icon-amber`,red:`text-icon-red`,violet:`text-icon-violet`,cyan:`text-icon-cyan`,accent:`text-accent`};function S(e){return e&&x[e]||``}function C(e){return typeof e==`string`&&/^#[0-9a-f]{6}$/i.test(e)}function w(e){return C(e)?{color:e}:void 0}function T({value:e,onChange:t,disabled:r=!1,label:i=`Colour`,onCustomChange:o}){let s=(0,f.useRef)(null),c=(0,f.useRef)(null);(0,f.useEffect)(()=>{let e=c.current;if(!e)return;let t=()=>{!r&&C(e.value)&&o?.(e.value)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[r,o]);let l=()=>{let t=c.current;if(!(!t||r)){if(C(e))t.value=e;else{let e=s.current.querySelector(`[aria-pressed="true"] > span`)??s.current.querySelector(`button > span`),n=document.createElement(`canvas`);n.width=n.height=1;let r=n.getContext(`2d`);r.fillStyle=getComputedStyle(e).backgroundColor,r.fillRect(0,0,1,1),t.value=`#`+[...r.getImageData(0,0,1,1).data].slice(0,3).map(e=>e.toString(16).padStart(2,`0`)).join(``)}t.click()}};return(0,p.jsxs)(`div`,{ref:s,role:`group`,"aria-label":i,className:`flex flex-wrap items-center gap-1`,children:[[null,...n].map(n=>(0,p.jsx)(`button`,{type:`button`,title:n??`Default`,"aria-label":n??`Default colour`,"aria-pressed":(e??null)===n,disabled:r,onClick:()=>t(n),className:a(`flex size-7 cursor-pointer items-center justify-center rounded-md transition-colors hover:bg-border/50 focus-visible:bg-border/50 disabled:cursor-default disabled:opacity-50`,(e??null)===n&&`bg-border/50`),children:(0,p.jsx)(`span`,{className:a(`size-3.5 rounded-full`,n?a(`bg-current`,S(n)):`bg-[var(--identity-default)]`)})},n??`default`)),o&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`button`,{type:`button`,title:`Custom colour`,"aria-label":`Custom ${i.toLowerCase()}`,"aria-pressed":C(e),disabled:r,onClick:l,className:a(`flex size-7 cursor-pointer items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-border/50 focus-visible:bg-border/50 disabled:cursor-default disabled:opacity-50`,C(e)&&`bg-border/50`),children:C(e)?(0,p.jsx)(`span`,{className:`size-3.5 rounded-full`,style:{backgroundColor:e}}):(0,p.jsx)(b,{className:`size-3.5`})}),(0,p.jsx)(`input`,{ref:c,type:`color`,"aria-label":`${i} custom colour picker`,disabled:r,tabIndex:-1,className:`sr-only`})]})]})}function E({id:e,value:t,onValueChange:n,onChoose:r,hints:i,placeholder:o,className:c,hintsClassName:l,autoFocus:u}){let[d,m]=(0,f.useState)(!1),[h,g]=(0,f.useState)(0),_=e=>{n(e.value),r?.(e),m(!1)};return(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(s,{id:e,value:t,onChange:e=>{n(e.target.value),m(!0),g(0)},onFocus:()=>m(!0),onBlur:()=>m(!1),onKeyDown:e=>{if(!(!d||i.length===0))if(e.key===`ArrowDown`)e.preventDefault(),g(e=>(e+1)%i.length);else if(e.key===`ArrowUp`)e.preventDefault(),g(e=>(e-1+i.length)%i.length);else if(e.key===`Enter`||e.key===`Tab`){let t=i[h]??i[0];t&&(e.preventDefault(),_(t))}else e.key===`Escape`&&(e.stopPropagation(),m(!1))},placeholder:o,className:c,autoComplete:`off`,spellCheck:!1,autoFocus:u}),d&&i.length>0&&(0,p.jsx)(`ul`,{className:a(`absolute top-full z-10 mt-1 max-h-56 overflow-y-auto rounded-md bg-elevated p-1 shadow-xl`,l??`w-full`),children:i.map((e,t)=>(0,p.jsx)(`li`,{children:(0,p.jsxs)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),_(e)},onMouseEnter:()=>g(t),className:a(`relative flex cursor-pointer select-none items-center gap-2 rounded-[var(--ui-menu-radius)] px-2 py-1.5 text-sm text-fg outline-none transition-colors`,`data-[selected=true]:bg-action data-[selected=true]:text-action-ink data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`,`w-full text-xs`),"data-selected":t===h,children:[(0,p.jsx)(`span`,{className:`truncate`,children:e.label??e.value}),e.badge&&(0,p.jsx)(`span`,{className:`ml-auto shrink-0 text-2xs opacity-70`,children:e.badge})]})},e.value))})]})}var D=(0,f.lazy)(()=>i(()=>import(`./Terminal-B2FWGxlE.js`).then(e=>({default:e.Terminal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35]))),O=null;async function k(){O=(await i(()=>import(`./Terminal-B2FWGxlE.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35]))).Terminal}function A(e){return O?(0,p.jsx)(O,{...e}):(0,p.jsx)(f.Suspense,{fallback:(0,p.jsx)(`div`,{className:`size-full bg-ground`}),children:(0,p.jsx)(D,{...e})})}export{S as a,y as c,l as d,d as f,T as i,v as l,k as n,w as o,u as p,E as r,C as s,A as t,_ as u};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{c as n,o as r,t as i}from"./buffer-store-Bh2IilxW.js";var a=e(t(),1);function o({buffers:e}){let t=(0,a.useRef)(new Set);return(0,a.useEffect)(()=>{let a=new Set(e.map(e=>i(e.session,e.path,e.root))),o=t.current;for(let e of a)o.has(e)||(n(e),o.add(e));for(let e of[...o])a.has(e)||(r(e),o.delete(e))},[e]),(0,a.useEffect)(()=>()=>{for(let e of t.current)r(e);t.current.clear()},[]),null}export{o as ModelRefcount};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{c as n,o as r,t as i}from"./buffer-store-fV6iYuCU.js";var a=e(t(),1);function o({buffers:e}){let t=(0,a.useRef)(new Set);return(0,a.useEffect)(()=>{let a=new Set(e.map(e=>i(e.session,e.path,e.root))),o=t.current;for(let e of a)o.has(e)||(n(e),o.add(e));for(let e of[...o])a.has(e)||(r(e),o.delete(e))},[e]),(0,a.useEffect)(()=>()=>{for(let e of t.current)r(e);t.current.clear()},[]),null}export{o as ModelRefcount};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{c as n}from"./auth-C3ruG3fE.js";import{t as r}from"./context-D1MuDP6X.js";import{r as i,s as a}from"./theme-swfNLod9.js";import{t as o}from"./jsx-runtime-By8HlURe.js";import{t as s}from"./preload-helper-Czpn1I53.js";var c=e(t(),1),l=o(),u=()=>()=>{},d={generation:null,revision:0,events:[]},f=()=>d;function p({modelId:e,fallback:t}){let n=(0,c.useContext)(r),i=n?.session,a=(0,c.useSyncExternalStore)(i?.subscribe??u,i?.getSnapshot??f),o=!!i?.state.state[e]&&!!a.generation&&!a.error,s=o?i.state:n?.saved,[d,p]=(0,c.useState)(!1);return s?.state[e]?(0,l.jsx)(h,{modelId:e,snapshot:s,session:o?i:null,generation:o?a.generation:null,extensions:o||d,onLoadExtension:()=>p(!0)},`${o?a.generation:`saved`}:${e}:${d}`):(0,l.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[t&&(0,l.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-sm text-fg-secondary`,children:t}),(0,l.jsx)(`p`,{children:a.error??(i?`Run this cell to create its widget.`:`Live Jupyter widgets require a local or SSH host with protocol 25.4 or newer.`)})]})}function m(){let e=getComputedStyle(document.documentElement),t=t=>e.getPropertyValue(t).trim();return{"--jp-layout-color0":t(`--bg-base`),"--jp-layout-color1":t(`--bg-surface`),"--jp-layout-color2":t(`--bg-elevated`),"--jp-layout-color3":t(`--bg-elevated`),"--jp-ui-font-color0":t(`--text-primary`),"--jp-ui-font-color1":t(`--text-primary`),"--jp-ui-font-color2":t(`--text-secondary`),"--jp-ui-font-color3":t(`--text-muted`),"--jp-content-font-color1":t(`--text-primary`),"--jp-border-color1":t(`--border`),"--jp-content-font-color0":t(`--text-primary`),"--jp-content-font-color2":t(`--text-secondary`),"--jp-content-font-color3":t(`--text-muted`),"--jp-content-font-family":t(`--font-sans`),"--jp-error-color1":t(`--danger`),"--jp-warn-color1":t(`--warning`),"--jp-success-color1":t(`--success`),"--jp-info-color1":t(`--accent`),"--jp-brand-color1":t(`--accent`),"--jp-ui-font-family":t(`--font-sans`),"--jp-code-font-family":t(`--font-mono`),"--danger":t(`--danger`)}}function h({modelId:e,snapshot:t,session:r,generation:o,extensions:u,onLoadExtension:d}){let f=(0,c.useRef)(null),p=(0,c.useRef)(null),h=(0,c.useRef)(t);h.current=t;let[g,_]=(0,c.useState)(),[v,y]=(0,c.useState)(0),[b,x]=(0,c.useState)(48),[S,C]=(0,c.useState)(),[w,T]=(0,c.useState)();return(0,c.useEffect)(()=>{p.current?.postMessage({type:`theme`,theme:m()})},[(0,c.useSyncExternalStore)(a,i,i)]),(0,c.useEffect)(()=>{let t=!1,i,a=a=>{if(a.source!==f.current?.contentWindow||a.data?.type!==`puddle-widget-ready`||p.current)return;let s=new MessageChannel;p.current=s.port1,s.port1.onmessage=e=>{if(t||!e.data||typeof e.data!=`object`)return;let i=e.data;if(i.type===`height`&&Number.isFinite(i.height)&&x(Math.max(24,Math.min(2e3,i.height))),i.type===`error`&&C(String(i.error).slice(0,1024)),i.type===`extension`&&T(String(i.name).slice(0,256)),i.type!==`comm`||!r||!o)return;let a=n.safeParse({source:r.source,generation:o,message:i.message});if(!a.success||JSON.stringify(a.data).length>2*1024*1024){C(`Widget action exceeds the supported message limits`);return}r.send(o,a.data.message).catch(e=>{t||s.port1.postMessage({type:`error`,msg_id:a.data.message.msg_id,error:e instanceof Error?e.message:`Widget action failed`})})},s.port1.start(),f.current.contentWindow.postMessage({type:`puddle-widget-connect`},`*`,[s.port2]),s.port1.postMessage({type:`init`,snapshot:structuredClone(r?.state??h.current),modelId:e,live:!!o,extensions:u,theme:m()}),i=r?.subscribe(e=>{e.generation!==o||e.error?s.port1.postMessage({type:`error`,error:e.error??`The kernel changed. Run the cell again.`}):e.snapshot?(p.current?.close(),p.current=null,i?.(),y(e=>e+1)):s.port1.postMessage({type:`events`,events:e.events})})};return window.addEventListener(`message`,a),(async()=>{let{default:e}=await s(async()=>{let{default:e}=await import(`./_virtual_notebook-widget-runtime-RX_hqyhn.js`);return{default:e}},[]);t||_(`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' blob: https:; style-src 'unsafe-inline' https:; img-src data: blob: https:; font-src data: https:; media-src data: blob: https:; connect-src https:; worker-src blob:; form-action 'none'; base-uri 'none'"><style>
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n}from"./auth-DYEjEl0U.js";import{t as r}from"./context-B6lkZJoM.js";import{r as i,s as a}from"./theme-swfNLod9.js";import{t as o}from"./jsx-runtime-By8HlURe.js";import{t as s}from"./preload-helper-Czpn1I53.js";var c=e(t(),1),l=o(),u=()=>()=>{},d={generation:null,revision:0,events:[]},f=()=>d;function p({modelId:e,fallback:t}){let n=(0,c.useContext)(r),i=n?.session,a=(0,c.useSyncExternalStore)(i?.subscribe??u,i?.getSnapshot??f),o=!!i?.state.state[e]&&!!a.generation&&!a.error,s=o?i.state:n?.saved,[d,p]=(0,c.useState)(!1);return s?.state[e]?(0,l.jsx)(h,{modelId:e,snapshot:s,session:o?i:null,generation:o?a.generation:null,extensions:o||d,onLoadExtension:()=>p(!0)},`${o?a.generation:`saved`}:${e}:${d}`):(0,l.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[t&&(0,l.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-sm text-fg-secondary`,children:t}),(0,l.jsx)(`p`,{children:a.error??(i?`Run this cell to create its widget.`:`Live Jupyter widgets require a local or SSH host with protocol 25.4 or newer.`)})]})}function m(){let e=getComputedStyle(document.documentElement),t=t=>e.getPropertyValue(t).trim();return{"--jp-layout-color0":t(`--bg-base`),"--jp-layout-color1":t(`--bg-surface`),"--jp-layout-color2":t(`--bg-elevated`),"--jp-layout-color3":t(`--bg-elevated`),"--jp-ui-font-color0":t(`--text-primary`),"--jp-ui-font-color1":t(`--text-primary`),"--jp-ui-font-color2":t(`--text-secondary`),"--jp-ui-font-color3":t(`--text-muted`),"--jp-content-font-color1":t(`--text-primary`),"--jp-border-color1":t(`--border`),"--jp-content-font-color0":t(`--text-primary`),"--jp-content-font-color2":t(`--text-secondary`),"--jp-content-font-color3":t(`--text-muted`),"--jp-content-font-family":t(`--font-sans`),"--jp-error-color1":t(`--danger`),"--jp-warn-color1":t(`--warning`),"--jp-success-color1":t(`--success`),"--jp-info-color1":t(`--accent`),"--jp-brand-color1":t(`--accent`),"--jp-ui-font-family":t(`--font-sans`),"--jp-code-font-family":t(`--font-mono`),"--danger":t(`--danger`)}}function h({modelId:e,snapshot:t,session:r,generation:o,extensions:u,onLoadExtension:d}){let f=(0,c.useRef)(null),p=(0,c.useRef)(null),h=(0,c.useRef)(t);h.current=t;let[g,_]=(0,c.useState)(),[v,y]=(0,c.useState)(0),[b,x]=(0,c.useState)(48),[S,C]=(0,c.useState)(),[w,T]=(0,c.useState)();return(0,c.useEffect)(()=>{p.current?.postMessage({type:`theme`,theme:m()})},[(0,c.useSyncExternalStore)(a,i,i)]),(0,c.useEffect)(()=>{let t=!1,i,a=a=>{if(a.source!==f.current?.contentWindow||a.data?.type!==`puddle-widget-ready`||p.current)return;let s=new MessageChannel;p.current=s.port1,s.port1.onmessage=e=>{if(t||!e.data||typeof e.data!=`object`)return;let i=e.data;if(i.type===`height`&&Number.isFinite(i.height)&&x(Math.max(24,Math.min(2e3,i.height))),i.type===`error`&&C(String(i.error).slice(0,1024)),i.type===`extension`&&T(String(i.name).slice(0,256)),i.type!==`comm`||!r||!o)return;let a=n.safeParse({source:r.source,generation:o,message:i.message});if(!a.success||JSON.stringify(a.data).length>2*1024*1024){C(`Widget action exceeds the supported message limits`);return}r.send(o,a.data.message).catch(e=>{t||s.port1.postMessage({type:`error`,msg_id:a.data.message.msg_id,error:e instanceof Error?e.message:`Widget action failed`})})},s.port1.start(),f.current.contentWindow.postMessage({type:`puddle-widget-connect`},`*`,[s.port2]),s.port1.postMessage({type:`init`,snapshot:structuredClone(r?.state??h.current),modelId:e,live:!!o,extensions:u,theme:m()}),i=r?.subscribe(e=>{e.generation!==o||e.error?s.port1.postMessage({type:`error`,error:e.error??`The kernel changed. Run the cell again.`}):e.snapshot?(p.current?.close(),p.current=null,i?.(),y(e=>e+1)):s.port1.postMessage({type:`events`,events:e.events})})};return window.addEventListener(`message`,a),(async()=>{let{default:e}=await s(async()=>{let{default:e}=await import(`./_virtual_notebook-widget-runtime-RX_hqyhn.js`);return{default:e}},[]);t||_(`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' blob: https:; style-src 'unsafe-inline' https:; img-src data: blob: https:; font-src data: https:; media-src data: blob: https:; connect-src https:; worker-src blob:; form-action 'none'; base-uri 'none'"><style>
2
2
  html,body{margin:0;background:var(--jp-layout-color0)!important;color:var(--jp-ui-font-color1)!important;font-family:var(--jp-ui-font-family)!important}
3
3
  .jupyter-widgets input,.jupyter-widgets select,.jupyter-widgets textarea,.jupyter-widgets button{border:0!important;color:var(--jp-ui-font-color1);background:var(--jp-layout-color1)}
4
4
  .jupyter-widgets button,.jupyter-widgets select,.jupyter-widgets input[type=range]{cursor:pointer}