@teammy/server 0.2.21 → 0.2.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +587 -36
- package/dist/web/assets/Assistant-Dks48Y5w.js +1 -0
- package/dist/web/assets/Computers-BtcIsnDD.css +1 -0
- package/dist/web/assets/Computers-CaCzZeCc.js +13 -0
- package/dist/web/assets/{Conversation-C5pZE7z5.js → Conversation-kAMzKADw.js} +1 -1
- package/dist/web/assets/{Dashboard-yaqwUqGh.js → Dashboard-ComNJNOg.js} +1 -1
- package/dist/web/assets/{Dropdown-DXEtBxVr.js → Dropdown-DGFI68Vd.js} +1 -1
- package/dist/web/assets/Files-Blsq_C-B.js +1 -0
- package/dist/web/assets/{Help-6fa7XqA5.js → Help-BM23uS-t.js} +58 -20
- package/dist/web/assets/{Markdown-nuwEQZ64.js → Markdown-CXnZDm5J.js} +4 -4
- package/dist/web/assets/{MessageComposer-0eprbRl2.js → MessageComposer-BoOgfyPA.js} +1 -1
- package/dist/web/assets/ResourceLibrary-C12_47kE.js +6 -0
- package/dist/web/assets/{TerminalPane-B0w1stXs.js → TerminalPane-BTRM-36z.js} +2 -2
- package/dist/web/assets/WorkspaceTree-Co7XG2RG.js +1 -0
- package/dist/web/assets/{file-links-Bo7XBz3i.js → file-links-CoVqmrXg.js} +1 -1
- package/dist/web/assets/index-mhJ33-bH.js +10 -0
- package/dist/web/assets/task-links-BE36-8mc.js +1 -0
- package/dist/web/downloads/teammy-inbox-skill.zip +0 -0
- package/dist/web/downloads/teammy-skill.zip +0 -0
- package/dist/web/index.html +2 -2
- package/dist/web/notification-worker.js +126 -0
- package/package.json +1 -1
- package/dist/web/assets/Assistant-3mdmSDTD.js +0 -1
- package/dist/web/assets/Computers-6l6HpFis.js +0 -13
- package/dist/web/assets/Computers-CBnQX-2p.css +0 -1
- package/dist/web/assets/Files-1vHzvDD3.js +0 -1
- package/dist/web/assets/ResourceLibrary-Cs01blNf.js +0 -6
- package/dist/web/assets/WorkspaceTree-DmSApj8i.js +0 -1
- package/dist/web/assets/index-Rry2cw7w.js +0 -10
- package/dist/web/assets/task-links-BJwIQ3SE.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{At as e,M as t,c as n}from"./Dropdown-DGFI68Vd.js";var r=e(),i=t();function a({value:e,onChange:t,onSubmit:a,onQueue:s,label:c,placeholder:l=`输入消息…`,disabled:u=!1,sendDisabled:d=!1,sendLabel:f=`发送`,actions:p,beforeSend:m,heading:h,inset:g=!1,plain:_=!1,attachments:v,hasAttachments:y=!1,onFiles:b}){let x=o(e),[S,C]=(0,r.useState)(!1),w=(0,r.useRef)(0),T=!u&&!d&&(!!e.trim()||y);return(0,i.jsxs)(`form`,{className:`message-composer${g?` message-composer-inset`:``}${_?` message-composer-plain`:``}${S?` message-composer-dragging`:``}`,onDragEnter:e=>{b&&!u&&e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),w.current++,C(!0))},onDragLeave:()=>{w.current=Math.max(0,w.current-1),w.current||C(!1)},onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=b&&!u?`copy`:`none`)},onDrop:e=>{w.current=0,C(!1),e.dataTransfer.files.length&&(e.preventDefault(),b&&!u&&b(Array.from(e.dataTransfer.files)))},onSubmit:e=>{e.preventDefault(),T&&a(e)},children:[h&&(0,i.jsx)(`div`,{className:`message-composer-heading`,children:h}),v,(0,i.jsx)(`textarea`,{ref:x,value:e,onChange:e=>t(e.target.value),"aria-label":c,placeholder:l,disabled:u,onPaste:n=>{let r=n.clipboardData.files.length?Array.from(n.clipboardData.files):Array.from(n.clipboardData.items).flatMap(e=>{let t=e.kind===`file`?e.getAsFile():null;return t?[t]:[]});if(b&&!u&&r.length){n.preventDefault(),b(r);let i=n.clipboardData.getData(`text/plain`);if(i){let r=n.currentTarget.selectionStart;t(e.slice(0,r)+i+e.slice(n.currentTarget.selectionEnd)),requestAnimationFrame(()=>x.current?.setSelectionRange(r+i.length,r+i.length))}}},rows:1,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),T&&(s&&(e.metaKey||e.ctrlKey)?s():e.currentTarget.form?.requestSubmit()))}}),(0,i.jsxs)(`div`,{className:`message-composer-footer`,children:[p&&(0,i.jsx)(`div`,{className:`message-composer-actions`,children:p}),m,(0,i.jsx)(`button`,{type:`submit`,className:`primary message-send`,"aria-label":f,title:s?`${f}(Ctrl / ⌘ + Enter 排队)`:f,disabled:!T,children:(0,i.jsx)(n,{name:`send`,size:`small`})})]})]})}function o(e,t){let n=(0,r.useRef)(null);return(0,r.useLayoutEffect)(()=>{let e=n.current;if(!e)return;let r=()=>{t?.(e),e.style.height=`0px`,e.style.height=`${e.scrollHeight}px`};r();let i=e.clientWidth,a=new ResizeObserver(()=>{i!==e.clientWidth&&(i=e.clientWidth,r())});return a.observe(e),()=>a.disconnect()},[e,t]),n}export{o as n,a as t};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{A as e,At as t,C as n,Ct as r,D as i,Dt as a,Et as o,H as s,I as c,L as l,M as u,Mt as d,N as f,O as p,Ot as m,S as h,V as g,_,a as v,bt as y,c as b,ct as x,d as S,dt as C,ft as w,ht as T,jt as E,l as D,lt as O,mt as k,o as ee,ot as A,p as j,pt as M,s as N,vt as P,w as F,wt as I,x as L,y as te,yt as R}from"./Dropdown-DGFI68Vd.js";import{F as z,I as B,L as V,U as H,i as ne,z as U}from"./index-mhJ33-bH.js";import{a as W}from"./task-links-BE36-8mc.js";import{n as G,r as K,t as q}from"./Markdown-CXnZDm5J.js";import{t as re}from"./Conversation-kAMzKADw.js";import{c as ie,l as ae,r as J}from"./WorkspaceTree-Co7XG2RG.js";function oe(e){return m(w,e)}var Y=t(),se=r().regex(/^R\d{6,}$/),X=y({name:r().min(1),sha256:x,size:R().int().nonnegative()}),Z=o().refine(e=>/^https?:\/\//i.test(e),`Use an HTTP or HTTPS URL.`);y({operationId:a(),title:r().trim().default(``),text:r().optional(),url:Z.optional(),originals:k(X).default([])}).strict().refine(e=>!!e.text?.trim()||!!e.url||e.originals.length>0,`Provide text, a link or a file.`),y({expectedRevision:O,title:r().trim().min(1).optional(),url:Z.nullable().optional(),content:r().optional(),summary:r().optional(),sourceVersion:r().optional(),contentDate:r().optional(),originals:k(X).optional()}).strict();var ce=y({id:se,projectId:r(),title:r(),submittedBy:r(),createdAt:r(),revision:O,source:y({kind:M([`web`,`chat`,`group`]),url:r().nullable(),groupId:r().optional(),messageId:r().optional(),sourceVersion:r().optional(),contentDate:r().optional()}),originals:k(X),content:r().nullable(),summary:r().nullable(),state:M([`waiting`,`running`,`ready`,`failed`]),error:r().nullable(),url:r()}),le=y({materials:k(ce),nextCursor:R().nullable()});y({query:r().trim().min(1),scope:M([`all`,`workspace`,`materials`]).default(`all`),materialId:se.optional(),originalHash:x.optional(),after:r().default(``),limit:oe().int().min(1).max(200).default(30)}).strict();var ue=y({items:k(y({key:r(),kind:M([`workspace`,`materials`]),title:r(),snippet:r(),url:r(),path:r()})),nextCursor:r().nullable()}),Q=u();function de(e){let t=(e.content??``).trimStart().split(`
|
|
2
|
+
`);return t[0]?.replace(/^#\s+/,``).trim()===e.title.trim()&&t[0].startsWith(`# `)&&t.shift(),t.join(`
|
|
3
|
+
`).trimStart()}function fe(){let e=new URLSearchParams(location.search),t=e.get(`id`);return t?{id:t,...e.get(`original`)?{original:e.get(`original`)}:{},...e.get(`revision`)?{revision:e.get(`revision`)}:{}}:void 0}function pe({active:t,onActivate:n,children:r}){let{request:i,projectId:a}=H(),[o,s]=(0,Y.useState)(fe),[l,u]=(0,Y.useState)(o),[f,m]=(0,Y.useState)(()=>new Set(o?[o.id]:[])),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(``),[x,S]=(0,Y.useState)(``),[C,w]=(0,Y.useState)(``),[T,O]=(0,Y.useState)([]),[k,A]=(0,Y.useState)(),[j,M]=(0,Y.useState)(!1),N=F(),P=(0,Y.useRef)(null),I=(0,Y.useCallback)(e=>i(`materials`,le,{signal:e}),[i]),L=p(I,5e3,e(a,`materials`)),R=(0,Y.useCallback)(e=>o?i(`materials/${encodeURIComponent(o.id)}${o.revision?`?revision=${encodeURIComponent(o.revision)}`:``}`,ce,{signal:e}):Promise.resolve(null),[i,o?.id,o?.revision]),B=p(R,5e3),V=B.data?.id===o?.id?B.data:null;ne(t?V?.originals.find(e=>e.sha256===o?.original)?.name??V?.title:void 0);let W=[...new Map([...T,...L.data?.materials??[],...V?[V]:[]].map(e=>[e.id,e])).values()].sort((e,t)=>t.createdAt.localeCompare(e.createdAt)||t.id.localeCompare(e.id)),G=k===void 0?L.data?.nextCursor:k;function K(e,t=``){n(),s(e),u(e),S(``),w(t),_(!1),m(t=>new Set([...t,e.id])),history.replaceState(null,``,E(`/projects/${a}/materials?${new URLSearchParams({...e})}`))}(0,Y.useEffect)(()=>{let e=()=>{if(!d().endsWith(`/materials`))return;let e=fe();s(e),u(e),S(``),y(``),w(``),_(!1),e&&m(t=>new Set([...t,e.id]))};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);async function re(){if(G&&!j){M(!0),N(``);try{let e=await i(`materials?before=${G}`,le);O(t=>[...t,...e.materials]),A(e.nextCursor)}catch(e){N(c(e))}finally{M(!1)}}}let ae=W.find(e=>e.id===l?.id),J=ae?.originals.find(e=>e.sha256===l?.original)?.name??ae?.title??`当前资料`;function oe(){u(void 0),w(``),P.current?.focus()}let se=(0,Q.jsx)(D,{icon:`plus`,label:`新增资料`,onClick:()=>{n(),_(!0),N(``)}}),X=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(h,{resource:L}),L.data?W.length===0?(0,Q.jsx)(`p`,{className:`tree-status`,children:`暂无资料`}):(0,Q.jsx)(Q.Fragment,{children:W.map(e=>(0,Q.jsxs)(`div`,{role:`none`,children:[(0,Q.jsxs)(U,{role:`treeitem`,"aria-level":1,"aria-expanded":f.has(e.id),"aria-selected":t&&!g&&o?.id===e.id&&!o.original,className:`tree-item tree-folder`,style:{"--tree-level":1},"data-testid":`material-folder`,title:e.title,onClick:()=>{let t=f.has(e.id);K({id:e.id}),t&&m(t=>{let n=new Set(t);return n.delete(e.id),n})},leading:(0,Q.jsx)(`span`,{className:`tree-chevron ${f.has(e.id)?`expanded`:``}`,children:(0,Q.jsx)(b,{name:`chevron`,size:`small`})}),children:[(0,Q.jsx)(b,{name:`files`}),(0,Q.jsx)(`span`,{className:`tree-name`,children:e.title})]}),f.has(e.id)&&(0,Q.jsx)(`div`,{role:`group`,children:[...e.originals].sort((e,t)=>ie(e.name,t.name)).map((n,r)=>(0,Q.jsxs)(U,{role:`treeitem`,"aria-level":2,"aria-selected":t&&!g&&o?.id===e.id&&o.original===n.sha256,className:`tree-item`,style:{"--tree-level":2},"data-testid":`material-original`,title:n.name,onClick:()=>K({id:e.id,original:n.sha256,...e.id===o?.id&&o.revision?{revision:o.revision}:{}}),leading:(0,Q.jsx)(`span`,{className:`tree-chevron`}),children:[(0,Q.jsx)(b,{name:`file`}),(0,Q.jsx)(`span`,{className:`tree-name`,children:n.name})]},`${n.sha256}:${r}`))})]},e.id))}):!L.error&&(0,Q.jsx)(`p`,{className:`tree-status`,children:`加载中…`}),G&&(0,Q.jsx)(`button`,{className:`tree-action`,disabled:j,onClick:()=>void re(),children:j?`加载中…`:`加载更多`})]}),Z=!g&&!x&&o?.original,ue=g?`新增资料`:x?`搜索结果`:V?.title||`资料预览`;return r({tree:X,reader:(0,Q.jsxs)(`section`,{className:`session-reader`,"aria-label":`资料内容与搜索`,children:[Z&&V?(0,Q.jsx)(he,{material:V,hash:Z,highlight:C,error:B.error},`${V.id}:${Z}`):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(z,{title:ue}),(0,Q.jsx)(`div`,{className:`session-reader-content`,children:g?(0,Q.jsx)(ye,{onCancel:()=>_(!1),onSaved:e=>{K({id:e}),L.reload()}}):x?(0,Q.jsx)(me,{query:x,scope:l,onSelect:e=>K(e,x)},`${x}/${l?.id}/${l?.original}`):o?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(h,{resource:B}),V?(0,Q.jsxs)(`article`,{className:`material-body`,children:[o.revision&&(0,Q.jsx)(`button`,{className:`material-link`,onClick:()=>K({id:o.id}),children:`查看最新内容`}),!o.revision&&(V.state===`waiting`||V.state===`running`)?(0,Q.jsx)(`p`,{className:`muted`,role:`status`,children:`正在整理…`}):null,(0,Q.jsx)(te,{children:V.error}),!o.revision&&V.state===`failed`&&(0,Q.jsx)(`button`,{onClick:()=>void i(`materials/${o.id}/retry`,ce,{method:`POST`}).then(()=>B.reload()).catch(e=>N(c(e))),children:`重试整理`}),V.content?(0,Q.jsx)(`div`,{className:`markdown`,children:(0,Q.jsx)(q,{highlight:C,children:de(V)})}):(0,Q.jsx)(`p`,{className:`muted`,children:`正文尚未整理,可以先查看左侧原件。`})]}):!B.error&&(0,Q.jsx)(`p`,{role:`status`,children:`加载中…`})]}):(0,Q.jsx)(ee,{mascot:!0,title:`选择资料开始阅读`,description:`也可以在下方搜索资料内容。`})})]}),!g&&(0,Q.jsxs)(`form`,{className:`session-search-dock`,"data-testid":`material-search-form`,onSubmit:e=>{e.preventDefault(),S(v.trim()),w(``)},children:[l&&(0,Q.jsxs)(`button`,{type:`button`,className:`search-scope-chip`,title:`清除搜索范围`,"aria-label":`清除范围:${J}`,onClick:oe,children:[(0,Q.jsxs)(`span`,{className:`scope-label`,children:[`搜索:`,J]}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`×`})]}),(0,Q.jsxs)(`div`,{className:`session-search-input-row`,children:[(0,Q.jsx)(`input`,{ref:P,"aria-label":`搜索资料`,placeholder:`搜索资料内容`,value:v,onChange:e=>y(e.target.value),onKeyDown:e=>{e.key===`Backspace`&&!v&&l&&(e.preventDefault(),oe())}}),(x||v||C)&&(0,Q.jsx)(D,{icon:`close`,label:`清空搜索`,onClick:()=>{y(``),S(``),w(``),P.current?.focus()}}),(0,Q.jsx)(D,{icon:`search`,type:`submit`,label:`搜索`,disabled:!v.trim()})]})]})]}),actions:se,href:`/projects/${a}/materials${o&&!g?`?${new URLSearchParams({...o})}`:``}`})}function me({query:e,scope:t,onSelect:n}){let{request:r}=H(),[i,a]=(0,Y.useState)(``),o=(0,Y.useCallback)(n=>r(`resources/search?${new URLSearchParams({query:e,scope:`materials`,after:i,...t?{materialId:t.id}:{},...t?.original?{originalHash:t.original}:{}})}`,ue,{signal:n}),[r,e,t?.id,t?.original,i]),s=p(o);return(0,Q.jsxs)(`section`,{className:`session-results stack`,"aria-label":`搜索结果`,children:[(0,Q.jsx)(h,{resource:s}),s.loading?(0,Q.jsx)(`p`,{role:`status`,children:`正在搜索…`}):s.data?.items.length===0?(0,Q.jsx)(`p`,{className:`empty`,children:`没有找到匹配的资料`}):s.data?.items.map(t=>(0,Q.jsxs)(`button`,{className:`session-item`,"data-testid":`material-match`,onClick:()=>{let e=new URL(t.url,location.origin).searchParams;n({id:e.get(`id`),...e.get(`original`)?{original:e.get(`original`)}:{},...e.get(`revision`)?{revision:e.get(`revision`)}:{}})},children:[(0,Q.jsx)(`strong`,{children:t.title.replace(/^R\d+ · /,``)}),(0,Q.jsx)(`span`,{className:`session-excerpt`,children:(0,Q.jsx)(G,{value:K(t.snippet,e),query:e})})]},t.key)),s.data?.nextCursor&&(0,Q.jsx)(`button`,{disabled:s.loading,onClick:()=>a(s.data.nextCursor),children:`下一页`})]})}function he({material:t,hash:n,highlight:r,error:i}){let{projectId:a}=H(),o=t.originals.find(e=>e.sha256===n),s=E(`/api/v1/projects/${a}/materials/${t.id}/originals/${n}?revision=${t.revision}`),[c,l]=(0,Y.useState)(!1),u=(0,Y.useCallback)(async e=>{let t=await fetch(s,{signal:e});if(!t.ok)throw new f(`HTTP_ERROR`,`原件暂时无法读取。`,t.status);let n=await t.arrayBuffer();try{let e=new TextDecoder(`utf8`,{fatal:!0}).decode(n);return e.includes(`\0`)?null:e}catch{return null}},[s]),d=p(u,!1,e(a,`material-original`,n));if(!o)return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(z,{title:`资料原件`}),(0,Q.jsx)(`div`,{className:`session-reader-content`,children:(0,Q.jsx)(te,{announce:!0,children:`找不到此原件。`})})]});let m=/\.(md|markdown)$/i.test(o.name),g=/\.html?$/i.test(o.name);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(z,{title:o.name,actions:(0,Q.jsxs)(`div`,{className:`toolbar-actions`,children:[(m||g)&&(0,Q.jsx)(D,{icon:c?`preview`:`code`,label:c?`切换为预览`:`切换为原文`,"aria-pressed":c,onClick:()=>l(!c)}),(0,Q.jsx)(`a`,{className:`icon-button`,"aria-label":`下载原件`,title:`下载原件`,href:s,download:o.name,children:(0,Q.jsx)(b,{name:`download`})})]})}),(0,Q.jsxs)(`div`,{className:`session-reader-content`,children:[(0,Q.jsx)(L,{message:i}),(0,Q.jsx)(h,{resource:d}),d.loading&&d.data===void 0?(0,Q.jsx)(`p`,{role:`status`,children:`加载中…`}):d.data===null?(0,Q.jsx)(`p`,{className:`muted`,children:`此格式请下载后查看。`}):d.data!==void 0&&(0,Q.jsx)(`div`,{className:`preview-body${g&&!c?` preview-body-html`:``}`,"data-testid":`material-original-content`,children:g&&!c?(0,Q.jsx)(ae,{url:s,name:o.name}):m&&!c?(0,Q.jsx)(`article`,{className:`markdown`,children:(0,Q.jsx)(q,{highlight:r,children:d.data})}):(0,Q.jsx)(`pre`,{className:`raw`,children:(0,Q.jsx)(G,{value:d.data,query:r})})})]})]})}function ge(e){if(e.kind===`text`){try{if([`http:`,`https:`].includes(new URL(e.text.trim()).protocol))return`link`}catch{}return`text`}let{name:t,type:n}=e.file;return n.startsWith(`image/`)||/\.(png|jpe?g|gif|webp|svg|heic|avif)$/i.test(t)?`imageFile`:/\.(csv|tsv|xlsx?|ods)$/i.test(t)?`spreadsheetFile`:/\.(json|ya?ml|xml|html?|css|[cm]?[jt]sx?|py|go|rs|sh|sql)$/i.test(t)?`codeFile`:n.startsWith(`text/`)||/\.(pdf|docx?|odt|rtf|md|txt)$/i.test(t)?`file`:`attachment`}function _e(e){try{return new URL(e.trim()).hostname}catch{return e.trim().split(`
|
|
4
|
+
`)[0]?.slice(0,80)||`文本`}}function ve(e){try{return new URL(e.trim()).href}catch{return e.trim().split(`
|
|
5
|
+
`).slice(1).join(`
|
|
6
|
+
`)}}function ye({onSaved:e,onCancel:t}){let{request:n,projectId:r}=H(),[i,a]=(0,Y.useState)([]),[o,s]=(0,Y.useState)(),[u,d]=(0,Y.useState)(!1),f=F(),p=(0,Y.useRef)(null),m=(0,Y.useRef)(l()),h=(0,Y.useRef)(new Map);function g(e){a(e),m.current=l(),f(``)}async function _(){d(!0),f(``);try{let t=[];for(let[e,n]of i.entries()){let i=h.current.get(n.id);if(!i){let t=n.kind===`file`?n.file.name:`${_e(n.text)}.txt`,a=await fetch(E(`/api/v1/projects/${r}/materials/uploads`),{method:`POST`,headers:{"content-type":`application/octet-stream`,"x-teammy-web":`1`},body:n.kind===`file`?n.file:new Blob([n.text],{type:`text/plain`})}),o=await a.json();if(!a.ok)throw Error(o.error?.message??`第 ${e+1} 项上传失败。`);i={name:t,sha256:o.sha256,size:o.size},h.current.set(n.id,i)}t.push(i)}let a=i.length===1&&i[0]?.kind===`text`?i[0].text.trim():``,o;try{let e=new URL(a);[`http:`,`https:`].includes(e.protocol)&&(o=e.href)}catch{}e((await n(`materials`,ce,{method:`POST`,body:{operationId:m.current,originals:t,...o?{url:o}:{}}})).id)}catch(e){f(c(e))}finally{d(!1)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`form`,{className:`material-form`,onSubmit:e=>{e.preventDefault(),_()},children:[(0,Q.jsx)(`p`,{className:`muted`,children:`上传附件到项目,以便于Tim进行理解`}),(0,Q.jsxs)(`fieldset`,{disabled:u,children:[(0,Q.jsxs)(`div`,{className:`attachment-grid`,children:[i.map(e=>(0,Q.jsxs)(`article`,{className:`attachment-card`,"data-testid":`attachment-card`,children:[e.kind===`text`?(0,Q.jsxs)(`button`,{type:`button`,className:`attachment-content`,"aria-label":`编辑:${_e(e.text)}`,onClick:()=>s({id:e.id,text:e.text}),children:[(0,Q.jsx)(b,{name:ge(e)}),(0,Q.jsx)(`span`,{className:`attachment-name`,children:_e(e.text)}),ve(e.text)&&(0,Q.jsx)(`span`,{className:`attachment-excerpt`,children:ve(e.text)})]}):(0,Q.jsxs)(`div`,{className:`attachment-content`,children:[(0,Q.jsx)(b,{name:ge(e)}),(0,Q.jsx)(`span`,{className:`attachment-name`,children:e.file.name})]}),(0,Q.jsx)(D,{className:`attachment-remove`,icon:`close`,label:`移除:${e.kind===`file`?e.file.name:_e(e.text)}`,onClick:()=>{h.current.delete(e.id),g(i.filter(t=>t.id!==e.id))}})]},e.id)),(0,Q.jsxs)(`button`,{type:`button`,className:`attachment-add`,onClick:()=>s({text:``}),children:[(0,Q.jsx)(b,{name:`addText`}),(0,Q.jsx)(`span`,{children:`添加文本/链接`})]}),(0,Q.jsxs)(`button`,{type:`button`,className:`attachment-add`,onClick:()=>p.current?.click(),children:[(0,Q.jsx)(b,{name:`addFile`}),(0,Q.jsx)(`span`,{children:`添加文件`})]})]}),(0,Q.jsx)(`input`,{ref:p,type:`file`,multiple:!0,hidden:!0,"aria-label":`原始文件`,onChange:e=>{g([...i,...[...e.target.files??[]].map(e=>({id:l(),kind:`file`,file:e}))]),e.target.value=``}}),(0,Q.jsxs)(`div`,{className:`actions attachment-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:t,children:`取消`}),(0,Q.jsx)(`button`,{type:`submit`,className:`primary`,disabled:!i.length,children:u?`上传中…`:`提交资料`})]})]})]}),o&&(0,Q.jsx)(S,{id:`material-text-editor`,title:`添加文本/链接`,onClose:()=>s(void 0),children:(0,Q.jsxs)(`form`,{className:`stack`,onSubmit:e=>{if(e.preventDefault(),!o.text.trim())return;let t={id:o.id??l(),kind:`text`,text:o.text};h.current.delete(t.id),g(o.id?i.map(e=>e.id===o.id?t:e):[...i,t]),s(void 0)},children:[(0,Q.jsx)(N,{id:`material-attachment-text`,label:`文本或链接`,children:(0,Q.jsx)(`textarea`,{autoFocus:!0,rows:8,value:o.text,onChange:e=>s({...o,text:e.target.value}),placeholder:`粘贴文本或网页链接`})}),(0,Q.jsx)(`div`,{className:`actions`,children:(0,Q.jsx)(`button`,{type:`submit`,className:`primary`,disabled:!o.text.trim(),children:o.id?`保存`:`添加`})})]})})]})}var be=M([`overview`,`handoff`]),xe=y({title:r().trim().min(1),summary:r().trim().min(1)}),Se=y({markdown:r().trim().min(1)}),Ce=xe.extend({sourceRevision:O,sourceHash:x,generatedAt:r(),stale:T()}),we=y({kind:be,status:M([`absent`,`queued`,`running`,`succeeded`,`failed`]),available:T(),currentRevision:O,sourceRevision:O.nullable(),stale:T(),result:I([xe,Se]).nullable(),generatedAt:r().nullable(),error:r().nullable()}),Te=M([`claude-code`,`codex`,`cursor`,`pi`,`dsh`]),Ee=y({formatVersion:P(1),adapterVersion:P(1),agent:Te,nativeId:r().min(1).max(512),cwd:r().min(1).max(4096),messages:k(y({id:r().min(1).max(1024),role:M([`user`,`assistant`]),text:r().min(1),source:r().min(1).max(1024)}).strict())}).strict().refine(e=>new Set(e.messages.map(e=>e.id)).size===e.messages.length,`Duplicate message IDs.`);y({operationId:a(),sessionKey:x,parentRevision:O,blob:A}).strict(),y({revision:O,hash:x.nullable(),cleared:T()});var De=y({owner:C,sessionKey:x,agent:Te,nativeId:r(),cwd:r(),title:r(),revision:O,updatedAt:r(),messageCount:R().int().nonnegative(),blob:A,overview:Ce.optional()}),Oe=y({sessions:k(De),nextCursor:O.nullable()}),ke=y({totalSessions:R().int().nonnegative(),totalMessages:R().int().nonnegative(),memberCount:R().int().nonnegative(),updatedAt:r().nullable()});y({owner:C.optional(),sessionKey:x.optional()}).strict().refine(e=>!e.sessionKey||!!e.owner,`A session scope requires an owner.`);var Ae=y({matches:k(y({owner:C,sessionKey:x,revision:O,messageId:r(),source:M([`message`,`handoff`]).default(`message`),role:M([`user`,`assistant`]),snippet:r(),title:r()})),nextCursor:O.nullable()}),je=y({owner:C,key:x,revision:O.refine(e=>e>0).optional(),messageId:r().min(1).optional(),source:M([`message`,`handoff`]).optional()});function Me(e){let t=new URLSearchParams(e);if(![`owner`,`sessionKey`,`revision`,`messageId`].some(e=>t.has(e)))return{};let n=je.safeParse({owner:t.get(`owner`),key:t.get(`sessionKey`),...t.has(`revision`)?{revision:Number(t.get(`revision`))}:{},...t.has(`messageId`)?{messageId:t.get(`messageId`)}:{},...t.has(`source`)?{source:t.get(`source`)}:{}});return n.success?{target:n.data}:{error:`对话链接不完整或已损坏。`}}function Ne({members:e,refresh:t,selected:n,onOwner:r,onSession:i,level:a=1}){let[o,s]=(0,Y.useState)(()=>new Set(n?.key?[n.owner]:[])),[c,l]=(0,Y.useState)(e[0]?.id??``);return(0,Q.jsx)(`div`,{role:a===1?`tree`:`group`,"aria-label":`成员对话`,"data-testid":`session-tree`,onKeyDown:a===1?J:void 0,children:[...e].sort((e,t)=>ie(e.id,t.id)).map(e=>(0,Q.jsxs)(`div`,{role:`none`,children:[(0,Q.jsxs)(U,{type:`button`,role:`treeitem`,"aria-level":a,"aria-expanded":o.has(e.id),"aria-selected":n?.owner===e.id&&!n.key,className:`tree-item tree-folder`,style:{"--tree-level":a},tabIndex:c===e.id?0:-1,"data-testid":`session-owner`,"data-owner-id":e.id,onFocus:()=>l(e.id),onClick:()=>{s(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}),r(e.id)},leading:(0,Q.jsx)(`span`,{className:`tree-chevron ${o.has(e.id)?`expanded`:``}`,children:(0,Q.jsx)(b,{name:`chevron`,size:`small`})}),children:[(0,Q.jsx)(b,{name:`files`}),(0,Q.jsx)(`span`,{className:`tree-name`,title:e.id,children:e.id})]}),o.has(e.id)&&(0,Q.jsx)(Pe,{level:a+1,owner:e.id,selected:n,onSession:i,focused:c,onFocus:l},`${e.id}/${t}`)]},e.id))})}function Pe({level:t,owner:n,selected:r,onSession:i,focused:a,onFocus:o}){let{request:s,projectId:l}=H(),u=(0,Y.useCallback)(e=>s(`sessions?${new URLSearchParams({owner:n,limit:`50`,order:`updated`})}`,Oe,{signal:e}),[n,s]),d=p(u,15e3,e(l,`session-tree`,n)),[f,m]=(0,Y.useState)(),[_,v]=(0,Y.useState)(!1),y=F(),x=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>x.current?.abort(),[]);let S=f?f.nextCursor:d.data?.nextCursor;return(0,Q.jsxs)(`div`,{role:`group`,"aria-busy":d.loading||_,children:[(0,Q.jsx)(h,{resource:d}),d.loading&&!d.data&&(0,Q.jsx)(`span`,{className:`tree-status`,role:`status`,children:`正在加载…`}),[...new Map([...f?.sessions??[],...d.data?.sessions??[]].map(e=>[e.sessionKey,e])).values()].sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt)||e.sessionKey.localeCompare(t.sessionKey)).map(e=>(0,Q.jsxs)(U,{type:`button`,role:`treeitem`,"aria-level":t,"aria-selected":r?.owner===n&&r.key===e.sessionKey,className:`tree-item`,style:{"--tree-level":t},tabIndex:a===`${n}/${e.sessionKey}`?0:-1,"data-testid":`session-row`,"data-owner-id":n,"data-session-key":e.sessionKey,title:g(e.title||e.nativeId),onFocus:()=>o(`${n}/${e.sessionKey}`),onClick:()=>i({owner:n,key:e.sessionKey,title:e.title||e.nativeId}),leading:(0,Q.jsx)(`span`,{className:`tree-chevron`}),children:[(0,Q.jsx)(b,{name:`sessions`}),(0,Q.jsx)(`span`,{className:`tree-name`,children:g(e.title||e.nativeId)})]},e.sessionKey)),S!=null&&(0,Q.jsx)(`button`,{className:`tree-action`,"data-testid":`session-tree-more`,disabled:_,onClick:async()=>{v(!0),y(``);let e=new AbortController;x.current=e;try{let t=await s(`sessions?${new URLSearchParams({owner:n,after:String(S),limit:`50`,order:`updated`})}`,Oe,{signal:e.signal});m(e=>({sessions:[...e?.sessions??[],...t.sessions],nextCursor:t.nextCursor}))}catch(t){e.signal.aborted||y(c(t))}finally{e.signal.aborted||v(!1)}},children:`加载更多`})]})}function Fe({info:e,targeted:t=!1,highlight:n=``}){let[r,i]=(0,Y.useState)(t),a=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{t&&a.current?.scrollIntoView({block:`center`})},[t]),(0,Q.jsxs)(`details`,{ref:a,open:r,className:`session-handoff`,onToggle:e=>i(e.currentTarget.open),children:[(0,Q.jsx)(`summary`,{children:`交接说明`}),r&&(0,Q.jsx)(Ie,{info:e,revision:t?e.revision:void 0,highlight:n})]})}function Ie({info:e,revision:t,highlight:n}){let{request:r}=H(),a=`sessions/${encodeURIComponent(e.owner)}/${e.sessionKey}`,o=(0,Y.useCallback)(e=>r(`${a}/analysis/handoff${t===void 0?``:`?revision=${t}`}`,we,{signal:e}),[r,a,t]),s=p(o,5e3),l=i(),[u,d]=(0,Y.useState)(!1),f=F(),m=s.data,g=u||m?.status===`queued`||m?.status===`running`,v=m?.result&&`markdown`in m.result?m.result.markdown:void 0;return(0,Q.jsxs)(`div`,{className:`stack`,"data-testid":`session-handoff`,children:[(0,Q.jsx)(h,{resource:s}),s.loading&&!m&&(0,Q.jsx)(`small`,{role:`status`,children:`正在加载…`}),m&&(0,Q.jsxs)(`div`,{className:`inline-actions`,children:[m.status===`failed`&&t===void 0&&(0,Q.jsx)(`button`,{"data-testid":`session-handoff-generate`,disabled:g||!m.available,onClick:async()=>{d(!0),f(``);try{await r(`${a}/handoff`,we,{method:`POST`,signal:l}),await s.reload()}catch(e){l.aborted||f(c(e))}finally{l.aborted||d(!1)}},children:g?`正在整理…`:`重试`}),!m.available&&(0,Q.jsx)(`small`,{children:`请先配置项目模型接入点`}),m.status===`failed`&&(0,Q.jsx)(`small`,{children:`整理未完成,可重试`}),m.available&&m.status!==`failed`&&(!v||m.stale||g)&&(0,Q.jsx)(`small`,{role:`status`,children:m.status===`running`||u?`正在整理…`:v?`对话已有新内容,等待自动更新…`:`等待自动整理…`}),m.currentRevision!==e.revision&&(0,Q.jsx)(`small`,{children:`交接说明使用最新对话;当前阅读的是历史原文`})]}),v&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`small`,{children:[`基于版本 `,m.sourceRevision,` · `,(0,Q.jsx)(_,{value:m.generatedAt})]}),(0,Q.jsx)(`div`,{className:`markdown`,"data-testid":`session-handoff-body`,children:(0,Q.jsx)(q,{highlight:n,children:v})})]})]})}function Le({members:t,active:n,onActivate:r,children:i}){let{request:a,projectId:o,api:c}=H(),l=(0,Y.useCallback)(async e=>{let[t,n]=await Promise.all([a(`sessions/stats`,ke,{signal:e}),c.members(e)]);return{...t,members:n.members}},[a,c]),u=p(l,!0,e(o,`session-stats`)),[f,m]=(0,Y.useState)(``),[_,y]=(0,Y.useState)(``),[b,x]=(0,Y.useState)(0),[S]=(0,Y.useState)(()=>Me(location.search)),[C,w]=(0,Y.useState)(S.target),[T,O]=(0,Y.useState)(S.target);ne(n&&T?.title?g(T.title):void 0);let[k,A]=(0,Y.useState)(S.error??``),[j,M]=(0,Y.useState)(``),N=(0,Y.useRef)(null),P=C?.key?C.title?`搜索对话:${g(C.title)}`:`搜索当前对话`:C?`搜索:${C.owner} 的对话内容`:``,F=()=>{w(void 0),M(``),I(),N.current?.focus()};function I(){if(!T?.messageId)return;let{messageId:e,...t}=T;O(t),history.replaceState(null,``,E(W(o,t.owner,t.key,t)))}let L=(0,Y.useCallback)(e=>{O(t=>t?.owner===e.owner&&t.key===e.sessionKey&&t.title!==e.title?{...t,title:e.title}:t),w(t=>t?.owner===e.owner&&t.key===e.sessionKey&&t.title!==e.title?{...t,title:e.title}:t)},[]);(0,Y.useEffect)(()=>{let e=()=>{if(!d().endsWith(`/sessions`))return;let e=Me(location.search);O(e.target),w(e.target),A(e.error??``),y(``),m(``),M(``)};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);let R=(e,t=``)=>{r(),O(e),w(e),y(``),M(t),A(``),history.replaceState(null,``,E(W(o,e.owner,e.key,e)))},B=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(h,{resource:u}),(0,Q.jsx)(Ne,{members:(u.data?.members??t).filter(e=>e.hasSessions),refresh:b,selected:n?C:void 0,level:2,onOwner:e=>{r(),w({owner:e}),O(void 0),y(``),M(``),A(``),history.replaceState(null,``,E(`/projects/${encodeURIComponent(o)}/sessions`))},onSession:R})]}),V=(0,Q.jsxs)(`section`,{className:`session-reader`,"aria-label":`对话内容与搜索`,children:[(0,Q.jsx)(z,{title:(0,Q.jsxs)(`h1`,{children:[s.sessions,(0,Q.jsx)(v,{children:(0,Q.jsx)(`span`,{"data-testid":`session-total`,children:u.data?.totalSessions??`—`})})]}),actions:(0,Q.jsx)(D,{icon:`refresh`,label:`刷新${s.sessions}`,"data-testid":`sessions-refresh`,disabled:u.loading,onClick:()=>{u.reload(),x(e=>e+1)}})}),(0,Q.jsx)(`div`,{className:`session-reader-content`,children:k?(0,Q.jsx)(te,{announce:!0,children:k}):_?(0,Q.jsx)(Re,{query:_,refresh:b,scope:{...C?{owner:C.owner}:{},...C?.key?{sessionKey:C.key}:{}},onSelect:e=>R(e,_)},`${_}/${C?.owner??``}/${C?.key??``}`):T?(0,Q.jsx)(ze,{selection:T,highlight:j,onLoaded:L,onLatest:()=>R({owner:T.owner,key:T.key})},`${T.owner}/${T.key}/${T.revision}/${T.source}/${b}`):(0,Q.jsx)(ee,{mascot:!0,title:`选择对话开始阅读`,description:`也可以在下方搜索会话库内容。`})}),(0,Q.jsxs)(`form`,{className:`session-search-dock`,"data-testid":`session-search-form`,onSubmit:e=>{e.preventDefault(),y(f.trim()),M(``),A(``),x(e=>e+1)},children:[C&&(0,Q.jsxs)(`button`,{type:`button`,className:`search-scope-chip`,"data-testid":`session-search-scope`,title:`清除搜索范围`,"aria-label":`清除范围:${P}`,onClick:F,children:[(0,Q.jsx)(`span`,{className:`scope-label`,children:P}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`×`})]}),(0,Q.jsxs)(`div`,{className:`session-search-input-row`,children:[(0,Q.jsx)(`input`,{ref:N,"aria-label":`搜索对话`,"data-testid":`session-query`,value:f,maxLength:500,placeholder:`搜索会话库内容`,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Backspace`&&!f&&C&&(e.preventDefault(),F())}}),(_||f||j)&&(0,Q.jsx)(D,{icon:`close`,label:`清空搜索`,"data-testid":`session-search-clear`,onClick:()=>{m(``),y(``),M(``),I(),N.current?.focus()}}),(0,Q.jsx)(D,{icon:`search`,type:`submit`,label:`搜索`,"data-testid":`session-search`,disabled:!f.trim()})]})]})]});return i({hasSelection:!!C,tree:B,reader:V,href:T?W(o,T.owner,T.key,T):`/projects/${o}/sessions`})}function Re({query:e,refresh:t,scope:n,onSelect:r}){let{request:i}=H(),[a,o]=(0,Y.useState)(0),s=(0,Y.useCallback)(t=>i(`sessions/search?${new URLSearchParams({q:e,after:String(a),limit:`30`,order:`updated`,...n.owner?{owner:n.owner}:{},...n.sessionKey?{sessionKey:n.sessionKey}:{}})}`,Ae,{signal:t}),[i,e,a,t,n.owner,n.sessionKey]),c=p(s);return(0,Q.jsxs)(`section`,{className:`session-results stack`,"aria-label":`搜索结果`,"aria-busy":c.loading,children:[(0,Q.jsx)(h,{resource:c}),c.loading&&(0,Q.jsx)(`p`,{role:`status`,children:`正在搜索…`}),!c.loading&&c.data?.matches.map(t=>(0,Q.jsxs)(`button`,{className:`session-item`,"data-testid":`session-match`,"data-message-id":t.messageId,onClick:()=>r({owner:t.owner,key:t.sessionKey,revision:t.revision,messageId:t.messageId||void 0,source:t.source,title:t.title}),children:[(0,Q.jsx)(`strong`,{children:g(t.title)}),(0,Q.jsxs)(`small`,{children:[t.owner,` ·`,` `,t.source===`handoff`?`交接说明`:t.role===`user`?`用户`:`助手`]}),(0,Q.jsx)(`span`,{className:`session-excerpt`,children:(0,Q.jsx)(G,{value:K(t.snippet,e),query:e})})]},`${t.owner}:${t.sessionKey}:${t.revision}:${t.source}:${t.messageId}`)),!c.loading&&c.data?.matches.length===0&&(0,Q.jsx)(`p`,{className:`empty`,children:`没有找到匹配的对话`}),c.data?.nextCursor!=null&&(0,Q.jsx)(`button`,{"data-testid":`sessions-next`,disabled:c.loading,onClick:()=>o(c.data.nextCursor),children:`下一页`}),a>0&&(0,Q.jsx)(`button`,{disabled:c.loading,onClick:()=>o(0),children:`返回第一页`})]})}function ze({selection:e,highlight:t,onLoaded:n,onLatest:r}){let{request:i}=H(),a=(0,Y.useCallback)(async t=>{try{return await i(`sessions/${encodeURIComponent(e.owner)}/${e.key}${e.revision===void 0?``:`?revision=${e.revision}`}`,De,{signal:t})}catch(e){throw e instanceof f&&e.code===`SESSION_NOT_FOUND`?Error(`找不到这条对话或引用的版本,原链接可能已失效。`):e}},[i,e.owner,e.key,e.revision]),o=p(a,5e3);return(0,Y.useEffect)(()=>{o.data&&n(o.data)},[o.data,n]),(0,Q.jsxs)(`section`,{className:`session-conversation stack`,"data-testid":`session-detail`,children:[(0,Q.jsx)(h,{resource:o}),o.loading&&!o.data&&(0,Q.jsx)(`p`,{role:`status`,children:`正在读取对话…`}),o.data&&(0,Q.jsx)(Be,{info:o.data,messageId:e.messageId,handoff:e.source===`handoff`,highlight:t,pinned:e.revision!==void 0,onLatest:r},o.data.blob.sha256)]})}function Be({info:e,messageId:t,handoff:n,highlight:r,pinned:i,onLatest:a}){let{readTextBlob:o,projectId:s}=H(),c=(0,Y.useCallback)(async t=>Ee.parse(JSON.parse(await o(e.blob,t))),[e.blob.sha256,e.blob.size]),l=p(c),u=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{l.data&&t&&u.current?.scrollIntoView({block:`center`})},[l.data,t]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`header`,{className:`conversation-header`,children:[(0,Q.jsx)(`h2`,{className:`session-title`,children:g(e.title||e.nativeId)}),(0,Q.jsxs)(`p`,{children:[e.owner,` · `,e.agent,` · `,e.messageCount,` 条消息`]}),(0,Q.jsxs)(`small`,{children:[(0,Q.jsx)(_,{value:e.updatedAt}),i&&(0,Q.jsxs)(Q.Fragment,{children:[` `,`· 引用版本 `,e.revision,` ·`,` `,(0,Q.jsx)(`a`,{href:E(W(s,e.owner,e.sessionKey)),onClick:e=>{e.preventDefault(),a()},children:`查看最新`})]})]}),e.overview&&(0,Q.jsx)(`p`,{"data-testid":`session-summary`,children:e.overview.summary}),e.overview?.stale&&(0,Q.jsx)(`small`,{children:`摘要待更新`})]}),(0,Q.jsx)(Fe,{info:e,targeted:n,highlight:n?r:``}),(0,Q.jsx)(h,{resource:l}),l.loading&&(0,Q.jsx)(`p`,{role:`status`,children:`正在读取对话…`}),l.data&&(0,Q.jsxs)(Q.Fragment,{children:[t&&!l.data.messages.some(e=>e.id===t)&&(0,Q.jsx)(j,{children:`该版本中找不到引用的消息,已打开对话原文。`}),(0,Q.jsx)(`div`,{className:`session-messages`,children:l.data.messages.map(e=>(0,Q.jsx)(re,{mine:e.role===`user`,author:e.role===`user`?`用户`:`助手`,className:`session-message ${e.role} ${e.id===t?`matched`:``}`,"data-testid":`session-message`,"data-message-id":e.id,ref:e.id===t?u:void 0,children:(0,Q.jsx)(`div`,{className:`markdown`,children:(0,Q.jsx)(q,{highlight:r,children:e.text})})},e.id))})]})]})}var $=r().trim().min(1),Ve=y({id:a(),text:$,state:M([`draft`,`kept`]),revision:R().int().positive(),createdAt:r(),updatedAt:r()}),He=y({cards:k(Ve)});y({id:a(),text:$}).strict(),y({expectedRevision:R().int().positive(),text:$.optional(),action:M([`keep`,`discard`,`delete`]).optional()}).strict().refine(e=>e.text!==void 0||e.action!==void 0,`没有需要保存的修改。`),y({text:$}).strict();function Ue(){let{request:t,projectId:n}=H(),r=(0,Y.useCallback)(e=>t(`memory`,He,{signal:e}),[t]),i=p(r,5e3,e(n,`memory`)),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)({}),u=(0,Y.useRef)(null),d=[...i.data?.cards??[]];for(let e of Object.values(s))d.some(t=>t.id===e.id)||d.push(e);if(i.data&&!u.current&&(u.current=[...d].sort((e,t)=>Number(t.state===`kept`)-Number(e.state===`kept`)).map(e=>e.id)),u.current){let e=new Map(u.current.map((e,t)=>[e,t]));for(let t of d)e.has(t.id)||(e.set(t.id,u.current.length),u.current.push(t.id));d.sort((t,n)=>e.get(t.id)-e.get(n.id))}return(0,Q.jsxs)(`section`,{className:`session-reader`,"aria-label":`项目记忆`,children:[(0,Q.jsx)(z,{title:`记忆`,actions:(0,Q.jsx)(D,{icon:`plus`,label:`新增记忆`,disabled:!!a,onClick:()=>o(l())})}),(0,Q.jsxs)(`div`,{className:`memory-page`,children:[(0,Q.jsx)(h,{resource:i}),!i.data&&i.loading&&(0,Q.jsx)(`p`,{role:`status`,children:`加载中…`}),(0,Q.jsxs)(`div`,{className:`memory-cards`,children:[a&&(0,Q.jsx)(We,{id:a,onDone:()=>o(null),reload:i.reload},a),d.map(e=>(0,Q.jsx)(We,{id:e.id,card:e,reload:i.reload,onEditing:t=>c(n=>{let r={...n};return t?r[e.id]=e:delete r[e.id],r})},e.id))]}),i.data&&d.length===0&&!a&&(0,Q.jsx)(`p`,{className:`memory-empty`,children:`暂无记忆`})]})]})}function We({id:e,card:t,reload:n,onDone:r,onEditing:i}){let{request:a}=H(),[o,s]=(0,Y.useState)(!t),[l,u]=(0,Y.useState)(t?.text??``),[d,f]=(0,Y.useState)(t?.revision),[p,m]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(!1),_=F(),v=(0,Y.useRef)(!1),x=(0,Y.useRef)(!1),S=(0,Y.useRef)(!1);function C(){S.current=!1,i?.(!0),u(t?.text??``),f(t?.revision),v.current=!1,g(!1),_(``),s(!0)}function w(){S.current=!0,s(!1),_(``),g(!1),i?.(!1),r?.()}async function E(u){if(!x.current){if(!u&&t&&l===t.text)s(!1),i?.(!1);else if((!u||u===`keep`)&&!$.safeParse(o?l:t?.text).success)g(!0);else{x.current=!0,m(!0),v.current=!1,g(!1),_(``);try{t?await a(`memory/${e}`,y({saved:T()}),{method:`PATCH`,body:{expectedRevision:o?d:t.revision,...u?{action:u}:{},...o&&u!==`discard`&&u!==`delete`?{text:l}:{}}}):await a(`memory`,Ve,{method:`POST`,body:{id:e,text:l}}),s(!1),await n(),i?.(!1),r?.()}catch(e){v.current=!0,_(c(e)),await n()}finally{x.current=!1,m(!1)}}}}return(0,Q.jsxs)(`article`,{className:`memory-card`,"data-testid":`memory-card`,"data-memory-id":e,children:[(0,Q.jsx)(`span`,{className:`memory-status ${t?.state===`kept`?`is-kept`:``}`,role:`img`,"aria-label":t?.state===`kept`?`已保留`:`待确认`,children:(0,Q.jsx)(b,{name:t?.state===`kept`?`check`:`question`})}),(0,Q.jsxs)(`div`,{className:`memory-content`,children:[o?(0,Q.jsx)(`textarea`,{autoFocus:!0,"aria-label":`记忆内容`,"aria-invalid":h||void 0,"aria-describedby":h?`memory-error-${e}`:void 0,value:l,rows:2,disabled:p,onChange:e=>{u(e.target.value),g(!1)},onBlur:e=>{S.current?S.current=!1:e.relatedTarget instanceof Element&&e.relatedTarget.closest(`.memory-actions`)||!h&&!v.current&&E()},onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Escape`&&(e.preventDefault(),w()),e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),E()))}}):(0,Q.jsx)(`button`,{type:`button`,className:`memory-text`,"aria-label":`编辑记忆:${t?.text??``}`,onClick:C,children:t?.text}),h&&(0,Q.jsx)(`small`,{id:`memory-error-${e}`,className:`error-detail`,children:`请填写记忆内容。`})]}),(0,Q.jsxs)(`div`,{className:`memory-actions`,onMouseDown:e=>{o&&e.preventDefault()},children:[(!t||t.state===`draft`)&&(0,Q.jsx)(D,{icon:`check`,label:t?`保留记忆`:`保存记忆`,disabled:p,onClick:()=>void E(t?`keep`:void 0)}),o&&t?.state===`kept`&&(0,Q.jsx)(D,{icon:`check`,label:`保存记忆`,disabled:p,onClick:()=>void E()}),(0,Q.jsx)(D,{icon:`close`,label:t?t.state===`draft`?`舍弃记忆`:`删除记忆`:`取消新增`,disabled:p,onClick:()=>{t?E(t.state===`draft`?`discard`:`delete`):w()}})]})]})}function Ge({section:e,members:t,navigate:r}){let{projectId:i}=H(),[a,o]=(0,Y.useState)(e===`sessions`);(0,Y.useEffect)(()=>{e===`sessions`&&o(!0)},[e]);let s=t=>{e!==t&&r(`/projects/${i}/${t}`)};return(0,Q.jsx)(pe,{active:e===`materials`,onActivate:()=>s(`materials`),children:i=>(0,Q.jsx)(Le,{members:t,active:e===`sessions`,onActivate:()=>s(`sessions`),children:t=>(0,Q.jsx)(B,{reading:!0,className:`resource-library`,"data-testid":`materials-page`,label:`资料目录`,navigation:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(V,{title:`资料`,children:i.actions}),(0,Q.jsxs)(`div`,{role:`tree`,"aria-label":`项目资料`,onKeyDown:J,style:{"--tree-level":1},children:[(0,Q.jsxs)(U,{role:`treeitem`,"aria-level":1,"aria-selected":e===`memory`,className:`tree-item tree-folder`,"data-testid":`library-memory`,leading:(0,Q.jsx)(`span`,{className:`tree-chevron`}),onClick:()=>s(`memory`),children:[(0,Q.jsx)(b,{name:`files`}),(0,Q.jsx)(`span`,{className:`tree-name`,children:`记忆`})]}),(0,Q.jsxs)(U,{role:`treeitem`,"aria-level":1,"aria-expanded":a,"aria-selected":e===`sessions`&&!t.hasSelection,className:`tree-item tree-folder`,"data-testid":`library-sessions`,leading:(0,Q.jsx)(`span`,{className:`tree-chevron ${a?`expanded`:``}`,children:(0,Q.jsx)(b,{name:`chevron`,size:`small`})}),onClick:()=>{o(!a),e!==`sessions`&&r(t.href)},children:[(0,Q.jsx)(b,{name:`files`}),(0,Q.jsx)(`span`,{className:`tree-name`,children:`会话库`})]}),(0,Q.jsx)(`div`,{hidden:!a,children:(0,Q.jsx)(n,{visible:a,children:t.tree})}),i.tree]})]}),children:e===`materials`?i.reader:e===`sessions`?t.reader:(0,Q.jsx)(Ue,{})})})})}export{Ge as ResourceLibrary};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{At as e,I as t,M as n,T as r,c as i,d as a,l as o,t as s,w as c}from"./Dropdown-DGFI68Vd.js";import{F as l}from"./index-mhJ33-bH.js";import{a as u}from"./Markdown-CXnZDm5J.js";import{t as d}from"./Computers-CaCzZeCc.js";var f=e(),p=Object.defineProperty,m=Object.getOwnPropertyDescriptor,h=(e,t)=>{for(var n in t)p(e,n,{get:t[n],enumerable:!0})},g=(e,t,n,r)=>{for(var i=r>1?void 0:r?m(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&p(t,n,i),i},_=(e,t)=>(n,r)=>t(n,r,e),v=`Terminal input`,ee={get:()=>v,set:e=>v=e},te=`Too much output to announce, navigate to rows manually to read`,ne={get:()=>te,set:e=>te=e};function re(e){return e.replace(/\r?\n/g,`\r`)}function y(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function ie(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function ae(e,t,n,r){e.stopPropagation(),e.clipboardData&&oe(e.clipboardData.getData(`text/plain`),t,n,r)}function oe(e,t,n,r){e=re(e),e=y(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function b(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function se(e,t,n,r,i){b(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function x(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function ce(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var le=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o)}else i!==65279&&(t[r++]=i)}return r}},ue=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128||(c=(i&31)<<6|a&63,c<128)){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},S=``,de=` `,fe=class e{constructor(){this.fg=0,this.bg=0,this.extended=new C}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},C=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},w=class e extends fe{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new C,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?x(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},pe=`di$target`,me=`di$dependencies`,he=new Map;function ge(e){return e[me]||[]}function T(e){if(he.has(e))return he.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);_e(t,e,r)};return t._id=e,he.set(e,t),t}function _e(e,t,n){t[pe]===t?t[me].push({id:e,index:n}):(t[me]=[{id:e,index:n}],t[pe]=t)}var E=T(`BufferService`),ve=T(`CoreMouseService`),D=T(`CoreService`),ye=T(`CharsetService`),be=T(`InstantiationService`),xe=T(`LogService`),O=T(`OptionsService`),Se=T(`OscLinkService`),Ce=T(`UnicodeService`),we=T(`DecorationService`),Te=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new w,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Ee(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};Te=g([_(0,E),_(1,O),_(2,Se)],Te);function Ee(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
2
2
|
|
|
3
3
|
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var De=T(`CharSizeService`),Oe=T(`CoreBrowserService`),ke=T(`MouseService`),Ae=T(`RenderService`),je=T(`SelectionService`),Me=T(`CharacterJoinerService`),Ne=T(`ThemeService`),Pe=T(`LinkProviderService`),Fe=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Ve.isErrorNoTelemetry(e)?new Ve(e.message+`
|
|
4
4
|
|
|
@@ -19,4 +19,4 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
|
|
|
19
19
|
|
|
20
20
|
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function bs(e){Ss(e)||ys.onUnexpectedError(e)}var xs=`Canceled`;function Ss(e){return e instanceof Cs||e instanceof Error&&e.name===xs&&e.message===xs}var Cs=class extends Error{constructor(){super(xs),this.name=this.message}},ws=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}},Ts;(e=>{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Ts||={});var Es=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>!t(n)||e(n)))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>!e(n)||(t=n,!1)),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||Ts.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};Es.empty=new Es(e=>{});function Ds(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var Os;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);t<n;t++)yield e[t]}e.slice=_;function v(t,n=1/0){let r=[];if(n===0)return[r,t];let i=t[Symbol.iterator]();for(let t=0;t<n;t++){let t=i.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator](){return i}}]}e.consume=v;async function ee(e){let t=[];for await(let n of e)t.push(n);return Promise.resolve(t)}e.asyncToArray=ee})(Os||={});var ks=null;function As(e){return ks?.trackDisposable(e),e}function js(e){ks?.markAsDisposed(e)}function Ms(e,t){ks?.setParent(e,t)}function Ns(e){if(Os.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function Ps(...e){return Fs(()=>Ns(e))}function Fs(e){let t=As({dispose:Ds(()=>{js(t),e()})});return t}var Is=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,As(this)}dispose(){this._isDisposed||(js(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Ns(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return Ms(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),Ms(e,null))}};Is.DISABLE_DISPOSED_WARNING=!1;var Ls=Is,Rs=class{constructor(){this._store=new Ls,As(this),Ms(this._store,this)}dispose(){js(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};Rs.None=Object.freeze({dispose(){}});var zs=class{constructor(){this._isDisposed=!1,As(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&Ms(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,js(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&Ms(e,null),e}},Bs=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};Bs.Undefined=new Bs(void 0);var Vs=globalThis.performance&&typeof globalThis.performance.now==`function`,Hs=class e{static create(t){return new e(t)}constructor(e){this._now=Vs&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime===-1?this._now()-this._startTime:this._stopTime-this._startTime}},Us;(e=>{e.None=()=>Rs.None;function t(e,t){return d(e,()=>{},0,void 0,!0,void 0,t)}e.defer=t;function n(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=n;function r(e,t,n){return l((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=r;function i(e,t,n){return l((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=i;function a(e,t,n){return l((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=a;function o(e){return e}e.signal=o;function s(...e){return(t,n=null,r)=>u(Ps(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=s;function c(e,t,n,i){let a=n;return r(e,e=>(a=t(a,e),a),i)}e.reduce=c;function l(e,t){let n,r=new tc({onWillAddFirstListener(){n=e(r.fire,r)},onDidRemoveLastListener(){n?.dispose()}});return t?.add(r),r.event}function u(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function d(e,t,n=100,r=!1,i=!1,a,o){let s,c,l,u=0,d,f=new tc({leakWarningThreshold:a,onWillAddFirstListener(){s=e(e=>{u++,c=t(c,e),r&&!l&&(f.fire(c),c=void 0),d=()=>{let e=c;c=void 0,l=void 0,(!r||u>1)&&f.fire(e),u=0},typeof n==`number`?(clearTimeout(l),l=setTimeout(d,n)):l===void 0&&(l=0,queueMicrotask(d))})},onWillRemoveListener(){i&&u>0&&d?.()},onDidRemoveLastListener(){d=void 0,s.dispose()}});return o?.add(f),f.event}e.debounce=d;function f(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=f;function p(e,t=(e,t)=>e===t,n){let r=!0,i;return a(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=p;function m(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=m;function h(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new tc({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=h;function g(e,t){return(n,r,i)=>{let a=t(new v);return e(function(e){let t=a.evaluate(e);t!==_&&n.call(r,t)},void 0,i)}}e.chain=g;let _=Symbol(`HaltChainable`);class v{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:_),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:_}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===_)break;return e}}function ee(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new tc({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=ee;function te(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new tc({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=te;function ne(e){return new Promise(t=>n(e)(t))}e.toPromise=ne;function re(e){let t=new tc;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=re;function y(e,t){return e(e=>t.fire(e))}e.forward=y;function ie(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=ie;class ae{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let n={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new tc(n),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function oe(e,t){return new ae(e,t).emitter.event}e.fromObservable=oe;function b(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof Ls?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=b})(Us||={});var Ws=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new Hs,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};Ws.all=new Set,Ws._idPool=0;var Gs=Ws,Ks=-1,qs=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t<n)return;this._stacks||=new Map;let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),--this._warnCountdown,this._warnCountdown<=0){this._warnCountdown=n*.5;let[e,r]=this.getMostFrequentStack(),i=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(i),console.warn(e);let a=new Xs(i,e);this._errorHandler(a)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t<r)&&(e=[n,r],t=r);return e}};qs._idPool=1;var Js=qs,Ys=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??``)}print(){console.warn(this.value.split(`
|
|
21
21
|
`).slice(2).join(`
|
|
22
|
-
`))}},Xs=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},Zs=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},Qs=0,$s=class{constructor(e){this.value=e,this.id=Qs++}},ec=2,tc=class{constructor(e){this._size=0,this._options=e,this._leakageMon=Ks>0||this._options?.leakWarningThreshold?new Js(e?.onListenerError??bs,this._options?.leakWarningThreshold??Ks):void 0,this._perfMon=this._options?._profName?new Gs(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new Zs(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||bs)(n),Rs.None}if(this._disposed)return Rs.None;t&&(e=e.bind(t));let r=new $s(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Ys.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof $s?(this._deliveryQueue??=new nc,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=Fs(()=>{i?.(),this._removeListener(r)});return n instanceof Ls?n.add(a):Array.isArray(n)&&n.push(a),a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*ec<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||bs;if(!n)e.value(t);else try{e.value(t)}catch(e){n(e)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners){if(this._listeners instanceof $s)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}}this._perfMon?.stop()}hasListeners(){return this._size>0}},nc=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},rc=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),ic;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof ac?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Us.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:rc})})(ic||={});var ac=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?rc:(this._emitter||=new tc,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},oc=`en`,sc=!1,cc=!1,lc=oc,uc,dc=globalThis,fc;typeof dc.vscode<`u`&&typeof dc.vscode.process<`u`?fc=dc.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(fc=process);var pc=typeof fc?.versions?.electron==`string`&&fc?.type===`renderer`;if(typeof fc==`object`){fc.platform,fc.platform,sc=fc.platform===`linux`,sc&&fc.env.SNAP&&fc.env.SNAP_REVISION,fc.env.CI||fc.env.BUILD_ARTIFACTSTAGINGDIRECTORY,lc=oc;let e=fc.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,lc=t.resolvedLanguage||oc,t.languagePack?.translationsConfigFile}catch{}}else typeof navigator==`object`&&!pc?(uc=navigator.userAgent,uc.indexOf(`Windows`),uc.indexOf(`Macintosh`),(uc.indexOf(`Macintosh`)>=0||uc.indexOf(`iPad`)>=0||uc.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,sc=uc.indexOf(`Linux`)>=0,uc?.indexOf(`Mobi`),cc=!0,lc=globalThis._VSCODE_NLS_LANGUAGE||oc,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);cc&&typeof dc.importScripts==`function`&&dc.origin;var mc=uc,hc=lc,gc;(e=>{function t(){return hc}e.value=t;function n(){return hc.length===2?hc===`en`:hc.length>=3&&hc[0]===`e`&&hc[1]===`n`&&hc[2]===`-`}e.isDefaultVariant=n;function r(){return hc===`en`}e.isDefault=r})(gc||={});var _c=typeof dc.postMessage==`function`&&!dc.importScripts;(()=>{if(_c){let e=[];dc.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),dc.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var vc=!!(mc&&mc.indexOf(`Chrome`)>=0);mc&&mc.indexOf(`Firefox`),!vc&&mc&&mc.indexOf(`Safari`),mc&&mc.indexOf(`Edg/`),mc&&mc.indexOf(`Android`);function yc(e,t=0,n){let r=setTimeout(()=>{e(),n&&i.dispose()},t),i=Fs(()=>{clearTimeout(r),n?.deleteAndLeak(i)});return n?.add(i),i}(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var bc;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(bc||={});var xc=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new tc,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await Us.toPromise(this._onStateChanged.event)}while(1)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};xc.EMPTY=xc.fromArray([]);var Sc=class extends Rs{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new zs),this._linesCacheDisposables=this._register(new zs),this._register(Fs(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=Ps(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=yc(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){return this._linesCache?.[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){let n=[],r=[0],i=this._terminal.buffer.active.getLine(e);for(;i;){let a=this._terminal.buffer.active.getLine(e+1),o=a?a.isWrapped:!1,s=i.translateToString(!o&&t);if(o&&a){let e=i.getCell(i.length-1);e&&e.getCode()===0&&e.getWidth()===1&&a.getCell(0)?.getWidth()===2&&(s=s.slice(0,-1))}if(n.push(s),o)r.push(r[r.length-1]+s.length);else break;e++,i=a}return[n.join(``),r]}},Cc=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return this._lastSearchOptions?e?this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord:!1:!0}shouldUpdateHighlighting(e,t){return t?.decorations?this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||this.didOptionsChange(t):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},wc=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,n,r){if(!e||e.length===0){this._terminal.clearSelection();return}if(n>this._terminal.cols)throw Error(`Invalid col: ${n} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let i={startRow:t,startCol:n},a=this._findInLine(e,i,r);if(!a)for(let n=t+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(i.startRow=n,i.startCol=0,a=this._findInLine(e,i,r),!a);n++);return a}findNextWithSelection(e,t,n){if(!e||e.length===0){this._terminal.clearSelection();return}let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let i=0,a=0;r&&(n===e?(i=r.end.x,a=r.end.y):(i=r.start.x,a=r.start.y)),this._lineCache.initLinesCache();let o={startRow:a,startCol:i},s=this._findInLine(e,o,t);if(!s)for(let n=a+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(o.startRow=n,o.startCol=0,s=this._findInLine(e,o,t),!s);n++);if(!s&&a!==0)for(let n=0;n<a&&(o.startRow=n,o.startCol=0,s=this._findInLine(e,o,t),!s);n++);return!s&&r&&(o.startRow=r.start.y,o.startCol=0,s=this._findInLine(e,o,t)),s}findPreviousWithSelection(e,t,n){if(!e||e.length===0){this._terminal.clearSelection();return}let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let i=this._terminal.buffer.active.baseY+this._terminal.rows-1,a=this._terminal.cols;this._lineCache.initLinesCache();let o={startRow:i,startCol:a},s;if(r&&(o.startRow=i=r.start.y,o.startCol=a=r.start.x,n!==e&&(s=this._findInLine(e,o,t,!1),s||(o.startRow=i=r.end.y,o.startCol=a=r.end.x))),s||=this._findInLine(e,o,t,!0),!s){o.startCol=Math.max(o.startCol,this._terminal.cols);for(let n=i-1;n>=0&&(o.startRow=n,s=this._findInLine(e,o,t,!0),!s);n--);}if(!s&&i!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let n=this._terminal.buffer.active.baseY+this._terminal.rows-1;n>=i&&(o.startRow=n,s=this._findInLine(e,o,t,!0),!s);n--);return s}_isWholeWord(e,t,n){return(e===0||` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`.includes(t[e-1]))&&(e+n.length===t.length||` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`.includes(t[e+n.length]))}_findInLine(e,t,n={},r=!1){let i=t.startRow,a=t.startCol;if(this._terminal.buffer.active.getLine(i)?.isWrapped){if(r){t.startCol+=this._terminal.cols;return}return t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,n)}let o=this._lineCache.getLineFromCache(i);o||(o=this._lineCache.translateBufferLineToStringWithWrap(i,!0),this._lineCache.setLineInCache(i,o));let[s,c]=o,l=this._bufferColsToStringOffset(i,a),u=e,d=s;n.regex||(u=n.caseSensitive?e:e.toLowerCase(),d=n.caseSensitive?s:s.toLowerCase());let f=-1;if(n.regex){let t=RegExp(u,n.caseSensitive?`g`:`gi`),i;if(r)for(;i=t.exec(d.slice(0,l));)f=t.lastIndex-i[0].length,e=i[0],t.lastIndex-=e.length-1;else i=t.exec(d.slice(l)),i&&i[0].length>0&&(f=l+(t.lastIndex-i[0].length),e=i[0])}else r?l-u.length>=0&&(f=d.lastIndexOf(u,l-u.length)):f=d.indexOf(u,l);if(f>=0){if(n.wholeWord&&!this._isWholeWord(f,d,e))return;let t=0;for(;t<c.length-1&&f>=c[t+1];)t++;let r=t;for(;r<c.length-1&&f+e.length>=c[r+1];)r++;let a=f-c[t],o=f+e.length-c[r],s=this._stringLengthToBufferSize(i+t,a),l=this._stringLengthToBufferSize(i+r,o)-s+this._terminal.cols*(r-t);return{term:e,col:s,row:i+t,size:l}}}_stringLengthToBufferSize(e,t){let n=this._terminal.buffer.active.getLine(e);if(!n)return 0;for(let e=0;e<t;e++){let r=n.getCell(e);if(!r)break;let i=r.getChars();i.length>1&&(t-=i.length-1);let a=n.getCell(e+1);a&&a.getWidth()===0&&t++}return t}_bufferColsToStringOffset(e,t){let n=e,r=0,i=this._terminal.buffer.active.getLine(n);for(;t>0&&i;){for(let e=0;e<t&&e<this._terminal.cols;e++){let t=i.getCell(e);if(!t)break;t.getWidth()&&(r+=t.getCode()===0?1:t.getChars().length)}if(n++,i=this._terminal.buffer.active.getLine(n),i&&!i.isWrapped)break;t-=this._terminal.cols}return r}},Tc=class extends Rs{constructor(e){super(),this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(Fs(()=>this.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let n of e){let e=this._createResultDecorations(n,t,!1);if(e)for(let t of e)this._storeDecoration(t,n)}}createActiveDecoration(e,t){let n=this._createResultDecorations(e,t,!0);if(n)return{decorations:n,match:e,dispose(){Ns(n)}}}clearHighlightDecorations(){Ns(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,n){e.classList.contains(`xterm-find-result-decoration`)||(e.classList.add(`xterm-find-result-decoration`),t&&(e.style.outline=`1px solid ${t}`)),n&&e.classList.add(`xterm-find-active-result-decoration`)}_createResultDecorations(e,t,n){let r=[],i=e.col,a=e.size,o=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;a>0;){let e=Math.min(this._terminal.cols-i,a);r.push([o,i,e]),i=0,a-=e,o++}let s=[];for(let e of r){let r=this._terminal.registerMarker(e[0]),i=this._terminal.registerDecoration({marker:r,x:e[1],width:e[2],backgroundColor:n?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(r.line)?void 0:{color:n?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:`center`}});if(i){let e=[];e.push(r),e.push(i.onRender(e=>this._applyStyles(e,n?t.activeMatchBorder:t.matchBorder,!1))),e.push(i.onDispose(()=>Ns(e))),s.push(i)}}return s.length===0?void 0:s}},Ec=class extends Rs{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new tc)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&=(this._selectedDecoration.dispose(),void 0)}findResultIndex(e){for(let t=0;t<this._searchResults.length;t++){let n=this._searchResults[t];if(n.row===e.row&&n.col===e.col&&n.size===e.size)return t}return-1}fireResultsChanged(e){if(!e)return;let t=-1;this._selectedDecoration&&(t=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:t,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},Dc=class extends Rs{constructor(e){super(),this._highlightTimeout=this._register(new zs),this._lineCache=this._register(new zs),this._state=new Cc,this._resultTracker=this._register(new Ec),this._highlightLimit=e?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new Sc(e),this._engine=new wc(e,this._lineCache.value),this._decorationManager=new Tc(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(Fs(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=yc(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,n){if(!this._terminal||!this._engine)throw Error(`Cannot use addon until it has been loaded`);this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findNextAndSelect(e,t,n);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw Error(`Cannot use addon until it has been loaded`);if(!this._state.isValidSearchTerm(e)){this.clearDecorations();return}this.clearDecorations(!0);let n=[],r,i=this._engine.find(e,0,0,t);for(;i&&(r?.row!==i.row||r?.col!==i.col)&&!(n.length>=this._highlightLimit);)r=i,n.push(r),i=this._engine.find(e,r.col+r.term.length>=this._terminal.cols?r.row+1:r.row,r.col+r.term.length>=this._terminal.cols?0:r.col+1,t);this._resultTracker.updateResults(n,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(n,t.decorations)}_findNextAndSelect(e,t,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,t?.decorations,n?.noScroll)}findPrevious(e,t,n){if(!this._terminal||!this._engine)throw Error(`Cannot use addon until it has been loaded`);this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findPreviousAndSelect(e,t,n);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_fireResults(e){this._resultTracker.fireResultsChanged(!!e?.decorations)}_findPreviousAndSelect(e,t,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,t?.decorations,n?.noScroll)}_selectResult(e,t,n){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let n=this._decorationManager.createActiveDecoration(e,t);n&&(this._resultTracker.selectedDecoration=n)}if(!n&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.row<this._terminal.buffer.active.viewportY)){let t=e.row-this._terminal.buffer.active.viewportY;t-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(t)}return!0}},Oc=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=Ac.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e))}};function kc(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var Ac=class e{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||``)+`g`),[o,s]=e._getWindowedLineStrings(t-1,r),c=o.join(``),l,u=[];for(;l=a.exec(c);){let t=l[0];if(!kc(t))continue;let[n,a]=e._mapStrIdx(r,s,0,l.index),[o,c]=e._mapStrIdx(r,n,a,t.length);if(n===-1||a===-1||o===-1||c===-1)continue;let d={start:{x:a+1,y:n+1},end:{x:c,y:o+1}};u.push({range:d,text:t,activate:i})}return u}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),n.isWrapped&&o.indexOf(` `)===-1););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n<e.length;++n){e.getCell(n,a);let o=a.getChars();if(a.getWidth()&&(r-=o.length||1,n===e.length-1&&o===``)){let e=i.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[t,n]}t++,o=0}return[t,o]}},jc=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Mc(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}var Nc=class{constructor(e=Mc,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||jc;this._linkProvider=this._terminal.registerLinkProvider(new Oc(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}};function Pc(e,t){return{provideLinks(n,r){let i=e.buffer.active,a=n-1,o=a;for(;a>0&&i.getLine(a)?.isWrapped;)a--;for(;i.getLine(o+1)?.isWrapped;)o++;let s=[],c=i.getNullCell(),l=``;for(let t=a;t<=o;t++){let n=i.getLine(t);if(!n)break;let r=Math.min(e.cols,n.length);for(let e=0;e<r;e++){n.getCell(e,c);let a=c.getWidth();if(!a)continue;let u=c.getChars();if(!u&&e===r-1&&t<o&&i.getLine(t+1)?.getCell(0)?.getWidth()===2)continue;let d=u||` `,f={start:{x:e+1,y:t+1},end:{x:e+a,y:t+1}};for(let e=0;e<d.length;e++)s.push(f);l+=d}}r(u(l).map(({start:e,end:n,link:r})=>({text:l.slice(e,n),range:{start:s[e].start,end:s[n-1].end},activate(e){(e.metaKey||e.ctrlKey)&&t(r)}})))}}}var $=i();function Fc(){let e=document.querySelector(`meta[name="teammy-style-nonce"]`)?.content;return new Proxy(document,{get(t,n){if(n===`createElement`)return(n,r)=>{let i=t.createElement(n,r);n===`style`&&e&&i.setAttribute(`nonce`,e);let a=i.appendChild;return i.appendChild=function(t){return t instanceof HTMLStyleElement&&e&&(t.nonce=e),a.call(this,t)},i};let r=Reflect.get(t,n,t);return typeof r==`function`?r.bind(t):r}})}function Ic({terminal:i,connection:a,onClosed:u,onFile:p}){let m=(0,f.useRef)(null),h=(0,f.useRef)(null),g=(0,f.useRef)(null),_=(0,f.useRef)(null),v=(0,f.useRef)(!1),ee=(0,f.useRef)(i);ee.current=i;let te=(0,f.useRef)(p);te.current=p;let[ne,re]=(0,f.useState)(!1),y=e(),[ie,ae]=(0,f.useState)(!1),[oe,b]=(0,f.useState)(``),[se,x]=(0,f.useState)(!1),[ce,le]=(0,f.useState)(!1),{send:ue,subscribe:S,request:de}=a,fe=a.connected&&a.directories.includes(i.directory),C=a.terminals.some(e=>e.id===i.id),w=(0,f.useRef)(()=>{});(0,f.useEffect)(()=>{let e={id:i.id,directory:i.directory},n=new hs({documentOverride:Fc(),cursorBlink:!0,cursorStyle:`bar`,fontSize:13,lineHeight:1.3,fontFamily:`"SFMono-Regular", Consolas, "Liberation Mono", monospace`,scrollback:2e3,allowProposedApi:!0,disableStdin:!0,theme:{background:`#faf9f7`,foreground:`#343434`,cursor:`#b75930`,selectionBackground:`#dedbd5`,black:`#30343b`,red:`#ac3737`,green:`#52733b`,yellow:`#967124`,blue:`#3f649c`,magenta:`#855092`,cyan:`#347b83`,white:`#b2b0ac`,brightBlack:`#737373`,brightRed:`#c74747`,brightGreen:`#5d833c`,brightYellow:`#9e7529`,brightBlue:`#547fbd`,brightMagenta:`#9861a5`,brightCyan:`#488f98`,brightWhite:`#dedbd5`}}),r=new vs,a=new Dc;n.loadAddon(r),n.loadAddon(a),n.loadAddon(new Nc((e,t)=>{(e.metaKey||e.ctrlKey)&&/^https?:\/\//i.test(t)&&window.open(t,`_blank`,`noopener,noreferrer`)})),n.registerLinkProvider(Pc(n,e=>te.current(e)));for(let e of[`c`,`n`]){n.parser.registerCsiHandler({final:e},()=>!0);for(let t of[`?`,`>`,`=`])n.parser.registerCsiHandler({prefix:t,final:e},()=>!0)}n.parser.registerCsiHandler({prefix:`>`,final:`q`},()=>!0),n.parser.registerCsiHandler({intermediates:`$`,final:`p`},()=>!0),n.parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},()=>!0),n.parser.registerDcsHandler({intermediates:`$`,final:`q`},()=>!0);for(let e of[4,10,11,12])n.parser.registerOscHandler(e,e=>e.includes(`?`));n.open(m.current),h.current=n,g.current=r,_.current=a;let o=-1,s=!1,l=e=>{try{ue(e)}catch(e){y(t(e))}};w.current=()=>{m.current?.clientWidth&&m.current.clientHeight&&!document.hidden&&(r.fit(),v.current&&ee.current.state===`running`&&l({...e,type:`resize`,cols:n.cols,rows:n.rows}))};let u=new ResizeObserver(()=>w.current());u.observe(m.current);let d=()=>{document.hidden||w.current()};document.addEventListener(`visibilitychange`,d);let f=S(t=>{if(`id`in t&&t.id===e.id){if(t.type===`snapshot`)v.current=!0,o=t.seq,n.reset(),n.resize(t.cols,t.rows),n.write(t.data,()=>{s||(n.options.disableStdin=ee.current.state!==`running`,re(!0),y(``),w.current(),n.focus())});else if(t.type===`size`)n.resize(t.cols,t.rows);else if(t.type===`output`){if(!v.current||t.seq<=o)return;if(t.seq!==o+1){v.current=!1,l({...e,type:`attach`});return}o=t.seq,n.write(t.data)}else t.type===`result`&&t.error&&y(t.error)}}),p=n.onData(t=>{if(!v.current||ee.current.state!==`running`)return;let n=t.match(/[\s\S]{1,16000}/gu)??[];for(let t of n)l({...e,type:`input`,data:t})});return n.attachCustomKeyEventHandler(e=>e.type===`keydown`&&(e.metaKey||e.ctrlKey&&e.shiftKey)&&e.key.toLowerCase()===`c`&&n.hasSelection()?(y(``),c(n.getSelection()).catch(()=>y(`未能复制所选终端内容,请重试。`)),!1):!0),()=>{s=!0,v.current=!1;try{ue({...e,type:`detach`})}catch{}f(),p.dispose(),u.disconnect(),document.removeEventListener(`visibilitychange`,d),n.dispose(),h.current=null,g.current=null,_.current=null}},[i.id,i.directory,ue,S,y]),(0,f.useEffect)(()=>{if(v.current=!1,re(!1),h.current&&(h.current.options.disableStdin=!0),fe&&C)try{ue({type:`attach`,id:i.id,directory:i.directory})}catch(e){y(t(e))}},[fe,C,i.id,i.directory,ue,y]),(0,f.useEffect)(()=>{h.current&&(h.current.options.disableStdin=!ne||i.state!==`running`)},[ne,i.state]);async function pe(e,n){le(!0),y(``);try{await de(e===`rename`?{type:e,id:i.id,directory:i.directory,title:n}:{type:e,id:i.id,directory:i.directory}),e===`close`&&u()}catch(e){y(t(e))}finally{le(!1),x(!1)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(l,{title:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(d,{title:i.title,busy:ce||!fe,onSave:e=>pe(`rename`,e)}),(0,$.jsxs)(`p`,{className:`terminal-location`,title:i.cwd,children:[`执行位置:`,i.cwd]})]}),actions:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(o,{icon:`search`,label:`查找终端内容`,onClick:()=>ae(!ie)}),(0,$.jsx)(s,{id:`terminal-menu`,routeKey:i.id,triggerId:`terminal-actions`,label:`终端操作`,trigger:(0,$.jsx)(n,{name:`more`}),className:`computer-create-menu`,children:e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{role:`menuitem`,onClick:()=>{h.current?.clear(),e()},children:`清屏`}),(0,$.jsx)(`button`,{role:`menuitem`,disabled:!fe||!C,onClick:()=>{e(),x(!0)},children:`关闭终端`})]})})]})}),ie&&(0,$.jsxs)(`form`,{className:`terminal-search`,onSubmit:e=>{e.preventDefault(),_.current?.findNext(oe)},children:[(0,$.jsx)(`input`,{autoFocus:!0,"aria-label":`查找终端内容`,placeholder:`查找`,value:oe,onChange:e=>{b(e.target.value),_.current?.findNext(e.target.value)}}),(0,$.jsx)(o,{icon:`close`,label:`关闭查找`,onClick:()=>{ae(!1),_.current?.clearDecorations(),h.current?.focus()}})]}),(0,$.jsx)(`div`,{className:`terminal-surface`,"data-testid":`terminal-pane`,children:(0,$.jsx)(`div`,{className:`terminal-emulator`,ref:m,"aria-label":`交互终端`})}),(!ne||i.state===`exited`||!C)&&(0,$.jsx)(`p`,{className:`terminal-status`,role:`status`,children:fe?C?i.state===`exited`?`进程已退出 · ${i.exitCode??0}`:`正在连接…`:`终端已结束,请新建终端。`:`连接已断开,正在重连…`}),se&&(0,$.jsxs)(r,{id:`terminal-close`,title:`关闭终端`,onClose:()=>x(!1),children:[(0,$.jsx)(`p`,{children:`结束此终端及其中运行的进程?`}),(0,$.jsxs)(`div`,{className:`actions`,children:[(0,$.jsx)(`button`,{onClick:()=>x(!1),children:`取消`}),(0,$.jsx)(`button`,{className:`primary`,disabled:ce,onClick:()=>void pe(`close`),children:`关闭终端`})]})]})]})}export{Ic as default};
|
|
22
|
+
`))}},Xs=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},Zs=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},Qs=0,$s=class{constructor(e){this.value=e,this.id=Qs++}},ec=2,tc=class{constructor(e){this._size=0,this._options=e,this._leakageMon=Ks>0||this._options?.leakWarningThreshold?new Js(e?.onListenerError??bs,this._options?.leakWarningThreshold??Ks):void 0,this._perfMon=this._options?._profName?new Gs(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new Zs(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||bs)(n),Rs.None}if(this._disposed)return Rs.None;t&&(e=e.bind(t));let r=new $s(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Ys.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof $s?(this._deliveryQueue??=new nc,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=Fs(()=>{i?.(),this._removeListener(r)});return n instanceof Ls?n.add(a):Array.isArray(n)&&n.push(a),a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*ec<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||bs;if(!n)e.value(t);else try{e.value(t)}catch(e){n(e)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners){if(this._listeners instanceof $s)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}}this._perfMon?.stop()}hasListeners(){return this._size>0}},nc=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},rc=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),ic;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof ac?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Us.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:rc})})(ic||={});var ac=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?rc:(this._emitter||=new tc,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},oc=`en`,sc=!1,cc=!1,lc=oc,uc,dc=globalThis,fc;typeof dc.vscode<`u`&&typeof dc.vscode.process<`u`?fc=dc.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(fc=process);var pc=typeof fc?.versions?.electron==`string`&&fc?.type===`renderer`;if(typeof fc==`object`){fc.platform,fc.platform,sc=fc.platform===`linux`,sc&&fc.env.SNAP&&fc.env.SNAP_REVISION,fc.env.CI||fc.env.BUILD_ARTIFACTSTAGINGDIRECTORY,lc=oc;let e=fc.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,lc=t.resolvedLanguage||oc,t.languagePack?.translationsConfigFile}catch{}}else typeof navigator==`object`&&!pc?(uc=navigator.userAgent,uc.indexOf(`Windows`),uc.indexOf(`Macintosh`),(uc.indexOf(`Macintosh`)>=0||uc.indexOf(`iPad`)>=0||uc.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,sc=uc.indexOf(`Linux`)>=0,uc?.indexOf(`Mobi`),cc=!0,lc=globalThis._VSCODE_NLS_LANGUAGE||oc,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);cc&&typeof dc.importScripts==`function`&&dc.origin;var mc=uc,hc=lc,gc;(e=>{function t(){return hc}e.value=t;function n(){return hc.length===2?hc===`en`:hc.length>=3&&hc[0]===`e`&&hc[1]===`n`&&hc[2]===`-`}e.isDefaultVariant=n;function r(){return hc===`en`}e.isDefault=r})(gc||={});var _c=typeof dc.postMessage==`function`&&!dc.importScripts;(()=>{if(_c){let e=[];dc.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),dc.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var vc=!!(mc&&mc.indexOf(`Chrome`)>=0);mc&&mc.indexOf(`Firefox`),!vc&&mc&&mc.indexOf(`Safari`),mc&&mc.indexOf(`Edg/`),mc&&mc.indexOf(`Android`);function yc(e,t=0,n){let r=setTimeout(()=>{e(),n&&i.dispose()},t),i=Fs(()=>{clearTimeout(r),n?.deleteAndLeak(i)});return n?.add(i),i}(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var bc;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(bc||={});var xc=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new tc,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await Us.toPromise(this._onStateChanged.event)}while(1)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};xc.EMPTY=xc.fromArray([]);var Sc=class extends Rs{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new zs),this._linesCacheDisposables=this._register(new zs),this._register(Fs(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=Ps(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=yc(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){return this._linesCache?.[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){let n=[],r=[0],i=this._terminal.buffer.active.getLine(e);for(;i;){let a=this._terminal.buffer.active.getLine(e+1),o=a?a.isWrapped:!1,s=i.translateToString(!o&&t);if(o&&a){let e=i.getCell(i.length-1);e&&e.getCode()===0&&e.getWidth()===1&&a.getCell(0)?.getWidth()===2&&(s=s.slice(0,-1))}if(n.push(s),o)r.push(r[r.length-1]+s.length);else break;e++,i=a}return[n.join(``),r]}},Cc=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return this._lastSearchOptions?e?this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord:!1:!0}shouldUpdateHighlighting(e,t){return t?.decorations?this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||this.didOptionsChange(t):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},wc=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,n,r){if(!e||e.length===0){this._terminal.clearSelection();return}if(n>this._terminal.cols)throw Error(`Invalid col: ${n} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let i={startRow:t,startCol:n},a=this._findInLine(e,i,r);if(!a)for(let n=t+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(i.startRow=n,i.startCol=0,a=this._findInLine(e,i,r),!a);n++);return a}findNextWithSelection(e,t,n){if(!e||e.length===0){this._terminal.clearSelection();return}let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let i=0,a=0;r&&(n===e?(i=r.end.x,a=r.end.y):(i=r.start.x,a=r.start.y)),this._lineCache.initLinesCache();let o={startRow:a,startCol:i},s=this._findInLine(e,o,t);if(!s)for(let n=a+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(o.startRow=n,o.startCol=0,s=this._findInLine(e,o,t),!s);n++);if(!s&&a!==0)for(let n=0;n<a&&(o.startRow=n,o.startCol=0,s=this._findInLine(e,o,t),!s);n++);return!s&&r&&(o.startRow=r.start.y,o.startCol=0,s=this._findInLine(e,o,t)),s}findPreviousWithSelection(e,t,n){if(!e||e.length===0){this._terminal.clearSelection();return}let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let i=this._terminal.buffer.active.baseY+this._terminal.rows-1,a=this._terminal.cols;this._lineCache.initLinesCache();let o={startRow:i,startCol:a},s;if(r&&(o.startRow=i=r.start.y,o.startCol=a=r.start.x,n!==e&&(s=this._findInLine(e,o,t,!1),s||(o.startRow=i=r.end.y,o.startCol=a=r.end.x))),s||=this._findInLine(e,o,t,!0),!s){o.startCol=Math.max(o.startCol,this._terminal.cols);for(let n=i-1;n>=0&&(o.startRow=n,s=this._findInLine(e,o,t,!0),!s);n--);}if(!s&&i!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let n=this._terminal.buffer.active.baseY+this._terminal.rows-1;n>=i&&(o.startRow=n,s=this._findInLine(e,o,t,!0),!s);n--);return s}_isWholeWord(e,t,n){return(e===0||` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`.includes(t[e-1]))&&(e+n.length===t.length||` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`.includes(t[e+n.length]))}_findInLine(e,t,n={},r=!1){let i=t.startRow,a=t.startCol;if(this._terminal.buffer.active.getLine(i)?.isWrapped){if(r){t.startCol+=this._terminal.cols;return}return t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,n)}let o=this._lineCache.getLineFromCache(i);o||(o=this._lineCache.translateBufferLineToStringWithWrap(i,!0),this._lineCache.setLineInCache(i,o));let[s,c]=o,l=this._bufferColsToStringOffset(i,a),u=e,d=s;n.regex||(u=n.caseSensitive?e:e.toLowerCase(),d=n.caseSensitive?s:s.toLowerCase());let f=-1;if(n.regex){let t=RegExp(u,n.caseSensitive?`g`:`gi`),i;if(r)for(;i=t.exec(d.slice(0,l));)f=t.lastIndex-i[0].length,e=i[0],t.lastIndex-=e.length-1;else i=t.exec(d.slice(l)),i&&i[0].length>0&&(f=l+(t.lastIndex-i[0].length),e=i[0])}else r?l-u.length>=0&&(f=d.lastIndexOf(u,l-u.length)):f=d.indexOf(u,l);if(f>=0){if(n.wholeWord&&!this._isWholeWord(f,d,e))return;let t=0;for(;t<c.length-1&&f>=c[t+1];)t++;let r=t;for(;r<c.length-1&&f+e.length>=c[r+1];)r++;let a=f-c[t],o=f+e.length-c[r],s=this._stringLengthToBufferSize(i+t,a),l=this._stringLengthToBufferSize(i+r,o)-s+this._terminal.cols*(r-t);return{term:e,col:s,row:i+t,size:l}}}_stringLengthToBufferSize(e,t){let n=this._terminal.buffer.active.getLine(e);if(!n)return 0;for(let e=0;e<t;e++){let r=n.getCell(e);if(!r)break;let i=r.getChars();i.length>1&&(t-=i.length-1);let a=n.getCell(e+1);a&&a.getWidth()===0&&t++}return t}_bufferColsToStringOffset(e,t){let n=e,r=0,i=this._terminal.buffer.active.getLine(n);for(;t>0&&i;){for(let e=0;e<t&&e<this._terminal.cols;e++){let t=i.getCell(e);if(!t)break;t.getWidth()&&(r+=t.getCode()===0?1:t.getChars().length)}if(n++,i=this._terminal.buffer.active.getLine(n),i&&!i.isWrapped)break;t-=this._terminal.cols}return r}},Tc=class extends Rs{constructor(e){super(),this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(Fs(()=>this.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let n of e){let e=this._createResultDecorations(n,t,!1);if(e)for(let t of e)this._storeDecoration(t,n)}}createActiveDecoration(e,t){let n=this._createResultDecorations(e,t,!0);if(n)return{decorations:n,match:e,dispose(){Ns(n)}}}clearHighlightDecorations(){Ns(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,n){e.classList.contains(`xterm-find-result-decoration`)||(e.classList.add(`xterm-find-result-decoration`),t&&(e.style.outline=`1px solid ${t}`)),n&&e.classList.add(`xterm-find-active-result-decoration`)}_createResultDecorations(e,t,n){let r=[],i=e.col,a=e.size,o=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;a>0;){let e=Math.min(this._terminal.cols-i,a);r.push([o,i,e]),i=0,a-=e,o++}let s=[];for(let e of r){let r=this._terminal.registerMarker(e[0]),i=this._terminal.registerDecoration({marker:r,x:e[1],width:e[2],backgroundColor:n?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(r.line)?void 0:{color:n?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:`center`}});if(i){let e=[];e.push(r),e.push(i.onRender(e=>this._applyStyles(e,n?t.activeMatchBorder:t.matchBorder,!1))),e.push(i.onDispose(()=>Ns(e))),s.push(i)}}return s.length===0?void 0:s}},Ec=class extends Rs{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new tc)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&=(this._selectedDecoration.dispose(),void 0)}findResultIndex(e){for(let t=0;t<this._searchResults.length;t++){let n=this._searchResults[t];if(n.row===e.row&&n.col===e.col&&n.size===e.size)return t}return-1}fireResultsChanged(e){if(!e)return;let t=-1;this._selectedDecoration&&(t=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:t,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},Dc=class extends Rs{constructor(e){super(),this._highlightTimeout=this._register(new zs),this._lineCache=this._register(new zs),this._state=new Cc,this._resultTracker=this._register(new Ec),this._highlightLimit=e?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new Sc(e),this._engine=new wc(e,this._lineCache.value),this._decorationManager=new Tc(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(Fs(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=yc(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,n){if(!this._terminal||!this._engine)throw Error(`Cannot use addon until it has been loaded`);this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findNextAndSelect(e,t,n);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw Error(`Cannot use addon until it has been loaded`);if(!this._state.isValidSearchTerm(e)){this.clearDecorations();return}this.clearDecorations(!0);let n=[],r,i=this._engine.find(e,0,0,t);for(;i&&(r?.row!==i.row||r?.col!==i.col)&&!(n.length>=this._highlightLimit);)r=i,n.push(r),i=this._engine.find(e,r.col+r.term.length>=this._terminal.cols?r.row+1:r.row,r.col+r.term.length>=this._terminal.cols?0:r.col+1,t);this._resultTracker.updateResults(n,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(n,t.decorations)}_findNextAndSelect(e,t,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,t?.decorations,n?.noScroll)}findPrevious(e,t,n){if(!this._terminal||!this._engine)throw Error(`Cannot use addon until it has been loaded`);this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findPreviousAndSelect(e,t,n);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_fireResults(e){this._resultTracker.fireResultsChanged(!!e?.decorations)}_findPreviousAndSelect(e,t,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,t?.decorations,n?.noScroll)}_selectResult(e,t,n){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let n=this._decorationManager.createActiveDecoration(e,t);n&&(this._resultTracker.selectedDecoration=n)}if(!n&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.row<this._terminal.buffer.active.viewportY)){let t=e.row-this._terminal.buffer.active.viewportY;t-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(t)}return!0}},Oc=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=Ac.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e))}};function kc(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var Ac=class e{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||``)+`g`),[o,s]=e._getWindowedLineStrings(t-1,r),c=o.join(``),l,u=[];for(;l=a.exec(c);){let t=l[0];if(!kc(t))continue;let[n,a]=e._mapStrIdx(r,s,0,l.index),[o,c]=e._mapStrIdx(r,n,a,t.length);if(n===-1||a===-1||o===-1||c===-1)continue;let d={start:{x:a+1,y:n+1},end:{x:c,y:o+1}};u.push({range:d,text:t,activate:i})}return u}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),n.isWrapped&&o.indexOf(` `)===-1););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n<e.length;++n){e.getCell(n,a);let o=a.getChars();if(a.getWidth()&&(r-=o.length||1,n===e.length-1&&o===``)){let e=i.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[t,n]}t++,o=0}return[t,o]}},jc=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Mc(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}var Nc=class{constructor(e=Mc,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||jc;this._linkProvider=this._terminal.registerLinkProvider(new Oc(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}};function Pc(e,t){return{provideLinks(n,r){let i=e.buffer.active,a=n-1,o=a;for(;a>0&&i.getLine(a)?.isWrapped;)a--;for(;i.getLine(o+1)?.isWrapped;)o++;let s=[],c=i.getNullCell(),l=``;for(let t=a;t<=o;t++){let n=i.getLine(t);if(!n)break;let r=Math.min(e.cols,n.length);for(let e=0;e<r;e++){n.getCell(e,c);let a=c.getWidth();if(!a)continue;let u=c.getChars();if(!u&&e===r-1&&t<o&&i.getLine(t+1)?.getCell(0)?.getWidth()===2)continue;let d=u||` `,f={start:{x:e+1,y:t+1},end:{x:e+a,y:t+1}};for(let e=0;e<d.length;e++)s.push(f);l+=d}}r(u(l).map(({start:e,end:n,link:r})=>({text:l.slice(e,n),range:{start:s[e].start,end:s[n-1].end},activate(e){(e.metaKey||e.ctrlKey)&&t(r)}})))}}}var $=n();function Fc(){let e=document.querySelector(`meta[name="teammy-style-nonce"]`)?.content;return new Proxy(document,{get(t,n){if(n===`createElement`)return(n,r)=>{let i=t.createElement(n,r);n===`style`&&e&&i.setAttribute(`nonce`,e);let a=i.appendChild;return i.appendChild=function(t){return t instanceof HTMLStyleElement&&e&&(t.nonce=e),a.call(this,t)},i};let r=Reflect.get(t,n,t);return typeof r==`function`?r.bind(t):r}})}function Ic({terminal:e,connection:n,onClosed:u,onFile:p}){let m=(0,f.useRef)(null),h=(0,f.useRef)(null),g=(0,f.useRef)(null),_=(0,f.useRef)(null),v=(0,f.useRef)(!1),ee=(0,f.useRef)(e);ee.current=e;let te=(0,f.useRef)(p);te.current=p;let[ne,re]=(0,f.useState)(!1),y=c(),[ie,ae]=(0,f.useState)(!1),[oe,b]=(0,f.useState)(``),[se,x]=(0,f.useState)(!1),[ce,le]=(0,f.useState)(!1),{send:ue,subscribe:S,request:de}=n,fe=n.connected&&n.directories.includes(e.directory),C=n.terminals.some(t=>t.id===e.id),w=(0,f.useRef)(()=>{});(0,f.useEffect)(()=>{let n={id:e.id,directory:e.directory},i=new hs({documentOverride:Fc(),cursorBlink:!0,cursorStyle:`bar`,fontSize:13,lineHeight:1.3,fontFamily:`"SFMono-Regular", Consolas, "Liberation Mono", monospace`,scrollback:2e3,allowProposedApi:!0,disableStdin:!0,theme:{background:`#faf9f7`,foreground:`#343434`,cursor:`#b75930`,selectionBackground:`#dedbd5`,black:`#30343b`,red:`#ac3737`,green:`#52733b`,yellow:`#967124`,blue:`#3f649c`,magenta:`#855092`,cyan:`#347b83`,white:`#b2b0ac`,brightBlack:`#737373`,brightRed:`#c74747`,brightGreen:`#5d833c`,brightYellow:`#9e7529`,brightBlue:`#547fbd`,brightMagenta:`#9861a5`,brightCyan:`#488f98`,brightWhite:`#dedbd5`}}),a=new vs,o=new Dc;i.loadAddon(a),i.loadAddon(o),i.loadAddon(new Nc((e,t)=>{(e.metaKey||e.ctrlKey)&&/^https?:\/\//i.test(t)&&window.open(t,`_blank`,`noopener,noreferrer`)})),i.registerLinkProvider(Pc(i,e=>te.current(e)));for(let e of[`c`,`n`]){i.parser.registerCsiHandler({final:e},()=>!0);for(let t of[`?`,`>`,`=`])i.parser.registerCsiHandler({prefix:t,final:e},()=>!0)}i.parser.registerCsiHandler({prefix:`>`,final:`q`},()=>!0),i.parser.registerCsiHandler({intermediates:`$`,final:`p`},()=>!0),i.parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},()=>!0),i.parser.registerDcsHandler({intermediates:`$`,final:`q`},()=>!0);for(let e of[4,10,11,12])i.parser.registerOscHandler(e,e=>e.includes(`?`));i.open(m.current),h.current=i,g.current=a,_.current=o;let s=-1,c=!1,l=e=>{try{ue(e)}catch(e){y(t(e))}};w.current=()=>{m.current?.clientWidth&&m.current.clientHeight&&!document.hidden&&(a.fit(),v.current&&ee.current.state===`running`&&l({...n,type:`resize`,cols:i.cols,rows:i.rows}))};let u=new ResizeObserver(()=>w.current());u.observe(m.current);let d=()=>{document.hidden||w.current()};document.addEventListener(`visibilitychange`,d);let f=S(e=>{if(`id`in e&&e.id===n.id){if(e.type===`snapshot`)v.current=!0,s=e.seq,i.reset(),i.resize(e.cols,e.rows),i.write(e.data,()=>{c||(i.options.disableStdin=ee.current.state!==`running`,re(!0),y(``),w.current(),i.focus())});else if(e.type===`size`)i.resize(e.cols,e.rows);else if(e.type===`output`){if(!v.current||e.seq<=s)return;if(e.seq!==s+1){v.current=!1,l({...n,type:`attach`});return}s=e.seq,i.write(e.data)}else e.type===`result`&&e.error&&y(e.error)}}),p=i.onData(e=>{if(!v.current||ee.current.state!==`running`)return;let t=e.match(/[\s\S]{1,16000}/gu)??[];for(let e of t)l({...n,type:`input`,data:e})});return i.attachCustomKeyEventHandler(e=>e.type===`keydown`&&(e.metaKey||e.ctrlKey&&e.shiftKey)&&e.key.toLowerCase()===`c`&&i.hasSelection()?(y(``),r(i.getSelection()).catch(()=>y(`未能复制所选终端内容,请重试。`)),!1):!0),()=>{c=!0,v.current=!1;try{ue({...n,type:`detach`})}catch{}f(),p.dispose(),u.disconnect(),document.removeEventListener(`visibilitychange`,d),i.dispose(),h.current=null,g.current=null,_.current=null}},[e.id,e.directory,ue,S,y]),(0,f.useEffect)(()=>{if(v.current=!1,re(!1),h.current&&(h.current.options.disableStdin=!0),fe&&C)try{ue({type:`attach`,id:e.id,directory:e.directory})}catch(e){y(t(e))}},[fe,C,e.id,e.directory,ue,y]),(0,f.useEffect)(()=>{h.current&&(h.current.options.disableStdin=!ne||e.state!==`running`)},[ne,e.state]);async function pe(n,r){le(!0),y(``);try{await de(n===`rename`?{type:n,id:e.id,directory:e.directory,title:r}:{type:n,id:e.id,directory:e.directory}),n===`close`&&u()}catch(e){y(t(e))}finally{le(!1),x(!1)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(l,{title:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(d,{title:e.title,busy:ce||!fe,onSave:e=>pe(`rename`,e)}),(0,$.jsxs)(`p`,{className:`terminal-location`,title:e.cwd,children:[`执行位置:`,e.cwd]})]}),actions:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(o,{icon:`search`,label:`查找终端内容`,onClick:()=>ae(!ie)}),(0,$.jsx)(s,{id:`terminal-menu`,routeKey:e.id,triggerId:`terminal-actions`,label:`终端操作`,trigger:(0,$.jsx)(i,{name:`more`}),className:`computer-create-menu`,children:e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{role:`menuitem`,onClick:()=>{h.current?.clear(),e()},children:`清屏`}),(0,$.jsx)(`button`,{role:`menuitem`,disabled:!fe||!C,onClick:()=>{e(),x(!0)},children:`关闭终端`})]})})]})}),ie&&(0,$.jsxs)(`form`,{className:`terminal-search`,onSubmit:e=>{e.preventDefault(),_.current?.findNext(oe)},children:[(0,$.jsx)(`input`,{autoFocus:!0,"aria-label":`查找终端内容`,placeholder:`查找`,value:oe,onChange:e=>{b(e.target.value),_.current?.findNext(e.target.value)}}),(0,$.jsx)(o,{icon:`close`,label:`关闭查找`,onClick:()=>{ae(!1),_.current?.clearDecorations(),h.current?.focus()}})]}),(0,$.jsx)(`div`,{className:`terminal-surface`,"data-testid":`terminal-pane`,children:(0,$.jsx)(`div`,{className:`terminal-emulator`,ref:m,"aria-label":`交互终端`})}),(!ne||e.state===`exited`||!C)&&(0,$.jsx)(`p`,{className:`terminal-status`,role:`status`,children:fe?C?e.state===`exited`?`进程已退出 · ${e.exitCode??0}`:`正在连接…`:`终端已结束,请新建终端。`:`连接已断开,正在重连…`}),se&&(0,$.jsxs)(a,{id:`terminal-close`,title:`关闭终端`,onClose:()=>x(!1),children:[(0,$.jsx)(`p`,{children:`结束此终端及其中运行的进程?`}),(0,$.jsxs)(`div`,{className:`actions`,children:[(0,$.jsx)(`button`,{onClick:()=>x(!1),children:`取消`}),(0,$.jsx)(`button`,{className:`primary`,disabled:ce,onClick:()=>void pe(`close`),children:`关闭终端`})]})]})]})}export{Ic as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as e,At as t,Ct as n,I as r,M as i,O as a,S as o,bt as s,c,dt as l,lt as u,mt as d,st as f,vt as p,w as m,wt as h}from"./Dropdown-DGFI68Vd.js";import{U as g,z as _}from"./index-mhJ33-bH.js";var v=i();function y({url:e,name:t}){return(0,v.jsx)(`iframe`,{className:`html-preview`,title:`${t} 预览`,src:`${e}${e.includes(`?`)?`&`:`?`}view=html`,sandbox:``,referrerPolicy:`no-referrer`})}var b=t(),x=new Intl.Collator(`zh-CN`,{numeric:!0,sensitivity:`base`});function S(e,t){return x.compare(e,t)||(e<t?-1:+(e>t))}var C=`_project`,w=`_resources`,T=e=>e===`_project`||e===`_resources`,E=e=>/^_memory(?:\/|$)/i.test(e);h([l,p(C),p(w)]);var D=n().max(255).refine(e=>{let t=e.endsWith(`/`),n=t?e.slice(0,-1):e;return f.safeParse(n).success&&!n.includes(`/`)&&!n.startsWith(`.`)&&!/^_?teammy/i.test(n)&&!E(n)&&(t?n.startsWith(`_`):n.includes(`.`))},`Use a root file (README.md) or an underscore-prefixed directory (_template/).`);s({maintainer:l.nullable(),paths:d(D).max(30).refine(e=>new Set(e.map(e=>e.toLowerCase())).size===e.length),revision:u}).strict().omit({revision:!0}).extend({expectedRevision:u}).strict();function O(e){return e.split(`/`).some(e=>/^\.teammy(?:[-.]|$)/i.test(e))}function k(e){let t=e.target.closest(`[role="treeitem"]`);if(!t)return;let n=[...e.currentTarget.querySelectorAll(`[role="treeitem"]`)].filter(e=>!e.closest(`[hidden]`)),r=n.indexOf(t),i=Number(t.getAttribute(`aria-level`)),a;switch(e.key){case`ArrowDown`:a=n[r+1];break;case`ArrowUp`:a=n[r-1];break;case`Home`:a=n[0];break;case`End`:a=n.at(-1);break;case`ArrowRight`:t.getAttribute(`aria-expanded`)===`false`?t.click():Number(n[r+1]?.getAttribute(`aria-level`))>i&&(a=n[r+1]);break;case`ArrowLeft`:t.getAttribute(`aria-expanded`)===`true`?t.click():a=n.slice(0,r).reverse().find(e=>Number(e.getAttribute(`aria-level`))<i);break;default:return}e.preventDefault(),a?.focus()}var A=(e,t)=>`${e}/${t}`,j=e=>({"--tree-level":e});function M({members:e,...t}){let[n,r]=(0,b.useState)(()=>`folder:${A(e.find(e=>e.hasFiles)?.id??`_project`,``)}`);return(0,v.jsx)(`div`,{role:`tree`,"aria-label":`工作区文件`,"data-testid":`workspace-tree`,onKeyDown:k,children:(0,v.jsx)(P,{owner:C,path:``,level:1,members:e.filter(e=>e.hasFiles),context:{...t,focused:n,onFocus:r}})})}function N({owner:e,path:t,level:n,context:r}){let i=r.expanded.has(A(e,t)),a=`folder:${A(e,t)}`;return(0,v.jsxs)(`div`,{role:`none`,children:[(0,v.jsxs)(_,{type:`button`,role:`treeitem`,className:`tree-item tree-folder`,style:j(n),"aria-label":t||e,"aria-level":n,"aria-expanded":i,"aria-selected":r.selected?.kind===`directory`&&r.selected.owner===e&&r.selected.path===t,tabIndex:r.focused===a?0:-1,"data-testid":`directory-row`,"data-owner-id":e,"data-directory-path":t,onFocus:()=>r.onFocus(a),onClick:()=>r.onToggle(e,t),leading:(0,v.jsx)(`span`,{className:`tree-chevron ${i?`expanded`:``}`,children:(0,v.jsx)(c,{name:`chevron`,size:`small`})}),children:[(0,v.jsx)(c,{name:`files`}),(0,v.jsx)(`span`,{className:`tree-name`,children:t.split(`/`).at(-1)||e})]}),i&&(0,v.jsx)(P,{owner:e,path:t,level:n+1,context:r})]})}function P({owner:t,path:n,level:i,context:s,members:l=[]}){let{api:u,projectId:d}=g(),f=(0,b.useCallback)(e=>u.tree(t,n,void 0,``,e),[t,n]),p=a(f,!1,e(d,`file-tree`,t,n)),[h,y]=(0,b.useState)(),[x,C]=(0,b.useState)(!1),w=m(),D=(0,b.useRef)(null);(0,b.useEffect)(()=>()=>D.current?.abort(),[]);let k=h?.revision===p.data?.revision?h:void 0,M=k?k.nextCursor:p.data?.nextCursor;async function P(){if(!M||!p.data||x)return;C(!0),w(``);let e=new AbortController;D.current=e;try{let r=await u.tree(t,n,p.data.revision,M,e.signal);e.signal.aborted||y({...r,entries:[...k?.entries??[],...r.entries]})}catch(t){e.signal.aborted||w(r(t))}finally{e.signal.aborted||C(!1)}}let F=[...(p.data?.entries??[]).filter(e=>!O(e.path)),...(k?.entries??[]).filter(e=>!O(e.path))],I=s.revealed;if(I?.owner===t&&!O(I.path)&&(!n||I.path.startsWith(n+`/`))){let e=n?I.path.slice(n.length+1):I.path,t=e.indexOf(`/`),r=t<0?I.path:[n,e.slice(0,t)].filter(Boolean).join(`/`);F.some(e=>e.path===r)||F.push(t<0?{...I.file,kind:`file`}:{kind:`directory`,path:r})}let L=[...F.filter(e=>t!==`_project`||!E(e.path)).map(e=>({...e,owner:t})),...l.map(e=>({kind:`directory`,path:``,owner:e.id}))].sort((e,t)=>e.kind===t.kind?S(e.path.split(`/`).at(-1)||e.owner,t.path.split(`/`).at(-1)||t.owner):e.kind===`directory`?-1:1);return(0,v.jsxs)(`div`,{role:`group`,"aria-label":A(T(t)?`teamcontext`:t,n),"aria-busy":p.loading||x,children:[p.loading&&(0,v.jsx)(`p`,{className:`tree-status`,role:`status`,children:`正在加载…`}),(0,v.jsx)(o,{resource:p}),L.map(e=>e.kind===`directory`?(0,v.jsx)(N,{owner:e.owner,path:e.path,level:i,context:s},A(e.owner,e.path)):(0,v.jsxs)(_,{type:`button`,role:`treeitem`,className:`tree-item`,style:j(i),"aria-label":e.path,"aria-level":i,"aria-selected":s.selected?.kind===`file`&&s.selected.owner===t&&s.selected.path===e.path,tabIndex:s.focused===`file:${A(t,e.path)}`?0:-1,"data-testid":`file-row`,"data-owner-id":t,"data-file-path":e.path,onFocus:()=>s.onFocus(`file:${A(t,e.path)}`),onClick:()=>s.onSelect(t,e.path),leading:(0,v.jsx)(`span`,{className:`tree-chevron`}),children:[(0,v.jsx)(c,{name:`file`}),(0,v.jsx)(`span`,{className:`tree-name`,children:e.path.split(`/`).at(-1)})]},e.path)),M&&(0,v.jsx)(`button`,{className:`tree-action`,"data-testid":`files-load-more`,disabled:x,onClick:()=>void P(),children:x?`正在加载…`:`加载更多`})]})}export{E as a,S as c,C as i,y as l,A as n,O as o,k as r,T as s,M as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{st as e}from"./Dropdown-DGFI68Vd.js";function t(t,n){if(!n||/^(?:[a-z][a-z0-9+.-]*:|\/)/i.test(n))return null;try{let r=n.split(/[?#]/,1)[0],i=r?t.split(`/`).slice(0,-1):t.split(`/`);for(let e of r.split(`/`)){let t=decodeURIComponent(e);if(t&&t!==`.`){if(t===`..`){if(!i.length)return null;i.pop()}else{if(t.includes(`/`)||t.includes(`\\`))return null;i.push(t)}}}return{path:i.length?e.parse(i.join(`/`)):``,directory:r.endsWith(`/`),anchor:n.includes(`#`)?decodeURIComponent(n.slice(n.indexOf(`#`)+1)):``}}catch{return null}}export{t};
|