@puddle-code/cli 0.4.17 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -30
- package/dist/host-control.mjs +419 -3
- package/dist/index.js +441 -6
- package/dist/public/assets/App-ESs-lBsA.js +49 -0
- package/dist/public/assets/CompilationCommandForm-D7uBn2um.js +1 -0
- package/dist/public/assets/Dashboard-DWwOy6bQ.js +1 -0
- package/dist/public/assets/DraftRecovery-DO-ymSIW.js +1 -0
- package/dist/public/assets/EditorTabClose-DEizui0i.js +1 -0
- package/dist/public/assets/FileCloseScope-DKbSgHF2.js +1 -0
- package/dist/public/assets/{FileEditorSettingsMenu-JUB6GRyp.js → FileEditorSettingsMenu-DnMJu5pC.js} +1 -1
- package/dist/public/assets/LazyTerminal-B0GmOiTE.js +2 -0
- package/dist/public/assets/{ModelRefcount-Bbr8zY_6.js → ModelRefcount-DBzR9UEq.js} +1 -1
- package/dist/public/assets/NotebookWidget-DlpLANDa.js +7 -0
- package/dist/public/assets/{PaneEditorBody-nc1Z681y.js → PaneEditorBody-DRZ6NrJ1.js} +19 -19
- package/dist/public/assets/PdfViewer-B3z9sh0x.js +2 -0
- package/dist/public/assets/{Ripple-DYosRAZ1.css → Ripple-C8HPFMGB.css} +1 -1
- package/dist/public/assets/Ripple-CLkhZZWa.js +11 -0
- package/dist/public/assets/SettingsDialog-DBUHpb9S.js +8 -0
- package/dist/public/assets/Terminal-C3TQK74f.js +65 -0
- package/dist/public/assets/Workspace-D_NxUGYW.js +20 -0
- package/dist/public/assets/api--n1Ha6tG.js +1 -0
- package/dist/public/assets/auth-eu0vmKkB.js +1 -0
- package/dist/public/assets/{buffer-store-fV6iYuCU.js → buffer-store-CBhXNRZm.js} +1 -1
- package/dist/public/assets/content-state-BDt3NnGs.js +1 -0
- package/dist/public/assets/context-BRrQlmgI.js +1 -0
- package/dist/public/assets/{cssMode-C63oO3vc.js → cssMode-BSxvHUeX.js} +1 -1
- package/dist/public/assets/{drafts-B_tChlzR.js → drafts-CCenbr5J.js} +1 -1
- package/dist/public/assets/editor-links-qwyINDCv.js +1 -0
- package/dist/public/assets/editor-sync-C5CgYn_q.js +1 -0
- package/dist/public/assets/{editor.api2-DTL_SiN1.js → editor.api2-Cyagyq8b.js} +1 -1
- package/dist/public/assets/{errors-CD96hLph.js → errors-DWF9D4n6.js} +1 -1
- package/dist/public/assets/expanding-content-BUkS1Qk4.js +1 -0
- package/dist/public/assets/{file-editor-settings-CzybzK8S.js → file-editor-settings-1cj6VRxs.js} +1 -1
- package/dist/public/assets/{file-links-BWU9Vnfc.js → file-links-BEPA2kg5.js} +1 -1
- package/dist/public/assets/forward-link-CcmVXHkx.js +1 -0
- package/dist/public/assets/{freemarker2-DKWtaCtp.js → freemarker2-RlVF_xG6.js} +1 -1
- package/dist/public/assets/{handlebars-uU1ujPOt.js → handlebars-2p1QNu5W.js} +1 -1
- package/dist/public/assets/{html-CrP_wDJ5.js → html-BOC2G_CE.js} +1 -1
- package/dist/public/assets/{htmlMode-lNJ18wA0.js → htmlMode-933MVCdH.js} +1 -1
- package/dist/public/assets/index-Botodnry.js +10 -0
- package/dist/public/assets/index-rjm6DMrz.css +2 -0
- package/dist/public/assets/{javascript-WHxEzdgn.js → javascript-C77bzTLL.js} +1 -1
- package/dist/public/assets/{jsonMode-xHnT5kRj.js → jsonMode-Cvtq6-nG.js} +1 -1
- package/dist/public/assets/{languages-MEV5hj_8.js → languages-O6mK4sJI.js} +3 -3
- package/dist/public/assets/{liquid-B1ddyofJ.js → liquid-CTjKJxys.js} +1 -1
- package/dist/public/assets/local-store-8IcyY3pd.js +64 -0
- package/dist/public/assets/{lspLanguageFeatures-CCO_e4_t.js → lspLanguageFeatures-DJLTbYTu.js} +1 -1
- package/dist/public/assets/{mdx-m1X3FtyX.js → mdx-CCh44hnn.js} +1 -1
- package/dist/public/assets/{monaco.contribution-BXkMDWX9.js → monaco.contribution-DOhsxmke.js} +2 -2
- package/dist/public/assets/notification-delivery-CWj1p0u-.js +1 -0
- package/dist/public/assets/{preferences-BX4iJsv8.js → preferences-Dy_61zsm.js} +1 -1
- package/dist/public/assets/profile-store-CarO9MCP.js +2 -0
- package/dist/public/assets/project-actions-Zt9oqLe5.js +1 -0
- package/dist/public/assets/project-drag-Bqy-V-45.js +1 -0
- package/dist/public/assets/protocol-support-BUdL5Q-x.js +1 -0
- package/dist/public/assets/{python-CRTN4ovU.js → python-mu5lS7bI.js} +1 -1
- package/dist/public/assets/queries-DnuokC1N.js +1 -0
- package/dist/public/assets/{razor-Cj7Cr6Fr.js → razor-ChcAhcMd.js} +1 -1
- package/dist/public/assets/{render-rich-content-cSjuhT75.js → render-rich-content-BULX1bwr.js} +1 -1
- package/dist/public/assets/scroll-restoration-Bl3jxJsC.js +1 -0
- package/dist/public/assets/select-DzQdQNsv.js +1 -0
- package/dist/public/assets/selection-actions-BSqrsD_7.js +1 -0
- package/dist/public/assets/session-order-CCDTBSiH.js +1 -0
- package/dist/public/assets/switch-BsUkvj8j.js +1 -0
- package/dist/public/assets/{tsMode-D0nEO9DL.js → tsMode-B7nLznL7.js} +1 -1
- package/dist/public/assets/{typescript-CQjjq4UE.js → typescript-DmvD4smm.js} +1 -1
- package/dist/public/assets/use-arrangement-ready-D18CpR8E.js +1 -0
- package/dist/public/assets/use-desktop-state-Dw9EfOjg.js +2 -0
- package/dist/public/assets/view-state-store-CY9DI6-i.js +1 -0
- package/dist/public/assets/{workers-m2qsiPbB.js → workers-CqunsJhE.js} +1 -1
- package/dist/public/assets/ws-DH0dKRnO.js +1 -0
- package/dist/public/assets/{xml-Ci2P6_gm.js → xml-CX8dI9sv.js} +1 -1
- package/dist/public/assets/{yaml-76T3bIWj.js → yaml-DbxzTbJh.js} +1 -1
- package/dist/public/index.html +5 -4
- package/dist/public/puddle-app.png +0 -0
- package/dist/public/puddle.svg +6 -5
- package/dist/pudl.js +419 -3
- package/package.json +1 -1
- package/dist/public/assets/App-ZtJSRE8n.js +0 -40
- package/dist/public/assets/CompilationCommandForm-BGIgFAkM.js +0 -1
- package/dist/public/assets/Dashboard-B_m3VKHu.js +0 -1
- package/dist/public/assets/EditorTabClose-CNB0NsZQ.js +0 -1
- package/dist/public/assets/LazyTerminal-SbouF2Y_.js +0 -2
- package/dist/public/assets/NotebookWidget-9z2Xca7D.js +0 -7
- package/dist/public/assets/PdfViewer-FWSPsqTc.js +0 -2
- package/dist/public/assets/Ripple-B2KIWnc_.js +0 -11
- package/dist/public/assets/SettingsDialog-DKnJSEij.js +0 -8
- package/dist/public/assets/Terminal-B2FWGxlE.js +0 -65
- package/dist/public/assets/Workspace-DUBYqpNS.js +0 -20
- package/dist/public/assets/api-BwP0jv_V.js +0 -1
- package/dist/public/assets/archive-BYp06n6i.js +0 -1
- package/dist/public/assets/auth-DYEjEl0U.js +0 -64
- package/dist/public/assets/context-B6lkZJoM.js +0 -1
- package/dist/public/assets/dist-cvE69gWt.js +0 -1
- package/dist/public/assets/editor-sync-W1bamxAP.js +0 -1
- package/dist/public/assets/expanding-content-UT_6Fp5v.js +0 -1
- package/dist/public/assets/forward-link-CkdngF7C.js +0 -1
- package/dist/public/assets/index-DtbUW4I4.css +0 -2
- package/dist/public/assets/index-ncmnNFLA.js +0 -10
- package/dist/public/assets/local-store-yUq3FKdV.js +0 -1
- package/dist/public/assets/media-refresh-store-Dxq65ATq.js +0 -1
- package/dist/public/assets/notification-delivery-NbIhmidu.js +0 -1
- package/dist/public/assets/profile-store-B54YLXa8.js +0 -1
- package/dist/public/assets/protocol-support-sBpa8MZK.js +0 -1
- package/dist/public/assets/scroll-restoration-D-jpZqdR.js +0 -1
- package/dist/public/assets/select-CCBPniW9.js +0 -1
- package/dist/public/assets/selection-actions-C33evFaY.js +0 -1
- package/dist/public/assets/session-order-DilOGTOO.js +0 -1
- package/dist/public/assets/switch-B3zcD6GH.js +0 -1
- package/dist/public/assets/use-ui-state-BLOunpIh.js +0 -1
- package/dist/public/assets/view-state-store-BLCtem0t.js +0 -1
- package/dist/public/assets/ws-DkbvXbTZ.js +0 -1
|
@@ -0,0 +1,49 @@
|
|
|
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-DBUHpb9S.js","assets/protocol-support-BUdL5Q-x.js","assets/local-store-8IcyY3pd.js","assets/LazyTerminal-B0GmOiTE.js","assets/preload-helper-Czpn1I53.js","assets/dist-NuV8HBEc.js","assets/chevron-right-DUkOv15w.js","assets/notification-delivery-CWj1p0u-.js","assets/theme-swfNLod9.js","assets/api--n1Ha6tG.js","assets/auth-eu0vmKkB.js","assets/profile-store-CarO9MCP.js","assets/queries-DnuokC1N.js","assets/switch-BsUkvj8j.js","assets/select-DzQdQNsv.js","assets/chevron-down--sjpQEHH.js","assets/ws-DH0dKRnO.js","assets/dist-BOS6OKSE.js","assets/notification-delivery-BZzMYzIP.css","assets/client-settings-BdKglwtW.js","assets/editor-links-qwyINDCv.js","assets/use-desktop-state-Dw9EfOjg.js","assets/errors-DWF9D4n6.js","assets/preview-kind-CJ9RTgbs.js","assets/content-state-BDt3NnGs.js","assets/debounce-B9DrqirV.js","assets/button-D-qeQvl5.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/use-debounced-value-C86N-mOK.js","assets/popover-Okyclsx8.js","assets/preferences-Dy_61zsm.js","assets/CompilationCommandForm-D7uBn2um.js","assets/SettingsDialog-CJX0gDhJ.css","assets/Dashboard-DWwOy6bQ.js","assets/session-order-CCDTBSiH.js","assets/motion-Bd_MB9cH.js","assets/dist-BcrNV8NP.js","assets/use-arrangement-ready-D18CpR8E.js","assets/project-actions-Zt9oqLe5.js","assets/expanding-content-BUkS1Qk4.js","assets/Workspace-D_NxUGYW.js","assets/forward-link-CcmVXHkx.js","assets/DraftRecovery-DO-ymSIW.js","assets/project-drag-Bqy-V-45.js","assets/whole-word-2m2pmAFT.js","assets/selection-actions-BSqrsD_7.js","assets/copy-CGsu8426.js","assets/search-Ct_rLLa4.js","assets/view-state-store-CY9DI6-i.js","assets/drafts-CCenbr5J.js","assets/buffer-logic-BAkSBQT7.js","assets/scroll-restoration-Bl3jxJsC.js","assets/FileCloseScope-DKbSgHF2.js","assets/file-links-BEPA2kg5.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{C as r,c as i,o as a}from"./protocol-support-BUdL5Q-x.js";import{H as o,P as s,S as c,U as l,W as u,Z as d,dt as f,i as p,it as m,m as h,q as g,r as _,st as v,ut as y}from"./local-store-8IcyY3pd.js";import{a as b,c as x,i as S,o as C,u as w}from"./LazyTerminal-B0GmOiTE.js";import{C as T,D as E,E as D,N as ee,P as te,T as ne,_ as re,a as O,d as ie,g as ae,h as k,i as oe,j as se,k as ce,l as le,m as ue,o as de,p as fe,s as pe,t as me,u as he,w as ge}from"./notification-delivery-CWj1p0u-.js";import{r as _e}from"./auth-eu0vmKkB.js";import{i as ve,r as ye,t as be}from"./client-settings-BdKglwtW.js";import{c as xe,n as Se,r as Ce,s as we,t as Te}from"./theme-swfNLod9.js";import{t as Ee}from"./jsx-runtime-By8HlURe.js";import{t as De}from"./preload-helper-Czpn1I53.js";import{n as A}from"./api--n1Ha6tG.js";import{a as Oe,d as ke,i as j,l as M,n as Ae,o as N,r as je,t as Me,u as Ne}from"./profile-store-CarO9MCP.js";import{t as Pe}from"./forward-link-CcmVXHkx.js";import{A as Fe,B as Ie,C as Le,F as Re,H as ze,I as Be,L as Ve,P as He,T as Ue,U as We,V as Ge,W as P,X as Ke,b as qe,c as Je,et as Ye,h as Xe,i as Ze,it as Qe,j as $e,k as et,l as tt,m as nt,n as rt,o as it,ot as at,r as ot,s as st,st as ct,t as lt,v as ut}from"./queries-DnuokC1N.js";import{D as dt,H as ft,N as pt,R as mt,Z as F,_ as ht,g as gt,h as _t,k as vt,o as yt,r as bt,z as xt}from"./use-desktop-state-Dw9EfOjg.js";import{C as St,D as Ct,E as wt,S as Tt,T as Et,a as Dt,b as Ot,c as kt,f as At,g as jt,m as Mt,o as Nt,r as Pt,s as Ft,v as It,w as Lt,x as Rt,y as zt}from"./session-order-CCDTBSiH.js";import{t as Bt}from"./motion-Bd_MB9cH.js";import{t as I}from"./utils-B6KiDbIe.js";import{o as Vt,r as Ht,s as Ut,t as Wt}from"./dialog-CTN-Lln6.js";import{n as L,t as Gt}from"./dist-BOS6OKSE.js";import{f as Kt,r as qt}from"./dist-NuV8HBEc.js";import{a as Jt,i as Yt,n as Xt,r as Zt,t as Qt}from"./select-DzQdQNsv.js";import{A as R,C as $t,D as en,E as tn,M as nn,N as z,O as rn,S as an,T as on,_ as sn,b as cn,c as ln,d as un,f as B,g as dn,h as fn,i as pn,j as V,k as mn,l as hn,m as gn,o as _n,r as vn,u as yn,v as bn,x as xn,y as Sn}from"./project-drag-Bqy-V-45.js";import{n as Cn,t as H}from"./button-D-qeQvl5.js";import{n as U,r as wn}from"./chevron-right-DUkOv15w.js";import{t as W}from"./createLucideIcon-DyMAgLa3.js";import{c as Tn,d as En,i as G,l as Dn,o as On,t as kn,u as An}from"./switch-BsUkvj8j.js";import{t as jn}from"./copy-CGsu8426.js";import{n as Mn,r as Nn,t as Pn}from"./expanding-content-BUkS1Qk4.js";import{n as Fn,t as In}from"./trash-2-DQeNROsF.js";import{t as Ln}from"./settings-2-CInoy48z.js";import{a as Rn,c as zn,d as Bn,f as K,g as Vn,h as Hn,i as Un,l as Wn,o as Gn,p as Kn,s as qn,t as q}from"./ws-DH0dKRnO.js";import{t as Jn}from"./control-tray-CjoJunx1.js";import{n as J}from"./errors-DWF9D4n6.js";import{a as Yn,c as Xn,i as Zn,n as Qn,o as $n,r as er,s as tr}from"./command-BeX8pm7h.js";import{n as nr,r as rr,t as ir}from"./popover-Okyclsx8.js";import{n as ar,r as or,t as sr}from"./queue-BlrQxHDl.js";import{n as cr,t as lr}from"./project-actions-Zt9oqLe5.js";var Y=e(t(),1),X=Ee();function ur(){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 Pe(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 dr=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:()=>{Ne().catch(e=>this.setState({error:e instanceof Error?e:Error(`Could not reload this window`)}))},className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Reload`})]})]})}};function fr(){return(0,X.jsx)(Gt,{theme:(0,Y.useSyncExternalStore)(we,Ce),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 pr(){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 mr=e(n(),1),hr=`a, button, [role="button"], [role="slider"], input, select, textarea, summary, label, [onclick], .cursor-pointer`,gr=`.monaco-editor`;function _r(e,t){return e?.closest(gr)&&!e.closest(t)?`text`:e?.closest(hr)?`interactive`:`default`}function vr(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(gr),m=_r(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 yr=[`top`,`right`,`bottom`,`left`];function br(){let e=(0,Y.useRef)(null);return vr(e),(0,X.jsx)(`div`,{ref:e,className:`custom-cursor drafting-cursor`,"aria-hidden":`true`,children:yr.map(e=>(0,X.jsx)(`span`,{className:`drafting-cursor-tick`,"data-side":e},e))})}function xr(){let e=(0,Y.useRef)(null);return vr(e),(0,X.jsx)(`div`,{ref:e,className:`custom-cursor invert-cursor`,"aria-hidden":`true`})}var Sr=`h1, h2, h3, h4, h5, h6, .no-rangefinder-caret`,Z=40.5,Q=4.05,Cr=Q*Math.sqrt(3)/2;function wr(){let e=[],t=[],n=Z/2,r=Math.ceil(n/Cr)+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*Cr,s=o+Cr,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 Tr=wr();function Er(){let e=(0,Y.useRef)(null);return vr(e,Sr),(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:Tr.light}),(0,X.jsx)(`path`,{className:`rangefinder-cursor-facet-dark`,d:Tr.dark})]})})}function Dr(){let{cursorPackage:e}=ve(),t=null;switch(e){case`rangefinder`:t=(0,X.jsx)(Er,{});break;case`drafting`:t=(0,X.jsx)(br,{});break;case`invert`:t=(0,X.jsx)(xr,{});break;case`system`:return null}return(0,mr.createPortal)(t,document.body)}var Or=W(`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`}]]),kr=W(`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`}]]),Ar=W(`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`}]]),jr=W(`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`}]]),Mr=W(`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`}]]),Nr=W(`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 Pr(){let e=ze(),t=Xe(),[n,r]=(0,Y.useState)(``),[i,a]=(0,Y.useState)(d),o=()=>{n.trim()&&t.mutate({name:n.trim(),branch_prefix:i.trim()},{onSuccess:e=>je(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:()=>je(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)(ce,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,X.jsx)(`span`,{className:I(`text-base`,b(e.icon_colour)||`text-fg`),style:C(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)(w,{htmlFor:`profile-name`,children:`Name`}),(0,X.jsx)(U,{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)(w,{htmlFor:`branch-prefix`,children:`Branch prefix`}),(0,X.jsx)(U,{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)(H,{type:`submit`,size:`lg`,className:`self-start px-6`,disabled:!n.trim()||t.isPending,children:`Create profile`})]})]})})}function Fr({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)(Nt,{children:[(0,X.jsxs)(Ft,{onSelect:n,children:[(0,X.jsx)(x,{}),`Rename `,e]}),(0,X.jsxs)(Ft,{onSelect:()=>c(!0),children:[(0,X.jsx)(An,{}),`Change `,e,` colour`]}),o&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(kt,{}),(0,X.jsxs)(Ft,{onSelect:o,children:[(0,X.jsx)(Dn,{}),`Host updates`]})]})]}),(0,X.jsx)(Wt,{open:s,onOpenChange:c,children:(0,X.jsxs)(Ht,{children:[(0,X.jsx)(Vt,{children:(0,X.jsx)(Ut,{children:e===`host`?`Host accent`:`Profile colour`})}),(0,X.jsx)(S,{value:t,onChange:r,onCustomChange:i?r:void 0,disabled:a,label:e===`host`?`Host accent`:`Profile colour`})]})})]})}function Ir(){let e=et(),{icon:t}=E(),n=j(),r=Hn()[`host.peek`],{showHostOnFocus:i}=ve(),[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||Bt())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=K(`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=M()?.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,mr.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)(D,{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:ot(e.data)??`Host`})]})}),document.body):null}function Lr(){let e=qe().data?.protocol,t=e!==void 0&&(e.major>25||e.major===25&&e.minor>=5),{data:n}=Qe({queryKey:[`storage`],queryFn:()=>A(`GET`,`/api/storage`),enabled:t&&!_(),refetchInterval:1e4,retry:!1});if(!t||_()||!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)(mn,{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)(On,{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 Rr=new class{transport;reload;pause;phase=`idle`;pending=null;constructor(e=fetch,t=Ne,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 ${_e.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=s.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=c.parse(await e.json());if(n.instance===r.instance||n.refreshId!==r.refreshId||n.upstream!==`ready`)continue}catch{continue}return await this.reload(),this.phase=`complete`,!0}}catch{}return this.phase=`failed`,!1}},zr=null;function Br(e){return zr=e,()=>{zr===e&&(zr=null)}}function Vr(){zr?.()}var Hr=new Set;function Ur(){return[...Hr].flatMap(e=>e())}function Wr({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=Lt(),p=Et(),m=j(),h=p.id,g=P(m??void 0),_=Ge(m??void 0),v=Ye(h),y=an(),b=Hn();(0,Y.useEffect)(()=>K(`palette.toggle`,()=>r(e=>!e)),[]),(0,Y.useEffect)(()=>tn(()=>r(!0)),[]),(0,Y.useEffect)(()=>{n||(a(`commands`),s(``),l(null),d(!1))},[n]);let x=(0,Y.useMemo)(()=>{let n=[],r=Pt((g.data??[]).filter(e=>!e.archived),_.data?.projectOrder??[]);for(let[e,t]of r.entries()){let r=Un[e];n.push({id:`project-${t.id}`,group:`Projects`,label:t.name,icon:Nn,keywords:`switch project open`,shortcut:r?qn(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:Mt,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:En,keywords:`new agent create start session`,run:()=>e()},{id:`new-terminal`,group:`Actions`,label:`New terminal`,icon:Mt,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:Nn,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:Fn,keywords:`new project open create repository repo workspace`,run:t}),n.push({id:`theme-dark`,group:`Theme`,label:`Switch theme: dark`,icon:ee,keywords:`switch theme dark appearance`,run:()=>void Te(`dark`)},{id:`theme-light`,group:`Theme`,label:`Switch theme: light`,icon:se,keywords:`switch theme light appearance`,run:()=>void Te(`light`)},{id:`theme-system`,group:`Theme`,label:`Switch theme: system`,icon:Ar,keywords:`switch theme system appearance`,run:()=>void Te(`system`)},{id:`open-settings`,group:`Actions`,label:`Settings`,icon:Nr,keywords:`open settings preferences options configure`,run:()=>G()},{id:`switch-profile`,group:`Actions`,label:`Switch profile`,icon:Tn,keywords:`switch profile identity user change`,run:()=>Ae.set(null)},{id:`refresh-connection`,group:`Actions`,label:`Refresh connection`,icon:Dn,keywords:`refresh connection reconnect restart cockpit tunnel ssh daemon`,run:()=>Vr()}),[...n,...Ur()]},[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 $t(e),r(!1)}catch(e){l(e instanceof Error?e.message:`Could not open that path.`)}finally{d(!1)}}};return(0,X.jsxs)(Qn,{open:n,onOpenChange:r,children:[(0,X.jsx)(Yn,{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)(tr,{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)(tr,{children:[(0,X.jsx)(er,{children:`Nothing matches.`}),S.map(([e,t])=>(0,X.jsx)(Zn,{heading:e,children:t.map(e=>{let t=e.icon;return(0,X.jsxs)($n,{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)(Xn,{children:e.shortcut})]},e.id)})},e))]})]})}function Gr(){let e=document.activeElement;return e instanceof Element&&e.closest(`.xterm`)!==null}function Kr(){let e=document.activeElement;return e instanceof Element&&e.closest(`.monaco-editor`)!==null}function qr(){let e=Lt(),t=j(),n=P(t??void 0),r=Ge(t??void 0),i=r.data?.hotkeys;return(0,Y.useEffect)(()=>{Kn(i&&typeof i==`object`?i:void 0)},[i]),(0,Y.useEffect)(()=>{if(t===null)return;let i=Pt((n.data??[]).filter(e=>!e.archived),r.data?.projectOrder??[]),a=Un.map((t,n)=>K(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)(()=>K(`window.close`,()=>{let e=M();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=Gn(e);if(!t)return;let n=Rn(t);if(!n)return;let r=zn(n);if(!r||!Bn(r,Kr())||r.deferInTerminal&&Gr())return;let i=Wn(n);i&&(e.preventDefault(),e.stopPropagation(),(!r.hold||!e.repeat)&&i())},t=e=>{let t=Gn(e);if(!t)return;let n=Rn(t);if(!n)return;let r=zn(n);if(!r||r.editor&&Kr()||r.deferInTerminal&&Gr())return;let i=Wn(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 Jr=4e3;function Yr(){let[e,t]=(0,Y.useState)(`hidden`),n=(0,Y.useRef)(e);n.current=e,(0,Y.useEffect)(()=>{let e=null,r=q.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`)},Jr))});return()=>{r(),e!==null&&clearTimeout(e)}},[]);let r=(0,Y.useCallback)(async()=>{n.current!==`refreshing`&&(t(`refreshing`),await Rr.refresh()||(L.error(`The cockpit has not come back — it may need a terminal (ssh re-auth): puddle refresh`),t(q.isConnected()?`hidden`:`lost`)))},[]);return(0,Y.useEffect)(()=>Br(()=>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)(H,{size:`sm`,className:`ml-auto`,onClick:()=>void r(),children:[(0,X.jsx)(Dn,{}),`Refresh connection`]})]})}function Xr({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 Zr(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Qr(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 $r({account:e,onLogin:t,onStartSession:n,installed:r=!0}){let i=it(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 `,Qr(i.data.last_activity_at)]})]}),i.data?.agent_usage&&(0,X.jsxs)(`span`,{className:`block text-2xs text-fg-muted`,children:[Zr(i.data.agent_usage.input_tokens),` in ·`,` `,Zr(i.data.agent_usage.output_tokens),` out ·`,` `,Zr(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)(Xr,{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)(te,{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)(Xr,{label:e.label,percentage:e.used_percentage,hint:e.resets==null?void 0:`resets ${e.resets}`},e.key))})]})}function ei(){let[e,t]=(0,Y.useState)(!1),[n,r]=(0,Y.useState)(!1),i=j(),a=ze(),o=Be(),s=a.data?.find(e=>e.id===i),c=st(i??void 0),l=Je(),u=$e(),{open:d,handler:f}=xn(),[p,m]=(0,Y.useState)(null),h=e=>u.mutate(e.id,{onSuccess:t=>m({stream:t.stream,label:`${e.agent_type}/${e.label}`}),onError:e=>J(e)}),g=e=>{t(!1),d({accountId:e.id})},_=e=>{r(!1);let t=e.trim();!i||!t||t===s?.name||o.mutate({id:i,name:t},{onError:e=>J(e)})},v=`profile-trigger font-sans compact:h-7 compact:px-1.5`;return n&&s?(0,X.jsxs)(`div`,{className:Cn({variant:`ghost`,size:`sm`,className:v}),style:C(s.icon_colour),children:[(0,X.jsx)(ce,{icon:s.icon,colour:s.icon_colour}),(0,X.jsx)(en,{initial:s.name,maxLength:100,fitContent:!0,className:b(s.icon_colour),onCommit:_,onCancel:()=>r(!1)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Dt,{onOpenChange:e=>{e&&t(!1)},children:[(0,X.jsxs)(ir,{open:e,onOpenChange:t,children:[(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{asChild:!0,children:(0,X.jsx)(rr,{asChild:!0,children:(0,X.jsx)(At,{asChild:!0,children:(0,X.jsxs)(H,{variant:`ghost`,size:`sm`,className:v,children:[(0,X.jsx)(ce,{icon:s?.icon,colour:s?.icon_colour}),(0,X.jsx)(`span`,{className:b(s?.icon_colour),style:C(s?.icon_colour),...rn(()=>{t(!1),r(!0)}),children:s?.name??`…`})]})})})}),(0,X.jsx)(V,{children:`Profile`})]}),(0,X.jsxs)(nr,{className:`w-[28rem] max-w-[calc(100vw-1rem)]`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(l.data??[]).map(e=>{let t=c.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)($r,{account:e,onLogin:()=>h(e),onStartSession:f&&n?()=>g(e):null,installed:n},e.id))]},e.id)}),c.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)(H,{variant:`ghost`,size:`sm`,onClick:()=>{t(!1),G(`accounts`)},children:[(0,X.jsx)(Fn,{}),`Add account`]}),(0,X.jsxs)(H,{variant:`ghost`,size:`sm`,className:`ml-auto`,onClick:()=>{t(!1),Ae.set(null)},children:[(0,X.jsx)(Ln,{}),`Switch profile`]})]})]})]}),(0,X.jsx)(Fr,{kind:`profile`,colour:s?.icon_colour,onRename:()=>{t(!1),r(!0)},onColour:e=>{i&&o.mutate({id:i,icon_colour:e},{onError:J})},pending:o.isPending||!i})]}),p&&(0,X.jsx)(T,{stream:p.stream,label:p.label,onClose:()=>m(null)})]})}function ti(e=`hostOffers`){let t=M()?.windows?.effects,[n,r]=(0,Y.useState)(()=>!t||null);return(0,Y.useEffect)(()=>{if(!t)return;let n=!0,i=!1,a=t=>{let i=p.safeParse(t);n&&i.success&&r(i.data[e])},o=t.onChanged(e=>{i=!0,a(e)});return t.status().then(e=>{i||a(e)}).catch(()=>{n&&!i&&r(!1)}),()=>{n=!1,o()}},[t,e]),n}var ni=`desktop-update`,ri=null;function ii(){let e=ti(`desktopOffers`);return(0,Y.useEffect)(()=>{e===!1&&L.dismiss(ni)},[e]),e?(0,X.jsx)(ai,{}):null}function ai(){return(0,Y.useEffect)(()=>{let e=M();if(e?.updateReady===void 0||e.onUpdateReady===void 0)return;let t=!0,n=e=>{!t||ri===e||(ri=e,L(`Puddle ${e} is downloaded and ready.`,{id:ni,duration:1/0,closeButton:!0,action:{label:`Restart to update`,onClick:()=>{M()?.installUpdate?.(),L.loading(`Restarting into Puddle ${e}…`,{id:`${ni}-restarting`,duration:1/0})}}}))};e.updateReady().then(e=>{e!==null&&n(e)});let r=e.onUpdateReady(n);return()=>{t=!1,r()}},[]),null}var oi=new ae,si=new Set;function ci({onReview:e}={}){let t=ti();return fe(),(0,Y.useEffect)(()=>{if(t===!1){for(let e of si)L.dismiss(e);si.clear()}},[t]),t?(0,X.jsx)(li,{onReview:e}):null}function li({onReview:e}){let t=ue(),n=ie(),r=ot(et().data),i=k();return(0,Y.useEffect)(()=>{if(!(!n||!r||t.isError))for(let n of oi.take(i,re(t.data))){let t=n.component===`daemon`?`Daemon`:`Runtime software`,a=`host-update-${i}-${n.component}-${n.version}`;si.add(a),L(`${r}: ${t} ${n.version} is available.`,{id:a,duration:1/0,closeButton:!0,action:{label:`Review update`,onClick:e??(()=>G(`host`))}})}},[t.data,t.isError,r,n,i,e]),null}function ui({hostKey:e,enabled:t=!0}){let n=Qe({queryKey:[`host`],queryFn:async({signal:e})=>m.parse(await A(`GET`,`/api/host`,void 0,e)),staleTime:1/0,enabled:t&&!e,retry:!1}),r=e??(n.data?sr(n.data):void 0),i=_(),a=i?.generation,o=Qe({queryKey:[`release-notes`,r],queryFn:async({signal:e})=>{let t=v.parse(await A(`GET`,`/api/release-notes`,void 0,e));if(_()!==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&&or(r,o.data)},[t,r,o.data,o.isError]),null}var di=(0,Y.lazy)(()=>De(()=>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 fi({remote:e=!1}){let t=(0,Y.useSyncExternalStore)(ar.subscribe,ar.snapshot)[0];return(0,Y.useEffect)(()=>{let t=e?[`cockpit`,`remote`]:[`cockpit`];ar.enqueue(`browser`,t.map(e=>({component:e,version:`0.5.0`,markdown:`## [0.5.0] — 2026-11-08
|
|
3
|
+
|
|
4
|
+
### Cockpit
|
|
5
|
+
|
|
6
|
+
#### Added
|
|
7
|
+
|
|
8
|
+
- Open projects in dedicated native windows, focus them through shared project navigation, and return their latest workspace after closing them even when no host window is open (application protocol 26.15; native OS acceptance remains in progress).
|
|
9
|
+
- Drag a dedicated project's sidebar label back to its host, or use its return menu, preserving drafts and closing project ownership atomically (application protocol 26.16).
|
|
10
|
+
- Open individual files and sessions in native pane windows from their existing context menus, and focus an existing detached view when reopening it (application protocol 26.9).
|
|
11
|
+
- Open an entire pane in its own native window from its tab-strip context menu, preserving dirty text through an acknowledged handoff (application protocol 26.8).
|
|
12
|
+
- Return detached panes to existing host/project windows through their context menu, preserving dirty text and view positions and retaining the source when late drafts remain (application protocol 26.11).
|
|
13
|
+
- Connect detached pane dragging to the acknowledged return handoff, validate host/profile identity and place the pane in the destination's visible project (application protocol 26.12; native OS acceptance remains in progress).
|
|
14
|
+
- Drag files, sessions and native tabs into existing pane windows through the same draft-preserving handoff, and keep filesystem/archive drag actions local to their source window (application protocol 26.13).
|
|
15
|
+
- Highlight TeX and LaTeX commands, comments, environments, mathematics and verbatim text, with automatic file detection and a per-file language choice.
|
|
16
|
+
|
|
17
|
+
#### Changed
|
|
18
|
+
|
|
19
|
+
- Review dirty files and untitled drafts when closing a native pane window, preserving cancellation and app-quit recovery and checking retained drafts again before closure (application protocol 26.22).
|
|
20
|
+
- Show only the project name in workspace window titles and the active file or session name in detached pane titles.
|
|
21
|
+
- Coordinate native notification sounds/delivery and update offers across windows, retain notifications when their original window closes, and route clicks to the correct profile or detached session (application protocol 26.21).
|
|
22
|
+
- Save, duplicate and load native window arrangements through the host Layouts popover, including project saves from the dashboard; preserve mounted editors when saving and observe uncertain loads without redispatch.
|
|
23
|
+
- Coordinate native arrangement application with scoped window matching, draft-preserving plans, atomic ownership and cancellation recovery; retain each restored window's layout mode without changing client preferences (application protocol 26.20; native OS acceptance remains in progress).
|
|
24
|
+
- Stage native layout participants through the reused workspace/dashboard, verify mounted revisions and preserve drafts on cancellation (application protocol 26.19).
|
|
25
|
+
- Coordinate native layout capture across window checkpoints and prepare atomic multi-window recovery transactions with draft retention (application protocol 26.18).
|
|
26
|
+
- Prepare named native window layouts with portable arrangement storage, scoped capture projections and a single-tree browser fallback (application protocol 26.17).
|
|
27
|
+
- Support typing through Ripple when its divider covers the live input, reusing native keyboard, paste and IME handling with anchored cells and a visible caret. Preserve the default display-only split and native composer.
|
|
28
|
+
|
|
29
|
+
- Prepare project-window handoffs with durable return records and shared destination planning; subsequent controls use the same ownership flow (application protocol 26.14).
|
|
30
|
+
- Refresh the Puddle logo across the favicon, in-app branding, web app and notification icons, and macOS/Linux desktop icons.
|
|
31
|
+
- Separate native window lifetime from host connections and retain revisioned desktop working sets and acknowledged transfer records (application protocol 26.7).
|
|
32
|
+
- Flush desktop working sets and dirty drafts before native close or Command-Q, and cancel closure when a renderer cannot confirm its checkpoint.
|
|
33
|
+
- Preserve editor selections when detaching from project-based layouts by translating their saved view-state scope.
|
|
34
|
+
- Save native window drafts before reload or host refresh, serialise navigation per host, and let Command-Q wait for pending navigation (application protocol 26.10).
|
|
35
|
+
|
|
36
|
+
#### Fixed
|
|
37
|
+
|
|
38
|
+
- Recover a native destination's lost acceptance reply by observing the committed transfer, keeping returned projects editable after their source window closes.
|
|
39
|
+
- Allow docking again after a destination renderer crashes and reloads, clearing its stale restoration flag while preserving draft rollback.
|
|
40
|
+
- Keep Monaco hover services alive when source/preview panes detach or dock, preventing disposed diff-editor services from crashing sibling editors.
|
|
41
|
+
- Preserve shared dirty text and draft persistence when closing a duplicate file view; ask to discard only when its last view closes.
|
|
42
|
+
- Reuse draft review when closing native panes with missing projects or profiles, expose orphaned drafts without remounting editors, and preserve independent cached edits when discarding recovery copies.
|
|
43
|
+
- Wait for pending untitled-draft saves before approved deletion, prevent discard dialogues from reactivating closed tabs, and keep the last explicitly closed native window out of restart recovery.
|
|
44
|
+
- Use the file tab's discard dialogue for keyboard closure too, retaining unsaved text on cancellation and preventing closure before the lazy dirty-file check loads.
|
|
45
|
+
- Cancel pending local draft writes after an approved discard so closing the editor cannot restore the discarded text on reopen.
|
|
46
|
+
- Keep unavailable native tabs and expose retained draft text for copying or downloading when a file, session or project disappears; preserve discard confirmation and restore editing after retry.
|
|
47
|
+
- Keep project and pane window titles identifiable when unrelated host sessions change status, and restore the current host title on leaving the workspace.
|
|
48
|
+
- Preserve the active editor on native window reload when the URL retains a previous session binding.
|
|
49
|
+
`})))},[e]),t?(0,X.jsx)(Y.Suspense,{fallback:null,children:(0,X.jsx)(di,{current:t})}):null}function pi(){let e=j(),t=ze().data?.find(t=>t.id===e),n=Ge(e??void 0),r=Ke(e??void 0,void 0),i=ve(),a=de(),o=pe(),s=Ve(e??``),c=Be(),l=ut(),[u,d]=(0,Y.useReducer)(e=>e+1,0);(0,Y.useEffect)(()=>we(()=>d()),[]);let f=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{f.current=null},[t?.name]);let p=a.data?.available===!0?a.data.file:void 0,m=t!==void 0&&e!==null&&n.data!==void 0&&r.data!==void 0&&p!==void 0,h=t&&p?O(p,t.name):void 0,g=s.isPending||c.isPending||l.isPending||o.isPending||n.isFetching||r.isFetching;(0,Y.useEffect)(()=>{if(!m||!h?.enabled||g)return;let a={client:i,theme:xe(),profileSettings:n.data,profile:t,scratchpad:r.data},u={setClient:e=>ye(e),setTheme:e=>{typeof e==`string`&&Te(e)},patchProfileSettings:e=>s.mutate(e),patchProfileColumns:t=>c.mutate({id:e,...t}),createScratchpad:t=>{for(let n of t)l.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(h.doc);if(f.current!==d){f.current=d,le(h.doc,u,a,h.groups);return}let p=he(h.groups,a),_=JSON.stringify(p);_!==d&&(f.current=_,o.mutate({profile:t.name,entry:{...h,doc:p,updatedAt:new Date().toISOString()}}))})}function mi(e){let t=t=>{let n=f.safeParse(t);n.success&&e(n.data)},n=M()?.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 hi=5e3,gi=`[data-notification-session]`;function _i(e){let t=null,n=()=>{t=null},r=e=>e.target instanceof Element?e.target.closest(gi):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<hi&&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 vi=new Set,yi=e=>!!e&&vi.has(e);async function bi(e,t){let n=M()?.windows?.effects;if(!n)return!0;try{return await n.claimNotification({id:e,...t?{legacy:!0}:{}})}catch{return!1}}async function xi(e){let t=M()?.windows,n=t?.projects;if(!n||e.host)return!1;let r={profileId:(await F.fetchQuery({queryKey:[`project`,e.project],queryFn:()=>A(`GET`,`/api/projects/${e.project}`),staleTime:1e4})).project.profile_id,route:`/project/${e.project}/session/${e.session}`};return await t?.transfers?.focusPane?.({profileId:r.profileId,ref:{type:`terminal`,session:e.session}})||await n.route(r)||await lr({...r,kind:`navigate-project`}),!0}var Si=y.parse({});function Ci(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 wi(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 Ti(e){return e.title??e.agent_title??e.osc_title??e.id.slice(0,8)}function Ei(){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 Di(){let e=Lt(),t=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{let e=_i(document);return t.current=e,()=>{t.current=null,e.dispose()}},[]),(0,Y.useEffect)(()=>mi(t=>{t.host||xi(t).then(n=>{n||e(`/project/${t.project}/session/${t.session}`,{state:{notificationSession:t.session}})}).catch(J)}),[e]),Oi(t=>{e(`/project/${t.project_id}/session/${t.id}`,{state:{notificationSession:t.id}})},e=>t.current?.isInteracting(e.id)??!1)}function Oi(e,t=()=>document.hasFocus()){let n=ct(),r=(0,Y.useRef)(e);r.current=e;let i=(0,Y.useRef)(t);i.current=t;let a=ot(et().data)??`Puddle`,o=(0,Y.useRef)(a);o.current=a;let[s,c]=(0,Y.useState)(0);Sn(`shell`,s>0?`(${s}) ${a}`:a),(0,Y.useEffect)(()=>{let e=new Set;c(0);let t=!0,a=async e=>{if(!await bi(e.id??`${e.session}:${e.activity??`waiting`}`,!e.id)||!t)return;let a=wi(n,e.session);if(!a)try{a=(await lt(n)).find(t=>t.id===e.session)}catch{return}if(!t||!a)return;let s=a,c,l;try{let e=await n.fetchQuery({queryKey:[`project`,s.project_id],queryFn:()=>A(`GET`,`/api/projects/${s.project_id}`),staleTime:1e4});if(!t)return;l=e.project;let r=l.profile_id,i=await n.fetchQuery({queryKey:[`profile-settings`,r],queryFn:()=>A(`GET`,`/api/profiles/${r}/settings`),staleTime:1e4});c=y.catch(Si).parse(i.notifications??{})}catch{return}if(!t)return;let u=Ci({prefs:c,projectId:s.project_id,sessionFocused:i.current(s),permission:oe()});u.sound&&Ei(),u.desktop&&!yi(_()?.scope)&&await me({id:e.id?`puddle-event-${e.id}`:`puddle-agent-${s.id}`,title:e.content?.title??Ti(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,..._()?.notificationHost?{host:_().notificationHost}:{}}},()=>{t&&r.current(s)},{host:o.current,project:l})},s=q.onAgentNotification(e=>{a(e)}),l=q.onStatus(t=>{let r=e.has(t.session);t.status===`waiting_input`?e.add(t.session):e.delete(t.session),c(e.size),!(t.status!==`waiting_input`||r)&&n.fetchQuery({queryKey:[`version`],queryFn:()=>A(`GET`,`/api/version`),staleTime:1/0}).then(e=>{if(!(e.protocol.major>22||e.protocol.major===22&&e.protocol.minor>=3))return a({session:t.session,reason:`waiting_input`,activity:t.last_activity_at})}).catch(()=>{})});return()=>{t=!1,l(),s()}},[n])}function ki({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)(U,{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)(wn,{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)(U,{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)(kn,{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:I(`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)(bn,{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)(H,{variant:`ghost`,size:`sm`,onClick:a,children:`Cancel`}),(0,X.jsx)(H,{size:`sm`,disabled:!c.trim(),onClick:g,children:`Save`})]})]})}function Ai(){let e=sn(),t=j(),n=Et().id,r=Ke(t??void 0,n).data??[],i=Je().data??[],a=ut(),o=Ie(),s=Ue(),c=dn(),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(null);(0,Y.useEffect)(()=>K(`scratchpad.toggle`,fn),[]),(0,Y.useEffect)(()=>{e||(u(null),f(null),m(null))},[e]);let y=(0,Y.useMemo)(()=>[...new Set(r.flatMap(e=>e.tags))].sort((e,t)=>e.localeCompare(t)),[r]),b=(0,Y.useMemo)(()=>[...new Set(r.map(e=>e.agent_type).filter(e=>e!==null))],[r]),x=d!==null||p!==null,S=r.filter(e=>(d===null||e.tags.includes(d))&&(p===null||e.agent_type===p)),C=x?S:_??r,w=e=>{t&&(a.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}),u(null))},T=(e,t)=>{o.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}),u(null)},E=(e,t)=>{let n=_??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),v(o)},D=()=>{let e=h,t=_;if(g(null),v(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;o.mutate({id:e,position:a})},ee=e=>{navigator.clipboard?.writeText(e.body),L.success(`Copied to clipboard`)};return(0,X.jsxs)(ir,{open:e,onOpenChange:gn,children:[(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{asChild:!0,children:(0,X.jsx)(rr,{asChild:!0,children:(0,X.jsxs)(H,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,children:[(0,X.jsx)(jr,{}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Scratchpad`})]})})}),(0,X.jsx)(V,{children:`Scratchpad`})]}),(0,X.jsxs)(nr,{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:()=>u(l===`new`?null:`new`),className:I(qt,`ml-auto`),children:[(0,X.jsx)(Fn,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`New entry`})]})]}),(y.length>0||b.length>0)&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-5 pb-2`,children:[y.map(e=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>f(t=>t===e?null:e),className:I(`rounded-full px-2 py-0.5 text-2xs transition-colors`,d===e?`bg-action text-action-ink`:`bg-surface text-fg-secondary hover:text-fg`),children:e},e)),b.map(e=>(0,X.jsx)(`button`,{type:`button`,"aria-pressed":p===e,onClick:()=>m(t=>t===e?null:e),className:I(`rounded-md p-1 transition-colors`,p===e?`bg-action text-action-ink`:`text-fg-gold hover:bg-surface`),children:(0,X.jsx)(bn,{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)(Pn,{expanded:l===`new`,children:l===`new`&&(0,X.jsx)(`div`,{className:`px-3 py-2`,children:(0,X.jsx)(ki,{defaultScope:n?`project`:`profile`,allowProject:n!==void 0,agents:i,onSave:w,onCancel:()=>u(null)})})}),C.length===0&&l!==`new`&&(0,X.jsx)(`p`,{className:`px-3 py-3 text-sm text-fg-muted`,children:x?`Nothing matches this filter.`:`No entries yet — press + to add a reusable prompt or note.`}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:C.map(e=>(0,X.jsx)(`li`,{draggable:!x&&l===null,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,g(e.id)},onDragOver:t=>{h!==null&&(t.preventDefault(),h!==e.id&&E(h,e.id))},onDragEnd:D,className:I(`transition-opacity`,h===e.id&&`opacity-50`),children:(0,X.jsx)(Pn,{expanded:l===e.id,children:l===e.id?(0,X.jsx)(`div`,{className:`px-3 py-2`,children:(0,X.jsx)(ki,{initial:e,defaultScope:e.scope,allowProject:n!==void 0||e.scope===`project`,agents:i,onSave:t=>T(e.id,t),onCancel:()=>u(null)})}):(0,X.jsx)(ji,{entry:e,onInsert:c?()=>{c(e.body),gn(!1)}:null,onCopy:()=>ee(e),onEdit:()=>u(e.id),onDelete:()=>s.mutate(e.id)})})},e.id))})]})]})]})}function ji({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:I(`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:I(Kt,`text-danger`),children:`Delete`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:Kt,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)(bn,{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)(Jn,{label:`Scratchpad entry actions`,className:`ml-auto`,children:[t&&(0,X.jsx)(Mi,{icon:Or,label:`Insert into focused terminal`,onClick:t}),(0,X.jsx)(Mi,{icon:jn,label:`Copy`,onClick:n}),(0,X.jsx)(Mi,{icon:x,label:`Edit`,onClick:r}),(0,X.jsx)(Mi,{icon:In,label:`Delete`,onClick:()=>o(!0)})]})]})]})}function Mi({icon:e,label:t,onClick:n}){return(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,onClick:n,className:qt,children:[(0,X.jsx)(e,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,X.jsx)(V,{children:t})]})}var Ni=e=>({layout_tree:e.layout_tree,active_session:e.active_session});function Pi(e,t,n,r){if(t===`project`&&!n)throw Error(`Select a project before saving its windows`);let i=e.flatMap(({identity:e,snapshot:i,visibleProject:a})=>{if(t===`project`&&e.kind!==`host`&&e.projectId!==n)return[];let s=i;if(t===`project`&&e.kind===`host`){let e=_t({snapshot:i,buffers:[],views:{}},n,r,a??``).destination.snapshot;s={...i,layout_mode:`project`,layout_tree:null,active_session:null,project_layouts:{[n]:{...Ni(e),layout_ref:null}}}}let c=s.layout_mode===`project`?s.layout_tree:s.layout_tree??dt(s);return[o.parse({key:e.kind===`host`?`host`:e.kind===`project`?`project-${e.projectId}`:e.id,kind:e.kind,project_id:e.kind===`host`?t===`project`?n:a:e.projectId,layout_mode:s.layout_mode??`profile`,layout_tree:c,active_session:s.active_session,project_layouts:Object.fromEntries(Object.entries(s.project_layouts).map(([e,t])=>[e,Ni(t)]))})]}),a=l.parse({version:1,windows:i}),s=u(a,t,n);if(s)throw Error(s);let c=new Set,d=i.flatMap(e=>e.layout_mode===`project`?Object.values(e.project_layouts).map(e=>e.layout_tree):[e.layout_tree]).filter(e=>e!==null).map(e=>ft(e,e=>e.type===`editor`?!0:c.has(e.session)?!1:(c.add(e.session),!0))).filter(e=>pt(e).length!==0);return{window_arrangement:a,layout_tree:d.length?vt(xt(d.length===1?d[0]:mt(`row`,d))):null,active_session:i.flatMap(e=>e.layout_mode===`project`?Object.values(e.project_layouts).map(e=>e.active_session):[e.active_session]).find(e=>e!==null&&c.has(e))??null}}function Fi(e,t,n,r){let i=e.entries.filter(e=>e.open).map(e=>({identity:e.identity,snapshot:e.snapshot,visibleProject:/^\/project\/([0-9a-f]{10})/.exec(e.route??``)?.[1]??null})),a=i.find(e=>e.identity.kind===`host`);for(let n of e.entries){if(!n.returnedProject||n.open||n.identity.kind!==`project`)continue;if(!a)throw Error(`The host layout has not loaded`);if(!n.snapshot.layout_tree)continue;let e=a.snapshot;a.snapshot=gt({snapshot:e,buffers:[],views:{}},{snapshot:n.snapshot,buffers:[],views:{}},n.identity.projectId).snapshot,t===`project`&&e.layout_mode===`project`&&(a.snapshot={...a.snapshot,project_layouts:{...e.project_layouts,[n.identity.projectId]:a.snapshot.project_layouts[n.identity.projectId]}})}return Pi(i,t,n,r)}function Ii(e){return JSON.stringify(e.windows.map(e=>JSON.stringify({kind:e.kind,project:e.kind===`host`?null:e.project_id,mode:e.layout_mode,tree:B(e.layout_tree),slices:Object.entries(e.project_layouts).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,B(t.layout_tree)])})).sort())}function Li(e){if(e.window_arrangement)return e.window_arrangement;let t={layout_tree:e.layout_tree,active_session:e.active_session};return l.parse({version:1,windows:[{key:`host`,kind:`host`,project_id:e.project_id,layout_mode:e.scope===`project`?`project`:`profile`,...e.scope===`project`?{layout_tree:null,active_session:null}:t,project_layouts:e.scope===`project`?{[e.project_id]:t}:{}}]})}var Ri=new class{running=!1;uncertain=null;listeners=new Set;busy=()=>this.running;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});async apply(e,t){if(!e.apply||!e.observe)throw Error(`Update the desktop app to load window layouts`);if(this.running)throw Error(`A window layout is already loading`);this.running=!0,this.listeners.forEach(e=>e());try{if(this.uncertain){let t=await e.observe(this.uncertain);throw t.status!==`committed`&&t.status!==`cancelled`?Error(`The previous layout outcome is still unknown. Reopen the host window to recover before loading another layout.`):(this.uncertain=null,Error(`The previous layout was ${t.status}. Choose the desired layout again to load it.`))}this.uncertain={id:t.id,profileId:t.profileId};let n;try{n=await e.apply(t)}catch{n=await e.observe(this.uncertain)}return(n.status===`committed`||n.status===`cancelled`)&&(this.uncertain=null),n}finally{this.running=!1,this.listeners.forEach(e=>e())}}};function zi(e,t,n,i){let a=N(),o=a!==null,s=M()?.windows?.layouts,c=qe().data?.protocol,l=!!s?.apply&&!!s.observe&&r(c,{major:26,minor:17}),u=a?.identity.kind===`host`,d=yt(o&&u?e:null),f=(0,Y.useSyncExternalStore)(Ri.subscribe,Ri.busy),p=i===`profile`?``:i??(n?.scope===`project`?n.projectId:``),m=p?`project`:`profile`,h=Qe({queryKey:[`native-layout-capture`,a?.identity.id,e,m,p],enabled:o&&u&&l&&t&&!!e&&!!d?.loaded&&!f,retry:!1,staleTime:0,queryFn:async()=>{if(!s||!e||Me()!==e)throw Error(`The active profile changed`);let t=await lt(F),n=await s.capture({profileId:e,scope:m,...p?{projectId:p}:{}});if(Me()!==e)throw Error(`The active profile changed`);return Fi(n,m,p||null,new Map(t.map(e=>[e.id,e.project_id])))}}),g=d?.snapshot,_=(0,Y.useRef)(g);(0,Y.useEffect)(()=>{let e=_.current!==g;_.current=g,e&&o&&u&&l&&t&&g&&!f&&F.invalidateQueries({queryKey:[`native-layout-capture`,a.identity.id]})},[o,u,l,t,g,f,a]),(0,Y.useEffect)(()=>{if(!o||!u||!l||!t||f)return;let e=()=>{F.invalidateQueries({queryKey:[`native-layout-capture`,a.identity.id]})};window.addEventListener(`focus`,e);let n=M()?.onWindowFocusChange?.(t=>{t&&e()});return()=>{window.removeEventListener(`focus`,e),n?.()}},[o,u,l,t,f,a]);let v=o&&!l?`Window layouts require an updated desktop app and host (application 26.17 or later).`:h.error?.message??null;if(!o||!u||!l||!e||!d?.loaded)return{native:o,bridge:null,busy:f,error:v};let y=()=>{if(Me()!==e)throw Error(`The active profile changed`)};return{native:o,bridge:{native:!0,scope:m,projectId:p,layoutRef:p?d.snapshot.project_layouts[p]?.layout_ref??d.snapshot.layout_ref:d.snapshot.layout_ref,signature:h.error||h.isStale&&h.isFetching?``:h.data?Ii(h.data.window_arrangement):``,savedSignature:e=>Ii(Li(e)),capture:async()=>{y();let e=await h.refetch({throwOnError:!0});if(!e.data)throw Error(`The window layout could not be captured`);return y(),e.data},adopt:async t=>{y();let n=bt(e),r=n.get(),i=t.project_id?r.project_layouts[t.project_id]:void 0;n.update(i&&t.project_id?{project_layouts:{...r.project_layouts,[t.project_id]:{...i,layout_ref:t.id}}}:{layout_ref:t.id}),await n.flush()},apply:async t=>{y();let n=await Ri.apply(s,{id:crypto.randomUUID(),profileId:e,scope:t.scope,...t.project_id?{projectId:t.project_id}:{},arrangement:Li(t),layoutRef:t.id});if(n.status!==`committed`)throw Error(n.error??(n.status===`cancelled`?`The layout was cancelled; your previous windows remain available.`:`The layout outcome is not confirmed. Load again to check its recorded outcome.`));return n.error&&L.warning(n.error),!0}},busy:f||h.isFetching,error:v}}var Bi=g.parse({});function Vi(e,t){let[n,r]=(0,Y.useState)(null),i=(0,Y.useRef)({profileId:e,enabled:t});i.current={profileId:e,enabled:t};let a=tt(t).data,o=P(e??void 0,t&&e!==null).data;return(0,Y.useEffect)(()=>{if(!t||e===null){r(null);return}let n=!1,i;try{i=pn(sessionStorage.getItem(_n(e)))}catch{i={kind:`absent`}}if(i.kind===`present`){r(i.snapshot);return}return rt(e).then(e=>{n||r(e?e.ui_state:Bi)}).catch(()=>{n||r(Bi)}),()=>{n=!0}},[t,e]),(0,Y.useMemo)(()=>{if(!t||e===null||n===null)return null;let s=t=>{r(t),Ze(e,t).catch(e=>console.warn(`ui-state save failed: ${e.message}`));try{sessionStorage.setItem(_n(e),JSON.stringify(t))}catch(e){console.warn(`ui-state write failed: ${e.message}`)}},c=e=>{if(!a||!o)return!1;let{patch:t,projectBased:r}=ht(n,e,{alive:new Set(a.filter(e=>e.status!==`archived`).map(e=>e.id)),sessionProject:new Map(a.map(e=>[e.id,e.project_id])),projectIds:o.map(e=>e.id),currentProject:null}),i={...n,...t};return s(i),be().projectBasedLayout!==r&&ye({projectBasedLayout:r}),!0},l=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:l,capture:()=>({layout_tree:null,active_session:null}),apply:c}:{scope:`profile`,projectId:``,layoutRef:n.layout_ref,signature:B(n.layout_tree),slices:l,capture:()=>({layout_tree:n.layout_tree,active_session:n.active_session}),adopt:e=>{i.current.enabled&&i.current.profileId===e.profile_id&&s({...n,layout_ref:e.id})},apply:c}},[t,e,n,a,o])}var Hi=B(null);function Ui(){let e=un(),t=Lt(),n=j(),r=yn(),[i,a]=(0,Y.useState)(null),o=zi(n,e,r,i),s=Vi(n,!o.native&&e&&r===null),c=o.native?o.bridge:r??s,[l,u]=(0,Y.useState)(!1),d=(0,Y.useRef)(!1),f=l||o.busy,p=async e=>{if(!(d.current||o.busy)){d.current=!0,u(!0);try{await e()}catch(e){J(e)}finally{d.current=!1,u(!1)}}},m=Fe(n??void 0,void 0).data??[],h=P(n??void 0,e&&n!==null).data??[],g=nt(),_=Re(),v=Le(),[y,b]=(0,Y.useState)(``),[x,S]=(0,Y.useState)(!1),[C,w]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{let e=N()?.identity.kind;if(!e||e===`host`)return K(`layouts.toggle`,hn)},[]),(0,Y.useEffect)(()=>{e||(b(``),S(!1),w(null),a(null))},[e]);let T=c?.headless===!0,E=c===null||T?null:m.find(e=>e.id===c.layoutRef&&(!c.native||e.scope===c.scope&&(e.scope===`profile`||e.project_id===c.projectId)))??null,D=c!==null&&!T&&(E===null?c.signature!==Hi:(c.savedSignature?.(E)??B(E.layout_tree))!==c.signature),ee=e=>{let t=c?.slices?.[e];if(!t)return!1;let n=t.layoutRef===null?null:m.find(e=>e.id===t.layoutRef)??null;return n?B(n.layout_tree)!==t.signature:t.signature!==Hi},te=e=>c===null?!1:c.native?!k(e)||!c.signature||c.savedSignature?.(e)!==c.signature:e.scope===`profile`?c.scope===`profile`&&D:e.project_id===null?!1:c.scope===`project`?!T&&e.project_id===c.projectId?D:ee(e.project_id):D||ee(e.project_id),ne=e=>E!==null&&e.id===E.id,re=e=>(e===null?void 0:h.find(t=>t.id===e)?.name)??`Project`,O=c!==null&&!T&&c.scope===`project`?m.filter(e=>e.scope===`profile`||e.project_id===c.projectId):m,ie=[...O.some(e=>e.scope===`profile`)?[{key:`profile`,name:`Profile-wide`}]:[],...[...new Set(O.flatMap(e=>e.project_id===null?[]:[e.project_id]))].map(e=>({key:e,name:re(e)})).sort((e,t)=>e.name.localeCompare(t.name))],ae=C===null?O:C===`profile`?O.filter(e=>e.scope===`profile`):O.filter(e=>e.project_id===C),k=e=>c!==null&&e.scope===c.scope&&(c.scope===`profile`||e.project_id===c.projectId),oe=async e=>{c?.adopt?await c.adopt(e):await c?.apply(e)},se=async(e,t,r)=>{if(!c||!n)return;let i=await g.mutateAsync({profile_id:n,scope:c.scope,...c.scope===`project`?{project_id:c.projectId}:{},name:e,...t});r&&await oe(i)},ce=e=>p(async()=>{if(!c)return;let t=k(e)?e:m.find(t=>t.name===e.name&&k(t)),n=await c.capture();t?await oe(await _.mutateAsync({id:t.id,...n})):await se(e.name,n,!0)}),le=(e,t)=>p(async()=>{await se(t,{layout_tree:e.layout_tree,active_session:e.active_session,...k(e)&&e.window_arrangement?{window_arrangement:e.window_arrangement}:{}},!1)}),ue=e=>p(async()=>{if(c){if(!await c.apply(e)){L.error(`Workspace is still loading — try again in a moment`);return}!c.native&&e.project_id!==null&&e.project_id!==c.projectId&&t(`/project/${e.project_id}`),ln(!1)}});return(0,X.jsxs)(ir,{open:e,onOpenChange:ln,children:[(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{asChild:!0,children:(0,X.jsx)(rr,{asChild:!0,children:(0,X.jsxs)(H,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,children:[(0,X.jsx)(kr,{}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Layouts`})]})})}),(0,X.jsx)(V,{children:`Layouts`})]}),(0,X.jsxs)(nr,{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`}),c!==null&&!T&&(0,X.jsxs)(`button`,{type:`button`,disabled:f,onClick:()=>S(e=>!e),className:I(`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)(Fn,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Save the current layout as a new layout`})]})]}),o.native&&(0,X.jsxs)(`div`,{className:`px-5 pb-3`,children:[(0,X.jsxs)(Qt,{value:c?.scope===`project`?c.projectId:`profile`,onValueChange:a,disabled:f,children:[(0,X.jsx)(Yt,{"aria-label":`Save layout for`,className:`h-8 text-sm`,children:(0,X.jsx)(Jt,{})}),(0,X.jsxs)(Xt,{children:[(0,X.jsx)(Zt,{value:`profile`,children:`Profile-wide`}),h.map(e=>(0,X.jsx)(Zt,{value:e.id,children:e.name},e.id))]})]}),o.error&&(0,X.jsx)(`p`,{role:`status`,className:`pt-2 text-sm text-fg-muted`,children:o.error})]}),(0,X.jsx)(Pn,{expanded:c!==null&&!T&&(E===null||x),children:c===null?(0,X.jsx)(`p`,{className:`px-5 pb-3 text-sm text-fg-muted`,children:`Loading the profile’s layout state…`}):T?(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.`}):(E===null||x)&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 px-5 pb-3`,children:[E===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:c.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=y.trim();t&&p(async()=>{await se(t,await c.capture(),!0),b(``),S(!1)})},children:[(0,X.jsx)(U,{autoFocus:x,value:y,placeholder:E===null?`Name this layout…`:`Save as a new layout…`,spellCheck:!1,onChange:e=>b(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&S(!1)},className:`h-8 flex-1 text-sm`}),(0,X.jsx)(H,{size:`sm`,type:`submit`,disabled:f||!y.trim(),children:`Save`}),E!==null&&(0,X.jsx)(H,{variant:`ghost`,size:`sm`,onClick:()=>S(!1),children:`Cancel`})]})]})}),ie.length>1&&(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 px-5 pb-2`,children:ie.map(e=>(0,X.jsx)(Ki,{active:C===e.key,onClick:()=>w(t=>t===e.key?null:e.key),children:e.name},e.key))}),(0,X.jsxs)(`div`,{inert:f||void 0,"aria-busy":f,className:`no-scrollbar max-h-[60vh] overflow-y-auto px-2 pb-3`,children:[ae.length===0&&(0,X.jsx)(`p`,{className:`px-3 py-3 text-sm text-fg-muted`,children:C===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:ae.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(Wi,{layout:e,projectLabel:e.scope===`profile`?null:re(e.project_id),isCurrent:ne(e),dirty:D,loadable:c!==null&&!f,savable:c!==null&&!T&&!f,confirmBeforeLoad:te(e),overwrites:k(e),onLoad:()=>ue(e),onRename:t=>_.mutate({id:e.id,name:t}),onDelete:()=>v.mutate(e.id),onSaveAs:()=>ce(e),onDuplicate:t=>le(e,t)})},e.id))})]})]})]})}function Wi({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)},S=()=>{if(n){d();return}m(`save`)},C=n?r?`unsaved`:`active`:null;return(0,X.jsxs)(`div`,{onClick:e=>{e.target.closest(`button, input`)||y()},className:I(`rounded-md px-3 py-2.5 transition-colors`,i&&`cursor-pointer hover:bg-surface`),children:[h===null?(0,X.jsxs)(`p`,{className:I(`flex items-baseline gap-2 text-sm font-medium`,C===`active`?`text-success`:C===`unsaved`?`text-interrupted`:`text-fg`),children:[e.name,C!==null&&(0,X.jsx)(`span`,{className:`text-2xs font-normal`,children:C===`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)(U,{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)(H,{size:`sm`,type:`submit`,disabled:!_.trim(),children:h===`rename`?`Rename`:`Save`})]}),p===`save`?(0,X.jsx)(Gi,{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)(Gi,{question:`Delete this layout? This can’t be undone.`,verb:`Delete`,onConfirm:()=>{m(null),u()},onCancel:()=>m(null)}):p===`load`?(0,X.jsx)(Gi,{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)(Jn,{label:`Layout actions`,className:`ml-auto`,children:[a&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(qi,{icon:Mr,label:n?`Save`:`Save the current layout as “${e.name}”`,onClick:S}),(0,X.jsx)(qi,{icon:jn,label:`Duplicate`,onClick:()=>b(`duplicate`)})]}),(0,X.jsx)(qi,{icon:x,label:`Rename`,onClick:()=>b(`rename`)}),(0,X.jsx)(qi,{icon:In,label:`Delete`,onClick:()=>m(`delete`)})]})]})]})}function Gi({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:I(Kt,`text-danger`),children:t}),(0,X.jsx)(`button`,{type:`button`,onClick:r,className:Kt,children:`Cancel`})]})}function Ki({active:e,onClick:t,children:n}){return(0,X.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:t,className:I(`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 qi({icon:e,label:t,onClick:n}){return(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,onClick:n,className:qt,children:[(0,X.jsx)(e,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,X.jsx)(V,{children:t})]})}var $=M()!==void 0&&/Mac/.test(navigator.platform),Ji=(0,Y.lazy)(()=>De(()=>import(`./SettingsDialog-DBUHpb9S.js`).then(e=>({default:e.SettingsDialog})),__vite__mapDeps([16,1,2,17,18,19,3,20,7,5,6,8,9,10,21,22,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,50,51,52])));function Yi(){let e=ct();(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=q.onStatus(e=>t(t=>t.id===e.session?{...t,status:e.status,last_activity_at:e.last_activity_at}:t)),r=q.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=q.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=q.onSessionsChanged(e=>a(e.project_ids)),s=q.onSessionSwitched(e=>a([e.target_project]));return()=>{n(),r(),i(),o(),s()}},[e])}function Xi(){let e=j(),t=Ve(e??``),n=qe().data?.protocol,r=E(),i=et(),o=He(),[s,c]=(0,Y.useState)(!1),l=ot(i.data),u=e=>{c(!1);let t=e.trim();t!==l&&o.mutate({displayName:t===i.data?.hostname?``:t},{onError:e=>J(e)})},d=(0,X.jsx)(D,{icon:r.icon}),f=I(`host-identity flex h-full shrink-0 items-center gap-2 px-4`,$&&`[-webkit-app-region:no-drag]`),p=`truncate font-sans text-xs font-normal`;return s&&l!==void 0?(0,X.jsxs)(`div`,{className:f,children:[d,(0,X.jsx)(en,{initial:i.data?.displayName??l,maxLength:64,className:I(p,`w-40`),onCommit:u,onCancel:()=>c(!1)})]}):(0,X.jsxs)(Dt,{children:[(0,X.jsx)(At,{asChild:!0,children:(0,X.jsxs)(zt,{to:`/`,className:I(f,`hover:bg-elevated focus-visible:bg-elevated`),title:`All projects`,children:[d,l!==void 0&&(0,X.jsx)(`span`,{className:p,...rn(()=>c(!0)),children:l})]})}),(0,X.jsx)(Fr,{kind:`host`,colour:r.colour,onRename:()=>c(!0),onColour:n=>{e&&t.mutate({hostColour:n},{onError:J})},pending:t.isPending||!e,custom:a(n),onUpdates:()=>G(`host`)})]})}function Zi(){let e=Et(),t=Vn(`palette.toggle`),n=We(e.id).data?.project,r=n!==void 0&&n.id===e.id?n.name:void 0;return(0,X.jsx)(`button`,{type:`button`,onClick:on,className:I(`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:I(`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&&b(n?.colour)),style:r?C(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 Qi(){let e=E(),{fullScreen:t,animate:n}=ke(),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`)||on())},className:I(`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)(Xi,{})}),(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`h-5 w-px bg-border`}),(0,X.jsx)(Zi,{}),(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`h-5 w-px bg-border`}),(0,X.jsxs)(Jn,{label:`Workspace controls`,className:I(`shell-header-actions h-full justify-self-end rounded-none!`,$&&`[-webkit-app-region:no-drag]`),children:[(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{asChild:!0,children:(0,X.jsxs)(H,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,onClick:()=>G(),children:[(0,X.jsx)(Nr,{}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Settings`})]})}),(0,X.jsx)(V,{children:`Settings`})]}),(0,X.jsx)(Ui,{}),(0,X.jsx)(Ai,{}),(0,X.jsx)(ei,{})]})]})}function $i(){let e=vn();Yi(),pi(),Di();let{handler:t}=xn(),n=j(),{pathname:r}=St(),[a,o]=(0,Y.useState)(!1),s=qe(),c=s.data!==void 0&&i(s.data.protocol);return(0,Y.useEffect)(()=>{if(!c)return;let e=()=>{let e=Se();q.reportTheme(e(`--text-primary`),e(`--bg-base`))};return e(),we(e)},[c]),(0,X.jsxs)(`div`,{ref:e.ref,"data-project-window-drop-target":e.enabled||void 0,className:`relative flex h-screen flex-col overflow-hidden overscroll-y-none bg-ground`,children:[e.active&&(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-1.5 z-50 flex items-center justify-center rounded-[var(--ui-surface-radius)] bg-accent/20`,children:(0,X.jsx)(`span`,{role:`status`,className:`rounded-[var(--ui-radius)] bg-surface px-4 py-2 text-sm text-fg shadow-lg`,children:`Return project here`})}),(0,X.jsx)(ne,{}),(0,X.jsx)(ge,{}),(0,X.jsx)(Ir,{}),(!N()||N()?.identity.kind===`host`)&&(0,X.jsx)(Qi,{}),(0,X.jsx)(`main`,{className:`min-h-0 flex-1`,children:(0,X.jsx)(dr,{resetOn:r,scope:r.startsWith(`/project/`)?`workspace`:`view`,children:(0,X.jsx)(jt,{className:`h-full`,motionKey:r.startsWith(`/project/`)?`workspace`:r,children:(0,X.jsx)(Ot,{})})})}),(0,X.jsx)(Lr,{}),(0,X.jsx)(Yr,{}),(0,X.jsx)(ii,{}),(0,X.jsx)(ci,{}),(0,X.jsx)(ui,{}),(0,X.jsx)(fi,{}),(0,X.jsx)(Wr,{onNewSession:t??void 0,onNewProject:()=>o(!0)}),n!==null&&(0,X.jsx)(Mn,{profileId:n,open:a,onOpenChange:o}),(0,X.jsx)(Y.Suspense,{fallback:null,children:(0,X.jsx)(Ji,{})}),(0,X.jsx)(qr,{})]})}function ea(){return(0,X.jsx)(cn,{children:(0,X.jsx)($i,{})})}function ta({children:e}){let t=(0,Y.useContext)(wt),n=St(),r=j(),i=M()?.windows?.projects,a=N(),o=(0,Y.useRef)(null),[,s]=(0,Y.useState)(0),c=(0,Y.useRef)(0),l=`${r}:${n.pathname}`,u=a?.identity,d=u&&u.kind!==`host`&&(n.pathname===`/project/${u.projectId}`||n.pathname.startsWith(`/project/${u.projectId}/session/`));(a?.stagingTransfer||a?.stagingArrangement||d)&&(o.current=l);let f=(0,Y.useMemo)(()=>{if(!i||!r)return t;let e=e=>(...a)=>{let[s]=a,l=(typeof s==`string`?s:Ct(s)).split(/[?#]/)[0]||n.pathname;if(!h.safeParse(l).success){t.navigator[e](...a);return}let u=++c.current;i.route({profileId:r,route:l}).then(n=>{u!==c.current||n||(o.current=`${r}:${l}`,t.navigator[e](...a))}).catch(J)};return{...t,navigator:{...t.navigator,push:e(`push`),replace:e(`replace`)}}},[i,r,t,n.pathname]);return(0,Y.useEffect)(()=>{if(!i||!r||o.current===l)return;let e=!0,t=()=>{let e=a?.identity,t=e&&e.kind!==`host`?`/project/${e.projectId}`:`/`;o.current=`${r}:${t}`,cr(t),s(e=>e+1)};return i.route({profileId:r,route:n.pathname}).then(n=>{e&&(n?t():(o.current=l,s(e=>e+1)))}).catch(n=>{e&&(J(n),t())}),()=>{e=!1}},[i,r,l,n.pathname,a]),i&&r&&o.current!==l?null:(0,X.jsx)(wt.Provider,{value:f,children:e})}var na=(0,Y.lazy)(()=>De(()=>import(`./Dashboard-DWwOy6bQ.js`).then(e=>({default:e.Dashboard})),__vite__mapDeps([53,1,2,17,18,19,3,20,7,5,6,8,9,10,21,22,27,28,25,26,54,55,35,56,42,57,37,38,33,39,40,41,58,59,48,32]))),ra=(0,Y.lazy)(()=>De(()=>import(`./Workspace-D_NxUGYW.js`).then(e=>({default:e.Workspace})),__vite__mapDeps([60,1,2,6,17,18,19,3,20,7,5,8,9,10,21,22,35,36,25,26,27,61,28,62,33,42,56,46,47,37,38,39,40,41,54,55,30,31,63,29,57,58,64,65,66,32,44,67,68,69,70,71,72,51,73,74])));function ia(){let e=j(),t=ze(),n=N()?.identity,r=n!==void 0&&n.kind!==`host`,i=e!==null&&t.data!==void 0&&!r&&!t.data.some(t=>t.id===e),a=e===null||i;return(0,X.jsx)(jt,{className:`h-screen`,motionKey:a?`profiles`:`cockpit`,children:a?(0,X.jsx)(Pr,{}):(0,X.jsx)(It,{useTransitions:!1,children:(0,X.jsx)(ta,{children:(0,X.jsx)(Y.Suspense,{fallback:null,children:(0,X.jsx)(Tt,{children:(0,X.jsxs)(Rt,{element:(0,X.jsx)(ea,{}),children:[(0,X.jsx)(Rt,{path:`/`,element:(0,X.jsx)(na,{})}),(0,X.jsx)(Rt,{path:`/project/:id`,element:(0,X.jsx)(ra,{})}),(0,X.jsx)(Rt,{path:`/project/:id/session/:sid`,element:(0,X.jsx)(ra,{})})]})})})})})})}function aa(){let e=(0,Y.useSyncExternalStore)(_e.subscribe,_e.get);return(0,X.jsx)(at,{client:F,children:(0,X.jsxs)(nn,{delayDuration:300,children:[(0,X.jsx)(Dr,{}),(0,X.jsx)(dr,{scope:`app`,children:e?window.location.pathname.startsWith(`/forward/`)?(0,X.jsx)(ur,{}):(0,X.jsx)(Oe,{children:(0,X.jsx)(ia,{})}):(0,X.jsx)(pr,{})}),(0,X.jsx)(fr,{})]})})}export{aa as App};
|
|
@@ -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{n as r}from"./api--n1Ha6tG.js";import{it as i,nt as a,rt as o}from"./queries-DnuokC1N.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=a(750);function d(e){return i({queryKey:[`compilation-capabilities`],queryFn:()=>r(`GET`,`/api/compilation/capabilities`),enabled:e,staleTime:3e4,refetchOnWindowFocus:!0})}function f(){return o({mutationFn:e=>r(`POST`,`/api/compilation/run`,e)})}function p(e){return r(`PUT`,`/api/compilation/mode`,e)}function m(e){return r(`POST`,`/api/compilation/status`,e)}function h(e,t){return i({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 i({queryKey:[`compilation-settings`,e],queryFn:()=>r(`POST`,`/api/compilation/settings`,e),enabled:e!==null,staleTime:3e4})}function _(e){return r(`PUT`,`/api/compilation/settings`,e)}function v(e){return i({queryKey:[`compilation-defaults`,e],queryFn:()=>r(`POST`,`/api/compilation/defaults`,e),enabled:e!==null,staleTime:3e4})}function y(e){return r(`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=n();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{s as n,y as r}from"./protocol-support-BUdL5Q-x.js";import{k as i}from"./local-store-8IcyY3pd.js";import{a,c as o,f as s,i as c,l,o as u,p as d,t as f,u as p}from"./LazyTerminal-B0GmOiTE.js";import{t as m}from"./jsx-runtime-By8HlURe.js";import{i as h}from"./profile-store-CarO9MCP.js";import{L as g,R as _,V as v,W as y,Y as b,b as x,et as S}from"./queries-DnuokC1N.js";import{a as C,f as w,i as T,m as E,o as D,r as O,s as k,y as A}from"./session-order-CCDTBSiH.js";import{t as j}from"./utils-B6KiDbIe.js";import{a as M,o as N,r as P,s as ee,t as te}from"./dialog-CTN-Lln6.js";import{t as F}from"./button-D-qeQvl5.js";import{n as I,t as L}from"./chevron-right-DUkOv15w.js";import{i as R,n as z,r as B,t as V}from"./use-arrangement-ready-D18CpR8E.js";import{n as H,r as U,t as W}from"./expanding-content-BUkS1Qk4.js";import{g as G,t as K}from"./ws-DH0dKRnO.js";import{n as q}from"./errors-DWF9D4n6.js";var J=e(t(),1),Y=m(),X=!1;function ne(){let[e,t]=(0,J.useState)(X),[n,r]=(0,J.useState)(null);(0,J.useEffect)(()=>{if(!e)return;let t=!1;return K.spawnShell(i).then(e=>{t||r(e)}),()=>{t=!0}},[e]);let a=()=>{X=!1,t(!1),r(null)};return{open:e,term:n,toggle:()=>{e?(n&&K.killShell(i,n),a()):(X=!0,t(!0))},onExit:a}}function re({term:e,onExit:t}){return(0,Y.jsx)(`div`,{className:`h-72 shrink-0 pb-6`,children:(0,Y.jsx)(`div`,{className:`mx-auto size-full max-w-4xl px-6`,children:(0,Y.jsx)(`div`,{className:`workspace-surface island-outline size-full bg-surface p-1`,children:(0,Y.jsx)(`div`,{className:`size-full overflow-hidden rounded-[var(--ui-radius)] bg-ground p-1`,children:e!==null&&(0,Y.jsx)(f,{stream:`home`,term:e,onExit:t})})})})})}var ie=`group block w-full island-outline rounded-[var(--ui-surface-radius)] bg-surface p-4 text-left transition-colors hover:bg-elevated`,ae=[{status:`running`,colour:`bg-running`},{status:`waiting_input`,colour:`bg-waiting`},{status:`interrupted`,colour:`bg-interrupted`}];function oe({project:e,repoPath:t,sessions:n}){let r=n.filter(e=>e.status!==`archived`);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h2`,{style:u(e.colour),className:j(`truncate pr-16 text-base font-semibold`,a(e.colour)||`text-fg group-hover:text-accent`),children:e.name}),(0,Y.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:t??`…`}),(0,Y.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3 text-2xs text-fg-muted tabular-nums`,children:[(0,Y.jsxs)(`span`,{children:[r.length,` session`,r.length===1?``:`s`]}),ae.map(({status:e,colour:t})=>{let n=r.filter(t=>t.status===e).length;return n>0?(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:`size-1.5 rounded-full ${t}`}),n,` `,e.replace(`_`,` `)]},e):null})]})]})}function Z({icon:e,label:t,onClick:n}){return(0,Y.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,Y.jsx)(e,{className:`size-4`})})}function Q({project:e,repoPath:t,draggable:i,dragging:l,onDragStart:f,onDragEnd:m,onDragOver:h}){let g=_(),v=x().data?.protocol,y=r(v),b=S(e.id),[T,E]=(0,J.useState)(!1),[O,L]=(0,J.useState)(e.name),[V,H]=(0,J.useState)(d(e)),[U,W]=(0,J.useState)(e.colour??null),G=t=>g.mutate({id:e.id,archived:t},{onError:e=>q(e)}),K=()=>{L(e.name),W(e.colour??null),H(d(e)),E(!0)},X=()=>{let t=O.trim(),n=s(V);if(!t){E(!1);return}let r={...t===e.name?{}:{name:t},...n&&n!==d(e)?{abbrev:n}:{},...y&&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=>q(e)})};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(C,{children:[(0,Y.jsx)(w,{asChild:!0,children:(0,Y.jsxs)(`div`,{draggable:i,onDragStart:f,onDragEnd:m,onDragOver:h,className:j(`group relative transition-opacity`,l&&`opacity-50`),children:[(0,Y.jsx)(A,{draggable:!1,to:`/project/${e.id}`,className:ie,children:(0,Y.jsx)(oe,{project:e,repoPath:t,sessions:b.data??[]})}),(0,Y.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,Y.jsx)(Z,{icon:R,label:`Reopen project`,onClick:()=>G(!1)}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Z,{icon:o,label:`Edit project`,onClick:K}),(0,Y.jsx)(Z,{icon:B,label:`Archive project`,onClick:()=>G(!0)})]})})]})}),(0,Y.jsxs)(D,{children:[(0,Y.jsx)(z,{projectId:e.id}),e.archived?(0,Y.jsxs)(k,{onSelect:()=>G(!1),children:[(0,Y.jsx)(R,{}),` Reopen`]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(k,{onSelect:K,children:[(0,Y.jsx)(o,{}),` Edit`]}),(0,Y.jsxs)(k,{onSelect:()=>G(!0),children:[(0,Y.jsx)(B,{}),` Archive`]})]})]})]}),(0,Y.jsx)(te,{open:T,onOpenChange:E,children:(0,Y.jsxs)(P,{children:[(0,Y.jsx)(N,{children:(0,Y.jsx)(ee,{children:`Edit project`})}),(0,Y.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),X()},children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(p,{htmlFor:`project-name-${e.id}`,children:`Name`}),(0,Y.jsx)(I,{id:`project-name-${e.id}`,value:O,className:a(U),style:u(U),onChange:e=>L(e.target.value),autoFocus:!0})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(p,{htmlFor:`project-abbrev-${e.id}`,children:`Abbreviation`}),(0,Y.jsx)(I,{id:`project-abbrev-${e.id}`,maxLength:5,value:V,onChange:e=>H(s(e.target.value)),className:`w-24 uppercase`}),(0,Y.jsxs)(`p`,{className:`text-2xs text-fg-muted`,children:[`Up to `,5,` characters — the label on the collapsed sidebar rail.`]})]}),y&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-fg-secondary`,children:`Colour`}),(0,Y.jsx)(c,{value:U,onChange:W,onCustomChange:n(v)?W:void 0,label:`Project colour`})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(p,{className:`text-fg-muted`,children:`Path`}),(0,Y.jsx)(`p`,{className:`truncate text-2xs text-fg-muted`,children:t??`…`})]}),(0,Y.jsxs)(M,{children:[(0,Y.jsx)(F,{type:`button`,variant:`ghost`,onClick:()=>E(!1),children:`Cancel`}),(0,Y.jsx)(F,{type:`submit`,disabled:!O.trim()||g.isPending,children:`Save`})]})]})]})})]})}function $({icon:e,label:t,hint:n,onClick:r}){return(0,Y.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,Y.jsxs)(`h2`,{className:`flex items-center gap-2 truncate text-base font-semibold text-fg group-hover:text-accent`,children:[(0,Y.jsx)(e,{className:`size-4 shrink-0`}),t]}),(0,Y.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:n})]})}function se(){let e=h();V(e,!0);let t=y(e??void 0),n=b(),r=v(e??void 0),i=g(e??``),[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(null),[u,d]=(0,J.useState)(!1),f=ne(),p=G(`palette.toggle`),m=e=>n.data?.find(t=>t.id===e)?.path,_=t.data??[],x=r.data?.projectOrder??[],S=O(_.filter(e=>!e.archived),x),C=_.filter(e=>e.archived),w=(e,t)=>{e!==t&&i.mutate({projectOrder:T(S.map(e=>e.id),e,t)})};return(0,Y.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Y.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[_.length===0&&(0,Y.jsxs)(`div`,{className:`mb-8 mt-16 flex flex-col items-center gap-3 text-center`,children:[(0,Y.jsx)(l,{className:`size-8 text-fg-muted`}),(0,Y.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[`No projects yet — open one below, or press `,p,`.`]})]}),(0,Y.jsxs)(`div`,{className:`grid auto-rows-fr grid-cols-1 gap-3 sm:grid-cols-2`,children:[S.map(e=>(0,Y.jsx)(Q,{project:e,repoPath:m(e.repo_id),draggable:!0,dragging:s===e.id,onDragStart:()=>c(e.id),onDragEnd:()=>c(null),onDragOver:t=>{t.preventDefault(),s&&s!==e.id&&w(s,e.id)}},e.id)),(0,Y.jsx)($,{icon:U,label:`Open project`,hint:`Point at a repository on this host`,onClick:()=>o(!0)}),(0,Y.jsx)($,{icon:E,label:f.open?`Close terminal`:`Open terminal`,hint:f.open?`End the shell below`:`A shell at ~ for cloning repositories`,onClick:f.toggle})]}),C.length>0&&(0,Y.jsxs)(`div`,{className:`mt-6`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>d(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,Y.jsx)(L,{className:j(`size-3 transition-transform`,u&&`rotate-90`)}),(0,Y.jsx)(B,{className:`size-3`}),(0,Y.jsx)(`span`,{children:`Archived`}),(0,Y.jsx)(`span`,{className:`tabular-nums`,children:C.length})]}),u&&(0,Y.jsx)(`div`,{className:`mt-2 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:C.map(e=>(0,Y.jsx)(Q,{project:e,repoPath:m(e.repo_id),draggable:!1,dragging:!1,onDragStart:()=>{},onDragEnd:()=>{},onDragOver:()=>{}},e.id))})]})]})}),(0,Y.jsx)(W,{expanded:f.open,children:f.open&&(0,Y.jsx)(re,{term:f.term,onExit:f.onExit})}),e!==null&&(0,Y.jsx)(H,{profileId:e,open:a,onOpenChange:o})]})}export{se as Dashboard};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{n}from"./local-store-8IcyY3pd.js";import{t as r}from"./jsx-runtime-By8HlURe.js";import{n as i,r as a,t as o}from"./api--n1Ha6tG.js";import{at as s,dt as c,ft as l,it as u,lt as d,nt as f,rt as p,st as m}from"./queries-DnuokC1N.js";import{t as h}from"./utils-B6KiDbIe.js";import{C as ee,E as g,T as te,g as _,y as ne}from"./dialog-CTN-Lln6.js";import{n as re}from"./dist-BOS6OKSE.js";import{o as ie}from"./x-CbfJFzGo.js";import{c as ae,l as oe,s as v}from"./dist-NuV8HBEc.js";import{t as se}from"./button-D-qeQvl5.js";import{r as ce,t as le}from"./chevron-right-DUkOv15w.js";import{t as y}from"./createLucideIcon-DyMAgLa3.js";import{_ as b,a as ue,c as de,d as fe,f as pe,g as me,h as he,i as ge,l as _e,m as ve,n as ye,o as be,p as xe,r as Se,s as Ce,t as we,u as Te}from"./dist-BcrNV8NP.js";import{t as Ee}from"./control-tray-CjoJunx1.js";var De=class extends d{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,u=n.fetchMeta?.fetchMore?.direction,d=o&&u===`forward`,f=i&&u===`forward`,p=o&&u===`backward`,m=i&&u===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:c(t,n.data),hasPreviousPage:l(t,n.data),isFetchNextPageError:d,isFetchingNextPage:f,isFetchPreviousPageError:p,isFetchingPreviousPage:m,isRefetchError:s&&!d&&!p,isRefetching:a&&!f&&!m}}};function Oe(e,t){return s(e,De,t)}var ke=y(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Ae=y(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),je=y(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),Me=y(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),Ne=y(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),Pe=y(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]);function x(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);try{r.href=n,r.download=t,document.body.appendChild(r),r.click()}finally{r.remove(),setTimeout(()=>URL.revokeObjectURL(n),6e4)}}var Fe=50;function S(e){return e===void 0?``:`&root=${encodeURIComponent(e)}`}function C(e){return e?{placeholderData:e=>e}:{}}function Ie(e,t,n){let r=e!==void 0;return u({queryKey:n===void 0?[`wt-tree`,e,t]:[`wt-tree`,e,t,n],queryFn:()=>i(`GET`,`/api/worktrees/${e}/tree?path=${encodeURIComponent(t)}${S(n)}`),enabled:r,...C(r)})}function Le(e,t,n){let r=n?.root;return u({queryKey:r===void 0?[`wt-file`,e,t]:[`wt-file`,e,t,r],queryFn:()=>i(`GET`,`/api/worktrees/${e}/file?path=${encodeURIComponent(t)}${S(r)}`),enabled:e!==void 0&&(n?.enabled??!0),...n?.live===!0?{refetchInterval:f(3e3),refetchOnWindowFocus:!0}:{}})}function Re(e,t){let n=m();return p({mutationFn:({path:n,...r})=>i(`PUT`,`/api/worktrees/${e}/file?path=${encodeURIComponent(n)}${S(t)}`,r),onSuccess:(r,{path:i})=>{n.invalidateQueries({queryKey:t===void 0?[`wt-file`,e,i]:[`wt-file`,e,i,t]}),n.invalidateQueries({queryKey:[`wt-diff`,e]})}})}function ze(e,t){let n=t?.against??`base`,r=t?.area,a=t?.root,o=e!==void 0&&(t?.enabled??!0);return u({queryKey:a===void 0?[`wt-diff`,e,n,r]:[`wt-diff`,e,n,r,a],queryFn:()=>{let t=r===void 0?``:`&area=${r}`;return i(`GET`,`/api/worktrees/${e}/diff?against=${n}${t}${S(a)}`)},enabled:o,refetchInterval:f(1e4),refetchOnWindowFocus:!0,...C(o)})}function Be(e,t){let n=t?.root,r=e!==void 0&&(t?.enabled??!0);return u({queryKey:n===void 0?[`git-repositories`,e]:[`git-repositories`,e,n],queryFn:()=>i(`GET`,`/api/worktrees/${e}/git-repositories${w(n)}`),enabled:r,refetchInterval:f(1e4),refetchOnWindowFocus:!0,...C(r)})}function Ve(e,t,n){let r=n?.root,a=e!==void 0&&(n?.enabled??!0);return u({queryKey:[`git-original`,e,t,r],queryFn:()=>i(`GET`,`/api/worktrees/${e}/git-original?path=${encodeURIComponent(t)}${S(r)}`),enabled:a,refetchInterval:f(1e4),refetchOnWindowFocus:!0})}function He(e,t,n){let r=n?.root;return u({queryKey:[`git-index-file`,e,t,r],queryFn:()=>i(`GET`,`/api/worktrees/${e}/index-file?path=${encodeURIComponent(t)}${S(r)}`),enabled:e!==void 0&&(n?.enabled??!0)})}function Ue(e,t){let n=m();return p({mutationFn:({action:n,...r})=>i(`POST`,`/api/worktrees/${e}/git-${n}${w(t)}`,r),onSuccess:(t,r)=>{r.action===`restore`&&(n.invalidateQueries({queryKey:[`wt-file`,e]}),n.invalidateQueries({queryKey:[`wt-tree`,e]})),n.invalidateQueries({queryKey:[`git-repositories`,e]}),n.invalidateQueries({queryKey:[`wt-git-status`,e]}),n.invalidateQueries({queryKey:[`wt-diff`,e]}),n.invalidateQueries({queryKey:[`wt-log`,e]}),n.invalidateQueries({queryKey:[`wt-show`,e]}),n.invalidateQueries({queryKey:[`git-original`,e]}),n.invalidateQueries({queryKey:[`git-index-file`,e]})}})}function We(e,t){let n=t?.root,r=e!==void 0&&(t?.enabled??!0);return u({queryKey:n===void 0?[`wt-git-status`,e]:[`wt-git-status`,e,n],queryFn:()=>i(`GET`,`/api/worktrees/${e}/git-status${w(n)}`),enabled:r,refetchInterval:f(1e4),refetchOnWindowFocus:!0,...C(r)})}function w(e){return e===void 0?``:`?root=${encodeURIComponent(e)}`}function Ge(e,t,n,r){return i(`POST`,`/api/worktrees/${e}/create${w(r)}`,{path:t,kind:n})}function Ke(e,t,n,r){return i(`POST`,`/api/worktrees/${e}/rename${w(r)}`,{from:t,to:n})}function qe(e,t,n,r){return i(`POST`,`/api/worktrees/${e}/copy${w(r)}`,{from:t,to:n})}function Je(e,t,n){return i(`POST`,`/api/worktrees/${e}/transfer${w(n)}`,t)}function Ye(e,t,n){return i(`POST`,`/api/worktrees/${e}/delete${w(n)}`,{path:t})}function Xe(e,t,n){let{query:r,regex:a,caseSensitive:o,wholeWord:s}=t;return u({queryKey:[`wt-search`,e,r,a,o,s,n],queryFn:()=>{let t=new URLSearchParams({q:r});return a&&t.set(`regex`,`1`),o&&t.set(`case`,`1`),s&&t.set(`word`,`1`),n!==void 0&&t.set(`root`,n),i(`GET`,`/api/worktrees/${e}/search?${t.toString()}`)},enabled:e!==void 0&&r.length>0,staleTime:2e3})}function Ze(e,t,n,r){let a=r?.root;return u({queryKey:[`wt-file-at`,e,t,n,a],queryFn:()=>i(`GET`,`/api/worktrees/${e}/file-at?ref=${encodeURIComponent(t)}&path=${encodeURIComponent(n)}${S(a)}`),enabled:e!==void 0&&(r?.enabled??!0),staleTime:1/0})}function Qe(e,t){let n=t?.root,r=e!==void 0&&(t?.enabled??!0);return Oe({queryKey:n===void 0?[`wt-log`,e]:[`wt-log`,e,n],queryFn:({pageParam:t})=>i(`GET`,`/api/worktrees/${e}/log?limit=${Fe}&skip=${t}${S(n)}`),initialPageParam:0,getNextPageParam:(e,t)=>e.has_more?t.length*Fe:void 0,enabled:r,...C(r)})}function $e(e,t,n){return u({queryKey:n===void 0?[`wt-show`,e,t]:[`wt-show`,e,t,n],queryFn:()=>i(`GET`,`/api/worktrees/${e}/show/${t}${w(n)}`),enabled:e!==void 0&&t!==void 0,staleTime:1/0})}var et=64*1024*1024;function tt(e,t){let n=[],r=[],i=0;for(let a of e)r.length>0&&i+a.size>t&&(n.push(r),r=[],i=0),r.push(a),i+=a.size;return r.length>0&&n.push(r),n}async function nt(e,t,n,r){let i=[];for(let o of tt(n,et)){let n=new FormData;for(let e of o)n.append(`files`,e,e.name);let s=await a(`POST`,`/api/worktrees/${e}/upload?dir=${encodeURIComponent(t)}${S(r)}`,{body:n});i.push(...(await s.json()).files)}return{files:i}}function rt(e,t){if(!e)return t;let n=/filename\*=UTF-8''([^;]+)/i.exec(e);if(n?.[1])try{return decodeURIComponent(n[1])}catch{return t}return/filename="?([^"; ]+)"?/i.exec(e)?.[1]??t}async function it(e,t,n){let r=await a(`GET`,`/api/worktrees/${e}/download?path=${encodeURIComponent(t)}${S(n)}`),i=await r.blob(),o=t.split(`/`).filter(Boolean).pop()??`worktree`;x(i,rt(r.headers.get(`content-disposition`),o))}var T=new Map,E=new Map,D=new Map,O=new Set,at=1;function ot(e){for(let t of E.get(e)??[])t();for(let e of O)e()}function k(e,t){T.set(e,t),ot(e)}function st(e,t){t&&D.set(e,{...t,scope:n(`conflicts`)});let r={phase:`unresolved`,revision:at++};return k(e,r),r}function ct(e){let t=T.get(e);return!t||t.phase!==`unresolved`&&t.phase!==`load-error`?null:(k(e,{phase:`loading`,revision:t.revision}),t.revision)}function lt(e,t,n,r){let i=T.get(e);return!i||i.phase!==`loading`||i.revision!==t?!1:(k(e,{phase:`opening`,revision:t,content:n,mtimeMs:r}),!0)}function ut(e,t){let n=T.get(e);return!n||n.phase!==`opening`||n.revision!==t?!1:(k(e,{...n,phase:`comparing`}),!0)}function dt(e,t,n){let r=T.get(e);return!r||r.phase!==`loading`||r.revision!==t?!1:(k(e,{phase:`load-error`,revision:t,message:n}),!0)}function ft(e,t){return t&&e?.phase===`unresolved`}function pt(e){return e?.phase===`comparing`?e.mtimeMs:void 0}function mt(e){return e?.phase===`loading`||e?.phase===`load-error`||e?.phase===`opening`}function ht(e){return e.phase===`opening`||e.phase===`comparing`}function gt(e){T.delete(e)&&(D.delete(e),ot(e))}function _t(e){return O.add(e),()=>O.delete(e)}function vt(e,t){for(let r of D.values())if(r.scope===n(`conflicts`)&&!(r.session!==e.session||r.root!==e.root)&&(r.path===e.path||t.includes(r.path.split(`.`).pop()?.toLowerCase()??``)))return!0;return!1}function yt(e){return T.get(e)??null}function bt(e,t){let n=E.get(e);return n||(n=new Set,E.set(e,n)),n.add(t),()=>n.delete(t)}var A=e(t(),1),j=[],M=new Map,N=new Map,P=new Map;function F(e,t){let n=M.get(e)??j;t.length===0?M.delete(e):M.set(e,t);let r=new Set([...n.map(e=>I(e.source)),...t.map(e=>I(e.source))]);for(let e of r)wt(e)}function xt(e){F(e,j)}function St(e,t,n){let r=I({session:e,path:t,...n===void 0?{}:{root:n}});return(0,A.useSyncExternalStore)((0,A.useCallback)(e=>Tt(r,e),[r]),()=>Ct({session:e,path:t,...n===void 0?{}:{root:n}}))}function Ct(e){return N.get(I(e))??j}function wt(e){let t=[...M.values()].flatMap(t=>t.filter(t=>I(t.source)===e));t.length===0?N.delete(e):N.set(e,t);for(let t of P.get(e)??[])t()}function Tt(e,t){let n=P.get(e)??new Set;return n.add(t),P.set(e,n),()=>{n.delete(t),n.size===0&&P.delete(e)}}function I(e){return JSON.stringify([e.session,e.root??null,e.path])}var L=r();function R(e,t,n){let r=`${encodeURIComponent(e)}:${encodeURIComponent(t)}`;return n===void 0?r:`${r}:${encodeURIComponent(n)}`}var z=new Map;function Et(e,t,n){let r={save:t,...n?{target:n}:{}};return z.set(e,r),()=>{z.get(e)===r&&z.delete(e)}}function Dt(e){if(e===null)return!1;let t=z.get(e);return t?(t.save(),!0):!1}async function Ot(e,t){let n=R(e.session,e.path,e.root),r=[...z.entries()].flatMap(([r,i])=>{let a=i.target;if(!a||a.session!==e.session||a.root!==e.root)return[];let o=kt(a.path);return r!==n&&!t.has(o)?[]:[Promise.resolve(i.save())]});return(await Promise.all(r)).every(e=>e!==!1)}function kt(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<0?``:t.slice(n+1).toLowerCase()}var At=`UTC`;function jt(e){return new Date(e).toLocaleDateString(`en-GB`,{day:`numeric`,month:`short`,year:`numeric`,timeZone:At})}var B=60,V=60*B,H=24*V,Mt=7*H;function Nt(e,t=new Date){let n=new Date(e).getTime(),r=Math.max(0,Math.floor((t.getTime()-n)/1e3));return r<B?`just now`:r<V?`${Math.floor(r/B)} m ago`:r<H?`${Math.floor(r/V)} h ago`:r<Mt?`${Math.floor(r/H)} d ago`:jt(n)}function Pt(e,t){return t?`added`:e}function Ft(e){return i(`POST`,`/api/profiles/${e}/untitled`)}function U(e,t){return[`untitled`,e,t]}function It(e,t,n=!0){return u({queryKey:U(e,t),queryFn:()=>i(`GET`,`/api/profiles/${e}/untitled/${t}`),enabled:e!==null&&n,staleTime:1/0})}function Lt(e,t,n,r){e.setQueryData(U(t,n),e=>e===void 0?e:{...e,content:r})}function Rt(e,t,n){return i(`PUT`,`/api/profiles/${e}/untitled/${t}`,{content:n})}async function zt(e,t){try{await i(`DELETE`,`/api/profiles/${e}/untitled/${t}`)}catch(e){if(!(e instanceof o&&e.status===404&&e.code===`not_found`))throw e}}var W=null,G=new Map;function Bt(e){W=e}function Vt(e){W?.(e)}function Ht(e,t){G.set(e,t)}function Ut(e){return G.get(e)}function Wt(e){G.delete(e)}var K=new Map;function Gt(e,t,n){let r=JSON.stringify([e,t]),i=K.get(r)??new Set;return i.add(n),K.set(r,i),()=>{i.delete(n),i.size||K.delete(r)}}async function Kt(e,t){await Promise.all([...K.get(JSON.stringify([e,t]))??[]].map(e=>e()))}var q=(0,A.createContext)({openFile:()=>void 0,handler:null,setHandler:()=>void 0});function qt({children:e}){let[t,n]=(0,A.useState)(null),r=(0,A.useCallback)(e=>n(()=>e),[]),i=(0,A.useCallback)((e,n,r,i)=>{if(!t){re(`The editor is not ready yet.`);return}t(e,n,r,i)},[t]),a=(0,A.useMemo)(()=>({openFile:i,handler:t,setHandler:r}),[i,t,r]);return(0,L.jsx)(q.Provider,{value:a,children:e})}function Jt(){let{openFile:e}=(0,A.useContext)(q);return{openFile:e}}function Yt(e){let{setHandler:t}=(0,A.useContext)(q),n=(0,A.useRef)(e);n.current=e,(0,A.useEffect)(()=>(t((e,t,r,i)=>n.current(e,t,r,i)),()=>t(null)),[t])}var J=new Map;function Xt(e,t){let n=R(e.session,e.path,e.root),r=J.get(n)??new Set;return r.add(t),J.set(n,r),()=>{r.delete(t),r.size||J.delete(n)}}function Zt(e){let t=J.get(R(e.session,e.path,e.root))?.values().next().value;return t?(t(),!0):!1}var Y=`DropdownMenu`,[Qt,$t]=te(Y,[b]),X=b(),[en,tn]=Qt(Y),nn=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=X(t),l=A.useRef(null),[u,d]=_({prop:i,defaultProp:a??!1,onChange:o,caller:Y});return(0,L.jsx)(en,{scope:t,triggerId:ne(),triggerRef:l,contentId:ne(),open:u,onOpenChange:d,onOpenToggle:A.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,L.jsx)(pe,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};nn.displayName=Y;var rn=`DropdownMenuTrigger`,an=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=tn(rn,n),o=X(n),s=ie(t,a.triggerRef);return(0,L.jsx)(we,{asChild:!0,...o,children:(0,L.jsx)(ee.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:g(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:g(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});an.displayName=rn;var on=`DropdownMenuPortal`,sn=e=>{let{__scopeDropdownMenu:t,...n}=e,r=X(t);return(0,L.jsx)(_e,{...r,...n})};sn.displayName=on;var Z=`DropdownMenuContent`,cn=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=tn(Z,n),a=X(n),o=A.useRef(!1);return(0,L.jsx)(ge,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:g(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:g(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});cn.displayName=Z;var ln=`DropdownMenuGroup`,un=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,L.jsx)(ue,{...i,...r,ref:t})});un.displayName=ln;var dn=`DropdownMenuLabel`,fn=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,L.jsx)(de,{...i,...r,ref:t})});fn.displayName=dn;var pn=`DropdownMenuItem`,mn=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,L.jsx)(be,{...i,...r,ref:t})});mn.displayName=pn;var hn=`DropdownMenuCheckboxItem`,gn=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,L.jsx)(Se,{...i,...r,ref:t})});gn.displayName=hn;var _n=`DropdownMenuRadioGroup`,vn=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,L.jsx)(Te,{...i,...r,ref:t})});vn.displayName=_n;var yn=`DropdownMenuRadioItem`,bn=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,L.jsx)(fe,{...i,...r,ref:t})});bn.displayName=yn;var xn=`DropdownMenuItemIndicator`,Sn=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,L.jsx)(Ce,{...i,...r,ref:t})});Sn.displayName=xn;var Cn=`DropdownMenuSeparator`,wn=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,L.jsx)(xe,{...i,...r,ref:t})});wn.displayName=Cn;var Tn=`DropdownMenuArrow`,En=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,L.jsx)(ye,{...i,...r,ref:t})});En.displayName=Tn;var Dn=e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:a}=e,o=X(t),[s,c]=_({prop:r,defaultProp:a??!1,onChange:i,caller:`DropdownMenuSub`});return(0,L.jsx)(ve,{...o,open:s,onOpenChange:c,children:n})},On=`DropdownMenuSubTrigger`,kn=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,L.jsx)(me,{...i,...r,ref:t})});kn.displayName=On;var An=`DropdownMenuSubContent`,jn=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,L.jsx)(he,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});jn.displayName=An;var Mn=nn,Nn=an,Pn=sn,Fn=cn,In=mn,Ln=wn,Rn=Dn,zn=kn,Bn=jn,Vn=Mn,Hn=Nn,Un=Rn;function Wn({className:e,sideOffset:t=4,...n}){return(0,L.jsx)(Pn,{children:(0,L.jsx)(Fn,{sideOffset:t,className:h(`z-50 min-w-36 overflow-hidden`,oe,`overlay-dropdown-menu-motion`,e),...n})})}function Gn({className:e,...t}){return(0,L.jsx)(In,{className:h(ae,v,`[&_svg]:size-3.5`,e),...t})}function Kn({className:e,children:t,...n}){return(0,L.jsxs)(zn,{className:h(ae,v,`data-[state=open]:bg-action data-[state=open]:text-action-ink [&_svg]:size-3.5`,e),...n,children:[t,(0,L.jsx)(le,{className:`ml-auto`})]})}function qn({className:e,...t}){return(0,L.jsx)(Pn,{children:(0,L.jsx)(Bn,{className:h(`z-50 min-w-36 overflow-hidden`,oe,`overlay-dropdown-menu-motion`,e),...t})})}function Jn({className:e,...t}){return(0,L.jsx)(Ln,{className:h(`-mx-1 my-1 h-px bg-border`,e),...t})}var Yn={png:`image`,jpg:`image`,jpeg:`image`,gif:`image`,webp:`image`,bmp:`image`,ico:`image`,avif:`image`,svg:`image`,mp4:`video`,m4v:`video`,webm:`video`,mov:`video`,mkv:`video`,avi:`video`,mp3:`audio`,wav:`audio`,ogg:`audio`,m4a:`audio`,flac:`audio`,aac:`audio`,pdf:`pdf`};function Xn(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n<=0?null:Yn[t.slice(n+1).toLowerCase()]??null}var Q=new Map,$=new Map;function Zn(e,t,n){let r=er(e,t,n);Q.set(r,(Q.get(r)??0)+1);for(let e of $.get(r)??[])e()}function Qn(e,t,n){let r=er(e,t,n),i=(0,A.useCallback)(e=>$n(r,e),[r]),a=(0,A.useCallback)(()=>Q.get(r)??0,[r]);return(0,A.useSyncExternalStore)(i,a,a)}function $n(e,t){let n=$.get(e);return n||(n=new Set,$.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&$.delete(e)}}function er(e,t,n){return JSON.stringify([e,n??null,t])}function tr({draft:e,actions:t}){return(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-2`,"data-window-draft-recovery":!0,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,L.jsx)(`span`,{className:`truncate text-sm`,title:e.path,children:e.path}),(0,L.jsxs)(Ee,{label:`Recovery actions for ${e.path}`,className:`shrink-0`,children:[(0,L.jsx)(se,{variant:`ghost`,onClick:()=>x(new Blob([e.content],{type:`text/plain;charset=utf-8`}),e.path.split(`/`).at(-1)||`recovered-draft.txt`),children:`Download recovered text`}),t]})]}),(0,L.jsx)(ce,{"aria-label":`Recovered text for ${e.path}`,readOnly:!0,value:e.content,rows:12,className:`font-mono text-xs`})]})}export{qe as $,Pt as A,gt as B,Bt as C,Me as Ct,Rt as D,zt as E,ke as Et,R as F,dt as G,mt as H,xt as I,vt as J,ut as K,F as L,Et as M,Dt as N,Lt as O,Ot as P,bt as Q,St as R,Vt as S,Ne as St,Ft as T,Ae as Tt,lt as U,pt as V,yt as W,ft as X,st as Y,_t as Z,Yt as _,Qe as _t,Vn as a,Je as at,Wt as b,x as bt,Jn as c,Ze as ct,Kn as d,Be as dt,Ge as et,Hn as f,He as ft,Jt as g,We as gt,qt as h,Le as ht,Xn as i,S as it,Nt as j,It as k,Un as l,Ue as lt,Zt as m,ze as mt,Zn as n,it as nt,Wn as o,nt as ot,Xt as p,Re as pt,ht as q,Qn as r,Ke as rt,Gn as s,$e as st,tr as t,Ye as tt,qn as u,Ve as ut,Gt as v,Xe as vt,Ut as w,je as wt,Ht as x,Pe as xt,Kt as y,Ie as yt,ct as z};
|
|
@@ -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{i as r,o as i}from"./profile-store-CarO9MCP.js";import{a,i as o,o as s,r as c,s as l,t as u}from"./dialog-CTN-Lln6.js";import{t as d}from"./x-CbfJFzGo.js";import{t as f}from"./button-D-qeQvl5.js";import{t as p}from"./createLucideIcon-DyMAgLa3.js";import{t as m}from"./content-state-BDt3NnGs.js";import{t as h}from"./drafts-CCenbr5J.js";import{s as g,t as _}from"./editor-sync-C5CgYn_q.js";import{i as v,t as y,u as b}from"./buffer-store-CBhXNRZm.js";import{n as x,o as S,r as C}from"./FileCloseScope-DKbSgHF2.js";var w=p(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),T=e(t(),1),E=n();function D(e,t,n){let a=y(e,t,n),o=r(),s=o&&i()?m(o):null;return(0,T.useSyncExternalStore)((0,T.useCallback)(e=>{let t=b(a,e),n=s?.subscribe(e);return()=>{t(),n?.()}},[a,s]),()=>v(a)||!!s?.buffer({session:e,path:t,root:n}))}function O({session:e,path:t,kind:n,root:r}){return D(e,t,r)&&n!==`commit`?(0,E.jsx)(w,{"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 k({session:e,path:t,kind:n,root:i,label:p,onClose:v,closeKey:b,recovered:w=!1}){let T=r(),O=D(e,t,i)&&n!==`commit`&&n!==`untitled`,{review:k,pending:A}=C(b??y(e,t,i)),j=x({session:e,path:t,root:i}),M=e=>e?.aborted?Promise.resolve(!1):O&&(w||!j())?k.request(`discard`,null,e):Promise.resolve(v(e)).then(e=>e!==!1);return S(b,M),(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`button`,{onClick:e=>{e.stopPropagation(),M()},className:`flex size-4 items-center justify-center rounded-sm text-fg-muted transition-colors hover:text-fg`,"aria-label":w?`Discard recovered text for ${p}`:`Close ${p}`,children:(0,E.jsx)(d,{className:`size-3`})}),(0,E.jsx)(u,{open:A!==null,onOpenChange:e=>!e&&k.cancel(),children:(0,E.jsxs)(c,{onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[(0,E.jsxs)(s,{children:[(0,E.jsx)(l,{children:w?`Discard recovered text for ${p}?`:`Discard changes to ${p}?`}),(0,E.jsx)(o,{children:w?`This removes the recovered copy from this window. Download or copy it first if you want to keep it.`:`This file has unsaved changes. Closing the tab will discard them.`})]}),(0,E.jsxs)(a,{children:[(0,E.jsx)(f,{variant:`ghost`,onClick:k.cancel,children:`Keep editing`}),(0,E.jsx)(f,{variant:`danger`,onClick:()=>{if(!(!A||k.get()!==A)){if(!w&&j()){k.finish(A,!0),v();return}w||g(e,t,i),T&&m(T).discardBuffer({session:e,path:t,root:i}),w||(h(e,t,i),_(e,t,i)),k.finish(A,!0),v()}},children:`Discard`})]})]})})]})}export{O as EditorDirtyDot,k as EditorTabClose};
|
|
@@ -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";var r=e(t(),1),i=n(),a=(0,r.createContext)(null);function o({children:e}){let[t]=(0,r.useState)(()=>new Map);return(0,i.jsx)(a,{value:t,children:e})}function s(e,t){return JSON.stringify([e,t])}function c(){let e=(0,r.useContext)(a);return(t,n,r=!1)=>{let i=e?.get(t);return i?i(n):r?Promise.reject(Error(`Wait for the file tabs to load or recover the project before closing this pane`)):Promise.resolve(!1)}}function l(e,t){let n=(0,r.useContext)(a);(0,r.useLayoutEffect)(()=>{if(!(!n||e===void 0))return n.set(e,t),()=>{n.get(e)===t&&n.delete(e)}},[n,e,t])}var u=class{pending=null;listeners=new Set;get=()=>this.pending;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});request(e,t,n){if(n?.aborted||this.pending&&this.pending.key!==e)return Promise.resolve(!1);if(!this.pending){let n,r=new Promise(e=>{n=e});this.pending={key:e,value:t,promise:r,resolve:n,cleanups:[]}}let r=this.pending;if(n){let e=()=>this.finish(r,!1);n.addEventListener(`abort`,e,{once:!0}),r.cleanups.push(()=>n.removeEventListener(`abort`,e))}for(let e of this.listeners)e();return r.promise}finish(e,t){if(!(!e||this.pending!==e)){this.pending=null;for(let t of e.cleanups)t();e.resolve(t);for(let e of this.listeners)e()}}cancel=()=>this.finish(this.pending,!1)};function d(e){let{review:t}=(0,r.useMemo)(()=>({scope:e,review:new u}),[e]);return(0,r.useEffect)(()=>()=>t.cancel(),[t]),{review:t,pending:(0,r.useSyncExternalStore)(t.subscribe,t.get)}}function f(e,t){let n=e=>e?e.kind===`split`?e.children.reduce((e,t)=>e+n(t),0):e.tabs.filter(e=>e.type===`editor`&&e.tab.kind!==`commit`&&e.tab.kind!==`untitled`&&e.tab.session===t.session&&e.tab.path===t.path&&e.tab.root===t.root).length:0;return e.layout_mode===`project`?Object.values(e.project_layouts).reduce((e,t)=>e+n(t.layout_tree),0):n(e.layout_tree)}var p=(0,r.createContext)(null);function m({state:e,children:t}){return(0,i.jsx)(p,{value:e,children:t})}function h(e){let t=(0,r.useContext)(p);return()=>t!==null&&f(t.current(),e)>1}export{s as a,o as i,h as n,l as o,d as r,c as s,m as t};
|
package/dist/public/assets/{FileEditorSettingsMenu-JUB6GRyp.js → FileEditorSettingsMenu-DnMJu5pC.js}
RENAMED
|
@@ -1 +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,
|
|
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,r as s,s as c,t as l}from"./select-DzQdQNsv.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-O6mK4sJI.js";import{i as S,r as C}from"./file-editor-settings-1cj6VRxs.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)(s,{value:`default`,children:[`Default (`,D.editorTabSize,`)`]}),Array.from({length:8},(e,t)=>t+1).map(e=>(0,T.jsx)(s,{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)(s,{value:`default`,children:[`Default (`,D.editorWordWrap?`on`:`off`,`)`]}),(0,T.jsx)(s,{value:`on`,children:`On`}),(0,T.jsx)(s,{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)(c,{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,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Terminal-C3TQK74f.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/react-dom-cJyBB_A4.js","assets/protocol-support-BUdL5Q-x.js","assets/local-store-8IcyY3pd.js","assets/client-settings-BdKglwtW.js","assets/theme-swfNLod9.js","assets/jsx-runtime-By8HlURe.js","assets/preload-helper-Czpn1I53.js","assets/profile-store-CarO9MCP.js","assets/forward-link-CcmVXHkx.js","assets/api--n1Ha6tG.js","assets/auth-eu0vmKkB.js","assets/queries-DnuokC1N.js","assets/motion-Bd_MB9cH.js","assets/utils-B6KiDbIe.js","assets/dist-BOS6OKSE.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-BSqrsD_7.js","assets/editor-links-qwyINDCv.js","assets/button-D-qeQvl5.js","assets/copy-CGsu8426.js","assets/ws-DH0dKRnO.js","assets/code-DRWf9a5s.js","assets/errors-DWF9D4n6.js","assets/preferences-Dy_61zsm.js","assets/file-links-BEPA2kg5.js","assets/render-rich-content-BULX1bwr.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{nt as n}from"./local-store-8IcyY3pd.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-C3TQK74f.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-C3TQK74f.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-
|
|
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-CBhXNRZm.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};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{g as n}from"./local-store-8IcyY3pd.js";import{t as r}from"./context-BRrQlmgI.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
|
+
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
|
+
.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
|
+
.jupyter-widgets button,.jupyter-widgets select,.jupyter-widgets input[type=range]{cursor:pointer}
|
|
5
|
+
.jupyter-widgets button:hover{opacity:.8}.widget-label{color:var(--jp-ui-font-color2)}
|
|
6
|
+
.math-display{display:block}
|
|
7
|
+
</style></head><body><script>${e.replace(/<\/script/gi,`<\\/script`)}<\/script></body></html>`)})().catch(e=>C(String(e))),()=>{t=!0,i?.(),window.removeEventListener(`message`,a),p.current?.close(),p.current=null}},[r,o,e,u]),(0,l.jsxs)(`div`,{children:[g&&(0,l.jsx)(`iframe`,{ref:f,title:`Jupyter widget`,loading:`lazy`,sandbox:`allow-scripts allow-downloads`,referrerPolicy:`no-referrer`,srcDoc:g,className:`block w-full border-0`,style:{height:b}},v),!o&&(0,l.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Saved widget · run the cell to reconnect`}),w&&!u?(0,l.jsxs)(`button`,{type:`button`,onClick:d,className:`cursor-pointer text-xs text-accent hover:opacity-80`,children:[`Load `,w,` widget extension`]}):S&&(0,l.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:S})]})}export{p as default};
|