@puddle-code/cli 0.3.4 → 0.3.6
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 +4 -13
- package/dist/host-control.mjs +5 -1
- package/dist/index.js +10 -4
- package/dist/public/assets/{App-CwV0Dizo.js → App-Duewv-oi.js} +2 -2
- package/dist/public/assets/{Dashboard-fA7E3Mr1.js → Dashboard-7gBsrB7q.js} +1 -1
- package/dist/public/assets/{EditorTabClose-DNWGZZN8.js → EditorTabClose-BV-zQyHT.js} +1 -1
- package/dist/public/assets/{LazyTerminal-CAvxgexS.js → LazyTerminal-gX1-vBQf.js} +2 -2
- package/dist/public/assets/{ModelRefcount-CJK-g5rf.js → ModelRefcount-BasPzO4R.js} +1 -1
- package/dist/public/assets/{NewProjectDialog-eDAOcbIM.js → NewProjectDialog-CDYUPliQ.js} +1 -1
- package/dist/public/assets/{PaneEditorBody-Cxn0s84L.js → PaneEditorBody-CqLkAxM1.js} +3 -3
- package/dist/public/assets/{PdfViewer-BY5xRKk1.js → PdfViewer-DAAfA9OC.js} +1 -1
- package/dist/public/assets/{SettingsDialog-Sd6i7Plz.js → SettingsDialog-DiwhE5dK.js} +1 -1
- package/dist/public/assets/{Terminal-CqjwbNAI.js → Terminal-DmlEI-h7.js} +3 -3
- package/dist/public/assets/{Workspace-C-M1AjMn.js → Workspace-cfjpv0xU.js} +4 -4
- package/dist/public/assets/{auth-cjbSLnao.js → auth-BxExwqPW.js} +1 -1
- package/dist/public/assets/{buffer-store-BAQjeFXg.js → buffer-store-CYe-IdNO.js} +1 -1
- package/dist/public/assets/{copy-Df7qIcX6.js → copy-CjatFFf8.js} +1 -1
- package/dist/public/assets/{disclosure-C2uTs3Vm.js → disclosure-7lu23NnB.js} +1 -1
- package/dist/public/assets/{dist-Cl5AP2As.js → dist-7fft9rhQ.js} +1 -1
- package/dist/public/assets/{errors-BiS6nBXL.js → errors-DhRwiizF.js} +1 -1
- package/dist/public/assets/{index-CW1P_8TN.js → index-BRywm-gU.js} +3 -3
- package/dist/public/assets/{markdown-mermaid-JPAETK2Y.js → markdown-mermaid-CF9txXiK.js} +1 -1
- package/dist/public/assets/{media-refresh-store-CHnqDJWI.js → media-refresh-store-DLtYZTP9.js} +1 -1
- package/dist/public/assets/{notification-delivery-Lz-hnQG7.js → notification-delivery-CoCRZRSK.js} +1 -1
- package/dist/public/assets/{project-abbrev-Bz8ZEwrb.js → project-abbrev-DX_a_ySv.js} +1 -1
- package/dist/public/assets/{protocol-support-CJIxbQCB.js → protocol-support-gmAQBWF3.js} +1 -1
- package/dist/public/assets/{scroll-restoration-r--43sOx.js → scroll-restoration-hg7BYUz2.js} +1 -1
- package/dist/public/assets/{selection-actions-C2udLSyj.js → selection-actions-BZy4596m.js} +1 -1
- package/dist/public/assets/{switch-DwMO1AUH.js → switch-OD1b2aeq.js} +1 -1
- package/dist/public/assets/{use-ui-state-Crvfdw4F.js → use-ui-state-C2LCTPRw.js} +1 -1
- package/dist/public/assets/{ws-B1kcYo2j.js → ws-oU1ansI7.js} +1 -1
- package/dist/public/index.html +2 -2
- package/dist/pudl.js +6 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,18 +4,9 @@ Archived release changelog. Governance lives in CLAUDE.md §"Changelog disciplin
|
|
|
4
4
|
|
|
5
5
|
# Changelog
|
|
6
6
|
|
|
7
|
-
## [0.3.
|
|
7
|
+
## [0.3.6] — 2026-10-23
|
|
8
8
|
|
|
9
|
-
###
|
|
9
|
+
### Fixed
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
- Choose project name colours from the profile palette when creating or editing a project, or from either sidebar's project context menu; retain colours across dashboard cards and project navigation.
|
|
14
|
-
- Add editable `.ipynb` notebook views with saved rich output, a JSON source toggle, and explicit whole-notebook execution through host-installed Jupyter.
|
|
15
|
-
- Run Python, JavaScript, TypeScript, C, C++, Rust, Go, Ruby, Perl, R and shell files with detected host tools, per-file command overrides, bounded output and managed result tabs; keep code execution manual.
|
|
16
|
-
|
|
17
|
-
### Changed
|
|
18
|
-
|
|
19
|
-
- Advance the daemon/cockpit protocol to 24.6 for host kernel discovery, status and explicit notebook lifecycle actions.
|
|
20
|
-
- Advance the daemon/cockpit protocol to 24.5 for optional project colours; hide colour controls on older hosts and preserve existing project styling by default.
|
|
21
|
-
- Advance the daemon/cockpit protocol to 24.4 for profile language command defaults, inherited file commands and an optional compilation-provider action label; retain LaTeX eager controls only for providers that advertise eager support.
|
|
11
|
+
- Reuse installed Node headers during CI and release dependency installation so native builds can recover from prebuilt-addon download failures without a second network request.
|
|
12
|
+
- Normalise ANSI colours in programme-terminal test assertions so coloured Node output does not fail CI.
|
package/dist/host-control.mjs
CHANGED
|
@@ -15211,7 +15211,9 @@ var compilationProviderSchema = external_exports.object({
|
|
|
15211
15211
|
executor: external_exports.string().min(1).nullable(),
|
|
15212
15212
|
eager: external_exports.boolean(),
|
|
15213
15213
|
/** Omitted by older providers, whose action remains compilation. */
|
|
15214
|
-
action: external_exports.enum(["compile", "run"]).optional()
|
|
15214
|
+
action: external_exports.enum(["compile", "run"]).optional(),
|
|
15215
|
+
/** Runs always launch a terminal, including any compilation step (25.0). */
|
|
15216
|
+
terminal: external_exports.boolean().optional()
|
|
15215
15217
|
});
|
|
15216
15218
|
var compilationCapabilitiesResponseSchema = external_exports.object({
|
|
15217
15219
|
providers: external_exports.array(compilationProviderSchema)
|
|
@@ -15257,6 +15259,8 @@ var compilationRunResponseSchema = external_exports.object({
|
|
|
15257
15259
|
/** The provider-resolved entry point (for LaTeX, the root TeX document). */
|
|
15258
15260
|
source: compilationFileTargetSchema,
|
|
15259
15261
|
artifacts: external_exports.array(compilationArtifactSchema),
|
|
15262
|
+
/** Newly launched terminal placement; success means launched, not programme completion. */
|
|
15263
|
+
terminal: sessionSchema.optional(),
|
|
15260
15264
|
/** Provider-owned navigation format available for the artifacts, if any. */
|
|
15261
15265
|
navigation: external_exports.object({ kind: external_exports.string().min(1) }).optional()
|
|
15262
15266
|
});
|
package/dist/index.js
CHANGED
|
@@ -3925,7 +3925,7 @@ import { createInterface } from "node:readline";
|
|
|
3925
3925
|
import { Writable } from "node:stream";
|
|
3926
3926
|
|
|
3927
3927
|
// ../shared/src/protocol.ts
|
|
3928
|
-
var PROTOCOL_VERSION = { major:
|
|
3928
|
+
var PROTOCOL_VERSION = { major: 25, minor: 0 };
|
|
3929
3929
|
|
|
3930
3930
|
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
|
|
3931
3931
|
var external_exports = {};
|
|
@@ -19131,7 +19131,9 @@ var compilationProviderSchema = external_exports.object({
|
|
|
19131
19131
|
executor: external_exports.string().min(1).nullable(),
|
|
19132
19132
|
eager: external_exports.boolean(),
|
|
19133
19133
|
/** Omitted by older providers, whose action remains compilation. */
|
|
19134
|
-
action: external_exports.enum(["compile", "run"]).optional()
|
|
19134
|
+
action: external_exports.enum(["compile", "run"]).optional(),
|
|
19135
|
+
/** Runs always launch a terminal, including any compilation step (25.0). */
|
|
19136
|
+
terminal: external_exports.boolean().optional()
|
|
19135
19137
|
});
|
|
19136
19138
|
var compilationCapabilitiesResponseSchema = external_exports.object({
|
|
19137
19139
|
providers: external_exports.array(compilationProviderSchema)
|
|
@@ -19177,6 +19179,8 @@ var compilationRunResponseSchema = external_exports.object({
|
|
|
19177
19179
|
/** The provider-resolved entry point (for LaTeX, the root TeX document). */
|
|
19178
19180
|
source: compilationFileTargetSchema,
|
|
19179
19181
|
artifacts: external_exports.array(compilationArtifactSchema),
|
|
19182
|
+
/** Newly launched terminal placement; success means launched, not programme completion. */
|
|
19183
|
+
terminal: sessionSchema.optional(),
|
|
19180
19184
|
/** Provider-owned navigation format available for the artifacts, if any. */
|
|
19181
19185
|
navigation: external_exports.object({ kind: external_exports.string().min(1) }).optional()
|
|
19182
19186
|
});
|
|
@@ -21878,7 +21882,7 @@ import { readFileSync as readFileSync4 } from "node:fs";
|
|
|
21878
21882
|
import { dirname as dirname4, join as join5 } from "node:path";
|
|
21879
21883
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
21880
21884
|
function cliVersion() {
|
|
21881
|
-
if (true) return "0.3.
|
|
21885
|
+
if (true) return "0.3.6";
|
|
21882
21886
|
const here = dirname4(fileURLToPath2(import.meta.url));
|
|
21883
21887
|
for (const candidate of [
|
|
21884
21888
|
join5(here, "..", "..", "package.json"),
|
|
@@ -22280,7 +22284,9 @@ var RELEASE_PROTOCOLS = {
|
|
|
22280
22284
|
"0.3.1": { major: 23, minor: 0 },
|
|
22281
22285
|
"0.3.2": { major: 24, minor: 0 },
|
|
22282
22286
|
"0.3.3": { major: 24, minor: 2 },
|
|
22283
|
-
"0.3.4": { major: 24, minor: 6 }
|
|
22287
|
+
"0.3.4": { major: 24, minor: 6 },
|
|
22288
|
+
"0.3.5": { major: 25, minor: 0 },
|
|
22289
|
+
"0.3.6": { major: 25, minor: 0 }
|
|
22284
22290
|
};
|
|
22285
22291
|
function validProtocol(value) {
|
|
22286
22292
|
if (typeof value !== "object" || value === null) return false;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SettingsDialog-
|
|
2
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{n,t as r}from"./jsx-runtime-ffCh33zF.js";import{B as i,O as a,V as o,j as s,l as c,o as l,r as u,v as d}from"./auth-cjbSLnao.js";import{a as f,c as p,l as m,o as h,u as g}from"./LazyTerminal-CAvxgexS.js";import{a as _,d as v,f as y,g as b,h as x,i as S,l as C,m as w,o as T,s as E,t as D,u as O}from"./notification-delivery-Lz-hnQG7.js";import{i as k,r as A,t as j}from"./client-settings-CwqpIric.js";import{t as M}from"./preload-helper-Czpn1I53.js";import{a as ee,n as te,o as ne,r as re,t as N}from"./index-CW1P_8TN.js";import{i as ie,n as ae,t as oe}from"./dist-Cl5AP2As.js";import{$t as se,A as ce,C as le,D as ue,E as de,F as fe,Ft as pe,Gt as me,Ht as he,I as ge,It as _e,Jt as ve,Kt as ye,L as be,Lt as xe,M as Se,N as Ce,O as we,Q as Te,Qt as Ee,R as De,S as Oe,Tt as ke,U as Ae,Ut as P,W as je,Wt as Me,Xt as Ne,Y as Pe,Yt as F,Zt as Fe,_ as Ie,_t as Le,at as Re,b as ze,dt as Be,en as Ve,et as He,ft as Ue,g as We,gt as Ge,ht as Ke,it as qe,j as Je,k as I,kt as Ye,lt as Xe,nn as Ze,o as Qe,ot as $e,q as et,qt as tt,tn as nt,ut as rt,vt as it,w as at,y as ot,yt as st,zt as ct}from"./protocol-support-CJIxbQCB.js";import{n as lt,t as ut}from"./copy-Df7qIcX6.js";import{a as dt,c as ft,d as pt,i as mt,l as ht,n as gt,o as _t,s as vt,t as yt,u as bt}from"./project-abbrev-Bz8ZEwrb.js";import{c as L,p as R}from"./es2015-CrC2hHeB.js";import{n as z,s as xt}from"./x-DCpy1q13.js";import{i as St,n as Ct}from"./recipes-K5GH3Kht.js";import{n as wt,r as Tt}from"./dist-BCwJL3w9.js";import{$ as Et,G as Dt,H as Ot,J as kt,K as At,Q as jt,U as Mt,W as Nt,X as Pt,Y as Ft,at as It,d as Lt,et as Rt,f as zt,h as B,i as Bt,it as V,m as Vt,nt as Ht,ot as H,p as Ut,q as Wt,r as Gt,rt as U,t as Kt,tt as qt}from"./use-ui-state-Crvfdw4F.js";import{t as W}from"./button-Chvl9hcE.js";import{t as G}from"./createLucideIcon-DyMAgLa3.js";import{c as Jt,i as Yt,s as Xt,t as Zt,u as Qt}from"./switch-DwMO1AUH.js";import{t as $t}from"./NewProjectDialog-eDAOcbIM.js";import{n as K}from"./errors-BiS6nBXL.js";import{t as q}from"./ws-B1kcYo2j.js";import{c as en,l as tn,n as nn,s as rn,t as an,u as on}from"./dialog-Bnex_wlx.js";import{n as sn,r as cn,t as ln}from"./popover-C-BfSLgw.js";var J=e(t(),1),Y=r();function un(){let[e,t]=(0,J.useState)(`Opening forwarded application…`);return(0,J.useEffect)(()=>{if(!/^\/forward\/([^/]+)\/(\d+)$/.exec(window.location.pathname)){t(`This forwarding link is invalid.`);return}let e=!0;return lt(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,Y.jsx)(`p`,{className:`p-8 text-sm text-fg-secondary`,children:e})}var dn=class extends Ve{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new xe({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=fn(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=fn(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=fn(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=fn(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){P.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>tt(t,e))}findAll(e={}){return this.getAll().filter(t=>tt(e,t))}notify(e){P.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return P.batch(()=>Promise.all(e.map(e=>e.continue().catch(F))))}};function fn(e){return e.options.scope?.id}var pn=class extends Ve{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??ye(r,t),a=this.get(i);return a||(a=new ct({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){P.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ve(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>ve(e,t)):t}notify(e){P.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){P.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){P.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},mn=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new pn,this.#t=e.mutationCache||new dn,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=se.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=he.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Fe(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=Me(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return P.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;P.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return P.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=P.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(F).catch(F)}invalidateQueries(e,t={}){return P.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=P.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(F)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(F)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Fe(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(F).catch(F)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(F).catch(F)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return he.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(me(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Ne(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(me(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Ne(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=ye(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===Ee&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},hn=class extends J.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,Y.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,Y.jsxs)(`p`,{className:`text-sm text-fg`,children:[`The `,this.props.scope,` stopped rendering.`]}),(0,Y.jsx)(`p`,{className:`max-w-lg font-mono text-2xs leading-relaxed text-interrupted`,children:e.message||String(e)}),(0,Y.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,Y.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Y.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,Y.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Reload`})]})]})}};function gn(){return(0,Y.jsx)(oe,{theme:(0,J.useSyncExternalStore)(ee,re),position:`bottom-right`,toastOptions:{style:{background:`var(--bg-elevated)`,border:`none`,boxShadow:`0 8px 30px rgb(0 0 0 / 0.25)`,color:`var(--text-primary)`},classNames:{description:`whitespace-pre-wrap break-words font-mono text-2xs leading-snug max-h-40 overflow-y-auto`}}})}function _n(){return(0,Y.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-ground`,children:(0,Y.jsxs)(`div`,{className:`flex w-full max-w-md flex-col gap-10 px-8 pb-24`,children:[(0,Y.jsx)(`h1`,{className:`font-mono text-2xl font-semibold text-fg`,children:`Puddle`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 text-sm leading-relaxed text-fg-secondary`,children:[(0,Y.jsxs)(`p`,{children:[`Authorise this browser by running`,` `,(0,Y.jsx)(`span`,{className:`font-mono text-accent`,children:`puddle launch`}),` in a terminal.`]}),(0,Y.jsx)(`p`,{children:`Use the link it opens. Your sessions, drafts and layouts stay in place.`})]})]})})}var vn=e(n(),1),yn=`a, button, [role="button"], [role="slider"], input, select, textarea, summary, label, [onclick], .cursor-pointer`,bn=`.monaco-editor`;function xn(e,t){return e?.closest(bn)&&!e.closest(t)?`text`:e?.closest(yn)?`interactive`:`default`}function Sn(e,t=`.no-custom-caret`){(0,J.useEffect)(()=>{let n=e.current;if(!n)return;let r=window.matchMedia(`(pointer: fine)`),i=()=>{n.style.opacity=`0`},a=e=>{if(e.pointerType===`touch`||!r.matches){i();return}n.style.transform=`translate3d(${e.clientX}px, ${e.clientY}px, 0) translate(-50%, -50%)`;let a=e.target instanceof Element?e.target:null;if(a instanceof HTMLIFrameElement){i();return}n.style.opacity=`1`;let o=a?.closest(bn),s=xn(a,t),c=s===`text`,l=s===`interactive`,u=c;if(c&&o){let e=getComputedStyle(o);n.style.setProperty(`--custom-cursor-caret-height`,`${Math.round(Number.parseFloat(e.fontSize)*1.3)}px`)}else if(!l&&a&&!a.closest(t)&&Array.from(a.childNodes).some(e=>e.nodeType===Node.TEXT_NODE&&e.textContent?.trim())){let e=getComputedStyle(a);e.userSelect!==`none`&&(u=!0,n.style.setProperty(`--custom-cursor-caret-height`,`${Math.round(Number.parseFloat(e.fontSize)*1.3)}px`))}n.classList.toggle(`is-interactive`,l),n.classList.toggle(`is-text`,u)};return window.addEventListener(`pointermove`,a,{passive:!0}),document.documentElement.addEventListener(`pointerleave`,i),window.addEventListener(`blur`,i),()=>{window.removeEventListener(`pointermove`,a),document.documentElement.removeEventListener(`pointerleave`,i),window.removeEventListener(`blur`,i)}},[t,e])}var Cn=[`top`,`right`,`bottom`,`left`];function wn(){let e=(0,J.useRef)(null);return Sn(e),(0,Y.jsx)(`div`,{ref:e,className:`custom-cursor drafting-cursor`,"aria-hidden":`true`,children:Cn.map(e=>(0,Y.jsx)(`span`,{className:`drafting-cursor-tick`,"data-side":e},e))})}function Tn(){let e=(0,J.useRef)(null);return Sn(e),(0,Y.jsx)(`div`,{ref:e,className:`custom-cursor invert-cursor`,"aria-hidden":`true`})}var En=`h1, h2, h3, h4, h5, h6, .no-rangefinder-caret`,Dn=40.5,X=4.05,On=X*Math.sqrt(3)/2;function kn(){let e=[],t=[],n=Dn/2,r=Math.ceil(n/On)+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*On,s=o+On,c=(i%2+2)%2*(X/2);for(let i=-r;i<r;i+=1){let r=n+i*X+c,l=[[r+X/2,o],[r,s],[r+X,s]],u=[[r+X/2,o],[r+3*X/2,o],[r+X,s]],d=e=>{let t=e.map(([e])=>e),n=e.map(([,e])=>e);return Math.max(...t)>0&&Math.min(...t)<Dn&&Math.max(...n)>0&&Math.min(...n)<Dn};d(l)&&e.push(a(l)),d(u)&&t.push(a(u))}}return{light:e.join(``),dark:t.join(``)}}var An=kn();function jn(){let e=(0,J.useRef)(null);return Sn(e,En),(0,Y.jsx)(`div`,{ref:e,className:`custom-cursor rangefinder-cursor`,"aria-hidden":`true`,children:(0,Y.jsxs)(`svg`,{className:`rangefinder-cursor-facets`,viewBox:`0 0 ${Dn} ${Dn}`,focusable:`false`,children:[(0,Y.jsx)(`path`,{className:`rangefinder-cursor-facet-light`,d:An.light}),(0,Y.jsx)(`path`,{className:`rangefinder-cursor-facet-dark`,d:An.dark})]})})}function Mn(){let{cursorPackage:e}=k(),t=null;switch(e){case`rangefinder`:t=(0,Y.jsx)(jn,{});break;case`drafting`:t=(0,Y.jsx)(wn,{});break;case`invert`:t=(0,Y.jsx)(Tn,{});break;case`system`:return null}return(0,vn.createPortal)(t,document.body)}var Nn=G(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),Pn=G(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),Fn=G(`monitor-cog`,[[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`m14.305 7.53.923-.382`,key:`1mlnsw`}],[`path`,{d:`m15.228 4.852-.923-.383`,key:`82mpwg`}],[`path`,{d:`m16.852 3.228-.383-.924`,key:`ln4sir`}],[`path`,{d:`m16.852 8.772-.383.923`,key:`1dejw0`}],[`path`,{d:`m19.148 3.228.383-.924`,key:`192kgf`}],[`path`,{d:`m19.53 9.696-.382-.924`,key:`fiavlr`}],[`path`,{d:`m20.772 4.852.924-.383`,key:`1j8mgp`}],[`path`,{d:`m20.772 7.148.924.383`,key:`zix9be`}],[`path`,{d:`M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7`,key:`1tnzv8`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}]]),In=G(`notebook-pen`,[[`path`,{d:`M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4`,key:`re6nr2`}],[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`path`,{d:`M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`pqwjuv`}]]),Ln=G(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),Rn=G(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),zn=G(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]);function Bn(){let e=Le(),t=je(),[n,r]=(0,J.useState)(``),[i,a]=(0,J.useState)(s),o=()=>{n.trim()&&t.mutate({name:n.trim(),branch_prefix:i.trim()},{onSuccess:e=>we(e.id)})},c=(e.data?.length??0)>0;return(0,Y.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-ground`,children:(0,Y.jsxs)(`div`,{className:`flex w-full max-w-md flex-col gap-10 px-8 pb-16`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`h1`,{className:`font-mono text-2xl font-semibold text-fg`,children:`Puddle`}),(0,Y.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`Who is working?`})]}),c&&(0,Y.jsx)(`div`,{className:`flex flex-col`,children:e.data.map(e=>(0,Y.jsxs)(`button`,{onClick:()=>we(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,Y.jsx)(y,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,Y.jsx)(`span`,{className:z(`text-base`,f(e.icon_colour)||`text-fg`),children:e.name}),e.branch_prefix&&(0,Y.jsxs)(`span`,{className:`ml-auto text-2xs text-fg-muted`,children:[e.branch_prefix,`…`]})]},e.id))}),(0,Y.jsxs)(`form`,{className:`flex flex-col gap-5`,onSubmit:e=>{e.preventDefault(),o()},children:[c&&(0,Y.jsx)(`p`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`or create a profile`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(p,{htmlFor:`profile-name`,children:`Name`}),(0,Y.jsx)(m,{id:`profile-name`,placeholder:`e.g. alice`,value:n,onChange:e=>r(e.target.value),className:`h-10`,autoFocus:!c})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(p,{htmlFor:`branch-prefix`,children:`Branch prefix`}),(0,Y.jsx)(m,{id:`branch-prefix`,placeholder:`no prefix`,value:i,onChange:e=>a(e.target.value),className:`h-10`})]}),t.error&&(0,Y.jsx)(`p`,{className:`text-xs text-danger`,children:t.error.message}),(0,Y.jsx)(W,{type:`submit`,size:`lg`,className:`self-start px-6`,disabled:!n.trim()||t.isPending,children:`Create profile`})]})]})})}var Vn=1,Hn=.9,Un=.8,Wn=.17,Gn=.1,Kn=.999,qn=.9999,Jn=.99,Yn=/[\\\/_+.#"@\[\(\{&]/,Xn=/[\\\/_+.#"@\[\(\{&]/g,Zn=/[\s-]/,Qn=/[\s-]/g;function $n(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Vn:Jn;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=$n(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=Vn:Yn.test(e.charAt(l-1))?(d*=Un,p=e.slice(i,l-1).match(Xn),p&&i>0&&(d*=Kn**+p.length)):Zn.test(e.charAt(l-1))?(d*=Hn,m=e.slice(i,l-1).match(Qn),m&&i>0&&(d*=Kn**+m.length)):(d*=Wn,i>0&&(d*=Kn**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=qn)),(d<Gn&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=$n(e,t,n,r,l+1,a+2,o),f*Gn>d&&(d=f*Gn)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function er(e){return e.toLowerCase().replace(Qn,` `)}function tr(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,$n(e,t,er(e),er(t),0,0,{})}var nr=`[cmdk-group=""]`,rr=`[cmdk-group-items=""]`,ir=`[cmdk-group-heading=""]`,ar=`[cmdk-item=""]`,or=`${ar}:not([aria-disabled="true"])`,sr=`cmdk-item-select`,Z=`data-value`,cr=(e,t,n)=>tr(e,t,n),lr=J.createContext(void 0),ur=()=>J.useContext(lr),dr=J.createContext(void 0),fr=()=>J.useContext(dr),pr=J.createContext(void 0),mr=J.forwardRef((e,t)=>{let n=Dr(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Dr(()=>new Set),i=Dr(()=>new Map),a=Dr(()=>new Map),o=Dr(()=>new Set),s=Er(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=L(),y=L(),b=L(),x=J.useRef(null),S=kr();Q(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),Q(()=>{S(6,k)},[]);let C=J.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=J.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??cr;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(rr);t?t.appendChild(e.parentElement===t?e:e.closest(`${rr} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${rr} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${nr}[${Z}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(Z);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(nr)?.querySelector(ir))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${ar}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(or)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(Z))}function ee(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(Z))}function te(e){let t=A()?.closest(nr),n;for(;t&&!n;)t=e>0?wr(t,nr):Tr(t,nr),n=t?.querySelector(or);n?C.setState(`value`,n.getAttribute(Z)):ee(e)}let ne=()=>M(j().length-1),re=e=>{e.preventDefault(),e.metaKey?ne():e.altKey?te(1):ee(1)},N=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?te(-1):ee(-1)};return J.createElement(R.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&re(e);break;case`ArrowDown`:re(e);break;case`p`:case`k`:g&&e.ctrlKey&&N(e);break;case`ArrowUp`:N(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),ne();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(sr);t.dispatchEvent(e)}}}}},J.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:Mr},c),jr(e,e=>J.createElement(dr.Provider,{value:C},J.createElement(lr.Provider,{value:w},e))))}),hr=J.forwardRef((e,t)=>{let n=L(),r=J.useRef(null),i=J.useContext(pr),a=ur(),o=Er(e),s=o.current?.forceMount??i?.forceMount;Q(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=Or(n,r,[e.value,e.children,r],e.keywords),l=fr(),u=$(e=>e.value&&e.value===c.current),d=$(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);J.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(sr,f),()=>t.removeEventListener(sr,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return J.createElement(R.div,{ref:xt(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),gr=J.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=L(),s=J.useRef(null),c=J.useRef(null),l=L(),u=ur(),d=$(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));Q(()=>u.group(o),[]),Or(o,s,[e.value,e.heading,c]);let f=J.useMemo(()=>({id:o,forceMount:i}),[i]);return J.createElement(R.div,{ref:xt(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&J.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),jr(e,e=>J.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},J.createElement(pr.Provider,{value:f},e))))}),_r=J.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=J.useRef(null),a=$(e=>!e.search);return!n&&!a?null:J.createElement(R.div,{ref:xt(i,t),...r,"cmdk-separator":``,role:`separator`})}),vr=J.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=fr(),o=$(e=>e.search),s=$(e=>e.selectedItemId),c=ur();return J.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),J.createElement(R.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),yr=J.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=J.useRef(null),o=J.useRef(null),s=$(e=>e.selectedItemId),c=ur();return J.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),J.createElement(R.div,{ref:xt(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},jr(e,e=>J.createElement(`div`,{ref:xt(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),br=J.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return J.createElement(rn,{open:n,onOpenChange:r},J.createElement(on,{container:o},J.createElement(tn,{"cmdk-overlay":``,className:i}),J.createElement(en,{"aria-label":e.label,"cmdk-dialog":``,className:a},J.createElement(mr,{ref:t,...s}))))}),xr=J.forwardRef((e,t)=>$(e=>e.filtered.count===0)?J.createElement(R.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),Sr=J.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return J.createElement(R.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},jr(e,e=>J.createElement(`div`,{"aria-hidden":!0},e)))}),Cr=Object.assign(mr,{List:yr,Item:hr,Input:vr,Group:gr,Separator:_r,Dialog:br,Empty:xr,Loading:Sr});function wr(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Tr(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Er(e){let t=J.useRef(e);return Q(()=>{t.current=e}),t}var Q=typeof window>`u`?J.useEffect:J.useLayoutEffect;function Dr(e){let t=J.useRef();return t.current===void 0&&(t.current=e()),t}function $(e){let t=fr(),n=()=>e(t.snapshot());return J.useSyncExternalStore(t.subscribe,n,n)}function Or(e,t,n,r=[]){let i=J.useRef(),a=ur();return Q(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(Z,s),i.current=s}),i}var kr=()=>{let[e,t]=J.useState(),n=Dr(()=>new Map);return Q(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function Ar(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function jr({asChild:e,children:t},n){return e&&J.isValidElement(t)?J.cloneElement(Ar(t),{ref:t.ref},n(t.props.children)):n(t)}var Mr={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function Nr({className:e,...t}){return(0,Y.jsx)(Cr,{className:z(`flex size-full flex-col overflow-hidden rounded-lg bg-elevated`,e),...t})}function Pr({open:e,onOpenChange:t,children:n}){return(0,Y.jsx)(an,{open:e,onOpenChange:t,children:(0,Y.jsx)(nn,{className:`max-w-lg overflow-hidden p-0 [&>button]:hidden`,children:(0,Y.jsx)(Nr,{loop:!0,children:n})})})}function Fr({className:e,...t}){return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pt-1`,children:[(0,Y.jsx)(Ht,{className:`size-4 shrink-0 text-fg-muted`}),(0,Y.jsx)(Cr.Input,{className:z(`flex h-10 w-full bg-transparent text-sm text-fg outline-none placeholder:text-fg-muted`,e),...t})]})}function Ir({className:e,...t}){return(0,Y.jsx)(Cr.List,{className:z(`max-h-72 overflow-y-auto p-1`,e),...t})}function Lr(e){return(0,Y.jsx)(Cr.Empty,{className:`py-6 text-center text-sm text-fg-muted`,...e})}function Rr({className:e,...t}){return(0,Y.jsx)(Cr.Group,{className:z(`overflow-hidden [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-2xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-wide [&_[cmdk-group-heading]]:text-fg-muted`,e),...t})}function zr({className:e,...t}){return(0,Y.jsx)(Cr.Item,{className:z(St,Ct,`[&_svg]:size-3.5 [&_svg]:text-fg-muted data-[selected=true]:[&_svg]:text-action-ink`,e),...t})}function Br({className:e,...t}){return(0,Y.jsx)(`span`,{className:z(`ml-auto font-mono text-2xs tracking-widest text-fg-muted`,e),...t})}var Vr=new class{transport;reload;pause;phase=`idle`;pending=null;constructor(e=fetch,t=()=>window.location.reload(),n=e=>new Promise(t=>setTimeout(t,e))){this.transport=e,this.reload=t,this.pause=n}refresh(e=12e4){return this.pending||=this.run(e).finally(()=>{this.pending=null}),this.pending}async run(e){this.phase=`requesting`;let t={authorization:`Bearer ${u.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=d.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;return this.phase=`complete`,this.reload(),!0}catch{}}}catch{}return this.phase=`failed`,!1}},Hr=null;function Ur(e){return Hr=e,()=>{Hr===e&&(Hr=null)}}function Wr(){Hr?.()}var Gr=new Set;function Kr(){return[...Gr].flatMap(e=>e())}function qr({onNewSession:e,onNewProject:t}){let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(`commands`),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(!1),f=bt(),p=pt(),m=I(),h=p.id,g=st(m??void 0),_=Ye(h),v=Ft();(0,J.useEffect)(()=>le(`palette.toggle`,()=>r(e=>!e)),[]),(0,J.useEffect)(()=>Et(()=>r(!0)),[]),(0,J.useEffect)(()=>{n||(a(`commands`),s(``),l(null),d(!1))},[n]);let y=(0,J.useMemo)(()=>{let n=[];for(let e of g.data??[])n.push({id:`project-${e.id}`,group:`Projects`,label:e.name,icon:gt,keywords:`switch project open`,run:()=>void f(`/project/${e.id}`)});for(let e of _.data??[])e.status!==`archived`&&n.push({id:`session-${e.id}`,group:`Sessions`,label:v(e),icon:yt,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:Qt,keywords:`new agent create start session`,run:()=>e()},{id:`new-terminal`,group:`Actions`,label:`New terminal`,icon:yt,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:gt,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:Tt,keywords:`new project open create repository repo workspace`,run:t}),n.push({id:`theme-dark`,group:`Theme`,label:`Switch theme: dark`,icon:x,keywords:`switch theme dark appearance`,run:()=>void N(`dark`)},{id:`theme-light`,group:`Theme`,label:`Switch theme: light`,icon:w,keywords:`switch theme light appearance`,run:()=>void N(`light`)},{id:`theme-system`,group:`Theme`,label:`Switch theme: system`,icon:Fn,keywords:`switch theme system appearance`,run:()=>void N(`system`)},{id:`open-settings`,group:`Actions`,label:`Settings`,icon:zn,keywords:`open settings preferences options configure`,run:()=>Yt()},{id:`switch-profile`,group:`Actions`,label:`Switch profile`,icon:Xt,keywords:`switch profile identity user change`,run:()=>ue.set(null)},{id:`refresh-connection`,group:`Actions`,label:`Refresh connection`,icon:Jt,keywords:`refresh connection reconnect restart cockpit tunnel ssh daemon`,run:()=>Wr()}),[...n,...Kr()]},[g.data,_.data,h,f,e,t,v]),b=(0,J.useMemo)(()=>{let e=new Map;for(let t of y){let n=e.get(t.group)??[];n.push(t),e.set(t.group,n)}return[...e.entries()]},[y]),S=async()=>{let e=o.trim();if(!(e===``||u)){d(!0),l(null);try{await Pt(e),r(!1)}catch(e){l(e instanceof Error?e.message:`Could not open that path.`)}finally{d(!1)}}};return(0,Y.jsxs)(Pr,{open:n,onOpenChange:r,children:[(0,Y.jsx)(Fr,{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(),S()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),a(`commands`),s(``),l(null)))}}),i===`path`?(0,Y.jsx)(Ir,{children:(0,Y.jsxs)(`div`,{className:`px-3 py-3 text-xs text-fg-muted`,children:[(0,Y.jsx)(`p`,{children:`Relative paths start from the bound worktree or project. Absolute and ~ paths work too.`}),(0,Y.jsx)(`p`,{className:c?`mt-2 text-danger`:`mt-2`,"aria-live":`polite`,children:c??(u?`Opening…`:`Press Enter to open.`)})]})}):(0,Y.jsxs)(Ir,{children:[(0,Y.jsx)(Lr,{children:`Nothing matches.`}),b.map(([e,t])=>(0,Y.jsx)(Rr,{heading:e,children:t.map(e=>{let t=e.icon;return(0,Y.jsxs)(zr,{value:`${e.label} ${e.keywords??``}`,onSelect:()=>{e.closeOnRun!==!1&&r(!1),e.run()},children:[t&&(0,Y.jsx)(t,{}),e.label,e.shortcut&&(0,Y.jsx)(Br,{children:e.shortcut})]},e.id)})},e))]})]})}function Jr(){let e=document.activeElement;return e instanceof Element&&e.closest(`.xterm`)!==null}function Yr(){let e=document.activeElement;return e instanceof Element&&e.closest(`.monaco-editor`)!==null}function Xr(){let e=Ge(I()??void 0).data?.hotkeys;return(0,J.useEffect)(()=>{at(e&&typeof e==`object`?e:void 0)},[e]),(0,J.useEffect)(()=>le(`window.close`,()=>{let e=nt();e?.closeWindow?e.closeWindow():window.close()}),[]),(0,J.useEffect)(()=>{let e=e=>{let t=Ie(e);if(!t)return;let n=We(t);if(!n)return;let r=ot(n);if(!r||!Oe(r,Yr()))return;let i=ze(n);i&&(e.preventDefault(),e.stopPropagation(),i())},t=e=>{let t=Ie(e);if(!t)return;let n=We(t);if(!n)return;let r=ot(n);if(!r||r.editor&&Yr()||r.deferInTerminal&&Jr())return;let i=ze(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 Zr=4e3;function Qr(){let[e,t]=(0,J.useState)(`hidden`),n=(0,J.useRef)(e);n.current=e,(0,J.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`)},Zr))});return()=>{r(),e!==null&&clearTimeout(e)}},[]);let r=(0,J.useCallback)(async()=>{n.current!==`refreshing`&&(t(`refreshing`),await Vr.refresh()||(ae.error(`The cockpit has not come back — it may need a terminal (ssh re-auth): puddle refresh`),t(q.isConnected()?`hidden`:`lost`)))},[]);return(0,J.useEffect)(()=>Ur(()=>void r()),[r]),e===`hidden`?null:(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 bg-elevated px-3 py-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-fg-secondary`,children:e===`refreshing`?`Restarting the cockpit.`:`Connection to the daemon lost.`}),e===`lost`&&(0,Y.jsxs)(W,{size:`sm`,className:`ml-auto`,onClick:()=>void r(),children:[(0,Y.jsx)(Jt,{}),`Refresh connection`]})]})}function $r({label:e,percentage:t,hint:n}){let r=Math.max(0,Math.min(100,t));return(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`w-24 shrink-0 truncate text-2xs text-fg-muted`,title:e,children:e}),(0,Y.jsx)(`span`,{className:`relative h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-border`,children:(0,Y.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,Y.jsxs)(`span`,{className:`shrink-0 text-2xs tabular-nums text-fg-muted`,children:[Math.round(r),`%`,n?` · ${n}`:``]})]})}function ei(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ti(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 ni({account:e,onLogin:t,onStartSession:n,installed:r=!0}){let i=fe(e.id),a=e.logged_in?n:r?t:null,o=i.data?.subscription;return(0,Y.jsxs)(`div`,{className:`rounded-md px-2 py-2 transition-colors hover:bg-elevated`,children:[(0,Y.jsxs)(`button`,{type:`button`,disabled:a===null,onClick:()=>a?.(),className:`flex w-full items-center gap-3 text-left disabled:cursor-default`,children:[(0,Y.jsx)(`span`,{className:`size-2 shrink-0 rounded-full ${e.logged_in?`bg-success`:`bg-idle`}`,"aria-hidden":!0}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.label}),(0,Y.jsxs)(`span`,{className:`block text-2xs text-fg-muted`,children:[e.logged_in?`logged in`:`logged out`,i.data&&(0,Y.jsxs)(Y.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 `,ti(i.data.last_activity_at)]})]}),i.data?.agent_usage&&(0,Y.jsxs)(`span`,{className:`block text-2xs text-fg-muted`,children:[ei(i.data.agent_usage.input_tokens),` in ·`,` `,ei(i.data.agent_usage.output_tokens),` out ·`,` `,ei(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,Y.jsx)(`span`,{className:`mt-1 block`,children:(0,Y.jsx)($r,{label:`context`,percentage:i.data.live_usage.context_used_percentage})})]}),(0,Y.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted`,children:r?e.logged_in?n?`new agent`:``:(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 text-warning`,children:[(0,Y.jsx)(b,{className:`size-3`}),`sign in`]}):`unavailable`})]}),o!=null&&o.windows.length>0&&(0,Y.jsx)(`div`,{className:`mt-2 flex flex-col gap-1 pl-5`,children:o.windows.map(e=>(0,Y.jsx)($r,{label:e.label,percentage:e.used_percentage,hint:e.resets==null?void 0:`resets ${e.resets}`},e.key))})]})}function ri(){let[e,t]=(0,J.useState)(!1),[n,r]=(0,J.useState)(!1),i=I(),a=Le(),o=Be(),s=a.data?.find(e=>e.id===i),c=ge(i??void 0),l=be(),u=$e(),{open:d,handler:p}=kt(),[m,h]=(0,J.useState)(null),g=e=>u.mutate(e.id,{onSuccess:t=>h({stream:t.stream,label:`${e.agent_type}/${e.label}`}),onError:e=>K(e)}),_=e=>{t(!1),d({accountId:e.id})};return n&&s?(0,Y.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-3`,children:[(0,Y.jsx)(y,{icon:s.icon,colour:s.icon_colour}),(0,Y.jsx)(Rt,{initial:s.name,maxLength:100,className:z(`w-32 text-sm`,f(s.icon_colour)),onCommit:e=>{r(!1);let t=e.trim();!i||!t||t===s?.name||o.mutate({id:i,name:t},{onError:e=>K(e)})},onCancel:()=>r(!1)})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(ln,{open:e,onOpenChange:t,children:[(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsx)(cn,{asChild:!0,children:(0,Y.jsxs)(W,{variant:`ghost`,size:`sm`,className:`font-sans compact:h-7 compact:px-1.5`,children:[(0,Y.jsx)(y,{icon:s?.icon,colour:s?.icon_colour}),(0,Y.jsx)(`span`,{className:f(s?.icon_colour),...qt(()=>{t(!1),r(!0)}),children:s?.name??`…`})]})})}),(0,Y.jsx)(V,{children:`Profile`})]}),(0,Y.jsxs)(sn,{className:`w-[28rem] max-w-[calc(100vw-1rem)]`,children:[(0,Y.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,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsxs)(`span`,{className:`px-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:[e.display_name,!n&&(0,Y.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,Y.jsx)(ni,{account:e,onLogin:()=>g(e),onStartSession:p&&n?()=>_(e):null,installed:n},e.id))]},e.id)}),c.data?.length===0&&(0,Y.jsx)(`p`,{className:`px-2 text-sm text-fg-muted`,children:`No accounts yet — add one in settings.`})]}),(0,Y.jsxs)(`div`,{className:`mt-4 flex items-center gap-2`,children:[(0,Y.jsxs)(W,{variant:`ghost`,size:`sm`,onClick:()=>{t(!1),Yt(`accounts`)},children:[(0,Y.jsx)(Tt,{}),`Add account`]}),(0,Y.jsxs)(W,{variant:`ghost`,size:`sm`,className:`ml-auto`,onClick:()=>{t(!1),ue.set(null)},children:[(0,Y.jsx)(Rn,{}),`Switch profile`]})]})]})]}),m&&(0,Y.jsx)(v,{stream:m.stream,label:m.label,onClose:()=>h(null)})]})}var ii=`desktop-update`;function ai(){let e=(0,J.useRef)(null);return(0,J.useEffect)(()=>{let t=nt();if(t?.updateReady===void 0||t.onUpdateReady===void 0)return;let n=t=>{e.current!==t&&(e.current=t,ae(`Puddle ${t} is downloaded and ready.`,{id:ii,duration:1/0,closeButton:!0,action:{label:`Restart to update`,onClick:()=>{nt()?.installUpdate?.(),ae.loading(`Restarting into Puddle ${t}…`,{id:`${ii}-restarting`,duration:1/0})}}}))};return t.updateReady().then(e=>{e!==null&&n(e)}),t.onUpdateReady(n)},[]),null}function oi(){let e=I(),t=Le().data?.find(t=>t.id===e),n=Ge(e??void 0),r=ke(e??void 0,void 0),i=k(),a=T(),o=E(),s=Ue(e??``),c=Be(),l=et(),[u,d]=(0,J.useReducer)(e=>e+1,0);(0,J.useEffect)(()=>ee(()=>d()),[]);let f=(0,J.useRef)(null);(0,J.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?_(p,t.name):void 0,g=s.isPending||c.isPending||l.isPending||o.isPending||n.isFetching||r.isFetching;(0,J.useEffect)(()=>{if(!m||!h?.enabled||g)return;let a={client:i,theme:ne(),profileSettings:n.data,profile:t,scratchpad:r.data},u={setClient:e=>A(e),setTheme:e=>{typeof e==`string`&&N(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,C(h.doc,u,a,h.groups);return}let p=O(h.groups,a),_=JSON.stringify(p);_!==d&&(f.current=_,o.mutate({profile:t.name,entry:{...h,doc:p,updatedAt:new Date().toISOString()}}))})}function si(e){let t=t=>{let n=o.safeParse(t);n.success&&e(n.data)},n=nt()?.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 ci=5e3,li=`[data-notification-session]`;function ui(e){let t=null,n=()=>{t=null},r=e=>e.target instanceof Element?e.target.closest(li):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<ci&&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 di=new Set,fi=e=>!!e&&di.has(e),pi=i.parse({});function mi(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 hi(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 gi(e){return e.title??e.agent_title??e.osc_title??e.id.slice(0,8)}function _i(){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 vi(){let e=bt(),t=(0,J.useRef)(null);(0,J.useEffect)(()=>{let e=ui(document);return t.current=e,()=>{t.current=null,e.dispose()}},[]),(0,J.useEffect)(()=>si(t=>{t.host||e(`/project/${t.project}/session/${t.session}`,{state:{notificationSession:t.session}})}),[e]),yi(t=>{e(`/project/${t.project_id}/session/${t.id}`,{state:{notificationSession:t.id}})},e=>t.current?.isInteracting(e.id)??!1)}function yi(e,t=()=>document.hasFocus()){let n=_e(),r=(0,J.useRef)(e);r.current=e;let a=(0,J.useRef)(t);a.current=t;let o=Se(qe().data)??`Puddle`,s=(0,J.useRef)(o);(0,J.useEffect)(()=>{document.title===s.current&&(document.title=o),s.current=o},[o]),(0,J.useEffect)(()=>{let e=new Set,t=()=>{document.title=e.size>0?`(${e.size}) ${s.current}`:s.current},o=!0,c=async e=>{let t=hi(n,e.session);if(!t)try{t=(await ce(n)).find(t=>t.id===e.session)}catch{return}if(!o||!t)return;let c=t,u,d;try{let e=await n.fetchQuery({queryKey:[`project`,c.project_id],queryFn:()=>ie(`GET`,`/api/projects/${c.project_id}`),staleTime:1e4});if(!o)return;d=e.project;let t=d.profile_id,r=await n.fetchQuery({queryKey:[`profile-settings`,t],queryFn:()=>ie(`GET`,`/api/profiles/${t}/settings`),staleTime:1e4});u=i.catch(pi).parse(r.notifications??{})}catch{return}if(!o)return;let f=mi({prefs:u,projectId:c.project_id,sessionFocused:a.current(c),permission:S()});f.sound&&_i(),f.desktop&&!fi(l()?.scope)&&await D({id:e.id?`puddle-event-${e.id}`:`puddle-agent-${c.id}`,title:e.content?.title??gi(c).slice(0,160),body:e.content?.body??(e.reason===`exited`?`Agent finished running`:`Waiting for your input`),target:{project:c.project_id,session:c.id,...l()?.notificationHost?{host:l().notificationHost}:{}}},()=>{o&&r.current(c)},{host:s.current,project:d})},u=q.onAgentNotification(e=>{c(e)}),d=q.onStatus(r=>{let i=e.has(r.session);r.status===`waiting_input`?e.add(r.session):e.delete(r.session),t(),!(r.status!==`waiting_input`||i)&&n.fetchQuery({queryKey:[`version`],queryFn:()=>ie(`GET`,`/api/version`),staleTime:1/0}).then(e=>{if(!(e.protocol.major>22||e.protocol.major===22&&e.protocol.minor>=3))return c({session:r.session,reason:`waiting_input`})}).catch(()=>{})});return()=>{o=!1,d(),u(),document.title=s.current}},[n])}function bi({initial:e,defaultScope:t,allowProject:n=!0,agents:r,onSave:i,onCancel:a}){let[o,s]=(0,J.useState)(e?.title??``),[c,l]=(0,J.useState)(e?.body??``),[u,d]=(0,J.useState)(n?e?.scope??t:`profile`),[f,p]=(0,J.useState)((e?.tags??[]).join(`, `)),[h,_]=(0,J.useState)(e?.agent_type??null),v=()=>{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:h})};return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Y.jsx)(m,{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,Y.jsx)(g,{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)&&v()},className:`resize-y text-sm leading-relaxed`}),(0,Y.jsx)(m,{value:f,placeholder:`tags, comma, separated`,spellCheck:!1,onChange:e=>p(e.target.value),onKeyDown:e=>e.stopPropagation(),className:`h-8 text-xs`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-2xs text-fg-secondary`,children:[(0,Y.jsx)(Zt,{checked:u===`profile`,onCheckedChange:e=>d(e?`profile`:`project`)}),`Profile-wide`]}),(0,Y.jsx)(`div`,{className:`ml-auto flex items-center gap-1`,children:r.map(e=>(0,Y.jsxs)(`button`,{type:`button`,title:e.display_name,"aria-pressed":h===e.id,onClick:()=>_(t=>t===e.id?null:e.id),className:z(`rounded-md p-1 transition-colors`,h===e.id?`bg-surface text-fg`:`text-fg-gold hover:bg-surface hover:text-fg`),children:[(0,Y.jsx)(At,{type:e.id,className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:e.display_name})]},e.id))})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,onClick:a,children:`Cancel`}),(0,Y.jsx)(W,{size:`sm`,disabled:!c.trim(),onClick:v,children:`Save`})]})]})}function xi(){let e=Dt(),t=I(),n=pt().id,r=ke(t??void 0,n).data??[],i=be().data??[],a=et(),o=Ke(),s=He(),c=Nt(),[l,u]=(0,J.useState)(null),[d,f]=(0,J.useState)(null),[p,m]=(0,J.useState)(null),[h,g]=(0,J.useState)(null),[_,v]=(0,J.useState)(null);(0,J.useEffect)(()=>le(`scratchpad.toggle`,Mt),[]),(0,J.useEffect)(()=>{e||(u(null),f(null),m(null))},[e]);let y=(0,J.useMemo)(()=>[...new Set(r.flatMap(e=>e.tags))].sort((e,t)=>e.localeCompare(t)),[r]),b=(0,J.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})},O=e=>{navigator.clipboard?.writeText(e.body),ae.success(`Copied to clipboard`)};return(0,Y.jsxs)(ln,{open:e,onOpenChange:Ot,children:[(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsx)(cn,{asChild:!0,children:(0,Y.jsxs)(W,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,children:[(0,Y.jsx)(In,{}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Scratchpad`})]})})}),(0,Y.jsx)(V,{children:`Scratchpad`})]}),(0,Y.jsxs)(sn,{className:`w-[34rem] max-w-[calc(100vw-1rem)] p-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-5 pb-2 pt-4`,children:[(0,Y.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Scratchpad`}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>u(l===`new`?null:`new`),className:`ml-auto flex items-center rounded-md p-1 text-fg-gold transition-colors hover:bg-surface hover:text-fg`,children:[(0,Y.jsx)(Tt,{className:`size-4`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`New entry`})]})]}),(y.length>0||b.length>0)&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-5 pb-2`,children:[y.map(e=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>f(t=>t===e?null:e),className:z(`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,Y.jsx)(`button`,{type:`button`,"aria-pressed":p===e,onClick:()=>m(t=>t===e?null:e),className:z(`rounded-md p-1 transition-colors`,p===e?`bg-action text-action-ink`:`text-fg-gold hover:bg-surface`),children:(0,Y.jsx)(At,{type:e,className:`size-3.5`})},e))]}),(0,Y.jsxs)(`div`,{className:`no-scrollbar max-h-[65vh] overflow-y-auto px-2 pb-3`,children:[l===`new`&&(0,Y.jsx)(`div`,{className:`px-3 py-2`,children:(0,Y.jsx)(bi,{defaultScope:n?`project`:`profile`,allowProject:n!==void 0,agents:i,onSave:w,onCancel:()=>u(null)})}),C.length===0&&l!==`new`&&(0,Y.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,Y.jsx)(`ul`,{className:`flex flex-col`,children:C.map(e=>l===e.id?(0,Y.jsx)(`li`,{className:`px-3 py-2`,children:(0,Y.jsx)(bi,{initial:e,defaultScope:e.scope,allowProject:n!==void 0||e.scope===`project`,agents:i,onSave:t=>T(e.id,t),onCancel:()=>u(null)})},e.id):(0,Y.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:z(`transition-opacity`,h===e.id&&`opacity-50`),children:(0,Y.jsx)(Si,{entry:e,onInsert:c?()=>{c(e.body),Ot(!1)}:null,onCopy:()=>O(e),onEdit:()=>u(e.id),onDelete:()=>s.mutate(e.id)})},e.id))})]})]})]})}function Si({entry:e,onInsert:t,onCopy:n,onEdit:r,onDelete:i}){let[a,o]=(0,J.useState)(!1);return(0,Y.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,Y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.title}),(0,Y.jsx)(`p`,{className:z(`line-clamp-3 whitespace-pre-wrap text-sm text-fg-secondary`,e.title&&`mt-0.5`),children:e.body}),a?(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:`Delete this entry? This can’t be undone.`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),i()},className:`text-2xs font-medium text-interrupted transition-colors hover:underline`,children:`Delete`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Cancel`})]}):(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:e.scope===`profile`?`Profile-wide`:`Project`}),e.agent_type&&(0,Y.jsx)(At,{type:e.agent_type,className:`size-3 text-fg-gold`}),e.tags.map(e=>(0,Y.jsx)(`span`,{className:`rounded-full bg-surface px-1.5 text-2xs text-fg-secondary`,children:e},e)),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[t&&(0,Y.jsx)(Ci,{icon:Nn,label:`Insert into focused terminal`,onClick:t}),(0,Y.jsx)(Ci,{icon:ut,label:`Copy`,onClick:n}),(0,Y.jsx)(Ci,{icon:h,label:`Edit`,onClick:r}),(0,Y.jsx)(Ci,{icon:wt,label:`Delete`,onClick:()=>o(!0)})]})]})]})}function Ci({icon:e,label:t,onClick:n}){return(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,Y.jsx)(e,{className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,Y.jsx)(V,{children:t})]})}var wi=a.parse({});function Ti(e,t){let[n,r]=(0,J.useState)(null),i=De(t).data,a=st(e??void 0,t&&e!==null).data;return(0,J.useEffect)(()=>{if(!t||e===null){r(null);return}let n=!1,i;try{i=Kt(sessionStorage.getItem(Gt(e)))}catch{i={kind:`absent`}}if(i.kind===`present`){r(i.snapshot);return}return Je(e).then(e=>{n||r(e?e.ui_state:wi)}).catch(()=>{n||r(wi)}),()=>{n=!0}},[t,e]),(0,J.useMemo)(()=>{if(!t||e===null||n===null)return null;let o=t=>{if(!i||!a)return!1;let{patch:o,projectBased:s}=Bt(n,t,{alive:new Set(i.filter(e=>e.status!==`archived`).map(e=>e.id)),sessionProject:new Map(i.map(e=>[e.id,e.project_id])),projectIds:a.map(e=>e.id),currentProject:null}),c={...n,...o};r(c),Ce(e,c).catch(e=>console.warn(`ui-state save failed: ${e.message}`));try{sessionStorage.setItem(Gt(e),JSON.stringify(c))}catch(e){console.warn(`ui-state write failed: ${e.message}`)}return j().projectBasedLayout!==s&&A({projectBasedLayout:s}),!0},s=Object.fromEntries(Object.entries(n.project_layouts).map(([e,t])=>[e,{layoutRef:t.layout_ref,signature:B(t.layout_tree)}]));return(n.layout_mode??`profile`)===`project`?{headless:!0,scope:`project`,projectId:``,layoutRef:null,signature:B(null),slices:s,capture:()=>({layout_tree:null,active_session:null}),apply:o}:{scope:`profile`,projectId:``,layoutRef:n.layout_ref,signature:B(n.layout_tree),slices:s,capture:()=>({layout_tree:n.layout_tree,active_session:n.active_session}),apply:o}},[t,e,n,i,a])}var Ei=B(null);function Di(){let e=Vt(),t=bt(),n=I(),r=Ut(),i=Ti(n,e&&r===null),a=r??i,o=Re(n??void 0,void 0).data??[],s=st(n??void 0,e&&n!==null).data??[],c=Ae(),l=rt(),u=Te(),[d,f]=(0,J.useState)(``),[p,h]=(0,J.useState)(!1),[g,_]=(0,J.useState)(null);(0,J.useEffect)(()=>le(`layouts.toggle`,zt),[]),(0,J.useEffect)(()=>{e||(f(``),h(!1),_(null))},[e]);let v=a?.headless===!0,y=a===null||v?null:o.find(e=>e.id===a.layoutRef)??null,b=a!==null&&!v&&(y===null?a.signature!==Ei:B(y.layout_tree)!==a.signature),x=e=>{let t=a?.slices?.[e];if(!t)return!1;let n=t.layoutRef===null?null:o.find(e=>e.id===t.layoutRef)??null;return n?B(n.layout_tree)!==t.signature:t.signature!==Ei},S=e=>a===null?!1:e.scope===`profile`?a.scope===`profile`&&b:e.project_id===null?!1:a.scope===`project`?!v&&e.project_id===a.projectId?b:x(e.project_id):b||x(e.project_id),C=e=>y!==null&&e.id===y.id,w=e=>(e===null?void 0:s.find(t=>t.id===e)?.name)??`Project`,T=a!==null&&!v&&a.scope===`project`?o.filter(e=>e.scope===`profile`||e.project_id===a.projectId):o,E=[...T.some(e=>e.scope===`profile`)?[{key:`profile`,name:`Profile-wide`}]:[],...[...new Set(T.flatMap(e=>e.project_id===null?[]:[e.project_id]))].map(e=>({key:e,name:w(e)})).sort((e,t)=>e.name.localeCompare(t.name))],D=g===null?T:g===`profile`?T.filter(e=>e.scope===`profile`):T.filter(e=>e.project_id===g),O=e=>a!==null&&e.scope===a.scope&&(a.scope===`profile`||e.project_id===a.projectId),k=(e,t,r)=>{!a||!n||c.mutate({profile_id:n,scope:a.scope,project_id:a.scope===`project`?a.projectId:void 0,name:e,...t},{onSuccess:e=>{r&&a.apply(e)},onError:e=>K(e)})},A=e=>{if(!a)return;let t=O(e)?e:o.find(t=>t.name===e.name&&O(t));if(!t){k(e.name,a.capture(),!0);return}l.mutate({id:t.id,...a.capture()},{onSuccess:e=>a.apply(e),onError:e=>K(e)})},j=(e,t)=>k(t,{layout_tree:e.layout_tree,active_session:e.active_session},!1),M=e=>{if(a){if(!a.apply(e)){ae.error(`Workspace is still loading — try again in a moment`);return}e.project_id!==null&&e.project_id!==a.projectId&&t(`/project/${e.project_id}`),Lt(!1)}};return(0,Y.jsxs)(ln,{open:e,onOpenChange:Lt,children:[(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsx)(cn,{asChild:!0,children:(0,Y.jsxs)(W,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,children:[(0,Y.jsx)(Pn,{}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Layouts`})]})})}),(0,Y.jsx)(V,{children:`Layouts`})]}),(0,Y.jsxs)(sn,{className:`w-[26rem] max-w-[calc(100vw-1rem)] p-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-5 pb-2 pt-4`,children:[(0,Y.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Layouts`}),a!==null&&!v&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>h(e=>!e),className:`ml-auto flex items-center rounded-md p-1 text-fg-gold transition-colors hover:bg-surface hover:text-fg`,children:[(0,Y.jsx)(Tt,{className:`size-4`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Save the current layout as a new layout`})]})]}),a===null?(0,Y.jsx)(`p`,{className:`px-5 pb-3 text-sm text-fg-muted`,children:`Loading the profile’s layout state…`}):v?(0,Y.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.`}):(y===null||p)&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 px-5 pb-3`,children:[y===null&&(0,Y.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:`Unnamed layout`}),(0,Y.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:a.scope===`profile`?`Profile-wide`:`Project`}),(0,Y.jsx)(`span`,{className:`ml-auto text-2xs text-interrupted`,children:`Unsaved`})]}),(0,Y.jsxs)(`form`,{className:`flex items-center gap-1.5`,onSubmit:e=>{e.preventDefault();let t=d.trim();t&&(k(t,a.capture(),!0),f(``),h(!1))},children:[(0,Y.jsx)(m,{autoFocus:p,value:d,placeholder:y===null?`Name this layout…`:`Save as a new layout…`,spellCheck:!1,onChange:e=>f(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&h(!1)},className:`h-8 flex-1 text-sm`}),(0,Y.jsx)(W,{size:`sm`,type:`submit`,disabled:!d.trim(),children:`Save`}),y!==null&&(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,onClick:()=>h(!1),children:`Cancel`})]})]}),E.length>1&&(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 px-5 pb-2`,children:E.map(e=>(0,Y.jsx)(Ai,{active:g===e.key,onClick:()=>_(t=>t===e.key?null:e.key),children:e.name},e.key))}),(0,Y.jsxs)(`div`,{className:`no-scrollbar max-h-[60vh] overflow-y-auto px-2 pb-3`,children:[D.length===0&&(0,Y.jsx)(`p`,{className:`px-3 py-3 text-sm text-fg-muted`,children:g===null?`No layouts yet — name and save the current layout to keep it.`:`Nothing matches this filter.`}),(0,Y.jsx)(`ul`,{className:`flex flex-col`,children:D.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(Oi,{layout:e,projectLabel:e.scope===`profile`?null:w(e.project_id),isCurrent:C(e),dirty:b,loadable:a!==null,savable:a!==null&&!v,confirmBeforeLoad:S(e),overwrites:O(e),onLoad:()=>M(e),onRename:t=>l.mutate({id:e.id,name:t}),onDelete:()=>u.mutate(e.id),onSaveAs:()=>A(e),onDuplicate:t=>j(e,t)})},e.id))})]})]})]})}function Oi({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,g]=(0,J.useState)(null),[_,v]=(0,J.useState)(null),[y,b]=(0,J.useState)(e.name),x=()=>{if(!(!i||_!==null)){if(o&&p!==`load`){g(`load`);return}g(null),c()}},S=t=>{g(null),b(t===`rename`?e.name:`${e.name} copy`),v(t)},C=()=>{if(n){d();return}g(`save`)},w=n?r?`unsaved`:`active`:null;return(0,Y.jsxs)(`div`,{onClick:e=>{e.target.closest(`button, input`)||x()},className:z(`rounded-md px-3 py-2.5 transition-colors`,i&&`cursor-pointer hover:bg-surface`),children:[_===null?(0,Y.jsxs)(`p`,{className:z(`flex items-baseline gap-2 text-sm font-medium`,w===`active`?`text-success`:w===`unsaved`?`text-interrupted`:`text-fg`),children:[e.name,w!==null&&(0,Y.jsx)(`span`,{className:`text-2xs font-normal`,children:w===`active`?`Active`:`Unsaved`})]}):(0,Y.jsxs)(`form`,{className:`flex items-center gap-1.5`,onSubmit:t=>{t.preventDefault();let n=y.trim();n&&(_===`rename`?n!==e.name&&l(n):f(n)),v(null)},children:[(0,Y.jsx)(m,{autoFocus:!0,value:y,spellCheck:!1,onChange:e=>b(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&v(null)},className:`h-7 flex-1 text-sm`}),(0,Y.jsx)(W,{size:`sm`,type:`submit`,disabled:!y.trim(),children:_===`rename`?`Rename`:`Save`})]}),p===`save`?(0,Y.jsx)(ki,{question:s?`Overwrite “${e.name}” with the current layout?`:`Save the current layout as “${e.name}” here?`,verb:s?`Overwrite`:`Save`,onConfirm:()=>{g(null),d()},onCancel:()=>g(null)}):p===`delete`?(0,Y.jsx)(ki,{question:`Delete this layout? This can’t be undone.`,verb:`Delete`,onConfirm:()=>{g(null),u()},onCancel:()=>g(null)}):p===`load`?(0,Y.jsx)(ki,{question:`Loading discards unsaved layout changes.`,verb:`Load`,onConfirm:x,onCancel:()=>g(null)}):(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:[t!==null&&(0,Y.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:t}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[a&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ji,{icon:Ln,label:n?`Save`:`Save the current layout as “${e.name}”`,onClick:C}),(0,Y.jsx)(ji,{icon:ut,label:`Duplicate`,onClick:()=>S(`duplicate`)})]}),(0,Y.jsx)(ji,{icon:h,label:`Rename`,onClick:()=>S(`rename`)}),(0,Y.jsx)(ji,{icon:wt,label:`Delete`,onClick:()=>g(`delete`)})]})]})]})}function ki({question:e,verb:t,onConfirm:n,onCancel:r}){return(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e}),(0,Y.jsx)(`button`,{type:`button`,onClick:n,className:`text-2xs font-medium text-interrupted transition-colors hover:underline`,children:t}),(0,Y.jsx)(`button`,{type:`button`,onClick:r,className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Cancel`})]})}function Ai({active:e,onClick:t,children:n}){return(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:t,className:z(`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 ji({icon:e,label:t,onClick:n}){return(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,Y.jsx)(e,{className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,Y.jsx)(V,{children:t})]})}var Mi=nt()!==void 0&&/Mac/.test(navigator.platform),Ni=(0,J.lazy)(()=>M(()=>import(`./SettingsDialog-Sd6i7Plz.js`).then(e=>({default:e.SettingsDialog})),__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])));function Pi(){let e=_e();(0,J.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 Fi(){let e=qe(),t=Xe(),[n,r]=(0,J.useState)(!1),i=Se(e.data),a=n=>{r(!1);let a=n.trim();a!==i&&t.mutate({displayName:a===e.data?.hostname?``:a},{onError:e=>K(e)})},o=!Mi&&(0,Y.jsx)(`img`,{src:`/puddle.svg`,alt:`Puddle`,className:`size-4`}),s=z(`flex shrink-0 items-center gap-2`,Mi&&`[-webkit-app-region:no-drag]`),c=`truncate text-sm font-semibold text-fg-secondary`;return n&&i!==void 0?(0,Y.jsxs)(`div`,{className:s,children:[o,(0,Y.jsx)(Rt,{initial:e.data?.displayName??i,maxLength:64,className:z(c,`w-40`),onCommit:a,onCancel:()=>r(!1)})]}):(0,Y.jsxs)(dt,{to:`/`,className:z(s,`transition-opacity hover:opacity-70`),title:`All projects`,children:[o,i!==void 0&&(0,Y.jsx)(`span`,{className:c,...qt(()=>r(!0)),children:i})]})}function Ii(){let e=pt(),t=de(`palette.toggle`),n=it(e.id).data?.project,r=n!==void 0&&n.id===e.id?n.name:void 0;return(0,Y.jsxs)(`button`,{type:`button`,onClick:jt,className:z(`absolute left-1/2 flex h-6 w-[min(30rem,42%)] -translate-x-1/2 items-center justify-center gap-2 rounded-md bg-ground text-fg-muted transition-colors hover:bg-elevated hover:text-fg-secondary`,Mi&&`[-webkit-app-region:no-drag]`),children:[(0,Y.jsx)(`span`,{className:z(`truncate text-xs`,r&&f(n?.colour)),children:r??`Puddle`}),(0,Y.jsx)(`span`,{className:`text-2xs`,children:t})]})}function Li(){let{fullScreen:e,animate:t}=Ze();return(0,Y.jsxs)(`header`,{className:z(`relative flex h-9 shrink-0 items-center gap-3 bg-surface pl-3 pr-3`,Mi&&!e&&`pl-[88px] [-webkit-app-region:drag]`,t&&`transition-[padding] duration-200 ease-out`),children:[(0,Y.jsx)(Fi,{}),(0,Y.jsx)(Ii,{}),(0,Y.jsxs)(`div`,{className:z(`ml-auto flex items-center`,Mi&&`[-webkit-app-region:no-drag]`),children:[(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsxs)(W,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,onClick:()=>Yt(),children:[(0,Y.jsx)(zn,{}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Settings`})]})}),(0,Y.jsx)(V,{children:`Settings`})]}),(0,Y.jsx)(Di,{}),(0,Y.jsx)(xi,{}),(0,Y.jsx)(ri,{})]})]})}function Ri(){Pi(),oi(),vi();let{handler:e}=kt(),t=I(),{pathname:n}=ht(),[r,i]=(0,J.useState)(!1),a=Pe(),o=a.data!==void 0&&Qe(a.data.protocol);return(0,J.useEffect)(()=>{if(!o)return;let e=()=>{let e=te();q.reportTheme(e(`--text-primary`),e(`--bg-base`))};return e(),ee(e)},[o]),(0,Y.jsxs)(`div`,{className:`flex h-screen flex-col overflow-hidden overscroll-y-none bg-ground`,children:[(0,Y.jsx)(Li,{}),(0,Y.jsx)(`main`,{className:`min-h-0 flex-1`,children:(0,Y.jsx)(hn,{resetOn:n,scope:n.startsWith(`/project/`)?`workspace`:`view`,children:(0,Y.jsx)(_t,{})})}),(0,Y.jsx)(Qr,{}),(0,Y.jsx)(ai,{}),(0,Y.jsx)(qr,{onNewSession:e??void 0,onNewProject:()=>i(!0)}),t!==null&&(0,Y.jsx)($t,{profileId:t,open:r,onOpenChange:i}),(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(Ni,{})}),(0,Y.jsx)(Xr,{})]})}function zi(){return(0,Y.jsx)(Wt,{children:(0,Y.jsx)(Ri,{})})}var Bi=(0,J.lazy)(()=>M(()=>import(`./Dashboard-fA7E3Mr1.js`).then(e=>({default:e.Dashboard})),__vite__mapDeps([30,1,2,3,4,5,6,7,8,9,10,13,12,31,20,32,23,33,34,16,27,26,35]))),Vi=(0,J.lazy)(()=>M(()=>import(`./Workspace-C-M1AjMn.js`).then(e=>({default:e.Workspace})),__vite__mapDeps([36,1,2,3,4,5,6,7,8,9,10,17,18,19,12,13,37,38,23,33,31,15,39,14,40,41,20,32,42,21,22,43,35,26,16,44,45,46,29,47]))),Hi=new mn({defaultOptions:{queries:{retry:1,staleTime:5e3}},mutationCache:new dn({onError:e=>K(e)})});function Ui(){let e=I(),t=Le(),n=e!==null&&t.data!==void 0&&!t.data.some(t=>t.id===e);return e===null||n?(0,Y.jsx)(Bn,{}):(0,Y.jsx)(mt,{useTransitions:!1,children:(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(ft,{children:(0,Y.jsxs)(vt,{element:(0,Y.jsx)(zi,{}),children:[(0,Y.jsx)(vt,{path:`/`,element:(0,Y.jsx)(Bi,{})}),(0,Y.jsx)(vt,{path:`/project/:id`,element:(0,Y.jsx)(Vi,{})}),(0,Y.jsx)(vt,{path:`/project/:id/session/:sid`,element:(0,Y.jsx)(Vi,{})})]})})})})}function Wi(){let e=(0,J.useSyncExternalStore)(u.subscribe,u.get);return(0,Y.jsx)(pe,{client:Hi,children:(0,Y.jsxs)(It,{delayDuration:300,children:[(0,Y.jsx)(Mn,{}),(0,Y.jsx)(hn,{scope:`app`,children:e?window.location.pathname.startsWith(`/forward/`)?(0,Y.jsx)(un,{}):(0,Y.jsx)(Ui,{}):(0,Y.jsx)(_n,{})}),(0,Y.jsx)(gn,{})]})})}export{Wi as App};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SettingsDialog-DiwhE5dK.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/jsx-runtime-ffCh33zF.js","assets/auth-BxExwqPW.js","assets/LazyTerminal-gX1-vBQf.js","assets/preload-helper-Czpn1I53.js","assets/es2015-CrC2hHeB.js","assets/x-DCpy1q13.js","assets/createLucideIcon-DyMAgLa3.js","assets/recipes-K5GH3Kht.js","assets/notification-delivery-CoCRZRSK.js","assets/dist-7fft9rhQ.js","assets/protocol-support-gmAQBWF3.js","assets/switch-OD1b2aeq.js","assets/dist-BCwJL3w9.js","assets/dialog-Bnex_wlx.js","assets/client-settings-CwqpIric.js","assets/index-BRywm-gU.js","assets/index-XBWIhnuP.css","assets/button-Chvl9hcE.js","assets/select-YFIOZ3zx.js","assets/chevron-down--sjpQEHH.js","assets/dist-DmyIHyF9.js","assets/code-DRWf9a5s.js","assets/rotate-ccw-CNjR2LSi.js","assets/errors-DhRwiizF.js","assets/use-debounced-value-C86N-mOK.js","assets/popover-C-BfSLgw.js","assets/disclosure-7lu23NnB.js","assets/Dashboard-7gBsrB7q.js","assets/project-abbrev-DX_a_ySv.js","assets/context-menu-DVUv5Z6a.js","assets/dist-B67qxih2.js","assets/NewProjectDialog-CDYUPliQ.js","assets/ws-oU1ansI7.js","assets/Workspace-cfjpv0xU.js","assets/copy-CjatFFf8.js","assets/media-refresh-store-DLtYZTP9.js","assets/use-ui-state-C2LCTPRw.js","assets/preview-kind-CJ9RTgbs.js","assets/debounce-B9DrqirV.js","assets/whole-word-2m2pmAFT.js","assets/selection-actions-BZy4596m.js","assets/drafts-B_tChlzR.js","assets/buffer-logic-BAkSBQT7.js","assets/scroll-restoration-hg7BYUz2.js","assets/Workspace-DdL3ODEC.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{n,t as r}from"./jsx-runtime-ffCh33zF.js";import{B as i,O as a,V as o,j as s,l as c,o as l,r as u,v as d}from"./auth-BxExwqPW.js";import{a as f,c as p,l as m,o as h,u as g}from"./LazyTerminal-gX1-vBQf.js";import{a as _,d as v,f as y,g as b,h as x,i as S,l as C,m as w,o as T,s as E,t as D,u as O}from"./notification-delivery-CoCRZRSK.js";import{i as k,r as A,t as j}from"./client-settings-CwqpIric.js";import{t as M}from"./preload-helper-Czpn1I53.js";import{a as ee,n as te,o as ne,r as re,t as N}from"./index-BRywm-gU.js";import{i as ie,n as ae,t as oe}from"./dist-7fft9rhQ.js";import{$t as se,A as ce,C as le,D as ue,E as de,F as fe,Ft as pe,Gt as me,Ht as he,I as ge,It as _e,Jt as ve,Kt as ye,L as be,Lt as xe,M as Se,N as Ce,O as we,Q as Te,Qt as Ee,R as De,S as Oe,Tt as ke,U as Ae,Ut as P,W as je,Wt as Me,Xt as Ne,Y as Pe,Yt as F,Zt as Fe,_ as Ie,_t as Le,at as Re,b as ze,dt as Be,en as Ve,et as He,ft as Ue,g as We,gt as Ge,ht as Ke,it as qe,j as Je,k as I,kt as Ye,lt as Xe,nn as Ze,o as Qe,ot as $e,q as et,qt as tt,tn as nt,ut as rt,vt as it,w as at,y as ot,yt as st,zt as ct}from"./protocol-support-gmAQBWF3.js";import{n as lt,t as ut}from"./copy-CjatFFf8.js";import{a as dt,c as ft,d as pt,i as mt,l as ht,n as gt,o as _t,s as vt,t as yt,u as bt}from"./project-abbrev-DX_a_ySv.js";import{c as L,p as R}from"./es2015-CrC2hHeB.js";import{n as z,s as xt}from"./x-DCpy1q13.js";import{i as St,n as Ct}from"./recipes-K5GH3Kht.js";import{n as wt,r as Tt}from"./dist-BCwJL3w9.js";import{$ as Et,G as Dt,H as Ot,J as kt,K as At,Q as jt,U as Mt,W as Nt,X as Pt,Y as Ft,at as It,d as Lt,et as Rt,f as zt,h as B,i as Bt,it as V,m as Vt,nt as Ht,ot as H,p as Ut,q as Wt,r as Gt,rt as U,t as Kt,tt as qt}from"./use-ui-state-C2LCTPRw.js";import{t as W}from"./button-Chvl9hcE.js";import{t as G}from"./createLucideIcon-DyMAgLa3.js";import{c as Jt,i as Yt,s as Xt,t as Zt,u as Qt}from"./switch-OD1b2aeq.js";import{t as $t}from"./NewProjectDialog-CDYUPliQ.js";import{n as K}from"./errors-DhRwiizF.js";import{t as q}from"./ws-oU1ansI7.js";import{c as en,l as tn,n as nn,s as rn,t as an,u as on}from"./dialog-Bnex_wlx.js";import{n as sn,r as cn,t as ln}from"./popover-C-BfSLgw.js";var J=e(t(),1),Y=r();function un(){let[e,t]=(0,J.useState)(`Opening forwarded application…`);return(0,J.useEffect)(()=>{if(!/^\/forward\/([^/]+)\/(\d+)$/.exec(window.location.pathname)){t(`This forwarding link is invalid.`);return}let e=!0;return lt(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,Y.jsx)(`p`,{className:`p-8 text-sm text-fg-secondary`,children:e})}var dn=class extends Ve{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new xe({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=fn(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=fn(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=fn(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=fn(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){P.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>tt(t,e))}findAll(e={}){return this.getAll().filter(t=>tt(e,t))}notify(e){P.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return P.batch(()=>Promise.all(e.map(e=>e.continue().catch(F))))}};function fn(e){return e.options.scope?.id}var pn=class extends Ve{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??ye(r,t),a=this.get(i);return a||(a=new ct({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){P.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ve(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>ve(e,t)):t}notify(e){P.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){P.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){P.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},mn=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new pn,this.#t=e.mutationCache||new dn,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=se.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=he.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Fe(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=Me(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return P.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;P.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return P.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=P.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(F).catch(F)}invalidateQueries(e,t={}){return P.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=P.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(F)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(F)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Fe(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(F).catch(F)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(F).catch(F)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return he.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(me(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Ne(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(me(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Ne(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=ye(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===Ee&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},hn=class extends J.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,Y.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,Y.jsxs)(`p`,{className:`text-sm text-fg`,children:[`The `,this.props.scope,` stopped rendering.`]}),(0,Y.jsx)(`p`,{className:`max-w-lg font-mono text-2xs leading-relaxed text-interrupted`,children:e.message||String(e)}),(0,Y.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,Y.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Y.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,Y.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Reload`})]})]})}};function gn(){return(0,Y.jsx)(oe,{theme:(0,J.useSyncExternalStore)(ee,re),position:`bottom-right`,toastOptions:{style:{background:`var(--bg-elevated)`,border:`none`,boxShadow:`0 8px 30px rgb(0 0 0 / 0.25)`,color:`var(--text-primary)`},classNames:{description:`whitespace-pre-wrap break-words font-mono text-2xs leading-snug max-h-40 overflow-y-auto`}}})}function _n(){return(0,Y.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-ground`,children:(0,Y.jsxs)(`div`,{className:`flex w-full max-w-md flex-col gap-10 px-8 pb-24`,children:[(0,Y.jsx)(`h1`,{className:`font-mono text-2xl font-semibold text-fg`,children:`Puddle`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 text-sm leading-relaxed text-fg-secondary`,children:[(0,Y.jsxs)(`p`,{children:[`Authorise this browser by running`,` `,(0,Y.jsx)(`span`,{className:`font-mono text-accent`,children:`puddle launch`}),` in a terminal.`]}),(0,Y.jsx)(`p`,{children:`Use the link it opens. Your sessions, drafts and layouts stay in place.`})]})]})})}var vn=e(n(),1),yn=`a, button, [role="button"], [role="slider"], input, select, textarea, summary, label, [onclick], .cursor-pointer`,bn=`.monaco-editor`;function xn(e,t){return e?.closest(bn)&&!e.closest(t)?`text`:e?.closest(yn)?`interactive`:`default`}function Sn(e,t=`.no-custom-caret`){(0,J.useEffect)(()=>{let n=e.current;if(!n)return;let r=window.matchMedia(`(pointer: fine)`),i=()=>{n.style.opacity=`0`},a=e=>{if(e.pointerType===`touch`||!r.matches){i();return}n.style.transform=`translate3d(${e.clientX}px, ${e.clientY}px, 0) translate(-50%, -50%)`;let a=e.target instanceof Element?e.target:null;if(a instanceof HTMLIFrameElement){i();return}n.style.opacity=`1`;let o=a?.closest(bn),s=xn(a,t),c=s===`text`,l=s===`interactive`,u=c;if(c&&o){let e=getComputedStyle(o);n.style.setProperty(`--custom-cursor-caret-height`,`${Math.round(Number.parseFloat(e.fontSize)*1.3)}px`)}else if(!l&&a&&!a.closest(t)&&Array.from(a.childNodes).some(e=>e.nodeType===Node.TEXT_NODE&&e.textContent?.trim())){let e=getComputedStyle(a);e.userSelect!==`none`&&(u=!0,n.style.setProperty(`--custom-cursor-caret-height`,`${Math.round(Number.parseFloat(e.fontSize)*1.3)}px`))}n.classList.toggle(`is-interactive`,l),n.classList.toggle(`is-text`,u)};return window.addEventListener(`pointermove`,a,{passive:!0}),document.documentElement.addEventListener(`pointerleave`,i),window.addEventListener(`blur`,i),()=>{window.removeEventListener(`pointermove`,a),document.documentElement.removeEventListener(`pointerleave`,i),window.removeEventListener(`blur`,i)}},[t,e])}var Cn=[`top`,`right`,`bottom`,`left`];function wn(){let e=(0,J.useRef)(null);return Sn(e),(0,Y.jsx)(`div`,{ref:e,className:`custom-cursor drafting-cursor`,"aria-hidden":`true`,children:Cn.map(e=>(0,Y.jsx)(`span`,{className:`drafting-cursor-tick`,"data-side":e},e))})}function Tn(){let e=(0,J.useRef)(null);return Sn(e),(0,Y.jsx)(`div`,{ref:e,className:`custom-cursor invert-cursor`,"aria-hidden":`true`})}var En=`h1, h2, h3, h4, h5, h6, .no-rangefinder-caret`,Dn=40.5,X=4.05,On=X*Math.sqrt(3)/2;function kn(){let e=[],t=[],n=Dn/2,r=Math.ceil(n/On)+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*On,s=o+On,c=(i%2+2)%2*(X/2);for(let i=-r;i<r;i+=1){let r=n+i*X+c,l=[[r+X/2,o],[r,s],[r+X,s]],u=[[r+X/2,o],[r+3*X/2,o],[r+X,s]],d=e=>{let t=e.map(([e])=>e),n=e.map(([,e])=>e);return Math.max(...t)>0&&Math.min(...t)<Dn&&Math.max(...n)>0&&Math.min(...n)<Dn};d(l)&&e.push(a(l)),d(u)&&t.push(a(u))}}return{light:e.join(``),dark:t.join(``)}}var An=kn();function jn(){let e=(0,J.useRef)(null);return Sn(e,En),(0,Y.jsx)(`div`,{ref:e,className:`custom-cursor rangefinder-cursor`,"aria-hidden":`true`,children:(0,Y.jsxs)(`svg`,{className:`rangefinder-cursor-facets`,viewBox:`0 0 ${Dn} ${Dn}`,focusable:`false`,children:[(0,Y.jsx)(`path`,{className:`rangefinder-cursor-facet-light`,d:An.light}),(0,Y.jsx)(`path`,{className:`rangefinder-cursor-facet-dark`,d:An.dark})]})})}function Mn(){let{cursorPackage:e}=k(),t=null;switch(e){case`rangefinder`:t=(0,Y.jsx)(jn,{});break;case`drafting`:t=(0,Y.jsx)(wn,{});break;case`invert`:t=(0,Y.jsx)(Tn,{});break;case`system`:return null}return(0,vn.createPortal)(t,document.body)}var Nn=G(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),Pn=G(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),Fn=G(`monitor-cog`,[[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`m14.305 7.53.923-.382`,key:`1mlnsw`}],[`path`,{d:`m15.228 4.852-.923-.383`,key:`82mpwg`}],[`path`,{d:`m16.852 3.228-.383-.924`,key:`ln4sir`}],[`path`,{d:`m16.852 8.772-.383.923`,key:`1dejw0`}],[`path`,{d:`m19.148 3.228.383-.924`,key:`192kgf`}],[`path`,{d:`m19.53 9.696-.382-.924`,key:`fiavlr`}],[`path`,{d:`m20.772 4.852.924-.383`,key:`1j8mgp`}],[`path`,{d:`m20.772 7.148.924.383`,key:`zix9be`}],[`path`,{d:`M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7`,key:`1tnzv8`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}]]),In=G(`notebook-pen`,[[`path`,{d:`M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4`,key:`re6nr2`}],[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`path`,{d:`M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`pqwjuv`}]]),Ln=G(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),Rn=G(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),zn=G(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]);function Bn(){let e=Le(),t=je(),[n,r]=(0,J.useState)(``),[i,a]=(0,J.useState)(s),o=()=>{n.trim()&&t.mutate({name:n.trim(),branch_prefix:i.trim()},{onSuccess:e=>we(e.id)})},c=(e.data?.length??0)>0;return(0,Y.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-ground`,children:(0,Y.jsxs)(`div`,{className:`flex w-full max-w-md flex-col gap-10 px-8 pb-16`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`h1`,{className:`font-mono text-2xl font-semibold text-fg`,children:`Puddle`}),(0,Y.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`Who is working?`})]}),c&&(0,Y.jsx)(`div`,{className:`flex flex-col`,children:e.data.map(e=>(0,Y.jsxs)(`button`,{onClick:()=>we(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,Y.jsx)(y,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,Y.jsx)(`span`,{className:z(`text-base`,f(e.icon_colour)||`text-fg`),children:e.name}),e.branch_prefix&&(0,Y.jsxs)(`span`,{className:`ml-auto text-2xs text-fg-muted`,children:[e.branch_prefix,`…`]})]},e.id))}),(0,Y.jsxs)(`form`,{className:`flex flex-col gap-5`,onSubmit:e=>{e.preventDefault(),o()},children:[c&&(0,Y.jsx)(`p`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`or create a profile`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(p,{htmlFor:`profile-name`,children:`Name`}),(0,Y.jsx)(m,{id:`profile-name`,placeholder:`e.g. alice`,value:n,onChange:e=>r(e.target.value),className:`h-10`,autoFocus:!c})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(p,{htmlFor:`branch-prefix`,children:`Branch prefix`}),(0,Y.jsx)(m,{id:`branch-prefix`,placeholder:`no prefix`,value:i,onChange:e=>a(e.target.value),className:`h-10`})]}),t.error&&(0,Y.jsx)(`p`,{className:`text-xs text-danger`,children:t.error.message}),(0,Y.jsx)(W,{type:`submit`,size:`lg`,className:`self-start px-6`,disabled:!n.trim()||t.isPending,children:`Create profile`})]})]})})}var Vn=1,Hn=.9,Un=.8,Wn=.17,Gn=.1,Kn=.999,qn=.9999,Jn=.99,Yn=/[\\\/_+.#"@\[\(\{&]/,Xn=/[\\\/_+.#"@\[\(\{&]/g,Zn=/[\s-]/,Qn=/[\s-]/g;function $n(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Vn:Jn;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=$n(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=Vn:Yn.test(e.charAt(l-1))?(d*=Un,p=e.slice(i,l-1).match(Xn),p&&i>0&&(d*=Kn**+p.length)):Zn.test(e.charAt(l-1))?(d*=Hn,m=e.slice(i,l-1).match(Qn),m&&i>0&&(d*=Kn**+m.length)):(d*=Wn,i>0&&(d*=Kn**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=qn)),(d<Gn&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=$n(e,t,n,r,l+1,a+2,o),f*Gn>d&&(d=f*Gn)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function er(e){return e.toLowerCase().replace(Qn,` `)}function tr(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,$n(e,t,er(e),er(t),0,0,{})}var nr=`[cmdk-group=""]`,rr=`[cmdk-group-items=""]`,ir=`[cmdk-group-heading=""]`,ar=`[cmdk-item=""]`,or=`${ar}:not([aria-disabled="true"])`,sr=`cmdk-item-select`,Z=`data-value`,cr=(e,t,n)=>tr(e,t,n),lr=J.createContext(void 0),ur=()=>J.useContext(lr),dr=J.createContext(void 0),fr=()=>J.useContext(dr),pr=J.createContext(void 0),mr=J.forwardRef((e,t)=>{let n=Dr(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Dr(()=>new Set),i=Dr(()=>new Map),a=Dr(()=>new Map),o=Dr(()=>new Set),s=Er(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=L(),y=L(),b=L(),x=J.useRef(null),S=kr();Q(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),Q(()=>{S(6,k)},[]);let C=J.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=J.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??cr;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(rr);t?t.appendChild(e.parentElement===t?e:e.closest(`${rr} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${rr} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${nr}[${Z}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(Z);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(nr)?.querySelector(ir))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${ar}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(or)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(Z))}function ee(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(Z))}function te(e){let t=A()?.closest(nr),n;for(;t&&!n;)t=e>0?wr(t,nr):Tr(t,nr),n=t?.querySelector(or);n?C.setState(`value`,n.getAttribute(Z)):ee(e)}let ne=()=>M(j().length-1),re=e=>{e.preventDefault(),e.metaKey?ne():e.altKey?te(1):ee(1)},N=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?te(-1):ee(-1)};return J.createElement(R.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&re(e);break;case`ArrowDown`:re(e);break;case`p`:case`k`:g&&e.ctrlKey&&N(e);break;case`ArrowUp`:N(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),ne();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(sr);t.dispatchEvent(e)}}}}},J.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:Mr},c),jr(e,e=>J.createElement(dr.Provider,{value:C},J.createElement(lr.Provider,{value:w},e))))}),hr=J.forwardRef((e,t)=>{let n=L(),r=J.useRef(null),i=J.useContext(pr),a=ur(),o=Er(e),s=o.current?.forceMount??i?.forceMount;Q(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=Or(n,r,[e.value,e.children,r],e.keywords),l=fr(),u=$(e=>e.value&&e.value===c.current),d=$(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);J.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(sr,f),()=>t.removeEventListener(sr,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return J.createElement(R.div,{ref:xt(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),gr=J.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=L(),s=J.useRef(null),c=J.useRef(null),l=L(),u=ur(),d=$(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));Q(()=>u.group(o),[]),Or(o,s,[e.value,e.heading,c]);let f=J.useMemo(()=>({id:o,forceMount:i}),[i]);return J.createElement(R.div,{ref:xt(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&J.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),jr(e,e=>J.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},J.createElement(pr.Provider,{value:f},e))))}),_r=J.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=J.useRef(null),a=$(e=>!e.search);return!n&&!a?null:J.createElement(R.div,{ref:xt(i,t),...r,"cmdk-separator":``,role:`separator`})}),vr=J.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=fr(),o=$(e=>e.search),s=$(e=>e.selectedItemId),c=ur();return J.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),J.createElement(R.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),yr=J.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=J.useRef(null),o=J.useRef(null),s=$(e=>e.selectedItemId),c=ur();return J.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),J.createElement(R.div,{ref:xt(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},jr(e,e=>J.createElement(`div`,{ref:xt(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),br=J.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return J.createElement(rn,{open:n,onOpenChange:r},J.createElement(on,{container:o},J.createElement(tn,{"cmdk-overlay":``,className:i}),J.createElement(en,{"aria-label":e.label,"cmdk-dialog":``,className:a},J.createElement(mr,{ref:t,...s}))))}),xr=J.forwardRef((e,t)=>$(e=>e.filtered.count===0)?J.createElement(R.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),Sr=J.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return J.createElement(R.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},jr(e,e=>J.createElement(`div`,{"aria-hidden":!0},e)))}),Cr=Object.assign(mr,{List:yr,Item:hr,Input:vr,Group:gr,Separator:_r,Dialog:br,Empty:xr,Loading:Sr});function wr(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Tr(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Er(e){let t=J.useRef(e);return Q(()=>{t.current=e}),t}var Q=typeof window>`u`?J.useEffect:J.useLayoutEffect;function Dr(e){let t=J.useRef();return t.current===void 0&&(t.current=e()),t}function $(e){let t=fr(),n=()=>e(t.snapshot());return J.useSyncExternalStore(t.subscribe,n,n)}function Or(e,t,n,r=[]){let i=J.useRef(),a=ur();return Q(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(Z,s),i.current=s}),i}var kr=()=>{let[e,t]=J.useState(),n=Dr(()=>new Map);return Q(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function Ar(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function jr({asChild:e,children:t},n){return e&&J.isValidElement(t)?J.cloneElement(Ar(t),{ref:t.ref},n(t.props.children)):n(t)}var Mr={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function Nr({className:e,...t}){return(0,Y.jsx)(Cr,{className:z(`flex size-full flex-col overflow-hidden rounded-lg bg-elevated`,e),...t})}function Pr({open:e,onOpenChange:t,children:n}){return(0,Y.jsx)(an,{open:e,onOpenChange:t,children:(0,Y.jsx)(nn,{className:`max-w-lg overflow-hidden p-0 [&>button]:hidden`,children:(0,Y.jsx)(Nr,{loop:!0,children:n})})})}function Fr({className:e,...t}){return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pt-1`,children:[(0,Y.jsx)(Ht,{className:`size-4 shrink-0 text-fg-muted`}),(0,Y.jsx)(Cr.Input,{className:z(`flex h-10 w-full bg-transparent text-sm text-fg outline-none placeholder:text-fg-muted`,e),...t})]})}function Ir({className:e,...t}){return(0,Y.jsx)(Cr.List,{className:z(`max-h-72 overflow-y-auto p-1`,e),...t})}function Lr(e){return(0,Y.jsx)(Cr.Empty,{className:`py-6 text-center text-sm text-fg-muted`,...e})}function Rr({className:e,...t}){return(0,Y.jsx)(Cr.Group,{className:z(`overflow-hidden [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-2xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-wide [&_[cmdk-group-heading]]:text-fg-muted`,e),...t})}function zr({className:e,...t}){return(0,Y.jsx)(Cr.Item,{className:z(St,Ct,`[&_svg]:size-3.5 [&_svg]:text-fg-muted data-[selected=true]:[&_svg]:text-action-ink`,e),...t})}function Br({className:e,...t}){return(0,Y.jsx)(`span`,{className:z(`ml-auto font-mono text-2xs tracking-widest text-fg-muted`,e),...t})}var Vr=new class{transport;reload;pause;phase=`idle`;pending=null;constructor(e=fetch,t=()=>window.location.reload(),n=e=>new Promise(t=>setTimeout(t,e))){this.transport=e,this.reload=t,this.pause=n}refresh(e=12e4){return this.pending||=this.run(e).finally(()=>{this.pending=null}),this.pending}async run(e){this.phase=`requesting`;let t={authorization:`Bearer ${u.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=d.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;return this.phase=`complete`,this.reload(),!0}catch{}}}catch{}return this.phase=`failed`,!1}},Hr=null;function Ur(e){return Hr=e,()=>{Hr===e&&(Hr=null)}}function Wr(){Hr?.()}var Gr=new Set;function Kr(){return[...Gr].flatMap(e=>e())}function qr({onNewSession:e,onNewProject:t}){let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(`commands`),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(!1),f=bt(),p=pt(),m=I(),h=p.id,g=st(m??void 0),_=Ye(h),v=Ft();(0,J.useEffect)(()=>le(`palette.toggle`,()=>r(e=>!e)),[]),(0,J.useEffect)(()=>Et(()=>r(!0)),[]),(0,J.useEffect)(()=>{n||(a(`commands`),s(``),l(null),d(!1))},[n]);let y=(0,J.useMemo)(()=>{let n=[];for(let e of g.data??[])n.push({id:`project-${e.id}`,group:`Projects`,label:e.name,icon:gt,keywords:`switch project open`,run:()=>void f(`/project/${e.id}`)});for(let e of _.data??[])e.status!==`archived`&&n.push({id:`session-${e.id}`,group:`Sessions`,label:v(e),icon:yt,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:Qt,keywords:`new agent create start session`,run:()=>e()},{id:`new-terminal`,group:`Actions`,label:`New terminal`,icon:yt,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:gt,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:Tt,keywords:`new project open create repository repo workspace`,run:t}),n.push({id:`theme-dark`,group:`Theme`,label:`Switch theme: dark`,icon:x,keywords:`switch theme dark appearance`,run:()=>void N(`dark`)},{id:`theme-light`,group:`Theme`,label:`Switch theme: light`,icon:w,keywords:`switch theme light appearance`,run:()=>void N(`light`)},{id:`theme-system`,group:`Theme`,label:`Switch theme: system`,icon:Fn,keywords:`switch theme system appearance`,run:()=>void N(`system`)},{id:`open-settings`,group:`Actions`,label:`Settings`,icon:zn,keywords:`open settings preferences options configure`,run:()=>Yt()},{id:`switch-profile`,group:`Actions`,label:`Switch profile`,icon:Xt,keywords:`switch profile identity user change`,run:()=>ue.set(null)},{id:`refresh-connection`,group:`Actions`,label:`Refresh connection`,icon:Jt,keywords:`refresh connection reconnect restart cockpit tunnel ssh daemon`,run:()=>Wr()}),[...n,...Kr()]},[g.data,_.data,h,f,e,t,v]),b=(0,J.useMemo)(()=>{let e=new Map;for(let t of y){let n=e.get(t.group)??[];n.push(t),e.set(t.group,n)}return[...e.entries()]},[y]),S=async()=>{let e=o.trim();if(!(e===``||u)){d(!0),l(null);try{await Pt(e),r(!1)}catch(e){l(e instanceof Error?e.message:`Could not open that path.`)}finally{d(!1)}}};return(0,Y.jsxs)(Pr,{open:n,onOpenChange:r,children:[(0,Y.jsx)(Fr,{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(),S()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),a(`commands`),s(``),l(null)))}}),i===`path`?(0,Y.jsx)(Ir,{children:(0,Y.jsxs)(`div`,{className:`px-3 py-3 text-xs text-fg-muted`,children:[(0,Y.jsx)(`p`,{children:`Relative paths start from the bound worktree or project. Absolute and ~ paths work too.`}),(0,Y.jsx)(`p`,{className:c?`mt-2 text-danger`:`mt-2`,"aria-live":`polite`,children:c??(u?`Opening…`:`Press Enter to open.`)})]})}):(0,Y.jsxs)(Ir,{children:[(0,Y.jsx)(Lr,{children:`Nothing matches.`}),b.map(([e,t])=>(0,Y.jsx)(Rr,{heading:e,children:t.map(e=>{let t=e.icon;return(0,Y.jsxs)(zr,{value:`${e.label} ${e.keywords??``}`,onSelect:()=>{e.closeOnRun!==!1&&r(!1),e.run()},children:[t&&(0,Y.jsx)(t,{}),e.label,e.shortcut&&(0,Y.jsx)(Br,{children:e.shortcut})]},e.id)})},e))]})]})}function Jr(){let e=document.activeElement;return e instanceof Element&&e.closest(`.xterm`)!==null}function Yr(){let e=document.activeElement;return e instanceof Element&&e.closest(`.monaco-editor`)!==null}function Xr(){let e=Ge(I()??void 0).data?.hotkeys;return(0,J.useEffect)(()=>{at(e&&typeof e==`object`?e:void 0)},[e]),(0,J.useEffect)(()=>le(`window.close`,()=>{let e=nt();e?.closeWindow?e.closeWindow():window.close()}),[]),(0,J.useEffect)(()=>{let e=e=>{let t=Ie(e);if(!t)return;let n=We(t);if(!n)return;let r=ot(n);if(!r||!Oe(r,Yr()))return;let i=ze(n);i&&(e.preventDefault(),e.stopPropagation(),i())},t=e=>{let t=Ie(e);if(!t)return;let n=We(t);if(!n)return;let r=ot(n);if(!r||r.editor&&Yr()||r.deferInTerminal&&Jr())return;let i=ze(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 Zr=4e3;function Qr(){let[e,t]=(0,J.useState)(`hidden`),n=(0,J.useRef)(e);n.current=e,(0,J.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`)},Zr))});return()=>{r(),e!==null&&clearTimeout(e)}},[]);let r=(0,J.useCallback)(async()=>{n.current!==`refreshing`&&(t(`refreshing`),await Vr.refresh()||(ae.error(`The cockpit has not come back — it may need a terminal (ssh re-auth): puddle refresh`),t(q.isConnected()?`hidden`:`lost`)))},[]);return(0,J.useEffect)(()=>Ur(()=>void r()),[r]),e===`hidden`?null:(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 bg-elevated px-3 py-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-fg-secondary`,children:e===`refreshing`?`Restarting the cockpit.`:`Connection to the daemon lost.`}),e===`lost`&&(0,Y.jsxs)(W,{size:`sm`,className:`ml-auto`,onClick:()=>void r(),children:[(0,Y.jsx)(Jt,{}),`Refresh connection`]})]})}function $r({label:e,percentage:t,hint:n}){let r=Math.max(0,Math.min(100,t));return(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`w-24 shrink-0 truncate text-2xs text-fg-muted`,title:e,children:e}),(0,Y.jsx)(`span`,{className:`relative h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-border`,children:(0,Y.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,Y.jsxs)(`span`,{className:`shrink-0 text-2xs tabular-nums text-fg-muted`,children:[Math.round(r),`%`,n?` · ${n}`:``]})]})}function ei(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ti(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 ni({account:e,onLogin:t,onStartSession:n,installed:r=!0}){let i=fe(e.id),a=e.logged_in?n:r?t:null,o=i.data?.subscription;return(0,Y.jsxs)(`div`,{className:`rounded-md px-2 py-2 transition-colors hover:bg-elevated`,children:[(0,Y.jsxs)(`button`,{type:`button`,disabled:a===null,onClick:()=>a?.(),className:`flex w-full items-center gap-3 text-left disabled:cursor-default`,children:[(0,Y.jsx)(`span`,{className:`size-2 shrink-0 rounded-full ${e.logged_in?`bg-success`:`bg-idle`}`,"aria-hidden":!0}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.label}),(0,Y.jsxs)(`span`,{className:`block text-2xs text-fg-muted`,children:[e.logged_in?`logged in`:`logged out`,i.data&&(0,Y.jsxs)(Y.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 `,ti(i.data.last_activity_at)]})]}),i.data?.agent_usage&&(0,Y.jsxs)(`span`,{className:`block text-2xs text-fg-muted`,children:[ei(i.data.agent_usage.input_tokens),` in ·`,` `,ei(i.data.agent_usage.output_tokens),` out ·`,` `,ei(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,Y.jsx)(`span`,{className:`mt-1 block`,children:(0,Y.jsx)($r,{label:`context`,percentage:i.data.live_usage.context_used_percentage})})]}),(0,Y.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted`,children:r?e.logged_in?n?`new agent`:``:(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 text-warning`,children:[(0,Y.jsx)(b,{className:`size-3`}),`sign in`]}):`unavailable`})]}),o!=null&&o.windows.length>0&&(0,Y.jsx)(`div`,{className:`mt-2 flex flex-col gap-1 pl-5`,children:o.windows.map(e=>(0,Y.jsx)($r,{label:e.label,percentage:e.used_percentage,hint:e.resets==null?void 0:`resets ${e.resets}`},e.key))})]})}function ri(){let[e,t]=(0,J.useState)(!1),[n,r]=(0,J.useState)(!1),i=I(),a=Le(),o=Be(),s=a.data?.find(e=>e.id===i),c=ge(i??void 0),l=be(),u=$e(),{open:d,handler:p}=kt(),[m,h]=(0,J.useState)(null),g=e=>u.mutate(e.id,{onSuccess:t=>h({stream:t.stream,label:`${e.agent_type}/${e.label}`}),onError:e=>K(e)}),_=e=>{t(!1),d({accountId:e.id})};return n&&s?(0,Y.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-3`,children:[(0,Y.jsx)(y,{icon:s.icon,colour:s.icon_colour}),(0,Y.jsx)(Rt,{initial:s.name,maxLength:100,className:z(`w-32 text-sm`,f(s.icon_colour)),onCommit:e=>{r(!1);let t=e.trim();!i||!t||t===s?.name||o.mutate({id:i,name:t},{onError:e=>K(e)})},onCancel:()=>r(!1)})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(ln,{open:e,onOpenChange:t,children:[(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsx)(cn,{asChild:!0,children:(0,Y.jsxs)(W,{variant:`ghost`,size:`sm`,className:`font-sans compact:h-7 compact:px-1.5`,children:[(0,Y.jsx)(y,{icon:s?.icon,colour:s?.icon_colour}),(0,Y.jsx)(`span`,{className:f(s?.icon_colour),...qt(()=>{t(!1),r(!0)}),children:s?.name??`…`})]})})}),(0,Y.jsx)(V,{children:`Profile`})]}),(0,Y.jsxs)(sn,{className:`w-[28rem] max-w-[calc(100vw-1rem)]`,children:[(0,Y.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,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsxs)(`span`,{className:`px-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:[e.display_name,!n&&(0,Y.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,Y.jsx)(ni,{account:e,onLogin:()=>g(e),onStartSession:p&&n?()=>_(e):null,installed:n},e.id))]},e.id)}),c.data?.length===0&&(0,Y.jsx)(`p`,{className:`px-2 text-sm text-fg-muted`,children:`No accounts yet — add one in settings.`})]}),(0,Y.jsxs)(`div`,{className:`mt-4 flex items-center gap-2`,children:[(0,Y.jsxs)(W,{variant:`ghost`,size:`sm`,onClick:()=>{t(!1),Yt(`accounts`)},children:[(0,Y.jsx)(Tt,{}),`Add account`]}),(0,Y.jsxs)(W,{variant:`ghost`,size:`sm`,className:`ml-auto`,onClick:()=>{t(!1),ue.set(null)},children:[(0,Y.jsx)(Rn,{}),`Switch profile`]})]})]})]}),m&&(0,Y.jsx)(v,{stream:m.stream,label:m.label,onClose:()=>h(null)})]})}var ii=`desktop-update`;function ai(){let e=(0,J.useRef)(null);return(0,J.useEffect)(()=>{let t=nt();if(t?.updateReady===void 0||t.onUpdateReady===void 0)return;let n=t=>{e.current!==t&&(e.current=t,ae(`Puddle ${t} is downloaded and ready.`,{id:ii,duration:1/0,closeButton:!0,action:{label:`Restart to update`,onClick:()=>{nt()?.installUpdate?.(),ae.loading(`Restarting into Puddle ${t}…`,{id:`${ii}-restarting`,duration:1/0})}}}))};return t.updateReady().then(e=>{e!==null&&n(e)}),t.onUpdateReady(n)},[]),null}function oi(){let e=I(),t=Le().data?.find(t=>t.id===e),n=Ge(e??void 0),r=ke(e??void 0,void 0),i=k(),a=T(),o=E(),s=Ue(e??``),c=Be(),l=et(),[u,d]=(0,J.useReducer)(e=>e+1,0);(0,J.useEffect)(()=>ee(()=>d()),[]);let f=(0,J.useRef)(null);(0,J.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?_(p,t.name):void 0,g=s.isPending||c.isPending||l.isPending||o.isPending||n.isFetching||r.isFetching;(0,J.useEffect)(()=>{if(!m||!h?.enabled||g)return;let a={client:i,theme:ne(),profileSettings:n.data,profile:t,scratchpad:r.data},u={setClient:e=>A(e),setTheme:e=>{typeof e==`string`&&N(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,C(h.doc,u,a,h.groups);return}let p=O(h.groups,a),_=JSON.stringify(p);_!==d&&(f.current=_,o.mutate({profile:t.name,entry:{...h,doc:p,updatedAt:new Date().toISOString()}}))})}function si(e){let t=t=>{let n=o.safeParse(t);n.success&&e(n.data)},n=nt()?.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 ci=5e3,li=`[data-notification-session]`;function ui(e){let t=null,n=()=>{t=null},r=e=>e.target instanceof Element?e.target.closest(li):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<ci&&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 di=new Set,fi=e=>!!e&&di.has(e),pi=i.parse({});function mi(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 hi(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 gi(e){return e.title??e.agent_title??e.osc_title??e.id.slice(0,8)}function _i(){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 vi(){let e=bt(),t=(0,J.useRef)(null);(0,J.useEffect)(()=>{let e=ui(document);return t.current=e,()=>{t.current=null,e.dispose()}},[]),(0,J.useEffect)(()=>si(t=>{t.host||e(`/project/${t.project}/session/${t.session}`,{state:{notificationSession:t.session}})}),[e]),yi(t=>{e(`/project/${t.project_id}/session/${t.id}`,{state:{notificationSession:t.id}})},e=>t.current?.isInteracting(e.id)??!1)}function yi(e,t=()=>document.hasFocus()){let n=_e(),r=(0,J.useRef)(e);r.current=e;let a=(0,J.useRef)(t);a.current=t;let o=Se(qe().data)??`Puddle`,s=(0,J.useRef)(o);(0,J.useEffect)(()=>{document.title===s.current&&(document.title=o),s.current=o},[o]),(0,J.useEffect)(()=>{let e=new Set,t=()=>{document.title=e.size>0?`(${e.size}) ${s.current}`:s.current},o=!0,c=async e=>{let t=hi(n,e.session);if(!t)try{t=(await ce(n)).find(t=>t.id===e.session)}catch{return}if(!o||!t)return;let c=t,u,d;try{let e=await n.fetchQuery({queryKey:[`project`,c.project_id],queryFn:()=>ie(`GET`,`/api/projects/${c.project_id}`),staleTime:1e4});if(!o)return;d=e.project;let t=d.profile_id,r=await n.fetchQuery({queryKey:[`profile-settings`,t],queryFn:()=>ie(`GET`,`/api/profiles/${t}/settings`),staleTime:1e4});u=i.catch(pi).parse(r.notifications??{})}catch{return}if(!o)return;let f=mi({prefs:u,projectId:c.project_id,sessionFocused:a.current(c),permission:S()});f.sound&&_i(),f.desktop&&!fi(l()?.scope)&&await D({id:e.id?`puddle-event-${e.id}`:`puddle-agent-${c.id}`,title:e.content?.title??gi(c).slice(0,160),body:e.content?.body??(e.reason===`exited`?`Agent finished running`:`Waiting for your input`),target:{project:c.project_id,session:c.id,...l()?.notificationHost?{host:l().notificationHost}:{}}},()=>{o&&r.current(c)},{host:s.current,project:d})},u=q.onAgentNotification(e=>{c(e)}),d=q.onStatus(r=>{let i=e.has(r.session);r.status===`waiting_input`?e.add(r.session):e.delete(r.session),t(),!(r.status!==`waiting_input`||i)&&n.fetchQuery({queryKey:[`version`],queryFn:()=>ie(`GET`,`/api/version`),staleTime:1/0}).then(e=>{if(!(e.protocol.major>22||e.protocol.major===22&&e.protocol.minor>=3))return c({session:r.session,reason:`waiting_input`})}).catch(()=>{})});return()=>{o=!1,d(),u(),document.title=s.current}},[n])}function bi({initial:e,defaultScope:t,allowProject:n=!0,agents:r,onSave:i,onCancel:a}){let[o,s]=(0,J.useState)(e?.title??``),[c,l]=(0,J.useState)(e?.body??``),[u,d]=(0,J.useState)(n?e?.scope??t:`profile`),[f,p]=(0,J.useState)((e?.tags??[]).join(`, `)),[h,_]=(0,J.useState)(e?.agent_type??null),v=()=>{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:h})};return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Y.jsx)(m,{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,Y.jsx)(g,{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)&&v()},className:`resize-y text-sm leading-relaxed`}),(0,Y.jsx)(m,{value:f,placeholder:`tags, comma, separated`,spellCheck:!1,onChange:e=>p(e.target.value),onKeyDown:e=>e.stopPropagation(),className:`h-8 text-xs`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-2xs text-fg-secondary`,children:[(0,Y.jsx)(Zt,{checked:u===`profile`,onCheckedChange:e=>d(e?`profile`:`project`)}),`Profile-wide`]}),(0,Y.jsx)(`div`,{className:`ml-auto flex items-center gap-1`,children:r.map(e=>(0,Y.jsxs)(`button`,{type:`button`,title:e.display_name,"aria-pressed":h===e.id,onClick:()=>_(t=>t===e.id?null:e.id),className:z(`rounded-md p-1 transition-colors`,h===e.id?`bg-surface text-fg`:`text-fg-gold hover:bg-surface hover:text-fg`),children:[(0,Y.jsx)(At,{type:e.id,className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:e.display_name})]},e.id))})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,onClick:a,children:`Cancel`}),(0,Y.jsx)(W,{size:`sm`,disabled:!c.trim(),onClick:v,children:`Save`})]})]})}function xi(){let e=Dt(),t=I(),n=pt().id,r=ke(t??void 0,n).data??[],i=be().data??[],a=et(),o=Ke(),s=He(),c=Nt(),[l,u]=(0,J.useState)(null),[d,f]=(0,J.useState)(null),[p,m]=(0,J.useState)(null),[h,g]=(0,J.useState)(null),[_,v]=(0,J.useState)(null);(0,J.useEffect)(()=>le(`scratchpad.toggle`,Mt),[]),(0,J.useEffect)(()=>{e||(u(null),f(null),m(null))},[e]);let y=(0,J.useMemo)(()=>[...new Set(r.flatMap(e=>e.tags))].sort((e,t)=>e.localeCompare(t)),[r]),b=(0,J.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})},O=e=>{navigator.clipboard?.writeText(e.body),ae.success(`Copied to clipboard`)};return(0,Y.jsxs)(ln,{open:e,onOpenChange:Ot,children:[(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsx)(cn,{asChild:!0,children:(0,Y.jsxs)(W,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,children:[(0,Y.jsx)(In,{}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Scratchpad`})]})})}),(0,Y.jsx)(V,{children:`Scratchpad`})]}),(0,Y.jsxs)(sn,{className:`w-[34rem] max-w-[calc(100vw-1rem)] p-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-5 pb-2 pt-4`,children:[(0,Y.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Scratchpad`}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>u(l===`new`?null:`new`),className:`ml-auto flex items-center rounded-md p-1 text-fg-gold transition-colors hover:bg-surface hover:text-fg`,children:[(0,Y.jsx)(Tt,{className:`size-4`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`New entry`})]})]}),(y.length>0||b.length>0)&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-5 pb-2`,children:[y.map(e=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>f(t=>t===e?null:e),className:z(`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,Y.jsx)(`button`,{type:`button`,"aria-pressed":p===e,onClick:()=>m(t=>t===e?null:e),className:z(`rounded-md p-1 transition-colors`,p===e?`bg-action text-action-ink`:`text-fg-gold hover:bg-surface`),children:(0,Y.jsx)(At,{type:e,className:`size-3.5`})},e))]}),(0,Y.jsxs)(`div`,{className:`no-scrollbar max-h-[65vh] overflow-y-auto px-2 pb-3`,children:[l===`new`&&(0,Y.jsx)(`div`,{className:`px-3 py-2`,children:(0,Y.jsx)(bi,{defaultScope:n?`project`:`profile`,allowProject:n!==void 0,agents:i,onSave:w,onCancel:()=>u(null)})}),C.length===0&&l!==`new`&&(0,Y.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,Y.jsx)(`ul`,{className:`flex flex-col`,children:C.map(e=>l===e.id?(0,Y.jsx)(`li`,{className:`px-3 py-2`,children:(0,Y.jsx)(bi,{initial:e,defaultScope:e.scope,allowProject:n!==void 0||e.scope===`project`,agents:i,onSave:t=>T(e.id,t),onCancel:()=>u(null)})},e.id):(0,Y.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:z(`transition-opacity`,h===e.id&&`opacity-50`),children:(0,Y.jsx)(Si,{entry:e,onInsert:c?()=>{c(e.body),Ot(!1)}:null,onCopy:()=>O(e),onEdit:()=>u(e.id),onDelete:()=>s.mutate(e.id)})},e.id))})]})]})]})}function Si({entry:e,onInsert:t,onCopy:n,onEdit:r,onDelete:i}){let[a,o]=(0,J.useState)(!1);return(0,Y.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,Y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.title}),(0,Y.jsx)(`p`,{className:z(`line-clamp-3 whitespace-pre-wrap text-sm text-fg-secondary`,e.title&&`mt-0.5`),children:e.body}),a?(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:`Delete this entry? This can’t be undone.`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),i()},className:`text-2xs font-medium text-interrupted transition-colors hover:underline`,children:`Delete`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Cancel`})]}):(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:e.scope===`profile`?`Profile-wide`:`Project`}),e.agent_type&&(0,Y.jsx)(At,{type:e.agent_type,className:`size-3 text-fg-gold`}),e.tags.map(e=>(0,Y.jsx)(`span`,{className:`rounded-full bg-surface px-1.5 text-2xs text-fg-secondary`,children:e},e)),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[t&&(0,Y.jsx)(Ci,{icon:Nn,label:`Insert into focused terminal`,onClick:t}),(0,Y.jsx)(Ci,{icon:ut,label:`Copy`,onClick:n}),(0,Y.jsx)(Ci,{icon:h,label:`Edit`,onClick:r}),(0,Y.jsx)(Ci,{icon:wt,label:`Delete`,onClick:()=>o(!0)})]})]})]})}function Ci({icon:e,label:t,onClick:n}){return(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,Y.jsx)(e,{className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,Y.jsx)(V,{children:t})]})}var wi=a.parse({});function Ti(e,t){let[n,r]=(0,J.useState)(null),i=De(t).data,a=st(e??void 0,t&&e!==null).data;return(0,J.useEffect)(()=>{if(!t||e===null){r(null);return}let n=!1,i;try{i=Kt(sessionStorage.getItem(Gt(e)))}catch{i={kind:`absent`}}if(i.kind===`present`){r(i.snapshot);return}return Je(e).then(e=>{n||r(e?e.ui_state:wi)}).catch(()=>{n||r(wi)}),()=>{n=!0}},[t,e]),(0,J.useMemo)(()=>{if(!t||e===null||n===null)return null;let o=t=>{if(!i||!a)return!1;let{patch:o,projectBased:s}=Bt(n,t,{alive:new Set(i.filter(e=>e.status!==`archived`).map(e=>e.id)),sessionProject:new Map(i.map(e=>[e.id,e.project_id])),projectIds:a.map(e=>e.id),currentProject:null}),c={...n,...o};r(c),Ce(e,c).catch(e=>console.warn(`ui-state save failed: ${e.message}`));try{sessionStorage.setItem(Gt(e),JSON.stringify(c))}catch(e){console.warn(`ui-state write failed: ${e.message}`)}return j().projectBasedLayout!==s&&A({projectBasedLayout:s}),!0},s=Object.fromEntries(Object.entries(n.project_layouts).map(([e,t])=>[e,{layoutRef:t.layout_ref,signature:B(t.layout_tree)}]));return(n.layout_mode??`profile`)===`project`?{headless:!0,scope:`project`,projectId:``,layoutRef:null,signature:B(null),slices:s,capture:()=>({layout_tree:null,active_session:null}),apply:o}:{scope:`profile`,projectId:``,layoutRef:n.layout_ref,signature:B(n.layout_tree),slices:s,capture:()=>({layout_tree:n.layout_tree,active_session:n.active_session}),apply:o}},[t,e,n,i,a])}var Ei=B(null);function Di(){let e=Vt(),t=bt(),n=I(),r=Ut(),i=Ti(n,e&&r===null),a=r??i,o=Re(n??void 0,void 0).data??[],s=st(n??void 0,e&&n!==null).data??[],c=Ae(),l=rt(),u=Te(),[d,f]=(0,J.useState)(``),[p,h]=(0,J.useState)(!1),[g,_]=(0,J.useState)(null);(0,J.useEffect)(()=>le(`layouts.toggle`,zt),[]),(0,J.useEffect)(()=>{e||(f(``),h(!1),_(null))},[e]);let v=a?.headless===!0,y=a===null||v?null:o.find(e=>e.id===a.layoutRef)??null,b=a!==null&&!v&&(y===null?a.signature!==Ei:B(y.layout_tree)!==a.signature),x=e=>{let t=a?.slices?.[e];if(!t)return!1;let n=t.layoutRef===null?null:o.find(e=>e.id===t.layoutRef)??null;return n?B(n.layout_tree)!==t.signature:t.signature!==Ei},S=e=>a===null?!1:e.scope===`profile`?a.scope===`profile`&&b:e.project_id===null?!1:a.scope===`project`?!v&&e.project_id===a.projectId?b:x(e.project_id):b||x(e.project_id),C=e=>y!==null&&e.id===y.id,w=e=>(e===null?void 0:s.find(t=>t.id===e)?.name)??`Project`,T=a!==null&&!v&&a.scope===`project`?o.filter(e=>e.scope===`profile`||e.project_id===a.projectId):o,E=[...T.some(e=>e.scope===`profile`)?[{key:`profile`,name:`Profile-wide`}]:[],...[...new Set(T.flatMap(e=>e.project_id===null?[]:[e.project_id]))].map(e=>({key:e,name:w(e)})).sort((e,t)=>e.name.localeCompare(t.name))],D=g===null?T:g===`profile`?T.filter(e=>e.scope===`profile`):T.filter(e=>e.project_id===g),O=e=>a!==null&&e.scope===a.scope&&(a.scope===`profile`||e.project_id===a.projectId),k=(e,t,r)=>{!a||!n||c.mutate({profile_id:n,scope:a.scope,project_id:a.scope===`project`?a.projectId:void 0,name:e,...t},{onSuccess:e=>{r&&a.apply(e)},onError:e=>K(e)})},A=e=>{if(!a)return;let t=O(e)?e:o.find(t=>t.name===e.name&&O(t));if(!t){k(e.name,a.capture(),!0);return}l.mutate({id:t.id,...a.capture()},{onSuccess:e=>a.apply(e),onError:e=>K(e)})},j=(e,t)=>k(t,{layout_tree:e.layout_tree,active_session:e.active_session},!1),M=e=>{if(a){if(!a.apply(e)){ae.error(`Workspace is still loading — try again in a moment`);return}e.project_id!==null&&e.project_id!==a.projectId&&t(`/project/${e.project_id}`),Lt(!1)}};return(0,Y.jsxs)(ln,{open:e,onOpenChange:Lt,children:[(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsx)(cn,{asChild:!0,children:(0,Y.jsxs)(W,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,children:[(0,Y.jsx)(Pn,{}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Layouts`})]})})}),(0,Y.jsx)(V,{children:`Layouts`})]}),(0,Y.jsxs)(sn,{className:`w-[26rem] max-w-[calc(100vw-1rem)] p-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-5 pb-2 pt-4`,children:[(0,Y.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Layouts`}),a!==null&&!v&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>h(e=>!e),className:`ml-auto flex items-center rounded-md p-1 text-fg-gold transition-colors hover:bg-surface hover:text-fg`,children:[(0,Y.jsx)(Tt,{className:`size-4`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Save the current layout as a new layout`})]})]}),a===null?(0,Y.jsx)(`p`,{className:`px-5 pb-3 text-sm text-fg-muted`,children:`Loading the profile’s layout state…`}):v?(0,Y.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.`}):(y===null||p)&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 px-5 pb-3`,children:[y===null&&(0,Y.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:`Unnamed layout`}),(0,Y.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:a.scope===`profile`?`Profile-wide`:`Project`}),(0,Y.jsx)(`span`,{className:`ml-auto text-2xs text-interrupted`,children:`Unsaved`})]}),(0,Y.jsxs)(`form`,{className:`flex items-center gap-1.5`,onSubmit:e=>{e.preventDefault();let t=d.trim();t&&(k(t,a.capture(),!0),f(``),h(!1))},children:[(0,Y.jsx)(m,{autoFocus:p,value:d,placeholder:y===null?`Name this layout…`:`Save as a new layout…`,spellCheck:!1,onChange:e=>f(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&h(!1)},className:`h-8 flex-1 text-sm`}),(0,Y.jsx)(W,{size:`sm`,type:`submit`,disabled:!d.trim(),children:`Save`}),y!==null&&(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,onClick:()=>h(!1),children:`Cancel`})]})]}),E.length>1&&(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 px-5 pb-2`,children:E.map(e=>(0,Y.jsx)(Ai,{active:g===e.key,onClick:()=>_(t=>t===e.key?null:e.key),children:e.name},e.key))}),(0,Y.jsxs)(`div`,{className:`no-scrollbar max-h-[60vh] overflow-y-auto px-2 pb-3`,children:[D.length===0&&(0,Y.jsx)(`p`,{className:`px-3 py-3 text-sm text-fg-muted`,children:g===null?`No layouts yet — name and save the current layout to keep it.`:`Nothing matches this filter.`}),(0,Y.jsx)(`ul`,{className:`flex flex-col`,children:D.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(Oi,{layout:e,projectLabel:e.scope===`profile`?null:w(e.project_id),isCurrent:C(e),dirty:b,loadable:a!==null,savable:a!==null&&!v,confirmBeforeLoad:S(e),overwrites:O(e),onLoad:()=>M(e),onRename:t=>l.mutate({id:e.id,name:t}),onDelete:()=>u.mutate(e.id),onSaveAs:()=>A(e),onDuplicate:t=>j(e,t)})},e.id))})]})]})]})}function Oi({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,g]=(0,J.useState)(null),[_,v]=(0,J.useState)(null),[y,b]=(0,J.useState)(e.name),x=()=>{if(!(!i||_!==null)){if(o&&p!==`load`){g(`load`);return}g(null),c()}},S=t=>{g(null),b(t===`rename`?e.name:`${e.name} copy`),v(t)},C=()=>{if(n){d();return}g(`save`)},w=n?r?`unsaved`:`active`:null;return(0,Y.jsxs)(`div`,{onClick:e=>{e.target.closest(`button, input`)||x()},className:z(`rounded-md px-3 py-2.5 transition-colors`,i&&`cursor-pointer hover:bg-surface`),children:[_===null?(0,Y.jsxs)(`p`,{className:z(`flex items-baseline gap-2 text-sm font-medium`,w===`active`?`text-success`:w===`unsaved`?`text-interrupted`:`text-fg`),children:[e.name,w!==null&&(0,Y.jsx)(`span`,{className:`text-2xs font-normal`,children:w===`active`?`Active`:`Unsaved`})]}):(0,Y.jsxs)(`form`,{className:`flex items-center gap-1.5`,onSubmit:t=>{t.preventDefault();let n=y.trim();n&&(_===`rename`?n!==e.name&&l(n):f(n)),v(null)},children:[(0,Y.jsx)(m,{autoFocus:!0,value:y,spellCheck:!1,onChange:e=>b(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&v(null)},className:`h-7 flex-1 text-sm`}),(0,Y.jsx)(W,{size:`sm`,type:`submit`,disabled:!y.trim(),children:_===`rename`?`Rename`:`Save`})]}),p===`save`?(0,Y.jsx)(ki,{question:s?`Overwrite “${e.name}” with the current layout?`:`Save the current layout as “${e.name}” here?`,verb:s?`Overwrite`:`Save`,onConfirm:()=>{g(null),d()},onCancel:()=>g(null)}):p===`delete`?(0,Y.jsx)(ki,{question:`Delete this layout? This can’t be undone.`,verb:`Delete`,onConfirm:()=>{g(null),u()},onCancel:()=>g(null)}):p===`load`?(0,Y.jsx)(ki,{question:`Loading discards unsaved layout changes.`,verb:`Load`,onConfirm:x,onCancel:()=>g(null)}):(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:[t!==null&&(0,Y.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:t}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[a&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ji,{icon:Ln,label:n?`Save`:`Save the current layout as “${e.name}”`,onClick:C}),(0,Y.jsx)(ji,{icon:ut,label:`Duplicate`,onClick:()=>S(`duplicate`)})]}),(0,Y.jsx)(ji,{icon:h,label:`Rename`,onClick:()=>S(`rename`)}),(0,Y.jsx)(ji,{icon:wt,label:`Delete`,onClick:()=>g(`delete`)})]})]})]})}function ki({question:e,verb:t,onConfirm:n,onCancel:r}){return(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e}),(0,Y.jsx)(`button`,{type:`button`,onClick:n,className:`text-2xs font-medium text-interrupted transition-colors hover:underline`,children:t}),(0,Y.jsx)(`button`,{type:`button`,onClick:r,className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Cancel`})]})}function Ai({active:e,onClick:t,children:n}){return(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:t,className:z(`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 ji({icon:e,label:t,onClick:n}){return(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,Y.jsx)(e,{className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,Y.jsx)(V,{children:t})]})}var Mi=nt()!==void 0&&/Mac/.test(navigator.platform),Ni=(0,J.lazy)(()=>M(()=>import(`./SettingsDialog-DiwhE5dK.js`).then(e=>({default:e.SettingsDialog})),__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])));function Pi(){let e=_e();(0,J.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 Fi(){let e=qe(),t=Xe(),[n,r]=(0,J.useState)(!1),i=Se(e.data),a=n=>{r(!1);let a=n.trim();a!==i&&t.mutate({displayName:a===e.data?.hostname?``:a},{onError:e=>K(e)})},o=!Mi&&(0,Y.jsx)(`img`,{src:`/puddle.svg`,alt:`Puddle`,className:`size-4`}),s=z(`flex shrink-0 items-center gap-2`,Mi&&`[-webkit-app-region:no-drag]`),c=`truncate text-sm font-semibold text-fg-secondary`;return n&&i!==void 0?(0,Y.jsxs)(`div`,{className:s,children:[o,(0,Y.jsx)(Rt,{initial:e.data?.displayName??i,maxLength:64,className:z(c,`w-40`),onCommit:a,onCancel:()=>r(!1)})]}):(0,Y.jsxs)(dt,{to:`/`,className:z(s,`transition-opacity hover:opacity-70`),title:`All projects`,children:[o,i!==void 0&&(0,Y.jsx)(`span`,{className:c,...qt(()=>r(!0)),children:i})]})}function Ii(){let e=pt(),t=de(`palette.toggle`),n=it(e.id).data?.project,r=n!==void 0&&n.id===e.id?n.name:void 0;return(0,Y.jsxs)(`button`,{type:`button`,onClick:jt,className:z(`absolute left-1/2 flex h-6 w-[min(30rem,42%)] -translate-x-1/2 items-center justify-center gap-2 rounded-md bg-ground text-fg-muted transition-colors hover:bg-elevated hover:text-fg-secondary`,Mi&&`[-webkit-app-region:no-drag]`),children:[(0,Y.jsx)(`span`,{className:z(`truncate text-xs`,r&&f(n?.colour)),children:r??`Puddle`}),(0,Y.jsx)(`span`,{className:`text-2xs`,children:t})]})}function Li(){let{fullScreen:e,animate:t}=Ze();return(0,Y.jsxs)(`header`,{className:z(`relative flex h-9 shrink-0 items-center gap-3 bg-surface pl-3 pr-3`,Mi&&!e&&`pl-[88px] [-webkit-app-region:drag]`,t&&`transition-[padding] duration-200 ease-out`),children:[(0,Y.jsx)(Fi,{}),(0,Y.jsx)(Ii,{}),(0,Y.jsxs)(`div`,{className:z(`ml-auto flex items-center`,Mi&&`[-webkit-app-region:no-drag]`),children:[(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsxs)(W,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,onClick:()=>Yt(),children:[(0,Y.jsx)(zn,{}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Settings`})]})}),(0,Y.jsx)(V,{children:`Settings`})]}),(0,Y.jsx)(Di,{}),(0,Y.jsx)(xi,{}),(0,Y.jsx)(ri,{})]})]})}function Ri(){Pi(),oi(),vi();let{handler:e}=kt(),t=I(),{pathname:n}=ht(),[r,i]=(0,J.useState)(!1),a=Pe(),o=a.data!==void 0&&Qe(a.data.protocol);return(0,J.useEffect)(()=>{if(!o)return;let e=()=>{let e=te();q.reportTheme(e(`--text-primary`),e(`--bg-base`))};return e(),ee(e)},[o]),(0,Y.jsxs)(`div`,{className:`flex h-screen flex-col overflow-hidden overscroll-y-none bg-ground`,children:[(0,Y.jsx)(Li,{}),(0,Y.jsx)(`main`,{className:`min-h-0 flex-1`,children:(0,Y.jsx)(hn,{resetOn:n,scope:n.startsWith(`/project/`)?`workspace`:`view`,children:(0,Y.jsx)(_t,{})})}),(0,Y.jsx)(Qr,{}),(0,Y.jsx)(ai,{}),(0,Y.jsx)(qr,{onNewSession:e??void 0,onNewProject:()=>i(!0)}),t!==null&&(0,Y.jsx)($t,{profileId:t,open:r,onOpenChange:i}),(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(Ni,{})}),(0,Y.jsx)(Xr,{})]})}function zi(){return(0,Y.jsx)(Wt,{children:(0,Y.jsx)(Ri,{})})}var Bi=(0,J.lazy)(()=>M(()=>import(`./Dashboard-7gBsrB7q.js`).then(e=>({default:e.Dashboard})),__vite__mapDeps([30,1,2,3,4,5,6,7,8,9,10,13,12,31,20,32,23,33,34,16,27,26,35]))),Vi=(0,J.lazy)(()=>M(()=>import(`./Workspace-cfjpv0xU.js`).then(e=>({default:e.Workspace})),__vite__mapDeps([36,1,2,3,4,5,6,7,8,9,10,17,18,19,12,13,37,38,23,33,31,15,39,14,40,41,20,32,42,21,22,43,35,26,16,44,45,46,29,47]))),Hi=new mn({defaultOptions:{queries:{retry:1,staleTime:5e3}},mutationCache:new dn({onError:e=>K(e)})});function Ui(){let e=I(),t=Le(),n=e!==null&&t.data!==void 0&&!t.data.some(t=>t.id===e);return e===null||n?(0,Y.jsx)(Bn,{}):(0,Y.jsx)(mt,{useTransitions:!1,children:(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(ft,{children:(0,Y.jsxs)(vt,{element:(0,Y.jsx)(zi,{}),children:[(0,Y.jsx)(vt,{path:`/`,element:(0,Y.jsx)(Bi,{})}),(0,Y.jsx)(vt,{path:`/project/:id`,element:(0,Y.jsx)(Vi,{})}),(0,Y.jsx)(vt,{path:`/project/:id/session/:sid`,element:(0,Y.jsx)(Vi,{})})]})})})})}function Wi(){let e=(0,J.useSyncExternalStore)(u.subscribe,u.get);return(0,Y.jsx)(pe,{client:Hi,children:(0,Y.jsxs)(It,{delayDuration:300,children:[(0,Y.jsx)(Mn,{}),(0,Y.jsx)(hn,{scope:`app`,children:e?window.location.pathname.startsWith(`/forward/`)?(0,Y.jsx)(un,{}):(0,Y.jsx)(Ui,{}):(0,Y.jsx)(_n,{})}),(0,Y.jsx)(gn,{})]})})}export{Wi as App};
|
|
@@ -1 +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-ffCh33zF.js";import{g as r}from"./auth-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{g as r}from"./auth-BxExwqPW.js";import{a as i,c as a,f as o,i as s,l as c,o as l,p as u,s as d,t as f}from"./LazyTerminal-gX1-vBQf.js";import{E as p,Y as m,d as h,ft as g,gt as _,k as v,kt as y,pt as b,wt as x,yt as S}from"./protocol-support-gmAQBWF3.js";import{a as C,n as w,t as T}from"./project-abbrev-DX_a_ySv.js";import{n as E}from"./x-DCpy1q13.js";import{t as D}from"./button-Chvl9hcE.js";import{c as O,f as k,h as A,m as j,n as M,p as N,r as P,t as F}from"./context-menu-DVUv5Z6a.js";import{r as I}from"./dist-DmyIHyF9.js";import{t as L}from"./NewProjectDialog-CDYUPliQ.js";import{n as R}from"./errors-DhRwiizF.js";import{t as z}from"./ws-oU1ansI7.js";import{a as B,i as V,n as H,o as U,t as W}from"./dialog-Bnex_wlx.js";var G=e(t(),1),K=n(),q=!1;function J(){let[e,t]=(0,G.useState)(q),[n,i]=(0,G.useState)(null);(0,G.useEffect)(()=>{if(!e)return;let t=!1;return z.spawnShell(r).then(e=>{t||i(e)}),()=>{t=!0}},[e]);let a=()=>{q=!1,t(!1),i(null)};return{open:e,term:n,toggle:()=>{e?(n&&z.killShell(r,n),a()):(q=!0,t(!0))},onExit:a}}function Y({term:e,onExit:t}){return(0,K.jsx)(`div`,{className:`h-72 shrink-0 pb-6`,children:(0,K.jsx)(`div`,{className:`mx-auto size-full max-w-4xl px-6`,children:e!==null&&(0,K.jsx)(f,{stream:`home`,term:e,onExit:t})})})}var X=`group block w-full rounded-lg bg-surface p-4 text-left transition-colors hover:bg-elevated`,ee=[{status:`running`,colour:`bg-running`},{status:`waiting_input`,colour:`bg-waiting`},{status:`interrupted`,colour:`bg-interrupted`}];function te({project:e,repoPath:t,sessions:n}){let r=n.filter(e=>e.status!==`archived`);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h2`,{className:E(`truncate pr-16 text-base font-semibold`,i(e.colour)||`text-fg group-hover:text-accent`),children:e.name}),(0,K.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:t??`…`}),(0,K.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3 text-2xs text-fg-muted tabular-nums`,children:[(0,K.jsxs)(`span`,{children:[r.length,` session`,r.length===1?``:`s`]}),ee.map(({status:e,colour:t})=>{let n=r.filter(t=>t.status===e).length;return n>0?(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`size-1.5 rounded-full ${t}`}),n,` `,e.replace(`_`,` `)]},e):null})]})]})}function Z({icon:e,label:t,onClick:n}){return(0,K.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,K.jsx)(e,{className:`size-4`})})}function Q({project:e,repoPath:t,draggable:n,dragging:r,onDragStart:d,onDragEnd:f,onDragOver:p}){let g=b(),_=h(m().data?.protocol),v=y(e.id),[x,S]=(0,G.useState)(!1),[w,T]=(0,G.useState)(e.name),[k,N]=(0,G.useState)(u(e)),[I,L]=(0,G.useState)(e.colour??null),z=t=>g.mutate({id:e.id,archived:t},{onError:e=>R(e)}),q=()=>{T(e.name),L(e.colour??null),N(u(e)),S(!0)},J=()=>{let t=w.trim(),n=o(k);if(!t){S(!1);return}let r={...t===e.name?{}:{name:t},...n&&n!==u(e)?{abbrev:n}:{},..._&&I!==(e.colour??null)?{colour:I}:{}};if(Object.keys(r).length===0){S(!1);return}g.mutate({id:e.id,...r},{onSuccess:()=>S(!1),onError:e=>R(e)})};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(F,{children:[(0,K.jsx)(O,{asChild:!0,children:(0,K.jsxs)(`div`,{draggable:n,onDragStart:d,onDragEnd:f,onDragOver:p,className:E(`group relative transition-opacity`,r&&`opacity-50`),children:[(0,K.jsx)(C,{draggable:!1,to:`/project/${e.id}`,className:X,children:(0,K.jsx)(te,{project:e,repoPath:t,sessions:v.data??[]})}),(0,K.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,K.jsx)(Z,{icon:A,label:`Reopen project`,onClick:()=>z(!1)}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Z,{icon:l,label:`Edit project`,onClick:q}),(0,K.jsx)(Z,{icon:j,label:`Archive project`,onClick:()=>z(!0)})]})})]})}),(0,K.jsx)(M,{children:e.archived?(0,K.jsxs)(P,{onSelect:()=>z(!1),children:[(0,K.jsx)(A,{}),` Reopen`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(P,{onSelect:q,children:[(0,K.jsx)(l,{}),` Edit`]}),(0,K.jsxs)(P,{onSelect:()=>z(!0),children:[(0,K.jsx)(j,{}),` Archive`]})]})})]}),(0,K.jsx)(W,{open:x,onOpenChange:S,children:(0,K.jsxs)(H,{children:[(0,K.jsx)(B,{children:(0,K.jsx)(U,{children:`Edit project`})}),(0,K.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),J()},children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(a,{htmlFor:`project-name-${e.id}`,children:`Name`}),(0,K.jsx)(c,{id:`project-name-${e.id}`,value:w,className:i(I),onChange:e=>T(e.target.value),autoFocus:!0})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(a,{htmlFor:`project-abbrev-${e.id}`,children:`Abbreviation`}),(0,K.jsx)(c,{id:`project-abbrev-${e.id}`,maxLength:5,value:k,onChange:e=>N(o(e.target.value)),className:`w-24 uppercase`}),(0,K.jsxs)(`p`,{className:`text-2xs text-fg-muted`,children:[`Up to `,5,` characters — the label on the collapsed sidebar rail.`]})]}),_&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-xs text-fg-secondary`,children:`Colour`}),(0,K.jsx)(s,{value:I,onChange:L,label:`Project colour`})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(a,{className:`text-fg-muted`,children:`Path`}),(0,K.jsx)(`p`,{className:`truncate text-2xs text-fg-muted`,children:t??`…`})]}),(0,K.jsxs)(V,{children:[(0,K.jsx)(D,{type:`button`,variant:`ghost`,onClick:()=>S(!1),children:`Cancel`}),(0,K.jsx)(D,{type:`submit`,disabled:!w.trim()||g.isPending,children:`Save`})]})]})]})})]})}function $({icon:e,label:t,hint:n,onClick:r}){return(0,K.jsxs)(`button`,{type:`button`,onClick:r,className:`group flex flex-col rounded-lg bg-surface p-4 text-left transition-colors hover:bg-elevated`,children:[(0,K.jsxs)(`h2`,{className:`flex items-center gap-2 truncate text-base font-semibold text-fg group-hover:text-accent`,children:[(0,K.jsx)(e,{className:`size-4 shrink-0`}),t]}),(0,K.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:n})]})}function ne(){let e=v(),t=S(e??void 0),n=x(),r=_(e??void 0),i=g(e??``),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(!1),f=J(),m=p(`palette.toggle`),h=e=>n.data?.find(t=>t.id===e)?.path,y=t.data??[],b=r.data?.projectOrder??[],C=k(y.filter(e=>!e.archived),b),D=y.filter(e=>e.archived),O=(e,t)=>{e!==t&&i.mutate({projectOrder:N(C.map(e=>e.id),e,t)})};return(0,K.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,K.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[y.length===0&&(0,K.jsxs)(`div`,{className:`mb-8 mt-16 flex flex-col items-center gap-3 text-center`,children:[(0,K.jsx)(d,{className:`size-8 text-fg-muted`}),(0,K.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[`No projects yet — open one below, or press `,m,`.`]})]}),(0,K.jsxs)(`div`,{className:`grid auto-rows-fr grid-cols-1 gap-3 sm:grid-cols-2`,children:[C.map(e=>(0,K.jsx)(Q,{project:e,repoPath:h(e.repo_id),draggable:!0,dragging:s===e.id,onDragStart:()=>c(e.id),onDragEnd:()=>c(null),onDragOver:t=>{t.preventDefault(),s&&s!==e.id&&O(s,e.id)}},e.id)),(0,K.jsx)($,{icon:w,label:`Open project`,hint:`Point at a repository on this host`,onClick:()=>o(!0)}),(0,K.jsx)($,{icon:T,label:f.open?`Close terminal`:`Open terminal`,hint:f.open?`End the shell below`:`A shell at ~ for cloning repositories`,onClick:f.toggle})]}),D.length>0&&(0,K.jsxs)(`div`,{className:`mt-6`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>u(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,K.jsx)(I,{className:E(`size-3 transition-transform`,l&&`rotate-90`)}),(0,K.jsx)(j,{className:`size-3`}),(0,K.jsx)(`span`,{children:`Archived`}),(0,K.jsx)(`span`,{className:`tabular-nums`,children:D.length})]}),l&&(0,K.jsx)(`div`,{className:`mt-2 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:D.map(e=>(0,K.jsx)(Q,{project:e,repoPath:h(e.repo_id),draggable:!1,dragging:!1,onDragStart:()=>{},onDragEnd:()=>{},onDragOver:()=>{}},e.id))})]})]})}),f.open&&(0,K.jsx)(Y,{term:f.term,onExit:f.onExit}),e!==null&&(0,K.jsx)(L,{profileId:e,open:a,onOpenChange:o})]})}export{ne as Dashboard};
|
|
@@ -1 +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-ffCh33zF.js";import{t as r}from"./x-DCpy1q13.js";import{t as i}from"./button-Chvl9hcE.js";import{t as a}from"./createLucideIcon-DyMAgLa3.js";import{a as o,i as s,n as c,o as l,r as u,t as d}from"./dialog-Bnex_wlx.js";import{t as f}from"./drafts-B_tChlzR.js";import{i as p,t as m,u as h}from"./buffer-store-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{t as r}from"./x-DCpy1q13.js";import{t as i}from"./button-Chvl9hcE.js";import{t as a}from"./createLucideIcon-DyMAgLa3.js";import{a as o,i as s,n as c,o as l,r as u,t as d}from"./dialog-Bnex_wlx.js";import{t as f}from"./drafts-B_tChlzR.js";import{i as p,t as m,u as h}from"./buffer-store-CYe-IdNO.js";import{t as g}from"./editor-sync-W1bamxAP.js";var _=a(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),v=e(t(),1),y=n();function b(e,t,n){let r=m(e,t,n);return(0,v.useSyncExternalStore)((0,v.useCallback)(e=>h(r,e),[r]),()=>p(r))}function x({session:e,path:t,kind:n,root:r}){return b(e,t,r)&&n!==`commit`?(0,y.jsx)(_,{"aria-hidden":!0,className:`size-2 shrink-0 fill-current text-fg-muted group-hover:hidden`}):null}function S({session:e,path:t,kind:n,root:a,label:p,onClose:m}){let h=b(e,t,a)&&n!==`commit`,[_,x]=(0,v.useState)(!1),S=()=>h?x(!0):m();return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`button`,{onClick:e=>{e.stopPropagation(),S()},className:`hidden size-4 items-center justify-center rounded-sm text-fg-muted transition-colors hover:text-fg group-hover:flex pointer-coarse:flex`,"aria-label":`Close ${p}`,children:(0,y.jsx)(r,{className:`size-3`})}),(0,y.jsx)(d,{open:_,onOpenChange:e=>!e&&x(!1),children:(0,y.jsxs)(c,{children:[(0,y.jsxs)(o,{children:[(0,y.jsxs)(l,{children:[`Discard changes to `,p,`?`]}),(0,y.jsx)(u,{children:`This file has unsaved changes. Closing the tab will discard them.`})]}),(0,y.jsxs)(s,{children:[(0,y.jsx)(i,{variant:`ghost`,onClick:()=>x(!1),children:`Keep editing`}),(0,y.jsx)(i,{variant:`danger`,onClick:()=>{f(e,t,a),g(e,t,a),x(!1),m()},children:`Discard`})]})]})})]})}export{x as EditorDirtyDot,S as EditorTabClose};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Terminal-
|
|
2
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{I as r}from"./auth-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Terminal-DmlEI-h7.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/jsx-runtime-ffCh33zF.js","assets/auth-BxExwqPW.js","assets/client-settings-CwqpIric.js","assets/preload-helper-Czpn1I53.js","assets/index-BRywm-gU.js","assets/index-XBWIhnuP.css","assets/dist-7fft9rhQ.js","assets/protocol-support-gmAQBWF3.js","assets/copy-CjatFFf8.js","assets/createLucideIcon-DyMAgLa3.js","assets/x-DCpy1q13.js","assets/FindWidget-BSK2PIfO.js","assets/whole-word-2m2pmAFT.js","assets/chevron-down--sjpQEHH.js","assets/selection-actions-BZy4596m.js","assets/button-Chvl9hcE.js","assets/ws-oU1ansI7.js","assets/code-DRWf9a5s.js","assets/errors-DhRwiizF.js","assets/math-delimiters-BCnTi7Ii.js","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{t as n}from"./jsx-runtime-ffCh33zF.js";import{I as r}from"./auth-BxExwqPW.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{p as a}from"./es2015-CrC2hHeB.js";import{n as o}from"./x-DCpy1q13.js";import{t as s}from"./recipes-K5GH3Kht.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=n();function m({className:e,type:t,...n}){return(0,p.jsx)(`input`,{type:t,className:o(`flex h-8 w-full px-2.5`,s,e),...n})}function h({className:e,...t}){return(0,p.jsx)(`textarea`,{className:o(`flex min-h-16 w-full px-2.5 py-2`,s,e),...t})}var g=`Label`,_=f.forwardRef((e,t)=>(0,p.jsx)(a.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));_.displayName=g;var v=_;function y({className:e,...t}){return(0,p.jsx)(v,{className:o(`text-xs font-medium text-fg-secondary peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var b=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`}]]),x=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`}]]),S={navy:`text-fg`,gold:`text-fg-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 C(e){return e&&S[e]||``}function w({value:e,onChange:t,disabled:n=!1,label:i=`Colour`}){return(0,p.jsx)(`div`,{role:`group`,"aria-label":i,className:`flex flex-wrap items-center gap-1`,children:[null,...r].map(r=>(0,p.jsx)(`button`,{type:`button`,title:r??`Default`,"aria-label":r??`Default colour`,"aria-pressed":(e??null)===r,disabled:n,onClick:()=>t(r),className:o(`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)===r&&`bg-border/50`),children:(0,p.jsx)(`span`,{className:o(`size-3.5 rounded-full`,r?o(`bg-current`,C(r)):`bg-fg-muted`)})},r??`default`))})}function T({id:e,value:t,onValueChange:n,onChoose:r,hints:i,placeholder:a,className:s,hintsClassName:c,autoFocus:l}){let[u,d]=(0,f.useState)(!1),[h,g]=(0,f.useState)(0),_=e=>{n(e.value),r?.(e),d(!1)};return(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(m,{id:e,value:t,onChange:e=>{n(e.target.value),d(!0),g(0)},onFocus:()=>d(!0),onBlur:()=>d(!1),onKeyDown:e=>{if(!(!u||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(),d(!1))},placeholder:a,className:s,autoComplete:`off`,spellCheck:!1,autoFocus:l}),u&&i.length>0&&(0,p.jsx)(`ul`,{className:o(`absolute top-full z-10 mt-1 max-h-56 overflow-y-auto rounded-md bg-elevated p-1 shadow-xl`,c??`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:o(`relative flex cursor-pointer select-none items-center gap-2 rounded-sm 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 E=(0,f.lazy)(()=>i(()=>import(`./Terminal-DmlEI-h7.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]))),D=null;async function O(){D=(await i(()=>import(`./Terminal-DmlEI-h7.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]))).Terminal}function k(e){return D?(0,p.jsx)(D,{...e}):(0,p.jsx)(f.Suspense,{fallback:(0,p.jsx)(`div`,{className:`size-full bg-ground`}),children:(0,p.jsx)(E,{...e})})}export{C as a,y as c,l as d,d as f,w as i,m as l,O as n,x as o,u as p,T as r,b as s,k as t,h 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-CYe-IdNO.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};
|