vibelet 1.2.230 → 1.2.231

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 (40) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/inventory-scan-worker.cjs +1 -1
  3. package/dist/runtime-version.cjs +1 -1
  4. package/dist/vibelet.mjs +123 -98
  5. package/dist/web/assets/App-BbkHX6Hv.css +1 -0
  6. package/dist/web/assets/App-TtlYNy7O.js +20 -0
  7. package/dist/web/assets/{BrowserControlPanel-BTBKDi0n.js → BrowserControlPanel-DzDyeCam.js} +1 -1
  8. package/dist/web/assets/{ChipGroup-ImS6VTKx.js → ChipGroup-Do4YgaVh.js} +1 -1
  9. package/dist/web/assets/FilesControlPanel-Dy08iN_7.js +1 -0
  10. package/dist/web/assets/{GlobalPendingDialog-BCLMQc_r.js → GlobalPendingDialog-BokEX_Go.js} +1 -1
  11. package/dist/web/assets/{ImageViewer-BvBKQ6wE.js → ImageViewer-BAycGfGo.js} +1 -1
  12. package/dist/web/assets/{LanguageSettingsPanel-DTDvB4l2.js → LanguageSettingsPanel-db264JO3.js} +1 -1
  13. package/dist/web/assets/NewSessionDialog-BTZlw3Gl.js +1 -0
  14. package/dist/web/assets/{NotificationSettingsPanel-BS01O3sC.js → NotificationSettingsPanel-BYr3-NRw.js} +1 -1
  15. package/dist/web/assets/{TerminalControlPanel-B7S_ebVy.js → TerminalControlPanel-16KT-TCS.js} +1 -1
  16. package/dist/web/assets/{ThemeSettingsPanel-DVaJ6nGu.js → ThemeSettingsPanel-D3-WUp4t.js} +1 -1
  17. package/dist/web/assets/{arrow-right-ORILUMdJ.js → arrow-right-mMC7Zi8G.js} +1 -1
  18. package/dist/web/assets/{collectMessageImages-lfAaZW_Y.js → collectMessageImages-F_MsAk3D.js} +2 -2
  19. package/dist/web/assets/{file-editor-FileCodeEditor-ZAqN9Q2f.js → file-editor-FileCodeEditor-CInvSSQe.js} +3 -3
  20. package/dist/web/assets/{file-editor-MarkdownLivePreview-DXTFwUnj.js → file-editor-MarkdownLivePreview-CRJo_RMu.js} +1 -1
  21. package/dist/web/assets/{file-editor-index-Dj3dV82Z.js → file-editor-index-Cbe_0mr3.js} +1 -1
  22. package/dist/web/assets/{file-editor-index-C4S-qKVH.js → file-editor-index-DXLgqR7Z.js} +1 -1
  23. package/dist/web/assets/{file-editor-index-DKQvp2Qx.js → file-editor-index-Gu3GlV9m.js} +1 -1
  24. package/dist/web/assets/{file-editor-index-Dc2gxJQY.js → file-editor-index-R2lTkg6K.js} +1 -1
  25. package/dist/web/assets/{file-editor-index-Byun61j6.js → file-editor-index-VN_2L1I4.js} +1 -1
  26. package/dist/web/assets/{file-editor-index-BC0Bqs8t.js → file-editor-index-awBV_67q.js} +1 -1
  27. package/dist/web/assets/{file-editor-index-Bo2dEHVF.js → file-editor-index-hdpS6VVW.js} +1 -1
  28. package/dist/web/assets/{file-editor-index-BBHGMD89.js → file-editor-index-ixbyM_m4.js} +1 -1
  29. package/dist/web/assets/{folder-plus-DHw5YJHP.js → folder-plus-DbDHVXck.js} +1 -1
  30. package/dist/web/assets/{highlighted-body-TPN3WLV5-DDb5MlJt.js → highlighted-body-TPN3WLV5-F1GioA6X.js} +1 -1
  31. package/dist/web/assets/{index-ConcKf33.js → index-DJLpIsPI.js} +9 -9
  32. package/dist/web/assets/{index-Be6TVbvo.css → index-XET9GutV.css} +1 -1
  33. package/dist/web/assets/{mermaid-O7DHMXV3-D-5FgaAx.js → mermaid-O7DHMXV3-H7_sz6Xo.js} +3 -3
  34. package/dist/web/index.html +2 -2
  35. package/package.json +1 -1
  36. package/dist/web/assets/App-94_jdzMk.css +0 -1
  37. package/dist/web/assets/App-CapuoJH2.js +0 -18
  38. package/dist/web/assets/DiffDrawer-sMBIj4bW.js +0 -2
  39. package/dist/web/assets/FilesControlPanel-4hHS85Mr.js +0 -1
  40. package/dist/web/assets/NewSessionDialog-LttGZHY7.js +0 -1
@@ -1 +1 @@
1
- import{c as y,r as u,k as g,j as s,E}from"./index-ConcKf33.js";import{a as N,A as R}from"./arrow-right-ORILUMdJ.js";import{X as A,G as x}from"./App-CapuoJH2.js";const B=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],L=y("rotate-cw",B);function C(r){const o=r.trim();if(!o)return null;let a=o;if(/^[a-z][a-z\d+.-]*:/i.test(o)&&!/^[^:/\s]+:\d+(?:[/?#]|$)/.test(o)){if(!/^https?:\/\//i.test(o))return null}else/^(localhost|127\.0\.0\.1|\[::1\])(?::\d+)?(?:[/?#]|$)/i.test(o)?a=`http://${o}`:!/\s/.test(o)&&/^[^/]+\.[^/]+/.test(o)?a=`https://${o}`:a=`https://www.google.com/search?q=${encodeURIComponent(o)}`;try{const l=new URL(a);return/^https?:$/.test(l.protocol)&&!l.username&&!l.password?l.href:null}catch{return null}}const G=(r,o)=>{const a=document.createElement("iframe");a.className="browser-page",a.title=r.getAttribute("aria-label")||"Browser",a.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-downloads"),a.referrerPolicy="no-referrer",r.append(a);const l=[];let t=-1,c=!1;const w=()=>o({url:l[t]||"",title:"",loading:c,canGoBack:t>0,canGoForward:t<l.length-1}),d=()=>{c=!0,a.src=l[t],w()};return a.addEventListener("load",()=>{c=!1,w()}),{navigate:e=>{l.splice(t+1),l.push(e),t++,d()},back:()=>{t>0&&(t--,d())},forward:()=>{t<l.length-1&&(t++,d())},reload:()=>{t>=0&&d()},stop:()=>{c=!1;try{a.contentWindow?.stop()}catch{}w()},destroy:()=>a.remove()}},F={url:"",title:"",loading:!1,canGoBack:!1,canGoForward:!1};function P({t:r,onTitleChange:o,dockActions:a}){const l=u.useRef(null),t=u.useRef(null),c=u.useRef(null),[w,d]=u.useState(""),[e,j]=u.useState(F),[h,b]=u.useState(!1);u.useEffect(()=>{e.url&&o?.(e.title||new URL(e.url).hostname)},[e.title,e.url,r.browser]);const f=!!g().mountBrowser;u.useEffect(()=>{if(!l.current)return;const i=(g().mountBrowser||G)(l.current,p=>{j(p),document.activeElement!==c.current&&d(p.url)});return t.current=i,()=>{t.current=null,i.destroy()}},[]);const v=n=>{n.preventDefault();const i=C(w);if(!i||new URL(i).origin===window.location.origin){b(!0);return}b(!1),d(i),t.current?.navigate(i),c.current?.blur()},m=(n,i,p,k=!1)=>s.jsx("button",{type:"button",title:n,"aria-label":n,onClick:p,disabled:k,children:s.jsx(i,{"aria-hidden":"true"})});return s.jsxs("section",{className:"embedded-browser-panel","aria-label":r.browser,children:[s.jsxs("div",{className:"browser-navigation",children:[a,m(r.browserBack,N,()=>t.current?.back(),!e.canGoBack),m(r.browserForward,R,()=>t.current?.forward(),!e.canGoForward),m(f&&e.loading?r.browserStop:r.browserReload,f&&e.loading?A:L,()=>f&&e.loading?t.current?.stop():t.current?.reload(),!e.url),s.jsx("span",{className:"browser-page-title",title:e.title||e.url,children:e.title||r.browser}),s.jsx("a",{href:e.url||void 0,target:"_blank",rel:"noopener noreferrer","aria-label":r.browserExternal,title:r.browserExternal,"aria-disabled":!e.url,onClick:n=>{e.url||n.preventDefault()},children:s.jsx(E,{"aria-hidden":"true"})})]}),s.jsxs("form",{className:"browser-address",onSubmit:v,children:[s.jsx(x,{"aria-hidden":"true"}),s.jsx("input",{ref:c,value:w,onChange:n=>{d(n.target.value),b(!1)},"aria-label":r.browserAddress,placeholder:r.browserAddress,autoComplete:"off",spellCheck:!1,"aria-invalid":h,onFocus:n=>n.target.select()})]}),h&&s.jsx("p",{className:"browser-status",role:"alert",children:r.browserInvalidAddress}),e.error&&s.jsxs("div",{className:"browser-load-error",role:"alert",children:[s.jsx("p",{children:r.browserLoadFailed}),s.jsx("small",{children:e.error}),s.jsx("button",{type:"button",onClick:()=>t.current?.reload(),children:r.retry})]}),e.loading&&s.jsx("div",{className:"browser-loading",role:"status","aria-label":r.browserLoading}),s.jsx("div",{ref:l,role:"region",className:"browser-surface","aria-label":r.browser,hidden:!e.url||!!e.error}),!e.url&&s.jsxs("div",{className:"browser-empty",children:[s.jsx(x,{"aria-hidden":"true"}),s.jsx("p",{children:r.browserWelcome})]}),!f&&e.url&&s.jsx("p",{className:"browser-status",children:r.browserEmbedHint})]})}export{P as default};
1
+ import{c as y,r as u,k as g,j as s,E}from"./index-DJLpIsPI.js";import{a as N,A as R}from"./arrow-right-mMC7Zi8G.js";import{X as A,G as x}from"./App-TtlYNy7O.js";const B=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],L=y("rotate-cw",B);function C(r){const o=r.trim();if(!o)return null;let a=o;if(/^[a-z][a-z\d+.-]*:/i.test(o)&&!/^[^:/\s]+:\d+(?:[/?#]|$)/.test(o)){if(!/^https?:\/\//i.test(o))return null}else/^(localhost|127\.0\.0\.1|\[::1\])(?::\d+)?(?:[/?#]|$)/i.test(o)?a=`http://${o}`:!/\s/.test(o)&&/^[^/]+\.[^/]+/.test(o)?a=`https://${o}`:a=`https://www.google.com/search?q=${encodeURIComponent(o)}`;try{const l=new URL(a);return/^https?:$/.test(l.protocol)&&!l.username&&!l.password?l.href:null}catch{return null}}const G=(r,o)=>{const a=document.createElement("iframe");a.className="browser-page",a.title=r.getAttribute("aria-label")||"Browser",a.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-downloads"),a.referrerPolicy="no-referrer",r.append(a);const l=[];let t=-1,c=!1;const w=()=>o({url:l[t]||"",title:"",loading:c,canGoBack:t>0,canGoForward:t<l.length-1}),d=()=>{c=!0,a.src=l[t],w()};return a.addEventListener("load",()=>{c=!1,w()}),{navigate:e=>{l.splice(t+1),l.push(e),t++,d()},back:()=>{t>0&&(t--,d())},forward:()=>{t<l.length-1&&(t++,d())},reload:()=>{t>=0&&d()},stop:()=>{c=!1;try{a.contentWindow?.stop()}catch{}w()},destroy:()=>a.remove()}},F={url:"",title:"",loading:!1,canGoBack:!1,canGoForward:!1};function P({t:r,onTitleChange:o,dockActions:a}){const l=u.useRef(null),t=u.useRef(null),c=u.useRef(null),[w,d]=u.useState(""),[e,j]=u.useState(F),[h,b]=u.useState(!1);u.useEffect(()=>{e.url&&o?.(e.title||new URL(e.url).hostname)},[e.title,e.url,r.browser]);const f=!!g().mountBrowser;u.useEffect(()=>{if(!l.current)return;const i=(g().mountBrowser||G)(l.current,p=>{j(p),document.activeElement!==c.current&&d(p.url)});return t.current=i,()=>{t.current=null,i.destroy()}},[]);const v=n=>{n.preventDefault();const i=C(w);if(!i||new URL(i).origin===window.location.origin){b(!0);return}b(!1),d(i),t.current?.navigate(i),c.current?.blur()},m=(n,i,p,k=!1)=>s.jsx("button",{type:"button",title:n,"aria-label":n,onClick:p,disabled:k,children:s.jsx(i,{"aria-hidden":"true"})});return s.jsxs("section",{className:"embedded-browser-panel","aria-label":r.browser,children:[s.jsxs("div",{className:"browser-navigation",children:[a,m(r.browserBack,N,()=>t.current?.back(),!e.canGoBack),m(r.browserForward,R,()=>t.current?.forward(),!e.canGoForward),m(f&&e.loading?r.browserStop:r.browserReload,f&&e.loading?A:L,()=>f&&e.loading?t.current?.stop():t.current?.reload(),!e.url),s.jsx("span",{className:"browser-page-title",title:e.title||e.url,children:e.title||r.browser}),s.jsx("a",{href:e.url||void 0,target:"_blank",rel:"noopener noreferrer","aria-label":r.browserExternal,title:r.browserExternal,"aria-disabled":!e.url,onClick:n=>{e.url||n.preventDefault()},children:s.jsx(E,{"aria-hidden":"true"})})]}),s.jsxs("form",{className:"browser-address",onSubmit:v,children:[s.jsx(x,{"aria-hidden":"true"}),s.jsx("input",{ref:c,value:w,onChange:n=>{d(n.target.value),b(!1)},"aria-label":r.browserAddress,placeholder:r.browserAddress,autoComplete:"off",spellCheck:!1,"aria-invalid":h,onFocus:n=>n.target.select()})]}),h&&s.jsx("p",{className:"browser-status",role:"alert",children:r.browserInvalidAddress}),e.error&&s.jsxs("div",{className:"browser-load-error",role:"alert",children:[s.jsx("p",{children:r.browserLoadFailed}),s.jsx("small",{children:e.error}),s.jsx("button",{type:"button",onClick:()=>t.current?.reload(),children:r.retry})]}),e.loading&&s.jsx("div",{className:"browser-loading",role:"status","aria-label":r.browserLoading}),s.jsx("div",{ref:l,role:"region",className:"browser-surface","aria-label":r.browser,hidden:!e.url||!!e.error}),!e.url&&s.jsxs("div",{className:"browser-empty",children:[s.jsx(x,{"aria-hidden":"true"}),s.jsx("p",{children:r.browserWelcome})]}),!f&&e.url&&s.jsx("p",{className:"browser-status",children:r.browserEmbedHint})]})}export{P as default};
@@ -1 +1 @@
1
- import{j as l}from"./index-ConcKf33.js";function i({ariaLabel:r,options:s,value:a,disabled:u,onChange:c}){return l.jsx("div",{className:"chip-group",role:"radiogroup","aria-label":r,children:s.map(e=>l.jsx("button",{"aria-checked":a===e.value,className:a===e.value?"selected":"",disabled:u,onClick:()=>c(e.value),role:"radio",title:e.title??e.label,type:"button",children:e.label},e.value))})}export{i as C};
1
+ import{j as l}from"./index-DJLpIsPI.js";function i({ariaLabel:r,options:s,value:a,disabled:u,onChange:c}){return l.jsx("div",{className:"chip-group",role:"radiogroup","aria-label":r,children:s.map(e=>l.jsx("button",{"aria-checked":a===e.value,className:a===e.value?"selected":"",disabled:u,onClick:()=>c(e.value),role:"radio",title:e.title??e.label,type:"button",children:e.label},e.value))})}export{i as C};
@@ -0,0 +1 @@
1
+ import{c as z,j as t,i as Q,r as u,E as ie,u as oe,e as le,l as ce}from"./index-DJLpIsPI.js";import{X as Z,a as de,P as se,T as ue,l as ee,w as fe,n as O,f as $,j as B,p as H,g as pe,L as te,R as me,A as he,h as re,i as ne,b as ae,k as G,m as xe}from"./App-TtlYNy7O.js";import{F as ye}from"./folder-plus-DbDHVXck.js";const ge=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],be=z("clipboard-paste",ge);const je=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],ke=z("file-code-corner",je);const Ee=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],we=z("image",Ee);const De=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],ve=z("link",De);const Ce=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],Ne=z("scissors",Ce);function Se({ops:r,onOpen:p,root:j}){const b=u.useRef(null),f=r.menu;u.useLayoutEffect(()=>{const i=b.current,m=document.activeElement,E=i.getBoundingClientRect();i.style.left=`${Math.max(8,Math.min(f.x,innerWidth-E.width-8))}px`,i.style.top=`${Math.max(8,Math.min(f.y,innerHeight-E.height-8))}px`,i.querySelector("button:not(:disabled)")?.focus();const w=c=>{i.contains(c.target)||r.setMenu(null)},y=()=>r.setMenu(null);return document.addEventListener("pointerdown",w),document.addEventListener("scroll",y,!0),window.addEventListener("resize",y),()=>{document.removeEventListener("pointerdown",w),document.removeEventListener("scroll",y,!0),window.removeEventListener("resize",y),i.contains(document.activeElement)&&m?.focus()}},[]);const o=i=>{i.stopPropagation();const m=Array.from(b.current.querySelectorAll("button:not(:disabled)")),E=m.indexOf(document.activeElement);["ArrowUp","ArrowDown","Home","End","Escape","Tab"].includes(i.key)&&i.preventDefault(),(i.key==="Escape"||i.key==="Tab")&&r.setMenu(null),i.key==="ArrowDown"&&m[(E+1)%m.length]?.focus(),i.key==="ArrowUp"&&m[(E-1+m.length)%m.length]?.focus(),i.key==="Home"&&m[0]?.focus(),i.key==="End"&&m.at(-1)?.focus()},x=i=>{r.setMenu(null),i()};return t.jsxs("div",{ref:b,role:"menu","aria-label":r.strings.open,className:"session-context-menu file-tree-menu",style:{left:f.x,top:f.y},onKeyDown:o,onContextMenu:i=>i.preventDefault(),children:[!f.directory&&t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>x(p),children:[t.jsx(ie,{}),r.strings.open]}),f.path!==j&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>r.copy(f,!1),children:[t.jsx(de,{}),r.strings.copy,t.jsx("kbd",{children:"⌘C"})]}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>r.copy(f,!0),children:[t.jsx(Ne,{}),r.strings.cut,t.jsx("kbd",{children:"⌘X"})]})]}),t.jsxs("button",{type:"button",role:"menuitem",disabled:!r.canPaste,onClick:()=>x(()=>{r.paste(f)}),children:[t.jsx(be,{}),r.strings.paste,t.jsx("kbd",{children:"⌘V"})]}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>x(()=>{r.copyPath(f)}),children:[t.jsx(ve,{}),r.strings.copyPath]}),f.path!==j&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"context-menu-separator"}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>r.startRename(f),children:[t.jsx(se,{}),r.strings.rename,t.jsx("kbd",{children:"F2"})]}),t.jsxs("button",{type:"button",role:"menuitem",className:"danger",onClick:()=>x(()=>r.setDeleting(f)),children:[t.jsx(ue,{}),r.strings.delete]})]})]})}function Fe({ops:r}){const p=oe(()=>{r.busy||r.setDeleting(null)});return t.jsx("div",{className:"modal-backdrop file-tree-backdrop",children:t.jsxs("div",{ref:p,className:"file-tree-delete-dialog",role:"dialog","aria-modal":"true","aria-label":r.strings.confirmDelete,tabIndex:-1,children:[t.jsx("h2",{children:r.strings.confirmDelete}),t.jsx("p",{children:r.deleting?.path}),t.jsx("p",{children:r.strings.deleteHint}),r.error&&t.jsx("p",{role:"alert",children:r.error}),t.jsxs("div",{className:"file-tree-dialog-actions",children:[t.jsx("button",{type:"button",disabled:r.busy,onClick:()=>r.setDeleting(null),children:r.strings.cancel}),t.jsx("button",{type:"button",className:"danger",disabled:r.busy,onClick:()=>{r.deleteItem()},children:r.strings.delete})]})]})})}function _e({ops:r,root:p,onOpen:j}){return t.jsxs(t.Fragment,{children:[r.menu&&Q.createPortal(t.jsx(Se,{ops:r,root:p,onOpen:j}),document.body),r.deleting&&Q.createPortal(t.jsx(Fe,{ops:r}),document.body),r.error&&!r.deleting&&t.jsxs("div",{className:"file-tree-notice",role:"alert",children:[t.jsx("span",{children:r.error}),t.jsx("button",{type:"button",title:r.strings.dismiss,"aria-label":r.strings.dismiss,onClick:()=>r.setError(""),children:t.jsx(Z,{})})]}),r.undo&&t.jsxs("div",{className:"file-tree-notice",role:"status",children:[t.jsx("span",{children:r.strings.deleted}),t.jsx("button",{type:"button",disabled:r.busy,onClick:()=>{r.restore()},children:r.strings.undo}),t.jsx("button",{type:"button",title:r.strings.dismiss,"aria-label":r.strings.dismiss,onClick:()=>r.setUndo(null),children:t.jsx(Z,{})})]})]})}function J(r){return[...r].sort((p,j)=>Number(j.isDirectory)-Number(p.isDirectory)||p.name.localeCompare(j.name,void 0,{numeric:!0,sensitivity:"base"}))}function Te(r,p,j){const[b,f]=u.useState(new Set),[o,x]=u.useState({}),[i,m]=u.useState(new Set),[E,w]=u.useState({}),y=u.useRef(0),c=u.useRef(new Set);return u.useEffect(()=>(y.current++,c.current.clear(),f(new Set),x({}),m(new Set),w({}),()=>{y.current++}),[r]),{refresh:async()=>{const g=++y.current;c.current.clear(),m(new Set(b)),w({});const v=await Promise.all([...b].map(async l=>{try{return[l,J(await j(l))]}catch{return null}}));g===y.current&&(x(Object.fromEntries(v.filter(l=>l!==null))),f(new Set(v.flatMap(l=>l?[l[0]]:[]))),m(new Set))},expanded:b,children:o,loading:i,errors:E,collapse:g=>f(v=>{const l=new Set(v);return l.delete(g),l}),expand:async g=>{if(f(l=>new Set(l).add(g)),o[g]||c.current.has(g))return;const v=y.current;c.current.add(g),m(l=>new Set(l).add(g)),w(l=>{const N={...l};return delete N[g],N});try{const l=await j(g);y.current===v&&x(N=>({...N,[g]:J(l)}))}catch{y.current===v&&w(l=>({...l,[g]:"unavailable"}))}finally{y.current===v&&(c.current.delete(g),m(l=>{const N=new Set(l);return N.delete(g),N}))}}}}const Me={copy:"Copy",cut:"Cut",paste:"Paste",copyPath:"Copy path",editPath:"Edit directory path",rename:"Rename",delete:"Delete",cancel:"Cancel",confirmDelete:"Delete this item?",deleteHint:"You can undo this deletion after it finishes.",deleted:"Deleted",undo:"Undo",dismiss:"Dismiss",name:"Name",open:"Open",errors:{destination_exists:"An item with this name already exists.",recursive_destination:"Choose a different folder.",outside_root:"Choose a destination inside this folder.",protected_path:"This location is protected.",invalid_operation:"Enter a valid file name.",unsaved_changes:"Save the open file changes first.",daemon_update_required:"Update Vibelet on the connected computer to enable file operations.",ENOENT:"The file or folder no longer exists. Refresh the tree.",EACCES:"Permission denied.",EXDEV:"Moving between disks is unavailable. Copy the item first.",operation_failed:"File operation failed."}},Pe={copy:"复制",cut:"剪切",paste:"粘贴",copyPath:"复制路径",editPath:"修改目录路径",rename:"重命名",delete:"删除",cancel:"取消",confirmDelete:"删除这个项目?",deleteHint:"删除完成后可以撤销。",deleted:"已删除",undo:"撤销",dismiss:"关闭",name:"名称",open:"打开",errors:{destination_exists:"已有同名文件或文件夹,请换一个名称。",recursive_destination:"不能移动或复制到自身目录中。",outside_root:"请选择当前文件夹内的目标目录。",protected_path:"不能操作这个受保护的位置。",invalid_operation:"请输入有效的文件名。",unsaved_changes:"请先保存已打开文件的修改。",daemon_update_required:"请更新被连接电脑上的 Vibelet,以启用文件操作。",ENOENT:"文件或文件夹已不存在,请刷新文件树。",EACCES:"没有操作权限。",EXDEV:"暂不支持跨磁盘移动,请先复制。",operation_failed:"文件操作失败。"}},Le={copy:"複製",cut:"剪下",paste:"貼上",copyPath:"複製路徑",editPath:"修改目錄路徑",rename:"重新命名",delete:"刪除",cancel:"取消",confirmDelete:"刪除這個項目?",deleteHint:"刪除完成後可以復原。",deleted:"已刪除",undo:"復原",dismiss:"關閉",name:"名稱",open:"開啟",errors:{destination_exists:"已有同名檔案或資料夾,請換一個名稱。",recursive_destination:"不能移動或複製到自身目錄中。",outside_root:"請選擇目前資料夾內的目標目錄。",protected_path:"不能操作這個受保護的位置。",invalid_operation:"請輸入有效的檔案名稱。",unsaved_changes:"請先儲存已開啟檔案的修改。",daemon_update_required:"請更新被連接電腦上的 Vibelet,以啟用檔案操作。",ENOENT:"檔案或資料夾已不存在,請重新整理檔案樹。",EACCES:"沒有操作權限。",EXDEV:"暫不支援跨磁碟移動,請先複製。",operation_failed:"檔案操作失敗。"}};function Ae(){const r=le(ce().language);return r==="en"?Me:r==="zh-TW"?Le:Pe}let P=null,_=null;const Y="application/x-vibelet-file",X="vibelet:file-clipboard";function Re(r,p,j){const b=Ae(),[f,o]=u.useState(null),[x,i]=u.useState(null),[m,E]=u.useState(""),[w,y]=u.useState(null),[c,s]=u.useState(null),[K,C]=u.useState(""),[g,v]=u.useState(!1),l=u.useRef(!1),[N,T]=u.useState(null),[,W]=u.useState(0),R=ee(),S=R?.daemonId;u.useEffect(()=>{const e=()=>W(a=>a+1);return window.addEventListener(X,e),()=>window.removeEventListener(X,e)},[]),u.useEffect(()=>{o(null),i(null),y(null),s(null),C(""),T(null)},[r,p,S]);const I=e=>{const a=e instanceof Error?e.message:"operation_failed";C(b.errors[a]??b.errors.operation_failed)},L=async e=>{if(!R||l.current)return!1;l.current=!0,v(!0),C("");try{const a=await pe({...e,root:r,cwd:p},R);return ee()?.daemonId===S&&(a.action==="delete"&&s(a),await j()),!0}catch(a){return I(a),!1}finally{l.current=!1,v(!1)}},F=(e,a)=>{S&&(P={target:e,cut:a,daemonId:S,root:r,cwd:p},window.dispatchEvent(new Event(X)),o(null),C(""))},U=e=>e.directory?e.path:H(e.path)??r,V=!!(P&&P.daemonId===S),q=async e=>{const a=P;if(!V||!a)return;await L({action:a.cut?"move":"copy",path:a.target.path,sourceRoot:a.root,sourceCwd:a.cwd,target:B(U(e),$(a.target.path)),autoRename:!a.cut&&O(U(e),p)===O(H(a.target.path)??a.root,a.cwd)})&&a.cut&&P===a&&(P=null,window.dispatchEvent(new Event(X)))},n=(e,a,M)=>{l.current||o({...e,x:a,y:M})},D=e=>{i(e),E($(e.path)),o(null),C("")},k=async()=>{if(!x)return;const e=m.trim();if(!e||/[/\\\x00]/.test(e)||e==="."||e===".."){I(new Error("invalid_operation"));return}if(e===$(x.path)){i(null);return}await L({action:"move",path:x.path,target:B(H(x.path)??r,e)})&&i(null)},h=(e,a)=>{if(e.target!==e.currentTarget)return!1;if((e.metaKey||e.ctrlKey)&&["c","x","v"].includes(e.key.toLowerCase()))return e.preventDefault(),e.key.toLowerCase()==="v"?q(a):F(a,e.key.toLowerCase()==="x"),!0;if(e.key==="F2")return e.preventDefault(),D(a),!0;if(e.key==="Delete"||e.metaKey&&e.key==="Backspace")return e.preventDefault(),y(a),!0;if(e.key==="ContextMenu"||e.shiftKey&&e.key==="F10"){e.preventDefault();const d=e.currentTarget.getBoundingClientRect();return n(a,d.left+20,d.top+24),!0}return!1},A=e=>{if(!_||_.daemonId!==S||_.root!==r||_.cwd!==p||l.current)return!1;const a=O(_.target.path,p),M=O(e,p);return M!==a&&!M.startsWith(`${a}/`)&&O(H(_.target.path)??r,p)!==M};return{strings:b,menu:f,setMenu:o,rename:x,setRename:i,name:m,setName:E,deleting:w,setDeleting:y,error:K,setError:C,busy:g,undo:c,setUndo:s,canPaste:V,copy:F,paste:q,key:h,startRename:D,commitRename:k,openMenu:n,copyPath:async e=>{try{await fe(O(e.path,p))}catch(a){I(a)}},deleteItem:async()=>{w&&await L({action:"delete",path:w.path})&&y(null)},restore:async()=>{c&&await L({action:"restore",path:c.path,recoveryId:c.recoveryId})&&s(null)},isCut:e=>!!(P?.cut&&P.daemonId===S&&P.target.path===e),dropTarget:N,dragStart:(e,a)=>{if(!S||l.current){e.preventDefault();return}_={target:a,cut:!0,daemonId:S,root:r,cwd:p},e.dataTransfer.setData(Y,a.path),e.dataTransfer.effectAllowed="copyMove",o(null)},dragEnd:()=>{_=null,T(null)},dragOver:(e,a)=>{!e.dataTransfer.types.includes(Y)||!A(a)||(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=e.altKey?"copy":"move",T(a))},dragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||T(null)},drop:(e,a)=>{e.preventDefault(),e.stopPropagation(),T(null),!(!e.dataTransfer.types.includes(Y)||!A(a)||!_)&&L({action:e.altKey?"copy":"move",path:_.target.path,target:B(a,$(_.target.path))})}}}function Ie(r){return/\.(png|jpe?g|gif|webp|svg|ico)$/i.test(r)?we:/\.(tsx?|jsx?|json|css|html|py|rs|go|swift|ya?ml|sh)$/i.test(r)?ke:xe}function Oe({cwd:r,entries:p,error:j,loaded:b,loading:f,path:o,selectedPath:x,t:i,onListDirectory:m,onLoadChildren:E,onNewFolder:w,onOpenRemoteFile:y}){const c=Te(o,p,E),s=Re(o,r,async()=>{m(o),await c.refresh()}),K=u.useRef(null),[C,g]=u.useState(!0),[v,l]=u.useState(!1),[N,T]=u.useState(o),[W,R]=u.useState(x),[S,I]=u.useState();u.useEffect(()=>{T(o),g(!0),l(!1)},[o]),u.useEffect(()=>I(void 0),[o,p]),u.useEffect(()=>{R(x)},[x]);const L=(n,D)=>{n.isDirectory?c.expanded.has(D)?c.collapse(D):c.expand(D):(R(D),y(D,r))},F=n=>n?.focus(),U=(n,D,k)=>{if(n.stopPropagation(),s.key(n,{path:k,directory:D.isDirectory})||n.target instanceof HTMLInputElement)return;const h=Array.from(K.current?.querySelectorAll('[role="treeitem"]')??[]),A=h.indexOf(n.currentTarget);["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","Enter"," "].includes(n.key)&&n.preventDefault(),n.key==="ArrowUp"&&F(h[Math.max(0,A-1)]),n.key==="ArrowDown"&&F(h[Math.min(h.length-1,A+1)]),n.key==="Home"&&F(h[0]),n.key==="End"&&F(h.at(-1)),n.key==="ArrowRight"&&D.isDirectory&&(!c.expanded.has(k)||c.errors[k]?c.expand(k):F(n.currentTarget.querySelector('[role="treeitem"]'))),n.key==="ArrowLeft"&&(D.isDirectory&&c.expanded.has(k)?c.collapse(k):F(n.currentTarget.parentElement?.closest('[role="treeitem"]'))),(n.key==="Enter"||n.key===" ")&&L(D,k)},V=J(p),q=(n,D,k)=>n.map((h,A)=>{const e=B(D,h.name),a=c.expanded.has(e),M=h.isDirectory?a?ae:G:Ie(h.name);return t.jsxs("div",{role:"treeitem","aria-label":h.name,"aria-level":k+1,"aria-posinset":A+1,"aria-setsize":n.length,"aria-expanded":h.isDirectory?a:void 0,"aria-selected":W===e,"aria-busy":c.loading.has(e)||void 0,"data-path":e,className:"explorer-tree-item",tabIndex:S===e||!S&&k===0&&A===0?0:-1,onFocus:d=>{d.target===d.currentTarget&&I(e)},onKeyDown:d=>U(d,h,e),children:[t.jsxs("div",{className:"explorer-tree-row",draggable:!s.busy&&s.rename?.path!==e,"data-cut":s.isCut(e)||void 0,"data-drop":s.dropTarget===e||void 0,onContextMenu:d=>{d.preventDefault(),d.stopPropagation(),F(d.currentTarget.parentElement),s.openMenu({path:e,directory:h.isDirectory},d.clientX,d.clientY)},onDragStart:d=>s.dragStart(d,{path:e,directory:h.isDirectory}),onDragEnd:s.dragEnd,onDragOver:d=>h.isDirectory&&s.dragOver(d,e),onDragLeave:s.dragLeave,onDrop:d=>h.isDirectory&&s.drop(d,e),style:{paddingLeft:8+k*14},title:e,onClick:d=>{F(d.currentTarget.parentElement),L(h,e)},children:[t.jsx("span",{className:"explorer-chevron","aria-hidden":"true",children:h.isDirectory&&(c.loading.has(e)?t.jsx(te,{className:"explorer-spinner"}):a?t.jsx(re,{}):t.jsx(ne,{}))}),t.jsx(M,{className:h.isDirectory?"explorer-folder-icon":"explorer-file-icon","aria-hidden":"true"}),t.jsx("span",{className:"explorer-entry-name",children:s.rename?.path===e?t.jsx("input",{className:"explorer-rename","aria-label":s.strings.name,autoFocus:!0,value:s.name,disabled:s.busy,onFocus:d=>d.target.select(),onClick:d=>d.stopPropagation(),onChange:d=>s.setName(d.target.value),onKeyDown:d=>{d.stopPropagation(),d.key==="Enter"&&(d.preventDefault(),s.commitRename()),d.key==="Escape"&&(d.preventDefault(),s.setRename(null))}}):h.name})]}),h.isDirectory&&a&&t.jsxs("div",{role:"group",className:"explorer-tree-group",style:{"--tree-guide-left":`${14+k*14}px`},children:[c.children[e]?q(c.children[e],e,k+1):null,c.errors[e]&&t.jsx("button",{className:"explorer-retry",type:"button",onClick:()=>{c.expand(e)},children:i.retry}),c.children[e]?.length===0&&t.jsx("p",{className:"explorer-empty",style:{paddingLeft:36+k*14},children:i.noFilesInDirectory})]})]},e)});return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"explorer-heading",children:[t.jsx("h2",{children:i.fileTree}),t.jsxs("div",{className:"explorer-actions",children:[t.jsx("button",{className:"icon-button",title:s.strings.editPath,"aria-label":s.strings.editPath,"aria-expanded":v,onClick:()=>{T(o==="."?r:o),l(n=>!n)},type:"button",children:t.jsx(se,{"aria-hidden":"true"})}),t.jsx("button",{className:"icon-button",title:i.newFolder,"aria-label":i.newFolder,onClick:w,type:"button",children:t.jsx(ye,{"aria-hidden":"true"})}),t.jsx("button",{className:"icon-button",title:i.refreshFiles,"aria-label":i.refreshFiles,disabled:f,onClick:()=>{m(o),c.refresh()},type:"button",children:f?t.jsx(te,{className:"explorer-spinner","aria-hidden":"true"}):t.jsx(me,{"aria-hidden":"true"})}),t.jsx("button",{className:"icon-button",title:i.parentFolder,"aria-label":i.parentFolder,disabled:!H(o),onClick:()=>m(H(o)??o),type:"button",children:t.jsx(he,{"aria-hidden":"true"})})]})]}),t.jsxs("button",{type:"button",className:"explorer-root-path",onContextMenu:n=>{n.preventDefault(),s.openMenu({path:o,directory:!0},n.clientX,n.clientY)},onDragOver:n=>s.dragOver(n,o),onDragLeave:s.dragLeave,onDrop:n=>s.drop(n,o),"data-drop":s.dropTarget===o||void 0,title:o==="."?r:o,"aria-expanded":C,onClick:()=>{g(n=>!n),l(!1)},children:[C?t.jsx(re,{"aria-hidden":"true"}):t.jsx(ne,{"aria-hidden":"true"}),C?t.jsx(ae,{"aria-hidden":"true"}):t.jsx(G,{"aria-hidden":"true"}),t.jsx("span",{children:$(o==="."?r:o)||o})]}),v&&t.jsx("form",{className:"explorer-path-form",onSubmit:n=>{n.preventDefault(),N.trim()&&(m(N.trim()),l(!1))},children:t.jsx("input",{autoFocus:!0,"aria-label":i.path,value:N,onChange:n=>T(n.target.value),onKeyDown:n=>{n.key==="Escape"&&l(!1)}})}),j&&t.jsx("p",{className:"empty-copy",role:"alert",children:j}),f&&t.jsx("p",{className:"explorer-empty",role:"status",children:i.loadingFiles}),C&&t.jsx("div",{ref:K,role:"tree","aria-label":i.fileTree,className:"explorer-tree","aria-busy":f||s.busy,"data-drop":s.dropTarget===o||void 0,onContextMenu:n=>{n.preventDefault(),s.openMenu({path:o,directory:!0},n.clientX,n.clientY)},onDragOver:n=>s.dragOver(n,o),onDragLeave:s.dragLeave,onDrop:n=>s.drop(n,o),children:q(V,o,0)}),t.jsx(_e,{ops:s,root:o,onOpen:()=>s.menu&&y(s.menu.path,r)}),C&&b&&!f&&!j&&p.length===0&&t.jsx("p",{className:"explorer-empty",children:i.noFilesInDirectory})]})}function $e({busy:r,onLoadChildren:p,cwd:j,directory:b,newDirName:f,remoteFile:o,t:x,onCreateDirectory:i,onListDirectory:m,onNewDirNameChange:E,onOpenRemoteFile:w}){const[y,c]=u.useState(!1);return t.jsx(t.Fragment,{children:t.jsxs("section",{className:"control-section files-explorer",children:[t.jsx(Oe,{cwd:j,selectedPath:o?.path,onLoadChildren:p,onNewFolder:()=>c(s=>!s),entries:b.entries,error:b.error,loaded:b.loaded,loading:b.loading,path:b.path,t:x,onListDirectory:m,onOpenRemoteFile:w}),y&&t.jsxs("div",{className:"field-row file-tree-create",children:[t.jsx("input",{value:f,onChange:s=>E(s.target.value),placeholder:x.newFolder,"aria-label":x.newFolder,autoFocus:!0,onKeyDown:s=>{s.key==="Escape"&&(c(!1),E("")),s.key==="Enter"&&f.trim()&&!r&&i()}}),t.jsxs("button",{className:"icon-text-button",onClick:i,type:"button",disabled:r||!f.trim(),children:[t.jsx(G,{"aria-hidden":"true"}),x.create]})]})]})})}export{$e as FilesControlPanel};
@@ -1 +1 @@
1
- import{c as y,j as e,r as v,u as k,i as q,t as R}from"./index-ConcKf33.js";import{S as P,d as f,X as c,C as m,K as I}from"./App-CapuoJH2.js";const A=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["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"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]],D=y("bell-ring",A);function N({activeApproval:n,activeQuestion:l,busy:a,questionAnswers:o,t:i,onCancelQuestion:h,onQuestionChoice:s,onRespondApproval:r,onRespondQuestion:x}){const u=!!(n||l);return e.jsxs(e.Fragment,{children:[u?null:e.jsxs("section",{className:"control-section",children:[e.jsx("h2",{children:i.pendingActions}),e.jsx("p",{className:"empty-copy",children:i.noPendingActions})]}),n?e.jsxs("section",{className:"attention-panel",children:[e.jsxs("div",{className:"attention-head",children:[e.jsx(P,{"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("h2",{children:i.approvalRequired}),e.jsx("p",{children:n.toolName})]})]}),e.jsx("p",{children:n.description}),e.jsx("pre",{children:f(n.input)}),e.jsxs("div",{className:"attention-actions",children:[e.jsxs("button",{type:"button",className:"danger-button",onClick:()=>r(!1),disabled:a,children:[e.jsx(c,{"aria-hidden":"true"}),i.deny]}),e.jsxs("button",{type:"button",className:"approve-button",onClick:()=>r(!0),disabled:a,children:[e.jsx(m,{"aria-hidden":"true"}),i.approve]})]})]}):null,l?e.jsxs("section",{className:"attention-panel",children:[e.jsxs("div",{className:"attention-head",children:[e.jsx(I,{"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("h2",{children:i.inputNeeded}),e.jsx("p",{children:i.notificationQuestionCount(l.questions.length)})]})]}),l.questions.map(d=>e.jsxs("div",{className:"question-block",children:[e.jsx("strong",{children:d.question}),e.jsx("div",{className:"choice-list",children:d.options.map(t=>{const b=(o[d.id]??[]).includes(t.label);return e.jsxs("button",{className:b?"selected":"",onClick:()=>s(d.id,t.label,d.multiSelect),type:"button",children:[e.jsx("span",{children:t.label}),t.description?e.jsx("small",{children:t.description}):null]},t.label)})})]},d.id)),e.jsxs("div",{className:"attention-actions",children:[e.jsxs("button",{type:"button",className:"danger-button",onClick:h,disabled:a,children:[e.jsx(c,{"aria-hidden":"true"}),i.cancel]}),e.jsxs("button",{type:"button",className:"approve-button",onClick:x,disabled:a,children:[e.jsx(m,{"aria-hidden":"true"}),i.submit]})]})]}):null]})}function M(n){const{activeApproval:l,activeQuestion:a,pendingCount:o,requestKey:i,sessions:h,t:s,errorText:r}=n,[x,u]=v.useState(null),d=o>0&&x!==i,t=()=>u(i),b=k(t,void 0,d),j=g=>{const p=h.find(C=>C.sessionId===g);return p?R(p):g};return o===0?null:q.createPortal(d?e.jsxs("div",{className:"global-pending-layer",children:[e.jsx("div",{className:"global-pending-backdrop","aria-hidden":"true",onClick:t}),e.jsxs("div",{className:"global-pending-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"global-pending-title",tabIndex:-1,ref:b,children:[e.jsxs("header",{className:"global-pending-header",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"global-pending-title",children:s.pendingActions}),e.jsx("p",{"aria-live":"polite",children:s.pendingActionCount(o)})]}),e.jsxs("div",{className:"global-pending-header-actions",children:[e.jsx("button",{className:"global-pending-clear",type:"button",onClick:n.onClearRequests,children:s.clearPendingRequests}),e.jsx("button",{className:"icon-button",type:"button","aria-label":s.close,title:s.close,onClick:t,children:e.jsx(c,{"aria-hidden":"true"})})]})]}),e.jsxs("div",{className:"global-pending-content",children:[l&&e.jsxs("section",{"data-pending-session":l.sessionId,children:[e.jsxs("div",{className:"global-pending-session-row",children:[e.jsx("p",{className:"global-pending-session",children:j(l.sessionId)}),e.jsx("button",{type:"button","aria-label":s.dismissPendingRequest,title:s.dismissPendingRequest,onClick:()=>n.onDismissRequest("approval",l.sessionId,l.requestId),children:e.jsx(c,{"aria-hidden":"true"})})]}),e.jsx(N,{...n,activeQuestion:null})]}),a&&e.jsxs("section",{"data-pending-session":a.sessionId,children:[e.jsxs("div",{className:"global-pending-session-row",children:[e.jsx("p",{className:"global-pending-session",children:j(a.sessionId)}),e.jsx("button",{type:"button","aria-label":s.dismissPendingRequest,title:s.dismissPendingRequest,onClick:()=>n.onDismissRequest("question",a.sessionId,a.requestId),children:e.jsx(c,{"aria-hidden":"true"})})]}),e.jsx(N,{...n,activeApproval:null})]}),r&&e.jsx("p",{role:"alert",className:"global-pending-error",children:r})]})]})]}):e.jsxs("div",{className:"global-pending-reminder",children:[e.jsxs("button",{type:"button",onClick:()=>u(null),"aria-label":s.pendingActionCount(o),title:s.pendingActions,children:[e.jsx(D,{"aria-hidden":"true"}),e.jsx("span",{children:s.pendingActionCount(o)})]}),e.jsx("button",{type:"button",className:"global-pending-reminder-clear",onClick:n.onClearRequests,"aria-label":s.clearPendingRequests,title:s.clearPendingRequests,children:e.jsx(c,{"aria-hidden":"true"})})]}),document.body)}export{M as default};
1
+ import{c as y,j as e,r as v,u as k,i as q,t as R}from"./index-DJLpIsPI.js";import{S as P,d as f,X as c,C as m,K as I}from"./App-TtlYNy7O.js";const A=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["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"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]],D=y("bell-ring",A);function N({activeApproval:n,activeQuestion:l,busy:a,questionAnswers:o,t:i,onCancelQuestion:h,onQuestionChoice:s,onRespondApproval:r,onRespondQuestion:x}){const u=!!(n||l);return e.jsxs(e.Fragment,{children:[u?null:e.jsxs("section",{className:"control-section",children:[e.jsx("h2",{children:i.pendingActions}),e.jsx("p",{className:"empty-copy",children:i.noPendingActions})]}),n?e.jsxs("section",{className:"attention-panel",children:[e.jsxs("div",{className:"attention-head",children:[e.jsx(P,{"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("h2",{children:i.approvalRequired}),e.jsx("p",{children:n.toolName})]})]}),e.jsx("p",{children:n.description}),e.jsx("pre",{children:f(n.input)}),e.jsxs("div",{className:"attention-actions",children:[e.jsxs("button",{type:"button",className:"danger-button",onClick:()=>r(!1),disabled:a,children:[e.jsx(c,{"aria-hidden":"true"}),i.deny]}),e.jsxs("button",{type:"button",className:"approve-button",onClick:()=>r(!0),disabled:a,children:[e.jsx(m,{"aria-hidden":"true"}),i.approve]})]})]}):null,l?e.jsxs("section",{className:"attention-panel",children:[e.jsxs("div",{className:"attention-head",children:[e.jsx(I,{"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("h2",{children:i.inputNeeded}),e.jsx("p",{children:i.notificationQuestionCount(l.questions.length)})]})]}),l.questions.map(d=>e.jsxs("div",{className:"question-block",children:[e.jsx("strong",{children:d.question}),e.jsx("div",{className:"choice-list",children:d.options.map(t=>{const b=(o[d.id]??[]).includes(t.label);return e.jsxs("button",{className:b?"selected":"",onClick:()=>s(d.id,t.label,d.multiSelect),type:"button",children:[e.jsx("span",{children:t.label}),t.description?e.jsx("small",{children:t.description}):null]},t.label)})})]},d.id)),e.jsxs("div",{className:"attention-actions",children:[e.jsxs("button",{type:"button",className:"danger-button",onClick:h,disabled:a,children:[e.jsx(c,{"aria-hidden":"true"}),i.cancel]}),e.jsxs("button",{type:"button",className:"approve-button",onClick:x,disabled:a,children:[e.jsx(m,{"aria-hidden":"true"}),i.submit]})]})]}):null]})}function M(n){const{activeApproval:l,activeQuestion:a,pendingCount:o,requestKey:i,sessions:h,t:s,errorText:r}=n,[x,u]=v.useState(null),d=o>0&&x!==i,t=()=>u(i),b=k(t,void 0,d),j=g=>{const p=h.find(C=>C.sessionId===g);return p?R(p):g};return o===0?null:q.createPortal(d?e.jsxs("div",{className:"global-pending-layer",children:[e.jsx("div",{className:"global-pending-backdrop","aria-hidden":"true",onClick:t}),e.jsxs("div",{className:"global-pending-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"global-pending-title",tabIndex:-1,ref:b,children:[e.jsxs("header",{className:"global-pending-header",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"global-pending-title",children:s.pendingActions}),e.jsx("p",{"aria-live":"polite",children:s.pendingActionCount(o)})]}),e.jsxs("div",{className:"global-pending-header-actions",children:[e.jsx("button",{className:"global-pending-clear",type:"button",onClick:n.onClearRequests,children:s.clearPendingRequests}),e.jsx("button",{className:"icon-button",type:"button","aria-label":s.close,title:s.close,onClick:t,children:e.jsx(c,{"aria-hidden":"true"})})]})]}),e.jsxs("div",{className:"global-pending-content",children:[l&&e.jsxs("section",{"data-pending-session":l.sessionId,children:[e.jsxs("div",{className:"global-pending-session-row",children:[e.jsx("p",{className:"global-pending-session",children:j(l.sessionId)}),e.jsx("button",{type:"button","aria-label":s.dismissPendingRequest,title:s.dismissPendingRequest,onClick:()=>n.onDismissRequest("approval",l.sessionId,l.requestId),children:e.jsx(c,{"aria-hidden":"true"})})]}),e.jsx(N,{...n,activeQuestion:null})]}),a&&e.jsxs("section",{"data-pending-session":a.sessionId,children:[e.jsxs("div",{className:"global-pending-session-row",children:[e.jsx("p",{className:"global-pending-session",children:j(a.sessionId)}),e.jsx("button",{type:"button","aria-label":s.dismissPendingRequest,title:s.dismissPendingRequest,onClick:()=>n.onDismissRequest("question",a.sessionId,a.requestId),children:e.jsx(c,{"aria-hidden":"true"})})]}),e.jsx(N,{...n,activeApproval:null})]}),r&&e.jsx("p",{role:"alert",className:"global-pending-error",children:r})]})]})]}):e.jsxs("div",{className:"global-pending-reminder",children:[e.jsxs("button",{type:"button",onClick:()=>u(null),"aria-label":s.pendingActionCount(o),title:s.pendingActions,children:[e.jsx(D,{"aria-hidden":"true"}),e.jsx("span",{children:s.pendingActionCount(o)})]}),e.jsx("button",{type:"button",className:"global-pending-reminder-clear",onClick:n.onClearRequests,"aria-label":s.clearPendingRequests,title:s.clearPendingRequests,children:e.jsx(c,{"aria-hidden":"true"})})]}),document.body)}export{M as default};
@@ -1 +1 @@
1
- import{c as N,r as p,e as E,l as A,u as L,i as C,j as a,k as M}from"./index-ConcKf33.js";import{u as P,r as B,f as D,I as O,L as S,a as T,X as W}from"./App-CapuoJH2.js";import{A as z,a as R}from"./arrow-right-ORILUMdJ.js";const V=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]],F=N("file-image",V);async function h(r){const i=new Image;i.crossOrigin="anonymous",i.src=r,await i.decode();const s=document.createElement("canvas");s.width=i.naturalWidth,s.height=i.naturalHeight;const d=s.getContext("2d");if(!d)throw new Error("Canvas unavailable");return d.drawImage(i,0,0),await new Promise((m,c)=>s.toBlob(t=>t?m(t):c(new Error("Image conversion failed")),"image/png"))}function U({request:r,onClose:i}){const[s,d]=p.useState(r.index),[m,c]=p.useState("idle"),t=r.images[s],{url:n,error:w,fail:y}=P(t.src,t.cwd,null),v=B(t.src),u=t.alt||D(v??t.src),x=E(A().language),o=x==="en"?{title:"Image viewer",previous:"Previous image",next:"Next image",copy:"Copy image",copied:"Image copied",failed:"Could not copy image",open:"Open original in tab",close:"Close",unavailable:"Image unavailable"}:x==="zh-TW"?{title:"圖片檢視器",previous:"上一張",next:"下一張",copy:"複製圖片",copied:"圖片已複製",failed:"圖片複製失敗",open:"在 Tab 開啟原檔案",close:"關閉",unavailable:"無法載入圖片"}:{title:"图片查看器",previous:"上一张",next:"下一张",copy:"复制图片",copied:"图片已复制",failed:"图片复制失败",open:"在 Tab 打开原文件",close:"关闭",unavailable:"无法加载图片"},b=L(i);p.useEffect(()=>{const e=document.getElementById("vibelet-workspace"),g=e?.inert;return e&&(e.inert=!0),()=>{e&&(e.inert=!!g)}},[]),p.useEffect(()=>c("idle"),[s]);const f=e=>d(g=>Math.max(0,Math.min(r.images.length-1,g+e))),j=async()=>{if(n)try{const e=M().writeClipboardImage;e?await e(new Uint8Array(await(await h(n)).arrayBuffer())):await navigator.clipboard.write([new ClipboardItem({"image/png":h(n)})]),c("copied")}catch{c("failed")}},l=(e,g,I,k=!1)=>a.jsx("button",{type:"button",className:"icon-button",title:e,"aria-label":e,onClick:I,disabled:k,children:g});return C.createPortal(a.jsx("div",{className:"image-viewer-backdrop",onClick:e=>{e.target===e.currentTarget&&i()},children:a.jsxs("div",{ref:b,className:"image-viewer",role:"dialog","aria-modal":"true","aria-label":o.title,tabIndex:-1,onKeyDown:e=>{(e.key==="ArrowLeft"||e.key==="ArrowRight")&&(e.preventDefault(),e.stopPropagation(),f(e.key==="ArrowLeft"?-1:1))},children:[a.jsxs("header",{className:"image-viewer-toolbar",children:[a.jsx("span",{className:"image-viewer-caption",title:u,children:u}),a.jsxs("span",{className:"image-viewer-count","aria-live":"polite",children:[s+1," / ",r.images.length]}),l(o.copy,a.jsx(T,{}),()=>{j()},!n||w),l(o.open,a.jsx(F,{}),()=>{i(),r.onOpen(v??t.src,t.cwd)}),l(o.close,a.jsx(W,{}),i)]}),a.jsxs("div",{className:"image-viewer-stage",children:[l(o.previous,a.jsx(R,{}),()=>f(-1),s===0),a.jsx("div",{className:"image-viewer-content",children:w?a.jsxs("p",{role:"status",children:[a.jsx(O,{}),o.unavailable]}):n?a.jsx("img",{src:n,alt:u,onError:y},t.src):a.jsx(S,{className:"session-running-icon","aria-label":o.title})}),l(o.next,a.jsx(z,{}),()=>f(1),s===r.images.length-1)]}),a.jsx("div",{className:"image-viewer-status",role:"status",children:m==="copied"?o.copied:m==="failed"?o.failed:""})]})}),document.body)}export{U as default};
1
+ import{c as N,r as p,e as E,l as A,u as L,i as C,j as a,k as M}from"./index-DJLpIsPI.js";import{u as P,r as B,f as D,I as O,L as S,a as T,X as W}from"./App-TtlYNy7O.js";import{A as z,a as R}from"./arrow-right-mMC7Zi8G.js";const V=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]],F=N("file-image",V);async function h(r){const i=new Image;i.crossOrigin="anonymous",i.src=r,await i.decode();const s=document.createElement("canvas");s.width=i.naturalWidth,s.height=i.naturalHeight;const d=s.getContext("2d");if(!d)throw new Error("Canvas unavailable");return d.drawImage(i,0,0),await new Promise((m,c)=>s.toBlob(t=>t?m(t):c(new Error("Image conversion failed")),"image/png"))}function U({request:r,onClose:i}){const[s,d]=p.useState(r.index),[m,c]=p.useState("idle"),t=r.images[s],{url:n,error:w,fail:y}=P(t.src,t.cwd,null),v=B(t.src),u=t.alt||D(v??t.src),x=E(A().language),o=x==="en"?{title:"Image viewer",previous:"Previous image",next:"Next image",copy:"Copy image",copied:"Image copied",failed:"Could not copy image",open:"Open original in tab",close:"Close",unavailable:"Image unavailable"}:x==="zh-TW"?{title:"圖片檢視器",previous:"上一張",next:"下一張",copy:"複製圖片",copied:"圖片已複製",failed:"圖片複製失敗",open:"在 Tab 開啟原檔案",close:"關閉",unavailable:"無法載入圖片"}:{title:"图片查看器",previous:"上一张",next:"下一张",copy:"复制图片",copied:"图片已复制",failed:"图片复制失败",open:"在 Tab 打开原文件",close:"关闭",unavailable:"无法加载图片"},b=L(i);p.useEffect(()=>{const e=document.getElementById("vibelet-workspace"),g=e?.inert;return e&&(e.inert=!0),()=>{e&&(e.inert=!!g)}},[]),p.useEffect(()=>c("idle"),[s]);const f=e=>d(g=>Math.max(0,Math.min(r.images.length-1,g+e))),j=async()=>{if(n)try{const e=M().writeClipboardImage;e?await e(new Uint8Array(await(await h(n)).arrayBuffer())):await navigator.clipboard.write([new ClipboardItem({"image/png":h(n)})]),c("copied")}catch{c("failed")}},l=(e,g,I,k=!1)=>a.jsx("button",{type:"button",className:"icon-button",title:e,"aria-label":e,onClick:I,disabled:k,children:g});return C.createPortal(a.jsx("div",{className:"image-viewer-backdrop",onClick:e=>{e.target===e.currentTarget&&i()},children:a.jsxs("div",{ref:b,className:"image-viewer",role:"dialog","aria-modal":"true","aria-label":o.title,tabIndex:-1,onKeyDown:e=>{(e.key==="ArrowLeft"||e.key==="ArrowRight")&&(e.preventDefault(),e.stopPropagation(),f(e.key==="ArrowLeft"?-1:1))},children:[a.jsxs("header",{className:"image-viewer-toolbar",children:[a.jsx("span",{className:"image-viewer-caption",title:u,children:u}),a.jsxs("span",{className:"image-viewer-count","aria-live":"polite",children:[s+1," / ",r.images.length]}),l(o.copy,a.jsx(T,{}),()=>{j()},!n||w),l(o.open,a.jsx(F,{}),()=>{i(),r.onOpen(v??t.src,t.cwd)}),l(o.close,a.jsx(W,{}),i)]}),a.jsxs("div",{className:"image-viewer-stage",children:[l(o.previous,a.jsx(R,{}),()=>f(-1),s===0),a.jsx("div",{className:"image-viewer-content",children:w?a.jsxs("p",{role:"status",children:[a.jsx(O,{}),o.unavailable]}):n?a.jsx("img",{src:n,alt:u,onError:y},t.src):a.jsx(S,{className:"session-running-icon","aria-label":o.title})}),l(o.next,a.jsx(z,{}),()=>f(1),s===r.images.length-1)]}),a.jsx("div",{className:"image-viewer-status",role:"status",children:m==="copied"?o.copied:m==="failed"?o.failed:""})]})}),document.body)}export{U as default};
@@ -1 +1 @@
1
- import{j as e}from"./index-ConcKf33.js";import{C as o}from"./ChipGroup-ImS6VTKx.js";import{F as r}from"./App-CapuoJH2.js";function m({language:s,t:a,onLanguageChange:l,showFeedback:n=!0}){return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"control-section compact-section",children:[e.jsx("h2",{children:a.language}),e.jsxs("label",{className:"field",children:[e.jsx("span",{children:a.displayLanguage}),e.jsx(o,{ariaLabel:a.displayLanguage,options:[{value:"system",label:a.followSystem},{value:"en",label:a.english},{value:"zh",label:a.chinese},{value:"zh-TW",label:a.traditionalChinese}],value:s,onChange:i=>l(i)})]})]}),n&&e.jsx(r,{language:s})]})}export{m as LanguageSettingsPanel};
1
+ import{j as e}from"./index-DJLpIsPI.js";import{C as o}from"./ChipGroup-Do4YgaVh.js";import{F as r}from"./App-TtlYNy7O.js";function m({language:s,t:a,onLanguageChange:l,showFeedback:n=!0}){return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"control-section compact-section",children:[e.jsx("h2",{children:a.language}),e.jsxs("label",{className:"field",children:[e.jsx("span",{children:a.displayLanguage}),e.jsx(o,{ariaLabel:a.displayLanguage,options:[{value:"system",label:a.followSystem},{value:"en",label:a.english},{value:"zh",label:a.chinese},{value:"zh-TW",label:a.traditionalChinese}],value:s,onChange:i=>l(i)})]})]}),n&&e.jsx(r,{language:s})]})}export{m as LanguageSettingsPanel};
@@ -0,0 +1 @@
1
+ import{c as ne,m as F,r as a,u as ae,i as oe,j as t}from"./index-DJLpIsPI.js";import{j as H,X as le,b as E,c as K,S as ie,e as re}from"./App-TtlYNy7O.js";import{F as ce}from"./folder-plus-DbDHVXck.js";const de=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],ue=ne("bot",de),L="vibelet.web.recentCreations";function U(n){try{const s=JSON.parse(F().getItem(L)||"{}")[n];return Array.isArray(s)?s.filter(r=>typeof r.cwd=="string"&&["claude","codex"].includes(r.agent)&&Number.isFinite(r.createdAt)).slice(0,8):[]}catch{return[]}}function he(n,s){try{const r=JSON.parse(F().getItem(L)||"{}");r[n]=[s,...U(n).filter(c=>c.cwd!==s.cwd||c.agent!==s.agent)].slice(0,8),F().setItem(L,JSON.stringify(r))}catch{}}function we(n){const{t:s,device:r,onClose:c,onListDirectories:I}=n,o=s.newSession!=="New session",[l,w]=a.useState(n.cwd),[u,O]=a.useState(n.agent),[y,X]=a.useState(n.approvalMode),[p,C]=a.useState(n.model),[z,G]=a.useState(""),[S,P]=a.useState([]),[R,T]=a.useState(""),B=[{value:"normal",label:s.approvalNormal},{value:"plan",label:s.approvalPlan},{value:"acceptEdits",label:s.approvalEdits},{value:"autoApprove",label:s.approvalAuto}];a.useEffect(()=>{let e=!1;return P([]),T(""),n.onListModels(u).then(i=>{e||P(i)}).catch(()=>{e||T(o?"模型加载失败,请重新选择代理重试。":"Models unavailable. Select the agent again to retry.")}),()=>{e=!0}},[u,n.onListModels,o]);const[d,J]=a.useState([]),[h,V]=a.useState(-1),[x,k]=a.useState(!1),[W,g]=a.useState(""),[Q,D]=a.useState(!1),[N,_]=a.useState(!1),[m,v]=a.useState(null),M=a.useRef(null),Y=ae(c,M),[$]=a.useState(()=>U(r));a.useEffect(()=>{if(J([]),V(-1),g(""),!x||!n.connected)return;let e=!1;const i=/^(?:[a-z]:[\\/]|\\\\)/i.test(l)?l.replaceAll("\\","/"):l,b=i.lastIndexOf("/"),q=b<0?".":i.slice(0,b+1)||"/",te=i.slice(b+1).toLowerCase(),se=window.setTimeout(()=>{D(!0),I(q).then(f=>{e||J(f.filter(j=>j.isDirectory&&j.name.toLowerCase().startsWith(te)).map(j=>H(q,j.name)).slice(0,12))}).catch(f=>{e||g(String(f instanceof Error?f.message:f))}).finally(()=>{e||D(!1)})},180);return()=>{e=!0,window.clearTimeout(se),D(!1)}},[l,x,n.connected,I]);const A=e=>{w(e+(e.endsWith("/")?"":"/")),M.current?.focus()},Z=()=>{!l.trim()||!n.connected||N||(n.onCreate(l.trim(),u,{draft:z,approvalMode:y,model:p}),he(r,{cwd:l.trim(),agent:u,createdAt:Date.now()}),c())},ee=()=>{A(l||n.cwd||"/"),k(!0)};return oe.createPortal(t.jsxs("div",{className:"new-session-layer",children:[t.jsx("div",{className:"new-session-backdrop",onClick:c}),t.jsxs("div",{className:"new-session-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"new-session-title",ref:Y,tabIndex:-1,children:[t.jsxs("header",{children:[t.jsx("h2",{id:"new-session-title",children:s.newSession}),t.jsx("button",{type:"button",className:"icon-button","aria-label":s.close,title:s.close,onClick:c,children:t.jsx(le,{})})]}),t.jsxs("form",{onSubmit:e=>{e.preventDefault(),Z()},children:[t.jsx("div",{className:"new-session-agents",children:["claude","codex"].map(e=>t.jsxs("button",{type:"button","aria-pressed":u===e,onClick:()=>{O(e),C("")},children:[t.jsx(ue,{size:18}),e==="claude"?"Claude":"Codex"]},e))}),t.jsxs("div",{className:"new-session-path-field",children:[t.jsxs("label",{className:"new-session-field",children:[t.jsx("span",{children:s.workingDirectory}),t.jsxs("div",{className:"new-session-path-row",children:[t.jsx("input",{ref:M,value:l,"aria-label":s.workingDirectory,role:"combobox","aria-autocomplete":"list",spellCheck:!1,"aria-expanded":x&&d.length>0,"aria-controls":"new-session-paths","aria-activedescendant":h>=0?`new-session-path-${h}`:void 0,onFocus:()=>k(!0),onBlur:()=>k(!1),onChange:e=>w(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||e.keyCode===229||!d.length||(e.key==="ArrowDown"||e.key==="ArrowUp"?(e.preventDefault(),V(i=>i<0?e.key==="ArrowDown"?0:d.length-1:(i+(e.key==="ArrowDown"?1:-1)+d.length)%d.length)):(e.key==="Enter"||e.key==="Tab")&&h>=0&&(e.preventDefault(),A(d[h])))}}),t.jsx("button",{type:"button",className:"icon-button","aria-label":s.browseDirectories,title:s.browseDirectories,onMouseDown:e=>e.preventDefault(),onClick:()=>{ee()},children:t.jsx(E,{})}),t.jsx("button",{type:"button",className:"icon-button","aria-label":o?"新建文件夹":"New folder",title:o?"新建文件夹":"New folder",onMouseDown:e=>e.preventDefault(),onClick:()=>v(""),children:t.jsx(ce,{})})]})]}),x&&d.length>0&&t.jsx("div",{className:"new-session-paths",id:"new-session-paths",role:"listbox",children:d.map((e,i)=>t.jsxs("button",{type:"button",id:`new-session-path-${i}`,role:"option","aria-selected":h===i,onMouseDown:b=>b.preventDefault(),onClick:()=>A(e),title:e,children:[t.jsx(E,{size:14}),e]},e))}),t.jsx("small",{className:"new-session-path-status",role:W||R?"alert":"status",title:W||R,children:Q?s.loadingDirectories:" "})]}),m!==null&&t.jsxs("div",{className:"new-session-path-row",children:[t.jsx("input",{"aria-label":o?"文件夹名称":"Folder name",value:m,onChange:e=>v(e.target.value)}),t.jsx("button",{type:"button",disabled:N||!m.trim()||/[/\\]/.test(m),onClick:async()=>{_(!0),g("");try{const e=H(l,m.trim());await n.onCreateDirectory(e),w(e),v(null)}catch(e){g(String(e))}finally{_(!1)}},children:o?"创建文件夹":"Create folder"}),t.jsx("button",{type:"button",onClick:()=>v(null),children:s.close})]}),$.length>0&&t.jsxs("section",{className:"new-session-recent",children:[t.jsx("h3",{children:o?"最近创建":"Recent creations"}),$.map(e=>t.jsxs("button",{type:"button",title:e.cwd,onClick:()=>{w(e.cwd),O(e.agent),C("")},children:[t.jsx(E,{size:14}),t.jsx("span",{children:e.cwd}),t.jsx("small",{children:e.agent==="claude"?"Claude":"Codex"})]},e.cwd+e.agent))]}),t.jsxs("label",{className:"new-session-field",children:[t.jsx("span",{children:o?"初始消息(可选)":"Initial message (optional)"}),t.jsx("textarea",{value:z,onChange:e=>G(e.target.value),rows:3})]}),t.jsxs("div",{className:"new-session-options",children:[t.jsx(K,{icon:ie,label:B.find(e=>e.value===y)?.label??s.approvalMode,menuLabel:s.approvalMode,value:y,onSelect:X,options:B}),t.jsx(K,{icon:re,label:S.find(e=>e.value===p)?.label??(p||(o?"默认模型":"Default model")),menuLabel:o?"模型":"Model",value:p,onSelect:C,options:[...S.some(e=>e.value==="")?[]:[{value:"",label:o?"默认模型":"Default model"}],...S.map(e=>({value:e.value,label:e.label,description:e.desc}))]})]}),!n.connected&&t.jsx("p",{role:"status",children:o?"请先连接设备,再创建会话。":"Connect a device before creating a session."}),t.jsxs("footer",{children:[t.jsx("small",{children:o?"创建后自动发送初始消息":"The initial message is sent after creation"}),t.jsx("button",{type:"button",onClick:c,children:o?"取消":"Cancel"}),t.jsx("button",{className:"primary",type:"submit",disabled:!n.connected||!l.trim()||N,children:s.newSession})]})]})]})]}),document.body)}export{we as default};
@@ -1 +1 @@
1
- import{c as i,j as e}from"./index-ConcKf33.js";const r=[["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"}]],d=i("bell",r);function h({notificationsBlocked:c,permission:s,settings:t,t:a,onToggleEnabled:n}){return e.jsxs("section",{className:"control-section compact-section",children:[e.jsx("h2",{children:a.notifications}),e.jsxs("label",{className:`toggle-field notification-toggle ${c?"disabled":""}`,children:[e.jsxs("span",{children:[e.jsx(d,{"aria-hidden":"true"}),a.browserAlerts]}),e.jsx("input",{type:"checkbox",role:"switch","aria-checked":t.enabled&&!c&&s==="granted",className:"settings-switch",checked:t.enabled&&!c&&s==="granted",disabled:c,onChange:l=>n(l.target.checked)})]}),c?e.jsx("p",{className:"empty-copy",children:a.notificationsBlocked}):null]})}export{h as NotificationSettingsPanel};
1
+ import{c as i,j as e}from"./index-DJLpIsPI.js";const r=[["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"}]],d=i("bell",r);function h({notificationsBlocked:c,permission:s,settings:t,t:a,onToggleEnabled:n}){return e.jsxs("section",{className:"control-section compact-section",children:[e.jsx("h2",{children:a.notifications}),e.jsxs("label",{className:`toggle-field notification-toggle ${c?"disabled":""}`,children:[e.jsxs("span",{children:[e.jsx(d,{"aria-hidden":"true"}),a.browserAlerts]}),e.jsx("input",{type:"checkbox",role:"switch","aria-checked":t.enabled&&!c&&s==="granted",className:"settings-switch",checked:t.enabled&&!c&&s==="granted",disabled:c,onChange:l=>n(l.target.checked)})]}),c?e.jsx("p",{className:"empty-copy",children:a.notificationsBlocked}):null]})}export{h as NotificationSettingsPanel};
@@ -1,4 +1,4 @@
1
- import{c as q,_ as Z,r as T,j as w}from"./index-ConcKf33.js";import{z as J,X as W,B as Q}from"./App-CapuoJH2.js";const tt=[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]],et=q("eraser",tt);var Y=(e=>(e[e.CURSOR_KEY_APPLICATION=0]="CURSOR_KEY_APPLICATION",e[e.KEYPAD_KEY_APPLICATION=1]="KEYPAD_KEY_APPLICATION",e[e.IGNORE_KEYPAD_WITH_NUMLOCK=2]="IGNORE_KEYPAD_WITH_NUMLOCK",e[e.ALT_ESC_PREFIX=3]="ALT_ESC_PREFIX",e[e.MODIFY_OTHER_KEYS_STATE_2=4]="MODIFY_OTHER_KEYS_STATE_2",e[e.KITTY_KEYBOARD_FLAGS=5]="KITTY_KEYBOARD_FLAGS",e))(Y||{}),$=(e=>(e[e.RELEASE=0]="RELEASE",e[e.PRESS=1]="PRESS",e[e.REPEAT=2]="REPEAT",e))($||{}),h=(e=>(e[e.UNIDENTIFIED=0]="UNIDENTIFIED",e[e.GRAVE=1]="GRAVE",e[e.BACKSLASH=2]="BACKSLASH",e[e.BRACKET_LEFT=3]="BRACKET_LEFT",e[e.BRACKET_RIGHT=4]="BRACKET_RIGHT",e[e.COMMA=5]="COMMA",e[e.ZERO=6]="ZERO",e[e.ONE=7]="ONE",e[e.TWO=8]="TWO",e[e.THREE=9]="THREE",e[e.FOUR=10]="FOUR",e[e.FIVE=11]="FIVE",e[e.SIX=12]="SIX",e[e.SEVEN=13]="SEVEN",e[e.EIGHT=14]="EIGHT",e[e.NINE=15]="NINE",e[e.EQUAL=16]="EQUAL",e[e.INTL_BACKSLASH=17]="INTL_BACKSLASH",e[e.INTL_RO=18]="INTL_RO",e[e.INTL_YEN=19]="INTL_YEN",e[e.A=20]="A",e[e.B=21]="B",e[e.C=22]="C",e[e.D=23]="D",e[e.E=24]="E",e[e.F=25]="F",e[e.G=26]="G",e[e.H=27]="H",e[e.I=28]="I",e[e.J=29]="J",e[e.K=30]="K",e[e.L=31]="L",e[e.M=32]="M",e[e.N=33]="N",e[e.O=34]="O",e[e.P=35]="P",e[e.Q=36]="Q",e[e.R=37]="R",e[e.S=38]="S",e[e.T=39]="T",e[e.U=40]="U",e[e.V=41]="V",e[e.W=42]="W",e[e.X=43]="X",e[e.Y=44]="Y",e[e.Z=45]="Z",e[e.MINUS=46]="MINUS",e[e.PERIOD=47]="PERIOD",e[e.QUOTE=48]="QUOTE",e[e.SEMICOLON=49]="SEMICOLON",e[e.SLASH=50]="SLASH",e[e.ALT_LEFT=51]="ALT_LEFT",e[e.ALT_RIGHT=52]="ALT_RIGHT",e[e.BACKSPACE=53]="BACKSPACE",e[e.CAPS_LOCK=54]="CAPS_LOCK",e[e.CONTEXT_MENU=55]="CONTEXT_MENU",e[e.CONTROL_LEFT=56]="CONTROL_LEFT",e[e.CONTROL_RIGHT=57]="CONTROL_RIGHT",e[e.ENTER=58]="ENTER",e[e.META_LEFT=59]="META_LEFT",e[e.META_RIGHT=60]="META_RIGHT",e[e.SHIFT_LEFT=61]="SHIFT_LEFT",e[e.SHIFT_RIGHT=62]="SHIFT_RIGHT",e[e.SPACE=63]="SPACE",e[e.TAB=64]="TAB",e[e.CONVERT=65]="CONVERT",e[e.KANA_MODE=66]="KANA_MODE",e[e.NON_CONVERT=67]="NON_CONVERT",e[e.DELETE=68]="DELETE",e[e.END=69]="END",e[e.HELP=70]="HELP",e[e.HOME=71]="HOME",e[e.INSERT=72]="INSERT",e[e.PAGE_DOWN=73]="PAGE_DOWN",e[e.PAGE_UP=74]="PAGE_UP",e[e.DOWN=75]="DOWN",e[e.LEFT=76]="LEFT",e[e.RIGHT=77]="RIGHT",e[e.UP=78]="UP",e[e.NUM_LOCK=79]="NUM_LOCK",e[e.KP_0=80]="KP_0",e[e.KP_1=81]="KP_1",e[e.KP_2=82]="KP_2",e[e.KP_3=83]="KP_3",e[e.KP_4=84]="KP_4",e[e.KP_5=85]="KP_5",e[e.KP_6=86]="KP_6",e[e.KP_7=87]="KP_7",e[e.KP_8=88]="KP_8",e[e.KP_9=89]="KP_9",e[e.KP_PLUS=90]="KP_PLUS",e[e.KP_BACKSPACE=91]="KP_BACKSPACE",e[e.KP_CLEAR=92]="KP_CLEAR",e[e.KP_CLEAR_ENTRY=93]="KP_CLEAR_ENTRY",e[e.KP_COMMA=94]="KP_COMMA",e[e.KP_PERIOD=95]="KP_PERIOD",e[e.KP_DIVIDE=96]="KP_DIVIDE",e[e.KP_ENTER=97]="KP_ENTER",e[e.KP_EQUAL=98]="KP_EQUAL",e[e.KP_MEMORY_ADD=99]="KP_MEMORY_ADD",e[e.KP_MEMORY_CLEAR=100]="KP_MEMORY_CLEAR",e[e.KP_MEMORY_RECALL=101]="KP_MEMORY_RECALL",e[e.KP_MEMORY_STORE=102]="KP_MEMORY_STORE",e[e.KP_MEMORY_SUBTRACT=103]="KP_MEMORY_SUBTRACT",e[e.KP_MULTIPLY=104]="KP_MULTIPLY",e[e.KP_PAREN_LEFT=105]="KP_PAREN_LEFT",e[e.KP_PAREN_RIGHT=106]="KP_PAREN_RIGHT",e[e.KP_MINUS=107]="KP_MINUS",e[e.KP_SEPARATOR=108]="KP_SEPARATOR",e[e.NUMPAD_UP=109]="NUMPAD_UP",e[e.NUMPAD_DOWN=110]="NUMPAD_DOWN",e[e.NUMPAD_RIGHT=111]="NUMPAD_RIGHT",e[e.NUMPAD_LEFT=112]="NUMPAD_LEFT",e[e.NUMPAD_BEGIN=113]="NUMPAD_BEGIN",e[e.NUMPAD_HOME=114]="NUMPAD_HOME",e[e.NUMPAD_END=115]="NUMPAD_END",e[e.NUMPAD_INSERT=116]="NUMPAD_INSERT",e[e.NUMPAD_DELETE=117]="NUMPAD_DELETE",e[e.NUMPAD_PAGE_UP=118]="NUMPAD_PAGE_UP",e[e.NUMPAD_PAGE_DOWN=119]="NUMPAD_PAGE_DOWN",e[e.ESCAPE=120]="ESCAPE",e[e.F1=121]="F1",e[e.F2=122]="F2",e[e.F3=123]="F3",e[e.F4=124]="F4",e[e.F5=125]="F5",e[e.F6=126]="F6",e[e.F7=127]="F7",e[e.F8=128]="F8",e[e.F9=129]="F9",e[e.F10=130]="F10",e[e.F11=131]="F11",e[e.F12=132]="F12",e[e.F13=133]="F13",e[e.F14=134]="F14",e[e.F15=135]="F15",e[e.F16=136]="F16",e[e.F17=137]="F17",e[e.F18=138]="F18",e[e.F19=139]="F19",e[e.F20=140]="F20",e[e.F21=141]="F21",e[e.F22=142]="F22",e[e.F23=143]="F23",e[e.F24=144]="F24",e[e.F25=145]="F25",e[e.FN_LOCK=146]="FN_LOCK",e[e.PRINT_SCREEN=147]="PRINT_SCREEN",e[e.SCROLL_LOCK=148]="SCROLL_LOCK",e[e.PAUSE=149]="PAUSE",e[e.BROWSER_BACK=150]="BROWSER_BACK",e[e.BROWSER_FAVORITES=151]="BROWSER_FAVORITES",e[e.BROWSER_FORWARD=152]="BROWSER_FORWARD",e[e.BROWSER_HOME=153]="BROWSER_HOME",e[e.BROWSER_REFRESH=154]="BROWSER_REFRESH",e[e.BROWSER_SEARCH=155]="BROWSER_SEARCH",e[e.BROWSER_STOP=156]="BROWSER_STOP",e[e.EJECT=157]="EJECT",e[e.LAUNCH_APP_1=158]="LAUNCH_APP_1",e[e.LAUNCH_APP_2=159]="LAUNCH_APP_2",e[e.LAUNCH_MAIL=160]="LAUNCH_MAIL",e[e.MEDIA_PLAY_PAUSE=161]="MEDIA_PLAY_PAUSE",e[e.MEDIA_SELECT=162]="MEDIA_SELECT",e[e.MEDIA_STOP=163]="MEDIA_STOP",e[e.MEDIA_TRACK_NEXT=164]="MEDIA_TRACK_NEXT",e[e.MEDIA_TRACK_PREVIOUS=165]="MEDIA_TRACK_PREVIOUS",e[e.POWER=166]="POWER",e[e.SLEEP=167]="SLEEP",e[e.AUDIO_VOLUME_DOWN=168]="AUDIO_VOLUME_DOWN",e[e.AUDIO_VOLUME_MUTE=169]="AUDIO_VOLUME_MUTE",e[e.AUDIO_VOLUME_UP=170]="AUDIO_VOLUME_UP",e[e.WAKE_UP=171]="WAKE_UP",e[e.COPY=172]="COPY",e[e.CUT=173]="CUT",e[e.PASTE=174]="PASTE",e))(h||{}),k=(e=>(e[e.NONE=0]="NONE",e[e.SHIFT=1]="SHIFT",e[e.CTRL=2]="CTRL",e[e.ALT=4]="ALT",e[e.SUPER=8]="SUPER",e[e.CAPSLOCK=16]="CAPSLOCK",e[e.NUMLOCK=32]="NUMLOCK",e))(k||{}),B=(e=>(e[e.NONE=0]="NONE",e[e.PARTIAL=1]="PARTIAL",e[e.FULL=2]="FULL",e))(B||{});const z=80;var b=(e=>(e[e.BOLD=1]="BOLD",e[e.ITALIC=2]="ITALIC",e[e.UNDERLINE=4]="UNDERLINE",e[e.STRIKETHROUGH=8]="STRIKETHROUGH",e[e.INVERSE=16]="INVERSE",e[e.INVISIBLE=32]="INVISIBLE",e[e.BLINK=64]="BLINK",e[e.FAINT=128]="FAINT",e))(b||{});class N{constructor(t){this.exports=t.exports,this.memory=this.exports.memory}createKeyEncoder(){return new st(this.exports)}createTerminal(t=80,i=24,s){return new it(this.exports,this.memory,t,i,s)}static async load(t){if(t)return N.loadFromPath(t);const i=new URL("/web/assets/ghostty-vt-DOMeXDrv.wasm",import.meta.url),s=[];if(i.protocol==="file:"){let o=i.pathname;o.match(/^\/[A-Za-z]:\//)&&(o=o.slice(1)),s.push(o)}s.push(i.href,"./ghostty-vt.wasm","/ghostty-vt.wasm");let r=null;for(const o of s)try{return await N.loadFromPath(o)}catch(n){r=n instanceof Error?n:new Error(String(n))}throw r||new Error("Failed to load Ghostty WASM")}static async loadFromPath(t){let i;if(typeof Bun<"u"&&typeof Bun.file=="function")try{const o=Bun.file(t);await o.exists()&&(i=await o.arrayBuffer())}catch{}if(!i)try{const o=await(await Z(async()=>{const{readFile:n}=await Promise.resolve().then(()=>St);return{readFile:n}},void 0)).readFile(t);i=o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}catch{}if(!i){const o=await fetch(t);if(!o.ok)throw new Error(`Failed to fetch WASM: ${o.status} ${o.statusText}`);if(i=await o.arrayBuffer(),i.byteLength===0)throw new Error(`WASM file is empty (0 bytes). Check path: ${t}`)}if(!i)throw new Error(`Could not load WASM from path: ${t}`);const s=await WebAssembly.compile(i),r=await WebAssembly.instantiate(s,{env:{log:(o,n)=>{const l=new Uint8Array(r.exports.memory.buffer,o,n);console.log("[ghostty-vt]",new TextDecoder().decode(l))}}});return new N(r)}}class st{constructor(t){this.encoder=0,this.exports=t;const i=this.exports.ghostty_wasm_alloc_opaque(),s=this.exports.ghostty_key_encoder_new(0,i);if(s!==0)throw new Error(`Failed to create key encoder: ${s}`);const r=new DataView(this.exports.memory.buffer);this.encoder=r.getUint32(i,!0),this.exports.ghostty_wasm_free_opaque(i)}setOption(t,i){const s=this.exports.ghostty_wasm_alloc_u8();new DataView(this.exports.memory.buffer).setUint8(s,typeof i=="boolean"?i?1:0:i),this.exports.ghostty_key_encoder_setopt(this.encoder,t,s),this.exports.ghostty_wasm_free_u8(s)}setKittyFlags(t){this.setOption(Y.KITTY_KEYBOARD_FLAGS,t)}encode(t){const i=this.exports.ghostty_wasm_alloc_opaque(),s=this.exports.ghostty_key_event_new(0,i);if(s!==0)throw new Error(`Failed to create key event: ${s}`);const r=new DataView(this.exports.memory.buffer),o=r.getUint32(i,!0);if(this.exports.ghostty_wasm_free_opaque(i),this.exports.ghostty_key_event_set_action(o,t.action),this.exports.ghostty_key_event_set_key(o,t.key),this.exports.ghostty_key_event_set_mods(o,t.mods),t.utf8){const p=new TextEncoder().encode(t.utf8),u=this.exports.ghostty_wasm_alloc_u8_array(p.length);new Uint8Array(this.exports.memory.buffer).set(p,u),this.exports.ghostty_key_event_set_utf8(o,u,p.length),this.exports.ghostty_wasm_free_u8_array(u,p.length)}const n=32,l=this.exports.ghostty_wasm_alloc_u8_array(n),a=this.exports.ghostty_wasm_alloc_usize(),c=this.exports.ghostty_key_encoder_encode(this.encoder,o,l,n,a);if(c!==0)throw this.exports.ghostty_wasm_free_u8_array(l,n),this.exports.ghostty_wasm_free_usize(a),this.exports.ghostty_key_event_free(o),new Error(`Failed to encode key: ${c}`);const d=r.getUint32(a,!0),m=new Uint8Array(this.exports.memory.buffer,l,d).slice();return this.exports.ghostty_wasm_free_u8_array(l,n),this.exports.ghostty_wasm_free_usize(a),this.exports.ghostty_key_event_free(o),m}dispose(){this.encoder&&(this.exports.ghostty_key_encoder_free(this.encoder),this.encoder=0)}}const j=class R{constructor(t,i,s=80,r=24,o){var n;if(this.viewportBufferPtr=0,this.viewportBufferSize=0,this.cellPool=[],this.graphemeBuffer=null,this.graphemeBufferPtr=0,this.exports=t,this.memory=i,this._cols=s,this._rows=r,o){const l=this.exports.ghostty_wasm_alloc_u8_array(z);if(l===0)throw new Error("Failed to allocate config (out of memory)");try{const a=new DataView(this.memory.buffer);let c=l;a.setUint32(c,o.scrollbackLimit??1e4,!0),c+=4,a.setUint32(c,o.fgColor??0,!0),c+=4,a.setUint32(c,o.bgColor??0,!0),c+=4,a.setUint32(c,o.cursorColor??0,!0),c+=4;for(let d=0;d<16;d++)a.setUint32(c,((n=o.palette)==null?void 0:n[d])??0,!0),c+=4;this.handle=this.exports.ghostty_terminal_new_with_config(s,r,l)}finally{this.exports.ghostty_wasm_free_u8_array(l,z)}}else this.handle=this.exports.ghostty_terminal_new(s,r);if(!this.handle)throw new Error("Failed to create terminal");this.initCellPool()}get cols(){return this._cols}get rows(){return this._rows}write(t){const i=typeof t=="string"?new TextEncoder().encode(t):t,s=this.exports.ghostty_wasm_alloc_u8_array(i.length);new Uint8Array(this.memory.buffer).set(i,s),this.exports.ghostty_terminal_write(this.handle,s,i.length),this.exports.ghostty_wasm_free_u8_array(s,i.length)}resize(t,i){t===this._cols&&i===this._rows||(this._cols=t,this._rows=i,this.exports.ghostty_terminal_resize(this.handle,t,i),this.invalidateBuffers(),this.initCellPool())}free(){this.viewportBufferPtr&&(this.exports.ghostty_wasm_free_u8_array(this.viewportBufferPtr,this.viewportBufferSize),this.viewportBufferPtr=0),this.exports.ghostty_terminal_free(this.handle)}update(){return this.exports.ghostty_render_state_update(this.handle)}getCursor(){return this.update(),{x:this.exports.ghostty_render_state_get_cursor_x(this.handle),y:this.exports.ghostty_render_state_get_cursor_y(this.handle),viewportX:this.exports.ghostty_render_state_get_cursor_x(this.handle),viewportY:this.exports.ghostty_render_state_get_cursor_y(this.handle),visible:this.exports.ghostty_render_state_get_cursor_visible(this.handle),blinking:!1,style:"block"}}getColors(){const t=this.exports.ghostty_render_state_get_bg_color(this.handle),i=this.exports.ghostty_render_state_get_fg_color(this.handle);return{background:{r:t>>16&255,g:t>>8&255,b:t&255},foreground:{r:i>>16&255,g:i>>8&255,b:i&255},cursor:null}}isRowDirty(t){return this.exports.ghostty_render_state_is_row_dirty(this.handle,t)}markClean(){this.exports.ghostty_render_state_mark_clean(this.handle)}getViewport(){const t=this._cols*this._rows,i=t*R.CELL_SIZE;return(!this.viewportBufferPtr||this.viewportBufferSize<i)&&(this.viewportBufferPtr&&this.exports.ghostty_wasm_free_u8_array(this.viewportBufferPtr,this.viewportBufferSize),this.viewportBufferPtr=this.exports.ghostty_wasm_alloc_u8_array(i),this.viewportBufferSize=i),this.exports.ghostty_render_state_get_viewport(this.handle,this.viewportBufferPtr,t)<0?this.cellPool:(this.parseCellsIntoPool(this.viewportBufferPtr,t),this.cellPool)}getLine(t){if(t<0||t>=this._rows)return null;this.update();const i=this.getViewport(),s=t*this._cols;return i.slice(s,s+this._cols).map(r=>({...r}))}isDirty(){return this.update()!==B.NONE}needsFullRedraw(){return this.update()===B.FULL}clearDirty(){this.markClean()}isAlternateScreen(){return!!this.exports.ghostty_terminal_is_alternate_screen(this.handle)}hasBracketedPaste(){return this.getMode(2004,!1)}hasFocusEvents(){return this.getMode(1004,!1)}hasMouseTracking(){return this.exports.ghostty_terminal_has_mouse_tracking(this.handle)!==0}getDimensions(){return{cols:this._cols,rows:this._rows}}getScrollbackLength(){return this.exports.ghostty_terminal_get_scrollback_length(this.handle)}getScrollbackLine(t){const i=this._cols*R.CELL_SIZE;(!this.viewportBufferPtr||this.viewportBufferSize<i)&&(this.viewportBufferPtr&&this.exports.ghostty_wasm_free_u8_array(this.viewportBufferPtr,this.viewportBufferSize),this.viewportBufferPtr=this.exports.ghostty_wasm_alloc_u8_array(i),this.viewportBufferSize=i),this.update();const s=this.exports.ghostty_terminal_get_scrollback_line(this.handle,t,this.viewportBufferPtr,this._cols);if(s<0)return null;const r=[],o=this.memory.buffer,n=new Uint8Array(o,this.viewportBufferPtr,s*R.CELL_SIZE),l=new DataView(o,this.viewportBufferPtr,s*R.CELL_SIZE);for(let a=0;a<s;a++){const c=a*R.CELL_SIZE;r.push({codepoint:l.getUint32(c,!0),fg_r:n[c+4],fg_g:n[c+5],fg_b:n[c+6],bg_r:n[c+7],bg_g:n[c+8],bg_b:n[c+9],flags:n[c+10],width:n[c+11],hyperlink_id:l.getUint16(c+12,!0),grapheme_len:n[c+14]})}return r}isRowWrapped(t){return this.exports.ghostty_terminal_is_row_wrapped(this.handle,t)!==0}getHyperlinkUri(t){return null}hasResponse(){return this.exports.ghostty_terminal_has_response(this.handle)}readResponse(){if(!this.hasResponse())return null;const t=256,i=this.exports.ghostty_wasm_alloc_u8_array(t);try{const s=this.exports.ghostty_terminal_read_response(this.handle,i,t);if(s<=0)return null;const r=new Uint8Array(this.memory.buffer,i,s);return new TextDecoder().decode(r.slice())}finally{this.exports.ghostty_wasm_free_u8_array(i,t)}}getMode(t,i=!1){return this.exports.ghostty_terminal_get_mode(this.handle,t,i)!==0}initCellPool(){const t=this._cols*this._rows;if(this.cellPool.length<t)for(let i=this.cellPool.length;i<t;i++)this.cellPool.push({codepoint:0,fg_r:204,fg_g:204,fg_b:204,bg_r:0,bg_g:0,bg_b:0,flags:0,width:1,hyperlink_id:0,grapheme_len:0})}parseCellsIntoPool(t,i){const s=this.memory.buffer,r=new Uint8Array(s,t,i*R.CELL_SIZE),o=new DataView(s,t,i*R.CELL_SIZE);for(let n=0;n<i;n++){const l=n*R.CELL_SIZE,a=this.cellPool[n];a.codepoint=o.getUint32(l,!0),a.fg_r=r[l+4],a.fg_g=r[l+5],a.fg_b=r[l+6],a.bg_r=r[l+7],a.bg_g=r[l+8],a.bg_b=r[l+9],a.flags=r[l+10],a.width=r[l+11],a.hyperlink_id=o.getUint16(l+12,!0),a.grapheme_len=r[l+14]}}getGrapheme(t,i){this.graphemeBuffer||(this.graphemeBufferPtr=this.exports.ghostty_wasm_alloc_u8_array(64),this.graphemeBuffer=new Uint32Array(this.memory.buffer,this.graphemeBufferPtr,16));const s=this.exports.ghostty_render_state_get_grapheme(this.handle,t,i,this.graphemeBufferPtr,16);if(s<0)return null;const r=new Uint32Array(this.memory.buffer,this.graphemeBufferPtr,s);return Array.from(r)}getGraphemeString(t,i){const s=this.getGrapheme(t,i);return!s||s.length===0?" ":String.fromCodePoint(...s)}getScrollbackGrapheme(t,i){this.graphemeBuffer||(this.graphemeBufferPtr=this.exports.ghostty_wasm_alloc_u8_array(64),this.graphemeBuffer=new Uint32Array(this.memory.buffer,this.graphemeBufferPtr,16));const s=this.exports.ghostty_terminal_get_scrollback_grapheme(this.handle,t,i,this.graphemeBufferPtr,16);if(s<0)return null;const r=new Uint32Array(this.memory.buffer,this.graphemeBufferPtr,s);return Array.from(r)}getScrollbackGraphemeString(t,i){const s=this.getScrollbackGrapheme(t,i);return!s||s.length===0?" ":String.fromCodePoint(...s)}invalidateBuffers(){this.viewportBufferPtr&&(this.exports.ghostty_wasm_free_u8_array(this.viewportBufferPtr,this.viewportBufferSize),this.viewportBufferPtr=0,this.viewportBufferSize=0)}};j.CELL_SIZE=16;let it=j;class L{constructor(){this.listeners=[],this.event=t=>(this.listeners.push(t),{dispose:()=>{const i=this.listeners.indexOf(t);i>=0&&this.listeners.splice(i,1)}})}fire(t){for(const i of this.listeners)i(t)}dispose(){this.listeners=[]}}class rt{constructor(t){this.bufferChangeEmitter=new L,this.terminal=t}get active(){const t=this.terminal.wasmTerm;return t?t.isAlternateScreen()?this.alternate:this.normal:this.normal}get normal(){return this._normalBuffer||(this._normalBuffer=new G(this.terminal,"normal")),this._normalBuffer}get alternate(){return this._alternateBuffer||(this._alternateBuffer=new G(this.terminal,"alternate")),this._alternateBuffer}get onBufferChange(){return this.bufferChangeEmitter.event}_fireBufferChange(t){this.bufferChangeEmitter.fire(t)}}class G{constructor(t,i){this.terminal=t,this.bufferType=i;const s={codepoint:0,fg_r:204,fg_g:204,fg_b:204,bg_r:0,bg_g:0,bg_b:0,flags:0,width:1,hyperlink_id:0,grapheme_len:0};this.nullCell=new U(s,0)}get type(){return this.bufferType}get cursorX(){const t=this.getWasmTerm();return t?t.getCursor().x:0}get cursorY(){const t=this.getWasmTerm();return t?t.getCursor().y:0}get viewportY(){return 0}get baseY(){return 0}get length(){const t=this.getWasmTerm();return t?this.bufferType==="alternate"?t.rows:t.getScrollbackLength()+t.rows:0}getLine(t){const i=this.getWasmTerm();if(!i||t<0||t>=this.length)return;const s=i.getScrollbackLength();let r,o,n;if(this.bufferType==="normal"&&t<s){const l=t;r=i.getScrollbackLine(l),n=!1}else o=this.bufferType==="normal"?t-s:t,r=i.getLine(o),n=i.isRowWrapped(o);if(r)return new ot(r,n,i.cols)}getNullCell(){return this.nullCell}getWasmTerm(){return this.terminal.wasmTerm}}class ot{constructor(t,i,s){this.cells=t,this._isWrapped=i,this._length=s}get length(){return this._length}get isWrapped(){return this._isWrapped}getCell(t){if(!(t<0||t>=this._length))return t>=this.cells.length?new U({codepoint:0,fg_r:204,fg_g:204,fg_b:204,bg_r:0,bg_g:0,bg_b:0,flags:0,width:1,hyperlink_id:0,grapheme_len:0},t):new U(this.cells[t],t)}translateToString(t=!1,i=0,s=this._length){const r=Math.max(0,Math.min(i,this._length)),o=Math.max(r,Math.min(s,this._length));let n="";for(let l=r;l<o;l++){const a=this.getCell(l);if(a){const c=a.getChars();n+=c}}return t&&(n=n.trimEnd()),n}}class U{constructor(t,i){this.cell=t,this.x=i}getChars(){const t=this.cell.codepoint;return t===0?"":t<0||t>1114111||t>=55296&&t<=57343?"�":String.fromCodePoint(t)}getCode(){return this.cell.codepoint}getWidth(){return this.cell.width}getFgColorMode(){return-1}getBgColorMode(){return-1}getFgColor(){return this.cell.fg_r<<16|this.cell.fg_g<<8|this.cell.fg_b}getBgColor(){return this.cell.bg_r<<16|this.cell.bg_g<<8|this.cell.bg_b}isBold(){return this.cell.flags&b.BOLD?1:0}isItalic(){return this.cell.flags&b.ITALIC?1:0}isUnderline(){return this.cell.flags&b.UNDERLINE?1:0}isStrikethrough(){return this.cell.flags&b.STRIKETHROUGH?1:0}isBlink(){return this.cell.flags&b.BLINK?1:0}isInverse(){return this.cell.flags&b.INVERSE?1:0}isInvisible(){return this.cell.flags&b.INVISIBLE?1:0}isFaint(){return this.cell.flags&b.FAINT?1:0}getHyperlinkId(){return this.cell.hyperlink_id}getCodepoint(){return this.cell.codepoint}isDim(){return(this.cell.flags&b.FAINT)!==0}}const nt={KeyA:h.A,KeyB:h.B,KeyC:h.C,KeyD:h.D,KeyE:h.E,KeyF:h.F,KeyG:h.G,KeyH:h.H,KeyI:h.I,KeyJ:h.J,KeyK:h.K,KeyL:h.L,KeyM:h.M,KeyN:h.N,KeyO:h.O,KeyP:h.P,KeyQ:h.Q,KeyR:h.R,KeyS:h.S,KeyT:h.T,KeyU:h.U,KeyV:h.V,KeyW:h.W,KeyX:h.X,KeyY:h.Y,KeyZ:h.Z,Digit1:h.ONE,Digit2:h.TWO,Digit3:h.THREE,Digit4:h.FOUR,Digit5:h.FIVE,Digit6:h.SIX,Digit7:h.SEVEN,Digit8:h.EIGHT,Digit9:h.NINE,Digit0:h.ZERO,Enter:h.ENTER,Escape:h.ESCAPE,Backspace:h.BACKSPACE,Tab:h.TAB,Space:h.SPACE,Minus:h.MINUS,Equal:h.EQUAL,BracketLeft:h.BRACKET_LEFT,BracketRight:h.BRACKET_RIGHT,Backslash:h.BACKSLASH,Semicolon:h.SEMICOLON,Quote:h.QUOTE,Backquote:h.GRAVE,Comma:h.COMMA,Period:h.PERIOD,Slash:h.SLASH,CapsLock:h.CAPS_LOCK,F1:h.F1,F2:h.F2,F3:h.F3,F4:h.F4,F5:h.F5,F6:h.F6,F7:h.F7,F8:h.F8,F9:h.F9,F10:h.F10,F11:h.F11,F12:h.F12,PrintScreen:h.PRINT_SCREEN,ScrollLock:h.SCROLL_LOCK,Pause:h.PAUSE,Insert:h.INSERT,Home:h.HOME,PageUp:h.PAGE_UP,Delete:h.DELETE,End:h.END,PageDown:h.PAGE_DOWN,ArrowRight:h.RIGHT,ArrowLeft:h.LEFT,ArrowDown:h.DOWN,ArrowUp:h.UP,NumLock:h.NUM_LOCK,NumpadDivide:h.KP_DIVIDE,NumpadMultiply:h.KP_MULTIPLY,NumpadSubtract:h.KP_MINUS,NumpadAdd:h.KP_PLUS,NumpadEnter:h.KP_ENTER,Numpad1:h.KP_1,Numpad2:h.KP_2,Numpad3:h.KP_3,Numpad4:h.KP_4,Numpad5:h.KP_5,Numpad6:h.KP_6,Numpad7:h.KP_7,Numpad8:h.KP_8,Numpad9:h.KP_9,Numpad0:h.KP_0,NumpadDecimal:h.KP_PERIOD,IntlBackslash:h.INTL_BACKSLASH,ContextMenu:h.CONTEXT_MENU,F13:h.F13,F14:h.F14,F15:h.F15,F16:h.F16,F17:h.F17,F18:h.F18,F19:h.F19,F20:h.F20,F21:h.F21,F22:h.F22,F23:h.F23,F24:h.F24};class lt{constructor(t,i,s,r,o,n,l){this.keydownListener=null,this.keypressListener=null,this.pasteListener=null,this.compositionStartListener=null,this.compositionUpdateListener=null,this.compositionEndListener=null,this.isComposing=!1,this.isDisposed=!1,this.encoder=t.createKeyEncoder(),this.container=i,this.onDataCallback=s,this.onBellCallback=r,this.onKeyCallback=o,this.customKeyEventHandler=n,this.getModeCallback=l,this.attach()}setCustomKeyEventHandler(t){this.customKeyEventHandler=t}attach(){typeof this.container.hasAttribute=="function"&&typeof this.container.setAttribute=="function"&&(this.container.hasAttribute("tabindex")||this.container.setAttribute("tabindex","0"),this.container.style&&(this.container.style.outline="none")),this.keydownListener=this.handleKeyDown.bind(this),this.container.addEventListener("keydown",this.keydownListener),this.pasteListener=this.handlePaste.bind(this),this.container.addEventListener("paste",this.pasteListener),this.compositionStartListener=this.handleCompositionStart.bind(this),this.container.addEventListener("compositionstart",this.compositionStartListener),this.compositionUpdateListener=this.handleCompositionUpdate.bind(this),this.container.addEventListener("compositionupdate",this.compositionUpdateListener),this.compositionEndListener=this.handleCompositionEnd.bind(this),this.container.addEventListener("compositionend",this.compositionEndListener)}mapKeyCode(t){return nt[t]??null}extractModifiers(t){let i=k.NONE;return t.shiftKey&&(i|=k.SHIFT),t.ctrlKey&&(i|=k.CTRL),t.altKey&&(i|=k.ALT),t.metaKey&&(i|=k.SUPER),i}isPrintableCharacter(t){return t.ctrlKey&&!t.altKey||t.altKey&&!t.ctrlKey||t.metaKey?!1:t.key.length===1}handleKeyDown(t){if(this.isDisposed||this.isComposing||t.isComposing||t.keyCode===229)return;if(this.onKeyCallback&&this.onKeyCallback({key:t.key,domEvent:t}),this.customKeyEventHandler&&this.customKeyEventHandler(t)){t.preventDefault();return}if((t.ctrlKey||t.metaKey)&&t.code==="KeyV"||t.metaKey&&t.code==="KeyC")return;if(this.isPrintableCharacter(t)){t.preventDefault(),this.onDataCallback(t.key);return}const i=this.mapKeyCode(t.code);if(i===null)return;const s=this.extractModifiers(t);if(s===k.NONE||s===k.SHIFT){let o=null;switch(i){case h.ENTER:o="\r";break;case h.TAB:o=" ";break;case h.BACKSPACE:o="";break;case h.ESCAPE:o="\x1B";break;case h.HOME:o="\x1B[H";break;case h.END:o="\x1B[F";break;case h.INSERT:o="\x1B[2~";break;case h.DELETE:o="\x1B[3~";break;case h.PAGE_UP:o="\x1B[5~";break;case h.PAGE_DOWN:o="\x1B[6~";break;case h.F1:o="\x1BOP";break;case h.F2:o="\x1BOQ";break;case h.F3:o="\x1BOR";break;case h.F4:o="\x1BOS";break;case h.F5:o="\x1B[15~";break;case h.F6:o="\x1B[17~";break;case h.F7:o="\x1B[18~";break;case h.F8:o="\x1B[19~";break;case h.F9:o="\x1B[20~";break;case h.F10:o="\x1B[21~";break;case h.F11:o="\x1B[23~";break;case h.F12:o="\x1B[24~";break}if(o!==null){t.preventDefault(),this.onDataCallback(o);return}}const r=$.PRESS;try{if(this.getModeCallback){const a=this.getModeCallback(1);this.encoder.setOption(Y.CURSOR_KEY_APPLICATION,a)}const o=t.key.length===1&&t.key.charCodeAt(0)<128?t.key.toLowerCase():void 0,n=this.encoder.encode({action:r,key:i,mods:s,utf8:o}),l=new TextDecoder().decode(n);t.preventDefault(),t.stopPropagation(),l.length>0&&this.onDataCallback(l)}catch(o){console.warn("Failed to encode key:",t.code,o)}}handlePaste(t){if(this.isDisposed)return;t.preventDefault(),t.stopPropagation();const i=t.clipboardData;if(!i){console.warn("No clipboard data available");return}const s=i.getData("text/plain");if(!s){console.warn("No text in clipboard");return}this.onDataCallback(s)}handleCompositionStart(t){this.isDisposed||(this.isComposing=!0)}handleCompositionUpdate(t){this.isDisposed}handleCompositionEnd(t){if(this.isDisposed)return;this.isComposing=!1;const i=t.data;if(i&&i.length>0&&this.onDataCallback(i),this.container&&this.container.childNodes)for(let s=this.container.childNodes.length-1;s>=0;s--){const r=this.container.childNodes[s];r.nodeType===3&&this.container.removeChild(r)}}dispose(){this.isDisposed||(this.keydownListener&&(this.container.removeEventListener("keydown",this.keydownListener),this.keydownListener=null),this.keypressListener&&(this.container.removeEventListener("keypress",this.keypressListener),this.keypressListener=null),this.pasteListener&&(this.container.removeEventListener("paste",this.pasteListener),this.pasteListener=null),this.compositionStartListener&&(this.container.removeEventListener("compositionstart",this.compositionStartListener),this.compositionStartListener=null),this.compositionUpdateListener&&(this.container.removeEventListener("compositionupdate",this.compositionUpdateListener),this.compositionUpdateListener=null),this.compositionEndListener&&(this.container.removeEventListener("compositionend",this.compositionEndListener),this.compositionEndListener=null),this.isDisposed=!0)}isActive(){return!this.isDisposed}}class at{constructor(t){this.terminal=t,this.providers=[],this.linkCache=new Map,this.scannedRows=new Set}registerProvider(t){this.providers.push(t),this.invalidateCache()}async getLinkAt(t,i){const s=this.terminal.buffer.active.getLine(i);if(!s||t<0||t>=s.length)return;const r=s.getCell(t);if(!r)return;const o=r.getHyperlinkId();if(o>0){const n=`h${o}`;if(this.linkCache.has(n))return this.linkCache.get(n)}if(this.scannedRows.has(i)||await this.scanRow(i),o>0){const n=`h${o}`,l=this.linkCache.get(n);if(l)return l}for(const n of this.linkCache.values())if(this.isPositionInLink(t,i,n))return n}async scanRow(t){this.scannedRows.add(t);const i=[];for(const s of this.providers){const r=await new Promise(o=>{s.provideLinks(t,o)});r&&i.push(...r)}for(const s of i)this.cacheLink(s)}cacheLink(t){const{start:i}=t.range,s=this.terminal.buffer.active.getLine(i.y);if(s){const l=s.getCell(i.x);if(!l){const{start:c,end:d}=t.range,m=`r${c.y}:${c.x}-${d.x}`;this.linkCache.set(m,t);return}const a=l.getHyperlinkId();if(a>0){this.linkCache.set(`h${a}`,t);return}}const{start:r,end:o}=t.range,n=`r${r.y}:${r.x}-${o.x}`;this.linkCache.set(n,t)}isPositionInLink(t,i,s){const{start:r,end:o}=s.range;return i<r.y||i>o.y?!1:r.y===o.y?t>=r.x&&t<=o.x:i===r.y?t>=r.x:i===o.y?t<=o.x:!0}invalidateCache(){this.linkCache.clear(),this.scannedRows.clear()}invalidateRows(t,i){for(let r=t;r<=i;r++)this.scannedRows.delete(r);const s=[];for(const[r,o]of this.linkCache.entries()){const{start:n,end:l}=o.range;(n.y>=t&&n.y<=i||l.y>=t&&l.y<=i||n.y<t&&l.y>i)&&s.push(r)}for(const r of s)this.linkCache.delete(r)}dispose(){var t;this.linkCache.clear(),this.scannedRows.clear();for(const i of this.providers)(t=i.dispose)==null||t.call(i);this.providers=[]}}class ht{constructor(t){this.terminal=t}provideLinks(t,i){const s=[],r=new Set,o=this.terminal.buffer.active.getLine(t);if(!o){i(void 0);return}for(let n=0;n<o.length;n++){const l=o.getCell(n);if(!l)continue;const a=l.getHyperlinkId();if(a===0||r.has(a))continue;r.add(a);const c=this.findLinkRange(a,t,n);if(!this.terminal.wasmTerm)continue;const d=this.terminal.wasmTerm.getHyperlinkUri(a);d&&s.push({text:d,range:c,activate:m=>{(m.ctrlKey||m.metaKey)&&window.open(d,"_blank","noopener,noreferrer")}})}i(s.length>0?s:void 0)}findLinkRange(t,i,s){const r=this.terminal.buffer.active;let o=i,n=s;for(;n>0;){const d=r.getLine(o);if(!d)break;const m=d.getCell(n-1);if(!m||m.getHyperlinkId()!==t)break;n--}if(n===0&&o>0){let d=o-1;for(;d>=0;){const m=r.getLine(d);if(!m||m.length===0)break;const p=m.getCell(m.length-1);if(!p||p.getHyperlinkId()!==t)break;o=d,n=0;for(let u=m.length-1;u>=0;u--){const f=m.getCell(u);if(!f||f.getHyperlinkId()!==t){n=u+1;break}}if(n===0)d--;else break}}let l=i,a=s;const c=r.getLine(l);if(c){for(;a<c.length-1;){const d=c.getCell(a+1);if(!d||d.getHyperlinkId()!==t)break;a++}if(a===c.length-1){let d=l+1;const m=r.length;for(;d<m;){const p=r.getLine(d);if(!p||p.length===0)break;const u=p.getCell(0);if(!u||u.getHyperlinkId()!==t)break;l=d,a=0;for(let f=0;f<p.length;f++){const _=p.getCell(f);if(!_)break;if(_.getHyperlinkId()!==t){a=f-1;break}a=f}if(a===p.length-1)d++;else break}}}return{start:{x:n,y:o},end:{x:a,y:l}}}dispose(){}}const V=class O{constructor(t){this.terminal=t}provideLinks(t,i){const s=[],r=this.terminal.buffer.active.getLine(t);if(!r){i(void 0);return}const o=this.lineToText(r);O.URL_REGEX.lastIndex=0;let n=O.URL_REGEX.exec(o);for(;n!==null;){let l=n[0];const a=n.index;let c=n.index+l.length-1;const d=l.replace(O.TRAILING_PUNCTUATION,"");d.length<l.length&&(l=d,c=a+l.length-1),l.length>8&&s.push({text:l,range:{start:{x:a,y:t},end:{x:c,y:t}},activate:m=>{(m.ctrlKey||m.metaKey)&&window.open(l,"_blank","noopener,noreferrer")}}),n=O.URL_REGEX.exec(o)}i(s.length>0?s:void 0)}lineToText(t){const i=[];for(let s=0;s<t.length;s++){const r=t.getCell(s);if(!r){i.push(" ");continue}const o=r.getCodepoint();o===0||o<32?i.push(" "):i.push(String.fromCodePoint(o))}return i.join("")}dispose(){}};V.URL_REGEX=/(?:https?:\/\/|mailto:|ftp:\/\/|ssh:\/\/|git:\/\/|tel:|magnet:|gemini:\/\/|gopher:\/\/|news:)[\w\-.~:\/?#@!$&*+,;=%]+/gi;V.TRAILING_PUNCTUATION=/[.,;!?)\]]+$/;let ct=V;const X={foreground:"#d4d4d4",background:"#1e1e1e",cursor:"#ffffff",cursorAccent:"#1e1e1e",selectionBackground:"#d4d4d4",selectionForeground:"#1e1e1e",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#ffffff"};class dt{constructor(t,i={}){this.cursorVisible=!0,this.lastCursorPosition={x:0,y:0},this.lastViewportY=0,this.currentBuffer=null,this.currentSelectionCoords=null,this.hoveredHyperlinkId=0,this.previousHoveredHyperlinkId=0,this.hoveredLinkRange=null,this.previousHoveredLinkRange=null,this.canvas=t;const s=t.getContext("2d",{alpha:!0});if(!s)throw new Error("Failed to get 2D rendering context");this.ctx=s,this.fontSize=i.fontSize??15,this.fontFamily=i.fontFamily??"monospace",this.cursorStyle=i.cursorStyle??"block",this.cursorBlink=i.cursorBlink??!1,this.theme={...X,...i.theme},this.devicePixelRatio=i.devicePixelRatio??window.devicePixelRatio??1,this.palette=[this.theme.black,this.theme.red,this.theme.green,this.theme.yellow,this.theme.blue,this.theme.magenta,this.theme.cyan,this.theme.white,this.theme.brightBlack,this.theme.brightRed,this.theme.brightGreen,this.theme.brightYellow,this.theme.brightBlue,this.theme.brightMagenta,this.theme.brightCyan,this.theme.brightWhite],this.metrics=this.measureFont(),this.cursorBlink&&this.startCursorBlink()}measureFont(){const t=document.createElement("canvas").getContext("2d");t.font=`${this.fontSize}px ${this.fontFamily}`;const i=t.measureText("M"),s=Math.ceil(i.width),r=i.actualBoundingBoxAscent||this.fontSize*.8,o=i.actualBoundingBoxDescent||this.fontSize*.2,n=Math.ceil(r+o)+2,l=Math.ceil(r)+1;return{width:s,height:n,baseline:l}}remeasureFont(){this.metrics=this.measureFont()}rgbToCSS(t,i,s){return`rgb(${t}, ${i}, ${s})`}resize(t,i){const s=t*this.metrics.width,r=i*this.metrics.height;this.canvas.style.width=`${s}px`,this.canvas.style.height=`${r}px`,this.canvas.width=s*this.devicePixelRatio,this.canvas.height=r*this.devicePixelRatio,this.ctx.scale(this.devicePixelRatio,this.devicePixelRatio),this.ctx.textBaseline="alphabetic",this.ctx.textAlign="left",this.ctx.fillStyle=this.theme.background,this.ctx.fillRect(0,0,s,r)}render(t,i=!1,s=0,r,o=1){var n;this.currentBuffer=t;const l=t.getCursor(),a=t.getDimensions(),c=r?r.getScrollbackLength():0;(n=t.needsFullRedraw)!=null&&n.call(t)&&(i=!0),(this.canvas.width!==a.cols*this.metrics.width*this.devicePixelRatio||this.canvas.height!==a.rows*this.metrics.height*this.devicePixelRatio)&&(this.resize(a.cols,a.rows),i=!0),s!==this.lastViewportY&&(i=!0,this.lastViewportY=s);const d=l.x!==this.lastCursorPosition.x||l.y!==this.lastCursorPosition.y;if(d||this.cursorBlink){if(!i&&!t.isRowDirty(l.y)){const g=t.getLine(l.y);g&&this.renderLine(g,l.y,a.cols)}if(d&&this.lastCursorPosition.y!==l.y&&!i&&!t.isRowDirty(this.lastCursorPosition.y)){const g=t.getLine(this.lastCursorPosition.y);g&&this.renderLine(g,this.lastCursorPosition.y,a.cols)}}const m=this.selectionManager&&this.selectionManager.hasSelection(),p=new Set;if(this.currentSelectionCoords=m?this.selectionManager.getSelectionCoords():null,this.currentSelectionCoords){const g=this.currentSelectionCoords;for(let E=g.startRow;E<=g.endRow;E++)p.add(E)}if(this.selectionManager){const g=this.selectionManager.getDirtySelectionRows();if(g.size>0){for(const E of g)p.add(E);this.selectionManager.clearDirtySelectionRows()}}const u=new Set,f=this.hoveredHyperlinkId!==this.previousHoveredHyperlinkId,_=JSON.stringify(this.hoveredLinkRange)!==JSON.stringify(this.previousHoveredLinkRange);if(f){for(let g=0;g<a.rows;g++){let E=null;if(s>0)if(g<s&&r){const y=c-Math.floor(s)+g;E=r.getScrollbackLine(y)}else{const y=g-Math.floor(s);E=t.getLine(y)}else E=t.getLine(g);if(E){for(const y of E)if(y.hyperlink_id===this.hoveredHyperlinkId||y.hyperlink_id===this.previousHoveredHyperlinkId){u.add(g);break}}}this.previousHoveredHyperlinkId=this.hoveredHyperlinkId}if(_){if(this.previousHoveredLinkRange)for(let g=this.previousHoveredLinkRange.startY;g<=this.previousHoveredLinkRange.endY;g++)u.add(g);if(this.hoveredLinkRange)for(let g=this.hoveredLinkRange.startY;g<=this.hoveredLinkRange.endY;g++)u.add(g);this.previousHoveredLinkRange=this.hoveredLinkRange}const v=new Set;for(let g=0;g<a.rows;g++)(s>0||i||t.isRowDirty(g)||p.has(g)||u.has(g))&&(v.add(g),g>0&&v.add(g-1),g<a.rows-1&&v.add(g+1));for(let g=0;g<a.rows;g++){if(!v.has(g))continue;let E=null;if(s>0)if(g<s&&r){const y=c-Math.floor(s)+g;E=r.getScrollbackLine(y)}else{const y=s>0?g-Math.floor(s):g;E=t.getLine(y)}else E=t.getLine(g);E&&this.renderLine(E,g,a.cols)}s===0&&l.visible&&this.cursorVisible&&this.renderCursor(l.x,l.y),r&&o>0&&this.renderScrollbar(s,c,a.rows,o),this.lastCursorPosition={x:l.x,y:l.y},t.clearDirty()}renderLine(t,i,s){const r=i*this.metrics.height;this.ctx.fillStyle=this.theme.background,this.ctx.fillRect(0,r,s*this.metrics.width,this.metrics.height);for(let o=0;o<t.length;o++){const n=t[o];n.width!==0&&this.renderCellBackground(n,o,i)}for(let o=0;o<t.length;o++){const n=t[o];n.width!==0&&this.renderCellText(n,o,i)}}renderCellBackground(t,i,s){const r=i*this.metrics.width,o=s*this.metrics.height,n=this.metrics.width*t.width;if(this.isInSelection(i,s)){this.ctx.fillStyle=this.theme.selectionBackground,this.ctx.fillRect(r,o,n,this.metrics.height);return}let l=t.bg_r,a=t.bg_g,c=t.bg_b;t.flags&b.INVERSE&&(l=t.fg_r,a=t.fg_g,c=t.fg_b),l===0&&a===0&&c===0||(this.ctx.fillStyle=this.rgbToCSS(l,a,c),this.ctx.fillRect(r,o,n,this.metrics.height))}renderCellText(t,i,s){var r;const o=i*this.metrics.width,n=s*this.metrics.height,l=this.metrics.width*t.width;if(t.flags&b.INVISIBLE)return;const a=this.isInSelection(i,s);let c="";if(t.flags&b.ITALIC&&(c+="italic "),t.flags&b.BOLD&&(c+="bold "),this.ctx.font=`${c}${this.fontSize}px ${this.fontFamily}`,a)this.ctx.fillStyle=this.theme.selectionForeground;else{let u=t.fg_r,f=t.fg_g,_=t.fg_b;t.flags&b.INVERSE&&(u=t.bg_r,f=t.bg_g,_=t.bg_b),this.ctx.fillStyle=this.rgbToCSS(u,f,_)}t.flags&b.FAINT&&(this.ctx.globalAlpha=.5);const d=o,m=n+this.metrics.baseline;let p;if(t.grapheme_len>0&&(r=this.currentBuffer)!=null&&r.getGraphemeString?p=this.currentBuffer.getGraphemeString(s,i):p=String.fromCodePoint(t.codepoint||32),this.ctx.fillText(p,d,m),t.flags&b.FAINT&&(this.ctx.globalAlpha=1),t.flags&b.UNDERLINE){const u=n+this.metrics.baseline+2;this.ctx.strokeStyle=this.ctx.fillStyle,this.ctx.lineWidth=1,this.ctx.beginPath(),this.ctx.moveTo(o,u),this.ctx.lineTo(o+l,u),this.ctx.stroke()}if(t.flags&b.STRIKETHROUGH){const u=n+this.metrics.height/2;this.ctx.strokeStyle=this.ctx.fillStyle,this.ctx.lineWidth=1,this.ctx.beginPath(),this.ctx.moveTo(o,u),this.ctx.lineTo(o+l,u),this.ctx.stroke()}if(t.hyperlink_id>0&&t.hyperlink_id===this.hoveredHyperlinkId){const u=n+this.metrics.baseline+2;this.ctx.strokeStyle="#4A90E2",this.ctx.lineWidth=1,this.ctx.beginPath(),this.ctx.moveTo(o,u),this.ctx.lineTo(o+l,u),this.ctx.stroke()}if(this.hoveredLinkRange){const u=this.hoveredLinkRange;if(s===u.startY&&i>=u.startX&&(s<u.endY||i<=u.endX)||s>u.startY&&s<u.endY||s===u.endY&&i<=u.endX&&(s>u.startY||i>=u.startX)){const f=n+this.metrics.baseline+2;this.ctx.strokeStyle="#4A90E2",this.ctx.lineWidth=1,this.ctx.beginPath(),this.ctx.moveTo(o,f),this.ctx.lineTo(o+l,f),this.ctx.stroke()}}}renderCursor(t,i){const s=t*this.metrics.width,r=i*this.metrics.height;switch(this.ctx.fillStyle=this.theme.cursor,this.cursorStyle){case"block":this.ctx.fillRect(s,r,this.metrics.width,this.metrics.height);break;case"underline":const o=Math.max(2,Math.floor(this.metrics.height*.15));this.ctx.fillRect(s,r+this.metrics.height-o,this.metrics.width,o);break;case"bar":const n=Math.max(2,Math.floor(this.metrics.width*.15));this.ctx.fillRect(s,r,n,this.metrics.height);break}}startCursorBlink(){this.cursorBlinkInterval=window.setInterval(()=>{this.cursorVisible=!this.cursorVisible},530)}stopCursorBlink(){this.cursorBlinkInterval!==void 0&&(clearInterval(this.cursorBlinkInterval),this.cursorBlinkInterval=void 0),this.cursorVisible=!0}setTheme(t){this.theme={...X,...t},this.palette=[this.theme.black,this.theme.red,this.theme.green,this.theme.yellow,this.theme.blue,this.theme.magenta,this.theme.cyan,this.theme.white,this.theme.brightBlack,this.theme.brightRed,this.theme.brightGreen,this.theme.brightYellow,this.theme.brightBlue,this.theme.brightMagenta,this.theme.brightCyan,this.theme.brightWhite]}setFontSize(t){this.fontSize=t,this.metrics=this.measureFont()}setFontFamily(t){this.fontFamily=t,this.metrics=this.measureFont()}setCursorStyle(t){this.cursorStyle=t}setCursorBlink(t){t&&!this.cursorBlink?(this.cursorBlink=!0,this.startCursorBlink()):!t&&this.cursorBlink&&(this.cursorBlink=!1,this.stopCursorBlink())}renderScrollbar(t,i,s,r=1){const o=this.ctx,n=this.canvas.height/this.devicePixelRatio,l=this.canvas.width/this.devicePixelRatio,a=8,c=l-a-4,d=4,m=n-d*2;if(o.fillStyle=this.theme.background,o.fillRect(c-2,0,a+6,n),r<=0||i===0)return;const p=i+s,u=Math.max(20,s/p*m),f=t/i,_=d+(m-u)*(1-f);o.fillStyle=`rgba(128, 128, 128, ${.1*r})`,o.fillRect(c,d,a,m);const v=t>0?.5:.3;o.fillStyle=`rgba(128, 128, 128, ${v*r})`,o.fillRect(c,_,a,u)}getMetrics(){return{...this.metrics}}getCanvas(){return this.canvas}setSelectionManager(t){this.selectionManager=t}isInSelection(t,i){const s=this.currentSelectionCoords;if(!s)return!1;const{startCol:r,startRow:o,endCol:n,endRow:l}=s;return o===l?i===o&&t>=r&&t<=n:i===o?t>=r:i===l?t<=n:i>o&&i<l}setHoveredHyperlinkId(t){this.hoveredHyperlinkId=t}setHoveredLinkRange(t){this.hoveredLinkRange=t}get charWidth(){return this.metrics.width}get charHeight(){return this.metrics.height}clear(){this.ctx.fillStyle=this.theme.background,this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)}dispose(){this.stopCursorBlink()}}const H=class A{constructor(t,i,s,r){this.selectionStart=null,this.selectionEnd=null,this.isSelecting=!1,this.mouseDownTarget=null,this.dirtySelectionRows=new Set,this.selectionChangedEmitter=new L,this.boundMouseUpHandler=null,this.boundContextMenuHandler=null,this.boundClickHandler=null,this.boundDocumentMouseMoveHandler=null,this.autoScrollInterval=null,this.autoScrollDirection=0,this.terminal=t,this.renderer=i,this.wasmTerm=s,this.textarea=r,this.attachEventListeners()}getViewportY(){const t=typeof this.terminal.getViewportY=="function"?this.terminal.getViewportY():this.terminal.viewportY||0;return Math.max(0,Math.floor(t))}viewportRowToAbsolute(t){const i=this.wasmTerm.getScrollbackLength(),s=this.getViewportY();return i+t-s}absoluteRowToViewport(t){const i=this.wasmTerm.getScrollbackLength(),s=this.getViewportY();return t-i+s}getSelection(){if(!this.selectionStart||!this.selectionEnd)return"";let{col:t,absoluteRow:i}=this.selectionStart,{col:s,absoluteRow:r}=this.selectionEnd;(i>r||i===r&&t>s)&&([t,s]=[s,t],[i,r]=[r,i]);const o=this.wasmTerm.getScrollbackLength();let n="";for(let l=i;l<=r;l++){let a=null;if(l<o)a=this.wasmTerm.getScrollbackLine(l);else{const u=l-o;a=this.wasmTerm.getLine(u)}if(!a)continue;let c=-1;const d=l===i?t:0,m=l===r?s:a.length-1;let p="";for(let u=d;u<=m;u++){const f=a[u];if(f&&f.codepoint!==0){let _;if(f.grapheme_len>0)if(l<o)_=this.wasmTerm.getScrollbackGraphemeString(l,u);else{const v=l-o;_=this.wasmTerm.getGraphemeString(v,u)}else _=String.fromCodePoint(f.codepoint);p+=_,_.trim()&&(c=p.length)}else p+=" "}c>=0?p=p.substring(0,c):p="",n+=p,l<r&&(n+=`
1
+ import{c as q,_ as Z,r as T,j as w}from"./index-DJLpIsPI.js";import{t as J,X as W,v as Q}from"./App-TtlYNy7O.js";const tt=[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]],et=q("eraser",tt);var Y=(e=>(e[e.CURSOR_KEY_APPLICATION=0]="CURSOR_KEY_APPLICATION",e[e.KEYPAD_KEY_APPLICATION=1]="KEYPAD_KEY_APPLICATION",e[e.IGNORE_KEYPAD_WITH_NUMLOCK=2]="IGNORE_KEYPAD_WITH_NUMLOCK",e[e.ALT_ESC_PREFIX=3]="ALT_ESC_PREFIX",e[e.MODIFY_OTHER_KEYS_STATE_2=4]="MODIFY_OTHER_KEYS_STATE_2",e[e.KITTY_KEYBOARD_FLAGS=5]="KITTY_KEYBOARD_FLAGS",e))(Y||{}),$=(e=>(e[e.RELEASE=0]="RELEASE",e[e.PRESS=1]="PRESS",e[e.REPEAT=2]="REPEAT",e))($||{}),h=(e=>(e[e.UNIDENTIFIED=0]="UNIDENTIFIED",e[e.GRAVE=1]="GRAVE",e[e.BACKSLASH=2]="BACKSLASH",e[e.BRACKET_LEFT=3]="BRACKET_LEFT",e[e.BRACKET_RIGHT=4]="BRACKET_RIGHT",e[e.COMMA=5]="COMMA",e[e.ZERO=6]="ZERO",e[e.ONE=7]="ONE",e[e.TWO=8]="TWO",e[e.THREE=9]="THREE",e[e.FOUR=10]="FOUR",e[e.FIVE=11]="FIVE",e[e.SIX=12]="SIX",e[e.SEVEN=13]="SEVEN",e[e.EIGHT=14]="EIGHT",e[e.NINE=15]="NINE",e[e.EQUAL=16]="EQUAL",e[e.INTL_BACKSLASH=17]="INTL_BACKSLASH",e[e.INTL_RO=18]="INTL_RO",e[e.INTL_YEN=19]="INTL_YEN",e[e.A=20]="A",e[e.B=21]="B",e[e.C=22]="C",e[e.D=23]="D",e[e.E=24]="E",e[e.F=25]="F",e[e.G=26]="G",e[e.H=27]="H",e[e.I=28]="I",e[e.J=29]="J",e[e.K=30]="K",e[e.L=31]="L",e[e.M=32]="M",e[e.N=33]="N",e[e.O=34]="O",e[e.P=35]="P",e[e.Q=36]="Q",e[e.R=37]="R",e[e.S=38]="S",e[e.T=39]="T",e[e.U=40]="U",e[e.V=41]="V",e[e.W=42]="W",e[e.X=43]="X",e[e.Y=44]="Y",e[e.Z=45]="Z",e[e.MINUS=46]="MINUS",e[e.PERIOD=47]="PERIOD",e[e.QUOTE=48]="QUOTE",e[e.SEMICOLON=49]="SEMICOLON",e[e.SLASH=50]="SLASH",e[e.ALT_LEFT=51]="ALT_LEFT",e[e.ALT_RIGHT=52]="ALT_RIGHT",e[e.BACKSPACE=53]="BACKSPACE",e[e.CAPS_LOCK=54]="CAPS_LOCK",e[e.CONTEXT_MENU=55]="CONTEXT_MENU",e[e.CONTROL_LEFT=56]="CONTROL_LEFT",e[e.CONTROL_RIGHT=57]="CONTROL_RIGHT",e[e.ENTER=58]="ENTER",e[e.META_LEFT=59]="META_LEFT",e[e.META_RIGHT=60]="META_RIGHT",e[e.SHIFT_LEFT=61]="SHIFT_LEFT",e[e.SHIFT_RIGHT=62]="SHIFT_RIGHT",e[e.SPACE=63]="SPACE",e[e.TAB=64]="TAB",e[e.CONVERT=65]="CONVERT",e[e.KANA_MODE=66]="KANA_MODE",e[e.NON_CONVERT=67]="NON_CONVERT",e[e.DELETE=68]="DELETE",e[e.END=69]="END",e[e.HELP=70]="HELP",e[e.HOME=71]="HOME",e[e.INSERT=72]="INSERT",e[e.PAGE_DOWN=73]="PAGE_DOWN",e[e.PAGE_UP=74]="PAGE_UP",e[e.DOWN=75]="DOWN",e[e.LEFT=76]="LEFT",e[e.RIGHT=77]="RIGHT",e[e.UP=78]="UP",e[e.NUM_LOCK=79]="NUM_LOCK",e[e.KP_0=80]="KP_0",e[e.KP_1=81]="KP_1",e[e.KP_2=82]="KP_2",e[e.KP_3=83]="KP_3",e[e.KP_4=84]="KP_4",e[e.KP_5=85]="KP_5",e[e.KP_6=86]="KP_6",e[e.KP_7=87]="KP_7",e[e.KP_8=88]="KP_8",e[e.KP_9=89]="KP_9",e[e.KP_PLUS=90]="KP_PLUS",e[e.KP_BACKSPACE=91]="KP_BACKSPACE",e[e.KP_CLEAR=92]="KP_CLEAR",e[e.KP_CLEAR_ENTRY=93]="KP_CLEAR_ENTRY",e[e.KP_COMMA=94]="KP_COMMA",e[e.KP_PERIOD=95]="KP_PERIOD",e[e.KP_DIVIDE=96]="KP_DIVIDE",e[e.KP_ENTER=97]="KP_ENTER",e[e.KP_EQUAL=98]="KP_EQUAL",e[e.KP_MEMORY_ADD=99]="KP_MEMORY_ADD",e[e.KP_MEMORY_CLEAR=100]="KP_MEMORY_CLEAR",e[e.KP_MEMORY_RECALL=101]="KP_MEMORY_RECALL",e[e.KP_MEMORY_STORE=102]="KP_MEMORY_STORE",e[e.KP_MEMORY_SUBTRACT=103]="KP_MEMORY_SUBTRACT",e[e.KP_MULTIPLY=104]="KP_MULTIPLY",e[e.KP_PAREN_LEFT=105]="KP_PAREN_LEFT",e[e.KP_PAREN_RIGHT=106]="KP_PAREN_RIGHT",e[e.KP_MINUS=107]="KP_MINUS",e[e.KP_SEPARATOR=108]="KP_SEPARATOR",e[e.NUMPAD_UP=109]="NUMPAD_UP",e[e.NUMPAD_DOWN=110]="NUMPAD_DOWN",e[e.NUMPAD_RIGHT=111]="NUMPAD_RIGHT",e[e.NUMPAD_LEFT=112]="NUMPAD_LEFT",e[e.NUMPAD_BEGIN=113]="NUMPAD_BEGIN",e[e.NUMPAD_HOME=114]="NUMPAD_HOME",e[e.NUMPAD_END=115]="NUMPAD_END",e[e.NUMPAD_INSERT=116]="NUMPAD_INSERT",e[e.NUMPAD_DELETE=117]="NUMPAD_DELETE",e[e.NUMPAD_PAGE_UP=118]="NUMPAD_PAGE_UP",e[e.NUMPAD_PAGE_DOWN=119]="NUMPAD_PAGE_DOWN",e[e.ESCAPE=120]="ESCAPE",e[e.F1=121]="F1",e[e.F2=122]="F2",e[e.F3=123]="F3",e[e.F4=124]="F4",e[e.F5=125]="F5",e[e.F6=126]="F6",e[e.F7=127]="F7",e[e.F8=128]="F8",e[e.F9=129]="F9",e[e.F10=130]="F10",e[e.F11=131]="F11",e[e.F12=132]="F12",e[e.F13=133]="F13",e[e.F14=134]="F14",e[e.F15=135]="F15",e[e.F16=136]="F16",e[e.F17=137]="F17",e[e.F18=138]="F18",e[e.F19=139]="F19",e[e.F20=140]="F20",e[e.F21=141]="F21",e[e.F22=142]="F22",e[e.F23=143]="F23",e[e.F24=144]="F24",e[e.F25=145]="F25",e[e.FN_LOCK=146]="FN_LOCK",e[e.PRINT_SCREEN=147]="PRINT_SCREEN",e[e.SCROLL_LOCK=148]="SCROLL_LOCK",e[e.PAUSE=149]="PAUSE",e[e.BROWSER_BACK=150]="BROWSER_BACK",e[e.BROWSER_FAVORITES=151]="BROWSER_FAVORITES",e[e.BROWSER_FORWARD=152]="BROWSER_FORWARD",e[e.BROWSER_HOME=153]="BROWSER_HOME",e[e.BROWSER_REFRESH=154]="BROWSER_REFRESH",e[e.BROWSER_SEARCH=155]="BROWSER_SEARCH",e[e.BROWSER_STOP=156]="BROWSER_STOP",e[e.EJECT=157]="EJECT",e[e.LAUNCH_APP_1=158]="LAUNCH_APP_1",e[e.LAUNCH_APP_2=159]="LAUNCH_APP_2",e[e.LAUNCH_MAIL=160]="LAUNCH_MAIL",e[e.MEDIA_PLAY_PAUSE=161]="MEDIA_PLAY_PAUSE",e[e.MEDIA_SELECT=162]="MEDIA_SELECT",e[e.MEDIA_STOP=163]="MEDIA_STOP",e[e.MEDIA_TRACK_NEXT=164]="MEDIA_TRACK_NEXT",e[e.MEDIA_TRACK_PREVIOUS=165]="MEDIA_TRACK_PREVIOUS",e[e.POWER=166]="POWER",e[e.SLEEP=167]="SLEEP",e[e.AUDIO_VOLUME_DOWN=168]="AUDIO_VOLUME_DOWN",e[e.AUDIO_VOLUME_MUTE=169]="AUDIO_VOLUME_MUTE",e[e.AUDIO_VOLUME_UP=170]="AUDIO_VOLUME_UP",e[e.WAKE_UP=171]="WAKE_UP",e[e.COPY=172]="COPY",e[e.CUT=173]="CUT",e[e.PASTE=174]="PASTE",e))(h||{}),k=(e=>(e[e.NONE=0]="NONE",e[e.SHIFT=1]="SHIFT",e[e.CTRL=2]="CTRL",e[e.ALT=4]="ALT",e[e.SUPER=8]="SUPER",e[e.CAPSLOCK=16]="CAPSLOCK",e[e.NUMLOCK=32]="NUMLOCK",e))(k||{}),B=(e=>(e[e.NONE=0]="NONE",e[e.PARTIAL=1]="PARTIAL",e[e.FULL=2]="FULL",e))(B||{});const G=80;var b=(e=>(e[e.BOLD=1]="BOLD",e[e.ITALIC=2]="ITALIC",e[e.UNDERLINE=4]="UNDERLINE",e[e.STRIKETHROUGH=8]="STRIKETHROUGH",e[e.INVERSE=16]="INVERSE",e[e.INVISIBLE=32]="INVISIBLE",e[e.BLINK=64]="BLINK",e[e.FAINT=128]="FAINT",e))(b||{});class N{constructor(t){this.exports=t.exports,this.memory=this.exports.memory}createKeyEncoder(){return new st(this.exports)}createTerminal(t=80,i=24,s){return new it(this.exports,this.memory,t,i,s)}static async load(t){if(t)return N.loadFromPath(t);const i=new URL("/web/assets/ghostty-vt-DOMeXDrv.wasm",import.meta.url),s=[];if(i.protocol==="file:"){let o=i.pathname;o.match(/^\/[A-Za-z]:\//)&&(o=o.slice(1)),s.push(o)}s.push(i.href,"./ghostty-vt.wasm","/ghostty-vt.wasm");let r=null;for(const o of s)try{return await N.loadFromPath(o)}catch(n){r=n instanceof Error?n:new Error(String(n))}throw r||new Error("Failed to load Ghostty WASM")}static async loadFromPath(t){let i;if(typeof Bun<"u"&&typeof Bun.file=="function")try{const o=Bun.file(t);await o.exists()&&(i=await o.arrayBuffer())}catch{}if(!i)try{const o=await(await Z(async()=>{const{readFile:n}=await Promise.resolve().then(()=>St);return{readFile:n}},void 0)).readFile(t);i=o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}catch{}if(!i){const o=await fetch(t);if(!o.ok)throw new Error(`Failed to fetch WASM: ${o.status} ${o.statusText}`);if(i=await o.arrayBuffer(),i.byteLength===0)throw new Error(`WASM file is empty (0 bytes). Check path: ${t}`)}if(!i)throw new Error(`Could not load WASM from path: ${t}`);const s=await WebAssembly.compile(i),r=await WebAssembly.instantiate(s,{env:{log:(o,n)=>{const l=new Uint8Array(r.exports.memory.buffer,o,n);console.log("[ghostty-vt]",new TextDecoder().decode(l))}}});return new N(r)}}class st{constructor(t){this.encoder=0,this.exports=t;const i=this.exports.ghostty_wasm_alloc_opaque(),s=this.exports.ghostty_key_encoder_new(0,i);if(s!==0)throw new Error(`Failed to create key encoder: ${s}`);const r=new DataView(this.exports.memory.buffer);this.encoder=r.getUint32(i,!0),this.exports.ghostty_wasm_free_opaque(i)}setOption(t,i){const s=this.exports.ghostty_wasm_alloc_u8();new DataView(this.exports.memory.buffer).setUint8(s,typeof i=="boolean"?i?1:0:i),this.exports.ghostty_key_encoder_setopt(this.encoder,t,s),this.exports.ghostty_wasm_free_u8(s)}setKittyFlags(t){this.setOption(Y.KITTY_KEYBOARD_FLAGS,t)}encode(t){const i=this.exports.ghostty_wasm_alloc_opaque(),s=this.exports.ghostty_key_event_new(0,i);if(s!==0)throw new Error(`Failed to create key event: ${s}`);const r=new DataView(this.exports.memory.buffer),o=r.getUint32(i,!0);if(this.exports.ghostty_wasm_free_opaque(i),this.exports.ghostty_key_event_set_action(o,t.action),this.exports.ghostty_key_event_set_key(o,t.key),this.exports.ghostty_key_event_set_mods(o,t.mods),t.utf8){const p=new TextEncoder().encode(t.utf8),u=this.exports.ghostty_wasm_alloc_u8_array(p.length);new Uint8Array(this.exports.memory.buffer).set(p,u),this.exports.ghostty_key_event_set_utf8(o,u,p.length),this.exports.ghostty_wasm_free_u8_array(u,p.length)}const n=32,l=this.exports.ghostty_wasm_alloc_u8_array(n),a=this.exports.ghostty_wasm_alloc_usize(),c=this.exports.ghostty_key_encoder_encode(this.encoder,o,l,n,a);if(c!==0)throw this.exports.ghostty_wasm_free_u8_array(l,n),this.exports.ghostty_wasm_free_usize(a),this.exports.ghostty_key_event_free(o),new Error(`Failed to encode key: ${c}`);const d=r.getUint32(a,!0),m=new Uint8Array(this.exports.memory.buffer,l,d).slice();return this.exports.ghostty_wasm_free_u8_array(l,n),this.exports.ghostty_wasm_free_usize(a),this.exports.ghostty_key_event_free(o),m}dispose(){this.encoder&&(this.exports.ghostty_key_encoder_free(this.encoder),this.encoder=0)}}const j=class R{constructor(t,i,s=80,r=24,o){var n;if(this.viewportBufferPtr=0,this.viewportBufferSize=0,this.cellPool=[],this.graphemeBuffer=null,this.graphemeBufferPtr=0,this.exports=t,this.memory=i,this._cols=s,this._rows=r,o){const l=this.exports.ghostty_wasm_alloc_u8_array(G);if(l===0)throw new Error("Failed to allocate config (out of memory)");try{const a=new DataView(this.memory.buffer);let c=l;a.setUint32(c,o.scrollbackLimit??1e4,!0),c+=4,a.setUint32(c,o.fgColor??0,!0),c+=4,a.setUint32(c,o.bgColor??0,!0),c+=4,a.setUint32(c,o.cursorColor??0,!0),c+=4;for(let d=0;d<16;d++)a.setUint32(c,((n=o.palette)==null?void 0:n[d])??0,!0),c+=4;this.handle=this.exports.ghostty_terminal_new_with_config(s,r,l)}finally{this.exports.ghostty_wasm_free_u8_array(l,G)}}else this.handle=this.exports.ghostty_terminal_new(s,r);if(!this.handle)throw new Error("Failed to create terminal");this.initCellPool()}get cols(){return this._cols}get rows(){return this._rows}write(t){const i=typeof t=="string"?new TextEncoder().encode(t):t,s=this.exports.ghostty_wasm_alloc_u8_array(i.length);new Uint8Array(this.memory.buffer).set(i,s),this.exports.ghostty_terminal_write(this.handle,s,i.length),this.exports.ghostty_wasm_free_u8_array(s,i.length)}resize(t,i){t===this._cols&&i===this._rows||(this._cols=t,this._rows=i,this.exports.ghostty_terminal_resize(this.handle,t,i),this.invalidateBuffers(),this.initCellPool())}free(){this.viewportBufferPtr&&(this.exports.ghostty_wasm_free_u8_array(this.viewportBufferPtr,this.viewportBufferSize),this.viewportBufferPtr=0),this.exports.ghostty_terminal_free(this.handle)}update(){return this.exports.ghostty_render_state_update(this.handle)}getCursor(){return this.update(),{x:this.exports.ghostty_render_state_get_cursor_x(this.handle),y:this.exports.ghostty_render_state_get_cursor_y(this.handle),viewportX:this.exports.ghostty_render_state_get_cursor_x(this.handle),viewportY:this.exports.ghostty_render_state_get_cursor_y(this.handle),visible:this.exports.ghostty_render_state_get_cursor_visible(this.handle),blinking:!1,style:"block"}}getColors(){const t=this.exports.ghostty_render_state_get_bg_color(this.handle),i=this.exports.ghostty_render_state_get_fg_color(this.handle);return{background:{r:t>>16&255,g:t>>8&255,b:t&255},foreground:{r:i>>16&255,g:i>>8&255,b:i&255},cursor:null}}isRowDirty(t){return this.exports.ghostty_render_state_is_row_dirty(this.handle,t)}markClean(){this.exports.ghostty_render_state_mark_clean(this.handle)}getViewport(){const t=this._cols*this._rows,i=t*R.CELL_SIZE;return(!this.viewportBufferPtr||this.viewportBufferSize<i)&&(this.viewportBufferPtr&&this.exports.ghostty_wasm_free_u8_array(this.viewportBufferPtr,this.viewportBufferSize),this.viewportBufferPtr=this.exports.ghostty_wasm_alloc_u8_array(i),this.viewportBufferSize=i),this.exports.ghostty_render_state_get_viewport(this.handle,this.viewportBufferPtr,t)<0?this.cellPool:(this.parseCellsIntoPool(this.viewportBufferPtr,t),this.cellPool)}getLine(t){if(t<0||t>=this._rows)return null;this.update();const i=this.getViewport(),s=t*this._cols;return i.slice(s,s+this._cols).map(r=>({...r}))}isDirty(){return this.update()!==B.NONE}needsFullRedraw(){return this.update()===B.FULL}clearDirty(){this.markClean()}isAlternateScreen(){return!!this.exports.ghostty_terminal_is_alternate_screen(this.handle)}hasBracketedPaste(){return this.getMode(2004,!1)}hasFocusEvents(){return this.getMode(1004,!1)}hasMouseTracking(){return this.exports.ghostty_terminal_has_mouse_tracking(this.handle)!==0}getDimensions(){return{cols:this._cols,rows:this._rows}}getScrollbackLength(){return this.exports.ghostty_terminal_get_scrollback_length(this.handle)}getScrollbackLine(t){const i=this._cols*R.CELL_SIZE;(!this.viewportBufferPtr||this.viewportBufferSize<i)&&(this.viewportBufferPtr&&this.exports.ghostty_wasm_free_u8_array(this.viewportBufferPtr,this.viewportBufferSize),this.viewportBufferPtr=this.exports.ghostty_wasm_alloc_u8_array(i),this.viewportBufferSize=i),this.update();const s=this.exports.ghostty_terminal_get_scrollback_line(this.handle,t,this.viewportBufferPtr,this._cols);if(s<0)return null;const r=[],o=this.memory.buffer,n=new Uint8Array(o,this.viewportBufferPtr,s*R.CELL_SIZE),l=new DataView(o,this.viewportBufferPtr,s*R.CELL_SIZE);for(let a=0;a<s;a++){const c=a*R.CELL_SIZE;r.push({codepoint:l.getUint32(c,!0),fg_r:n[c+4],fg_g:n[c+5],fg_b:n[c+6],bg_r:n[c+7],bg_g:n[c+8],bg_b:n[c+9],flags:n[c+10],width:n[c+11],hyperlink_id:l.getUint16(c+12,!0),grapheme_len:n[c+14]})}return r}isRowWrapped(t){return this.exports.ghostty_terminal_is_row_wrapped(this.handle,t)!==0}getHyperlinkUri(t){return null}hasResponse(){return this.exports.ghostty_terminal_has_response(this.handle)}readResponse(){if(!this.hasResponse())return null;const t=256,i=this.exports.ghostty_wasm_alloc_u8_array(t);try{const s=this.exports.ghostty_terminal_read_response(this.handle,i,t);if(s<=0)return null;const r=new Uint8Array(this.memory.buffer,i,s);return new TextDecoder().decode(r.slice())}finally{this.exports.ghostty_wasm_free_u8_array(i,t)}}getMode(t,i=!1){return this.exports.ghostty_terminal_get_mode(this.handle,t,i)!==0}initCellPool(){const t=this._cols*this._rows;if(this.cellPool.length<t)for(let i=this.cellPool.length;i<t;i++)this.cellPool.push({codepoint:0,fg_r:204,fg_g:204,fg_b:204,bg_r:0,bg_g:0,bg_b:0,flags:0,width:1,hyperlink_id:0,grapheme_len:0})}parseCellsIntoPool(t,i){const s=this.memory.buffer,r=new Uint8Array(s,t,i*R.CELL_SIZE),o=new DataView(s,t,i*R.CELL_SIZE);for(let n=0;n<i;n++){const l=n*R.CELL_SIZE,a=this.cellPool[n];a.codepoint=o.getUint32(l,!0),a.fg_r=r[l+4],a.fg_g=r[l+5],a.fg_b=r[l+6],a.bg_r=r[l+7],a.bg_g=r[l+8],a.bg_b=r[l+9],a.flags=r[l+10],a.width=r[l+11],a.hyperlink_id=o.getUint16(l+12,!0),a.grapheme_len=r[l+14]}}getGrapheme(t,i){this.graphemeBuffer||(this.graphemeBufferPtr=this.exports.ghostty_wasm_alloc_u8_array(64),this.graphemeBuffer=new Uint32Array(this.memory.buffer,this.graphemeBufferPtr,16));const s=this.exports.ghostty_render_state_get_grapheme(this.handle,t,i,this.graphemeBufferPtr,16);if(s<0)return null;const r=new Uint32Array(this.memory.buffer,this.graphemeBufferPtr,s);return Array.from(r)}getGraphemeString(t,i){const s=this.getGrapheme(t,i);return!s||s.length===0?" ":String.fromCodePoint(...s)}getScrollbackGrapheme(t,i){this.graphemeBuffer||(this.graphemeBufferPtr=this.exports.ghostty_wasm_alloc_u8_array(64),this.graphemeBuffer=new Uint32Array(this.memory.buffer,this.graphemeBufferPtr,16));const s=this.exports.ghostty_terminal_get_scrollback_grapheme(this.handle,t,i,this.graphemeBufferPtr,16);if(s<0)return null;const r=new Uint32Array(this.memory.buffer,this.graphemeBufferPtr,s);return Array.from(r)}getScrollbackGraphemeString(t,i){const s=this.getScrollbackGrapheme(t,i);return!s||s.length===0?" ":String.fromCodePoint(...s)}invalidateBuffers(){this.viewportBufferPtr&&(this.exports.ghostty_wasm_free_u8_array(this.viewportBufferPtr,this.viewportBufferSize),this.viewportBufferPtr=0,this.viewportBufferSize=0)}};j.CELL_SIZE=16;let it=j;class L{constructor(){this.listeners=[],this.event=t=>(this.listeners.push(t),{dispose:()=>{const i=this.listeners.indexOf(t);i>=0&&this.listeners.splice(i,1)}})}fire(t){for(const i of this.listeners)i(t)}dispose(){this.listeners=[]}}class rt{constructor(t){this.bufferChangeEmitter=new L,this.terminal=t}get active(){const t=this.terminal.wasmTerm;return t?t.isAlternateScreen()?this.alternate:this.normal:this.normal}get normal(){return this._normalBuffer||(this._normalBuffer=new z(this.terminal,"normal")),this._normalBuffer}get alternate(){return this._alternateBuffer||(this._alternateBuffer=new z(this.terminal,"alternate")),this._alternateBuffer}get onBufferChange(){return this.bufferChangeEmitter.event}_fireBufferChange(t){this.bufferChangeEmitter.fire(t)}}class z{constructor(t,i){this.terminal=t,this.bufferType=i;const s={codepoint:0,fg_r:204,fg_g:204,fg_b:204,bg_r:0,bg_g:0,bg_b:0,flags:0,width:1,hyperlink_id:0,grapheme_len:0};this.nullCell=new U(s,0)}get type(){return this.bufferType}get cursorX(){const t=this.getWasmTerm();return t?t.getCursor().x:0}get cursorY(){const t=this.getWasmTerm();return t?t.getCursor().y:0}get viewportY(){return 0}get baseY(){return 0}get length(){const t=this.getWasmTerm();return t?this.bufferType==="alternate"?t.rows:t.getScrollbackLength()+t.rows:0}getLine(t){const i=this.getWasmTerm();if(!i||t<0||t>=this.length)return;const s=i.getScrollbackLength();let r,o,n;if(this.bufferType==="normal"&&t<s){const l=t;r=i.getScrollbackLine(l),n=!1}else o=this.bufferType==="normal"?t-s:t,r=i.getLine(o),n=i.isRowWrapped(o);if(r)return new ot(r,n,i.cols)}getNullCell(){return this.nullCell}getWasmTerm(){return this.terminal.wasmTerm}}class ot{constructor(t,i,s){this.cells=t,this._isWrapped=i,this._length=s}get length(){return this._length}get isWrapped(){return this._isWrapped}getCell(t){if(!(t<0||t>=this._length))return t>=this.cells.length?new U({codepoint:0,fg_r:204,fg_g:204,fg_b:204,bg_r:0,bg_g:0,bg_b:0,flags:0,width:1,hyperlink_id:0,grapheme_len:0},t):new U(this.cells[t],t)}translateToString(t=!1,i=0,s=this._length){const r=Math.max(0,Math.min(i,this._length)),o=Math.max(r,Math.min(s,this._length));let n="";for(let l=r;l<o;l++){const a=this.getCell(l);if(a){const c=a.getChars();n+=c}}return t&&(n=n.trimEnd()),n}}class U{constructor(t,i){this.cell=t,this.x=i}getChars(){const t=this.cell.codepoint;return t===0?"":t<0||t>1114111||t>=55296&&t<=57343?"�":String.fromCodePoint(t)}getCode(){return this.cell.codepoint}getWidth(){return this.cell.width}getFgColorMode(){return-1}getBgColorMode(){return-1}getFgColor(){return this.cell.fg_r<<16|this.cell.fg_g<<8|this.cell.fg_b}getBgColor(){return this.cell.bg_r<<16|this.cell.bg_g<<8|this.cell.bg_b}isBold(){return this.cell.flags&b.BOLD?1:0}isItalic(){return this.cell.flags&b.ITALIC?1:0}isUnderline(){return this.cell.flags&b.UNDERLINE?1:0}isStrikethrough(){return this.cell.flags&b.STRIKETHROUGH?1:0}isBlink(){return this.cell.flags&b.BLINK?1:0}isInverse(){return this.cell.flags&b.INVERSE?1:0}isInvisible(){return this.cell.flags&b.INVISIBLE?1:0}isFaint(){return this.cell.flags&b.FAINT?1:0}getHyperlinkId(){return this.cell.hyperlink_id}getCodepoint(){return this.cell.codepoint}isDim(){return(this.cell.flags&b.FAINT)!==0}}const nt={KeyA:h.A,KeyB:h.B,KeyC:h.C,KeyD:h.D,KeyE:h.E,KeyF:h.F,KeyG:h.G,KeyH:h.H,KeyI:h.I,KeyJ:h.J,KeyK:h.K,KeyL:h.L,KeyM:h.M,KeyN:h.N,KeyO:h.O,KeyP:h.P,KeyQ:h.Q,KeyR:h.R,KeyS:h.S,KeyT:h.T,KeyU:h.U,KeyV:h.V,KeyW:h.W,KeyX:h.X,KeyY:h.Y,KeyZ:h.Z,Digit1:h.ONE,Digit2:h.TWO,Digit3:h.THREE,Digit4:h.FOUR,Digit5:h.FIVE,Digit6:h.SIX,Digit7:h.SEVEN,Digit8:h.EIGHT,Digit9:h.NINE,Digit0:h.ZERO,Enter:h.ENTER,Escape:h.ESCAPE,Backspace:h.BACKSPACE,Tab:h.TAB,Space:h.SPACE,Minus:h.MINUS,Equal:h.EQUAL,BracketLeft:h.BRACKET_LEFT,BracketRight:h.BRACKET_RIGHT,Backslash:h.BACKSLASH,Semicolon:h.SEMICOLON,Quote:h.QUOTE,Backquote:h.GRAVE,Comma:h.COMMA,Period:h.PERIOD,Slash:h.SLASH,CapsLock:h.CAPS_LOCK,F1:h.F1,F2:h.F2,F3:h.F3,F4:h.F4,F5:h.F5,F6:h.F6,F7:h.F7,F8:h.F8,F9:h.F9,F10:h.F10,F11:h.F11,F12:h.F12,PrintScreen:h.PRINT_SCREEN,ScrollLock:h.SCROLL_LOCK,Pause:h.PAUSE,Insert:h.INSERT,Home:h.HOME,PageUp:h.PAGE_UP,Delete:h.DELETE,End:h.END,PageDown:h.PAGE_DOWN,ArrowRight:h.RIGHT,ArrowLeft:h.LEFT,ArrowDown:h.DOWN,ArrowUp:h.UP,NumLock:h.NUM_LOCK,NumpadDivide:h.KP_DIVIDE,NumpadMultiply:h.KP_MULTIPLY,NumpadSubtract:h.KP_MINUS,NumpadAdd:h.KP_PLUS,NumpadEnter:h.KP_ENTER,Numpad1:h.KP_1,Numpad2:h.KP_2,Numpad3:h.KP_3,Numpad4:h.KP_4,Numpad5:h.KP_5,Numpad6:h.KP_6,Numpad7:h.KP_7,Numpad8:h.KP_8,Numpad9:h.KP_9,Numpad0:h.KP_0,NumpadDecimal:h.KP_PERIOD,IntlBackslash:h.INTL_BACKSLASH,ContextMenu:h.CONTEXT_MENU,F13:h.F13,F14:h.F14,F15:h.F15,F16:h.F16,F17:h.F17,F18:h.F18,F19:h.F19,F20:h.F20,F21:h.F21,F22:h.F22,F23:h.F23,F24:h.F24};class lt{constructor(t,i,s,r,o,n,l){this.keydownListener=null,this.keypressListener=null,this.pasteListener=null,this.compositionStartListener=null,this.compositionUpdateListener=null,this.compositionEndListener=null,this.isComposing=!1,this.isDisposed=!1,this.encoder=t.createKeyEncoder(),this.container=i,this.onDataCallback=s,this.onBellCallback=r,this.onKeyCallback=o,this.customKeyEventHandler=n,this.getModeCallback=l,this.attach()}setCustomKeyEventHandler(t){this.customKeyEventHandler=t}attach(){typeof this.container.hasAttribute=="function"&&typeof this.container.setAttribute=="function"&&(this.container.hasAttribute("tabindex")||this.container.setAttribute("tabindex","0"),this.container.style&&(this.container.style.outline="none")),this.keydownListener=this.handleKeyDown.bind(this),this.container.addEventListener("keydown",this.keydownListener),this.pasteListener=this.handlePaste.bind(this),this.container.addEventListener("paste",this.pasteListener),this.compositionStartListener=this.handleCompositionStart.bind(this),this.container.addEventListener("compositionstart",this.compositionStartListener),this.compositionUpdateListener=this.handleCompositionUpdate.bind(this),this.container.addEventListener("compositionupdate",this.compositionUpdateListener),this.compositionEndListener=this.handleCompositionEnd.bind(this),this.container.addEventListener("compositionend",this.compositionEndListener)}mapKeyCode(t){return nt[t]??null}extractModifiers(t){let i=k.NONE;return t.shiftKey&&(i|=k.SHIFT),t.ctrlKey&&(i|=k.CTRL),t.altKey&&(i|=k.ALT),t.metaKey&&(i|=k.SUPER),i}isPrintableCharacter(t){return t.ctrlKey&&!t.altKey||t.altKey&&!t.ctrlKey||t.metaKey?!1:t.key.length===1}handleKeyDown(t){if(this.isDisposed||this.isComposing||t.isComposing||t.keyCode===229)return;if(this.onKeyCallback&&this.onKeyCallback({key:t.key,domEvent:t}),this.customKeyEventHandler&&this.customKeyEventHandler(t)){t.preventDefault();return}if((t.ctrlKey||t.metaKey)&&t.code==="KeyV"||t.metaKey&&t.code==="KeyC")return;if(this.isPrintableCharacter(t)){t.preventDefault(),this.onDataCallback(t.key);return}const i=this.mapKeyCode(t.code);if(i===null)return;const s=this.extractModifiers(t);if(s===k.NONE||s===k.SHIFT){let o=null;switch(i){case h.ENTER:o="\r";break;case h.TAB:o=" ";break;case h.BACKSPACE:o="";break;case h.ESCAPE:o="\x1B";break;case h.HOME:o="\x1B[H";break;case h.END:o="\x1B[F";break;case h.INSERT:o="\x1B[2~";break;case h.DELETE:o="\x1B[3~";break;case h.PAGE_UP:o="\x1B[5~";break;case h.PAGE_DOWN:o="\x1B[6~";break;case h.F1:o="\x1BOP";break;case h.F2:o="\x1BOQ";break;case h.F3:o="\x1BOR";break;case h.F4:o="\x1BOS";break;case h.F5:o="\x1B[15~";break;case h.F6:o="\x1B[17~";break;case h.F7:o="\x1B[18~";break;case h.F8:o="\x1B[19~";break;case h.F9:o="\x1B[20~";break;case h.F10:o="\x1B[21~";break;case h.F11:o="\x1B[23~";break;case h.F12:o="\x1B[24~";break}if(o!==null){t.preventDefault(),this.onDataCallback(o);return}}const r=$.PRESS;try{if(this.getModeCallback){const a=this.getModeCallback(1);this.encoder.setOption(Y.CURSOR_KEY_APPLICATION,a)}const o=t.key.length===1&&t.key.charCodeAt(0)<128?t.key.toLowerCase():void 0,n=this.encoder.encode({action:r,key:i,mods:s,utf8:o}),l=new TextDecoder().decode(n);t.preventDefault(),t.stopPropagation(),l.length>0&&this.onDataCallback(l)}catch(o){console.warn("Failed to encode key:",t.code,o)}}handlePaste(t){if(this.isDisposed)return;t.preventDefault(),t.stopPropagation();const i=t.clipboardData;if(!i){console.warn("No clipboard data available");return}const s=i.getData("text/plain");if(!s){console.warn("No text in clipboard");return}this.onDataCallback(s)}handleCompositionStart(t){this.isDisposed||(this.isComposing=!0)}handleCompositionUpdate(t){this.isDisposed}handleCompositionEnd(t){if(this.isDisposed)return;this.isComposing=!1;const i=t.data;if(i&&i.length>0&&this.onDataCallback(i),this.container&&this.container.childNodes)for(let s=this.container.childNodes.length-1;s>=0;s--){const r=this.container.childNodes[s];r.nodeType===3&&this.container.removeChild(r)}}dispose(){this.isDisposed||(this.keydownListener&&(this.container.removeEventListener("keydown",this.keydownListener),this.keydownListener=null),this.keypressListener&&(this.container.removeEventListener("keypress",this.keypressListener),this.keypressListener=null),this.pasteListener&&(this.container.removeEventListener("paste",this.pasteListener),this.pasteListener=null),this.compositionStartListener&&(this.container.removeEventListener("compositionstart",this.compositionStartListener),this.compositionStartListener=null),this.compositionUpdateListener&&(this.container.removeEventListener("compositionupdate",this.compositionUpdateListener),this.compositionUpdateListener=null),this.compositionEndListener&&(this.container.removeEventListener("compositionend",this.compositionEndListener),this.compositionEndListener=null),this.isDisposed=!0)}isActive(){return!this.isDisposed}}class at{constructor(t){this.terminal=t,this.providers=[],this.linkCache=new Map,this.scannedRows=new Set}registerProvider(t){this.providers.push(t),this.invalidateCache()}async getLinkAt(t,i){const s=this.terminal.buffer.active.getLine(i);if(!s||t<0||t>=s.length)return;const r=s.getCell(t);if(!r)return;const o=r.getHyperlinkId();if(o>0){const n=`h${o}`;if(this.linkCache.has(n))return this.linkCache.get(n)}if(this.scannedRows.has(i)||await this.scanRow(i),o>0){const n=`h${o}`,l=this.linkCache.get(n);if(l)return l}for(const n of this.linkCache.values())if(this.isPositionInLink(t,i,n))return n}async scanRow(t){this.scannedRows.add(t);const i=[];for(const s of this.providers){const r=await new Promise(o=>{s.provideLinks(t,o)});r&&i.push(...r)}for(const s of i)this.cacheLink(s)}cacheLink(t){const{start:i}=t.range,s=this.terminal.buffer.active.getLine(i.y);if(s){const l=s.getCell(i.x);if(!l){const{start:c,end:d}=t.range,m=`r${c.y}:${c.x}-${d.x}`;this.linkCache.set(m,t);return}const a=l.getHyperlinkId();if(a>0){this.linkCache.set(`h${a}`,t);return}}const{start:r,end:o}=t.range,n=`r${r.y}:${r.x}-${o.x}`;this.linkCache.set(n,t)}isPositionInLink(t,i,s){const{start:r,end:o}=s.range;return i<r.y||i>o.y?!1:r.y===o.y?t>=r.x&&t<=o.x:i===r.y?t>=r.x:i===o.y?t<=o.x:!0}invalidateCache(){this.linkCache.clear(),this.scannedRows.clear()}invalidateRows(t,i){for(let r=t;r<=i;r++)this.scannedRows.delete(r);const s=[];for(const[r,o]of this.linkCache.entries()){const{start:n,end:l}=o.range;(n.y>=t&&n.y<=i||l.y>=t&&l.y<=i||n.y<t&&l.y>i)&&s.push(r)}for(const r of s)this.linkCache.delete(r)}dispose(){var t;this.linkCache.clear(),this.scannedRows.clear();for(const i of this.providers)(t=i.dispose)==null||t.call(i);this.providers=[]}}class ht{constructor(t){this.terminal=t}provideLinks(t,i){const s=[],r=new Set,o=this.terminal.buffer.active.getLine(t);if(!o){i(void 0);return}for(let n=0;n<o.length;n++){const l=o.getCell(n);if(!l)continue;const a=l.getHyperlinkId();if(a===0||r.has(a))continue;r.add(a);const c=this.findLinkRange(a,t,n);if(!this.terminal.wasmTerm)continue;const d=this.terminal.wasmTerm.getHyperlinkUri(a);d&&s.push({text:d,range:c,activate:m=>{(m.ctrlKey||m.metaKey)&&window.open(d,"_blank","noopener,noreferrer")}})}i(s.length>0?s:void 0)}findLinkRange(t,i,s){const r=this.terminal.buffer.active;let o=i,n=s;for(;n>0;){const d=r.getLine(o);if(!d)break;const m=d.getCell(n-1);if(!m||m.getHyperlinkId()!==t)break;n--}if(n===0&&o>0){let d=o-1;for(;d>=0;){const m=r.getLine(d);if(!m||m.length===0)break;const p=m.getCell(m.length-1);if(!p||p.getHyperlinkId()!==t)break;o=d,n=0;for(let u=m.length-1;u>=0;u--){const f=m.getCell(u);if(!f||f.getHyperlinkId()!==t){n=u+1;break}}if(n===0)d--;else break}}let l=i,a=s;const c=r.getLine(l);if(c){for(;a<c.length-1;){const d=c.getCell(a+1);if(!d||d.getHyperlinkId()!==t)break;a++}if(a===c.length-1){let d=l+1;const m=r.length;for(;d<m;){const p=r.getLine(d);if(!p||p.length===0)break;const u=p.getCell(0);if(!u||u.getHyperlinkId()!==t)break;l=d,a=0;for(let f=0;f<p.length;f++){const _=p.getCell(f);if(!_)break;if(_.getHyperlinkId()!==t){a=f-1;break}a=f}if(a===p.length-1)d++;else break}}}return{start:{x:n,y:o},end:{x:a,y:l}}}dispose(){}}const V=class O{constructor(t){this.terminal=t}provideLinks(t,i){const s=[],r=this.terminal.buffer.active.getLine(t);if(!r){i(void 0);return}const o=this.lineToText(r);O.URL_REGEX.lastIndex=0;let n=O.URL_REGEX.exec(o);for(;n!==null;){let l=n[0];const a=n.index;let c=n.index+l.length-1;const d=l.replace(O.TRAILING_PUNCTUATION,"");d.length<l.length&&(l=d,c=a+l.length-1),l.length>8&&s.push({text:l,range:{start:{x:a,y:t},end:{x:c,y:t}},activate:m=>{(m.ctrlKey||m.metaKey)&&window.open(l,"_blank","noopener,noreferrer")}}),n=O.URL_REGEX.exec(o)}i(s.length>0?s:void 0)}lineToText(t){const i=[];for(let s=0;s<t.length;s++){const r=t.getCell(s);if(!r){i.push(" ");continue}const o=r.getCodepoint();o===0||o<32?i.push(" "):i.push(String.fromCodePoint(o))}return i.join("")}dispose(){}};V.URL_REGEX=/(?:https?:\/\/|mailto:|ftp:\/\/|ssh:\/\/|git:\/\/|tel:|magnet:|gemini:\/\/|gopher:\/\/|news:)[\w\-.~:\/?#@!$&*+,;=%]+/gi;V.TRAILING_PUNCTUATION=/[.,;!?)\]]+$/;let ct=V;const X={foreground:"#d4d4d4",background:"#1e1e1e",cursor:"#ffffff",cursorAccent:"#1e1e1e",selectionBackground:"#d4d4d4",selectionForeground:"#1e1e1e",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#ffffff"};class dt{constructor(t,i={}){this.cursorVisible=!0,this.lastCursorPosition={x:0,y:0},this.lastViewportY=0,this.currentBuffer=null,this.currentSelectionCoords=null,this.hoveredHyperlinkId=0,this.previousHoveredHyperlinkId=0,this.hoveredLinkRange=null,this.previousHoveredLinkRange=null,this.canvas=t;const s=t.getContext("2d",{alpha:!0});if(!s)throw new Error("Failed to get 2D rendering context");this.ctx=s,this.fontSize=i.fontSize??15,this.fontFamily=i.fontFamily??"monospace",this.cursorStyle=i.cursorStyle??"block",this.cursorBlink=i.cursorBlink??!1,this.theme={...X,...i.theme},this.devicePixelRatio=i.devicePixelRatio??window.devicePixelRatio??1,this.palette=[this.theme.black,this.theme.red,this.theme.green,this.theme.yellow,this.theme.blue,this.theme.magenta,this.theme.cyan,this.theme.white,this.theme.brightBlack,this.theme.brightRed,this.theme.brightGreen,this.theme.brightYellow,this.theme.brightBlue,this.theme.brightMagenta,this.theme.brightCyan,this.theme.brightWhite],this.metrics=this.measureFont(),this.cursorBlink&&this.startCursorBlink()}measureFont(){const t=document.createElement("canvas").getContext("2d");t.font=`${this.fontSize}px ${this.fontFamily}`;const i=t.measureText("M"),s=Math.ceil(i.width),r=i.actualBoundingBoxAscent||this.fontSize*.8,o=i.actualBoundingBoxDescent||this.fontSize*.2,n=Math.ceil(r+o)+2,l=Math.ceil(r)+1;return{width:s,height:n,baseline:l}}remeasureFont(){this.metrics=this.measureFont()}rgbToCSS(t,i,s){return`rgb(${t}, ${i}, ${s})`}resize(t,i){const s=t*this.metrics.width,r=i*this.metrics.height;this.canvas.style.width=`${s}px`,this.canvas.style.height=`${r}px`,this.canvas.width=s*this.devicePixelRatio,this.canvas.height=r*this.devicePixelRatio,this.ctx.scale(this.devicePixelRatio,this.devicePixelRatio),this.ctx.textBaseline="alphabetic",this.ctx.textAlign="left",this.ctx.fillStyle=this.theme.background,this.ctx.fillRect(0,0,s,r)}render(t,i=!1,s=0,r,o=1){var n;this.currentBuffer=t;const l=t.getCursor(),a=t.getDimensions(),c=r?r.getScrollbackLength():0;(n=t.needsFullRedraw)!=null&&n.call(t)&&(i=!0),(this.canvas.width!==a.cols*this.metrics.width*this.devicePixelRatio||this.canvas.height!==a.rows*this.metrics.height*this.devicePixelRatio)&&(this.resize(a.cols,a.rows),i=!0),s!==this.lastViewportY&&(i=!0,this.lastViewportY=s);const d=l.x!==this.lastCursorPosition.x||l.y!==this.lastCursorPosition.y;if(d||this.cursorBlink){if(!i&&!t.isRowDirty(l.y)){const g=t.getLine(l.y);g&&this.renderLine(g,l.y,a.cols)}if(d&&this.lastCursorPosition.y!==l.y&&!i&&!t.isRowDirty(this.lastCursorPosition.y)){const g=t.getLine(this.lastCursorPosition.y);g&&this.renderLine(g,this.lastCursorPosition.y,a.cols)}}const m=this.selectionManager&&this.selectionManager.hasSelection(),p=new Set;if(this.currentSelectionCoords=m?this.selectionManager.getSelectionCoords():null,this.currentSelectionCoords){const g=this.currentSelectionCoords;for(let E=g.startRow;E<=g.endRow;E++)p.add(E)}if(this.selectionManager){const g=this.selectionManager.getDirtySelectionRows();if(g.size>0){for(const E of g)p.add(E);this.selectionManager.clearDirtySelectionRows()}}const u=new Set,f=this.hoveredHyperlinkId!==this.previousHoveredHyperlinkId,_=JSON.stringify(this.hoveredLinkRange)!==JSON.stringify(this.previousHoveredLinkRange);if(f){for(let g=0;g<a.rows;g++){let E=null;if(s>0)if(g<s&&r){const y=c-Math.floor(s)+g;E=r.getScrollbackLine(y)}else{const y=g-Math.floor(s);E=t.getLine(y)}else E=t.getLine(g);if(E){for(const y of E)if(y.hyperlink_id===this.hoveredHyperlinkId||y.hyperlink_id===this.previousHoveredHyperlinkId){u.add(g);break}}}this.previousHoveredHyperlinkId=this.hoveredHyperlinkId}if(_){if(this.previousHoveredLinkRange)for(let g=this.previousHoveredLinkRange.startY;g<=this.previousHoveredLinkRange.endY;g++)u.add(g);if(this.hoveredLinkRange)for(let g=this.hoveredLinkRange.startY;g<=this.hoveredLinkRange.endY;g++)u.add(g);this.previousHoveredLinkRange=this.hoveredLinkRange}const v=new Set;for(let g=0;g<a.rows;g++)(s>0||i||t.isRowDirty(g)||p.has(g)||u.has(g))&&(v.add(g),g>0&&v.add(g-1),g<a.rows-1&&v.add(g+1));for(let g=0;g<a.rows;g++){if(!v.has(g))continue;let E=null;if(s>0)if(g<s&&r){const y=c-Math.floor(s)+g;E=r.getScrollbackLine(y)}else{const y=s>0?g-Math.floor(s):g;E=t.getLine(y)}else E=t.getLine(g);E&&this.renderLine(E,g,a.cols)}s===0&&l.visible&&this.cursorVisible&&this.renderCursor(l.x,l.y),r&&o>0&&this.renderScrollbar(s,c,a.rows,o),this.lastCursorPosition={x:l.x,y:l.y},t.clearDirty()}renderLine(t,i,s){const r=i*this.metrics.height;this.ctx.fillStyle=this.theme.background,this.ctx.fillRect(0,r,s*this.metrics.width,this.metrics.height);for(let o=0;o<t.length;o++){const n=t[o];n.width!==0&&this.renderCellBackground(n,o,i)}for(let o=0;o<t.length;o++){const n=t[o];n.width!==0&&this.renderCellText(n,o,i)}}renderCellBackground(t,i,s){const r=i*this.metrics.width,o=s*this.metrics.height,n=this.metrics.width*t.width;if(this.isInSelection(i,s)){this.ctx.fillStyle=this.theme.selectionBackground,this.ctx.fillRect(r,o,n,this.metrics.height);return}let l=t.bg_r,a=t.bg_g,c=t.bg_b;t.flags&b.INVERSE&&(l=t.fg_r,a=t.fg_g,c=t.fg_b),l===0&&a===0&&c===0||(this.ctx.fillStyle=this.rgbToCSS(l,a,c),this.ctx.fillRect(r,o,n,this.metrics.height))}renderCellText(t,i,s){var r;const o=i*this.metrics.width,n=s*this.metrics.height,l=this.metrics.width*t.width;if(t.flags&b.INVISIBLE)return;const a=this.isInSelection(i,s);let c="";if(t.flags&b.ITALIC&&(c+="italic "),t.flags&b.BOLD&&(c+="bold "),this.ctx.font=`${c}${this.fontSize}px ${this.fontFamily}`,a)this.ctx.fillStyle=this.theme.selectionForeground;else{let u=t.fg_r,f=t.fg_g,_=t.fg_b;t.flags&b.INVERSE&&(u=t.bg_r,f=t.bg_g,_=t.bg_b),this.ctx.fillStyle=this.rgbToCSS(u,f,_)}t.flags&b.FAINT&&(this.ctx.globalAlpha=.5);const d=o,m=n+this.metrics.baseline;let p;if(t.grapheme_len>0&&(r=this.currentBuffer)!=null&&r.getGraphemeString?p=this.currentBuffer.getGraphemeString(s,i):p=String.fromCodePoint(t.codepoint||32),this.ctx.fillText(p,d,m),t.flags&b.FAINT&&(this.ctx.globalAlpha=1),t.flags&b.UNDERLINE){const u=n+this.metrics.baseline+2;this.ctx.strokeStyle=this.ctx.fillStyle,this.ctx.lineWidth=1,this.ctx.beginPath(),this.ctx.moveTo(o,u),this.ctx.lineTo(o+l,u),this.ctx.stroke()}if(t.flags&b.STRIKETHROUGH){const u=n+this.metrics.height/2;this.ctx.strokeStyle=this.ctx.fillStyle,this.ctx.lineWidth=1,this.ctx.beginPath(),this.ctx.moveTo(o,u),this.ctx.lineTo(o+l,u),this.ctx.stroke()}if(t.hyperlink_id>0&&t.hyperlink_id===this.hoveredHyperlinkId){const u=n+this.metrics.baseline+2;this.ctx.strokeStyle="#4A90E2",this.ctx.lineWidth=1,this.ctx.beginPath(),this.ctx.moveTo(o,u),this.ctx.lineTo(o+l,u),this.ctx.stroke()}if(this.hoveredLinkRange){const u=this.hoveredLinkRange;if(s===u.startY&&i>=u.startX&&(s<u.endY||i<=u.endX)||s>u.startY&&s<u.endY||s===u.endY&&i<=u.endX&&(s>u.startY||i>=u.startX)){const f=n+this.metrics.baseline+2;this.ctx.strokeStyle="#4A90E2",this.ctx.lineWidth=1,this.ctx.beginPath(),this.ctx.moveTo(o,f),this.ctx.lineTo(o+l,f),this.ctx.stroke()}}}renderCursor(t,i){const s=t*this.metrics.width,r=i*this.metrics.height;switch(this.ctx.fillStyle=this.theme.cursor,this.cursorStyle){case"block":this.ctx.fillRect(s,r,this.metrics.width,this.metrics.height);break;case"underline":const o=Math.max(2,Math.floor(this.metrics.height*.15));this.ctx.fillRect(s,r+this.metrics.height-o,this.metrics.width,o);break;case"bar":const n=Math.max(2,Math.floor(this.metrics.width*.15));this.ctx.fillRect(s,r,n,this.metrics.height);break}}startCursorBlink(){this.cursorBlinkInterval=window.setInterval(()=>{this.cursorVisible=!this.cursorVisible},530)}stopCursorBlink(){this.cursorBlinkInterval!==void 0&&(clearInterval(this.cursorBlinkInterval),this.cursorBlinkInterval=void 0),this.cursorVisible=!0}setTheme(t){this.theme={...X,...t},this.palette=[this.theme.black,this.theme.red,this.theme.green,this.theme.yellow,this.theme.blue,this.theme.magenta,this.theme.cyan,this.theme.white,this.theme.brightBlack,this.theme.brightRed,this.theme.brightGreen,this.theme.brightYellow,this.theme.brightBlue,this.theme.brightMagenta,this.theme.brightCyan,this.theme.brightWhite]}setFontSize(t){this.fontSize=t,this.metrics=this.measureFont()}setFontFamily(t){this.fontFamily=t,this.metrics=this.measureFont()}setCursorStyle(t){this.cursorStyle=t}setCursorBlink(t){t&&!this.cursorBlink?(this.cursorBlink=!0,this.startCursorBlink()):!t&&this.cursorBlink&&(this.cursorBlink=!1,this.stopCursorBlink())}renderScrollbar(t,i,s,r=1){const o=this.ctx,n=this.canvas.height/this.devicePixelRatio,l=this.canvas.width/this.devicePixelRatio,a=8,c=l-a-4,d=4,m=n-d*2;if(o.fillStyle=this.theme.background,o.fillRect(c-2,0,a+6,n),r<=0||i===0)return;const p=i+s,u=Math.max(20,s/p*m),f=t/i,_=d+(m-u)*(1-f);o.fillStyle=`rgba(128, 128, 128, ${.1*r})`,o.fillRect(c,d,a,m);const v=t>0?.5:.3;o.fillStyle=`rgba(128, 128, 128, ${v*r})`,o.fillRect(c,_,a,u)}getMetrics(){return{...this.metrics}}getCanvas(){return this.canvas}setSelectionManager(t){this.selectionManager=t}isInSelection(t,i){const s=this.currentSelectionCoords;if(!s)return!1;const{startCol:r,startRow:o,endCol:n,endRow:l}=s;return o===l?i===o&&t>=r&&t<=n:i===o?t>=r:i===l?t<=n:i>o&&i<l}setHoveredHyperlinkId(t){this.hoveredHyperlinkId=t}setHoveredLinkRange(t){this.hoveredLinkRange=t}get charWidth(){return this.metrics.width}get charHeight(){return this.metrics.height}clear(){this.ctx.fillStyle=this.theme.background,this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)}dispose(){this.stopCursorBlink()}}const H=class A{constructor(t,i,s,r){this.selectionStart=null,this.selectionEnd=null,this.isSelecting=!1,this.mouseDownTarget=null,this.dirtySelectionRows=new Set,this.selectionChangedEmitter=new L,this.boundMouseUpHandler=null,this.boundContextMenuHandler=null,this.boundClickHandler=null,this.boundDocumentMouseMoveHandler=null,this.autoScrollInterval=null,this.autoScrollDirection=0,this.terminal=t,this.renderer=i,this.wasmTerm=s,this.textarea=r,this.attachEventListeners()}getViewportY(){const t=typeof this.terminal.getViewportY=="function"?this.terminal.getViewportY():this.terminal.viewportY||0;return Math.max(0,Math.floor(t))}viewportRowToAbsolute(t){const i=this.wasmTerm.getScrollbackLength(),s=this.getViewportY();return i+t-s}absoluteRowToViewport(t){const i=this.wasmTerm.getScrollbackLength(),s=this.getViewportY();return t-i+s}getSelection(){if(!this.selectionStart||!this.selectionEnd)return"";let{col:t,absoluteRow:i}=this.selectionStart,{col:s,absoluteRow:r}=this.selectionEnd;(i>r||i===r&&t>s)&&([t,s]=[s,t],[i,r]=[r,i]);const o=this.wasmTerm.getScrollbackLength();let n="";for(let l=i;l<=r;l++){let a=null;if(l<o)a=this.wasmTerm.getScrollbackLine(l);else{const u=l-o;a=this.wasmTerm.getLine(u)}if(!a)continue;let c=-1;const d=l===i?t:0,m=l===r?s:a.length-1;let p="";for(let u=d;u<=m;u++){const f=a[u];if(f&&f.codepoint!==0){let _;if(f.grapheme_len>0)if(l<o)_=this.wasmTerm.getScrollbackGraphemeString(l,u);else{const v=l-o;_=this.wasmTerm.getGraphemeString(v,u)}else _=String.fromCodePoint(f.codepoint);p+=_,_.trim()&&(c=p.length)}else p+=" "}c>=0?p=p.substring(0,c):p="",n+=p,l<r&&(n+=`
2
2
  `)}return n}hasSelection(){return!this.selectionStart||!this.selectionEnd?!1:!(this.selectionStart.col===this.selectionEnd.col&&this.selectionStart.absoluteRow===this.selectionEnd.absoluteRow)}clearSelection(){if(!this.hasSelection())return;const t=this.normalizeSelection();if(t)for(let i=t.startRow;i<=t.endRow;i++)this.dirtySelectionRows.add(i);this.selectionStart=null,this.selectionEnd=null,this.isSelecting=!1,this.requestRender()}selectAll(){const t=this.wasmTerm.getDimensions(),i=this.getViewportY();this.selectionStart={col:0,absoluteRow:i},this.selectionEnd={col:t.cols-1,absoluteRow:i+t.rows-1},this.requestRender(),this.selectionChangedEmitter.fire()}select(t,i,s){const r=this.wasmTerm.getDimensions();i=Math.max(0,Math.min(i,r.rows-1)),t=Math.max(0,Math.min(t,r.cols-1));let o=i,n=t+s-1;for(;n>=r.cols;)n-=r.cols,o++;o=Math.min(o,r.rows-1);const l=this.getViewportY();this.selectionStart={col:t,absoluteRow:l+i},this.selectionEnd={col:n,absoluteRow:l+o},this.requestRender(),this.selectionChangedEmitter.fire()}selectLines(t,i){const s=this.wasmTerm.getDimensions();t=Math.max(0,Math.min(t,s.rows-1)),i=Math.max(0,Math.min(i,s.rows-1)),t>i&&([t,i]=[i,t]);const r=this.getViewportY();this.selectionStart={col:0,absoluteRow:r+t},this.selectionEnd={col:s.cols-1,absoluteRow:r+i},this.requestRender(),this.selectionChangedEmitter.fire()}getSelectionPosition(){const t=this.normalizeSelection();if(t)return{start:{x:t.startCol,y:t.startRow},end:{x:t.endCol,y:t.endRow}}}deselect(){this.clearSelection(),this.selectionChangedEmitter.fire()}focus(){const t=this.renderer.getCanvas();t.parentElement&&t.parentElement.focus()}getSelectionCoords(){return this.normalizeSelection()}getDirtySelectionRows(){return this.dirtySelectionRows}clearDirtySelectionRows(){this.dirtySelectionRows.clear()}get onSelectionChange(){return this.selectionChangedEmitter.event}dispose(){this.selectionChangedEmitter.dispose(),this.stopAutoScroll(),this.boundMouseUpHandler&&(document.removeEventListener("mouseup",this.boundMouseUpHandler),this.boundMouseUpHandler=null),this.boundDocumentMouseMoveHandler&&(document.removeEventListener("mousemove",this.boundDocumentMouseMoveHandler),this.boundDocumentMouseMoveHandler=null),this.boundContextMenuHandler&&(this.renderer.getCanvas().removeEventListener("contextmenu",this.boundContextMenuHandler),this.boundContextMenuHandler=null),this.boundClickHandler&&(document.removeEventListener("click",this.boundClickHandler),this.boundClickHandler=null)}attachEventListeners(){const t=this.renderer.getCanvas();t.addEventListener("mousedown",i=>{if(i.button===0){t.parentElement&&t.parentElement.focus();const s=this.pixelToCell(i.offsetX,i.offsetY);this.hasSelection()&&this.clearSelection();const r=this.viewportRowToAbsolute(s.row);this.selectionStart={col:s.col,absoluteRow:r},this.selectionEnd={col:s.col,absoluteRow:r},this.isSelecting=!0}}),t.addEventListener("mousemove",i=>{if(this.isSelecting){this.markCurrentSelectionDirty();const s=this.pixelToCell(i.offsetX,i.offsetY),r=this.viewportRowToAbsolute(s.row);this.selectionEnd={col:s.col,absoluteRow:r},this.requestRender(),this.updateAutoScroll(i.offsetY,t.clientHeight)}}),t.addEventListener("mouseleave",i=>{if(this.isSelecting){const s=t.getBoundingClientRect();i.clientY<s.top?this.startAutoScroll(-1):i.clientY>s.bottom&&this.startAutoScroll(1)}}),t.addEventListener("mouseenter",()=>{this.isSelecting&&this.stopAutoScroll()}),this.boundDocumentMouseMoveHandler=i=>{if(this.isSelecting){const s=t.getBoundingClientRect(),r=Math.max(s.left,Math.min(i.clientX,s.right)),o=Math.max(s.top,Math.min(i.clientY,s.bottom)),n=r-s.left,l=o-s.top;if((i.clientX<s.left||i.clientX>s.right||i.clientY<s.top||i.clientY>s.bottom)&&(i.clientY<s.top?this.startAutoScroll(-1):i.clientY>s.bottom?this.startAutoScroll(1):this.stopAutoScroll(),this.autoScrollDirection===0)){this.markCurrentSelectionDirty();const a=this.pixelToCell(n,l),c=this.viewportRowToAbsolute(a.row);this.selectionEnd={col:a.col,absoluteRow:c},this.requestRender()}}},document.addEventListener("mousemove",this.boundDocumentMouseMoveHandler),document.addEventListener("mousedown",i=>{this.mouseDownTarget=i.target}),this.boundMouseUpHandler=i=>{if(this.isSelecting){this.isSelecting=!1,this.stopAutoScroll();const s=this.getSelection();s&&(this.copyToClipboard(s),this.selectionChangedEmitter.fire())}},document.addEventListener("mouseup",this.boundMouseUpHandler),t.addEventListener("dblclick",i=>{const s=this.pixelToCell(i.offsetX,i.offsetY),r=this.getWordAtCell(s.col,s.row);if(r){const o=this.viewportRowToAbsolute(s.row);this.selectionStart={col:r.startCol,absoluteRow:o},this.selectionEnd={col:r.endCol,absoluteRow:o},this.requestRender();const n=this.getSelection();n&&(this.copyToClipboard(n),this.selectionChangedEmitter.fire())}}),this.boundContextMenuHandler=i=>{if(this.renderer.getCanvas().getBoundingClientRect(),this.textarea.style.position="fixed",this.textarea.style.left=`${i.clientX}px`,this.textarea.style.top=`${i.clientY}px`,this.textarea.style.width="1px",this.textarea.style.height="1px",this.textarea.style.zIndex="1000",this.textarea.style.opacity="0",this.textarea.style.pointerEvents="auto",this.hasSelection()){const s=this.getSelection();this.textarea.value=s,this.textarea.select(),this.textarea.setSelectionRange(0,s.length)}else this.textarea.value="";this.textarea.focus(),setTimeout(()=>{const s=()=>{this.textarea.style.pointerEvents="none",this.textarea.style.zIndex="-10",this.textarea.style.width="0",this.textarea.style.height="0",this.textarea.style.left="0",this.textarea.style.top="0",this.textarea.value="",document.removeEventListener("click",s),document.removeEventListener("contextmenu",s),this.textarea.removeEventListener("blur",s)};document.addEventListener("click",s,{once:!0}),document.addEventListener("contextmenu",s,{once:!0}),this.textarea.addEventListener("blur",s,{once:!0})},10)},t.addEventListener("contextmenu",this.boundContextMenuHandler),this.boundClickHandler=i=>{if(this.isSelecting||this.mouseDownTarget&&t.contains(this.mouseDownTarget))return;const s=i.target;t.contains(s)||this.hasSelection()&&this.clearSelection()},document.addEventListener("click",this.boundClickHandler)}markCurrentSelectionDirty(){const t=this.normalizeSelection();if(t)for(let i=t.startRow;i<=t.endRow;i++)this.dirtySelectionRows.add(i)}updateAutoScroll(t,i){const s=A.AUTO_SCROLL_EDGE_SIZE;t<s?this.startAutoScroll(-1):t>i-s?this.startAutoScroll(1):this.stopAutoScroll()}startAutoScroll(t){this.autoScrollInterval!==null&&this.autoScrollDirection===t||(this.stopAutoScroll(),this.autoScrollDirection=t,this.autoScrollInterval=setInterval(()=>{if(!this.isSelecting){this.stopAutoScroll();return}const i=A.AUTO_SCROLL_SPEED*this.autoScrollDirection;if(this.terminal.scrollLines(i),this.selectionEnd){const s=this.wasmTerm.getDimensions();if(this.autoScrollDirection<0){const r=this.viewportRowToAbsolute(0);r<this.selectionEnd.absoluteRow&&(this.selectionEnd={col:0,absoluteRow:r})}else{const r=this.viewportRowToAbsolute(s.rows-1);r>this.selectionEnd.absoluteRow&&(this.selectionEnd={col:s.cols-1,absoluteRow:r})}}this.requestRender()},A.AUTO_SCROLL_INTERVAL))}stopAutoScroll(){this.autoScrollInterval!==null&&(clearInterval(this.autoScrollInterval),this.autoScrollInterval=null),this.autoScrollDirection=0}pixelToCell(t,i){const s=this.renderer.getMetrics(),r=Math.floor(t/s.width),o=Math.floor(i/s.height);return{col:Math.max(0,Math.min(r,this.terminal.cols-1)),row:Math.max(0,Math.min(o,this.terminal.rows-1))}}normalizeSelection(){if(!this.selectionStart||!this.selectionEnd)return null;let{col:t,absoluteRow:i}=this.selectionStart,{col:s,absoluteRow:r}=this.selectionEnd;(i>r||i===r&&t>s)&&([t,s]=[s,t],[i,r]=[r,i]);let o=this.absoluteRowToViewport(i),n=this.absoluteRowToViewport(r);const l=this.wasmTerm.getDimensions(),a=l.rows-1;return n<0||o>a?null:(o<0&&(o=0,t=0),n>a&&(n=a,s=l.cols-1),{startCol:t,startRow:o,endCol:s,endRow:n})}getWordAtCell(t,i){const s=this.wasmTerm.getLine(i);if(!s)return null;const r=l=>{if(!l||l.codepoint===0)return!1;const a=String.fromCodePoint(l.codepoint);return/[\w-]/.test(a)};if(!r(s[t]))return null;let o=t;for(;o>0&&r(s[o-1]);)o--;let n=t;for(;n<s.length-1&&r(s[n+1]);)n++;return{startCol:o,endCol:n}}async copyToClipboard(t){if(navigator.clipboard&&navigator.clipboard.writeText)try{await navigator.clipboard.writeText(t);return}catch{}const i=document.activeElement;try{const s=this.textarea;s.value=t,s.style.position="fixed",s.style.left="-9999px",s.style.top="0",s.style.width="1px",s.style.height="1px",s.style.opacity="0",s.focus(),s.select(),s.setSelectionRange(0,t.length);const r=document.execCommand("copy");i&&i.focus(),r||console.error("❌ execCommand copy failed")}catch(s){console.error("❌ Fallback copy failed:",s),i&&i.focus()}}requestRender(){}};H.AUTO_SCROLL_EDGE_SIZE=30;H.AUTO_SCROLL_SPEED=3;H.AUTO_SCROLL_INTERVAL=50;let ut=H;class mt{constructor(t={}){this.unicode={get activeVersion(){return"15.1"}},this.dataEmitter=new L,this.resizeEmitter=new L,this.bellEmitter=new L,this.selectionChangeEmitter=new L,this.keyEmitter=new L,this.titleChangeEmitter=new L,this.scrollEmitter=new L,this.renderEmitter=new L,this.cursorMoveEmitter=new L,this.onData=this.dataEmitter.event,this.onResize=this.resizeEmitter.event,this.onBell=this.bellEmitter.event,this.onSelectionChange=this.selectionChangeEmitter.event,this.onKey=this.keyEmitter.event,this.onTitleChange=this.titleChangeEmitter.event,this.onScroll=this.scrollEmitter.event,this.onRender=this.renderEmitter.event,this.onCursorMove=this.cursorMoveEmitter.event,this.isOpen=!1,this.isDisposed=!1,this.addons=[],this.currentTitle="",this.viewportY=0,this.targetViewportY=0,this.lastCursorY=0,this.isDraggingScrollbar=!1,this.scrollbarDragStart=null,this.scrollbarDragStartViewportY=0,this.scrollbarVisible=!1,this.scrollbarOpacity=0,this.SCROLLBAR_HIDE_DELAY_MS=1500,this.SCROLLBAR_FADE_DURATION_MS=200,this.animateScroll=()=>{if(!this.wasmTerm||this.scrollAnimationStartTime===void 0)return;const s=this.options.smoothScrollDuration??100,r=this.targetViewportY-this.viewportY;if(Math.abs(r)<.01){this.viewportY=this.targetViewportY,this.scrollEmitter.fire(Math.floor(this.viewportY)),this.getScrollbackLength()>0&&this.showScrollbar(),this.scrollAnimationFrame=void 0,this.scrollAnimationStartTime=void 0,this.scrollAnimationStartY=void 0;return}const o=1-(1/(s/1e3*60))**2;this.viewportY+=r*o;const n=Math.floor(this.viewportY);this.scrollEmitter.fire(n),this.getScrollbackLength()>0&&this.showScrollbar(),this.scrollAnimationFrame=requestAnimationFrame(this.animateScroll)},this.handleMouseMove=s=>{if(!(!this.canvas||!this.renderer||!this.wasmTerm)){if(this.isDraggingScrollbar){this.processScrollbarDrag(s);return}if(this.linkDetector){if(this.mouseMoveThrottleTimeout){this.pendingMouseMove=s;return}this.processMouseMove(s),this.mouseMoveThrottleTimeout=window.setTimeout(()=>{if(this.mouseMoveThrottleTimeout=void 0,this.pendingMouseMove){const r=this.pendingMouseMove;this.pendingMouseMove=void 0,this.processMouseMove(r)}},16)}}},this.handleMouseLeave=()=>{var s,r;this.renderer&&this.wasmTerm&&((this.renderer.hoveredHyperlinkId||0)>0&&this.renderer.setHoveredHyperlinkId(0),this.renderer.setHoveredLinkRange(null)),this.currentHoveredLink&&((r=(s=this.currentHoveredLink).hover)==null||r.call(s,!1),this.currentHoveredLink=void 0,this.element&&(this.element.style.cursor="text"))},this.handleClick=async s=>{if(!this.canvas||!this.renderer||!this.linkDetector||!this.wasmTerm)return;const r=this.canvas.getBoundingClientRect(),o=Math.floor((s.clientX-r.left)/this.renderer.charWidth),n=Math.floor((s.clientY-r.top)/this.renderer.charHeight),l=this.wasmTerm.getScrollbackLength();let a;const c=this.getViewportY(),d=Math.max(0,Math.floor(c));if(d>0)if(n<d)a=l-d+n;else{const p=n-d;a=l+p}else a=l+n;const m=await this.linkDetector.getLinkAt(o,a);m&&(m.activate(s),(s.ctrlKey||s.metaKey)&&s.preventDefault())},this.handleWheel=s=>{var r,o,n;if(s.preventDefault(),s.stopPropagation(),!(this.customWheelEventHandler&&this.customWheelEventHandler(s)))if(((r=this.wasmTerm)==null?void 0:r.isAlternateScreen())??!1){const l=s.deltaY>0?"down":"up",a=Math.min(Math.abs(Math.round(s.deltaY/33)),5);for(let c=0;c<a;c++)l==="up"?this.dataEmitter.fire("\x1B[A"):this.dataEmitter.fire("\x1B[B")}else{let l;if(s.deltaMode===WheelEvent.DOM_DELTA_PIXEL){const a=((n=(o=this.renderer)==null?void 0:o.getMetrics())==null?void 0:n.height)??20;l=s.deltaY/a}else s.deltaMode===WheelEvent.DOM_DELTA_LINE?l=s.deltaY:s.deltaMode===WheelEvent.DOM_DELTA_PAGE?l=s.deltaY*this.rows:l=s.deltaY/33;if(l!==0){const a=this.viewportY-l;this.smoothScrollTo(a)}}},this.handleMouseDown=s=>{if(!this.canvas||!this.renderer||!this.wasmTerm)return;const r=this.wasmTerm.getScrollbackLength();if(r===0)return;const o=this.canvas.getBoundingClientRect(),n=s.clientX-o.left,l=s.clientY-o.top,a=o.width,c=o.height,d=8,m=a-d-4,p=4;if(n>=m&&n<=m+d){s.preventDefault(),s.stopPropagation(),s.stopImmediatePropagation();const u=c-p*2,f=this.rows,_=r+f,v=Math.max(20,f/_*u),g=this.viewportY/r,E=p+(u-v)*(1-g);if(l>=E&&l<=E+v)this.isDraggingScrollbar=!0,this.scrollbarDragStart=l,this.scrollbarDragStartViewportY=this.viewportY,this.canvas&&(this.canvas.style.userSelect="none",this.canvas.style.webkitUserSelect="none");else{const y=1-(l-p)/u,M=Math.round(y*r);this.scrollToLine(Math.max(0,Math.min(r,M)))}}},this.handleMouseUp=()=>{this.isDraggingScrollbar&&(this.isDraggingScrollbar=!1,this.scrollbarDragStart=null,this.canvas&&(this.canvas.style.userSelect="",this.canvas.style.webkitUserSelect=""),this.scrollbarVisible&&this.getScrollbackLength()>0&&this.showScrollbar())},this.ghostty=t.ghostty??wt();const i={cols:t.cols??80,rows:t.rows??24,cursorBlink:t.cursorBlink??!1,cursorStyle:t.cursorStyle??"block",theme:t.theme??{},scrollback:t.scrollback??1e4,fontSize:t.fontSize??15,fontFamily:t.fontFamily??"monospace",allowTransparency:t.allowTransparency??!1,convertEol:t.convertEol??!1,disableStdin:t.disableStdin??!1,smoothScrollDuration:t.smoothScrollDuration??100};this.options=new Proxy(i,{set:(s,r,o)=>{const n=s[r];return s[r]=o,this.isOpen&&this.handleOptionChange(r,o,n),!0}}),this.cols=this.options.cols,this.rows=this.options.rows,this.buffer=new rt(this)}handleOptionChange(t,i,s){if(i!==s)switch(t){case"disableStdin":break;case"cursorBlink":case"cursorStyle":this.renderer&&(this.renderer.setCursorStyle(this.options.cursorStyle),this.renderer.setCursorBlink(this.options.cursorBlink));break;case"theme":this.renderer&&console.warn("ghostty-web: theme changes after open() are not yet fully supported");break;case"fontSize":this.renderer&&(this.renderer.setFontSize(this.options.fontSize),this.handleFontChange());break;case"fontFamily":this.renderer&&(this.renderer.setFontFamily(this.options.fontFamily),this.handleFontChange());break;case"cols":case"rows":this.resize(this.options.cols,this.options.rows);break}}handleFontChange(){if(!this.renderer||!this.wasmTerm||!this.canvas)return;this.selectionManager&&this.selectionManager.clearSelection(),this.renderer.resize(this.cols,this.rows);const t=this.renderer.getMetrics();this.canvas.width=t.width*this.cols,this.canvas.height=t.height*this.rows,this.canvas.style.width=`${t.width*this.cols}px`,this.canvas.style.height=`${t.height*this.rows}px`,this.renderer.render(this.wasmTerm,!0,this.viewportY,this)}parseColorToHex(t){if(!t)return 0;if(t.startsWith("#")){let s=t.slice(1);s.length===3&&(s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]);const r=Number.parseInt(s,16);return Number.isNaN(r)?0:r}const i=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(i){const s=Number.parseInt(i[1],10),r=Number.parseInt(i[2],10),o=Number.parseInt(i[3],10);return s<<16|r<<8|o}return 0}buildWasmConfig(){const t=this.options.theme,i=this.options.scrollback;if(!t&&i===1e4)return;const s=[this.parseColorToHex(t?.black),this.parseColorToHex(t?.red),this.parseColorToHex(t?.green),this.parseColorToHex(t?.yellow),this.parseColorToHex(t?.blue),this.parseColorToHex(t?.magenta),this.parseColorToHex(t?.cyan),this.parseColorToHex(t?.white),this.parseColorToHex(t?.brightBlack),this.parseColorToHex(t?.brightRed),this.parseColorToHex(t?.brightGreen),this.parseColorToHex(t?.brightYellow),this.parseColorToHex(t?.brightBlue),this.parseColorToHex(t?.brightMagenta),this.parseColorToHex(t?.brightCyan),this.parseColorToHex(t?.brightWhite)];return{scrollbackLimit:i,fgColor:this.parseColorToHex(t?.foreground),bgColor:this.parseColorToHex(t?.background),cursorColor:this.parseColorToHex(t?.cursor),palette:s}}open(t){if(this.isOpen)throw new Error("Terminal is already open");if(this.isDisposed)throw new Error("Terminal has been disposed");this.element=t,this.isOpen=!0;try{t.hasAttribute("tabindex")||t.setAttribute("tabindex","0"),t.setAttribute("contenteditable","true"),t.addEventListener("beforeinput",r=>r.preventDefault()),t.setAttribute("role","textbox"),t.setAttribute("aria-label","Terminal input"),t.setAttribute("aria-multiline","true");const i=this.buildWasmConfig();this.wasmTerm=this.ghostty.createTerminal(this.cols,this.rows,i),this.canvas=document.createElement("canvas"),this.canvas.style.display="block",t.appendChild(this.canvas),this.textarea=document.createElement("textarea"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.setAttribute("tabindex","0"),this.textarea.setAttribute("aria-label","Terminal input"),this.textarea.style.position="absolute",this.textarea.style.left="0",this.textarea.style.top="0",this.textarea.style.width="1px",this.textarea.style.height="1px",this.textarea.style.padding="0",this.textarea.style.border="none",this.textarea.style.margin="0",this.textarea.style.opacity="0",this.textarea.style.clipPath="inset(50%)",this.textarea.style.overflow="hidden",this.textarea.style.whiteSpace="nowrap",this.textarea.style.resize="none",t.appendChild(this.textarea);const s=this.textarea;this.canvas.addEventListener("mousedown",r=>{r.preventDefault(),s.focus()}),this.canvas.addEventListener("touchend",r=>{r.preventDefault(),s.focus()}),this.renderer=new dt(this.canvas,{fontSize:this.options.fontSize,fontFamily:this.options.fontFamily,cursorStyle:this.options.cursorStyle,cursorBlink:this.options.cursorBlink,theme:this.options.theme}),this.renderer.resize(this.cols,this.rows),this.inputHandler=new lt(this.ghostty,t,r=>{this.options.disableStdin||this.dataEmitter.fire(r)},()=>{this.bellEmitter.fire()},r=>{this.keyEmitter.fire(r)},this.customKeyEventHandler,r=>{var o;return((o=this.wasmTerm)==null?void 0:o.getMode(r,!1))??!1}),this.selectionManager=new ut(this,this.renderer,this.wasmTerm,this.textarea),this.renderer.setSelectionManager(this.selectionManager),this.selectionManager.onSelectionChange(()=>{this.selectionChangeEmitter.fire()}),this.textarea.addEventListener("paste",r=>{var o;r.preventDefault(),r.stopPropagation();const n=(o=r.clipboardData)==null?void 0:o.getData("text");n&&this.paste(n)}),this.linkDetector=new at(this),this.linkDetector.registerProvider(new ht(this)),this.linkDetector.registerProvider(new ct(this)),t.addEventListener("mousedown",this.handleMouseDown,{capture:!0}),t.addEventListener("mousemove",this.handleMouseMove),t.addEventListener("mouseleave",this.handleMouseLeave),t.addEventListener("click",this.handleClick),document.addEventListener("mouseup",this.handleMouseUp),t.addEventListener("wheel",this.handleWheel,{passive:!1,capture:!0}),this.renderer.render(this.wasmTerm,!0,this.viewportY,this,this.scrollbarOpacity),this.startRenderLoop(),this.focus()}catch(i){throw this.isOpen=!1,this.cleanupComponents(),new Error(`Failed to open terminal: ${i}`)}}write(t,i){this.assertOpen(),this.options.convertEol&&typeof t=="string"&&(t=t.replace(/\n/g,`\r
3
3
  `)),this.writeInternal(t,i)}writeInternal(t,i){var s;this.wasmTerm.write(t),this.processTerminalResponses(),typeof t=="string"&&t.includes("\x07")?this.bellEmitter.fire():t instanceof Uint8Array&&t.includes(7)&&this.bellEmitter.fire(),(s=this.linkDetector)==null||s.invalidateCache(),this.viewportY!==0&&this.scrollToBottom(),typeof t=="string"&&t.includes("\x1B]")&&this.checkForTitleChange(t),i&&requestAnimationFrame(i)}writeln(t,i){if(typeof t=="string")this.write(t+`\r
4
4
  `,i);else{const s=new Uint8Array(t.length+2);s.set(t),s[t.length]=13,s[t.length+1]=10,this.write(s,i)}}paste(t){this.assertOpen(),!this.options.disableStdin&&(this.wasmTerm.hasBracketedPaste()?this.dataEmitter.fire("\x1B[200~"+t+"\x1B[201~"):this.dataEmitter.fire(t))}input(t,i=!1){this.assertOpen(),!this.options.disableStdin&&(i?this.dataEmitter.fire(t):this.write(t))}resize(t,i){if(this.assertOpen(),t===this.cols&&i===this.rows)return;this.cols=t,this.rows=i,this.wasmTerm.resize(t,i),this.renderer.resize(t,i);const s=this.renderer.getMetrics();this.canvas.width=s.width*t,this.canvas.height=s.height*i,this.canvas.style.width=`${s.width*t}px`,this.canvas.style.height=`${s.height*i}px`,this.resizeEmitter.fire({cols:t,rows:i}),this.renderer.render(this.wasmTerm,!0,this.viewportY,this)}clear(){this.assertOpen(),this.wasmTerm.write("\x1B[2J\x1B[H")}reset(){this.assertOpen(),this.wasmTerm&&this.wasmTerm.free();const t=this.buildWasmConfig();this.wasmTerm=this.ghostty.createTerminal(this.cols,this.rows,t),this.renderer.clear(),this.currentTitle=""}focus(){this.isOpen&&this.element&&(this.element.focus(),setTimeout(()=>{var t;(t=this.element)==null||t.focus()},0))}blur(){this.isOpen&&this.element&&this.element.blur()}loadAddon(t){t.activate(this),this.addons.push(t)}getSelection(){var t;return((t=this.selectionManager)==null?void 0:t.getSelection())||""}hasSelection(){var t;return((t=this.selectionManager)==null?void 0:t.hasSelection())||!1}clearSelection(){var t;(t=this.selectionManager)==null||t.clearSelection()}selectAll(){var t;(t=this.selectionManager)==null||t.selectAll()}select(t,i,s){var r;(r=this.selectionManager)==null||r.select(t,i,s)}selectLines(t,i){var s;(s=this.selectionManager)==null||s.selectLines(t,i)}getViewportY(){return this.viewportY}getSelectionPosition(){var t;return(t=this.selectionManager)==null?void 0:t.getSelectionPosition()}attachCustomKeyEventHandler(t){this.customKeyEventHandler=t,this.inputHandler&&this.inputHandler.setCustomKeyEventHandler(t)}attachCustomWheelEventHandler(t){this.customWheelEventHandler=t}registerLinkProvider(t){if(!this.linkDetector)throw new Error("Terminal must be opened before registering link providers");this.linkDetector.registerProvider(t)}scrollLines(t){if(!this.wasmTerm)throw new Error("Terminal not open");const i=this.getScrollbackLength(),s=Math.max(0,Math.min(i,this.viewportY-t));s!==this.viewportY&&(this.viewportY=s,this.scrollEmitter.fire(this.viewportY),i>0&&this.showScrollbar())}scrollPages(t){this.scrollLines(t*this.rows)}scrollToTop(){const t=this.getScrollbackLength();t>0&&this.viewportY!==t&&(this.viewportY=t,this.scrollEmitter.fire(this.viewportY),this.showScrollbar())}scrollToBottom(){this.viewportY!==0&&(this.viewportY=0,this.scrollEmitter.fire(this.viewportY),this.getScrollbackLength()>0&&this.showScrollbar())}scrollToLine(t){const i=this.getScrollbackLength(),s=Math.max(0,Math.min(i,t));s!==this.viewportY&&(this.viewportY=s,this.scrollEmitter.fire(this.viewportY),i>0&&this.showScrollbar())}smoothScrollTo(t){if(!this.wasmTerm)return;const i=this.getScrollbackLength(),s=Math.max(0,Math.min(i,t));if((this.options.smoothScrollDuration??100)===0){this.viewportY=s,this.targetViewportY=s,this.scrollEmitter.fire(Math.floor(this.viewportY)),i>0&&this.showScrollbar();return}this.targetViewportY=s,!this.scrollAnimationFrame&&(this.scrollAnimationStartTime=Date.now(),this.scrollAnimationStartY=this.viewportY,this.animateScroll())}dispose(){if(!this.isDisposed){this.isDisposed=!0,this.isOpen=!1,this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0),this.scrollAnimationFrame&&(cancelAnimationFrame(this.scrollAnimationFrame),this.scrollAnimationFrame=void 0),this.mouseMoveThrottleTimeout&&(clearTimeout(this.mouseMoveThrottleTimeout),this.mouseMoveThrottleTimeout=void 0),this.pendingMouseMove=void 0;for(const t of this.addons)t.dispose();this.addons=[],this.cleanupComponents(),this.dataEmitter.dispose(),this.resizeEmitter.dispose(),this.bellEmitter.dispose(),this.selectionChangeEmitter.dispose(),this.keyEmitter.dispose(),this.titleChangeEmitter.dispose(),this.scrollEmitter.dispose(),this.renderEmitter.dispose(),this.cursorMoveEmitter.dispose()}}startRenderLoop(){const t=()=>{if(!this.isDisposed&&this.isOpen){this.renderer.render(this.wasmTerm,!1,this.viewportY,this,this.scrollbarOpacity);const i=this.wasmTerm.getCursor();i.y!==this.lastCursorY&&(this.lastCursorY=i.y,this.cursorMoveEmitter.fire()),this.animationFrameId=requestAnimationFrame(t)}};t()}getScrollbackLine(t){return this.wasmTerm?this.wasmTerm.getScrollbackLine(t):null}getScrollbackLength(){return this.wasmTerm?this.wasmTerm.getScrollbackLength():0}cleanupComponents(){this.selectionManager&&(this.selectionManager.dispose(),this.selectionManager=void 0),this.inputHandler&&(this.inputHandler.dispose(),this.inputHandler=void 0),this.renderer&&(this.renderer.dispose(),this.renderer=void 0),this.canvas&&this.canvas.parentNode&&(this.canvas.parentNode.removeChild(this.canvas),this.canvas=void 0),this.textarea&&this.textarea.parentNode&&(this.textarea.parentNode.removeChild(this.textarea),this.textarea=void 0),this.element&&(this.element.removeEventListener("wheel",this.handleWheel),this.element.removeEventListener("mousedown",this.handleMouseDown,{capture:!0}),this.element.removeEventListener("mousemove",this.handleMouseMove),this.element.removeEventListener("mouseleave",this.handleMouseLeave),this.element.removeEventListener("click",this.handleClick),this.element.removeAttribute("contenteditable"),this.element.removeAttribute("role"),this.element.removeAttribute("aria-label"),this.element.removeAttribute("aria-multiline")),this.isOpen&&typeof document<"u"&&document.removeEventListener("mouseup",this.handleMouseUp),this.scrollbarHideTimeout&&(window.clearTimeout(this.scrollbarHideTimeout),this.scrollbarHideTimeout=void 0),this.linkDetector&&(this.linkDetector.dispose(),this.linkDetector=void 0),this.wasmTerm&&(this.wasmTerm.free(),this.wasmTerm=void 0),this.ghostty=void 0,this.element=void 0,this.textarea=void 0}assertOpen(){if(this.isDisposed)throw new Error("Terminal has been disposed");if(!this.isOpen)throw new Error("Terminal must be opened before use. Call terminal.open(parent) first.")}processMouseMove(t){if(!this.canvas||!this.renderer||!this.linkDetector||!this.wasmTerm)return;const i=this.canvas.getBoundingClientRect(),s=Math.floor((t.clientX-i.left)/this.renderer.charWidth),r=Math.floor((t.clientY-i.top)/this.renderer.charHeight);let o=0,n=null;const l=this.getViewportY(),a=Math.max(0,Math.floor(l));if(a>0){const f=this.wasmTerm.getScrollbackLength();if(r<a){const _=f-a+r;n=this.wasmTerm.getScrollbackLine(_)}else{const _=r-a;n=this.wasmTerm.getLine(_)}}else n=this.wasmTerm.getLine(r);n&&s>=0&&s<n.length&&(o=n[s].hyperlink_id);const c=this.renderer.hoveredHyperlinkId||0;o!==c&&this.renderer.setHoveredHyperlinkId(o);const d=this.wasmTerm.getScrollbackLength();let m;const p=this.getViewportY(),u=Math.max(0,Math.floor(p));if(u>0)if(r<u)m=d-u+r;else{const f=r-u;m=d+f}else m=d+r;this.linkDetector.getLinkAt(s,m).then(f=>{var _,v,g,E;if(f!==this.currentHoveredLink&&((v=(_=this.currentHoveredLink)==null?void 0:_.hover)==null||v.call(_,!1),this.currentHoveredLink=f,(g=f?.hover)==null||g.call(f,!0),this.element&&(this.element.style.cursor=f?"pointer":"text"),this.renderer))if(f){const y=((E=this.wasmTerm)==null?void 0:E.getScrollbackLength())||0,M=this.getViewportY(),P=Math.max(0,Math.floor(M)),C=f.range.start.y-y+P,S=f.range.end.y-y+P;C<this.rows&&S>=0?this.renderer.setHoveredLinkRange({startX:f.range.start.x,startY:Math.max(0,C),endX:f.range.end.x,endY:Math.min(this.rows-1,S)}):this.renderer.setHoveredLinkRange(null)}else this.renderer.setHoveredLinkRange(null)}).catch(f=>{console.warn("Link detection error:",f)})}processScrollbarDrag(t){if(!this.canvas||!this.renderer||!this.wasmTerm||this.scrollbarDragStart===null)return;const i=this.wasmTerm.getScrollbackLength();if(i===0)return;const s=this.canvas.getBoundingClientRect(),r=t.clientY-s.top-this.scrollbarDragStart,o=s.height-8,n=this.rows,l=i+n,a=Math.max(20,n/l*o),c=-r/(o-a),d=Math.round(c*i),m=this.scrollbarDragStartViewportY+d;this.scrollToLine(Math.max(0,Math.min(i,m)))}showScrollbar(){this.scrollbarHideTimeout&&(window.clearTimeout(this.scrollbarHideTimeout),this.scrollbarHideTimeout=void 0),this.scrollbarVisible?this.scrollbarOpacity=1:(this.scrollbarVisible=!0,this.scrollbarOpacity=0,this.fadeInScrollbar()),this.isDraggingScrollbar||(this.scrollbarHideTimeout=window.setTimeout(()=>{this.hideScrollbar()},this.SCROLLBAR_HIDE_DELAY_MS))}hideScrollbar(){this.scrollbarHideTimeout&&(window.clearTimeout(this.scrollbarHideTimeout),this.scrollbarHideTimeout=void 0),this.scrollbarVisible&&this.fadeOutScrollbar()}fadeInScrollbar(){const t=Date.now(),i=()=>{const s=Date.now()-t,r=Math.min(s/this.SCROLLBAR_FADE_DURATION_MS,1);this.scrollbarOpacity=r,this.renderer&&this.wasmTerm&&this.renderer.render(this.wasmTerm,!1,this.viewportY,this,this.scrollbarOpacity),r<1&&requestAnimationFrame(i)};i()}fadeOutScrollbar(){const t=Date.now(),i=this.scrollbarOpacity,s=()=>{const r=Date.now()-t,o=Math.min(r/this.SCROLLBAR_FADE_DURATION_MS,1);this.scrollbarOpacity=i*(1-o),this.renderer&&this.wasmTerm&&this.renderer.render(this.wasmTerm,!1,this.viewportY,this,this.scrollbarOpacity),o<1?requestAnimationFrame(s):(this.scrollbarVisible=!1,this.scrollbarOpacity=0,this.renderer&&this.wasmTerm&&this.renderer.render(this.wasmTerm,!1,this.viewportY,this,0))};s()}processTerminalResponses(){if(!this.wasmTerm)return;const t=this.wasmTerm.readResponse();t&&this.dataEmitter.fire(t)}checkForTitleChange(t){const i=/\x1b\]([012]);([^\x07\x1b]*?)(?:\x07|\x1b\\)/g;let s=null;for(;(s=i.exec(t))!==null;){const r=s[1],o=s[2];(r==="0"||r==="2")&&o!==this.currentTitle&&(this.currentTitle=o,this.titleChangeEmitter.fire(o))}}getMode(t,i=!1){return this.assertOpen(),this.wasmTerm.getMode(t,i)}hasBracketedPaste(){return this.assertOpen(),this.wasmTerm.hasBracketedPaste()}hasFocusEvents(){return this.assertOpen(),this.wasmTerm.hasFocusEvents()}hasMouseTracking(){return this.assertOpen(),this.wasmTerm.hasMouseTracking()}}const gt=2,pt=1,ft=15,_t=100;class Et{constructor(){this._isResizing=!1}activate(t){this._terminal=t}dispose(){this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeDebounceTimer&&(clearTimeout(this._resizeDebounceTimer),this._resizeDebounceTimer=void 0),this._lastCols=void 0,this._lastRows=void 0,this._terminal=void 0}fit(){if(this._isResizing)return;const t=this.proposeDimensions();if(!t||!this._terminal)return;const i=this._terminal,s=i.cols,r=i.rows;if(!(t.cols===this._lastCols&&t.rows===this._lastRows||t.cols===s&&t.rows===r)){this._lastCols=t.cols,this._lastRows=t.rows,this._isResizing=!0;try{i.resize&&typeof i.resize=="function"&&i.resize(t.cols,t.rows)}finally{setTimeout(()=>{this._isResizing=!1},50)}}}proposeDimensions(){var t;if(!((t=this._terminal)!=null&&t.element))return;const i=this._terminal.renderer;if(!i||typeof i.getMetrics!="function")return;const s=i.getMetrics();if(!s||s.width===0||s.height===0)return;const r=this._terminal.element;if(typeof r.clientWidth>"u")return;const o=window.getComputedStyle(r),n=Number.parseInt(o.getPropertyValue("padding-top"))||0,l=Number.parseInt(o.getPropertyValue("padding-bottom"))||0,a=Number.parseInt(o.getPropertyValue("padding-left"))||0,c=Number.parseInt(o.getPropertyValue("padding-right"))||0,d=r.clientWidth,m=r.clientHeight;if(d===0||m===0)return;const p=d-a-c-ft,u=m-n-l,f=Math.max(gt,Math.floor(p/s.width)),_=Math.max(pt,Math.floor(u/s.height));return{cols:f,rows:_}}observeResize(){var t;(t=this._terminal)!=null&&t.element&&(this._resizeObserver||(this._resizeObserver=new ResizeObserver(i=>{this._isResizing||!i[0]||(this._resizeDebounceTimer&&clearTimeout(this._resizeDebounceTimer),this._resizeDebounceTimer=setTimeout(()=>{this.fit()},_t))}),this._resizeObserver.observe(this._terminal.element)))}}function wt(){throw new Error(`ghostty-web not initialized. Call init() before creating Terminal instances.
@@ -1 +1 @@
1
- import{r,l as o,j as e,s as b,b as g,d as x,e as j,f as S,W as v,g as y,h as C}from"./index-ConcKf33.js";import{C as m}from"./ChipGroup-ImS6VTKx.js";function E({t:s}){const[t,i]=r.useState(()=>o().composer.sendShortcut);return e.jsxs("section",{className:"control-section compact-section",children:[e.jsx("h2",{children:s.sendShortcut}),e.jsx(m,{ariaLabel:s.sendShortcut,options:[{value:"enter",label:s.sendShortcutEnter},{value:"modEnter",label:s.sendShortcutModEnter}],value:t,onChange:c=>{const l=o();b({...l,composer:{...l.composer,sendShortcut:c}}),i(c),window.dispatchEvent(new Event("vibelet.preferences.changed"))}}),e.jsx("p",{className:"hint",children:t==="enter"?s.sendShortcutEnterDescription:s.sendShortcutModEnterDescription})]})}function W({t:s,theme:t,onThemeChange:i}){const[c,l]=r.useState(g),[h,u]=r.useState(x),d=j(o().language),a=d==="en"?{title:"Visual theme",classic:"Classic",minimal:"Minimal",accent:"Accent color",hint:"Classic uses the original paper tones and lavender accent.",names:["Blue","Cyan","Green","Lime","Yellow","Orange","Pink","Magenta","Purple","Black"]}:d==="zh-TW"?{title:"外觀主題",classic:"經典",minimal:"簡約",accent:"強調色",hint:"經典主題保留紙色背景與固定紫色點綴。",names:["藍色","青色","綠色","青檸綠","黃色","橙色","粉色","洋紅色","紫色","黑色"]}:{title:"外观主题",classic:"经典",minimal:"简约",accent:"强调色",hint:"经典主题保留纸色背景与固定紫色点缀。",names:["蓝色","青色","绿色","青柠绿","黄色","橙色","粉色","洋红色","紫色","黑色"]};return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"control-section compact-section",children:[e.jsx("h2",{children:s.appearance}),e.jsxs("div",{className:"field",children:[e.jsx("span",{children:s.displayTheme}),e.jsx(m,{ariaLabel:s.displayTheme,options:[{value:"system",label:s.systemTheme},{value:"light",label:s.lightTheme},{value:"dark",label:s.darkTheme}],value:t,onChange:i})]}),e.jsxs("div",{className:"field",children:[e.jsx("span",{children:a.title}),e.jsx(m,{ariaLabel:a.title,options:[{value:"minimal",label:a.minimal},{value:"classic",label:a.classic}],value:h,onChange:n=>{S(n),u(n)}})]}),h==="minimal"?e.jsxs("div",{className:"field",children:[e.jsx("span",{children:a.accent}),e.jsx("div",{className:"accent-options",role:"group","aria-label":a.accent,children:v.map((n,p)=>e.jsx("button",{type:"button","data-accent":n,"aria-label":a.names[p],title:a.names[p],"aria-pressed":n===c,onClick:()=>{C(n),l(n)},children:e.jsx("span",{style:{background:y("minimal",document.documentElement.dataset.theme==="dark"?"dark":"light",n).accent}})},n))})]}):e.jsx("p",{className:"muted theme-style-hint",children:a.hint})]}),e.jsx(E,{t:s})]})}export{W as ThemeSettingsPanel};
1
+ import{r,l as o,j as e,s as b,b as g,d as x,e as j,f as S,W as v,g as y,h as C}from"./index-DJLpIsPI.js";import{C as m}from"./ChipGroup-Do4YgaVh.js";function E({t:s}){const[t,i]=r.useState(()=>o().composer.sendShortcut);return e.jsxs("section",{className:"control-section compact-section",children:[e.jsx("h2",{children:s.sendShortcut}),e.jsx(m,{ariaLabel:s.sendShortcut,options:[{value:"enter",label:s.sendShortcutEnter},{value:"modEnter",label:s.sendShortcutModEnter}],value:t,onChange:c=>{const l=o();b({...l,composer:{...l.composer,sendShortcut:c}}),i(c),window.dispatchEvent(new Event("vibelet.preferences.changed"))}}),e.jsx("p",{className:"hint",children:t==="enter"?s.sendShortcutEnterDescription:s.sendShortcutModEnterDescription})]})}function W({t:s,theme:t,onThemeChange:i}){const[c,l]=r.useState(g),[h,u]=r.useState(x),d=j(o().language),a=d==="en"?{title:"Visual theme",classic:"Classic",minimal:"Minimal",accent:"Accent color",hint:"Classic uses the original paper tones and lavender accent.",names:["Blue","Cyan","Green","Lime","Yellow","Orange","Pink","Magenta","Purple","Black"]}:d==="zh-TW"?{title:"外觀主題",classic:"經典",minimal:"簡約",accent:"強調色",hint:"經典主題保留紙色背景與固定紫色點綴。",names:["藍色","青色","綠色","青檸綠","黃色","橙色","粉色","洋紅色","紫色","黑色"]}:{title:"外观主题",classic:"经典",minimal:"简约",accent:"强调色",hint:"经典主题保留纸色背景与固定紫色点缀。",names:["蓝色","青色","绿色","青柠绿","黄色","橙色","粉色","洋红色","紫色","黑色"]};return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"control-section compact-section",children:[e.jsx("h2",{children:s.appearance}),e.jsxs("div",{className:"field",children:[e.jsx("span",{children:s.displayTheme}),e.jsx(m,{ariaLabel:s.displayTheme,options:[{value:"system",label:s.systemTheme},{value:"light",label:s.lightTheme},{value:"dark",label:s.darkTheme}],value:t,onChange:i})]}),e.jsxs("div",{className:"field",children:[e.jsx("span",{children:a.title}),e.jsx(m,{ariaLabel:a.title,options:[{value:"minimal",label:a.minimal},{value:"classic",label:a.classic}],value:h,onChange:n=>{S(n),u(n)}})]}),h==="minimal"?e.jsxs("div",{className:"field",children:[e.jsx("span",{children:a.accent}),e.jsx("div",{className:"accent-options",role:"group","aria-label":a.accent,children:v.map((n,p)=>e.jsx("button",{type:"button","data-accent":n,"aria-label":a.names[p],title:a.names[p],"aria-pressed":n===c,onClick:()=>{C(n),l(n)},children:e.jsx("span",{style:{background:y("minimal",document.documentElement.dataset.theme==="dark"?"dark":"light",n).accent}})},n))})]}):e.jsx("p",{className:"muted theme-style-hint",children:a.hint})]}),e.jsx(E,{t:s})]})}export{W as ThemeSettingsPanel};
@@ -1 +1 @@
1
- import{c as o}from"./index-ConcKf33.js";const t=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],e=o("arrow-left",t);const r=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],c=o("arrow-right",r);export{c as A,e as a};
1
+ import{c as o}from"./index-DJLpIsPI.js";const t=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],e=o("arrow-left",t);const r=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],c=o("arrow-right",r);export{c as A,e as a};