@puddle-code/cli 0.4.3 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/CHANGELOG.md +12 -6
  2. package/dist/index.js +3 -2
  3. package/dist/public/assets/{App-BCbtMAtT.js → App-DiuYTEQv.js} +13 -8
  4. package/dist/public/assets/{Dashboard-nQpeuNVO.js → Dashboard-DwYEuGdA.js} +1 -1
  5. package/dist/public/assets/{EditorTabClose-BvQUApC8.js → EditorTabClose-DWcVp29x.js} +1 -1
  6. package/dist/public/assets/{LazyTerminal-CB6HNxTY.js → LazyTerminal-BRdmWa8z.js} +2 -2
  7. package/dist/public/assets/{ModelRefcount-DAWvhyB_.js → ModelRefcount-C0bySKlY.js} +1 -1
  8. package/dist/public/assets/{NewProjectDialog-lh9FEfzd.js → NewProjectDialog-D87YE4pz.js} +1 -1
  9. package/dist/public/assets/{NotebookWidget-C93HDt3h.js → NotebookWidget-BxU1ILhZ.js} +1 -1
  10. package/dist/public/assets/{PaneEditorBody-DtVSqmqc.js → PaneEditorBody-DosywVrH.js} +3 -3
  11. package/dist/public/assets/ReleaseNotesDialog-BXqx8SP6.js +1 -0
  12. package/dist/public/assets/{SettingsDialog-D8zu__T0.js → SettingsDialog-gGoY2tNN.js} +1 -1
  13. package/dist/public/assets/{Terminal-DCG4oUTx.js → Terminal-ixgwoszm.js} +4 -4
  14. package/dist/public/assets/{Workspace-DLDOs4cG.js → Workspace-BaIPEaup.js} +4 -4
  15. package/dist/public/assets/{Workspace-CmtwcmGk.css → Workspace-D5qlJNnU.css} +1 -1
  16. package/dist/public/assets/{buffer-store-DLpJesbU.js → buffer-store-KcgRSSvB.js} +1 -1
  17. package/dist/public/assets/{index-DdOKMIa5.js → index-ByBNBhsx.js} +2 -2
  18. package/dist/public/assets/{markdown-mermaid-CuwsuNsF.js → markdown-mermaid-Bn0a2pwd.js} +1 -1
  19. package/dist/public/assets/{notification-delivery-Ygc29Xb8.js → notification-delivery-C9wsvfQY.js} +1 -1
  20. package/dist/public/assets/{selection-actions-vwVXE8h8.js → selection-actions-C4diprgb.js} +1 -1
  21. package/dist/public/assets/ws-Dgc69_w8.js +1 -0
  22. package/dist/public/index.html +1 -1
  23. package/package.json +1 -1
  24. package/dist/public/assets/ReleaseNotesDialog-Z7jtCZYz.js +0 -1
  25. package/dist/public/assets/ws-DpgAmFEj.js +0 -1
@@ -1,4 +1,4 @@
1
- import{r as e,t}from"./rolldown-runtime-QTnfLwEv.js";import{t as n}from"./react-CZI7_Jkm.js";import{A as r,E as i,G as a,H as o,I as s,Q as c,R as l,St as u,T as d,Tt as f,W as p,Y as m,Z as h,at as g,c as _,ct as v,et as y,j as b,mt as x,n as S,ot as C,pt as w,q as T,rt as E,tt as D,x as O,z as ee}from"./protocol-support-CsLR9u7d.js";import{B as te,G as ne,H as re,Q as ie,U as ae,V as oe,_ as se,g as ce,h as le,q as ue,v as de,y as fe}from"./auth-olLlgxc3.js";import{c as pe,i as me,o as he,r as ge,s as _e}from"./LazyTerminal-CB6HNxTY.js";import{C as ve,O as ye,S as be,T as xe,_ as Se,a as Ce,b as we,c as Te,d as Ee,f as De,i as Oe,l as ke,m as Ae,n as je,o as Me,r as Ne,s as Pe,t as Fe,u as Ie,v as Le,w as Re,x as ze,y as Be}from"./notification-delivery-Ygc29Xb8.js";import{a as Ve,i as He,r as k,t as Ue}from"./client-settings-CwqpIric.js";import{t as We}from"./jsx-runtime-By8HlURe.js";import{d as Ge,o as Ke,t as qe}from"./index-DdOKMIa5.js";import{n as Je,t as Ye}from"./api-BOuyloUi.js";import{_ as Xe,a as Ze,f as Qe,g as A,i as $e,m as et,n as tt,t as nt}from"./hotkeys-Cu0t6sbz.js";import{n as j}from"./dist-BOS6OKSE.js";import{a as rt,i as M,n as N,o as P,r as F,t as I}from"./dialog-IU2fjIs9.js";import{n as L,r as it}from"./chevron-right-BP2NLwlG.js";import{n as at,r as ot}from"./dist-BHBQY7ao.js";import{n as R,t as z}from"./createLucideIcon-C9A1vLE-.js";import{t as B}from"./button-q0ardkfx.js";import{a as st,c as ct,i as lt,l as ut,n as dt,o as ft,r as pt,t as V,u as mt}from"./switch-DihTSmnc.js";import{a as H,i as U,n as ht,r as W,t as gt}from"./select-C0UTbo8D.js";import{t as _t}from"./code-Cf4ftdOa.js";import{t as vt}from"./rotate-ccw-BI2k_h3A.js";import{r as G}from"./ws-DpgAmFEj.js";import{t as yt}from"./use-debounced-value-C86N-mOK.js";import{n as bt,r as xt,t as St}from"./popover-B5Bw2ljC.js";import{a as Ct,o as wt,r as Tt,t as Et,u as Dt}from"./CompilationCommandForm-C71yC-_B.js";var Ot=z(`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`}]]),kt=z(`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`}]]),At=z(`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`}]]),jt=z(`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`}]]),Mt=z(`shield-check`,[[`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:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Nt=z(`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`}]]),Pt=z(`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(n(),1),q=We();function Ft({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)(L,{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 J({label:e,description:t,descriptionClassName:n,htmlFor:r,children:i,className:a}){return(0,q.jsxs)(`div`,{className:R(`flex items-center gap-4 py-2.5`,a),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:R(`text-xs text-fg-muted`,n),children:t})]}),(0,q.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:i})]})}function Y({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 It(){let e=He(),[t,n]=(0,K.useState)(Ke());return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(Y,{children:`Appearance`}),(0,q.jsx)(J,{label:`Theme`,children:(0,q.jsxs)(gt,{value:t,onValueChange:e=>{n(e),qe(e)},children:[(0,q.jsx)(U,{className:`w-32`,children:(0,q.jsx)(H,{})}),(0,q.jsxs)(ht,{children:[(0,q.jsx)(W,{value:`dark`,children:`Dark`}),(0,q.jsx)(W,{value:`light`,children:`Light`}),(0,q.jsx)(W,{value:`system`,children:`System`})]})]})}),(0,q.jsx)(J,{label:`Cursor style`,children:(0,q.jsxs)(gt,{value:e.cursorPackage,onValueChange:e=>k({cursorPackage:e}),children:[(0,q.jsx)(U,{className:`w-36`,children:(0,q.jsx)(H,{})}),(0,q.jsx)(ht,{children:Ve.map(e=>(0,q.jsx)(W,{value:e.id,children:e.label},e.id))})]})}),(0,q.jsx)(J,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,q.jsx)(Ft,{id:`ui-font-size`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onCommit:e=>k({uiFontSize:e})})}),(0,q.jsx)(J,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,q.jsx)(Ft,{id:`terminal-font-size`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onCommit:e=>k({terminalFontSize:e})})}),(0,q.jsx)(J,{label:`Editor font size`,htmlFor:`editor-font-size`,children:(0,q.jsx)(Ft,{id:`editor-font-size`,min:9,max:32,step:.5,className:`w-20 tabular-nums`,value:e.editorFontSize,onCommit:e=>k({editorFontSize:e})})}),(0,q.jsx)(J,{label:`Density`,children:(0,q.jsxs)(gt,{value:e.density,onValueChange:e=>k({density:e}),children:[(0,q.jsx)(U,{className:`w-36`,children:(0,q.jsx)(H,{})}),(0,q.jsxs)(ht,{children:[(0,q.jsx)(W,{value:`compact`,children:`Compact`}),(0,q.jsx)(W,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,q.jsx)(J,{label:`Project-based layout`,description:`Editor layouts are separated across projects.`,htmlFor:`project-based-layout`,children:(0,q.jsx)(V,{id:`project-based-layout`,checked:e.projectBasedLayout,onCheckedChange:e=>k({projectBasedLayout:e})})}),(0,q.jsx)(J,{label:`All projects in the session list`,description:`Right sidebar displays sessions from all projects.`,htmlFor:`show-all-project-sessions`,children:(0,q.jsx)(V,{id:`show-all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>k({showAllProjectSessions:e})})})]})}function Lt({profile:e}){let t=y(),[n,r]=(0,K.useState)(!1),i=n=>{t.mutate({id:e.id,icon:n},{onError:e=>G(e)}),r(!1)};return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(J,{label:`Icon`,children:(0,q.jsxs)(St,{open:n,onOpenChange:r,children:[(0,q.jsx)(xt,{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)(Re,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,q.jsx)(bt,{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:()=>i(null),className:R(`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)(Re,{icon:null,colour:null,className:`size-4`})}),xe.map(({name:t,Icon:n})=>(0,q.jsx)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:R(`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)(J,{label:`Icon colour`,children:(0,q.jsx)(me,{value:e.icon_colour,onChange:n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>G(e)}),label:`Icon colour`})})]})}var Rt=`__none__`;function zt(){let e=A(),t=C().data?.find(t=>t.id===e),n=d(e??void 0),r=g(e??void 0),i=y(),a=D(e??``),s=o(),[c,l]=(0,K.useState)(``),[u,f]=(0,K.useState)(``),[p,m]=(0,K.useState)(!1),[h,_]=(0,K.useState)(``);if((0,K.useEffect)(()=>{t&&(l(t.name),f(t.branch_prefix))},[t]),!t)return null;let v=r.data?.default_account_id;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(Y,{children:`Profile`}),(0,q.jsxs)(J,{label:`Name`,description:`Letters, digits, dot, underscore and hyphen.`,htmlFor:`profile-name`,children:[(0,q.jsx)(L,{id:`profile-name`,value:c,onChange:e=>l(e.target.value),className:`w-44`}),(0,q.jsx)(B,{size:`sm`,variant:`secondary`,disabled:c===t.name||c.trim()===``||i.isPending,onClick:()=>i.mutate({id:t.id,name:c},{onError:e=>G(e)}),children:`Save`})]}),(0,q.jsxs)(J,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,q.jsx)(L,{id:`branch-prefix`,value:u,onChange:e=>f(e.target.value),placeholder:`no prefix`,className:`w-44`}),(0,q.jsx)(B,{size:`sm`,variant:`secondary`,disabled:u===t.branch_prefix||i.isPending,onClick:()=>i.mutate({id:t.id,branch_prefix:u},{onError:e=>G(e)}),children:`Save`})]}),(0,q.jsx)(Lt,{profile:t}),(0,q.jsx)(J,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,q.jsxs)(gt,{value:typeof v==`number`?String(v):Rt,onValueChange:e=>a.mutate({default_account_id:e===Rt?null:Number(e)},{onError:e=>G(e)}),children:[(0,q.jsx)(U,{className:`w-56`,children:(0,q.jsx)(H,{})}),(0,q.jsxs)(ht,{children:[(0,q.jsx)(W,{value:Rt,children:`First available`}),n.data?.map(e=>(0,q.jsx)(W,{value:String(e.id),children:(0,q.jsxs)(`span`,{children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,q.jsx)(J,{label:`Delete profile`,description:`Non-archived sessions block deletion.`,className:`mt-4`,children:(0,q.jsx)(B,{variant:`danger`,size:`sm`,onClick:()=>m(!0),children:`Delete…`})}),(0,q.jsx)(I,{open:p,onOpenChange:e=>{e||(m(!1),_(``))},children:(0,q.jsxs)(N,{children:[(0,q.jsxs)(rt,{children:[(0,q.jsxs)(P,{children:[`Delete profile `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),`?`]}),(0,q.jsx)(F,{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)(pe,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),` to confirm`]}),(0,q.jsx)(L,{id:`delete-confirm-name`,value:h,onChange:e=>_(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(M,{children:[(0,q.jsx)(B,{variant:`ghost`,onClick:()=>{m(!1),_(``)},children:`Cancel`}),(0,q.jsx)(B,{variant:`danger`,disabled:h!==t.name||s.isPending,onClick:()=>s.mutate(t.id,{onSuccess:()=>{pt(),et.set(null)},onError:e=>{m(!1),_(``),G(e)}}),children:`Delete profile`})]})]})})]})}function Bt({agent:e,profileId:t,onClose:n,onCreated:r}){let i=b(),[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(``),l=p(yt(s,150)),u=s.trim(),d=u===``||u.startsWith(`/`)||u.startsWith(`~`),f=a.trim()!==``&&d,m=()=>{!f||i.isPending||i.mutate({profile_id:t,agent_type:e.id,label:a.trim(),...u===``?{}:{import_dir:u}},{onSuccess:e=>{n(),r(e,u!==``)},onError:e=>G(e)})};return(0,q.jsx)(I,{open:!0,onOpenChange:e=>!e&&n(),children:(0,q.jsxs)(N,{children:[(0,q.jsxs)(rt,{children:[(0,q.jsxs)(P,{children:[`Add a `,e.display_name,` account`]}),(0,q.jsxs)(F,{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)(L,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>o(e.target.value)}),(0,q.jsx)(ge,{value:s,onValueChange:c,placeholder:`(optional) existing config dir, e.g. ~/.claude`,hints:(l.data?.entries??[]).map(e=>({value:e.path,label:e.name}))})]}),(0,q.jsxs)(M,{children:[(0,q.jsx)(B,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,q.jsxs)(B,{disabled:!f||i.isPending,onClick:m,children:[(0,q.jsx)(ot,{}),`Add account`]})]})]})})}function Vt({account:e,gateOpen:t,installed:n}){let r=m(),i=h(),a=ee(),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(!1),[u,d]=(0,K.useState)(e.label),f=(0,K.useRef)(null);return(0,K.useEffect)(()=>d(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:f,value:u,onChange:e=>d(e.target.value),onBlur:()=>{let t=u.trim();if(t!==e.label){if(t===``){d(e.label);return}i.mutate({id:e.id,label:t},{onError:t=>{G(t),d(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(d(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:()=>{f.current?.focus(),f.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)(he,{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)(V,{checked:e.skip_permissions_default,onCheckedChange:t=>i.mutate({id:e.id,skip_permissions_default:t},{onError:e=>G(e)})})]}),(0,q.jsxs)(B,{size:`sm`,variant:`secondary`,disabled:r.isPending||!n,onClick:()=>r.mutate(e.id,{onSuccess:e=>s({stream:e.stream,hint:e.hint}),onError:e=>G(e)}),children:[(0,q.jsx)(ye,{}),e.logged_in?`Re-login`:`Login`]}),(0,q.jsxs)(B,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>l(!0),children:[(0,q.jsx)(at,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),o&&(0,q.jsx)(ve,{stream:o.stream,hint:o.hint,label:`${e.agent_type}/${e.label}`,onClose:()=>s(null)}),(0,q.jsx)(I,{open:c,onOpenChange:l,children:(0,q.jsxs)(N,{children:[(0,q.jsxs)(rt,{children:[(0,q.jsxs)(P,{children:[`Delete `,(0,q.jsx)(`span`,{className:`text-fg`,children:e.label}),`?`]}),(0,q.jsx)(F,{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)(M,{children:[(0,q.jsx)(B,{variant:`ghost`,onClick:()=>l(!1),children:`Cancel`}),(0,q.jsx)(B,{variant:`danger`,disabled:a.isPending,onClick:()=>a.mutate(e.id,{onSuccess:()=>l(!1),onError:e=>{l(!1),G(e)}}),children:`Delete account`})]})]})})]})}function Ht(){let e=A(),t=i(),n=d(e??void 0),r=g(e??void 0),a=m(),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(null),u=r.data?.allowSkipPermissions===!0;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(Y,{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)(J,{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)(Vt,{account:t,gateOpen:u&&e.capabilities.skip_permissions,installed:r},t.id)),(0,q.jsx)(`div`,{className:`flex`,children:(0,q.jsxs)(B,{type:`button`,size:`sm`,variant:`secondary`,disabled:!r,onClick:()=>l(e),children:[(0,q.jsx)(ot,{}),`Add account`]})})]})]},e.id)}),o&&(0,q.jsx)(ve,{stream:o.stream,label:o.label,hint:o.hint,onClose:()=>s(null)}),c!==null&&e!==null&&(0,q.jsx)(Bt,{agent:c,profileId:e,onClose:()=>l(null),onCreated:(e,t)=>{if(t){e.logged_in||j.info(`Imported without credentials — press Login to authenticate.`);return}a.mutate(e.id,{onSuccess:t=>s({stream:t.stream,label:`${e.agent_type}/${e.label}`,hint:t.hint}),onError:e=>G(e)})}})]})}function Ut(){let e=r(),t=c(),[n,i]=(0,K.useState)(``);return(0,K.useEffect)(()=>{e.data&&i(e.data.agentPath)},[e.data]),(0,q.jsx)(J,{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)(L,{id:`agent-path`,type:`text`,className:`w-64 text-2xs`,value:n,onChange:e=>i(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function Wt({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=Dt(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)(J,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,q.jsx)(L,{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)(J,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,q.jsx)(V,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,q.jsx)(J,{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)(V,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function Gt(){return(0,q.jsx)(J,{label:`Terminal scrollback`,htmlFor:`scrollback`,children:(0,q.jsx)(Ft,{id:`scrollback`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:He().terminalScrollback,onCommit:e=>k({terminalScrollback:e})})})}function Kt({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)(it,{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)(B,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,q.jsx)(B,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var qt={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 Jt({initial:e,onSave:t,pending:n}){let[r,i]=(0,K.useState)(e),a=r.length>0?r:ae;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)(L,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:ae}),(0,q.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,q.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:dt(qt,a)})]}),(0,q.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:ne.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)(B,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,q.jsx)(B,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(ae),t(ae)},children:`Reset to default`})]})]})}function Yt(){let e=A(),t=C().data?.find(t=>t.id===e),n=g(e??void 0),r=D(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=>G(e)}),u=e=>t=>r.mutate({[e]:t},{onError:e=>G(e)});return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(Y,{children:`Sessions`}),(0,q.jsx)(J,{label:`Skip permission prompts`,htmlFor:`gate`,children:(0,q.jsx)(V,{id:`gate`,checked:c,onCheckedChange:e=>{e?a(!0):l(!1)}})}),(0,q.jsx)(J,{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)(V,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:r.isPending,onCheckedChange:e=>r.mutate({captureSessionEnv:e},{onError:e=>G(e)})})}),(0,q.jsx)(Ut,{}),(0,q.jsx)(Gt,{}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(Y,{children:`New session defaults`}),n.data&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Wt,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>G(e)}),pending:r.isPending},`${e}:agent-seed`),(0,q.jsx)(Wt,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>G(e)}),pending:r.isPending},`${e}:terminal-seed`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(Y,{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)(Kt,{id:`onboarding-template`,label:`New worktree`,description:`Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??oe,defaultText:oe,onSave:u(`onboardingTemplate`),pending:r.isPending},`${e}:onboarding`),(0,q.jsx)(Kt,{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??te,defaultText:te,onSave:u(`concurrentTemplate`),pending:r.isPending},`${e}:concurrent`),(0,q.jsx)(Kt,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot.`,initial:n.data.restartTemplate??re,defaultText:re,onSave:u(`restartTemplate`),pending:r.isPending},`${e}:restart`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(Y,{children:`Tab title`}),n.data&&(0,q.jsx)(Jt,{initial:n.data.tabTitleTemplate||"${name}",onSave:u(`tabTitleTemplate`),pending:r.isPending},`${e}:tab-title`)]}),(0,q.jsx)(I,{open:i,onOpenChange:e=>{e||(a(!1),s(``))},children:(0,q.jsxs)(N,{children:[(0,q.jsxs)(rt,{children:[(0,q.jsxs)(P,{className:`flex items-center gap-2`,children:[(0,q.jsx)(jt,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,q.jsx)(F,{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)(pe,{htmlFor:`confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t?.name}),` to confirm`]}),(0,q.jsx)(L,{id:`confirm-name`,value:o,onChange:e=>s(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(M,{children:[(0,q.jsx)(B,{variant:`ghost`,onClick:()=>{a(!1),s(``)},children:`Cancel`}),(0,q.jsx)(B,{variant:`danger`,disabled:o!==t?.name||r.isPending,onClick:()=>l(!0),children:`Open the gate`})]})]})})]})}var Xt=ie.parse({});function Zt(){let[e,t]=(0,K.useState)(Oe);return(0,K.useEffect)(()=>{let e=()=>t(Oe());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(Oe())]}function Qt({permission:e,onRequest:t}){return e===`granted`||e===`unverified`?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 $t(){let e=A(),t=g(e??void 0),n=D(e??``),r=v(e??void 0),[i,a]=Zt(),o=Ne(),[s,c]=(0,K.useState)(!1);(0,K.useEffect)(()=>{je();let e=()=>void je();return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]);let l=ie.catch(Xt).parse(t.data?.notifications??{}),u=e=>n.mutate({notifications:e},{onError:e=>G(e)}),d=()=>{Xe()?.showNotification||typeof Notification>`u`||Notification.requestPermission().then(a)};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(Y,{children:`Notifications`}),(0,q.jsx)(J,{label:`Agent notifications`,htmlFor:`notify-desktop`,children:(0,q.jsx)(V,{id:`notify-desktop`,checked:l.desktop,onCheckedChange:e=>{e&&d(),u({...l,desktop:e})}})}),l.desktop&&(0,q.jsx)(Qt,{permission:i,onRequest:d}),(0,q.jsx)(J,{label:`Notify while interacting with a session`,htmlFor:`notify-focused`,description:`When off, typing or clicking in a session silences its desktop alerts for five seconds. Mobile Web Push is configured separately on each device.`,children:(0,q.jsx)(V,{id:`notify-focused`,checked:l.when_focused,onCheckedChange:e=>u({...l,when_focused:e})})}),(0,q.jsx)(J,{label:`Test delivery`,description:`Send a notification to check this device’s permissions.`,children:(0,q.jsx)(B,{variant:`ghost`,disabled:s,onClick:()=>{c(!0),(async()=>{!Xe()?.showNotification&&typeof Notification<`u`&&Notification.permission==="default"&&(await Notification.requestPermission(),a()),await Fe({id:`puddle-test`,title:`Puddle`,body:`Notifications are working on this device.`},()=>{})})().catch(G).finally(()=>c(!1))},children:s?`Sending…`:`Send test`})}),(0,q.jsx)(`p`,{role:`status`,className:`pb-2 text-xs text-fg-muted`,children:o.state===`shown`?`The system accepted the notification. Banner visibility also depends on Focus / Do Not Disturb.`:o.message??`Delivery has not been tested on this device.`}),(0,q.jsx)(J,{label:`Sound`,htmlFor:`notify-sound`,children:(0,q.jsx)(V,{id:`notify-sound`,checked:l.sound,onCheckedChange:e=>u({...l,sound:e})})}),(0,q.jsx)(J,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,q.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[l.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)(V,{checked:l.muted_projects.includes(e.id),onCheckedChange:t=>u({...l,muted_projects:t?[...l.muted_projects,e.id]:l.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function en(){let e=A(),t=S(l().data?.protocol),n=Ct(t&&e!==null),[r,i]=(0,K.useState)(null),a=n.data?.providers??[],o=a.find(e=>e.id===r)??a[0];return!t||!e?null:(0,q.jsxs)(`div`,{className:`mt-8`,children:[(0,q.jsx)(Y,{note:`Defaults for this profile on the connected host. Individual files can override them from their tab menu.`,children:`Compilation & running code`}),n.isLoading?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Loading languages…`}):n.isError?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:`Couldn’t load languages.`}):o?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(J,{label:`Language`,htmlFor:`compilation-language`,children:(0,q.jsxs)(gt,{value:o.id,onValueChange:i,children:[(0,q.jsx)(U,{id:`compilation-language`,className:`w-48`,children:(0,q.jsx)(H,{})}),(0,q.jsx)(ht,{children:a.map(e=>(0,q.jsx)(W,{value:e.id,detail:e.available?void 0:`Not installed`,children:e.display_name},e.id))})]})}),!o.available&&(0,q.jsxs)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:[`No supported `,o.display_name,` tool is installed on this host. Saved commands apply when a supported tool is available.`]}),(0,q.jsx)(tn,{request:{profile_id:e,provider:o.id}},`${e}:${o.id}`)]}):(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No languages advertised by this host.`})]})}function tn({request:e}){let t=wt(e),n=f();return t.isLoading?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Loading commands…`}):t.isError?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t.error instanceof Error?t.error.message:`Couldn’t load commands`}):t.data?(0,q.jsx)(Et,{settings:t.data,onSave:async t=>{for(let r of t){let t=await Tt({...e,...r});n.setQueryData([`compilation-defaults`,e],t),await n.invalidateQueries({queryKey:[`compilation-settings`]})}}}):null}function nn(){let e=He();return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(Y,{children:`Editor`}),(0,q.jsx)(J,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,q.jsx)(Ft,{id:`tab-size`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onCommit:e=>k({editorTabSize:e})})}),(0,q.jsx)(J,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,q.jsx)(V,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>k({editorWordWrap:e})})}),(0,q.jsx)(J,{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)(L,{id:`editor-link-host`,type:`text`,placeholder:Ge.get()??`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>k({editorLinkSshHost:e.target.value})})}),(0,q.jsx)(en,{})]})}function rn({value:e,isDefault:t,onRecord:n,onReset:r}){let[i,a]=(0,K.useState)(!1);return(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>a(!0),onBlur:()=>a(!1),onKeyDown:e=>{if(!i)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){a(!1);return}let t=$e(e.nativeEvent);t&&(n(t),a(!1))},className:R(`min-w-24 rounded-md px-2 py-1 text-center font-mono text-xs transition-colors`,i?`bg-action text-action-ink`:`bg-elevated text-fg hover:bg-border/70`),children:i?`Press keys…`:Ze(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)(vt,{className:`size-3.5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function an(){let e=A(),t=g(e??void 0),n=D(e??``),r=t.data?.hotkeys??{},i=(e,t)=>r[e]||t,a=new Map;for(let e of nt){let t=i(e.id,Qe(e));a.set(t,(a.get(t)??0)+1)}let o=(e,t)=>n.mutate({hotkeys:{...r,[e]:t}},{onError:e=>G(e)}),s=e=>{let t={...r};delete t[e],n.mutate({hotkeys:t},{onError:e=>G(e)})};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(Y,{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)(J,{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)(V,{id:`terminal-app-shortcuts`,checked:t.data?.terminalAppShortcuts!==!1,disabled:n.isPending,onCheckedChange:e=>n.mutate({terminalAppShortcuts:e},{onError:e=>G(e)})})}),tt.map(e=>{let t=nt.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,Qe(e)),n=(a.get(t)??0)>1?`Conflicts with another shortcut.`:void 0;return(0,q.jsx)(J,{label:e.label,description:n,descriptionClassName:n?`text-interrupted`:void 0,children:(0,q.jsx)(rn,{value:t,isDefault:!r[e.id],onRecord:t=>o(e.id,t),onReset:()=>s(e.id)})},e.id)})]},e)})]})}var on=e=>[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``);function sn(e,t){let[n,r]=(0,K.useState)(null),[i,a]=(0,K.useState)(!0),[o,s]=(0,K.useState)(``),c=(0,K.useRef)(0),l=(0,K.useRef)(null);(0,K.useEffect)(()=>()=>{c.current+=1},[]),(0,K.useEffect)(()=>{if(n)return;let e=!0;return l.current=null,a(!0),(async()=>{try{let t=on(crypto.getRandomValues(new Uint8Array(32))),n=on(new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(t))));e&&(l.current={code:t,challenge:n})}catch(t){e&&s(t instanceof Error?t.message:`Could not prepare sign-in.`)}finally{e&&a(!1)}})(),()=>{e=!1,l.current=null}},[n]);let u=(0,K.useRef)(t);return(0,K.useEffect)(()=>{u.current=t},[t]),(0,K.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>{c.current+=1,r(null),s(`Sign-in expired. Try again.`)},Math.max(0,n.request.expires-Date.now()));return()=>clearTimeout(e)},[n]),(0,K.useEffect)(()=>{if(!n||e)return;let t=c.current,i=!1,a,o=async()=>{try{if(n.request.expires<=Date.now())throw Error(`Sign-in expired. Try again.`);let{ready:e}=se.parse(await Je(`POST`,`/cockpit/remote/registration`,{service:n.request.service,code:n.code}));if(i||t!==c.current)return;if(n.request.expires<=Date.now())throw Error(`Sign-in expired. Try again.`);e?(r(null),await u.current({t:`enable`,registration:{service:n.request.service,app:n.request.app,code:n.code}})):a=setTimeout(()=>void o(),2e3)}catch(e){if(i||t!==c.current)return;r(null),s(e instanceof Error?e.message:`Sign-in failed. Try again.`)}};return a=setTimeout(()=>void o(),2e3),()=>{i=!0,clearTimeout(a)}},[n,e]),{attempt:n,preparing:i,error:o,begin:(t,n,i)=>{if(!(e||!l.current)){s(``);try{let{code:e,challenge:a}=l.current,o=ce.safeParse({service:t.trim(),app:n.trim(),label:i.trim(),challenge:a,expires:Date.now()+de.invitationMs});if(!o.success)throw Error(`Enter a host name and exact HTTPS application and relay origins.`);let s=o.data,u=`${s.app}/#register=${encodeURIComponent(JSON.stringify(s))}`;c.current+=1,l.current=null,r({request:s,code:e,url:u}),window.open(u,`_blank`,`noopener,noreferrer`)}catch(e){s(e instanceof Error?e.message:`Could not start sign-in.`)}}},cancel:()=>{c.current+=1,l.current=null,a(!0),r(null)}}}function cn({service:e=`https://charles.waddlelabs.ai`,app:t=`https://puddle.waddlelabs.ai`,hostName:n,busy:r,disabled:i,enable:a,cancel:o}){let[s,c]=(0,K.useState)(e),[l,u]=(0,K.useState)(t),[d,f]=(0,K.useState)(n),p=sn(i,a),m=i||p.preparing||!!p.attempt;return(0,q.jsxs)(`form`,{className:`mt-4 space-y-4`,onSubmit:e=>{e.preventDefault(),m||p.begin(s,l,d)},children:[(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[`Application origin`,(0,q.jsx)(L,{type:`url`,required:!0,value:l,onChange:e=>u(e.target.value),placeholder:`https://app.example.com`,autoComplete:`off`,disabled:m})]}),(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[`Relay origin`,(0,q.jsx)(L,{type:`url`,required:!0,value:s,onChange:e=>c(e.target.value),placeholder:`https://relay.example.com`,autoComplete:`off`,disabled:m})]}),(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[`Host name`,(0,q.jsx)(L,{required:!0,maxLength:80,value:d,onChange:e=>f(e.target.value),disabled:m})]}),o&&(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Saving a new registration revokes existing browser approvals and invitations.`}),p.error&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:p.error}),p.attempt?(0,q.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,q.jsxs)(`p`,{role:`status`,children:[`Confirm this host in your browser. Match request`,` `,(0,q.jsx)(`strong`,{className:`font-mono`,children:p.attempt.request.challenge.slice(0,8).toUpperCase()}),`. Sign-in expires in five minutes.`]}),(0,q.jsx)(`a`,{href:p.attempt.url,target:`_blank`,rel:`noreferrer`,className:`text-accent hover:opacity-80`,children:`Continue in browser ↗`}),(0,q.jsx)(B,{type:`button`,variant:`ghost`,onClick:p.cancel,children:`Cancel sign-in`})]}):(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(B,{type:`submit`,disabled:m||!d.trim()||!s||!l,children:r?`Enabling…`:p.preparing?`Preparing sign-in…`:`Sign in and enable`}),o&&(0,q.jsx)(B,{type:`button`,variant:`ghost`,disabled:m,onClick:o,children:`Cancel`})]})]})}var ln=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),X=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),un=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),dn=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),fn=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),pn=t((e=>{var t=X().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),mn=t((e=>{var t=X().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),hn=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),gn=t((e=>{var t=un(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),_n=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),vn=t((e=>{var t=_n();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),yn=t(((e,t)=>{var n=vn();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),bn=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),xn=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
1
+ import{r as e,t}from"./rolldown-runtime-QTnfLwEv.js";import{t as n}from"./react-CZI7_Jkm.js";import{A as r,E as i,G as a,H as o,I as s,Q as c,R as l,St as u,T as d,Tt as f,W as p,Y as m,Z as h,at as g,c as _,ct as v,et as y,j as b,mt as x,n as S,ot as C,pt as w,q as T,rt as E,tt as D,x as O,z as ee}from"./protocol-support-CsLR9u7d.js";import{B as te,G as ne,H as re,Q as ie,U as ae,V as oe,_ as se,g as ce,h as le,q as ue,v as de,y as fe}from"./auth-olLlgxc3.js";import{c as pe,i as me,o as he,r as ge,s as _e}from"./LazyTerminal-BRdmWa8z.js";import{C as ve,O as ye,S as be,T as xe,_ as Se,a as Ce,b as we,c as Te,d as Ee,f as De,i as Oe,l as ke,m as Ae,n as je,o as Me,r as Ne,s as Pe,t as Fe,u as Ie,v as Le,w as Re,x as ze,y as Be}from"./notification-delivery-C9wsvfQY.js";import{a as Ve,i as He,r as k,t as Ue}from"./client-settings-CwqpIric.js";import{t as We}from"./jsx-runtime-By8HlURe.js";import{d as Ge,o as Ke,t as qe}from"./index-ByBNBhsx.js";import{n as Je,t as Ye}from"./api-BOuyloUi.js";import{_ as Xe,a as Ze,f as Qe,g as A,i as $e,m as et,n as tt,t as nt}from"./hotkeys-Cu0t6sbz.js";import{n as j}from"./dist-BOS6OKSE.js";import{a as rt,i as M,n as N,o as P,r as F,t as I}from"./dialog-IU2fjIs9.js";import{n as L,r as it}from"./chevron-right-BP2NLwlG.js";import{n as at,r as ot}from"./dist-BHBQY7ao.js";import{n as R,t as z}from"./createLucideIcon-C9A1vLE-.js";import{t as B}from"./button-q0ardkfx.js";import{a as st,c as ct,i as lt,l as ut,n as dt,o as ft,r as pt,t as V,u as mt}from"./switch-DihTSmnc.js";import{a as H,i as U,n as ht,r as W,t as gt}from"./select-C0UTbo8D.js";import{t as _t}from"./code-Cf4ftdOa.js";import{t as vt}from"./rotate-ccw-BI2k_h3A.js";import{r as G}from"./ws-Dgc69_w8.js";import{t as yt}from"./use-debounced-value-C86N-mOK.js";import{n as bt,r as xt,t as St}from"./popover-B5Bw2ljC.js";import{a as Ct,o as wt,r as Tt,t as Et,u as Dt}from"./CompilationCommandForm-C71yC-_B.js";var Ot=z(`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`}]]),kt=z(`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`}]]),At=z(`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`}]]),jt=z(`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`}]]),Mt=z(`shield-check`,[[`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:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Nt=z(`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`}]]),Pt=z(`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(n(),1),q=We();function Ft({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)(L,{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 J({label:e,description:t,descriptionClassName:n,htmlFor:r,children:i,className:a}){return(0,q.jsxs)(`div`,{className:R(`flex items-center gap-4 py-2.5`,a),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:R(`text-xs text-fg-muted`,n),children:t})]}),(0,q.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:i})]})}function Y({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 It(){let e=He(),[t,n]=(0,K.useState)(Ke());return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(Y,{children:`Appearance`}),(0,q.jsx)(J,{label:`Theme`,children:(0,q.jsxs)(gt,{value:t,onValueChange:e=>{n(e),qe(e)},children:[(0,q.jsx)(U,{className:`w-32`,children:(0,q.jsx)(H,{})}),(0,q.jsxs)(ht,{children:[(0,q.jsx)(W,{value:`dark`,children:`Dark`}),(0,q.jsx)(W,{value:`light`,children:`Light`}),(0,q.jsx)(W,{value:`system`,children:`System`})]})]})}),(0,q.jsx)(J,{label:`Cursor style`,children:(0,q.jsxs)(gt,{value:e.cursorPackage,onValueChange:e=>k({cursorPackage:e}),children:[(0,q.jsx)(U,{className:`w-36`,children:(0,q.jsx)(H,{})}),(0,q.jsx)(ht,{children:Ve.map(e=>(0,q.jsx)(W,{value:e.id,children:e.label},e.id))})]})}),(0,q.jsx)(J,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,q.jsx)(Ft,{id:`ui-font-size`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onCommit:e=>k({uiFontSize:e})})}),(0,q.jsx)(J,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,q.jsx)(Ft,{id:`terminal-font-size`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onCommit:e=>k({terminalFontSize:e})})}),(0,q.jsx)(J,{label:`Editor font size`,htmlFor:`editor-font-size`,children:(0,q.jsx)(Ft,{id:`editor-font-size`,min:9,max:32,step:.5,className:`w-20 tabular-nums`,value:e.editorFontSize,onCommit:e=>k({editorFontSize:e})})}),(0,q.jsx)(J,{label:`Density`,children:(0,q.jsxs)(gt,{value:e.density,onValueChange:e=>k({density:e}),children:[(0,q.jsx)(U,{className:`w-36`,children:(0,q.jsx)(H,{})}),(0,q.jsxs)(ht,{children:[(0,q.jsx)(W,{value:`compact`,children:`Compact`}),(0,q.jsx)(W,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,q.jsx)(J,{label:`Project-based layout`,description:`Editor layouts are separated across projects.`,htmlFor:`project-based-layout`,children:(0,q.jsx)(V,{id:`project-based-layout`,checked:e.projectBasedLayout,onCheckedChange:e=>k({projectBasedLayout:e})})}),(0,q.jsx)(J,{label:`All projects in the session list`,description:`Right sidebar displays sessions from all projects.`,htmlFor:`show-all-project-sessions`,children:(0,q.jsx)(V,{id:`show-all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>k({showAllProjectSessions:e})})})]})}function Lt({profile:e}){let t=y(),[n,r]=(0,K.useState)(!1),i=n=>{t.mutate({id:e.id,icon:n},{onError:e=>G(e)}),r(!1)};return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(J,{label:`Icon`,children:(0,q.jsxs)(St,{open:n,onOpenChange:r,children:[(0,q.jsx)(xt,{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)(Re,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,q.jsx)(bt,{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:()=>i(null),className:R(`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)(Re,{icon:null,colour:null,className:`size-4`})}),xe.map(({name:t,Icon:n})=>(0,q.jsx)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:R(`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)(J,{label:`Icon colour`,children:(0,q.jsx)(me,{value:e.icon_colour,onChange:n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>G(e)}),label:`Icon colour`})})]})}var Rt=`__none__`;function zt(){let e=A(),t=C().data?.find(t=>t.id===e),n=d(e??void 0),r=g(e??void 0),i=y(),a=D(e??``),s=o(),[c,l]=(0,K.useState)(``),[u,f]=(0,K.useState)(``),[p,m]=(0,K.useState)(!1),[h,_]=(0,K.useState)(``);if((0,K.useEffect)(()=>{t&&(l(t.name),f(t.branch_prefix))},[t]),!t)return null;let v=r.data?.default_account_id;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(Y,{children:`Profile`}),(0,q.jsxs)(J,{label:`Name`,description:`Letters, digits, dot, underscore and hyphen.`,htmlFor:`profile-name`,children:[(0,q.jsx)(L,{id:`profile-name`,value:c,onChange:e=>l(e.target.value),className:`w-44`}),(0,q.jsx)(B,{size:`sm`,variant:`secondary`,disabled:c===t.name||c.trim()===``||i.isPending,onClick:()=>i.mutate({id:t.id,name:c},{onError:e=>G(e)}),children:`Save`})]}),(0,q.jsxs)(J,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,q.jsx)(L,{id:`branch-prefix`,value:u,onChange:e=>f(e.target.value),placeholder:`no prefix`,className:`w-44`}),(0,q.jsx)(B,{size:`sm`,variant:`secondary`,disabled:u===t.branch_prefix||i.isPending,onClick:()=>i.mutate({id:t.id,branch_prefix:u},{onError:e=>G(e)}),children:`Save`})]}),(0,q.jsx)(Lt,{profile:t}),(0,q.jsx)(J,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,q.jsxs)(gt,{value:typeof v==`number`?String(v):Rt,onValueChange:e=>a.mutate({default_account_id:e===Rt?null:Number(e)},{onError:e=>G(e)}),children:[(0,q.jsx)(U,{className:`w-56`,children:(0,q.jsx)(H,{})}),(0,q.jsxs)(ht,{children:[(0,q.jsx)(W,{value:Rt,children:`First available`}),n.data?.map(e=>(0,q.jsx)(W,{value:String(e.id),children:(0,q.jsxs)(`span`,{children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,q.jsx)(J,{label:`Delete profile`,description:`Non-archived sessions block deletion.`,className:`mt-4`,children:(0,q.jsx)(B,{variant:`danger`,size:`sm`,onClick:()=>m(!0),children:`Delete…`})}),(0,q.jsx)(I,{open:p,onOpenChange:e=>{e||(m(!1),_(``))},children:(0,q.jsxs)(N,{children:[(0,q.jsxs)(rt,{children:[(0,q.jsxs)(P,{children:[`Delete profile `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),`?`]}),(0,q.jsx)(F,{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)(pe,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),` to confirm`]}),(0,q.jsx)(L,{id:`delete-confirm-name`,value:h,onChange:e=>_(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(M,{children:[(0,q.jsx)(B,{variant:`ghost`,onClick:()=>{m(!1),_(``)},children:`Cancel`}),(0,q.jsx)(B,{variant:`danger`,disabled:h!==t.name||s.isPending,onClick:()=>s.mutate(t.id,{onSuccess:()=>{pt(),et.set(null)},onError:e=>{m(!1),_(``),G(e)}}),children:`Delete profile`})]})]})})]})}function Bt({agent:e,profileId:t,onClose:n,onCreated:r}){let i=b(),[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(``),l=p(yt(s,150)),u=s.trim(),d=u===``||u.startsWith(`/`)||u.startsWith(`~`),f=a.trim()!==``&&d,m=()=>{!f||i.isPending||i.mutate({profile_id:t,agent_type:e.id,label:a.trim(),...u===``?{}:{import_dir:u}},{onSuccess:e=>{n(),r(e,u!==``)},onError:e=>G(e)})};return(0,q.jsx)(I,{open:!0,onOpenChange:e=>!e&&n(),children:(0,q.jsxs)(N,{children:[(0,q.jsxs)(rt,{children:[(0,q.jsxs)(P,{children:[`Add a `,e.display_name,` account`]}),(0,q.jsxs)(F,{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)(L,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>o(e.target.value)}),(0,q.jsx)(ge,{value:s,onValueChange:c,placeholder:`(optional) existing config dir, e.g. ~/.claude`,hints:(l.data?.entries??[]).map(e=>({value:e.path,label:e.name}))})]}),(0,q.jsxs)(M,{children:[(0,q.jsx)(B,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,q.jsxs)(B,{disabled:!f||i.isPending,onClick:m,children:[(0,q.jsx)(ot,{}),`Add account`]})]})]})})}function Vt({account:e,gateOpen:t,installed:n}){let r=m(),i=h(),a=ee(),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(!1),[u,d]=(0,K.useState)(e.label),f=(0,K.useRef)(null);return(0,K.useEffect)(()=>d(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:f,value:u,onChange:e=>d(e.target.value),onBlur:()=>{let t=u.trim();if(t!==e.label){if(t===``){d(e.label);return}i.mutate({id:e.id,label:t},{onError:t=>{G(t),d(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(d(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:()=>{f.current?.focus(),f.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)(he,{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)(V,{checked:e.skip_permissions_default,onCheckedChange:t=>i.mutate({id:e.id,skip_permissions_default:t},{onError:e=>G(e)})})]}),(0,q.jsxs)(B,{size:`sm`,variant:`secondary`,disabled:r.isPending||!n,onClick:()=>r.mutate(e.id,{onSuccess:e=>s({stream:e.stream,hint:e.hint}),onError:e=>G(e)}),children:[(0,q.jsx)(ye,{}),e.logged_in?`Re-login`:`Login`]}),(0,q.jsxs)(B,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>l(!0),children:[(0,q.jsx)(at,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),o&&(0,q.jsx)(ve,{stream:o.stream,hint:o.hint,label:`${e.agent_type}/${e.label}`,onClose:()=>s(null)}),(0,q.jsx)(I,{open:c,onOpenChange:l,children:(0,q.jsxs)(N,{children:[(0,q.jsxs)(rt,{children:[(0,q.jsxs)(P,{children:[`Delete `,(0,q.jsx)(`span`,{className:`text-fg`,children:e.label}),`?`]}),(0,q.jsx)(F,{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)(M,{children:[(0,q.jsx)(B,{variant:`ghost`,onClick:()=>l(!1),children:`Cancel`}),(0,q.jsx)(B,{variant:`danger`,disabled:a.isPending,onClick:()=>a.mutate(e.id,{onSuccess:()=>l(!1),onError:e=>{l(!1),G(e)}}),children:`Delete account`})]})]})})]})}function Ht(){let e=A(),t=i(),n=d(e??void 0),r=g(e??void 0),a=m(),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(null),u=r.data?.allowSkipPermissions===!0;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(Y,{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)(J,{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)(Vt,{account:t,gateOpen:u&&e.capabilities.skip_permissions,installed:r},t.id)),(0,q.jsx)(`div`,{className:`flex`,children:(0,q.jsxs)(B,{type:`button`,size:`sm`,variant:`secondary`,disabled:!r,onClick:()=>l(e),children:[(0,q.jsx)(ot,{}),`Add account`]})})]})]},e.id)}),o&&(0,q.jsx)(ve,{stream:o.stream,label:o.label,hint:o.hint,onClose:()=>s(null)}),c!==null&&e!==null&&(0,q.jsx)(Bt,{agent:c,profileId:e,onClose:()=>l(null),onCreated:(e,t)=>{if(t){e.logged_in||j.info(`Imported without credentials — press Login to authenticate.`);return}a.mutate(e.id,{onSuccess:t=>s({stream:t.stream,label:`${e.agent_type}/${e.label}`,hint:t.hint}),onError:e=>G(e)})}})]})}function Ut(){let e=r(),t=c(),[n,i]=(0,K.useState)(``);return(0,K.useEffect)(()=>{e.data&&i(e.data.agentPath)},[e.data]),(0,q.jsx)(J,{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)(L,{id:`agent-path`,type:`text`,className:`w-64 text-2xs`,value:n,onChange:e=>i(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function Wt({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=Dt(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)(J,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,q.jsx)(L,{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)(J,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,q.jsx)(V,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,q.jsx)(J,{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)(V,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function Gt(){return(0,q.jsx)(J,{label:`Terminal scrollback`,htmlFor:`scrollback`,children:(0,q.jsx)(Ft,{id:`scrollback`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:He().terminalScrollback,onCommit:e=>k({terminalScrollback:e})})})}function Kt({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)(it,{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)(B,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,q.jsx)(B,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var qt={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 Jt({initial:e,onSave:t,pending:n}){let[r,i]=(0,K.useState)(e),a=r.length>0?r:ae;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)(L,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:ae}),(0,q.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,q.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:dt(qt,a)})]}),(0,q.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:ne.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)(B,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,q.jsx)(B,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(ae),t(ae)},children:`Reset to default`})]})]})}function Yt(){let e=A(),t=C().data?.find(t=>t.id===e),n=g(e??void 0),r=D(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=>G(e)}),u=e=>t=>r.mutate({[e]:t},{onError:e=>G(e)});return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(Y,{children:`Sessions`}),(0,q.jsx)(J,{label:`Skip permission prompts`,htmlFor:`gate`,children:(0,q.jsx)(V,{id:`gate`,checked:c,onCheckedChange:e=>{e?a(!0):l(!1)}})}),(0,q.jsx)(J,{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)(V,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:r.isPending,onCheckedChange:e=>r.mutate({captureSessionEnv:e},{onError:e=>G(e)})})}),(0,q.jsx)(Ut,{}),(0,q.jsx)(Gt,{}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(Y,{children:`New session defaults`}),n.data&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Wt,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>G(e)}),pending:r.isPending},`${e}:agent-seed`),(0,q.jsx)(Wt,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>G(e)}),pending:r.isPending},`${e}:terminal-seed`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(Y,{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)(Kt,{id:`onboarding-template`,label:`New worktree`,description:`Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??oe,defaultText:oe,onSave:u(`onboardingTemplate`),pending:r.isPending},`${e}:onboarding`),(0,q.jsx)(Kt,{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??te,defaultText:te,onSave:u(`concurrentTemplate`),pending:r.isPending},`${e}:concurrent`),(0,q.jsx)(Kt,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot.`,initial:n.data.restartTemplate??re,defaultText:re,onSave:u(`restartTemplate`),pending:r.isPending},`${e}:restart`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(Y,{children:`Tab title`}),n.data&&(0,q.jsx)(Jt,{initial:n.data.tabTitleTemplate||"${name}",onSave:u(`tabTitleTemplate`),pending:r.isPending},`${e}:tab-title`)]}),(0,q.jsx)(I,{open:i,onOpenChange:e=>{e||(a(!1),s(``))},children:(0,q.jsxs)(N,{children:[(0,q.jsxs)(rt,{children:[(0,q.jsxs)(P,{className:`flex items-center gap-2`,children:[(0,q.jsx)(jt,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,q.jsx)(F,{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)(pe,{htmlFor:`confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t?.name}),` to confirm`]}),(0,q.jsx)(L,{id:`confirm-name`,value:o,onChange:e=>s(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(M,{children:[(0,q.jsx)(B,{variant:`ghost`,onClick:()=>{a(!1),s(``)},children:`Cancel`}),(0,q.jsx)(B,{variant:`danger`,disabled:o!==t?.name||r.isPending,onClick:()=>l(!0),children:`Open the gate`})]})]})})]})}var Xt=ie.parse({});function Zt(){let[e,t]=(0,K.useState)(Oe);return(0,K.useEffect)(()=>{let e=()=>t(Oe());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(Oe())]}function Qt({permission:e,onRequest:t}){return e===`granted`||e===`unverified`?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 $t(){let e=A(),t=g(e??void 0),n=D(e??``),r=v(e??void 0),[i,a]=Zt(),o=Ne(),[s,c]=(0,K.useState)(!1);(0,K.useEffect)(()=>{je();let e=()=>void je();return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]);let l=ie.catch(Xt).parse(t.data?.notifications??{}),u=e=>n.mutate({notifications:e},{onError:e=>G(e)}),d=()=>{Xe()?.showNotification||typeof Notification>`u`||Notification.requestPermission().then(a)};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(Y,{children:`Notifications`}),(0,q.jsx)(J,{label:`Agent notifications`,htmlFor:`notify-desktop`,children:(0,q.jsx)(V,{id:`notify-desktop`,checked:l.desktop,onCheckedChange:e=>{e&&d(),u({...l,desktop:e})}})}),l.desktop&&(0,q.jsx)(Qt,{permission:i,onRequest:d}),(0,q.jsx)(J,{label:`Notify while interacting with a session`,htmlFor:`notify-focused`,description:`When off, typing or clicking in a session silences its desktop alerts for five seconds. Mobile Web Push is configured separately on each device.`,children:(0,q.jsx)(V,{id:`notify-focused`,checked:l.when_focused,onCheckedChange:e=>u({...l,when_focused:e})})}),(0,q.jsx)(J,{label:`Test delivery`,description:`Send a notification to check this device’s permissions.`,children:(0,q.jsx)(B,{variant:`ghost`,disabled:s,onClick:()=>{c(!0),(async()=>{!Xe()?.showNotification&&typeof Notification<`u`&&Notification.permission==="default"&&(await Notification.requestPermission(),a()),await Fe({id:`puddle-test`,title:`Puddle`,body:`Notifications are working on this device.`},()=>{})})().catch(G).finally(()=>c(!1))},children:s?`Sending…`:`Send test`})}),(0,q.jsx)(`p`,{role:`status`,className:`pb-2 text-xs text-fg-muted`,children:o.state===`shown`?`The system accepted the notification. Banner visibility also depends on Focus / Do Not Disturb.`:o.message??`Delivery has not been tested on this device.`}),(0,q.jsx)(J,{label:`Sound`,htmlFor:`notify-sound`,children:(0,q.jsx)(V,{id:`notify-sound`,checked:l.sound,onCheckedChange:e=>u({...l,sound:e})})}),(0,q.jsx)(J,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,q.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[l.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)(V,{checked:l.muted_projects.includes(e.id),onCheckedChange:t=>u({...l,muted_projects:t?[...l.muted_projects,e.id]:l.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function en(){let e=A(),t=S(l().data?.protocol),n=Ct(t&&e!==null),[r,i]=(0,K.useState)(null),a=n.data?.providers??[],o=a.find(e=>e.id===r)??a[0];return!t||!e?null:(0,q.jsxs)(`div`,{className:`mt-8`,children:[(0,q.jsx)(Y,{note:`Defaults for this profile on the connected host. Individual files can override them from their tab menu.`,children:`Compilation & running code`}),n.isLoading?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Loading languages…`}):n.isError?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:`Couldn’t load languages.`}):o?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(J,{label:`Language`,htmlFor:`compilation-language`,children:(0,q.jsxs)(gt,{value:o.id,onValueChange:i,children:[(0,q.jsx)(U,{id:`compilation-language`,className:`w-48`,children:(0,q.jsx)(H,{})}),(0,q.jsx)(ht,{children:a.map(e=>(0,q.jsx)(W,{value:e.id,detail:e.available?void 0:`Not installed`,children:e.display_name},e.id))})]})}),!o.available&&(0,q.jsxs)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:[`No supported `,o.display_name,` tool is installed on this host. Saved commands apply when a supported tool is available.`]}),(0,q.jsx)(tn,{request:{profile_id:e,provider:o.id}},`${e}:${o.id}`)]}):(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No languages advertised by this host.`})]})}function tn({request:e}){let t=wt(e),n=f();return t.isLoading?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Loading commands…`}):t.isError?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t.error instanceof Error?t.error.message:`Couldn’t load commands`}):t.data?(0,q.jsx)(Et,{settings:t.data,onSave:async t=>{for(let r of t){let t=await Tt({...e,...r});n.setQueryData([`compilation-defaults`,e],t),await n.invalidateQueries({queryKey:[`compilation-settings`]})}}}):null}function nn(){let e=He();return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(Y,{children:`Editor`}),(0,q.jsx)(J,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,q.jsx)(Ft,{id:`tab-size`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onCommit:e=>k({editorTabSize:e})})}),(0,q.jsx)(J,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,q.jsx)(V,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>k({editorWordWrap:e})})}),(0,q.jsx)(J,{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)(L,{id:`editor-link-host`,type:`text`,placeholder:Ge.get()??`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>k({editorLinkSshHost:e.target.value})})}),(0,q.jsx)(en,{})]})}function rn({value:e,isDefault:t,onRecord:n,onReset:r}){let[i,a]=(0,K.useState)(!1);return(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>a(!0),onBlur:()=>a(!1),onKeyDown:e=>{if(!i)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){a(!1);return}let t=$e(e.nativeEvent);t&&(n(t),a(!1))},className:R(`min-w-24 rounded-md px-2 py-1 text-center font-mono text-xs transition-colors`,i?`bg-action text-action-ink`:`bg-elevated text-fg hover:bg-border/70`),children:i?`Press keys…`:Ze(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)(vt,{className:`size-3.5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function an(){let e=A(),t=g(e??void 0),n=D(e??``),r=t.data?.hotkeys??{},i=(e,t)=>r[e]||t,a=new Map;for(let e of nt){let t=i(e.id,Qe(e));a.set(t,(a.get(t)??0)+1)}let o=(e,t)=>n.mutate({hotkeys:{...r,[e]:t}},{onError:e=>G(e)}),s=e=>{let t={...r};delete t[e],n.mutate({hotkeys:t},{onError:e=>G(e)})};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(Y,{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)(J,{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)(V,{id:`terminal-app-shortcuts`,checked:t.data?.terminalAppShortcuts!==!1,disabled:n.isPending,onCheckedChange:e=>n.mutate({terminalAppShortcuts:e},{onError:e=>G(e)})})}),tt.map(e=>{let t=nt.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,Qe(e)),n=(a.get(t)??0)>1?`Conflicts with another shortcut.`:void 0;return(0,q.jsx)(J,{label:e.label,description:n,descriptionClassName:n?`text-interrupted`:void 0,children:(0,q.jsx)(rn,{value:t,isDefault:!r[e.id],onRecord:t=>o(e.id,t),onReset:()=>s(e.id)})},e.id)})]},e)})]})}var on=e=>[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``);function sn(e,t){let[n,r]=(0,K.useState)(null),[i,a]=(0,K.useState)(!0),[o,s]=(0,K.useState)(``),c=(0,K.useRef)(0),l=(0,K.useRef)(null);(0,K.useEffect)(()=>()=>{c.current+=1},[]),(0,K.useEffect)(()=>{if(n)return;let e=!0;return l.current=null,a(!0),(async()=>{try{let t=on(crypto.getRandomValues(new Uint8Array(32))),n=on(new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(t))));e&&(l.current={code:t,challenge:n})}catch(t){e&&s(t instanceof Error?t.message:`Could not prepare sign-in.`)}finally{e&&a(!1)}})(),()=>{e=!1,l.current=null}},[n]);let u=(0,K.useRef)(t);return(0,K.useEffect)(()=>{u.current=t},[t]),(0,K.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>{c.current+=1,r(null),s(`Sign-in expired. Try again.`)},Math.max(0,n.request.expires-Date.now()));return()=>clearTimeout(e)},[n]),(0,K.useEffect)(()=>{if(!n||e)return;let t=c.current,i=!1,a,o=async()=>{try{if(n.request.expires<=Date.now())throw Error(`Sign-in expired. Try again.`);let{ready:e}=se.parse(await Je(`POST`,`/cockpit/remote/registration`,{service:n.request.service,code:n.code}));if(i||t!==c.current)return;if(n.request.expires<=Date.now())throw Error(`Sign-in expired. Try again.`);e?(r(null),await u.current({t:`enable`,registration:{service:n.request.service,app:n.request.app,code:n.code}})):a=setTimeout(()=>void o(),2e3)}catch(e){if(i||t!==c.current)return;r(null),s(e instanceof Error?e.message:`Sign-in failed. Try again.`)}};return a=setTimeout(()=>void o(),2e3),()=>{i=!0,clearTimeout(a)}},[n,e]),{attempt:n,preparing:i,error:o,begin:(t,n,i)=>{if(!(e||!l.current)){s(``);try{let{code:e,challenge:a}=l.current,o=ce.safeParse({service:t.trim(),app:n.trim(),label:i.trim(),challenge:a,expires:Date.now()+de.invitationMs});if(!o.success)throw Error(`Enter a host name and exact HTTPS application and relay origins.`);let s=o.data,u=`${s.app}/#register=${encodeURIComponent(JSON.stringify(s))}`;c.current+=1,l.current=null,r({request:s,code:e,url:u}),window.open(u,`_blank`,`noopener,noreferrer`)}catch(e){s(e instanceof Error?e.message:`Could not start sign-in.`)}}},cancel:()=>{c.current+=1,l.current=null,a(!0),r(null)}}}function cn({service:e=`https://charles.waddlelabs.ai`,app:t=`https://puddle.waddlelabs.ai`,hostName:n,busy:r,disabled:i,enable:a,cancel:o}){let[s,c]=(0,K.useState)(e),[l,u]=(0,K.useState)(t),[d,f]=(0,K.useState)(n),p=sn(i,a),m=i||p.preparing||!!p.attempt;return(0,q.jsxs)(`form`,{className:`mt-4 space-y-4`,onSubmit:e=>{e.preventDefault(),m||p.begin(s,l,d)},children:[(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[`Application origin`,(0,q.jsx)(L,{type:`url`,required:!0,value:l,onChange:e=>u(e.target.value),placeholder:`https://app.example.com`,autoComplete:`off`,disabled:m})]}),(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[`Relay origin`,(0,q.jsx)(L,{type:`url`,required:!0,value:s,onChange:e=>c(e.target.value),placeholder:`https://relay.example.com`,autoComplete:`off`,disabled:m})]}),(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[`Host name`,(0,q.jsx)(L,{required:!0,maxLength:80,value:d,onChange:e=>f(e.target.value),disabled:m})]}),o&&(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Saving a new registration revokes existing browser approvals and invitations.`}),p.error&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:p.error}),p.attempt?(0,q.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,q.jsxs)(`p`,{role:`status`,children:[`Confirm this host in your browser. Match request`,` `,(0,q.jsx)(`strong`,{className:`font-mono`,children:p.attempt.request.challenge.slice(0,8).toUpperCase()}),`. Sign-in expires in five minutes.`]}),(0,q.jsx)(`a`,{href:p.attempt.url,target:`_blank`,rel:`noreferrer`,className:`text-accent hover:opacity-80`,children:`Continue in browser ↗`}),(0,q.jsx)(B,{type:`button`,variant:`ghost`,onClick:p.cancel,children:`Cancel sign-in`})]}):(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(B,{type:`submit`,disabled:m||!d.trim()||!s||!l,children:r?`Enabling…`:p.preparing?`Preparing sign-in…`:`Sign in and enable`}),o&&(0,q.jsx)(B,{type:`button`,variant:`ghost`,disabled:m,onClick:o,children:`Cancel`})]})]})}var ln=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),X=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),un=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),dn=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),fn=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),pn=t((e=>{var t=X().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),mn=t((e=>{var t=X().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),hn=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),gn=t((e=>{var t=un(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),_n=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),vn=t((e=>{var t=_n();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),yn=t(((e,t)=>{var n=vn();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),bn=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),xn=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
2
2
  ]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^[0-9]+$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),Z=t((e=>{var t=bn(),n=xn();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),Sn=t((e=>{var t=X(),n=gn(),r=un(),i=Z(),a=bn(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),Cn=t((e=>{var t=X(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),wn=t(((e,t)=>{var n=Z();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),Tn=t(((e,t)=>{var n=Z(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),En=t(((e,t)=>{var n=Z();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),Dn=t(((e,t)=>{var n=Z(),r=X();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
3
3
  Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),On=t(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),kn=t((e=>{var t=Z(),n=wn(),r=Tn(),i=En(),a=Dn(),o=xn(),s=X(),c=On();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
4
4
  Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),An=t((e=>{var t=X(),n=un(),r=dn(),i=fn(),a=pn(),o=mn(),s=hn(),c=gn(),l=yn(),u=Sn(),d=Cn(),f=Z(),p=kn();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/markdown-mermaid-CuwsuNsF.js","assets/rolldown-runtime-QTnfLwEv.js","assets/preload-helper-Czpn1I53.js","assets/index-DdOKMIa5.js","assets/react-CZI7_Jkm.js","assets/react-dom-cJyBB_A4.js","assets/auth-olLlgxc3.js","assets/client-settings-CwqpIric.js","assets/jsx-runtime-By8HlURe.js","assets/index-C3TPFFMc.css","assets/math-CSw6sgCC.js","assets/math-delimiters-BCnTi7Ii.js","assets/purify.es-D8QhFVkO.js","assets/katex.min-ZqdHjttS.js","assets/katex-Dz-67XSV.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./react-dom-cJyBB_A4.js";import{R as r,at as i,o as a}from"./protocol-support-CsLR9u7d.js";import{a as o}from"./auth-olLlgxc3.js";import{i as s}from"./client-settings-CwqpIric.js";import{t as c}from"./jsx-runtime-By8HlURe.js";import{t as l}from"./preload-helper-Czpn1I53.js";import{a as u,c as d,n as f,r as p,s as m}from"./index-DdOKMIa5.js";import{g as h,i as g,o as _,r as ee,s as te}from"./hotkeys-Cu0t6sbz.js";import{n as ne}from"./forward-link-DMvLf0Xw.js";import{n as re}from"./dist-BOS6OKSE.js";import{n as ie}from"./createLucideIcon-C9A1vLE-.js";import{a as ae,i as oe,o as v,s as se,t as y}from"./FindWidget-CaVwYvST.js";import{_ as ce,a as b,b as le,f as ue,i as de,m as x,n as fe,t as pe,v as me,y as he}from"./selection-actions-vwVXE8h8.js";import{t as ge}from"./code-Cf4ftdOa.js";import{r as _e,t as ve}from"./ws-DpgAmFEj.js";import{r as S}from"./math-delimiters-BCnTi7Ii.js";var C=e(t(),1),ye=Object.defineProperty,be=Object.getOwnPropertyDescriptor,xe=(e,t)=>{for(var n in t)ye(e,n,{get:t[n],enumerable:!0})},w=(e,t,n,r)=>{for(var i=r>1?void 0:r?be(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&&ye(t,n,i),i},T=(e,t)=>(n,r)=>t(n,r,e),Se=`Terminal input`,Ce={get:()=>Se,set:e=>Se=e},we=`Too much output to announce, navigate to rows manually to read`,Te={get:()=>we,set:e=>we=e};function Ee(e){return e.replace(/\r?\n/g,`\r`)}function De(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function Oe(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function ke(e,t,n,r){e.stopPropagation(),e.clipboardData&&Ae(e.clipboardData.getData(`text/plain`),t,n,r)}function Ae(e,t,n,r){e=Ee(e),e=De(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function je(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 Me(e,t,n,r,i){je(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 Ne(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 Pe=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}},Fe=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}},Ie=``,Le=` `,Re=class e{constructor(){this.fg=0,this.bg=0,this.extended=new ze}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}},ze=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}},Be=class e extends Re{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ze,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()]}},Ve=`di$target`,He=`di$dependencies`,Ue=new Map;function We(e){return e[He]||[]}function D(e){if(Ue.has(e))return Ue.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Ge(t,e,r)};return t._id=e,Ue.set(e,t),t}function Ge(e,t,n){t[Ve]===t?t[He].push({id:e,index:n}):(t[He]=[{id:e,index:n}],t[Ve]=t)}var O=D(`BufferService`),Ke=D(`CoreMouseService`),qe=D(`CoreService`),Je=D(`CharsetService`),Ye=D(`InstantiationService`),Xe=D(`LogService`),k=D(`OptionsService`),Ze=D(`OscLinkService`),Qe=D(`UnicodeService`),$e=D(`DecorationService`),et=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 Be,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):tt(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)}};et=w([T(0,O),T(1,k),T(2,Ze)],et);function tt(e,t){if(confirm(`Do you want to navigate to ${t}?
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/markdown-mermaid-Bn0a2pwd.js","assets/rolldown-runtime-QTnfLwEv.js","assets/preload-helper-Czpn1I53.js","assets/index-ByBNBhsx.js","assets/react-CZI7_Jkm.js","assets/react-dom-cJyBB_A4.js","assets/auth-olLlgxc3.js","assets/client-settings-CwqpIric.js","assets/jsx-runtime-By8HlURe.js","assets/index-C3TPFFMc.css","assets/math-CSw6sgCC.js","assets/math-delimiters-BCnTi7Ii.js","assets/purify.es-D8QhFVkO.js","assets/katex.min-ZqdHjttS.js","assets/katex-Dz-67XSV.css"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./react-dom-cJyBB_A4.js";import{R as r,at as i,o as a}from"./protocol-support-CsLR9u7d.js";import{a as o}from"./auth-olLlgxc3.js";import{i as s}from"./client-settings-CwqpIric.js";import{t as c}from"./jsx-runtime-By8HlURe.js";import{t as l}from"./preload-helper-Czpn1I53.js";import{a as u,c as d,n as f,r as p,s as m}from"./index-ByBNBhsx.js";import{g as h,i as g,o as _,r as ee,s as te}from"./hotkeys-Cu0t6sbz.js";import{n as ne}from"./forward-link-DMvLf0Xw.js";import{n as re}from"./dist-BOS6OKSE.js";import{n as ie}from"./createLucideIcon-C9A1vLE-.js";import{a as ae,i as oe,o as v,s as se,t as y}from"./FindWidget-CaVwYvST.js";import{_ as ce,a as b,b as le,f as ue,i as de,m as x,n as fe,t as pe,v as me,y as he}from"./selection-actions-C4diprgb.js";import{t as ge}from"./code-Cf4ftdOa.js";import{r as _e,t as ve}from"./ws-Dgc69_w8.js";import{r as S}from"./math-delimiters-BCnTi7Ii.js";var C=e(t(),1),ye=Object.defineProperty,be=Object.getOwnPropertyDescriptor,xe=(e,t)=>{for(var n in t)ye(e,n,{get:t[n],enumerable:!0})},w=(e,t,n,r)=>{for(var i=r>1?void 0:r?be(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&&ye(t,n,i),i},T=(e,t)=>(n,r)=>t(n,r,e),Se=`Terminal input`,Ce={get:()=>Se,set:e=>Se=e},we=`Too much output to announce, navigate to rows manually to read`,Te={get:()=>we,set:e=>we=e};function Ee(e){return e.replace(/\r?\n/g,`\r`)}function De(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function Oe(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function ke(e,t,n,r){e.stopPropagation(),e.clipboardData&&Ae(e.clipboardData.getData(`text/plain`),t,n,r)}function Ae(e,t,n,r){e=Ee(e),e=De(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function je(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 Me(e,t,n,r,i){je(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 Ne(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 Pe=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}},Fe=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}},Ie=``,Le=` `,Re=class e{constructor(){this.fg=0,this.bg=0,this.extended=new ze}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}},ze=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}},Be=class e extends Re{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ze,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()]}},Ve=`di$target`,He=`di$dependencies`,Ue=new Map;function We(e){return e[He]||[]}function D(e){if(Ue.has(e))return Ue.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Ge(t,e,r)};return t._id=e,Ue.set(e,t),t}function Ge(e,t,n){t[Ve]===t?t[He].push({id:e,index:n}):(t[He]=[{id:e,index:n}],t[Ve]=t)}var O=D(`BufferService`),Ke=D(`CoreMouseService`),qe=D(`CoreService`),Je=D(`CharsetService`),Ye=D(`InstantiationService`),Xe=D(`LogService`),k=D(`OptionsService`),Ze=D(`OscLinkService`),Qe=D(`UnicodeService`),$e=D(`DecorationService`),et=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 Be,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):tt(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)}};et=w([T(0,O),T(1,k),T(2,Ze)],et);function tt(e,t){if(confirm(`Do you want to navigate to ${t}?
3
3
 
4
4
  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 nt=D(`CharSizeService`),rt=D(`CoreBrowserService`),it=D(`MouseService`),at=D(`RenderService`),ot=D(`SelectionService`),st=D(`CharacterJoinerService`),ct=D(`ThemeService`),lt=D(`LinkProviderService`),ut=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?gt.isErrorNoTelemetry(e)?new gt(e.message+`
5
5
 
@@ -58,9 +58,9 @@ ${s.join(`
58
58
  `).slice(2).join(`
59
59
  `))}},Zc=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},Qc=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},$c=0,el=class{constructor(e){this.value=e,this.id=$c++}},tl=2,nl,rl=class{constructor(e){this._size=0,this._options=e,this._leakageMon=qc>0||this._options?.leakWarningThreshold?new Yc(e?.onListenerError??mc,this._options?.leakWarningThreshold??qc):void 0,this._perfMon=this._options?._profName?new Kc(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 Qc(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||mc)(n),zc.None}if(this._disposed)return zc.None;t&&(e=e.bind(t));let r=new el(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Xc.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof el?(this._deliveryQueue??=new il,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=Ic(()=>{nl?.unregister(a),i?.(),this._removeListener(r)});if(n instanceof Rc?n.add(a):Array.isArray(n)&&n.push(a),nl){let e=Error().stack.split(`
60
60
  `).slice(2,3).join(`
61
- `).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);nl.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*tl<=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||mc;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 el)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}},il=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}},al=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),ol;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof sl?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Wc.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:al})})(ol||={});var sl=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?al:(this._emitter||=new rl,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},cl=`en`,ll=!1,ul=!1,dl=cl,fl,pl=globalThis,ml;typeof pl.vscode<`u`&&typeof pl.vscode.process<`u`?ml=pl.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(ml=process);var hl=typeof ml?.versions?.electron==`string`&&ml?.type===`renderer`;if(typeof ml==`object`){ml.platform,ml.platform,ll=ml.platform===`linux`,ll&&ml.env.SNAP&&ml.env.SNAP_REVISION,ml.env.CI||ml.env.BUILD_ARTIFACTSTAGINGDIRECTORY,dl=cl;let e=ml.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,dl=t.resolvedLanguage||cl,t.languagePack?.translationsConfigFile}catch{}}else typeof navigator==`object`&&!hl?(fl=navigator.userAgent,fl.indexOf(`Windows`),fl.indexOf(`Macintosh`),(fl.indexOf(`Macintosh`)>=0||fl.indexOf(`iPad`)>=0||fl.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,ll=fl.indexOf(`Linux`)>=0,fl?.indexOf(`Mobi`),ul=!0,dl=globalThis._VSCODE_NLS_LANGUAGE||cl,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);ul&&typeof pl.importScripts==`function`&&pl.origin;var gl=fl,_l=dl,vl;(e=>{function t(){return _l}e.value=t;function n(){return _l.length===2?_l===`en`:_l.length>=3&&_l[0]===`e`&&_l[1]===`n`&&_l[2]===`-`}e.isDefaultVariant=n;function r(){return _l===`en`}e.isDefault=r})(vl||={});var yl=typeof pl.postMessage==`function`&&!pl.importScripts;(()=>{if(yl){let e=[];pl.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}),pl.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var bl=!!(gl&&gl.indexOf(`Chrome`)>=0);gl&&gl.indexOf(`Firefox`),!bl&&gl&&gl.indexOf(`Safari`),gl&&gl.indexOf(`Edg/`),gl&&gl.indexOf(`Android`);function xl(e,t=0,n){let r=setTimeout(()=>{e(),n&&i.dispose()},t),i=Ic(()=>{clearTimeout(r),n?.deleteAndLeak(i)});return n?.add(i),i}(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var Sl;(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})(Sl||={});var Cl=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 rl,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 Wc.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())}};Cl.EMPTY=Cl.fromArray([]);var wl=class extends zc{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new Bc),this._linesCacheDisposables=this._register(new Bc),this._register(Ic(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=Fc(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=xl(()=>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]}},Tl=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}},El=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}},Dl=class extends zc{constructor(e){super(),this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(Ic(()=>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(){Pc(n)}}}clearHighlightDecorations(){Pc(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(()=>Pc(e))),s.push(i)}}return s.length===0?void 0:s}},Ol=class extends zc{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new rl)}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()}},kl=class extends zc{constructor(e){super(),this._highlightTimeout=this._register(new Bc),this._lineCache=this._register(new Bc),this._state=new Tl,this._resultTracker=this._register(new Ol),this._highlightLimit=e?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new wl(e),this._engine=new El(e,this._lineCache.value),this._decorationManager=new Dl(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(Ic(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=xl(()=>{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}};function Al(e){return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)}function jl(){return(0,C.useSyncExternalStore)(Al,()=>document.visibilityState===`visible`)}function Ml(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 Nl(e,t){let n=Ml(t);return n?`\x1b]${e};${n}\x1b\\`:null}function Pl(e,t){let n=[10,11].map(n=>e.parser.registerOscHandler(n,e=>{if(e!==`?`)return!1;if(!t.daemonAnswers&&!t.isReplaying()){let e=Nl(n,t.readColour(n));e&&t.reply(e)}return!0}));return{dispose:()=>n.forEach(e=>e.dispose())}}function Fl(e,t,n=!1){return e.type===`keydown`?n&&Il(e)?!0:t?e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`c`:e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&e.key.toLowerCase()===`c`:!1}function Il(e){return e.type===`keydown`&&e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`c`}function Ll(e){if(!/^https?:\/\//i.test(e)||/[\s<>"`\\\p{Cc}]/u.test(e))return!1;try{return new URL(e).hostname!==``}catch{return!1}}function Rl(e){let t=[];for(let n of e.matchAll(/\bhttps?:\/\/[^\s<>"'`\\{}|^]+/gi)){let e=n[0];for(;e;){let t=e.at(-1),n=t===`)`?`(`:t===`]`?`[`:null;if(/[.,;:!?]/.test(t)||n&&e.split(t).length>e.split(n).length)e=e.slice(0,-1);else break}Ll(e)&&t.push({uri:e,start:n.index,end:n.index+e.length})}return t}function zl(e,t,n,r){let i=Rl(r).at(-1),a=/\bhttps?:\/\/[^\s<>"'`\\{}|^]*$/i.exec(r)?.[0];if(!a||i&&/[\])]/.test(r.slice(i.end)))return!1;let o=t.text.trimStart();if(!o||/^(?:https?:\/\/|~\/|\.{1,2}\/)/i.test(o))return!1;let s=o.split(/\s/,1)[0].replace(/[.,;:!?\])]+$/,``);if(!/^[\p{L}\p{N}_%/?.:#&=+~-]/u.test(s))return!1;let c=/[/_.?&#=%+~-]/.test(s);if(!c&&/\s/.test(o.trimEnd()))return!1;let l=e.cells[e.text.trimEnd().length-1];return a.endsWith(`/`)&&c||l!==void 0&&l.col>=n-9}function Bl(e,t,n){return ce(e,t,n,Rl,zl)}function Vl(e,t){return e.registerLinkProvider({provideLinks(n,r){r(Bl(e.buffer.active,n-1,e.cols).map(({candidate:e,start:n,end:r})=>({range:{start:{x:n.col+1,y:n.row+1},end:{x:r.col+1,y:r.row+1}},text:e.uri,activate:()=>t(e.uri)})))}})}function Hl(e){let t=e.trim(),n=/^<([^<>]+)>$/.exec(t);if(n&&Ll(n[1]))return n[1];let r=/^\[(?:\\.|[^\]\\])*\]\(\s*(?:<([^<>]+)>|([^\s]+))\s*\)$/.exec(t);if(!r)return e;let i=r[1]??r[2];if(r[2]){let t=0;for(let n=0;n<i.length;n++)if(i[n]===`\\`)n++;else if(i[n]===`(`)t++;else if(i[n]===`)`&&--t<0)return e;if(t!==0)return e}let a=i.replace(/\\([!-/:-@[-`{-~])/g,`$1`);return Ll(a)?a:e}function Ul(e){let t=e.getSelection(),n=e.getSelectionPosition();if(n&&/\r?\n/.test(t)){let r=t.trim().replace(/[\t ]*\r?\n[\t ]*/g,``),i=Bl(e.buffer.active,n.start.y,e.cols).find(({candidate:e})=>e.uri===r);if(i)return i.candidate.uri}return Hl(t)}function Wl(e){let t=null,n=null,r=()=>{n?.cancel(),n=null},i=()=>{r(),t=null},a={reset:i,input(e){!e.startsWith(`\x1B[<`)&&!e.startsWith(`\x1B[M`)&&i()},osc(a){if(!e.available())return i(),!0;let o=a.indexOf(`;`);if(o<0)return!0;let s=a.slice(o+1);if(s===`?`)return!0;if(!s)return i(),!0;try{let e=Uint8Array.from(atob(s),e=>e.charCodeAt(0));t=Hl(new TextDecoder(`utf-8`,{fatal:!0}).decode(e)),t&&n?.resolve(t),r()}catch{i()}return!0},key(a){let o=Hl(e.selection()),s=o||t,c=Fl(a,e.isMac,!!s),l=Il(a);if(!c&&!l)return!1;if(o)return r(),e.writeClipboard(o),!0;if(!e.available())return i(),c;if(s)return r(),e.writeClipboard(s),!0;if(!e.mouseTracking())return!1;r();let u=new Promise((e,t)=>{let i=setTimeout(()=>{r()},2e3);n={resolve:t=>{clearTimeout(i),e(t)},cancel:()=>{clearTimeout(i),t(new DOMException(`Copy cancelled`,`AbortError`))}}});return e.writeClipboard(u),e.writeInput(l?``:e.isMac?`\x1B[99;9u`:`\x1B[99;6u`),!0},copy(n){let r=Hl(e.selection()),i=r||t;if(!(!r&&!e.available())){if(!i){a.key({type:`keydown`,key:`c`,metaKey:e.isMac,ctrlKey:!e.isMac,shiftKey:!e.isMac,altKey:!1})&&(n.preventDefault(),n.stopPropagation());return}n.clipboardData&&(n.clipboardData.setData(`text/plain`,i),n.preventDefault(),n.stopPropagation())}}};return a}function Gl(e,t){typeof e!=`string`&&e.catch(()=>{}),(async()=>{if(typeof e==`string`)await navigator.clipboard.writeText(e);else if(typeof ClipboardItem<`u`&&navigator.clipboard?.write){let t=e.then(e=>new Blob([e],{type:`text/plain`}));t.catch(()=>{}),await navigator.clipboard.write([new ClipboardItem({"text/plain":t})])}else await navigator.clipboard.writeText(await e)})().catch(async n=>{if(!(n instanceof DOMException&&n.name===`AbortError`)){if(typeof e!=`string`)try{await e}catch{return}t()}})}function Kl(e){if(e.type!==`keydown`||e.ctrlKey||e.shiftKey)return null;if(e.metaKey&&!e.altKey)switch(e.key){case`ArrowLeft`:return``;case`ArrowRight`:return``;case`Backspace`:return``;case`Delete`:return`\v`}if(e.altKey&&!e.metaKey)switch(e.key){case`ArrowLeft`:return`\x1Bb`;case`ArrowRight`:return`\x1Bf`}return null}var ql=new Set([`localhost`,`127.0.0.1`,`::1`,`[::1]`]);function Jl(e,t,n){if(!n)return e;let r;try{r=new URL(e)}catch{return e}return r.protocol!==`http:`&&r.protocol!==`https:`||!ql.has(r.hostname)?e:`/forward/${t}/${r.port===``?r.protocol===`https:`?`443`:`80`:r.port}?path=${encodeURIComponent(r.pathname+r.search+r.hash)}`}var Yl=1e3,Xl=250;function Zl(e,t){return o(JSON.stringify([e,t]))}function Ql(e){return Number.isFinite(e)?Math.max(0,Math.trunc(e)):0}function $l(e){return Number.isFinite(e)?Math.max(1,Math.trunc(e)):1}function eu(e,t){return t===0?1:Math.max(0,Math.min(1,e/t))}function tu(e,t){let n=Ql(t),r=Math.min(n,Ql(e));return{viewportY:r,atBottom:r>=n}}function nu(e,t){let n=Ql(t);return e.atBottom?n:Math.min(e.viewportY,n)}function ru(e,t,n,r){let i=tu(e,t),a=i.viewportY;if(!i.atBottom)for(;a>0&&r(a);)a--;return{...i,logicalLineY:a,cellOffset:(i.viewportY-a)*$l(n),scrollProgress:eu(i.viewportY,Ql(t))}}function iu(e,t,n,r){let i=Ql(r);if(e.atBottom)return i;if(t===void 0||t<0)return Math.round(e.scrollProgress*i);let a=Ql(t)+Math.floor(e.cellOffset/$l(n));return Math.min(a,i)}var au=class{timer;managedScrolls=0;state;capture(e){if(this.state)return this.arm(Yl),!0;let t=e.buffer.active;if(t.type!==`normal`)return!1;let n=ru(t.viewportY,t.baseY,e.cols,e=>t.getLine(e)?.isWrapped===!0);if(n.atBottom)return!1;let r=t.baseY+t.cursorY;return this.state={anchor:n,marker:e.registerMarker(n.logicalLineY-r),buffer:t.type},this.arm(Yl),!0}restore(e){let t=this.state,n=e.buffer.active;if(!t||n.type!==t.buffer)return null;let r=t.marker.isDisposed?void 0:t.marker.line;return e.scrollToLine(iu(t.anchor,r,e.cols,n.baseY)),r===void 0?(this.arm(Xl),`replaced`):`tracked`}beginManagedScroll(){this.managedScrolls++}endManagedScroll(){this.managedScrolls=Math.max(0,this.managedScrolls-1)}get managingScroll(){return this.managedScrolls>0}release(){this.timer!==void 0&&clearTimeout(this.timer),this.timer=void 0,this.managedScrolls=0,this.state?.marker.dispose(),this.state=void 0}arm(e){this.timer!==void 0&&clearTimeout(this.timer),this.timer=setTimeout(()=>this.release(),e)}},ou=new class{maxEntries;positions=new Map;constructor(e=500){this.maxEntries=e}set(e,t,n,r){let i=Zl(e,t),a=tu(n,r);for(this.positions.delete(i),this.positions.set(i,a);this.positions.size>this.maxEntries;){let e=this.positions.keys().next().value;if(e===void 0)break;this.positions.delete(e)}return a}get(e,t){return this.positions.get(Zl(e,t))}},su=new WeakSet;function cu(e){let t=e._core?._inputHandler,n=t;if(typeof t!=`object`||!t||typeof n?.scrollUp!=`function`||typeof n._eraseAttrData!=`function`||typeof n._bufferService?.scroll!=`function`||typeof n._dirtyRowTracker?.markRangeDirty!=`function`)throw Error(`xterm scrollback internals do not match the pinned 6.0.0 release`);return t}function lu(e){let t=cu(e);if(su.has(t))return;su.add(t);let n=t.scrollUp.bind(t);t.scrollUp=e=>{if(t._activeBuffer.scrollTop!==0)return n(e);let r=e.params[0]||1;for(;r--;){let e=t._activeBuffer.ybase;t._bufferService.scroll(t._eraseAttrData()),t._activeBuffer.savedY+=t._activeBuffer.ybase-e}return t._dirtyRowTracker.markRangeDirty(t._activeBuffer.scrollTop,t._activeBuffer.scrollBottom),!0}}function uu(e,t,n,r){let i=null,a=!1,o=0,s=null,c=0,l=(n,r)=>{let i=t.getBoundingClientRect(),a=Math.max(0,Math.min(e.cols-1,Math.floor((n-i.left)/(i.width/e.cols)))),o=e.buffer.active.viewportY+Math.max(0,Math.min(e.rows-1,Math.floor((r-i.top)/(i.height/e.rows)))),s=e.buffer.active.getLine(o),c=a>0&&s?.getCell(a)?.getWidth()===0?a-1:a;return{row:o,column:c,width:Math.max(1,s?.getCell(c)?.getWidth()??1)}},u=()=>{if(!i||!s)return;let t=l(s.x,s.y),r=t.row*e.cols+t.column,a=Math.min(i.start,r),o=Math.max(i.end,r+t.width);e.select(a%e.cols,Math.floor(a/e.cols),o-a),n(e.getSelection())},d=()=>{cancelAnimationFrame(o),o=0,s=null},f=n=>{if(o=0,!s)return;let i=t.getBoundingClientRect(),a=s.y<i.top?-1:+(s.y>=i.bottom);a&&n-c>=50&&e.buffer.active.type===`normal`&&(c=n,r(),e.scrollLines(a),u()),o=requestAnimationFrame(f)},p=e.onSelectionChange(()=>{a&&n(e.getSelection())});return{begin(t,r){let o=l(t,r),s=e.buffer.active.getLine(o.row),c=o.column,u=o.column+o.width,d=e=>{let t=s?.getCell(e);return t&&(t.getWidth()===0||/\S/u.test(t.getChars()))};if(d(c)){for(;c>0&&d(c-1);)c--;for(;u<e.cols&&d(u);)u++}i={start:o.row*e.cols+c,end:o.row*e.cols+u},a=!0,e.select(c,o.row,u-c),n(e.getSelection())},extend(e,t){s={x:e,y:t},u(),o||=requestAnimationFrame(f)},stop:d,clear:()=>{d(),i=null,a=!1,e.clearSelection(),n(null)},dispose(){d(),p.dispose()}}}var du=8;function fu(e,t,n,r){let i=e.element?.querySelector(`.xterm-screen`);if(!i)return()=>{};let a=uu(e,i,r,n),o,s=null,c=()=>{clearTimeout(o),a.stop(),s=null},l=e=>{if(c(),e.touches.length!==1||!t())return;a.clear();let n=e.touches[0];s={id:n.identifier,x:n.clientX,y:n.clientY,lastY:n.clientY,remainder:0,at:performance.now(),dragged:!1,selecting:!1},o=setTimeout(()=>{!s||!t()||(s.selecting=!0,a.begin(s.x,s.y))},450)},u=r=>{if(!s)return;let l=r.touches[0];if(r.touches.length!==1||l?.identifier!==s.id||!t()){c();return}if(s.selecting){r.preventDefault(),a.extend(l.clientX,l.clientY);return}if(!s.dragged){if(Math.hypot(l.clientX-s.x,l.clientY-s.y)<du)return;s.dragged=!0,clearTimeout(o)}r.preventDefault();let u=i.getBoundingClientRect(),d=u.height/e.rows;if(d<=0)return;s.remainder+=s.lastY-l.clientY,s.lastY=l.clientY;let f=Math.trunc(s.remainder/d);if(f!==0){if(s.remainder-=f*d,n(),e.buffer.active.type===`normal`&&e.modes.mouseTrackingMode===`none`){e.scrollLines(f);return}for(let e=0;e<Math.abs(f);e++)i.dispatchEvent(new WheelEvent(`wheel`,{bubbles:!0,cancelable:!0,deltaMode:WheelEvent.DOM_DELTA_LINE,deltaY:Math.sign(f),clientX:Math.max(u.left,Math.min(u.right-1,l.clientX)),clientY:Math.max(u.top,Math.min(u.bottom-1,l.clientY))}))}},d=n=>{s?.dragged||s?.selecting?n.preventDefault():s&&t()&&performance.now()-s.at<300&&e.focus(),c()},f=e=>{!s||!t()||(e.preventDefault(),e.stopPropagation())};return i.addEventListener(`contextmenu`,f,!0),i.addEventListener(`touchstart`,l,{passive:!0}),i.addEventListener(`touchmove`,u,{passive:!1}),i.addEventListener(`touchend`,d,{passive:!1}),i.addEventListener(`touchcancel`,c),()=>{i.removeEventListener(`touchstart`,l),i.removeEventListener(`touchmove`,u),i.removeEventListener(`touchend`,d),i.removeEventListener(`touchcancel`,c),i.removeEventListener(`contextmenu`,f,!0),c(),a.dispose()}}var pu=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,mu=8,hu=2,gu=[,,,,,].fill(` `.repeat(mu)).join(`
61
+ `).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);nl.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*tl<=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||mc;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 el)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}},il=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}},al=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),ol;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof sl?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Wc.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:al})})(ol||={});var sl=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?al:(this._emitter||=new rl,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},cl=`en`,ll=!1,ul=!1,dl=cl,fl,pl=globalThis,ml;typeof pl.vscode<`u`&&typeof pl.vscode.process<`u`?ml=pl.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(ml=process);var hl=typeof ml?.versions?.electron==`string`&&ml?.type===`renderer`;if(typeof ml==`object`){ml.platform,ml.platform,ll=ml.platform===`linux`,ll&&ml.env.SNAP&&ml.env.SNAP_REVISION,ml.env.CI||ml.env.BUILD_ARTIFACTSTAGINGDIRECTORY,dl=cl;let e=ml.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,dl=t.resolvedLanguage||cl,t.languagePack?.translationsConfigFile}catch{}}else typeof navigator==`object`&&!hl?(fl=navigator.userAgent,fl.indexOf(`Windows`),fl.indexOf(`Macintosh`),(fl.indexOf(`Macintosh`)>=0||fl.indexOf(`iPad`)>=0||fl.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,ll=fl.indexOf(`Linux`)>=0,fl?.indexOf(`Mobi`),ul=!0,dl=globalThis._VSCODE_NLS_LANGUAGE||cl,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);ul&&typeof pl.importScripts==`function`&&pl.origin;var gl=fl,_l=dl,vl;(e=>{function t(){return _l}e.value=t;function n(){return _l.length===2?_l===`en`:_l.length>=3&&_l[0]===`e`&&_l[1]===`n`&&_l[2]===`-`}e.isDefaultVariant=n;function r(){return _l===`en`}e.isDefault=r})(vl||={});var yl=typeof pl.postMessage==`function`&&!pl.importScripts;(()=>{if(yl){let e=[];pl.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}),pl.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var bl=!!(gl&&gl.indexOf(`Chrome`)>=0);gl&&gl.indexOf(`Firefox`),!bl&&gl&&gl.indexOf(`Safari`),gl&&gl.indexOf(`Edg/`),gl&&gl.indexOf(`Android`);function xl(e,t=0,n){let r=setTimeout(()=>{e(),n&&i.dispose()},t),i=Ic(()=>{clearTimeout(r),n?.deleteAndLeak(i)});return n?.add(i),i}(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var Sl;(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})(Sl||={});var Cl=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 rl,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 Wc.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())}};Cl.EMPTY=Cl.fromArray([]);var wl=class extends zc{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new Bc),this._linesCacheDisposables=this._register(new Bc),this._register(Ic(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=Fc(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=xl(()=>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]}},Tl=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}},El=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}},Dl=class extends zc{constructor(e){super(),this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(Ic(()=>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(){Pc(n)}}}clearHighlightDecorations(){Pc(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(()=>Pc(e))),s.push(i)}}return s.length===0?void 0:s}},Ol=class extends zc{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new rl)}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()}},kl=class extends zc{constructor(e){super(),this._highlightTimeout=this._register(new Bc),this._lineCache=this._register(new Bc),this._state=new Tl,this._resultTracker=this._register(new Ol),this._highlightLimit=e?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new wl(e),this._engine=new El(e,this._lineCache.value),this._decorationManager=new Dl(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(Ic(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=xl(()=>{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}};function Al(e){return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)}function jl(){return(0,C.useSyncExternalStore)(Al,()=>document.visibilityState===`visible`)}function Ml(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 Nl(e,t){let n=Ml(t);return n?`\x1b]${e};${n}\x1b\\`:null}function Pl(e,t){let n=[10,11].map(n=>e.parser.registerOscHandler(n,e=>{if(e!==`?`)return!1;if(!t.daemonAnswers&&!t.isReplaying()){let e=Nl(n,t.readColour(n));e&&t.reply(e)}return!0}));return{dispose:()=>n.forEach(e=>e.dispose())}}function Fl(e,t,n=!1){return e.type===`keydown`?n&&Il(e)?!0:t?e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`c`:e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&e.key.toLowerCase()===`c`:!1}function Il(e){return e.type===`keydown`&&e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`c`}function Ll(e){if(!/^https?:\/\//i.test(e)||/[\s<>"`\\\p{Cc}]/u.test(e))return!1;try{return new URL(e).hostname!==``}catch{return!1}}function Rl(e){let t=[];for(let n of e.matchAll(/\bhttps?:\/\/[^\s<>"'`\\{}|^]+/gi)){let e=n[0];for(;e;){let t=e.at(-1),n=t===`)`?`(`:t===`]`?`[`:null;if(/[.,;:!?]/.test(t)||n&&e.split(t).length>e.split(n).length)e=e.slice(0,-1);else break}Ll(e)&&t.push({uri:e,start:n.index,end:n.index+e.length})}return t}function zl(e,t,n,r){let i=Rl(r).at(-1),a=/\bhttps?:\/\/[^\s<>"'`\\{}|^]*$/i.exec(r)?.[0];if(!a||i&&/[\])]/.test(r.slice(i.end)))return!1;let o=t.text.trimStart();if(!o||/^(?:https?:\/\/|~\/|\.{1,2}\/)/i.test(o))return!1;let s=o.split(/\s/,1)[0].replace(/[.,;:!?\])]+$/,``);if(!/^[\p{L}\p{N}_%/?.:#&=+~-]/u.test(s))return!1;let c=/[/_.?&#=%+~-]/.test(s);if(!c&&/\s/.test(o.trimEnd()))return!1;let l=e.cells[e.text.trimEnd().length-1];return a.endsWith(`/`)&&c||l!==void 0&&l.col>=n-9}function Bl(e,t,n){return ce(e,t,n,Rl,zl)}function Vl(e,t){return e.registerLinkProvider({provideLinks(n,r){r(Bl(e.buffer.active,n-1,e.cols).map(({candidate:e,start:n,end:r})=>({range:{start:{x:n.col+1,y:n.row+1},end:{x:r.col+1,y:r.row+1}},text:e.uri,activate:()=>t(e.uri)})))}})}function Hl(e){let t=e.trim(),n=/^<([^<>]+)>$/.exec(t);if(n&&Ll(n[1]))return n[1];let r=/^\[(?:\\.|[^\]\\])*\]\(\s*(?:<([^<>]+)>|([^\s]+))\s*\)$/.exec(t);if(!r)return e;let i=r[1]??r[2];if(r[2]){let t=0;for(let n=0;n<i.length;n++)if(i[n]===`\\`)n++;else if(i[n]===`(`)t++;else if(i[n]===`)`&&--t<0)return e;if(t!==0)return e}let a=i.replace(/\\([!-/:-@[-`{-~])/g,`$1`);return Ll(a)?a:e}function Ul(e){let t=e.getSelection(),n=e.getSelectionPosition();if(n&&/\r?\n/.test(t)){let r=t.trim().replace(/[\t ]*\r?\n[\t ]*/g,``),i=Bl(e.buffer.active,n.start.y,e.cols).find(({candidate:e})=>e.uri===r);if(i)return i.candidate.uri}return Hl(t)}function Wl(e){let t=null,n=null,r=()=>{n?.cancel(),n=null},i=()=>{r(),t=null},a={reset:i,input(e){!e.startsWith(`\x1B[<`)&&!e.startsWith(`\x1B[M`)&&i()},osc(a){if(!e.available())return i(),!0;let o=a.indexOf(`;`);if(o<0)return!0;let s=a.slice(o+1);if(s===`?`)return!0;if(!s)return i(),!0;try{let e=Uint8Array.from(atob(s),e=>e.charCodeAt(0));t=Hl(new TextDecoder(`utf-8`,{fatal:!0}).decode(e)),t&&n?.resolve(t),r()}catch{i()}return!0},key(a){let o=Hl(e.selection()),s=o||t,c=Fl(a,e.isMac,!!s),l=Il(a);if(!c&&!l)return!1;if(o)return r(),e.writeClipboard(o),!0;if(!e.available())return i(),c;if(s)return r(),e.writeClipboard(s),!0;if(!e.mouseTracking())return!1;r();let u=new Promise((e,t)=>{let i=setTimeout(()=>{r()},2e3);n={resolve:t=>{clearTimeout(i),e(t)},cancel:()=>{clearTimeout(i),t(new DOMException(`Copy cancelled`,`AbortError`))}}});return e.writeClipboard(u),e.writeInput(l?``:e.isMac?`\x1B[99;9u`:`\x1B[99;6u`),!0},copy(n){let r=Hl(e.selection()),i=r||t;if(!(!r&&!e.available())){if(!i){a.key({type:`keydown`,key:`c`,metaKey:e.isMac,ctrlKey:!e.isMac,shiftKey:!e.isMac,altKey:!1})&&(n.preventDefault(),n.stopPropagation());return}n.clipboardData&&(n.clipboardData.setData(`text/plain`,i),n.preventDefault(),n.stopPropagation())}}};return a}function Gl(e,t){typeof e!=`string`&&e.catch(()=>{}),(async()=>{if(typeof e==`string`)await navigator.clipboard.writeText(e);else if(typeof ClipboardItem<`u`&&navigator.clipboard?.write){let t=e.then(e=>new Blob([e],{type:`text/plain`}));t.catch(()=>{}),await navigator.clipboard.write([new ClipboardItem({"text/plain":t})])}else await navigator.clipboard.writeText(await e)})().catch(async n=>{if(!(n instanceof DOMException&&n.name===`AbortError`)){if(typeof e!=`string`)try{await e}catch{return}t()}})}function Kl(e){if(e.type!==`keydown`||e.ctrlKey||e.shiftKey)return null;if(e.metaKey&&!e.altKey)switch(e.key){case`ArrowLeft`:return``;case`ArrowRight`:return``;case`Backspace`:return``;case`Delete`:return`\v`}if(e.altKey&&!e.metaKey)switch(e.key){case`ArrowLeft`:return`\x1Bb`;case`ArrowRight`:return`\x1Bf`}return null}var ql=new Set([`localhost`,`127.0.0.1`,`::1`,`[::1]`]);function Jl(e,t,n){if(!n)return e;let r;try{r=new URL(e)}catch{return e}return r.protocol!==`http:`&&r.protocol!==`https:`||!ql.has(r.hostname)?e:`/forward/${t}/${r.port===``?r.protocol===`https:`?`443`:`80`:r.port}?path=${encodeURIComponent(r.pathname+r.search+r.hash)}`}var Yl=1e3,Xl=250;function Zl(e,t){return o(JSON.stringify([e,t]))}function Ql(e){return Number.isFinite(e)?Math.max(0,Math.trunc(e)):0}function $l(e){return Number.isFinite(e)?Math.max(1,Math.trunc(e)):1}function eu(e,t){return t===0?1:Math.max(0,Math.min(1,e/t))}function tu(e,t){let n=Ql(t),r=Math.min(n,Ql(e));return{viewportY:r,atBottom:r>=n}}function nu(e,t){let n=Ql(t);return e.atBottom?n:Math.min(e.viewportY,n)}function ru(e,t,n,r){let i=tu(e,t),a=i.viewportY;if(!i.atBottom)for(;a>0&&r(a);)a--;return{...i,logicalLineY:a,cellOffset:(i.viewportY-a)*$l(n),scrollProgress:eu(i.viewportY,Ql(t))}}function iu(e,t,n,r){let i=Ql(r);if(e.atBottom)return i;if(t===void 0||t<0)return Math.round(e.scrollProgress*i);let a=Ql(t)+Math.floor(e.cellOffset/$l(n));return Math.min(a,i)}var au=class{timer;managedScrolls=0;state;capture(e){if(this.state)return this.arm(Yl),!0;let t=e.buffer.active;if(t.type!==`normal`)return!1;let n=ru(t.viewportY,t.baseY,e.cols,e=>t.getLine(e)?.isWrapped===!0);if(n.atBottom)return!1;let r=t.baseY+t.cursorY;return this.state={anchor:n,marker:e.registerMarker(n.logicalLineY-r),buffer:t.type},this.arm(Yl),!0}restore(e){let t=this.state,n=e.buffer.active;if(!t||n.type!==t.buffer)return null;let r=t.marker.isDisposed?void 0:t.marker.line;return e.scrollToLine(iu(t.anchor,r,e.cols,n.baseY)),r===void 0?(this.arm(Xl),`replaced`):`tracked`}beginManagedScroll(){this.managedScrolls++}endManagedScroll(){this.managedScrolls=Math.max(0,this.managedScrolls-1)}get managingScroll(){return this.managedScrolls>0}release(){this.timer!==void 0&&clearTimeout(this.timer),this.timer=void 0,this.managedScrolls=0,this.state?.marker.dispose(),this.state=void 0}arm(e){this.timer!==void 0&&clearTimeout(this.timer),this.timer=setTimeout(()=>this.release(),e)}},ou=new class{maxEntries;positions=new Map;constructor(e=500){this.maxEntries=e}set(e,t,n,r){let i=Zl(e,t),a=tu(n,r);for(this.positions.delete(i),this.positions.set(i,a);this.positions.size>this.maxEntries;){let e=this.positions.keys().next().value;if(e===void 0)break;this.positions.delete(e)}return a}get(e,t){return this.positions.get(Zl(e,t))}},su=new WeakSet;function cu(e){let t=e._core?._inputHandler,n=t;if(typeof t!=`object`||!t||typeof n?.scrollUp!=`function`||typeof n._eraseAttrData!=`function`||typeof n._bufferService?.scroll!=`function`||typeof n._dirtyRowTracker?.markRangeDirty!=`function`)throw Error(`xterm scrollback internals do not match the pinned 6.0.0 release`);return t}function lu(e){let t=cu(e);if(su.has(t))return;su.add(t);let n=t.scrollUp.bind(t);t.scrollUp=e=>{if(t._activeBuffer.scrollTop!==0)return n(e);let r=e.params[0]||1;for(;r--;){let e=t._activeBuffer.ybase;t._bufferService.scroll(t._eraseAttrData()),t._activeBuffer.savedY+=t._activeBuffer.ybase-e}return t._dirtyRowTracker.markRangeDirty(t._activeBuffer.scrollTop,t._activeBuffer.scrollBottom),!0}}function uu(e,t,n,r){let i=null,a=!1,o=0,s=null,c=0,l=(n,r)=>{let i=t.getBoundingClientRect(),a=Math.max(0,Math.min(e.cols-1,Math.floor((n-i.left)/(i.width/e.cols)))),o=e.buffer.active.viewportY+Math.max(0,Math.min(e.rows-1,Math.floor((r-i.top)/(i.height/e.rows)))),s=e.buffer.active.getLine(o),c=a>0&&s?.getCell(a)?.getWidth()===0?a-1:a;return{row:o,column:c,width:Math.max(1,s?.getCell(c)?.getWidth()??1)}},u=()=>{if(!i||!s)return;let t=l(s.x,s.y),r=t.row*e.cols+t.column,a=Math.min(i.start,r),o=Math.max(i.end,r+t.width);e.select(a%e.cols,Math.floor(a/e.cols),o-a),n(e.getSelection())},d=()=>{cancelAnimationFrame(o),o=0,s=null},f=n=>{if(o=0,!s)return;let i=t.getBoundingClientRect(),a=s.y<i.top?-1:+(s.y>=i.bottom);a&&n-c>=50&&e.buffer.active.type===`normal`&&(c=n,r(),e.scrollLines(a),u()),o=requestAnimationFrame(f)},p=e.onSelectionChange(()=>{a&&(e.hasSelection()?n(e.getSelection()):(d(),i=null,a=!1,n(null)))});return{begin(t,r){let o=l(t,r),s=e.buffer.active.getLine(o.row),c=o.column,u=o.column+o.width,d=e=>{let t=s?.getCell(e);return t&&(t.getWidth()===0||/\S/u.test(t.getChars()))};if(d(c)){for(;c>0&&d(c-1);)c--;for(;u<e.cols&&d(u);)u++}i={start:o.row*e.cols+c,end:o.row*e.cols+u},a=!0,e.select(c,o.row,u-c),n(e.getSelection())},extend(e,t){s={x:e,y:t},u(),o||=requestAnimationFrame(f)},stop:d,clear:()=>{d(),i=null,a=!1,e.clearSelection(),n(null)},dispose(){d(),p.dispose()}}}var du=8;function fu(e,t,n,r){let i=e.element?.querySelector(`.xterm-screen`);if(!i)return()=>{};let a=uu(e,i,r,n),o,s=null,c=()=>{clearTimeout(o),a.stop(),s=null},l=e=>{if(c(),e.touches.length!==1||!t())return;a.clear();let n=e.touches[0];s={id:n.identifier,x:n.clientX,y:n.clientY,lastY:n.clientY,remainder:0,at:performance.now(),dragged:!1,selecting:!1},o=setTimeout(()=>{!s||!t()||(s.selecting=!0,a.begin(s.x,s.y))},450)},u=r=>{if(!s)return;let l=r.touches[0];if(r.touches.length!==1||l?.identifier!==s.id||!t()){c();return}if(s.selecting){r.preventDefault(),a.extend(l.clientX,l.clientY);return}if(!s.dragged){if(Math.hypot(l.clientX-s.x,l.clientY-s.y)<du)return;s.dragged=!0,clearTimeout(o)}r.preventDefault();let u=i.getBoundingClientRect(),d=u.height/e.rows;if(d<=0)return;s.remainder+=s.lastY-l.clientY,s.lastY=l.clientY;let f=Math.trunc(s.remainder/d);if(f!==0){if(s.remainder-=f*d,n(),e.buffer.active.type===`normal`&&e.modes.mouseTrackingMode===`none`){e.scrollLines(f);return}for(let e=0;e<Math.abs(f);e++)i.dispatchEvent(new WheelEvent(`wheel`,{bubbles:!0,cancelable:!0,deltaMode:WheelEvent.DOM_DELTA_LINE,deltaY:Math.sign(f),clientX:Math.max(u.left,Math.min(u.right-1,l.clientX)),clientY:Math.max(u.top,Math.min(u.bottom-1,l.clientY))}))}},d=n=>{s?.dragged||s?.selecting?n.preventDefault():s&&t()&&performance.now()-s.at<300&&e.focus(),c()},f=e=>{!s||!t()||(e.preventDefault(),e.stopPropagation())};return i.addEventListener(`contextmenu`,f,!0),i.addEventListener(`touchstart`,l,{passive:!0}),i.addEventListener(`touchmove`,u,{passive:!1}),i.addEventListener(`touchend`,d,{passive:!1}),i.addEventListener(`touchcancel`,c),()=>{i.removeEventListener(`touchstart`,l),i.removeEventListener(`touchmove`,u),i.removeEventListener(`touchend`,d),i.removeEventListener(`touchcancel`,c),i.removeEventListener(`contextmenu`,f,!0),c(),a.dispose()}}var pu=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,mu=8,hu=2,gu=[,,,,,].fill(` `.repeat(mu)).join(`
62
62
  `),_u=22;function vu(e,t){if(!pu)return()=>{};let n=e.textarea,r=n.parentElement,i=new AbortController,a={capture:!0,signal:i.signal},o=!1,s=e.onKey(({domEvent:e})=>e.preventDefault());n.style.whiteSpace=`pre`;let c=n=>{n&&t()&&e.input(n,!0)},l=()=>{n.value!==gu&&(n.value=gu),n.setSelectionRange(_u,_u)};return r.addEventListener(`focus`,l,a),r.addEventListener(`blur`,l,a),r.addEventListener(`keydown`,e=>{o||e.isComposing?e.stopImmediatePropagation():l()},a),r.addEventListener(`keyup`,()=>{o||l()},a),r.addEventListener(`beforeinput`,e=>{o||e.isComposing||(e.preventDefault(),l(),c({insertText:e.data,insertLineBreak:`\r`,insertParagraph:`\r`,deleteContentBackward:``,deleteWordBackward:`\x1B`,deleteContentForward:`\x1B[3~`}[e.inputType]??null))},a),r.addEventListener(`compositionstart`,e=>{e.stopImmediatePropagation(),l(),o=!0},a),r.addEventListener(`compositionupdate`,e=>e.stopImmediatePropagation(),a),r.addEventListener(`compositionend`,e=>{e.stopImmediatePropagation(),o=!1,c(e.data),l()},a),document.addEventListener(`selectionchange`,()=>{if(o||document.activeElement!==n)return;let{selectionStart:r,selectionEnd:i}=n;if(!(n.value===gu&&r===_u&&i===_u)){if(n.value===gu&&t()){let t=r===_u?i:r,n=Math.floor(t/9)-hu,a=t%9-mu/2;if(Math.abs(n||a)<hu)return;let o=n<0?`A`:n>0?`B`:a<0?`D`:`C`;c(`\x1b${e.modes.applicationCursorKeysMode?`O`:`[`}${o}`)}l()}},{signal:i.signal}),document.activeElement===n&&l(),()=>{s.dispose(),i.abort()}}var yu=e(n(),1),bu=128,xu=32768,Su=32,Cu=/^\s*(`{3,}|~{3,})(.*)$/,wu=/^\s*(?:flowchart|graph)\s+(?:TB|TD|BT|RL|LR)\s*;?\s*$/,Tu=/^\s*sequenceDiagram\s*$/;function Eu(e,t){let n=e.trim();return n===``||/^(?:%%|end\b)/.test(n)?!0:t?/^(?:participant|actor|create|destroy|activate|deactivate|note|loop|alt|else|opt|par|and|critical|option|break|rect|autonumber)\b/i.test(n)||/^\S+\s*(?:--?|<<-)[<>x)+-]*>/.test(n):/^(?:subgraph|direction|style|classDef|class|linkStyle)\b/.test(n)||/^[\w-]+\s*(?:\[|\(|\{|>|@\{|<*[-=.]+[->ox| ])/.test(n)}function Du(e,t,n,r){if(t<1||r<1)return[];let i=Math.min(bu,Math.max(0,Math.floor((xu/(t+1)-r)/2))),a=Math.max(0,n-i),o=Math.min(e.length,n+r+i),s=[],c=0;for(let n=a;n<o;n++){let r=me(e,n,t);if(!r)break;let i=e.getLine(n+1)?.isWrapped?r.text.length:r.text.trimEnd().length;if(c+=i+1,c>xu)break;let a=s.at(-1);r.isWrapped&&a?(a.text+=r.text.slice(0,i),a.cells.push(...r.cells.slice(0,i))):s.push({text:r.text.slice(0,i),cells:r.cells.slice(0,i)})}let l=[],u=(t,i,a,o)=>{let s=o[0],c=o.at(-1);if(!s||!c||!i.trim()||l.length>=Su||c.row<n||s.row>=n+r)return;let u=e.getLine(c.row)?.getCell(c.col)?.getWidth()??1;l.push({kind:t,source:i.trim(),display:a,start:s,end:{row:c.row,col:c.col+Math.max(1,u)-1}})};for(let e=0;e<s.length&&l.length<Su;e++){let t=s[e],n=Cu.exec(t.text);if(n){let t=e+1;for(;t<s.length;){let e=Cu.exec(s[t].text);if(e&&!e[2].trim()&&e[1][0]===n[1][0]&&e[1].length>=n[1].length)break;t++}if(t===s.length)break;let r=n[2].trim().split(/\s+/)[0].toLowerCase();if([`mermaid`,`math`,`latex`,`tex`].includes(r)){let n=s.slice(e+1,t).map(e=>e.text).join(`
63
63
  `);u(r===`mermaid`?`mermaid`:`math`,n,!0,s.slice(e,t+1).flatMap(e=>e.cells))}e=t;continue}let r=Tu.test(t.text);if(wu.test(t.text)||r){let t=e+1;for(;t<s.length&&Eu(s[t].text,r);)t++;for(;t>e+1&&!s[t-1].text.trim();)t--;if(t>e+1){let n=s.slice(e,t);u(`mermaid`,n.map(e=>e.text).join(`
64
- `),!0,n.flatMap(e=>e.cells)),e=t-1;continue}}let i=t.text.trim();if(i.startsWith(`$$`)||i.startsWith(`\\[`)){let t=i,n=e,r=S(t);for(;!r&&n+1<s.length&&(t+=`\n${s[++n].text.trim()}`,r=S(t),!/\n\s*\n/.test(t)););if(r?.display&&r.length===t.length){u(`math`,r.tex,!0,s.slice(e,n+1).flatMap(e=>e.cells)),e=n;continue}if(i===`$$`||i===`\\[`)continue}for(let e=0;e<t.text.length;e++){if(t.text[e]==="`"){let n=/^`+/.exec(t.text.slice(e))[0],r=t.text.indexOf(n,e+n.length);if(r<0)break;e=r+n.length-1;continue}let n=S(t.text,e);if(n){let r=t.cells.slice(e,e+n.length);(r[0]?.row===r.at(-1)?.row||t.text.trim()===t.text.slice(e,e+n.length))&&u(`math`,n.tex,n.display,r),e+=n.length-1}else t.text[e]===`\\`&&e++}}return l}var Ou=c();function ku({block:e,box:t,theme:n,fontSize:r}){let i=(0,C.useRef)(null),a=(0,C.useRef)(null),[o,s]=(0,C.useState)(!1),[c,u]=(0,C.useState)(``),[d,f]=(0,C.useState)(!1),{source:p,kind:m,display:h}=e;(0,C.useEffect)(()=>{let e=i.current;if(!e)return;let t=new AbortController;return s(!1),u(``),e.replaceChildren(),(async()=>{if(m===`mermaid`){let{renderMermaidDiagrams:r}=await l(async()=>{let{renderMermaidDiagrams:e}=await import(`./markdown-mermaid-CuwsuNsF.js`).then(e=>e.t);return{renderMermaidDiagrams:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));if(t.signal.aborted)return;let i=document.createElement(`div`);if(i.setAttribute(`data-puddle-mermaid`,``),i.textContent=p,e.append(i),await r(e,n,t.signal,!0),t.signal.aborted)return;let a=i.querySelector(`svg`);if(!a)throw Error(`Unable to render Mermaid diagram`);let o=a.viewBox.baseVal;a.style.maxWidth=`none`,a.style.width=`${o.width}px`,a.style.height=`${o.height}px`}else{let[{renderMathHtml:n},{default:r}]=await Promise.all([l(()=>import(`./math-CSw6sgCC.js`).then(e=>e.n),__vite__mapDeps([10,1,11])),l(()=>import(`./purify.es-D8QhFVkO.js`).then(e=>e.n),__vite__mapDeps([12,1])),l(()=>import(`./katex.min-ZqdHjttS.js`).then(e=>e.t),__vite__mapDeps([13,1,14]))]);if(t.signal.aborted)return;if(e.innerHTML=r.sanitize(n(p,h)),e.querySelector(`.katex-error`))throw Error(`Unable to render LaTeX`)}t.signal.aborted||s(!0)})().catch(e=>{t.signal.aborted||u(e instanceof Error?e.message:`Unable to render output`)}),()=>t.abort()},[p,m,h,n]),(0,C.useLayoutEffect)(()=>{let e=i.current,t=a.current;if(!e||!t)return;let n=()=>{let n=e.scrollWidth,r=e.scrollHeight;if(!n||!r)return;let i=Math.min(1,t.clientWidth/n,t.clientHeight/r);e.style.transform=`scale(${i})`,e.style.left=`${h?(t.clientWidth-n*i)/2:0}px`,e.style.top=`${(t.clientHeight-r*i)/2}px`},r=new ResizeObserver(n);return r.observe(e),r.observe(t),n(),()=>r.disconnect()},[h,o]);let g=o&&!d,_=g?`Show terminal source`:`Render ${m===`math`?`LaTeX`:`Mermaid`}`;return(0,Ou.jsxs)(`div`,{ref:a,className:ie(`absolute overflow-hidden`,g&&`bg-ground`),style:{...t,fontSize:r},"data-terminal-rich-block":m,"data-rendered":g,children:[(0,Ou.jsx)(`div`,{ref:i,className:ie(`absolute w-max origin-top-left text-fg`,!g&&`invisible`),"aria-hidden":!g}),(0,Ou.jsx)(`button`,{type:`button`,"aria-label":_,title:c||_,style:{top:Math.max(0,-t.top)},disabled:!o,onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),onKeyUp:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),f(e=>!e)},className:`pointer-events-auto absolute right-0 top-0 rounded-sm bg-ground p-0.5 text-fg-muted opacity-0 transition-opacity hover:text-fg focus:opacity-100 group-hover/terminal:opacity-100 pointer-coarse:opacity-100`,children:g?(0,Ou.jsx)(ge,{className:`size-3`}):(0,Ou.jsx)(le,{className:`size-3`})})]})}function Au(e,t){return t.map(({start:t,end:n})=>{let r=[];for(let i=t.row;i<=n.row;i++)r.push(e.getLine(i)?.translateToString(!0)??``);return r.join(`
64
+ `),!0,n.flatMap(e=>e.cells)),e=t-1;continue}}let i=t.text.trim();if(i.startsWith(`$$`)||i.startsWith(`\\[`)){let t=i,n=e,r=S(t);for(;!r&&n+1<s.length&&(t+=`\n${s[++n].text.trim()}`,r=S(t),!/\n\s*\n/.test(t)););if(r?.display&&r.length===t.length){u(`math`,r.tex,!0,s.slice(e,n+1).flatMap(e=>e.cells)),e=n;continue}if(i===`$$`||i===`\\[`)continue}for(let e=0;e<t.text.length;e++){if(t.text[e]==="`"){let n=/^`+/.exec(t.text.slice(e))[0],r=t.text.indexOf(n,e+n.length);if(r<0)break;e=r+n.length-1;continue}let n=S(t.text,e);if(n){let r=t.cells.slice(e,e+n.length);(r[0]?.row===r.at(-1)?.row||t.text.trim()===t.text.slice(e,e+n.length))&&u(`math`,n.tex,n.display,r),e+=n.length-1}else t.text[e]===`\\`&&e++}}return l}var Ou=c();function ku({block:e,box:t,theme:n,fontSize:r}){let i=(0,C.useRef)(null),a=(0,C.useRef)(null),[o,s]=(0,C.useState)(!1),[c,u]=(0,C.useState)(``),[d,f]=(0,C.useState)(!1),{source:p,kind:m,display:h}=e;(0,C.useEffect)(()=>{let e=i.current;if(!e)return;let t=new AbortController;return s(!1),u(``),e.replaceChildren(),(async()=>{if(m===`mermaid`){let{renderMermaidDiagrams:r}=await l(async()=>{let{renderMermaidDiagrams:e}=await import(`./markdown-mermaid-Bn0a2pwd.js`).then(e=>e.t);return{renderMermaidDiagrams:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));if(t.signal.aborted)return;let i=document.createElement(`div`);if(i.setAttribute(`data-puddle-mermaid`,``),i.textContent=p,e.append(i),await r(e,n,t.signal,!0),t.signal.aborted)return;let a=i.querySelector(`svg`);if(!a)throw Error(`Unable to render Mermaid diagram`);let o=a.viewBox.baseVal;a.style.maxWidth=`none`,a.style.width=`${o.width}px`,a.style.height=`${o.height}px`}else{let[{renderMathHtml:n},{default:r}]=await Promise.all([l(()=>import(`./math-CSw6sgCC.js`).then(e=>e.n),__vite__mapDeps([10,1,11])),l(()=>import(`./purify.es-D8QhFVkO.js`).then(e=>e.n),__vite__mapDeps([12,1])),l(()=>import(`./katex.min-ZqdHjttS.js`).then(e=>e.t),__vite__mapDeps([13,1,14]))]);if(t.signal.aborted)return;if(e.innerHTML=r.sanitize(n(p,h)),e.querySelector(`.katex-error`))throw Error(`Unable to render LaTeX`)}t.signal.aborted||s(!0)})().catch(e=>{t.signal.aborted||u(e instanceof Error?e.message:`Unable to render output`)}),()=>t.abort()},[p,m,h,n]),(0,C.useLayoutEffect)(()=>{let e=i.current,t=a.current;if(!e||!t)return;let n=()=>{let n=e.scrollWidth,r=e.scrollHeight;if(!n||!r)return;let i=Math.min(1,t.clientWidth/n,t.clientHeight/r);e.style.transform=`scale(${i})`,e.style.left=`${h?(t.clientWidth-n*i)/2:0}px`,e.style.top=`${(t.clientHeight-r*i)/2}px`},r=new ResizeObserver(n);return r.observe(e),r.observe(t),n(),()=>r.disconnect()},[h,o]);let g=o&&!d,_=g?`Show terminal source`:`Render ${m===`math`?`LaTeX`:`Mermaid`}`;return(0,Ou.jsxs)(`div`,{ref:a,className:ie(`absolute overflow-hidden`,g&&`bg-ground`),style:{...t,fontSize:r},"data-terminal-rich-block":m,"data-rendered":g,children:[(0,Ou.jsx)(`div`,{ref:i,className:ie(`absolute w-max origin-top-left text-fg`,!g&&`invisible`),"aria-hidden":!g}),(0,Ou.jsx)(`button`,{type:`button`,"aria-label":_,title:c||_,style:{top:Math.max(0,-t.top)},disabled:!o,onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),onKeyUp:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),f(e=>!e)},className:`pointer-events-auto absolute right-0 top-0 rounded-sm bg-ground p-0.5 text-fg-muted opacity-0 transition-opacity hover:text-fg focus:opacity-100 group-hover/terminal:opacity-100 pointer-coarse:opacity-100`,children:g?(0,Ou.jsx)(ge,{className:`size-3`}):(0,Ou.jsx)(le,{className:`size-3`})})]})}function Au(e,t){return t.map(({start:t,end:n})=>{let r=[];for(let i=t.row;i<=n.row;i++)r.push(e.getLine(i)?.translateToString(!0)??``);return r.join(`
65
65
  `)}).join(`
66
66
  \0`)}function ju({terminal:e}){let[t,n]=(0,C.useState)(null),[r,i]=(0,C.useState)(!1),a=(0,C.useSyncExternalStore)(u,p,p),o=e.element?.querySelector(`.xterm-screen`);if((0,C.useEffect)(()=>{if(!o)return;let t,r=0,a=!0,s,c=()=>{r=0;let t=e.buffer.active,c=Du(t,e.cols,t.viewportY,e.rows);s={blocks:c,signature:Au(t,c),buffer:t,viewportY:t.viewportY,cols:e.cols},n({blocks:c,viewportY:t.viewportY,buffer:t.type,width:o.clientWidth,cellWidth:o.clientWidth/e.cols,cellHeight:o.clientHeight/e.rows,fontSize:e.options.fontSize??14}),a=!1,i(e.hasSelection())},l=(e,n=!1)=>{n||(i(!0),a=!0),!(e>0&&(t!==void 0||r!==0))&&(clearTimeout(t),cancelAnimationFrame(r),t=setTimeout(()=>{t=void 0,r=requestAnimationFrame(c)},e))},u=[e.onWriteParsed(()=>{let t=e.buffer.active,n=!!s&&s.buffer===t&&s.cols===e.cols&&s.viewportY===t.viewportY&&s.signature===Au(t,s.blocks);l(120,n)}),e.onScroll(()=>l(0)),e.onResize(()=>l(0)),e.buffer.onBufferChange(()=>l(0)),e.onSelectionChange(()=>i(a||e.hasSelection()))],d=new ResizeObserver(()=>l(0));return d.observe(o),l(0),()=>{clearTimeout(t),cancelAnimationFrame(r),d.disconnect();for(let e of u)e.dispose()}},[e,o]),!o||!t)return null;let{cellWidth:s,cellHeight:c,viewportY:l,width:d}=t;return(0,yu.createPortal)((0,Ou.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-10 overflow-hidden`,style:{visibility:r?`hidden`:void 0},children:t.blocks.map(e=>{let n=e.start.row!==e.end.row,r=n?0:e.start.col*s;return(0,Ou.jsx)(ku,{block:e,theme:a,fontSize:t.fontSize,box:{left:r,top:(e.start.row-l)*c,width:n?d:(e.end.col-e.start.col+1)*s,height:(e.end.row-e.start.row+1)*c}},`${t.buffer}:${e.start.row}:${e.start.col}:${e.source}`)})}),o)}var Mu=/Mac|iPhone|iPad/.test(navigator.platform),Nu=`'Ubuntu Sans Mono', ui-monospace, monospace`,Pu=`12px 'Ubuntu Sans Mono'`,Fu=typeof document>`u`||!(`fonts`in document)||document.fonts.check(Pu),Iu=Fu?null:document.fonts.load(Pu).catch(()=>void 0).then(()=>{Fu=!0});function Lu(){let[e,t]=(0,C.useState)(Fu);return(0,C.useEffect)(()=>{if(e||Iu===null)return;let n=!0;return Iu.then(()=>{n&&t(!0)}),()=>{n=!1}},[e]),e}var Ru=[`starting`,`running`,`waiting_input`];function zu(e){let t=f();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 Bu(e,t){let[n,r]=(0,C.useState)(e);return(0,C.useEffect)(()=>{if(e){r(!0);return}let n=setTimeout(()=>r(!1),t);return()=>clearTimeout(n)},[e,t]),n}var Vu=1500;function Hu({stream:e,term:t=`agent`,className:n,onExit:o,onOpenFile:c,paused:l=!1}){let p=(0,C.useRef)(null),ce=(0,C.useRef)(null),[le,me]=(0,C.useState)(null),ge=(0,C.useRef)(null),[S,ye]=(0,C.useState)(null),be=(0,C.useRef)(null),xe=(0,C.useRef)(null),w=(0,C.useRef)(new au),T=(0,C.useRef)(!1),Se=(0,C.useRef)(!1),Ce=s(),we=(0,C.useRef)(o);we.current=o;let Te=(0,C.useRef)(c);Te.current=c;let Ee=jl(),De=(0,C.useRef)(!l&&Ee);De.current=!l&&Ee;let Oe=Bu(!l&&Ee,Vu),ke=Lu(),Ae=a(r().data?.protocol),je=i(h()??void 0).data?.terminalAppShortcuts!==!1,Me=(0,C.useRef)(je);Me.current=je;let E=ae({shortcutEnabled:!1,onFind:(e,t,n)=>{let r=xe.current,i=ce.current;if(!r||!i)return v;if(e.length===0)return r.clearDecorations(),i.clearSelection(),v;if(!oe(e,t))return r.clearDecorations(),i.clearSelection(),{index:-1,count:0,invalid:!0};let a=zu(t);n===`previous`?r.findPrevious(e,a):r.findNext(e,{...a,incremental:n===`reset`})},onClear:()=>{xe.current?.clearDecorations(),ce.current?.clearSelection()},onCloseFocus:()=>ce.current?.focus()}),Ne=(0,C.useCallback)(n=>{if(!Se.current||T.current)return;w.current.restore(n);let r=n.buffer.active;r.type===`normal`&&ou.set(e,t,r.viewportY,r.baseY)},[e,t]),Pe=(0,C.useCallback)(()=>{let e=ce.current,t=p.current;if(!e||!t||t.clientWidth===0||t.clientHeight===0)return null;let n=w.current;n.capture(e),n.beginManagedScroll();try{be.current?.fit(),e.refresh(0,e.rows-1),Ne(e)}finally{n.endManagedScroll()}return e},[Ne]),Fe=(0,C.useCallback)(()=>{if(!De.current)return;let n=Pe();n&&ve.resize(e,t,n.cols,n.rows)},[Pe,e,t]);return(0,C.useEffect)(()=>{if(!Ee)return;let e=requestAnimationFrame(()=>{let e=ce.current;e&&e.refresh(0,e.rows-1)});return()=>cancelAnimationFrame(e)},[Ee]),(0,C.useEffect)(()=>{let n=p.current;if(!n||!ke)return;let r=e.startsWith(`login-`)||e===`home`,i=t=>{ne(r?t:Jl(t,e,he()!==null)).catch(_e)},a=new lc({allowProposedApi:!0,...d(),fontFamily:Nu,fontSize:Ce.terminalFontSize,scrollback:Ce.terminalScrollback,cursorBlink:!0,macOptionClickForcesSelection:Mu,linkHandler:{activate:(e,t)=>i(t)}});lu(a),Se.current=!1,T.current=!1,ce.current=a;let o=new fc,s=new kl;a.loadAddon(o),a.loadAddon(s);let c=Vl(a,i);a.open(n),me(a),o.fit(),be.current=o,xe.current=s;let l=s.onDidChangeResults(e=>{E.setResult({index:e.resultIndex,count:e.resultCount})}),h=a.onScroll(n=>{if(!Se.current||T.current)return;w.current.managingScroll||w.current.release();let r=a.buffer.active;r.type===`normal`&&ou.set(e,t,n,r.baseY)}),ie=Te.current&&!r?ue(a,e,e=>Te.current?.(e)):null,ae=Wl({isMac:Mu,selection:()=>Ul(a),mouseTracking:()=>a.modes.mouseTrackingMode!==`none`,available:()=>De.current&&ve.isConnected()&&!T.current,writeInput:n=>ve.write(e,t,n),writeClipboard:e=>Gl(e,()=>{re.error(`Could not copy the selection. Allow clipboard access and try again.`)})});ge.current=ae;let oe=e=>ae.copy(e),v=()=>ae.reset();n.addEventListener(`copy`,oe,!0),n.addEventListener(`focusout`,v),n.addEventListener(`mousedown`,v,!0),window.addEventListener(`blur`,v);let y=null,le=vu(a,()=>De.current&&ve.isConnected()&&!T.current),de=b(e,t,e=>{y=[];try{return a.paste(e),y.join(``)}finally{y=null}},()=>a.focus(),()=>a.modes.applicationCursorKeysMode),pe=a.onData(n=>{if(y){y.push(n);return}T.current||(ae.input(n),ve.write(e,t,fe(e,t,n)))}),S=Pl(a,{daemonAnswers:Ae,isReplaying:()=>T.current,readColour:e=>f()(e===10?`--text-primary`:`--bg-base`),reply:n=>ve.write(e,t,n)}),C=a.parser.registerOscHandler(52,ae.osc);a.attachCustomKeyEventHandler(n=>{if(n.type===`keydown`&&se(n,Mu))return n.preventDefault(),E.openFind(),!1;if(ae.key(n))return n.preventDefault(),!1;if(n.type===`keydown`&&Me.current){let e=g(n),t=e===null?void 0:ee(e),r=t===void 0?void 0:_(t);if(t!==void 0&&r!==void 0&&!r.editor&&!r.deferInTerminal&&te(t)!==void 0)return!1}if(!Mu)return!0;let r=Kl(n);return r?(n.preventDefault(),ve.write(e,t,r),!1):!0});let we=n=>{x(n,e,t)&&(n.preventDefault(),n.stopPropagation())};n.addEventListener(`paste`,we,!0);let Ee=()=>w.current.release();n.addEventListener(`wheel`,Ee,{capture:!0,passive:!0});let Oe=fu(a,()=>De.current,Ee,e=>ye(e===null?null:Ul(a))),je=()=>Fe();n.addEventListener(`focusin`,je);let Ne=new ResizeObserver(()=>Fe());Ne.observe(n);let Pe=u(()=>{a.options.theme=m(),E.refresh()});return()=>{ae.reset(),ge.current=null,n.removeEventListener(`copy`,oe,!0),n.removeEventListener(`focusout`,v),n.removeEventListener(`mousedown`,v,!0),window.removeEventListener(`blur`,v),n.removeEventListener(`paste`,we,!0),n.removeEventListener(`wheel`,Ee,!0),n.removeEventListener(`focusin`,je),Oe(),le(),Ne.disconnect(),Pe(),w.current.release(),l.dispose(),h.dispose(),S.dispose(),C.dispose(),c.dispose(),ie?.dispose(),de(),pe.dispose(),a.dispose(),me(null),ce.current=null,be.current=null,xe.current=null}},[e,t,Fe,ke,Ae]),(0,C.useEffect)(()=>{let n=ce.current;if(!n||!Oe)return;let r=p.current;r&&r.clientWidth>0&&r.clientHeight>0&&Pe(),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;let t=w.current;t.beginManagedScroll(),n.write(e,()=>{try{Ne(n)}finally{t.endManagedScroll()}})},c=e=>{o.push(e),a+=e.length,a>=64*1024?s():i===0&&(i=requestAnimationFrame(s))},l=ve.attach(e,t,n.cols,n.rows,{onData:(r,s)=>{if(s===`replay`){i!==0&&cancelAnimationFrame(i),i=0,a=0,o=[];let s=ou.get(e,t);ge.current?.reset(),T.current=!0;let c=w.current;c.beginManagedScroll(),n.reset(),n.write(r,()=>{try{if(ce.current!==n)return;T.current=!1,Se.current=!0,n.refresh(0,n.rows-1),s&&(n.scrollToLine(nu(s,n.buffer.active.baseY)),c.capture(n)),Ne(n)}finally{c.endManagedScroll()}});return}c(r)},onExit:e=>we.current?.(e)});return()=>{i!==0&&cancelAnimationFrame(i),ge.current?.reset(),l()}},[e,t,Oe,ke,Ae,Pe,Ne]),(0,C.useEffect)(()=>{let e=ce.current;e&&(e.options.fontSize=Ce.terminalFontSize,e.options.scrollback=Ce.terminalScrollback,Fe())},[Ce.terminalFontSize,Ce.terminalScrollback,Fe]),(0,C.useEffect)(()=>{let t=!1;return ve.onStatus(n=>{if(n.session!==e)return;let r=Ru.includes(n.status);r&&!t&&Fe(),t=r})},[e,Fe]),(0,Ou.jsxs)(`div`,{className:ie(`puddle-terminal group/terminal relative size-full`,n),"data-notification-session":!l&&t===`agent`?e:void 0,children:[(0,Ou.jsx)(`div`,{ref:p,className:`size-full`}),le&&!l&&Ee&&(0,Ou.jsx)(ju,{terminal:le}),S!==null&&!l&&(0,Ou.jsx)(pe,{label:`Selected terminal text`,text:S,paste:()=>de(e,t,()=>De.current),clear:()=>{ce.current?.clearSelection(),ye(null)}}),E.open&&(0,Ou.jsx)(y,{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{Hu as Terminal};