@puddle-code/cli 0.0.51 → 0.0.52
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 +3 -4
- package/dist/index.js +13 -3
- package/dist/public/assets/{Dashboard-BVhpOZWL.js → Dashboard-Dq6RrWk7.js} +1 -1
- package/dist/public/assets/{EditorTabClose-BBeGhcin.js → EditorTabClose-BS5aHxh5.js} +1 -1
- package/dist/public/assets/{LazyTerminal-dobHNDnL.js → LazyTerminal-CbtFuzQP.js} +2 -2
- package/dist/public/assets/{ModelRefcount-Bh-Gx_um.js → ModelRefcount-ChfPx0UZ.js} +1 -1
- package/dist/public/assets/{PaneEditorBody-DeInskNr.js → PaneEditorBody-8lazO4kO.js} +7 -7
- package/dist/public/assets/{SettingsDialog-B-y1ZE4i.js → SettingsDialog-BpsUZQB5.js} +1 -1
- package/dist/public/assets/{Terminal-ChnHAaOZ.js → Terminal-Bexn0tqa.js} +2 -2
- package/dist/public/assets/Workspace-BE_QOMyH.js +7 -0
- package/dist/public/assets/{buffer-store-CtR80J8K.js → buffer-store-BTEgWcpZ.js} +3 -3
- package/dist/public/assets/{context-menu-D2IgAJf3.js → context-menu-BIqiOFyY.js} +1 -1
- package/dist/public/assets/{cssMode-D0_hzalo.js → cssMode-BH6iLDEP.js} +1 -1
- package/dist/public/assets/editor-context-BZHPtUDq.js +1 -0
- package/dist/public/assets/{editor-sync-DoqKyrPU.js → editor-sync-DcvE_QhK.js} +1 -1
- package/dist/public/assets/{file-links-Cv4u-85W.js → file-links-BUb_sQYr.js} +1 -1
- package/dist/public/assets/{hotkeys-uS50-PkH.js → hotkeys-BApA7bsN.js} +1 -1
- package/dist/public/assets/{htmlMode-CfxGDG5X.js → htmlMode-VynBD_99.js} +1 -1
- package/dist/public/assets/index-DMiHDm9d.js +10 -0
- package/dist/public/assets/{jsonMode-BJ8glT_6.js → jsonMode-BkDE2aQc.js} +1 -1
- package/dist/public/assets/{session-seed-BXfZcX7t.js → session-seed-DJUa6_Hr.js} +1 -1
- package/dist/public/assets/{tsMode-QThqdAds.js → tsMode-Bc49vc2n.js} +1 -1
- package/dist/public/assets/{use-find-controls-XCU2T3Mk.js → use-find-controls-BiId78Q6.js} +1 -1
- package/dist/public/index.html +3 -3
- package/package.json +1 -1
- package/dist/public/assets/Workspace-DdkhBJEw.js +0 -7
- package/dist/public/assets/editor-context-ZCl2hgXk.js +0 -1
- package/dist/public/assets/index-V87RMkBD.js +0 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n,n as r,r as i}from"./x-BJOrp_m5.js";import{$ as a,A as o,F as s,Ft as c,It as l,J as u,K as d,Mt as f,Nt as p,Pt as m,R as h,T as g,U as ee,V as _,Vt as v,W as te,X as ne,Z as y,a as b,at as x,et as S,f as C,ft as w,g as re,i as ie,it as T,jt as ae,k as oe,n as se,nt as ce,pt as le,st as ue,t as de,v as E,w as fe}from"./hotkeys-uS50-PkH.js";import{a as D,h as O,i as k,n as A,o as j,r as M,t as N}from"./dialog-DjL0qoAv.js";import{a as pe,c as P,i as F,l as I,o as me,r as he,s as ge}from"./LazyTerminal-dobHNDnL.js";import{a as L,i as R,n as z,o as B,r as V,t as _e}from"./session-seed-BXfZcX7t.js";import{t as ve}from"./chevron-down-59O6CgEo.js";import{r as ye}from"./dist-DDFe8e3m.js";import{$ as be,Ct as xe,Dt as Se,Et as Ce,G as we,H as Te,J as Ee,K as De,Lt as Oe,Ot as ke,Q as Ae,R as H,St as je,U as Me,V as U,Vt as Ne,W as Pe,X as W,Y as G,bt as Fe,et as Ie,gt as Le,ht as Re,kt as ze,mt as Be,ot as Ve,q as He,r as Ue,rt as We,tt as Ge,xt as Ke,yt as qe}from"./index-V87RMkBD.js";var Je=r(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),Ye=r(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Xe=r(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),Ze=r(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),Qe=r(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),$e=r(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),et=r(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),tt=r(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),K=e(t(),1),q=n();function J({id:e,value:t,min:n,max:r,step:i,className:a,onCommit:o}){let[s,c]=(0,K.useState)(String(t));return(0,K.useEffect)(()=>c(String(t)),[t]),(0,q.jsx)(P,{id:e,type:`number`,min:n,max:r,step:i,className:a,value:s,onChange:e=>c(e.target.value),onBlur:()=>{let e=Number(s);if(s.trim()===``||!Number.isFinite(e)){c(String(t));return}let i=Math.min(r??e,Math.max(n??e,e));c(String(i)),i!==t&&o(i)},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}function Y({label:e,description:t,descriptionClassName:n,htmlFor:r,children:a,className:o}){return(0,q.jsxs)(`div`,{className:i(`flex items-center gap-4 py-2.5`,o),children:[(0,q.jsxs)(`label`,{htmlFor:r,className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,q.jsx)(`span`,{className:`text-sm text-fg`,children:e}),t&&(0,q.jsx)(`span`,{className:i(`text-xs text-fg-muted`,n),children:t})]}),(0,q.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:a})]})}function X({children:e,note:t}){return(0,q.jsxs)(`div`,{className:`mb-2 flex flex-col gap-0.5`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e}),t&&(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t})]})}function nt(){let e=W(),[t,n]=(0,K.useState)(Ne());return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Appearance`}),(0,q.jsx)(Y,{label:`Theme`,children:(0,q.jsxs)(z,{value:t,onValueChange:e=>{n(e),Oe(e)},children:[(0,q.jsx)(L,{className:`w-32`,children:(0,q.jsx)(B,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(R,{value:`dark`,children:`Dark`}),(0,q.jsx)(R,{value:`light`,children:`Light`}),(0,q.jsx)(R,{value:`system`,children:`System`})]})]})}),(0,q.jsx)(Y,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,q.jsx)(J,{id:`ui-font-size`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onCommit:e=>G({uiFontSize:e})})}),(0,q.jsx)(Y,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,q.jsx)(J,{id:`terminal-font-size`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onCommit:e=>G({terminalFontSize:e})})}),(0,q.jsx)(Y,{label:`Editor font size`,htmlFor:`editor-font-size`,children:(0,q.jsx)(J,{id:`editor-font-size`,min:9,max:32,step:.5,className:`w-20 tabular-nums`,value:e.editorFontSize,onCommit:e=>G({editorFontSize:e})})}),(0,q.jsx)(Y,{label:`Density`,children:(0,q.jsxs)(z,{value:e.density,onValueChange:e=>G({density:e}),children:[(0,q.jsx)(L,{className:`w-36`,children:(0,q.jsx)(B,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(R,{value:`compact`,children:`Compact`}),(0,q.jsx)(R,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,q.jsx)(Y,{label:`Project-based layout`,description:`Editor layouts are separated across projects.`,htmlFor:`project-based-layout`,children:(0,q.jsx)(H,{id:`project-based-layout`,checked:e.projectBasedLayout,onCheckedChange:e=>G({projectBasedLayout:e})})}),(0,q.jsx)(Y,{label:`All projects in the session list`,description:`Right sidebar displays sessions from all projects.`,htmlFor:`show-all-project-sessions`,children:(0,q.jsx)(H,{id:`show-all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>G({showAllProjectSessions:e})})})]})}function rt({profile:e}){let t=a(),[n,r]=(0,K.useState)(!1),o=n=>{t.mutate({id:e.id,icon:n},{onError:e=>F(e)}),r(!1)},s=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>F(e)});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{label:`Icon`,children:(0,q.jsxs)(be,{open:n,onOpenChange:r,children:[(0,q.jsx)(Ge,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,className:`flex size-9 items-center justify-center rounded-md text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(qe,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,q.jsx)(Ie,{align:`end`,className:`w-72`,children:(0,q.jsxs)(`div`,{className:`grid grid-cols-8 gap-1`,children:[(0,q.jsx)(`button`,{type:`button`,title:`Default`,onClick:()=>o(null),className:i(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,!e.icon&&`bg-elevated text-fg`),children:(0,q.jsx)(qe,{icon:null,colour:null,className:`size-4`})}),Ke.map(({name:t,Icon:n})=>(0,q.jsx)(`button`,{type:`button`,title:t,onClick:()=>o(t),className:i(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,e.icon===t&&`bg-elevated text-fg`),children:(0,q.jsx)(n,{className:`size-4`})},t))]})})]})}),(0,q.jsx)(Y,{label:`Icon colour`,children:(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,q.jsxs)(`button`,{type:`button`,title:`Default`,onClick:()=>s(null),className:i(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,!e.icon_colour&&`bg-elevated`),children:[(0,q.jsx)(`span`,{className:`size-3.5 rounded-full bg-fg-muted`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Default colour`})]}),c.map(t=>(0,q.jsxs)(`button`,{type:`button`,title:t,onClick:()=>s(t),className:i(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,e.icon_colour===t&&`bg-elevated`),children:[(0,q.jsx)(`span`,{className:i(`size-3.5 rounded-full bg-current`,Fe(t))}),(0,q.jsx)(`span`,{className:`sr-only`,children:t})]},t))]})})]})}var it=`__none__`;function at(){let e=E(),t=x().data?.find(t=>t.id===e),n=fe(e??void 0),r=T(e??void 0),i=a(),o=S(e??``),s=_(),[c,l]=(0,K.useState)(``),[u,d]=(0,K.useState)(``),[f,p]=(0,K.useState)(!1),[m,h]=(0,K.useState)(``);if((0,K.useEffect)(()=>{t&&(l(t.name),d(t.branch_prefix))},[t]),!t)return null;let g=r.data?.default_account_id;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Profile`}),(0,q.jsxs)(Y,{label:`Name`,description:`Letters, digits, dot, underscore and hyphen.`,htmlFor:`profile-name`,children:[(0,q.jsx)(P,{id:`profile-name`,value:c,onChange:e=>l(e.target.value),className:`w-44`}),(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:c===t.name||c.trim()===``||i.isPending,onClick:()=>i.mutate({id:t.id,name:c},{onError:e=>F(e)}),children:`Save`})]}),(0,q.jsxs)(Y,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,q.jsx)(P,{id:`branch-prefix`,value:u,onChange:e=>d(e.target.value),placeholder:`no prefix`,className:`w-44`}),(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:u===t.branch_prefix||i.isPending,onClick:()=>i.mutate({id:t.id,branch_prefix:u},{onError:e=>F(e)}),children:`Save`})]}),(0,q.jsx)(rt,{profile:t}),(0,q.jsx)(Y,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,q.jsxs)(z,{value:typeof g==`number`?String(g):it,onValueChange:e=>o.mutate({default_account_id:e===it?null:Number(e)},{onError:e=>F(e)}),children:[(0,q.jsx)(L,{className:`w-56`,children:(0,q.jsx)(B,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(R,{value:it,children:`First available`}),n.data?.map(e=>(0,q.jsx)(R,{value:String(e.id),children:(0,q.jsxs)(`span`,{children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,q.jsx)(Y,{label:`Delete profile`,description:`Non-archived sessions block deletion.`,className:`mt-4`,children:(0,q.jsx)(O,{variant:`danger`,size:`sm`,onClick:()=>p(!0),children:`Delete…`})}),(0,q.jsx)(N,{open:f,onOpenChange:e=>{e||(p(!1),h(``))},children:(0,q.jsxs)(A,{children:[(0,q.jsxs)(D,{children:[(0,q.jsxs)(j,{children:[`Delete profile `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),`?`]}),(0,q.jsx)(M,{children:`Everything this profile owns goes with it: projects, workspace layouts, accounts and their credential directories, and archived session history. Branches, repositories, and terminal logs on disk are untouched. This cannot be undone.`})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(ge,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),` to confirm`]}),(0,q.jsx)(P,{id:`delete-confirm-name`,value:m,onChange:e=>h(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(k,{children:[(0,q.jsx)(O,{variant:`ghost`,onClick:()=>{p(!1),h(``)},children:`Cancel`}),(0,q.jsx)(O,{variant:`danger`,disabled:m!==t.name||s.isPending,onClick:()=>s.mutate(t.id,{onSuccess:()=>{Be(),re.set(null)},onError:e=>{p(!1),h(``),F(e)}}),children:`Delete profile`})]})]})})]})}function ot({agent:e,profileId:t,onClose:n,onCreated:r}){let i=o(),[a,s]=(0,K.useState)(``),[c,l]=(0,K.useState)(``),u=ee(Ve(c,150)),d=c.trim(),f=d===``||d.startsWith(`/`)||d.startsWith(`~`),p=a.trim()!==``&&f,m=()=>{!p||i.isPending||i.mutate({profile_id:t,agent_type:e.id,label:a.trim(),...d===``?{}:{import_dir:d}},{onSuccess:e=>{n(),r(e,d!==``)},onError:e=>F(e)})};return(0,q.jsx)(N,{open:!0,onOpenChange:e=>!e&&n(),children:(0,q.jsxs)(A,{children:[(0,q.jsxs)(D,{children:[(0,q.jsxs)(j,{children:[`Add a `,e.display_name,` account`]}),(0,q.jsxs)(M,{children:[`Accounts are isolated config dirs under this profile. Naming one is enough — Puddle creates it and takes you straight to `,e.display_name,`’s login. To reuse an account you already have on this machine, give its config directory: it is copied in and the original is never touched.`]})]}),(0,q.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),m()},children:[(0,q.jsx)(P,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>s(e.target.value)}),(0,q.jsx)(he,{value:c,onValueChange:l,placeholder:`(optional) existing config dir, e.g. ~/.claude`,hints:(u.data?.entries??[]).map(e=>({value:e.path,label:e.name}))})]}),(0,q.jsxs)(k,{children:[(0,q.jsx)(O,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,q.jsxs)(O,{disabled:!p||i.isPending,onClick:m,children:[(0,q.jsx)(Se,{}),`Add account`]})]})]})})}function st({account:e,gateOpen:t,installed:n}){let r=u(),i=ne(),a=h(),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(!1),[d,f]=(0,K.useState)(e.label),p=(0,K.useRef)(null);return(0,K.useEffect)(()=>f(e.label),[e.label]),(0,q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md bg-surface px-3 py-2`,children:[(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(`input`,{ref:p,value:d,onChange:e=>f(e.target.value),onBlur:()=>{let t=d.trim();if(t!==e.label){if(t===``){f(e.label);return}i.mutate({id:e.id,label:t},{onError:t=>{F(t),f(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(f(e.label),t.currentTarget.blur())},"aria-label":`Account name`,className:`-mx-1 block w-full min-w-0 truncate rounded-sm bg-transparent px-1 py-0.5 text-sm text-fg transition-colors hover:bg-elevated focus:bg-elevated focus:outline-none`}),(0,q.jsxs)(`button`,{type:`button`,title:`Rename account`,onClick:()=>{p.current?.focus(),p.current?.select()},className:`shrink-0 rounded-sm p-0.5 text-fg-muted transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(pe,{className:`size-3`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Rename account`})]})]}),(0,q.jsx)(`span`,{className:`text-2xs ${e.logged_in?`text-success`:`text-warning`}`,children:e.logged_in?`logged in`:`not logged in`})]}),t&&(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-secondary`,children:[`skip prompts`,(0,q.jsx)(H,{checked:e.skip_permissions_default,onCheckedChange:t=>i.mutate({id:e.id,skip_permissions_default:t},{onError:e=>F(e)})})]}),(0,q.jsxs)(O,{size:`sm`,variant:`secondary`,disabled:r.isPending||!n,onClick:()=>r.mutate(e.id,{onSuccess:e=>s({stream:e.stream,hint:e.hint}),onError:e=>F(e)}),children:[(0,q.jsx)(ze,{}),e.logged_in?`Re-login`:`Login`]}),(0,q.jsxs)(O,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>l(!0),children:[(0,q.jsx)(xe,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),o&&(0,q.jsx)(Ae,{stream:o.stream,hint:o.hint,label:`${e.agent_type}/${e.label}`,onClose:()=>s(null)}),(0,q.jsx)(N,{open:c,onOpenChange:l,children:(0,q.jsxs)(A,{children:[(0,q.jsxs)(D,{children:[(0,q.jsxs)(j,{children:[`Delete `,(0,q.jsx)(`span`,{className:`text-fg`,children:e.label}),`?`]}),(0,q.jsx)(M,{children:`Removes the account, its archived session history, and its credential directory — this logs the account out. Non-archived sessions block deletion.`})]}),(0,q.jsxs)(k,{children:[(0,q.jsx)(O,{variant:`ghost`,onClick:()=>l(!1),children:`Cancel`}),(0,q.jsx)(O,{variant:`danger`,disabled:a.isPending,onClick:()=>a.mutate(e.id,{onSuccess:()=>l(!1),onError:e=>{l(!1),F(e)}}),children:`Delete account`})]})]})})]})}function ct(){let e=E(),t=g(),n=fe(e??void 0),r=T(e??void 0),i=u(),[a,o]=(0,K.useState)(null),[s,c]=(0,K.useState)(null),l=r.data?.allowSkipPermissions===!0;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Accounts`}),t.data?.map(e=>{let t=n.data?.filter(t=>t.agent_type===e.id)??[],r=e.available!==!1;return(0,q.jsxs)(`div`,{className:`mb-5`,children:[(0,q.jsx)(Y,{label:e.display_name,description:r?`Accounts are initialised in config dirs owned by this profile.`:`No ${e.binary??e.id} on the daemon’s PATH. Install it or add its directory to the agent search path in Sessions.`,className:`py-1`,children:(0,q.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e.id})}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t.map(t=>(0,q.jsx)(st,{account:t,gateOpen:l&&e.capabilities.skip_permissions,installed:r},t.id)),(0,q.jsx)(`div`,{className:`flex`,children:(0,q.jsxs)(O,{type:`button`,size:`sm`,variant:`secondary`,disabled:!r,onClick:()=>c(e),children:[(0,q.jsx)(Se,{}),`Add account`]})})]})]},e.id)}),a&&(0,q.jsx)(Ae,{stream:a.stream,label:a.label,hint:a.hint,onClose:()=>o(null)}),s!==null&&e!==null&&(0,q.jsx)(ot,{agent:s,profileId:e,onClose:()=>c(null),onCreated:(e,t)=>{if(t){e.logged_in||v.info(`Imported without credentials — press Login to authenticate.`);return}i.mutate(e.id,{onSuccess:t=>o({stream:t.stream,label:`${e.agent_type}/${e.label}`,hint:t.hint}),onError:e=>F(e)})}})]})}function lt(){let e=oe(),t=y(),[n,r]=(0,K.useState)(``);return(0,K.useEffect)(()=>{e.data&&r(e.data.agentPath)},[e.data]),(0,q.jsx)(Y,{label:`Agent search path (host-wide)`,description:`Colon-separated dirs the daemon prepends to PATH; helps find agent CLIs like claude (e.g. ~/.local/bin).`,htmlFor:`agent-path`,children:(0,q.jsx)(P,{id:`agent-path`,type:`text`,className:`w-64 text-2xs`,value:n,onChange:e=>r(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function ut({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=_e(e,n),o=n.sessionDefaults??{},[s,c]=(0,K.useState)(a.baseBranch),l=t=>r({...o,[e]:{...o[e],...t}});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mb-1 mt-4 text-xs font-medium uppercase tracking-wide text-fg-gold`,children:t}),(0,q.jsx)(Y,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,q.jsx)(P,{id:`${e}-default-base`,type:`text`,placeholder:`repository default`,className:`w-48`,value:s,onChange:e=>c(e.target.value),onBlur:()=>{s.trim()!==a.baseBranch&&l({baseBranch:s.trim()})}})}),(0,q.jsx)(Y,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,q.jsx)(H,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,q.jsx)(Y,{label:`Separate directory`,description:a.separateBranch?`Always on while a separate branch is used.`:`Start on working copy of the selected branch instead of sharing one directory.`,htmlFor:`${e}-default-dir`,children:(0,q.jsx)(H,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function dt(){return(0,q.jsx)(Y,{label:`Terminal scrollback`,htmlFor:`scrollback`,children:(0,q.jsx)(J,{id:`scrollback`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:W().terminalScrollback,onCommit:e=>G({terminalScrollback:e})})})}function ft({id:e,label:t,description:n,initial:r,defaultText:i,onSave:a,pending:o}){let[s,c]=(0,K.useState)(r);return(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:e,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[t,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n})]}),(0,q.jsx)(I,{id:e,value:s,onChange:e=>c(e.target.value),rows:6,className:`font-mono`}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,q.jsx)(O,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var pt={id:`4f3c2b1a-7e6d-5c4b-3a2f-1e0d9c8b7a6f`,title:null,agent_title:`Refactor the auth flow`,osc_title:`claude`,branch:`alice/refactor-auth`,worktree_path:`/home/alice/code/app--refactor-auth`,status:`waiting_input`,agent_type:`claude-code`};function mt({initial:e,onSave:t,pending:n}){let[r,i]=(0,K.useState)(e),a=r.length>0?r:m;return(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:`tab-title-template`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Template`,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Compose the label from the parts below. Empty falls back to the default.`})]}),(0,q.jsx)(P,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:m}),(0,q.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,q.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:We(pt,a)})]}),(0,q.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:l.map(([e,t])=>(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`dt`,{className:`w-24 shrink-0 font-mono text-fg-secondary`,children:`\${${e}}`}),(0,q.jsx)(`dd`,{className:`text-fg-muted`,children:t})]},e))}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,q.jsx)(O,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(m),t(m)},children:`Reset to default`})]})]})}function ht(){let e=E(),t=x().data?.find(t=>t.id===e),n=T(e??void 0),r=S(e??``),[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(``),c=n.data?.allowSkipPermissions===!0,l=e=>r.mutate({allowSkipPermissions:e},{onSuccess:()=>{a(!1),s(``)},onError:e=>F(e)}),u=e=>t=>r.mutate({[e]:t},{onError:e=>F(e)});return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Sessions`}),(0,q.jsx)(Y,{label:`Skip permission prompts`,htmlFor:`gate`,children:(0,q.jsx)(H,{id:`gate`,checked:c,onCheckedChange:e=>{e?a(!0):l(!1)}})}),(0,q.jsx)(Y,{label:`Capture exported env variables`,description:n.data?.captureSessionEnv===!1?`No variables are captured or injected; already-captured variabless are kept for when this is re-enabled.`:`Variables exported in a session persist and are re-injected upon terminal and agent restarts.`,htmlFor:`capture-env`,children:(0,q.jsx)(H,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:r.isPending,onCheckedChange:e=>r.mutate({captureSessionEnv:e},{onError:e=>F(e)})})}),(0,q.jsx)(lt,{}),(0,q.jsx)(dt,{}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{children:`New session defaults`}),n.data&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(ut,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>F(e)}),pending:r.isPending},`${e}:agent-seed`),(0,q.jsx)(ut,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>F(e)}),pending:r.isPending},`${e}:terminal-seed`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{note:`Sent to agent as opening message when a session (re)starts. You can make this empty.`,children:`Launch text`}),n.data&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(ft,{id:`onboarding-template`,label:`New worktree`,description:`Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??f,defaultText:f,onSave:u(`onboardingTemplate`),pending:r.isPending},`${e}:onboarding`),(0,q.jsx)(ft,{id:`concurrent-template`,label:`Existing / shared worktree`,description:`For a session joining a worktree other agents may already be working in.`,initial:n.data.concurrentTemplate??ae,defaultText:ae,onSave:u(`concurrentTemplate`),pending:r.isPending},`${e}:concurrent`),(0,q.jsx)(ft,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot.`,initial:n.data.restartTemplate??p,defaultText:p,onSave:u(`restartTemplate`),pending:r.isPending},`${e}:restart`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{children:`Tab title`}),n.data&&(0,q.jsx)(mt,{initial:n.data.tabTitleTemplate||"${name}",onSave:u(`tabTitleTemplate`),pending:r.isPending},`${e}:tab-title`)]}),(0,q.jsx)(N,{open:i,onOpenChange:e=>{e||(a(!1),s(``))},children:(0,q.jsxs)(A,{children:[(0,q.jsxs)(D,{children:[(0,q.jsxs)(j,{className:`flex items-center gap-2`,children:[(0,q.jsx)($e,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,q.jsx)(M,{asChild:!0,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,q.jsx)(`p`,{children:`A prompt-free agent acts unattended, with your credentials, inside its worktree — and nothing technically stops a shell command from reaching outside it. It can:`}),(0,q.jsxs)(`ul`,{className:`list-disc pl-5 text-fg-secondary`,children:[(0,q.jsx)(`li`,{children:`run any shell command without asking first,`}),(0,q.jsx)(`li`,{children:`modify, delete, or exfiltrate files your user can reach,`}),(0,q.jsx)(`li`,{children:`install dependencies and execute the network requests they make,`}),(0,q.jsx)(`li`,{children:`push branches or call remote APIs with the credentials it finds.`})]}),(0,q.jsx)(`p`,{children:`Only open this gate if every account you opt in runs work you would trust a colleague to run unsupervised on this machine.`}),(0,q.jsx)(`p`,{className:`text-fg-muted`,children:`Opening it also records the agent’s own bypass-permissions acceptance for this profile’s accounts, so the skip actually takes effect.`})]})})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(ge,{htmlFor:`confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t?.name}),` to confirm`]}),(0,q.jsx)(P,{id:`confirm-name`,value:o,onChange:e=>s(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(k,{children:[(0,q.jsx)(O,{variant:`ghost`,onClick:()=>{a(!1),s(``)},children:`Cancel`}),(0,q.jsx)(O,{variant:`danger`,disabled:o!==t?.name||r.isPending,onClick:()=>l(!0),children:`Open the gate`})]})]})})]})}var gt={desktop:!0,sound:!1,muted_projects:[]};function _t(){let[e,t]=(0,K.useState)(U);return(0,K.useEffect)(()=>{let e=()=>t(U());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(U())]}function vt({permission:e,onRequest:t}){return e===`granted`?null:(0,q.jsxs)(`p`,{className:`pb-2 text-xs text-warning`,children:[e==="default"&&(0,q.jsxs)(q.Fragment,{children:[`The browser has not been asked for permission yet, so nothing will show —`,` `,(0,q.jsx)(`button`,{type:`button`,onClick:t,className:`underline underline-offset-2 transition-colors hover:text-fg`,children:`request it now`}),`.`]}),e===`denied`&&`Blocked by the browser — allow notifications for this site in its site settings, then return here.`,e===`unsupported`&&`This browser cannot show desktop notifications.`]})}function yt(){let e=E(),t=T(e??void 0),n=S(e??``),r=ue(e??void 0),[i,a]=_t(),o={...gt,...t.data?.notifications??{}},s=e=>n.mutate({notifications:e},{onError:e=>F(e)}),c=()=>{typeof Notification>`u`||Notification.requestPermission().then(a)};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Notifications`}),(0,q.jsx)(Y,{label:`Desktop notification on waiting`,htmlFor:`notify-desktop`,children:(0,q.jsx)(H,{id:`notify-desktop`,checked:o.desktop,onCheckedChange:e=>{e&&c(),s({...o,desktop:e})}})}),o.desktop&&(0,q.jsx)(vt,{permission:i,onRequest:c}),(0,q.jsx)(Y,{label:`Sound`,htmlFor:`notify-sound`,children:(0,q.jsx)(H,{id:`notify-sound`,checked:o.sound,onCheckedChange:e=>s({...o,sound:e})})}),(0,q.jsx)(Y,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,q.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[o.muted_projects.length,` muted`]})}),(0,q.jsx)(`div`,{className:`flex flex-col gap-1`,children:r.data?.map(e=>(0,q.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-secondary hover:bg-elevated`,children:[(0,q.jsx)(H,{checked:o.muted_projects.includes(e.id),onCheckedChange:t=>s({...o,muted_projects:t?[...o.muted_projects,e.id]:o.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function bt(){let e=W();return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Editor`}),(0,q.jsx)(Y,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,q.jsx)(J,{id:`tab-size`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onCommit:e=>G({editorTabSize:e})})}),(0,q.jsx)(Y,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,q.jsx)(H,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>G({editorWordWrap:e})})}),(0,q.jsx)(Y,{label:`SSH host for editor links`,description:`Used for vscode:// and cursor:// remote links until the CLI supplies it automatically.`,htmlFor:`editor-link-host`,children:(0,q.jsx)(P,{id:`editor-link-host`,type:`text`,placeholder:Ue.get()??`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>G({editorLinkSshHost:e.target.value})})})]})}function xt({value:e,isDefault:t,onRecord:n,onReset:r}){let[a,o]=(0,K.useState)(!1);return(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>o(!0),onBlur:()=>o(!1),onKeyDown:e=>{if(!a)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){o(!1);return}let t=ie(e.nativeEvent);t&&(n(t),o(!1))},className:i(`min-w-24 rounded-md px-2 py-1 text-center font-mono text-xs transition-colors`,a?`bg-action text-action-ink`:`bg-elevated text-fg hover:bg-border/70`),children:a?`Press keys…`:b(e)}),!t&&(0,q.jsxs)(`button`,{type:`button`,title:`Reset to default`,onClick:r,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(Ze,{className:`size-3.5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function St(){let e=E(),t=T(e??void 0),n=S(e??``),r=t.data?.hotkeys??{},i=(e,t)=>r[e]||t,a=new Map;for(let e of de){let t=i(e.id,C(e));a.set(t,(a.get(t)??0)+1)}let o=(e,t)=>n.mutate({hotkeys:{...r,[e]:t}},{onError:e=>F(e)}),s=e=>{let t={...r};delete t[e],n.mutate({hotkeys:t},{onError:e=>F(e)})};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Hotkeys`}),(0,q.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:`Per-profile keyboard shortcuts. Filetree navigation and terminal line-edits are fixed.`}),(0,q.jsx)(Y,{label:`App shortcuts in terminals`,description:t.data?.terminalAppShortcuts===!1?`A focused terminal receives these keys instead.`:`The shortcuts below work while a terminal is focused.`,htmlFor:`terminal-app-shortcuts`,className:`mb-4`,children:(0,q.jsx)(H,{id:`terminal-app-shortcuts`,checked:t.data?.terminalAppShortcuts!==!1,disabled:n.isPending,onCheckedChange:e=>n.mutate({terminalAppShortcuts:e},{onError:e=>F(e)})})}),se.map(e=>{let t=de.filter(t=>t.group===e);return t.length===0?null:(0,q.jsxs)(`div`,{className:`mb-5`,children:[(0,q.jsx)(`div`,{className:`mb-1 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:e}),t.map(e=>{let t=i(e.id,C(e)),n=(a.get(t)??0)>1?`Conflicts with another shortcut.`:void 0;return(0,q.jsx)(Y,{label:e.label,description:n,descriptionClassName:n?`text-interrupted`:void 0,children:(0,q.jsx)(xt,{value:t,isDefault:!r[e.id],onRecord:t=>o(e.id,t),onReset:()=>s(e.id)})},e.id)})]},e)})]})}var Ct=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,Z=65,Q=Object.fromEntries([...Ct].map((e,t)=>[e,t])),wt=`H`,Tt=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t+=1){let n=t;for(let e=0;e<8;e+=1)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function Et(e){let t=4294967295;for(let n of e)t=Tt[(t^n)&255]^t>>>8;return((t^4294967295)>>>0).toString(16).padStart(8,`0`)}function Dt(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function Ot(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}async function kt(e){let t=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}async function At(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Response(t).text()}function jt(e,t){let n=(t%Z+Z)%Z,r=``;for(let t of e){let e=Q[t];r+=e===void 0?t:Ct[(e+n)%Z]}return r}async function Mt(e){let t=await kt(JSON.stringify(e));return jt(Dt(t)+Et(t),1+Math.floor(Math.random()*(Z-1)))}async function Nt(e){let t=e.trim(),n=t[0];if(!n||Q[n]===void 0)throw Error(`Not a settings export.`);let r=jt(t,-((Q[n]-Q[wt]+Z)%Z));if(r.length<9||r[0]!==wt)throw Error(`Not a settings export.`);let i=r.slice(0,-8),a=r.slice(-8),o=Ot(i);if(Et(o)!==a)throw Error(`Settings export is corrupt (checksum mismatch).`);return JSON.parse(await At(o))}var Pt=`puddle.sync-selection`;function Ft(){try{let e=JSON.parse(localStorage.getItem(Pt)??`null`);if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}catch{}return we.map(e=>e.id)}function It({selected:e,onToggle:t}){return(0,q.jsx)(`div`,{className:`flex flex-col gap-2 pl-1`,children:we.map(n=>(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(H,{checked:e.includes(n.id),onCheckedChange:e=>t(n.id,e)}),n.label]},n.id))})}function Lt(){let e=E(),t=T(e??void 0),n=x().data?.find(t=>t.id===e),r=le(e??void 0,void 0),i=S(e??``),o=a(),c=s(),l=Me(),u=Pe(),[d,f]=(0,K.useState)(``),[p,m]=(0,K.useState)(``),[h,g]=(0,K.useState)(!1),[ee,_]=(0,K.useState)(!1),[te,ne]=(0,K.useState)(Ft),y=n&&l.data?Te(l.data.file,n.name):void 0,b=y?.enabled===!0,C=b&&y?y.groups:te,w=()=>({client:Ee(),theme:Ne(),profileSettings:t.data??{},profile:n??{},scratchpad:r.data??[]}),re={setClient:e=>G(e),setTheme:e=>{typeof e==`string`&&Oe(e)},patchProfileSettings:e=>i.mutate(e,{onError:e=>F(e)}),patchProfileColumns:t=>{e&&o.mutate({id:e,...t},{onError:e=>F(e)})},createScratchpad:t=>{if(e)for(let n of t)c.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},ie=(e,t)=>{n&&u.mutate({profile:n.name,entry:{enabled:e.enabled??b,groups:t,doc:He(t,w()),updatedAt:new Date().toISOString()}},{onError:e=>F(e)})},ae=(e,t)=>{let n=t?[...C,e]:C.filter(t=>t!==e);ne(n),localStorage.setItem(Pt,JSON.stringify(n)),b&&ie({},n)},oe=async()=>{_(!0);try{let e=De(await Nt(d.trim()),re,{profileSettings:t.data??{},scratchpad:r.data??[]});e.length===0?v.error(`Nothing recognised to import.`):(v.success(`Imported ${e.join(`, `)}.`),f(``))}catch(e){v.error(e.message)}finally{_(!1)}},se=async()=>{_(!0);try{let e=await Mt(He(C,w()));m(e),await navigator.clipboard?.writeText(e),v.success(`Copied to clipboard`)}finally{_(!1)}};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Sync`}),(0,q.jsx)(`p`,{className:`mb-5 text-xs text-fg-muted`,children:`Carry your settings between machines. Accounts, repositories, and anything host-specific are never included. Applies to this profile.`}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Sync locally`}),l.data?.available===!1?(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:`Not available in this cockpit — start the UI with the Puddle CLI to sync across windows.`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:[`Sync selected groups through this machine’s`,` `,(0,q.jsx)(`span`,{className:`text-fg-secondary`,children:`~/.puddle`}),`, so every Puddle window stays in step for profiles named`,` `,(0,q.jsx)(`span`,{className:`text-fg-secondary`,children:n?.name??`…`}),`.`]}),(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(H,{checked:b,disabled:!n||l.isLoading||u.isPending,onCheckedChange:e=>ie({enabled:e},C)}),`Sync locally`]})]})]}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>g(e=>!e),className:`flex items-center gap-1 text-xs text-fg-secondary transition-colors hover:text-fg`,children:[h?(0,q.jsx)(ve,{className:`size-3.5`}):(0,q.jsx)(ye,{className:`size-3.5`}),`Choose what to sync`]}),h&&(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(It,{selected:C,onToggle:ae})})]}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Export`}),(0,q.jsx)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:`Builds a Puddle magic string that encodes settings from the checklist above.`}),(0,q.jsx)(O,{size:`sm`,disabled:ee,onClick:()=>void se(),children:`Export & copy`}),p&&(0,q.jsx)(I,{readOnly:!0,value:p,rows:3,spellCheck:!1,onFocus:e=>e.currentTarget.select(),className:`mt-2 resize-y font-mono text-xs`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Import`}),(0,q.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:`Paste a Puddle magic string to import its settings.`}),(0,q.jsx)(I,{value:d,onChange:e=>f(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:`Paste a settings export…`,rows:3,spellCheck:!1,className:`resize-y font-mono text-xs`}),(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(O,{size:`sm`,disabled:!d.trim()||ee,onClick:()=>void oe(),children:`Import`})})]})]})}function Rt({repo:e}){let t=ce(),n=te(),[r,i]=(0,K.useState)(e.default_base_branch),[a,o]=(0,K.useState)(e.onboarding_notes??``),s=e=>F(e);return(0,q.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface p-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.path}),(0,q.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted tabular-nums`,children:e.last_fetched_at?`fetched ${new Date(e.last_fetched_at).toLocaleString()}`:`never fetched`}),(0,q.jsxs)(O,{size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:()=>v.success(`Fetched.`),onError:s}),children:[(0,q.jsx)(Ce,{}),`Fetch now`]})]}),(0,q.jsxs)(Y,{label:`Default base branch`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,q.jsx)(P,{id:`base-${e.id}`,value:r,onChange:e=>i(e.target.value),className:`w-40`}),(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:r===e.default_base_branch||t.isPending,onClick:()=>t.mutate({id:e.id,default_base_branch:r},{onError:s}),children:`Save`})]}),(0,q.jsx)(Y,{label:`Periodic fetch`,description:`Fetched on open and on the daemon's interval while sessions are active.`,htmlFor:`fetch-${e.id}`,className:`py-1.5`,children:(0,q.jsx)(H,{id:`fetch-${e.id}`,checked:e.fetch_enabled,onCheckedChange:n=>t.mutate({id:e.id,fetch_enabled:n},{onError:s})})}),(0,q.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:`notes-${e.id}`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Onboarding notes`,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Standing setup rules, injected into every fresh worktree. Agents update them via .puddle/onboarding-notes.md.`})]}),(0,q.jsx)(I,{id:`notes-${e.id}`,value:a,onChange:e=>o(e.target.value),rows:4}),(0,q.jsx)(`div`,{children:(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:a===(e.onboarding_notes??``)||t.isPending,onClick:()=>t.mutate({id:e.id,onboarding_notes:a},{onError:s}),children:`Save notes`})})]}),e.orphan_worktrees.length>0&&(0,q.jsxs)(`div`,{className:`mt-3 rounded-md bg-elevated p-2`,children:[(0,q.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:`Orphan worktrees — directories no session claims. Puddle never deletes these automatically; remove them by hand if unwanted.`}),(0,q.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.orphan_worktrees.map(e=>(0,q.jsx)(`li`,{className:`truncate text-2xs text-fg-muted`,children:e},e))})]})]})}function zt(){let e=w();return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Projects`}),e.data?.length===0&&(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No projects yet — create one from the dashboard, pointing at a repository.`}),e.data?.map(e=>(0,q.jsx)(Rt,{repo:e},e.id))]})}function $({label:e,description:t,field:n,config:r,min:i,step:a=1}){let o=y();return(0,q.jsx)(Y,{label:e,description:t,htmlFor:`host-${n}`,children:(0,q.jsx)(P,{id:`host-${n}`,type:`number`,min:i,step:a,className:`w-32 tabular-nums`,defaultValue:r[n],onBlur:e=>{if(e.target.value.trim()===``){e.target.value=String(r[n]);return}let t=Number(e.target.value);Number.isFinite(t)&&t!==r[n]&&o.mutate({[n]:t},{onError:e=>F(e)})}})})}function Bt(){let e=oe(),t=y(),n=d();return e.data?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{note:`Affects all profiles on this host`,children:`Host`}),(0,q.jsx)(Y,{label:`Display name`,description:`Shown in place of the hostname across the UI. Leave blank for the hostname.`,htmlFor:`host-displayName`,children:(0,q.jsx)(P,{id:`host-displayName`,type:`text`,maxLength:64,className:`w-48`,placeholder:n.data?.hostname,defaultValue:e.data.displayName,onBlur:n=>{let r=n.target.value.trim();r!==e.data.displayName&&t.mutate({displayName:r},{onError:e=>F(e)})}})}),(0,q.jsx)($,{label:`Fetch interval (minutes)`,description:`Periodic git fetch for repos with active sessions.`,field:`fetchIntervalMinutes`,config:e.data,min:1}),(0,q.jsx)($,{label:`Log size cap (bytes)`,description:`Per-terminal on-disk log cap.`,field:`logMaxBytes`,config:e.data,min:65536,step:1048576}),(0,q.jsx)($,{label:`Replay size (bytes)`,description:`Log tail sent to a terminal on attach.`,field:`replayBytes`,config:e.data,min:1024,step:65536}),(0,q.jsx)($,{label:`UI-state retention (days)`,description:`Stale workspace snapshots are swept at boot.`,field:`uiStateRetentionDays`,config:e.data,min:1}),(0,q.jsx)(Y,{label:`Auto-resume`,description:`Resume interrupted sessions automatically after a daemon restart.`,htmlFor:`host-autoResume`,children:(0,q.jsx)(H,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>F(e)})})})]}):null}var Vt=[{id:`appearance`,label:`Appearance`,icon:ke,render:()=>(0,q.jsx)(nt,{})},{id:`profile`,label:`Profile`,icon:je,render:()=>(0,q.jsx)(at,{})},{id:`accounts`,label:`Accounts`,icon:tt,render:()=>(0,q.jsx)(ct,{})},{id:`sessions`,label:`Sessions`,icon:et,render:()=>(0,q.jsx)(ht,{})},{id:`editor`,label:`Editor`,icon:Ye,render:()=>(0,q.jsx)(bt,{})},{id:`hotkeys`,label:`Hotkeys`,icon:Xe,render:()=>(0,q.jsx)(St,{})},{id:`notifications`,label:`Notifications`,icon:Je,render:()=>(0,q.jsx)(yt,{})},{id:`projects`,label:`Projects`,icon:me,render:()=>(0,q.jsx)(zt,{})},{id:`host`,label:`Host`,icon:Qe,render:()=>(0,q.jsx)(Bt,{})},{id:`sync`,label:`Sync`,icon:Ce,render:()=>(0,q.jsx)(Lt,{})}],Ht={terminal:`sessions`,repositories:`projects`};function Ut(){let e=Le(),t=e===null?null:Ht[e]??e,n=Vt.find(e=>e.id===t)??Vt[0];return(0,q.jsx)(N,{open:e!==null,onOpenChange:e=>!e&&Be(),children:(0,q.jsxs)(A,{wide:!0,className:`grid h-[34rem] grid-cols-[14rem_1fr] gap-0 overflow-hidden p-0`,children:[(0,q.jsx)(j,{className:`sr-only`,children:`Settings`}),(0,q.jsxs)(`nav`,{className:`flex flex-col gap-1 bg-surface p-2.5 pr-6`,children:[(0,q.jsx)(`span`,{className:`px-2.5 py-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`Settings`}),Vt.map(({id:e,label:t,icon:r})=>(0,q.jsxs)(`button`,{onClick:()=>Re(e),className:i(`flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors`,e===n.id?`bg-elevated text-fg`:`text-fg-secondary hover:bg-elevated hover:text-fg`),children:[(0,q.jsx)(r,{className:`size-4 shrink-0`}),t]},e))]}),(0,q.jsx)(`div`,{className:`overflow-y-auto p-5`,children:n.render()})]})})}export{Ut as SettingsDialog};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n,n as r,r as i}from"./x-BJOrp_m5.js";import{$ as a,A as o,F as s,Ft as c,It as l,J as u,K as d,Mt as f,Nt as p,Pt as m,R as h,T as g,U as ee,V as _,Vt as v,W as te,X as ne,Z as y,a as b,at as x,et as S,f as C,ft as w,g as re,i as ie,it as T,jt as ae,k as oe,n as se,nt as ce,pt as le,st as ue,t as de,v as E,w as fe}from"./hotkeys-BApA7bsN.js";import{a as D,h as O,i as k,n as A,o as j,r as M,t as N}from"./dialog-DjL0qoAv.js";import{a as pe,c as P,i as F,l as I,o as me,r as he,s as ge}from"./LazyTerminal-CbtFuzQP.js";import{a as L,i as R,n as z,o as B,r as V,t as _e}from"./session-seed-DJUa6_Hr.js";import{t as ve}from"./chevron-down-59O6CgEo.js";import{r as ye}from"./dist-DDFe8e3m.js";import{$ as be,At as xe,Ct as Se,Dt as Ce,G as we,H as Te,Ht as Ee,J as De,K as Oe,Ot as ke,Q as Ae,R as H,Rt as je,St as Me,U as Ne,V as U,W as Pe,X as W,Y as G,_t as Fe,bt as Ie,et as Le,gt as Re,ht as ze,kt as Be,ot as Ve,q as He,r as Ue,rt as We,tt as Ge,wt as Ke,xt as qe}from"./index-DMiHDm9d.js";var Je=r(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),Ye=r(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Xe=r(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),Ze=r(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),Qe=r(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),$e=r(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),et=r(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),tt=r(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),K=e(t(),1),q=n();function J({id:e,value:t,min:n,max:r,step:i,className:a,onCommit:o}){let[s,c]=(0,K.useState)(String(t));return(0,K.useEffect)(()=>c(String(t)),[t]),(0,q.jsx)(P,{id:e,type:`number`,min:n,max:r,step:i,className:a,value:s,onChange:e=>c(e.target.value),onBlur:()=>{let e=Number(s);if(s.trim()===``||!Number.isFinite(e)){c(String(t));return}let i=Math.min(r??e,Math.max(n??e,e));c(String(i)),i!==t&&o(i)},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}function Y({label:e,description:t,descriptionClassName:n,htmlFor:r,children:a,className:o}){return(0,q.jsxs)(`div`,{className:i(`flex items-center gap-4 py-2.5`,o),children:[(0,q.jsxs)(`label`,{htmlFor:r,className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,q.jsx)(`span`,{className:`text-sm text-fg`,children:e}),t&&(0,q.jsx)(`span`,{className:i(`text-xs text-fg-muted`,n),children:t})]}),(0,q.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:a})]})}function X({children:e,note:t}){return(0,q.jsxs)(`div`,{className:`mb-2 flex flex-col gap-0.5`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e}),t&&(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t})]})}function nt(){let e=W(),[t,n]=(0,K.useState)(Ee());return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Appearance`}),(0,q.jsx)(Y,{label:`Theme`,children:(0,q.jsxs)(z,{value:t,onValueChange:e=>{n(e),je(e)},children:[(0,q.jsx)(L,{className:`w-32`,children:(0,q.jsx)(B,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(R,{value:`dark`,children:`Dark`}),(0,q.jsx)(R,{value:`light`,children:`Light`}),(0,q.jsx)(R,{value:`system`,children:`System`})]})]})}),(0,q.jsx)(Y,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,q.jsx)(J,{id:`ui-font-size`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onCommit:e=>G({uiFontSize:e})})}),(0,q.jsx)(Y,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,q.jsx)(J,{id:`terminal-font-size`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onCommit:e=>G({terminalFontSize:e})})}),(0,q.jsx)(Y,{label:`Editor font size`,htmlFor:`editor-font-size`,children:(0,q.jsx)(J,{id:`editor-font-size`,min:9,max:32,step:.5,className:`w-20 tabular-nums`,value:e.editorFontSize,onCommit:e=>G({editorFontSize:e})})}),(0,q.jsx)(Y,{label:`Density`,children:(0,q.jsxs)(z,{value:e.density,onValueChange:e=>G({density:e}),children:[(0,q.jsx)(L,{className:`w-36`,children:(0,q.jsx)(B,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(R,{value:`compact`,children:`Compact`}),(0,q.jsx)(R,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,q.jsx)(Y,{label:`Project-based layout`,description:`Editor layouts are separated across projects.`,htmlFor:`project-based-layout`,children:(0,q.jsx)(H,{id:`project-based-layout`,checked:e.projectBasedLayout,onCheckedChange:e=>G({projectBasedLayout:e})})}),(0,q.jsx)(Y,{label:`All projects in the session list`,description:`Right sidebar displays sessions from all projects.`,htmlFor:`show-all-project-sessions`,children:(0,q.jsx)(H,{id:`show-all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>G({showAllProjectSessions:e})})})]})}function rt({profile:e}){let t=a(),[n,r]=(0,K.useState)(!1),o=n=>{t.mutate({id:e.id,icon:n},{onError:e=>F(e)}),r(!1)},s=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>F(e)});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{label:`Icon`,children:(0,q.jsxs)(be,{open:n,onOpenChange:r,children:[(0,q.jsx)(Ge,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,className:`flex size-9 items-center justify-center rounded-md text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(Ie,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,q.jsx)(Le,{align:`end`,className:`w-72`,children:(0,q.jsxs)(`div`,{className:`grid grid-cols-8 gap-1`,children:[(0,q.jsx)(`button`,{type:`button`,title:`Default`,onClick:()=>o(null),className:i(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,!e.icon&&`bg-elevated text-fg`),children:(0,q.jsx)(Ie,{icon:null,colour:null,className:`size-4`})}),Me.map(({name:t,Icon:n})=>(0,q.jsx)(`button`,{type:`button`,title:t,onClick:()=>o(t),className:i(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,e.icon===t&&`bg-elevated text-fg`),children:(0,q.jsx)(n,{className:`size-4`})},t))]})})]})}),(0,q.jsx)(Y,{label:`Icon colour`,children:(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,q.jsxs)(`button`,{type:`button`,title:`Default`,onClick:()=>s(null),className:i(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,!e.icon_colour&&`bg-elevated`),children:[(0,q.jsx)(`span`,{className:`size-3.5 rounded-full bg-fg-muted`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Default colour`})]}),c.map(t=>(0,q.jsxs)(`button`,{type:`button`,title:t,onClick:()=>s(t),className:i(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,e.icon_colour===t&&`bg-elevated`),children:[(0,q.jsx)(`span`,{className:i(`size-3.5 rounded-full bg-current`,qe(t))}),(0,q.jsx)(`span`,{className:`sr-only`,children:t})]},t))]})})]})}var it=`__none__`;function at(){let e=E(),t=x().data?.find(t=>t.id===e),n=fe(e??void 0),r=T(e??void 0),i=a(),o=S(e??``),s=_(),[c,l]=(0,K.useState)(``),[u,d]=(0,K.useState)(``),[f,p]=(0,K.useState)(!1),[m,h]=(0,K.useState)(``);if((0,K.useEffect)(()=>{t&&(l(t.name),d(t.branch_prefix))},[t]),!t)return null;let g=r.data?.default_account_id;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Profile`}),(0,q.jsxs)(Y,{label:`Name`,description:`Letters, digits, dot, underscore and hyphen.`,htmlFor:`profile-name`,children:[(0,q.jsx)(P,{id:`profile-name`,value:c,onChange:e=>l(e.target.value),className:`w-44`}),(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:c===t.name||c.trim()===``||i.isPending,onClick:()=>i.mutate({id:t.id,name:c},{onError:e=>F(e)}),children:`Save`})]}),(0,q.jsxs)(Y,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,q.jsx)(P,{id:`branch-prefix`,value:u,onChange:e=>d(e.target.value),placeholder:`no prefix`,className:`w-44`}),(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:u===t.branch_prefix||i.isPending,onClick:()=>i.mutate({id:t.id,branch_prefix:u},{onError:e=>F(e)}),children:`Save`})]}),(0,q.jsx)(rt,{profile:t}),(0,q.jsx)(Y,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,q.jsxs)(z,{value:typeof g==`number`?String(g):it,onValueChange:e=>o.mutate({default_account_id:e===it?null:Number(e)},{onError:e=>F(e)}),children:[(0,q.jsx)(L,{className:`w-56`,children:(0,q.jsx)(B,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(R,{value:it,children:`First available`}),n.data?.map(e=>(0,q.jsx)(R,{value:String(e.id),children:(0,q.jsxs)(`span`,{children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,q.jsx)(Y,{label:`Delete profile`,description:`Non-archived sessions block deletion.`,className:`mt-4`,children:(0,q.jsx)(O,{variant:`danger`,size:`sm`,onClick:()=>p(!0),children:`Delete…`})}),(0,q.jsx)(N,{open:f,onOpenChange:e=>{e||(p(!1),h(``))},children:(0,q.jsxs)(A,{children:[(0,q.jsxs)(D,{children:[(0,q.jsxs)(j,{children:[`Delete profile `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),`?`]}),(0,q.jsx)(M,{children:`Everything this profile owns goes with it: projects, workspace layouts, accounts and their credential directories, and archived session history. Branches, repositories, and terminal logs on disk are untouched. This cannot be undone.`})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(ge,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),` to confirm`]}),(0,q.jsx)(P,{id:`delete-confirm-name`,value:m,onChange:e=>h(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(k,{children:[(0,q.jsx)(O,{variant:`ghost`,onClick:()=>{p(!1),h(``)},children:`Cancel`}),(0,q.jsx)(O,{variant:`danger`,disabled:m!==t.name||s.isPending,onClick:()=>s.mutate(t.id,{onSuccess:()=>{ze(),re.set(null)},onError:e=>{p(!1),h(``),F(e)}}),children:`Delete profile`})]})]})})]})}function ot({agent:e,profileId:t,onClose:n,onCreated:r}){let i=o(),[a,s]=(0,K.useState)(``),[c,l]=(0,K.useState)(``),u=ee(Ve(c,150)),d=c.trim(),f=d===``||d.startsWith(`/`)||d.startsWith(`~`),p=a.trim()!==``&&f,m=()=>{!p||i.isPending||i.mutate({profile_id:t,agent_type:e.id,label:a.trim(),...d===``?{}:{import_dir:d}},{onSuccess:e=>{n(),r(e,d!==``)},onError:e=>F(e)})};return(0,q.jsx)(N,{open:!0,onOpenChange:e=>!e&&n(),children:(0,q.jsxs)(A,{children:[(0,q.jsxs)(D,{children:[(0,q.jsxs)(j,{children:[`Add a `,e.display_name,` account`]}),(0,q.jsxs)(M,{children:[`Accounts are isolated config dirs under this profile. Naming one is enough — Puddle creates it and takes you straight to `,e.display_name,`’s login. To reuse an account you already have on this machine, give its config directory: it is copied in and the original is never touched.`]})]}),(0,q.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),m()},children:[(0,q.jsx)(P,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>s(e.target.value)}),(0,q.jsx)(he,{value:c,onValueChange:l,placeholder:`(optional) existing config dir, e.g. ~/.claude`,hints:(u.data?.entries??[]).map(e=>({value:e.path,label:e.name}))})]}),(0,q.jsxs)(k,{children:[(0,q.jsx)(O,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,q.jsxs)(O,{disabled:!p||i.isPending,onClick:m,children:[(0,q.jsx)(ke,{}),`Add account`]})]})]})})}function st({account:e,gateOpen:t,installed:n}){let r=u(),i=ne(),a=h(),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(!1),[d,f]=(0,K.useState)(e.label),p=(0,K.useRef)(null);return(0,K.useEffect)(()=>f(e.label),[e.label]),(0,q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md bg-surface px-3 py-2`,children:[(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(`input`,{ref:p,value:d,onChange:e=>f(e.target.value),onBlur:()=>{let t=d.trim();if(t!==e.label){if(t===``){f(e.label);return}i.mutate({id:e.id,label:t},{onError:t=>{F(t),f(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(f(e.label),t.currentTarget.blur())},"aria-label":`Account name`,className:`-mx-1 block w-full min-w-0 truncate rounded-sm bg-transparent px-1 py-0.5 text-sm text-fg transition-colors hover:bg-elevated focus:bg-elevated focus:outline-none`}),(0,q.jsxs)(`button`,{type:`button`,title:`Rename account`,onClick:()=>{p.current?.focus(),p.current?.select()},className:`shrink-0 rounded-sm p-0.5 text-fg-muted transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(pe,{className:`size-3`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Rename account`})]})]}),(0,q.jsx)(`span`,{className:`text-2xs ${e.logged_in?`text-success`:`text-warning`}`,children:e.logged_in?`logged in`:`not logged in`})]}),t&&(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-secondary`,children:[`skip prompts`,(0,q.jsx)(H,{checked:e.skip_permissions_default,onCheckedChange:t=>i.mutate({id:e.id,skip_permissions_default:t},{onError:e=>F(e)})})]}),(0,q.jsxs)(O,{size:`sm`,variant:`secondary`,disabled:r.isPending||!n,onClick:()=>r.mutate(e.id,{onSuccess:e=>s({stream:e.stream,hint:e.hint}),onError:e=>F(e)}),children:[(0,q.jsx)(xe,{}),e.logged_in?`Re-login`:`Login`]}),(0,q.jsxs)(O,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>l(!0),children:[(0,q.jsx)(Ke,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),o&&(0,q.jsx)(Ae,{stream:o.stream,hint:o.hint,label:`${e.agent_type}/${e.label}`,onClose:()=>s(null)}),(0,q.jsx)(N,{open:c,onOpenChange:l,children:(0,q.jsxs)(A,{children:[(0,q.jsxs)(D,{children:[(0,q.jsxs)(j,{children:[`Delete `,(0,q.jsx)(`span`,{className:`text-fg`,children:e.label}),`?`]}),(0,q.jsx)(M,{children:`Removes the account, its archived session history, and its credential directory — this logs the account out. Non-archived sessions block deletion.`})]}),(0,q.jsxs)(k,{children:[(0,q.jsx)(O,{variant:`ghost`,onClick:()=>l(!1),children:`Cancel`}),(0,q.jsx)(O,{variant:`danger`,disabled:a.isPending,onClick:()=>a.mutate(e.id,{onSuccess:()=>l(!1),onError:e=>{l(!1),F(e)}}),children:`Delete account`})]})]})})]})}function ct(){let e=E(),t=g(),n=fe(e??void 0),r=T(e??void 0),i=u(),[a,o]=(0,K.useState)(null),[s,c]=(0,K.useState)(null),l=r.data?.allowSkipPermissions===!0;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Accounts`}),t.data?.map(e=>{let t=n.data?.filter(t=>t.agent_type===e.id)??[],r=e.available!==!1;return(0,q.jsxs)(`div`,{className:`mb-5`,children:[(0,q.jsx)(Y,{label:e.display_name,description:r?`Accounts are initialised in config dirs owned by this profile.`:`No ${e.binary??e.id} on the daemon’s PATH. Install it or add its directory to the agent search path in Sessions.`,className:`py-1`,children:(0,q.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e.id})}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t.map(t=>(0,q.jsx)(st,{account:t,gateOpen:l&&e.capabilities.skip_permissions,installed:r},t.id)),(0,q.jsx)(`div`,{className:`flex`,children:(0,q.jsxs)(O,{type:`button`,size:`sm`,variant:`secondary`,disabled:!r,onClick:()=>c(e),children:[(0,q.jsx)(ke,{}),`Add account`]})})]})]},e.id)}),a&&(0,q.jsx)(Ae,{stream:a.stream,label:a.label,hint:a.hint,onClose:()=>o(null)}),s!==null&&e!==null&&(0,q.jsx)(ot,{agent:s,profileId:e,onClose:()=>c(null),onCreated:(e,t)=>{if(t){e.logged_in||v.info(`Imported without credentials — press Login to authenticate.`);return}i.mutate(e.id,{onSuccess:t=>o({stream:t.stream,label:`${e.agent_type}/${e.label}`,hint:t.hint}),onError:e=>F(e)})}})]})}function lt(){let e=oe(),t=y(),[n,r]=(0,K.useState)(``);return(0,K.useEffect)(()=>{e.data&&r(e.data.agentPath)},[e.data]),(0,q.jsx)(Y,{label:`Agent search path (host-wide)`,description:`Colon-separated dirs the daemon prepends to PATH; helps find agent CLIs like claude (e.g. ~/.local/bin).`,htmlFor:`agent-path`,children:(0,q.jsx)(P,{id:`agent-path`,type:`text`,className:`w-64 text-2xs`,value:n,onChange:e=>r(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function ut({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=_e(e,n),o=n.sessionDefaults??{},[s,c]=(0,K.useState)(a.baseBranch),l=t=>r({...o,[e]:{...o[e],...t}});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mb-1 mt-4 text-xs font-medium uppercase tracking-wide text-fg-gold`,children:t}),(0,q.jsx)(Y,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,q.jsx)(P,{id:`${e}-default-base`,type:`text`,placeholder:`repository default`,className:`w-48`,value:s,onChange:e=>c(e.target.value),onBlur:()=>{s.trim()!==a.baseBranch&&l({baseBranch:s.trim()})}})}),(0,q.jsx)(Y,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,q.jsx)(H,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,q.jsx)(Y,{label:`Separate directory`,description:a.separateBranch?`Always on while a separate branch is used.`:`Start on working copy of the selected branch instead of sharing one directory.`,htmlFor:`${e}-default-dir`,children:(0,q.jsx)(H,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function dt(){return(0,q.jsx)(Y,{label:`Terminal scrollback`,htmlFor:`scrollback`,children:(0,q.jsx)(J,{id:`scrollback`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:W().terminalScrollback,onCommit:e=>G({terminalScrollback:e})})})}function ft({id:e,label:t,description:n,initial:r,defaultText:i,onSave:a,pending:o}){let[s,c]=(0,K.useState)(r);return(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:e,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[t,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n})]}),(0,q.jsx)(I,{id:e,value:s,onChange:e=>c(e.target.value),rows:6,className:`font-mono`}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,q.jsx)(O,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var pt={id:`4f3c2b1a-7e6d-5c4b-3a2f-1e0d9c8b7a6f`,title:null,agent_title:`Refactor the auth flow`,osc_title:`claude`,branch:`alice/refactor-auth`,worktree_path:`/home/alice/code/app--refactor-auth`,status:`waiting_input`,agent_type:`claude-code`};function mt({initial:e,onSave:t,pending:n}){let[r,i]=(0,K.useState)(e),a=r.length>0?r:m;return(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:`tab-title-template`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Template`,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Compose the label from the parts below. Empty falls back to the default.`})]}),(0,q.jsx)(P,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:m}),(0,q.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,q.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:We(pt,a)})]}),(0,q.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:l.map(([e,t])=>(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`dt`,{className:`w-24 shrink-0 font-mono text-fg-secondary`,children:`\${${e}}`}),(0,q.jsx)(`dd`,{className:`text-fg-muted`,children:t})]},e))}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,q.jsx)(O,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(m),t(m)},children:`Reset to default`})]})]})}function ht(){let e=E(),t=x().data?.find(t=>t.id===e),n=T(e??void 0),r=S(e??``),[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(``),c=n.data?.allowSkipPermissions===!0,l=e=>r.mutate({allowSkipPermissions:e},{onSuccess:()=>{a(!1),s(``)},onError:e=>F(e)}),u=e=>t=>r.mutate({[e]:t},{onError:e=>F(e)});return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Sessions`}),(0,q.jsx)(Y,{label:`Skip permission prompts`,htmlFor:`gate`,children:(0,q.jsx)(H,{id:`gate`,checked:c,onCheckedChange:e=>{e?a(!0):l(!1)}})}),(0,q.jsx)(Y,{label:`Capture exported env variables`,description:n.data?.captureSessionEnv===!1?`No variables are captured or injected; already-captured variabless are kept for when this is re-enabled.`:`Variables exported in a session persist and are re-injected upon terminal and agent restarts.`,htmlFor:`capture-env`,children:(0,q.jsx)(H,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:r.isPending,onCheckedChange:e=>r.mutate({captureSessionEnv:e},{onError:e=>F(e)})})}),(0,q.jsx)(lt,{}),(0,q.jsx)(dt,{}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{children:`New session defaults`}),n.data&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(ut,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>F(e)}),pending:r.isPending},`${e}:agent-seed`),(0,q.jsx)(ut,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>F(e)}),pending:r.isPending},`${e}:terminal-seed`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{note:`Sent to agent as opening message when a session (re)starts. You can make this empty.`,children:`Launch text`}),n.data&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(ft,{id:`onboarding-template`,label:`New worktree`,description:`Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??f,defaultText:f,onSave:u(`onboardingTemplate`),pending:r.isPending},`${e}:onboarding`),(0,q.jsx)(ft,{id:`concurrent-template`,label:`Existing / shared worktree`,description:`For a session joining a worktree other agents may already be working in.`,initial:n.data.concurrentTemplate??ae,defaultText:ae,onSave:u(`concurrentTemplate`),pending:r.isPending},`${e}:concurrent`),(0,q.jsx)(ft,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot.`,initial:n.data.restartTemplate??p,defaultText:p,onSave:u(`restartTemplate`),pending:r.isPending},`${e}:restart`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{children:`Tab title`}),n.data&&(0,q.jsx)(mt,{initial:n.data.tabTitleTemplate||"${name}",onSave:u(`tabTitleTemplate`),pending:r.isPending},`${e}:tab-title`)]}),(0,q.jsx)(N,{open:i,onOpenChange:e=>{e||(a(!1),s(``))},children:(0,q.jsxs)(A,{children:[(0,q.jsxs)(D,{children:[(0,q.jsxs)(j,{className:`flex items-center gap-2`,children:[(0,q.jsx)($e,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,q.jsx)(M,{asChild:!0,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,q.jsx)(`p`,{children:`A prompt-free agent acts unattended, with your credentials, inside its worktree — and nothing technically stops a shell command from reaching outside it. It can:`}),(0,q.jsxs)(`ul`,{className:`list-disc pl-5 text-fg-secondary`,children:[(0,q.jsx)(`li`,{children:`run any shell command without asking first,`}),(0,q.jsx)(`li`,{children:`modify, delete, or exfiltrate files your user can reach,`}),(0,q.jsx)(`li`,{children:`install dependencies and execute the network requests they make,`}),(0,q.jsx)(`li`,{children:`push branches or call remote APIs with the credentials it finds.`})]}),(0,q.jsx)(`p`,{children:`Only open this gate if every account you opt in runs work you would trust a colleague to run unsupervised on this machine.`}),(0,q.jsx)(`p`,{className:`text-fg-muted`,children:`Opening it also records the agent’s own bypass-permissions acceptance for this profile’s accounts, so the skip actually takes effect.`})]})})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(ge,{htmlFor:`confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t?.name}),` to confirm`]}),(0,q.jsx)(P,{id:`confirm-name`,value:o,onChange:e=>s(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(k,{children:[(0,q.jsx)(O,{variant:`ghost`,onClick:()=>{a(!1),s(``)},children:`Cancel`}),(0,q.jsx)(O,{variant:`danger`,disabled:o!==t?.name||r.isPending,onClick:()=>l(!0),children:`Open the gate`})]})]})})]})}var gt={desktop:!0,sound:!1,muted_projects:[]};function _t(){let[e,t]=(0,K.useState)(U);return(0,K.useEffect)(()=>{let e=()=>t(U());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(U())]}function vt({permission:e,onRequest:t}){return e===`granted`?null:(0,q.jsxs)(`p`,{className:`pb-2 text-xs text-warning`,children:[e==="default"&&(0,q.jsxs)(q.Fragment,{children:[`The browser has not been asked for permission yet, so nothing will show —`,` `,(0,q.jsx)(`button`,{type:`button`,onClick:t,className:`underline underline-offset-2 transition-colors hover:text-fg`,children:`request it now`}),`.`]}),e===`denied`&&`Blocked by the browser — allow notifications for this site in its site settings, then return here.`,e===`unsupported`&&`This browser cannot show desktop notifications.`]})}function yt(){let e=E(),t=T(e??void 0),n=S(e??``),r=ue(e??void 0),[i,a]=_t(),o={...gt,...t.data?.notifications??{}},s=e=>n.mutate({notifications:e},{onError:e=>F(e)}),c=()=>{typeof Notification>`u`||Notification.requestPermission().then(a)};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Notifications`}),(0,q.jsx)(Y,{label:`Desktop notification on waiting`,htmlFor:`notify-desktop`,children:(0,q.jsx)(H,{id:`notify-desktop`,checked:o.desktop,onCheckedChange:e=>{e&&c(),s({...o,desktop:e})}})}),o.desktop&&(0,q.jsx)(vt,{permission:i,onRequest:c}),(0,q.jsx)(Y,{label:`Sound`,htmlFor:`notify-sound`,children:(0,q.jsx)(H,{id:`notify-sound`,checked:o.sound,onCheckedChange:e=>s({...o,sound:e})})}),(0,q.jsx)(Y,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,q.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[o.muted_projects.length,` muted`]})}),(0,q.jsx)(`div`,{className:`flex flex-col gap-1`,children:r.data?.map(e=>(0,q.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-secondary hover:bg-elevated`,children:[(0,q.jsx)(H,{checked:o.muted_projects.includes(e.id),onCheckedChange:t=>s({...o,muted_projects:t?[...o.muted_projects,e.id]:o.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function bt(){let e=W();return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Editor`}),(0,q.jsx)(Y,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,q.jsx)(J,{id:`tab-size`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onCommit:e=>G({editorTabSize:e})})}),(0,q.jsx)(Y,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,q.jsx)(H,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>G({editorWordWrap:e})})}),(0,q.jsx)(Y,{label:`SSH host for editor links`,description:`Used for vscode:// and cursor:// remote links until the CLI supplies it automatically.`,htmlFor:`editor-link-host`,children:(0,q.jsx)(P,{id:`editor-link-host`,type:`text`,placeholder:Ue.get()??`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>G({editorLinkSshHost:e.target.value})})})]})}function xt({value:e,isDefault:t,onRecord:n,onReset:r}){let[a,o]=(0,K.useState)(!1);return(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>o(!0),onBlur:()=>o(!1),onKeyDown:e=>{if(!a)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){o(!1);return}let t=ie(e.nativeEvent);t&&(n(t),o(!1))},className:i(`min-w-24 rounded-md px-2 py-1 text-center font-mono text-xs transition-colors`,a?`bg-action text-action-ink`:`bg-elevated text-fg hover:bg-border/70`),children:a?`Press keys…`:b(e)}),!t&&(0,q.jsxs)(`button`,{type:`button`,title:`Reset to default`,onClick:r,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(Ze,{className:`size-3.5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function St(){let e=E(),t=T(e??void 0),n=S(e??``),r=t.data?.hotkeys??{},i=(e,t)=>r[e]||t,a=new Map;for(let e of de){let t=i(e.id,C(e));a.set(t,(a.get(t)??0)+1)}let o=(e,t)=>n.mutate({hotkeys:{...r,[e]:t}},{onError:e=>F(e)}),s=e=>{let t={...r};delete t[e],n.mutate({hotkeys:t},{onError:e=>F(e)})};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Hotkeys`}),(0,q.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:`Per-profile keyboard shortcuts. Filetree navigation and terminal line-edits are fixed.`}),(0,q.jsx)(Y,{label:`App shortcuts in terminals`,description:t.data?.terminalAppShortcuts===!1?`A focused terminal receives these keys instead.`:`The shortcuts below work while a terminal is focused.`,htmlFor:`terminal-app-shortcuts`,className:`mb-4`,children:(0,q.jsx)(H,{id:`terminal-app-shortcuts`,checked:t.data?.terminalAppShortcuts!==!1,disabled:n.isPending,onCheckedChange:e=>n.mutate({terminalAppShortcuts:e},{onError:e=>F(e)})})}),se.map(e=>{let t=de.filter(t=>t.group===e);return t.length===0?null:(0,q.jsxs)(`div`,{className:`mb-5`,children:[(0,q.jsx)(`div`,{className:`mb-1 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:e}),t.map(e=>{let t=i(e.id,C(e)),n=(a.get(t)??0)>1?`Conflicts with another shortcut.`:void 0;return(0,q.jsx)(Y,{label:e.label,description:n,descriptionClassName:n?`text-interrupted`:void 0,children:(0,q.jsx)(xt,{value:t,isDefault:!r[e.id],onRecord:t=>o(e.id,t),onReset:()=>s(e.id)})},e.id)})]},e)})]})}var Ct=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,Z=65,Q=Object.fromEntries([...Ct].map((e,t)=>[e,t])),wt=`H`,Tt=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t+=1){let n=t;for(let e=0;e<8;e+=1)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function Et(e){let t=4294967295;for(let n of e)t=Tt[(t^n)&255]^t>>>8;return((t^4294967295)>>>0).toString(16).padStart(8,`0`)}function Dt(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function Ot(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}async function kt(e){let t=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}async function At(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Response(t).text()}function jt(e,t){let n=(t%Z+Z)%Z,r=``;for(let t of e){let e=Q[t];r+=e===void 0?t:Ct[(e+n)%Z]}return r}async function Mt(e){let t=await kt(JSON.stringify(e));return jt(Dt(t)+Et(t),1+Math.floor(Math.random()*(Z-1)))}async function Nt(e){let t=e.trim(),n=t[0];if(!n||Q[n]===void 0)throw Error(`Not a settings export.`);let r=jt(t,-((Q[n]-Q[wt]+Z)%Z));if(r.length<9||r[0]!==wt)throw Error(`Not a settings export.`);let i=r.slice(0,-8),a=r.slice(-8),o=Ot(i);if(Et(o)!==a)throw Error(`Settings export is corrupt (checksum mismatch).`);return JSON.parse(await At(o))}var Pt=`puddle.sync-selection`;function Ft(){try{let e=JSON.parse(localStorage.getItem(Pt)??`null`);if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}catch{}return we.map(e=>e.id)}function It({selected:e,onToggle:t}){return(0,q.jsx)(`div`,{className:`flex flex-col gap-2 pl-1`,children:we.map(n=>(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(H,{checked:e.includes(n.id),onCheckedChange:e=>t(n.id,e)}),n.label]},n.id))})}function Lt(){let e=E(),t=T(e??void 0),n=x().data?.find(t=>t.id===e),r=le(e??void 0,void 0),i=S(e??``),o=a(),c=s(),l=Ne(),u=Pe(),[d,f]=(0,K.useState)(``),[p,m]=(0,K.useState)(``),[h,g]=(0,K.useState)(!1),[ee,_]=(0,K.useState)(!1),[te,ne]=(0,K.useState)(Ft),y=n&&l.data?Te(l.data.file,n.name):void 0,b=y?.enabled===!0,C=b&&y?y.groups:te,w=()=>({client:De(),theme:Ee(),profileSettings:t.data??{},profile:n??{},scratchpad:r.data??[]}),re={setClient:e=>G(e),setTheme:e=>{typeof e==`string`&&je(e)},patchProfileSettings:e=>i.mutate(e,{onError:e=>F(e)}),patchProfileColumns:t=>{e&&o.mutate({id:e,...t},{onError:e=>F(e)})},createScratchpad:t=>{if(e)for(let n of t)c.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},ie=(e,t)=>{n&&u.mutate({profile:n.name,entry:{enabled:e.enabled??b,groups:t,doc:He(t,w()),updatedAt:new Date().toISOString()}},{onError:e=>F(e)})},ae=(e,t)=>{let n=t?[...C,e]:C.filter(t=>t!==e);ne(n),localStorage.setItem(Pt,JSON.stringify(n)),b&&ie({},n)},oe=async()=>{_(!0);try{let e=Oe(await Nt(d.trim()),re,{profileSettings:t.data??{},scratchpad:r.data??[]});e.length===0?v.error(`Nothing recognised to import.`):(v.success(`Imported ${e.join(`, `)}.`),f(``))}catch(e){v.error(e.message)}finally{_(!1)}},se=async()=>{_(!0);try{let e=await Mt(He(C,w()));m(e),await navigator.clipboard?.writeText(e),v.success(`Copied to clipboard`)}finally{_(!1)}};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Sync`}),(0,q.jsx)(`p`,{className:`mb-5 text-xs text-fg-muted`,children:`Carry your settings between machines. Accounts, repositories, and anything host-specific are never included. Applies to this profile.`}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Sync locally`}),l.data?.available===!1?(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:`Not available in this cockpit — start the UI with the Puddle CLI to sync across windows.`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:[`Sync selected groups through this machine’s`,` `,(0,q.jsx)(`span`,{className:`text-fg-secondary`,children:`~/.puddle`}),`, so every Puddle window stays in step for profiles named`,` `,(0,q.jsx)(`span`,{className:`text-fg-secondary`,children:n?.name??`…`}),`.`]}),(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(H,{checked:b,disabled:!n||l.isLoading||u.isPending,onCheckedChange:e=>ie({enabled:e},C)}),`Sync locally`]})]})]}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>g(e=>!e),className:`flex items-center gap-1 text-xs text-fg-secondary transition-colors hover:text-fg`,children:[h?(0,q.jsx)(ve,{className:`size-3.5`}):(0,q.jsx)(ye,{className:`size-3.5`}),`Choose what to sync`]}),h&&(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(It,{selected:C,onToggle:ae})})]}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Export`}),(0,q.jsx)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:`Builds a Puddle magic string that encodes settings from the checklist above.`}),(0,q.jsx)(O,{size:`sm`,disabled:ee,onClick:()=>void se(),children:`Export & copy`}),p&&(0,q.jsx)(I,{readOnly:!0,value:p,rows:3,spellCheck:!1,onFocus:e=>e.currentTarget.select(),className:`mt-2 resize-y font-mono text-xs`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Import`}),(0,q.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:`Paste a Puddle magic string to import its settings.`}),(0,q.jsx)(I,{value:d,onChange:e=>f(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:`Paste a settings export…`,rows:3,spellCheck:!1,className:`resize-y font-mono text-xs`}),(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(O,{size:`sm`,disabled:!d.trim()||ee,onClick:()=>void oe(),children:`Import`})})]})]})}function Rt({repo:e}){let t=ce(),n=te(),[r,i]=(0,K.useState)(e.default_base_branch),[a,o]=(0,K.useState)(e.onboarding_notes??``),s=e=>F(e);return(0,q.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface p-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.path}),(0,q.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted tabular-nums`,children:e.last_fetched_at?`fetched ${new Date(e.last_fetched_at).toLocaleString()}`:`never fetched`}),(0,q.jsxs)(O,{size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:()=>v.success(`Fetched.`),onError:s}),children:[(0,q.jsx)(Ce,{}),`Fetch now`]})]}),(0,q.jsxs)(Y,{label:`Default base branch`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,q.jsx)(P,{id:`base-${e.id}`,value:r,onChange:e=>i(e.target.value),className:`w-40`}),(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:r===e.default_base_branch||t.isPending,onClick:()=>t.mutate({id:e.id,default_base_branch:r},{onError:s}),children:`Save`})]}),(0,q.jsx)(Y,{label:`Periodic fetch`,description:`Fetched on open and on the daemon's interval while sessions are active.`,htmlFor:`fetch-${e.id}`,className:`py-1.5`,children:(0,q.jsx)(H,{id:`fetch-${e.id}`,checked:e.fetch_enabled,onCheckedChange:n=>t.mutate({id:e.id,fetch_enabled:n},{onError:s})})}),(0,q.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:`notes-${e.id}`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Onboarding notes`,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Standing setup rules, injected into every fresh worktree. Agents update them via .puddle/onboarding-notes.md.`})]}),(0,q.jsx)(I,{id:`notes-${e.id}`,value:a,onChange:e=>o(e.target.value),rows:4}),(0,q.jsx)(`div`,{children:(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:a===(e.onboarding_notes??``)||t.isPending,onClick:()=>t.mutate({id:e.id,onboarding_notes:a},{onError:s}),children:`Save notes`})})]}),e.orphan_worktrees.length>0&&(0,q.jsxs)(`div`,{className:`mt-3 rounded-md bg-elevated p-2`,children:[(0,q.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:`Orphan worktrees — directories no session claims. Puddle never deletes these automatically; remove them by hand if unwanted.`}),(0,q.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.orphan_worktrees.map(e=>(0,q.jsx)(`li`,{className:`truncate text-2xs text-fg-muted`,children:e},e))})]})]})}function zt(){let e=w();return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Projects`}),e.data?.length===0&&(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No projects yet — create one from the dashboard, pointing at a repository.`}),e.data?.map(e=>(0,q.jsx)(Rt,{repo:e},e.id))]})}function $({label:e,description:t,field:n,config:r,min:i,step:a=1}){let o=y();return(0,q.jsx)(Y,{label:e,description:t,htmlFor:`host-${n}`,children:(0,q.jsx)(P,{id:`host-${n}`,type:`number`,min:i,step:a,className:`w-32 tabular-nums`,defaultValue:r[n],onBlur:e=>{if(e.target.value.trim()===``){e.target.value=String(r[n]);return}let t=Number(e.target.value);Number.isFinite(t)&&t!==r[n]&&o.mutate({[n]:t},{onError:e=>F(e)})}})})}function Bt(){let e=oe(),t=y(),n=d();return e.data?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{note:`Affects all profiles on this host`,children:`Host`}),(0,q.jsx)(Y,{label:`Display name`,description:`Shown in place of the hostname across the UI. Leave blank for the hostname.`,htmlFor:`host-displayName`,children:(0,q.jsx)(P,{id:`host-displayName`,type:`text`,maxLength:64,className:`w-48`,placeholder:n.data?.hostname,defaultValue:e.data.displayName,onBlur:n=>{let r=n.target.value.trim();r!==e.data.displayName&&t.mutate({displayName:r},{onError:e=>F(e)})}})}),(0,q.jsx)($,{label:`Fetch interval (minutes)`,description:`Periodic git fetch for repos with active sessions.`,field:`fetchIntervalMinutes`,config:e.data,min:1}),(0,q.jsx)($,{label:`Log size cap (bytes)`,description:`Per-terminal on-disk log cap.`,field:`logMaxBytes`,config:e.data,min:65536,step:1048576}),(0,q.jsx)($,{label:`Replay size (bytes)`,description:`Log tail sent to a terminal on attach.`,field:`replayBytes`,config:e.data,min:1024,step:65536}),(0,q.jsx)($,{label:`UI-state retention (days)`,description:`Stale workspace snapshots are swept at boot.`,field:`uiStateRetentionDays`,config:e.data,min:1}),(0,q.jsx)(Y,{label:`Auto-resume`,description:`Resume interrupted sessions automatically after a daemon restart.`,htmlFor:`host-autoResume`,children:(0,q.jsx)(H,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>F(e)})})})]}):null}var Vt=[{id:`appearance`,label:`Appearance`,icon:Be,render:()=>(0,q.jsx)(nt,{})},{id:`profile`,label:`Profile`,icon:Se,render:()=>(0,q.jsx)(at,{})},{id:`accounts`,label:`Accounts`,icon:tt,render:()=>(0,q.jsx)(ct,{})},{id:`sessions`,label:`Sessions`,icon:et,render:()=>(0,q.jsx)(ht,{})},{id:`editor`,label:`Editor`,icon:Ye,render:()=>(0,q.jsx)(bt,{})},{id:`hotkeys`,label:`Hotkeys`,icon:Xe,render:()=>(0,q.jsx)(St,{})},{id:`notifications`,label:`Notifications`,icon:Je,render:()=>(0,q.jsx)(yt,{})},{id:`projects`,label:`Projects`,icon:me,render:()=>(0,q.jsx)(zt,{})},{id:`host`,label:`Host`,icon:Qe,render:()=>(0,q.jsx)(Bt,{})},{id:`sync`,label:`Sync`,icon:Ce,render:()=>(0,q.jsx)(Lt,{})}],Ht={terminal:`sessions`,repositories:`projects`};function Ut(){let e=Fe(),t=e===null?null:Ht[e]??e,n=Vt.find(e=>e.id===t)??Vt[0];return(0,q.jsx)(N,{open:e!==null,onOpenChange:e=>!e&&ze(),children:(0,q.jsxs)(A,{wide:!0,className:`grid h-[34rem] grid-cols-[14rem_1fr] gap-0 overflow-hidden p-0`,children:[(0,q.jsx)(j,{className:`sr-only`,children:`Settings`}),(0,q.jsxs)(`nav`,{className:`flex flex-col gap-1 bg-surface p-2.5 pr-6`,children:[(0,q.jsx)(`span`,{className:`px-2.5 py-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`Settings`}),Vt.map(({id:e,label:t,icon:r})=>(0,q.jsxs)(`button`,{onClick:()=>Re(e),className:i(`flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors`,e===n.id?`bg-elevated text-fg`:`text-fg-secondary hover:bg-elevated hover:text-fg`),children:[(0,q.jsx)(r,{className:`size-4 shrink-0`}),t]},e))]}),(0,q.jsx)(`div`,{className:`overflow-y-auto p-5`,children:n.render()})]})})}export{Ut as SettingsDialog};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n,r}from"./x-BJOrp_m5.js";import{Et as i,L as a,Rt as o,Vt as s,i as c,it as l,o as u,r as d,s as f,v as p,xt as m}from"./hotkeys-uS50-PkH.js";import{i as h,n as g}from"./file-links-Cv4u-85W.js";import{i as _,n as v,o as ee,r as te,t as ne}from"./use-find-controls-XCU2T3Mk.js";import{Bt as re,Ht as ie,Rt as ae,X as oe,lt as se,ut as y}from"./index-V87RMkBD.js";var b=e(t(),1),x=Object.defineProperty,S=Object.getOwnPropertyDescriptor,ce=(e,t)=>{for(var n in t)x(e,n,{get:t[n],enumerable:!0})},C=(e,t,n,r)=>{for(var i=r>1?void 0:r?S(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&x(t,n,i),i},w=(e,t)=>(n,r)=>t(n,r,e),le=`Terminal input`,ue={get:()=>le,set:e=>le=e},de=`Too much output to announce, navigate to rows manually to read`,fe={get:()=>de,set:e=>de=e};function pe(e){return e.replace(/\r?\n/g,`\r`)}function T(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function me(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function he(e,t,n,r){e.stopPropagation(),e.clipboardData&&ge(e.clipboardData.getData(`text/plain`),t,n,r)}function ge(e,t,n,r){e=pe(e),e=T(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function E(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function D(e,t,n,r,i){E(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function _e(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function ve(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var ye=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},be=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},xe=``,Se=` `,Ce=class e{constructor(){this.fg=0,this.bg=0,this.extended=new we}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},we=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Te=class e extends Ce{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new we,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?_e(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Ee=`di$target`,De=`di$dependencies`,Oe=new Map;function ke(e){return e[De]||[]}function O(e){if(Oe.has(e))return Oe.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Ae(t,e,r)};return t._id=e,Oe.set(e,t),t}function Ae(e,t,n){t[Ee]===t?t[De].push({id:e,index:n}):(t[De]=[{id:e,index:n}],t[Ee]=t)}var k=O(`BufferService`),je=O(`CoreMouseService`),Me=O(`CoreService`),Ne=O(`CharsetService`),Pe=O(`InstantiationService`),Fe=O(`LogService`),A=O(`OptionsService`),Ie=O(`OscLinkService`),Le=O(`UnicodeService`),Re=O(`DecorationService`),ze=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new Te,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Be(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};ze=C([w(0,k),w(1,A),w(2,Ie)],ze);function Be(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n,r}from"./x-BJOrp_m5.js";import{Et as i,L as a,Rt as o,Vt as s,i as c,it as l,o as u,r as d,s as f,v as p,xt as m}from"./hotkeys-BApA7bsN.js";import{i as h,n as g}from"./file-links-BUb_sQYr.js";import{i as _,n as v,o as ee,r as te,t as ne}from"./use-find-controls-BiId78Q6.js";import{Ut as re,Vt as ie,X as ae,dt as oe,lt as se,zt as y}from"./index-DMiHDm9d.js";var b=e(t(),1),x=Object.defineProperty,S=Object.getOwnPropertyDescriptor,ce=(e,t)=>{for(var n in t)x(e,n,{get:t[n],enumerable:!0})},C=(e,t,n,r)=>{for(var i=r>1?void 0:r?S(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&x(t,n,i),i},w=(e,t)=>(n,r)=>t(n,r,e),le=`Terminal input`,ue={get:()=>le,set:e=>le=e},de=`Too much output to announce, navigate to rows manually to read`,fe={get:()=>de,set:e=>de=e};function pe(e){return e.replace(/\r?\n/g,`\r`)}function T(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function me(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function he(e,t,n,r){e.stopPropagation(),e.clipboardData&&ge(e.clipboardData.getData(`text/plain`),t,n,r)}function ge(e,t,n,r){e=pe(e),e=T(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function E(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function D(e,t,n,r,i){E(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function _e(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function ve(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var ye=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},be=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},xe=``,Se=` `,Ce=class e{constructor(){this.fg=0,this.bg=0,this.extended=new we}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},we=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Te=class e extends Ce{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new we,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?_e(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Ee=`di$target`,De=`di$dependencies`,Oe=new Map;function ke(e){return e[De]||[]}function O(e){if(Oe.has(e))return Oe.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Ae(t,e,r)};return t._id=e,Oe.set(e,t),t}function Ae(e,t,n){t[Ee]===t?t[De].push({id:e,index:n}):(t[De]=[{id:e,index:n}],t[Ee]=t)}var k=O(`BufferService`),je=O(`CoreMouseService`),Me=O(`CoreService`),Ne=O(`CharsetService`),Pe=O(`InstantiationService`),Fe=O(`LogService`),A=O(`OptionsService`),Ie=O(`OscLinkService`),Le=O(`UnicodeService`),Re=O(`DecorationService`),ze=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new Te,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Be(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};ze=C([w(0,k),w(1,A),w(2,Ie)],ze);function Be(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
2
2
|
|
|
3
3
|
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var Ve=O(`CharSizeService`),He=O(`CoreBrowserService`),Ue=O(`MouseService`),We=O(`RenderService`),Ge=O(`SelectionService`),Ke=O(`CharacterJoinerService`),qe=O(`ThemeService`),Je=O(`LinkProviderService`),Ye=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?tt.isErrorNoTelemetry(e)?new tt(e.message+`
|
|
4
4
|
|
|
@@ -57,4 +57,4 @@ ${s.join(`
|
|
|
57
57
|
`).slice(2).join(`
|
|
58
58
|
`))}},Lc=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},Rc=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},zc=0,Bc=class{constructor(e){this.value=e,this.id=zc++}},Vc=2,Hc,Uc=class{constructor(e){this._size=0,this._options=e,this._leakageMon=Nc>0||this._options?.leakWarningThreshold?new Fc(e?.onListenerError??ec,this._options?.leakWarningThreshold??Nc):void 0,this._perfMon=this._options?._profName?new Mc(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new Rc(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||ec)(n),Tc.None}if(this._disposed)return Tc.None;t&&(e=e.bind(t));let r=new Bc(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Ic.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Bc?(this._deliveryQueue??=new Wc,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=Sc(()=>{Hc?.unregister(a),i?.(),this._removeListener(r)});if(n instanceof wc?n.add(a):Array.isArray(n)&&n.push(a),Hc){let e=Error().stack.split(`
|
|
59
59
|
`).slice(2,3).join(`
|
|
60
|
-
`).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);Hc.register(a,t?.[2]??e,a)}return a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*Vc<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||ec;if(!n){e.value(t);return}try{e.value(t)}catch(e){n(e)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof Bc)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},Wc=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Gc=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),Kc;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof qc?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ac.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Gc})})(Kc||={});var qc=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Gc:(this._emitter||=new Uc,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},Jc=`en`,Yc=!1,Xc=!1,Zc=Jc,Qc,$c=globalThis,el;typeof $c.vscode<`u`&&typeof $c.vscode.process<`u`?el=$c.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(el=process);var tl=typeof el?.versions?.electron==`string`&&el?.type===`renderer`;if(typeof el==`object`){el.platform,el.platform,Yc=el.platform===`linux`,Yc&&el.env.SNAP&&el.env.SNAP_REVISION,el.env.CI||el.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Zc=Jc;let e=el.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,Zc=t.resolvedLanguage||Jc,t.languagePack?.translationsConfigFile}catch{}}else typeof navigator==`object`&&!tl?(Qc=navigator.userAgent,Qc.indexOf(`Windows`),Qc.indexOf(`Macintosh`),(Qc.indexOf(`Macintosh`)>=0||Qc.indexOf(`iPad`)>=0||Qc.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,Yc=Qc.indexOf(`Linux`)>=0,Qc?.indexOf(`Mobi`),Xc=!0,Zc=globalThis._VSCODE_NLS_LANGUAGE||Jc,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);Xc&&typeof $c.importScripts==`function`&&$c.origin;var nl=Qc,rl=Zc,il;(e=>{function t(){return rl}e.value=t;function n(){return rl.length===2?rl===`en`:rl.length>=3&&rl[0]===`e`&&rl[1]===`n`&&rl[2]===`-`}e.isDefaultVariant=n;function r(){return rl===`en`}e.isDefault=r})(il||={});var al=typeof $c.postMessage==`function`&&!$c.importScripts;(()=>{if(al){let e=[];$c.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),$c.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var ol=!!(nl&&nl.indexOf(`Chrome`)>=0);nl&&nl.indexOf(`Firefox`),!ol&&nl&&nl.indexOf(`Safari`),nl&&nl.indexOf(`Edg/`),nl&&nl.indexOf(`Android`);function sl(e,t=0,n){let r=setTimeout(()=>{e(),n&&i.dispose()},t),i=Sc(()=>{clearTimeout(r),n?.deleteAndLeak(i)});return n?.add(i),i}(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var cl;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(cl||={});var ll=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new Uc,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await Ac.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};ll.EMPTY=ll.fromArray([]);var ul=class extends Tc{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new Ec),this._linesCacheDisposables=this._register(new Ec),this._register(Sc(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=xc(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=sl(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){return this._linesCache?.[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){let n=[],r=[0],i=this._terminal.buffer.active.getLine(e);for(;i;){let a=this._terminal.buffer.active.getLine(e+1),o=a?a.isWrapped:!1,s=i.translateToString(!o&&t);if(o&&a){let e=i.getCell(i.length-1);e&&e.getCode()===0&&e.getWidth()===1&&a.getCell(0)?.getWidth()===2&&(s=s.slice(0,-1))}if(n.push(s),o)r.push(r[r.length-1]+s.length);else break;e++,i=a}return[n.join(``),r]}},dl=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return this._lastSearchOptions?e?this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord:!1:!0}shouldUpdateHighlighting(e,t){return t?.decorations?this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||this.didOptionsChange(t):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},fl=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,n,r){if(!e||e.length===0){this._terminal.clearSelection();return}if(n>this._terminal.cols)throw Error(`Invalid col: ${n} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let i={startRow:t,startCol:n},a=this._findInLine(e,i,r);if(!a)for(let n=t+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(i.startRow=n,i.startCol=0,a=this._findInLine(e,i,r),!a);n++);return a}findNextWithSelection(e,t,n){if(!e||e.length===0){this._terminal.clearSelection();return}let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let i=0,a=0;r&&(n===e?(i=r.end.x,a=r.end.y):(i=r.start.x,a=r.start.y)),this._lineCache.initLinesCache();let o={startRow:a,startCol:i},s=this._findInLine(e,o,t);if(!s)for(let n=a+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(o.startRow=n,o.startCol=0,s=this._findInLine(e,o,t),!s);n++);if(!s&&a!==0)for(let n=0;n<a&&(o.startRow=n,o.startCol=0,s=this._findInLine(e,o,t),!s);n++);return!s&&r&&(o.startRow=r.start.y,o.startCol=0,s=this._findInLine(e,o,t)),s}findPreviousWithSelection(e,t,n){if(!e||e.length===0){this._terminal.clearSelection();return}let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let i=this._terminal.buffer.active.baseY+this._terminal.rows-1,a=this._terminal.cols;this._lineCache.initLinesCache();let o={startRow:i,startCol:a},s;if(r&&(o.startRow=i=r.start.y,o.startCol=a=r.start.x,n!==e&&(s=this._findInLine(e,o,t,!1),s||(o.startRow=i=r.end.y,o.startCol=a=r.end.x))),s||=this._findInLine(e,o,t,!0),!s){o.startCol=Math.max(o.startCol,this._terminal.cols);for(let n=i-1;n>=0&&(o.startRow=n,s=this._findInLine(e,o,t,!0),!s);n--);}if(!s&&i!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let n=this._terminal.buffer.active.baseY+this._terminal.rows-1;n>=i&&(o.startRow=n,s=this._findInLine(e,o,t,!0),!s);n--);return s}_isWholeWord(e,t,n){return(e===0||` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`.includes(t[e-1]))&&(e+n.length===t.length||` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`.includes(t[e+n.length]))}_findInLine(e,t,n={},r=!1){let i=t.startRow,a=t.startCol;if(this._terminal.buffer.active.getLine(i)?.isWrapped){if(r){t.startCol+=this._terminal.cols;return}return t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,n)}let o=this._lineCache.getLineFromCache(i);o||(o=this._lineCache.translateBufferLineToStringWithWrap(i,!0),this._lineCache.setLineInCache(i,o));let[s,c]=o,l=this._bufferColsToStringOffset(i,a),u=e,d=s;n.regex||(u=n.caseSensitive?e:e.toLowerCase(),d=n.caseSensitive?s:s.toLowerCase());let f=-1;if(n.regex){let t=RegExp(u,n.caseSensitive?`g`:`gi`),i;if(r)for(;i=t.exec(d.slice(0,l));)f=t.lastIndex-i[0].length,e=i[0],t.lastIndex-=e.length-1;else i=t.exec(d.slice(l)),i&&i[0].length>0&&(f=l+(t.lastIndex-i[0].length),e=i[0])}else r?l-u.length>=0&&(f=d.lastIndexOf(u,l-u.length)):f=d.indexOf(u,l);if(f>=0){if(n.wholeWord&&!this._isWholeWord(f,d,e))return;let t=0;for(;t<c.length-1&&f>=c[t+1];)t++;let r=t;for(;r<c.length-1&&f+e.length>=c[r+1];)r++;let a=f-c[t],o=f+e.length-c[r],s=this._stringLengthToBufferSize(i+t,a),l=this._stringLengthToBufferSize(i+r,o)-s+this._terminal.cols*(r-t);return{term:e,col:s,row:i+t,size:l}}}_stringLengthToBufferSize(e,t){let n=this._terminal.buffer.active.getLine(e);if(!n)return 0;for(let e=0;e<t;e++){let r=n.getCell(e);if(!r)break;let i=r.getChars();i.length>1&&(t-=i.length-1);let a=n.getCell(e+1);a&&a.getWidth()===0&&t++}return t}_bufferColsToStringOffset(e,t){let n=e,r=0,i=this._terminal.buffer.active.getLine(n);for(;t>0&&i;){for(let e=0;e<t&&e<this._terminal.cols;e++){let t=i.getCell(e);if(!t)break;t.getWidth()&&(r+=t.getCode()===0?1:t.getChars().length)}if(n++,i=this._terminal.buffer.active.getLine(n),i&&!i.isWrapped)break;t-=this._terminal.cols}return r}},pl=class extends Tc{constructor(e){super(),this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(Sc(()=>this.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let n of e){let e=this._createResultDecorations(n,t,!1);if(e)for(let t of e)this._storeDecoration(t,n)}}createActiveDecoration(e,t){let n=this._createResultDecorations(e,t,!0);if(n)return{decorations:n,match:e,dispose(){bc(n)}}}clearHighlightDecorations(){bc(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,n){e.classList.contains(`xterm-find-result-decoration`)||(e.classList.add(`xterm-find-result-decoration`),t&&(e.style.outline=`1px solid ${t}`)),n&&e.classList.add(`xterm-find-active-result-decoration`)}_createResultDecorations(e,t,n){let r=[],i=e.col,a=e.size,o=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;a>0;){let e=Math.min(this._terminal.cols-i,a);r.push([o,i,e]),i=0,a-=e,o++}let s=[];for(let e of r){let r=this._terminal.registerMarker(e[0]),i=this._terminal.registerDecoration({marker:r,x:e[1],width:e[2],backgroundColor:n?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(r.line)?void 0:{color:n?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:`center`}});if(i){let e=[];e.push(r),e.push(i.onRender(e=>this._applyStyles(e,n?t.activeMatchBorder:t.matchBorder,!1))),e.push(i.onDispose(()=>bc(e))),s.push(i)}}return s.length===0?void 0:s}},ml=class extends Tc{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new Uc)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&=(this._selectedDecoration.dispose(),void 0)}findResultIndex(e){for(let t=0;t<this._searchResults.length;t++){let n=this._searchResults[t];if(n.row===e.row&&n.col===e.col&&n.size===e.size)return t}return-1}fireResultsChanged(e){if(!e)return;let t=-1;this._selectedDecoration&&(t=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:t,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},hl=class extends Tc{constructor(e){super(),this._highlightTimeout=this._register(new Ec),this._lineCache=this._register(new Ec),this._state=new dl,this._resultTracker=this._register(new ml),this._highlightLimit=e?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new ul(e),this._engine=new fl(e,this._lineCache.value),this._decorationManager=new pl(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(Sc(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=sl(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,n){if(!this._terminal||!this._engine)throw Error(`Cannot use addon until it has been loaded`);this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findNextAndSelect(e,t,n);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw Error(`Cannot use addon until it has been loaded`);if(!this._state.isValidSearchTerm(e)){this.clearDecorations();return}this.clearDecorations(!0);let n=[],r,i=this._engine.find(e,0,0,t);for(;i&&(r?.row!==i.row||r?.col!==i.col)&&!(n.length>=this._highlightLimit);)r=i,n.push(r),i=this._engine.find(e,r.col+r.term.length>=this._terminal.cols?r.row+1:r.row,r.col+r.term.length>=this._terminal.cols?0:r.col+1,t);this._resultTracker.updateResults(n,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(n,t.decorations)}_findNextAndSelect(e,t,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,t?.decorations,n?.noScroll)}findPrevious(e,t,n){if(!this._terminal||!this._engine)throw Error(`Cannot use addon until it has been loaded`);this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findPreviousAndSelect(e,t,n);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_fireResults(e){this._resultTracker.fireResultsChanged(!!e?.decorations)}_findPreviousAndSelect(e,t,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,t?.decorations,n?.noScroll)}_selectResult(e,t,n){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let n=this._decorationManager.createActiveDecoration(e,t);n&&(this._resultTracker.selectedDecoration=n)}if(!n&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.row<this._terminal.buffer.active.viewportY)){let t=e.row-this._terminal.buffer.active.viewportY;t-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(t)}return!0}},gl=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=vl.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e))}};function _l(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var vl=class e{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||``)+`g`),[o,s]=e._getWindowedLineStrings(t-1,r),c=o.join(``),l,u=[];for(;l=a.exec(c);){let t=l[0];if(!_l(t))continue;let[n,a]=e._mapStrIdx(r,s,0,l.index),[o,c]=e._mapStrIdx(r,n,a,t.length);if(n===-1||a===-1||o===-1||c===-1)continue;let d={start:{x:a+1,y:n+1},end:{x:c,y:o+1}};u.push({range:d,text:t,activate:i})}return u}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),!(!n.isWrapped||o.indexOf(` `)!==-1)););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n<e.length;++n){e.getCell(n,a);let o=a.getChars();if(a.getWidth()&&(r-=o.length||1,n===e.length-1&&o===``)){let e=i.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[t,n]}t++,o=0}return[t,o]}},yl=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function bl(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}var xl=class{constructor(e=bl,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||yl;this._linkProvider=this._terminal.registerLinkProvider(new gl(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}};function Sl(e){return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)}function Cl(){return(0,b.useSyncExternalStore)(Sl,()=>document.visibilityState===`visible`)}function wl(e){let t=/^#?([0-9a-fA-F]{6})(?:[0-9a-fA-F]{2})?$/.exec(e.trim());if(!t)return null;let n=t[1].toLowerCase(),r=e=>n.slice(e,e+2).repeat(2);return`rgb:${r(0)}/${r(2)}/${r(4)}`}function Tl(e,t){let n=wl(t);return n?`\x1b]${e};${n}\x1b\\`:null}function El(e,t){return e.type===`keydown`?t?e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&e.key===`c`:e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&e.key.toLowerCase()===`c`:!1}function Dl(e,t,n){if(t.startsWith(`login-`)||t===`home`)return!1;let r=Array.from(e.clipboardData?.items??[]);if(r.some(e=>e.type===`text/plain`))return!1;let a=r.find(e=>e.kind===`file`&&e.type.startsWith(`image/`));if(!a)return!1;let o=a.getAsFile();if(!o)return!1;let c=i.safeParse(a.type);return c.success?(Ol(o,c.data,t,n),!0):(s.error(`Cannot paste ${a.type} — png, jpeg, gif, and webp are supported`),!0)}async function Ol(e,t,n,r){try{let i=await kl(e),a=await m(`POST`,`/api/worktrees/${n}/paste`,{mime:t,data:i});se.write(n,r,`${a.path} `)}catch(e){s.error(e instanceof Error?`Image paste failed: ${e.message}`:`Image paste failed`)}}function kl(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result).replace(/^data:[^,]*,/,``)),r.onerror=()=>n(r.error??Error(`could not read the clipboard image`)),r.readAsDataURL(e)})}var Al=new Set([`localhost`,`127.0.0.1`,`::1`,`[::1]`]);function jl(e,t,n,r){if(!n)return e;let i;try{i=new URL(e)}catch{return e}if(i.protocol!==`http:`&&i.protocol!==`https:`||!Al.has(i.hostname))return e;let a=i.port===``?i.protocol===`https:`?`443`:`80`:i.port,o=r?`puddle_token=${r}`:``,s=i.search?`${i.search}${o?`&${o}`:``}`:o?`?${o}`:``;return`/proxy/${t}/${a}${i.pathname}${s}${i.hash}`}var Ml=n(),Nl=/Mac|iPhone|iPad/.test(navigator.platform),Pl=`'Ubuntu Sans Mono', ui-monospace, monospace`,Fl=`12px 'Ubuntu Sans Mono'`,Il=typeof document>`u`||!(`fonts`in document)||document.fonts.check(Fl),Ll=Il?null:document.fonts.load(Fl).catch(()=>void 0).then(()=>{Il=!0});function Rl(){let[e,t]=(0,b.useState)(Il);return(0,b.useEffect)(()=>{if(e||Ll===null)return;let n=!0;return Ll.then(()=>{n&&t(!0)}),()=>{n=!1}},[e]),e}var zl=[`starting`,`running`,`waiting_input`],Bl={ArrowLeft:``,ArrowRight:``,Backspace:``,Delete:`\v`};function Vl(e){let t=ae();return{...e,decorations:{matchBackground:t(`--bg-surface`),matchBorder:t(`--text-muted`),matchOverviewRuler:t(`--text-muted`),activeMatchBackground:t(`--bg-elevated`),activeMatchBorder:t(`--accent`),activeMatchColorOverviewRuler:t(`--accent`)}}}function Hl(e,t){let[n,r]=(0,b.useState)(e);return(0,b.useEffect)(()=>{if(e){r(!0);return}let n=setTimeout(()=>r(!1),t);return()=>clearTimeout(n)},[e,t]),n}var Ul=1500;function Wl({stream:e,term:t=`agent`,className:n,onExit:i,onOpenFile:s,paused:m=!1}){let x=(0,b.useRef)(null),S=(0,b.useRef)(null),ce=(0,b.useRef)(null),C=(0,b.useRef)(null),w=(0,b.useRef)(!1),le=oe(),ue=(0,b.useRef)(i);ue.current=i;let de=(0,b.useRef)(s);de.current=s;let fe=Cl(),pe=Hl(!m&&fe,Ul),T=Rl(),me=y(a().data?.protocol),he=l(p()??void 0).data?.terminalAppShortcuts!==!1,ge=(0,b.useRef)(he);ge.current=he;let E=ne({shortcutEnabled:!1,onFind:(e,t,n)=>{let r=C.current,i=S.current;if(!r||!i)return v;if(e.length===0)return r.clearDecorations(),i.clearSelection(),v;if(!ee(e,t))return r.clearDecorations(),i.clearSelection(),{index:-1,count:0,invalid:!0};let a=Vl(t);n===`previous`?r.findPrevious(e,a):r.findNext(e,{...a,incremental:n===`reset`})},onClear:()=>{C.current?.clearDecorations(),S.current?.clearSelection()},onCloseFocus:()=>S.current?.focus()}),D=(0,b.useCallback)(()=>{let n=S.current,r=x.current;!n||!r||r.clientWidth===0||(ce.current?.fit(),n.resize(n.cols,n.rows),n.refresh(0,n.rows-1),se.resize(e,t,n.cols,n.rows))},[e,t]);return(0,b.useEffect)(()=>{if(!fe)return;let e=requestAnimationFrame(()=>{let e=S.current;e&&e.refresh(0,e.rows-1)});return()=>cancelAnimationFrame(e)},[fe]),(0,b.useEffect)(()=>{let n=x.current;if(!n||!T)return;let r=e.startsWith(`login-`)||e===`home`,i=t=>{let n=r?t:jl(t,e,h()!==null,o.get());window.open(n,`_blank`,`noopener,noreferrer`)},a=new Ys({allowProposedApi:!0,theme:ie(),fontFamily:Pl,fontSize:le.terminalFontSize,scrollback:le.terminalScrollback,cursorBlink:!0,macOptionClickForcesSelection:Nl,linkHandler:{activate:(e,t)=>i(t)}});S.current=a;let s=new Qs,l=new hl;a.loadAddon(s),a.loadAddon(l),a.loadAddon(new xl((e,t)=>i(t))),a.open(n),s.fit(),ce.current=s,C.current=l;let p=l.onDidChangeResults(e=>{E.setResult({index:e.resultIndex,count:e.resultCount})}),m=de.current&&!r?g(a,e,e=>de.current?.(e)):null,v={stash:null},ee=a.onData(n=>{w.current||(n.startsWith(`\x1B[<`)||(v.stash=null),se.write(e,t,n))}),te=(n,r)=>i=>{if(i!==`?`)return!1;if(w.current)return!0;let a=Tl(n,ae()(r));return a&&se.write(e,t,a),!0},ne=me?null:a.parser.registerOscHandler(10,te(10,`--text-primary`)),oe=me?null:a.parser.registerOscHandler(11,te(11,`--bg-base`)),y=a.parser.registerOscHandler(52,e=>{if(w.current)return!0;let t=e.indexOf(`;`),n=t===-1?``:e.slice(t+1);if(!n||n===`?`)return!0;try{let e=Uint8Array.from(atob(n),e=>e.charCodeAt(0));v.stash=new TextDecoder().decode(e)}catch{}return!0});a.attachCustomKeyEventHandler(n=>{if(n.type===`keydown`&&_(n,Nl))return n.preventDefault(),E.openFind(),!1;if(El(n,Nl)){let e=a.getSelection()||v.stash;return e?(navigator.clipboard?.writeText(e),n.preventDefault(),!1):!0}if(n.type===`keydown`&&ge.current){let e=c(n),t=e===null?void 0:d(e),r=t===void 0?void 0:u(t);if(t!==void 0&&r!==void 0&&!r.editor&&!r.deferInTerminal&&f(t)!==void 0)return!1}if(!Nl||n.type!==`keydown`||!n.metaKey||n.ctrlKey||n.altKey||n.shiftKey)return!0;let r=Bl[n.key];return r?(n.preventDefault(),se.write(e,t,r),!1):!0});let b=n=>{Dl(n,e,t)&&(n.preventDefault(),n.stopPropagation())};n.addEventListener(`paste`,b,!0);let ue=()=>D();n.addEventListener(`focusin`,ue);let fe=new ResizeObserver(()=>D());fe.observe(n);let pe=re(()=>{a.options.theme=ie(),E.refresh()});return()=>{n.removeEventListener(`paste`,b,!0),n.removeEventListener(`focusin`,ue),fe.disconnect(),pe(),p.dispose(),ne?.dispose(),oe?.dispose(),y.dispose(),m?.dispose(),ee.dispose(),a.dispose(),S.current=null,ce.current=null,C.current=null}},[e,t,D,T,me]),(0,b.useEffect)(()=>{let n=S.current;if(!n||!pe)return;let r=x.current;r&&r.clientWidth>0&&ce.current?.fit(),n.refresh(0,n.rows-1);let i=0,a=0,o=[],s=()=>{if(i!==0&&cancelAnimationFrame(i),i=0,a===0)return;let e=o.join(``);o=[],a=0,n.write(e)},c=e=>{o.push(e),a+=e.length,a>=64*1024?s():i===0&&(i=requestAnimationFrame(s))},l=se.attach(e,t,n.cols,n.rows,{onData:(e,t)=>{if(t===`replay`){i!==0&&cancelAnimationFrame(i),i=0,a=0,o=[],w.current=!0,n.reset(),n.write(e,()=>{w.current=!1,n.refresh(0,n.rows-1)});return}c(e)},onExit:e=>ue.current?.(e)});return()=>{i!==0&&cancelAnimationFrame(i),l()}},[e,t,pe,T]),(0,b.useEffect)(()=>{let e=S.current;e&&(e.options.fontSize=le.terminalFontSize,e.options.scrollback=le.terminalScrollback,D())},[le.terminalFontSize,le.terminalScrollback,D]),(0,b.useEffect)(()=>{let t=!1;return se.onStatus(n=>{if(n.session!==e)return;let r=zl.includes(n.status);r&&!t&&D(),t=r})},[e,D]),(0,Ml.jsxs)(`div`,{className:r(`relative size-full`,n),children:[(0,Ml.jsx)(`div`,{ref:x,className:`size-full`}),E.open&&(0,Ml.jsx)(te,{query:E.query,focusKey:E.focusKey,options:E.options,result:E.result,onQueryChange:E.setQuery,onOptionsChange:E.setOptions,onNext:E.next,onPrevious:E.previous,onClose:E.close})]})}export{Wl as Terminal};
|
|
60
|
+
`).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);Hc.register(a,t?.[2]??e,a)}return a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*Vc<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||ec;if(!n){e.value(t);return}try{e.value(t)}catch(e){n(e)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof Bc)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},Wc=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Gc=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),Kc;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof qc?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ac.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Gc})})(Kc||={});var qc=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Gc:(this._emitter||=new Uc,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},Jc=`en`,Yc=!1,Xc=!1,Zc=Jc,Qc,$c=globalThis,el;typeof $c.vscode<`u`&&typeof $c.vscode.process<`u`?el=$c.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(el=process);var tl=typeof el?.versions?.electron==`string`&&el?.type===`renderer`;if(typeof el==`object`){el.platform,el.platform,Yc=el.platform===`linux`,Yc&&el.env.SNAP&&el.env.SNAP_REVISION,el.env.CI||el.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Zc=Jc;let e=el.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,Zc=t.resolvedLanguage||Jc,t.languagePack?.translationsConfigFile}catch{}}else typeof navigator==`object`&&!tl?(Qc=navigator.userAgent,Qc.indexOf(`Windows`),Qc.indexOf(`Macintosh`),(Qc.indexOf(`Macintosh`)>=0||Qc.indexOf(`iPad`)>=0||Qc.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,Yc=Qc.indexOf(`Linux`)>=0,Qc?.indexOf(`Mobi`),Xc=!0,Zc=globalThis._VSCODE_NLS_LANGUAGE||Jc,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);Xc&&typeof $c.importScripts==`function`&&$c.origin;var nl=Qc,rl=Zc,il;(e=>{function t(){return rl}e.value=t;function n(){return rl.length===2?rl===`en`:rl.length>=3&&rl[0]===`e`&&rl[1]===`n`&&rl[2]===`-`}e.isDefaultVariant=n;function r(){return rl===`en`}e.isDefault=r})(il||={});var al=typeof $c.postMessage==`function`&&!$c.importScripts;(()=>{if(al){let e=[];$c.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),$c.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var ol=!!(nl&&nl.indexOf(`Chrome`)>=0);nl&&nl.indexOf(`Firefox`),!ol&&nl&&nl.indexOf(`Safari`),nl&&nl.indexOf(`Edg/`),nl&&nl.indexOf(`Android`);function sl(e,t=0,n){let r=setTimeout(()=>{e(),n&&i.dispose()},t),i=Sc(()=>{clearTimeout(r),n?.deleteAndLeak(i)});return n?.add(i),i}(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var cl;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(cl||={});var ll=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new Uc,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await Ac.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};ll.EMPTY=ll.fromArray([]);var ul=class extends Tc{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new Ec),this._linesCacheDisposables=this._register(new Ec),this._register(Sc(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=xc(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=sl(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){return this._linesCache?.[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){let n=[],r=[0],i=this._terminal.buffer.active.getLine(e);for(;i;){let a=this._terminal.buffer.active.getLine(e+1),o=a?a.isWrapped:!1,s=i.translateToString(!o&&t);if(o&&a){let e=i.getCell(i.length-1);e&&e.getCode()===0&&e.getWidth()===1&&a.getCell(0)?.getWidth()===2&&(s=s.slice(0,-1))}if(n.push(s),o)r.push(r[r.length-1]+s.length);else break;e++,i=a}return[n.join(``),r]}},dl=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return this._lastSearchOptions?e?this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord:!1:!0}shouldUpdateHighlighting(e,t){return t?.decorations?this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||this.didOptionsChange(t):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},fl=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,n,r){if(!e||e.length===0){this._terminal.clearSelection();return}if(n>this._terminal.cols)throw Error(`Invalid col: ${n} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let i={startRow:t,startCol:n},a=this._findInLine(e,i,r);if(!a)for(let n=t+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(i.startRow=n,i.startCol=0,a=this._findInLine(e,i,r),!a);n++);return a}findNextWithSelection(e,t,n){if(!e||e.length===0){this._terminal.clearSelection();return}let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let i=0,a=0;r&&(n===e?(i=r.end.x,a=r.end.y):(i=r.start.x,a=r.start.y)),this._lineCache.initLinesCache();let o={startRow:a,startCol:i},s=this._findInLine(e,o,t);if(!s)for(let n=a+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(o.startRow=n,o.startCol=0,s=this._findInLine(e,o,t),!s);n++);if(!s&&a!==0)for(let n=0;n<a&&(o.startRow=n,o.startCol=0,s=this._findInLine(e,o,t),!s);n++);return!s&&r&&(o.startRow=r.start.y,o.startCol=0,s=this._findInLine(e,o,t)),s}findPreviousWithSelection(e,t,n){if(!e||e.length===0){this._terminal.clearSelection();return}let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let i=this._terminal.buffer.active.baseY+this._terminal.rows-1,a=this._terminal.cols;this._lineCache.initLinesCache();let o={startRow:i,startCol:a},s;if(r&&(o.startRow=i=r.start.y,o.startCol=a=r.start.x,n!==e&&(s=this._findInLine(e,o,t,!1),s||(o.startRow=i=r.end.y,o.startCol=a=r.end.x))),s||=this._findInLine(e,o,t,!0),!s){o.startCol=Math.max(o.startCol,this._terminal.cols);for(let n=i-1;n>=0&&(o.startRow=n,s=this._findInLine(e,o,t,!0),!s);n--);}if(!s&&i!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let n=this._terminal.buffer.active.baseY+this._terminal.rows-1;n>=i&&(o.startRow=n,s=this._findInLine(e,o,t,!0),!s);n--);return s}_isWholeWord(e,t,n){return(e===0||` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`.includes(t[e-1]))&&(e+n.length===t.length||` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`.includes(t[e+n.length]))}_findInLine(e,t,n={},r=!1){let i=t.startRow,a=t.startCol;if(this._terminal.buffer.active.getLine(i)?.isWrapped){if(r){t.startCol+=this._terminal.cols;return}return t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,n)}let o=this._lineCache.getLineFromCache(i);o||(o=this._lineCache.translateBufferLineToStringWithWrap(i,!0),this._lineCache.setLineInCache(i,o));let[s,c]=o,l=this._bufferColsToStringOffset(i,a),u=e,d=s;n.regex||(u=n.caseSensitive?e:e.toLowerCase(),d=n.caseSensitive?s:s.toLowerCase());let f=-1;if(n.regex){let t=RegExp(u,n.caseSensitive?`g`:`gi`),i;if(r)for(;i=t.exec(d.slice(0,l));)f=t.lastIndex-i[0].length,e=i[0],t.lastIndex-=e.length-1;else i=t.exec(d.slice(l)),i&&i[0].length>0&&(f=l+(t.lastIndex-i[0].length),e=i[0])}else r?l-u.length>=0&&(f=d.lastIndexOf(u,l-u.length)):f=d.indexOf(u,l);if(f>=0){if(n.wholeWord&&!this._isWholeWord(f,d,e))return;let t=0;for(;t<c.length-1&&f>=c[t+1];)t++;let r=t;for(;r<c.length-1&&f+e.length>=c[r+1];)r++;let a=f-c[t],o=f+e.length-c[r],s=this._stringLengthToBufferSize(i+t,a),l=this._stringLengthToBufferSize(i+r,o)-s+this._terminal.cols*(r-t);return{term:e,col:s,row:i+t,size:l}}}_stringLengthToBufferSize(e,t){let n=this._terminal.buffer.active.getLine(e);if(!n)return 0;for(let e=0;e<t;e++){let r=n.getCell(e);if(!r)break;let i=r.getChars();i.length>1&&(t-=i.length-1);let a=n.getCell(e+1);a&&a.getWidth()===0&&t++}return t}_bufferColsToStringOffset(e,t){let n=e,r=0,i=this._terminal.buffer.active.getLine(n);for(;t>0&&i;){for(let e=0;e<t&&e<this._terminal.cols;e++){let t=i.getCell(e);if(!t)break;t.getWidth()&&(r+=t.getCode()===0?1:t.getChars().length)}if(n++,i=this._terminal.buffer.active.getLine(n),i&&!i.isWrapped)break;t-=this._terminal.cols}return r}},pl=class extends Tc{constructor(e){super(),this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(Sc(()=>this.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let n of e){let e=this._createResultDecorations(n,t,!1);if(e)for(let t of e)this._storeDecoration(t,n)}}createActiveDecoration(e,t){let n=this._createResultDecorations(e,t,!0);if(n)return{decorations:n,match:e,dispose(){bc(n)}}}clearHighlightDecorations(){bc(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,n){e.classList.contains(`xterm-find-result-decoration`)||(e.classList.add(`xterm-find-result-decoration`),t&&(e.style.outline=`1px solid ${t}`)),n&&e.classList.add(`xterm-find-active-result-decoration`)}_createResultDecorations(e,t,n){let r=[],i=e.col,a=e.size,o=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;a>0;){let e=Math.min(this._terminal.cols-i,a);r.push([o,i,e]),i=0,a-=e,o++}let s=[];for(let e of r){let r=this._terminal.registerMarker(e[0]),i=this._terminal.registerDecoration({marker:r,x:e[1],width:e[2],backgroundColor:n?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(r.line)?void 0:{color:n?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:`center`}});if(i){let e=[];e.push(r),e.push(i.onRender(e=>this._applyStyles(e,n?t.activeMatchBorder:t.matchBorder,!1))),e.push(i.onDispose(()=>bc(e))),s.push(i)}}return s.length===0?void 0:s}},ml=class extends Tc{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new Uc)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&=(this._selectedDecoration.dispose(),void 0)}findResultIndex(e){for(let t=0;t<this._searchResults.length;t++){let n=this._searchResults[t];if(n.row===e.row&&n.col===e.col&&n.size===e.size)return t}return-1}fireResultsChanged(e){if(!e)return;let t=-1;this._selectedDecoration&&(t=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:t,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},hl=class extends Tc{constructor(e){super(),this._highlightTimeout=this._register(new Ec),this._lineCache=this._register(new Ec),this._state=new dl,this._resultTracker=this._register(new ml),this._highlightLimit=e?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new ul(e),this._engine=new fl(e,this._lineCache.value),this._decorationManager=new pl(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(Sc(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=sl(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,n){if(!this._terminal||!this._engine)throw Error(`Cannot use addon until it has been loaded`);this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findNextAndSelect(e,t,n);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw Error(`Cannot use addon until it has been loaded`);if(!this._state.isValidSearchTerm(e)){this.clearDecorations();return}this.clearDecorations(!0);let n=[],r,i=this._engine.find(e,0,0,t);for(;i&&(r?.row!==i.row||r?.col!==i.col)&&!(n.length>=this._highlightLimit);)r=i,n.push(r),i=this._engine.find(e,r.col+r.term.length>=this._terminal.cols?r.row+1:r.row,r.col+r.term.length>=this._terminal.cols?0:r.col+1,t);this._resultTracker.updateResults(n,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(n,t.decorations)}_findNextAndSelect(e,t,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,t?.decorations,n?.noScroll)}findPrevious(e,t,n){if(!this._terminal||!this._engine)throw Error(`Cannot use addon until it has been loaded`);this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findPreviousAndSelect(e,t,n);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_fireResults(e){this._resultTracker.fireResultsChanged(!!e?.decorations)}_findPreviousAndSelect(e,t,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,t?.decorations,n?.noScroll)}_selectResult(e,t,n){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let n=this._decorationManager.createActiveDecoration(e,t);n&&(this._resultTracker.selectedDecoration=n)}if(!n&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.row<this._terminal.buffer.active.viewportY)){let t=e.row-this._terminal.buffer.active.viewportY;t-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(t)}return!0}},gl=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=vl.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e))}};function _l(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var vl=class e{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||``)+`g`),[o,s]=e._getWindowedLineStrings(t-1,r),c=o.join(``),l,u=[];for(;l=a.exec(c);){let t=l[0];if(!_l(t))continue;let[n,a]=e._mapStrIdx(r,s,0,l.index),[o,c]=e._mapStrIdx(r,n,a,t.length);if(n===-1||a===-1||o===-1||c===-1)continue;let d={start:{x:a+1,y:n+1},end:{x:c,y:o+1}};u.push({range:d,text:t,activate:i})}return u}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),!(!n.isWrapped||o.indexOf(` `)!==-1)););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n<e.length;++n){e.getCell(n,a);let o=a.getChars();if(a.getWidth()&&(r-=o.length||1,n===e.length-1&&o===``)){let e=i.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[t,n]}t++,o=0}return[t,o]}},yl=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function bl(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}var xl=class{constructor(e=bl,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||yl;this._linkProvider=this._terminal.registerLinkProvider(new gl(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}};function Sl(e){return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)}function Cl(){return(0,b.useSyncExternalStore)(Sl,()=>document.visibilityState===`visible`)}function wl(e){let t=/^#?([0-9a-fA-F]{6})(?:[0-9a-fA-F]{2})?$/.exec(e.trim());if(!t)return null;let n=t[1].toLowerCase(),r=e=>n.slice(e,e+2).repeat(2);return`rgb:${r(0)}/${r(2)}/${r(4)}`}function Tl(e,t){let n=wl(t);return n?`\x1b]${e};${n}\x1b\\`:null}function El(e,t){return e.type===`keydown`?t?e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&e.key===`c`:e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&e.key.toLowerCase()===`c`:!1}function Dl(e,t,n){if(t.startsWith(`login-`)||t===`home`)return!1;let r=Array.from(e.clipboardData?.items??[]);if(r.some(e=>e.type===`text/plain`))return!1;let a=r.find(e=>e.kind===`file`&&e.type.startsWith(`image/`));if(!a)return!1;let o=a.getAsFile();if(!o)return!1;let c=i.safeParse(a.type);return c.success?(Ol(o,c.data,t,n),!0):(s.error(`Cannot paste ${a.type} — png, jpeg, gif, and webp are supported`),!0)}async function Ol(e,t,n,r){try{let i=await kl(e),a=await m(`POST`,`/api/worktrees/${n}/paste`,{mime:t,data:i});se.write(n,r,`${a.path} `)}catch(e){s.error(e instanceof Error?`Image paste failed: ${e.message}`:`Image paste failed`)}}function kl(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result).replace(/^data:[^,]*,/,``)),r.onerror=()=>n(r.error??Error(`could not read the clipboard image`)),r.readAsDataURL(e)})}var Al=new Set([`localhost`,`127.0.0.1`,`::1`,`[::1]`]);function jl(e,t,n,r){if(!n)return e;let i;try{i=new URL(e)}catch{return e}if(i.protocol!==`http:`&&i.protocol!==`https:`||!Al.has(i.hostname))return e;let a=i.port===``?i.protocol===`https:`?`443`:`80`:i.port,o=r?`puddle_token=${r}`:``,s=i.search?`${i.search}${o?`&${o}`:``}`:o?`?${o}`:``;return`/proxy/${t}/${a}${i.pathname}${s}${i.hash}`}var Ml=n(),Nl=/Mac|iPhone|iPad/.test(navigator.platform),Pl=`'Ubuntu Sans Mono', ui-monospace, monospace`,Fl=`12px 'Ubuntu Sans Mono'`,Il=typeof document>`u`||!(`fonts`in document)||document.fonts.check(Fl),Ll=Il?null:document.fonts.load(Fl).catch(()=>void 0).then(()=>{Il=!0});function Rl(){let[e,t]=(0,b.useState)(Il);return(0,b.useEffect)(()=>{if(e||Ll===null)return;let n=!0;return Ll.then(()=>{n&&t(!0)}),()=>{n=!1}},[e]),e}var zl=[`starting`,`running`,`waiting_input`],Bl={ArrowLeft:``,ArrowRight:``,Backspace:``,Delete:`\v`};function Vl(e){let t=y();return{...e,decorations:{matchBackground:t(`--bg-surface`),matchBorder:t(`--text-muted`),matchOverviewRuler:t(`--text-muted`),activeMatchBackground:t(`--bg-elevated`),activeMatchBorder:t(`--accent`),activeMatchColorOverviewRuler:t(`--accent`)}}}function Hl(e,t){let[n,r]=(0,b.useState)(e);return(0,b.useEffect)(()=>{if(e){r(!0);return}let n=setTimeout(()=>r(!1),t);return()=>clearTimeout(n)},[e,t]),n}var Ul=1500;function Wl({stream:e,term:t=`agent`,className:n,onExit:i,onOpenFile:s,paused:m=!1}){let x=(0,b.useRef)(null),S=(0,b.useRef)(null),ce=(0,b.useRef)(null),C=(0,b.useRef)(null),w=(0,b.useRef)(!1),le=ae(),ue=(0,b.useRef)(i);ue.current=i;let de=(0,b.useRef)(s);de.current=s;let fe=Cl(),pe=Hl(!m&&fe,Ul),T=Rl(),me=oe(a().data?.protocol),he=l(p()??void 0).data?.terminalAppShortcuts!==!1,ge=(0,b.useRef)(he);ge.current=he;let E=ne({shortcutEnabled:!1,onFind:(e,t,n)=>{let r=C.current,i=S.current;if(!r||!i)return v;if(e.length===0)return r.clearDecorations(),i.clearSelection(),v;if(!ee(e,t))return r.clearDecorations(),i.clearSelection(),{index:-1,count:0,invalid:!0};let a=Vl(t);n===`previous`?r.findPrevious(e,a):r.findNext(e,{...a,incremental:n===`reset`})},onClear:()=>{C.current?.clearDecorations(),S.current?.clearSelection()},onCloseFocus:()=>S.current?.focus()}),D=(0,b.useCallback)(()=>{let n=S.current,r=x.current;!n||!r||r.clientWidth===0||(ce.current?.fit(),n.resize(n.cols,n.rows),n.refresh(0,n.rows-1),se.resize(e,t,n.cols,n.rows))},[e,t]);return(0,b.useEffect)(()=>{if(!fe)return;let e=requestAnimationFrame(()=>{let e=S.current;e&&e.refresh(0,e.rows-1)});return()=>cancelAnimationFrame(e)},[fe]),(0,b.useEffect)(()=>{let n=x.current;if(!n||!T)return;let r=e.startsWith(`login-`)||e===`home`,i=t=>{let n=r?t:jl(t,e,h()!==null,o.get());window.open(n,`_blank`,`noopener,noreferrer`)},a=new Ys({allowProposedApi:!0,theme:re(),fontFamily:Pl,fontSize:le.terminalFontSize,scrollback:le.terminalScrollback,cursorBlink:!0,macOptionClickForcesSelection:Nl,linkHandler:{activate:(e,t)=>i(t)}});S.current=a;let s=new Qs,l=new hl;a.loadAddon(s),a.loadAddon(l),a.loadAddon(new xl((e,t)=>i(t))),a.open(n),s.fit(),ce.current=s,C.current=l;let p=l.onDidChangeResults(e=>{E.setResult({index:e.resultIndex,count:e.resultCount})}),m=de.current&&!r?g(a,e,e=>de.current?.(e)):null,v={stash:null},ee=a.onData(n=>{w.current||(n.startsWith(`\x1B[<`)||(v.stash=null),se.write(e,t,n))}),te=(n,r)=>i=>{if(i!==`?`)return!1;if(w.current)return!0;let a=Tl(n,y()(r));return a&&se.write(e,t,a),!0},ne=me?null:a.parser.registerOscHandler(10,te(10,`--text-primary`)),ae=me?null:a.parser.registerOscHandler(11,te(11,`--bg-base`)),oe=a.parser.registerOscHandler(52,e=>{if(w.current)return!0;let t=e.indexOf(`;`),n=t===-1?``:e.slice(t+1);if(!n||n===`?`)return!0;try{let e=Uint8Array.from(atob(n),e=>e.charCodeAt(0));v.stash=new TextDecoder().decode(e)}catch{}return!0});a.attachCustomKeyEventHandler(n=>{if(n.type===`keydown`&&_(n,Nl))return n.preventDefault(),E.openFind(),!1;if(El(n,Nl)){let e=a.getSelection()||v.stash;return e?(navigator.clipboard?.writeText(e),n.preventDefault(),!1):!0}if(n.type===`keydown`&&ge.current){let e=c(n),t=e===null?void 0:d(e),r=t===void 0?void 0:u(t);if(t!==void 0&&r!==void 0&&!r.editor&&!r.deferInTerminal&&f(t)!==void 0)return!1}if(!Nl||n.type!==`keydown`||!n.metaKey||n.ctrlKey||n.altKey||n.shiftKey)return!0;let r=Bl[n.key];return r?(n.preventDefault(),se.write(e,t,r),!1):!0});let b=n=>{Dl(n,e,t)&&(n.preventDefault(),n.stopPropagation())};n.addEventListener(`paste`,b,!0);let ue=()=>D();n.addEventListener(`focusin`,ue);let fe=new ResizeObserver(()=>D());fe.observe(n);let pe=ie(()=>{a.options.theme=re(),E.refresh()});return()=>{n.removeEventListener(`paste`,b,!0),n.removeEventListener(`focusin`,ue),fe.disconnect(),pe(),p.dispose(),ne?.dispose(),ae?.dispose(),oe.dispose(),m?.dispose(),ee.dispose(),a.dispose(),S.current=null,ce.current=null,C.current=null}},[e,t,D,T,me]),(0,b.useEffect)(()=>{let n=S.current;if(!n||!pe)return;let r=x.current;r&&r.clientWidth>0&&ce.current?.fit(),n.refresh(0,n.rows-1);let i=0,a=0,o=[],s=()=>{if(i!==0&&cancelAnimationFrame(i),i=0,a===0)return;let e=o.join(``);o=[],a=0,n.write(e)},c=e=>{o.push(e),a+=e.length,a>=64*1024?s():i===0&&(i=requestAnimationFrame(s))},l=se.attach(e,t,n.cols,n.rows,{onData:(e,t)=>{if(t===`replay`){i!==0&&cancelAnimationFrame(i),i=0,a=0,o=[],w.current=!0,n.reset(),n.write(e,()=>{w.current=!1,n.refresh(0,n.rows-1)});return}c(e)},onExit:e=>ue.current?.(e)});return()=>{i!==0&&cancelAnimationFrame(i),l()}},[e,t,pe,T]),(0,b.useEffect)(()=>{let e=S.current;e&&(e.options.fontSize=le.terminalFontSize,e.options.scrollback=le.terminalScrollback,D())},[le.terminalFontSize,le.terminalScrollback,D]),(0,b.useEffect)(()=>{let t=!1;return se.onStatus(n=>{if(n.session!==e)return;let r=zl.includes(n.status);r&&!t&&D(),t=r})},[e,D]),(0,Ml.jsxs)(`div`,{className:r(`relative size-full`,n),children:[(0,Ml.jsx)(`div`,{ref:x,className:`size-full`}),E.open&&(0,Ml.jsx)(te,{query:E.query,focusKey:E.focusKey,options:E.options,result:E.result,onQueryChange:E.setQuery,onOptionsChange:E.setOptions,onNext:E.next,onPrevious:E.previous,onClose:E.close})]})}export{Wl as Terminal};
|