@teammy/server 0.2.11 → 0.2.13
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 +6 -2
- package/dist/web/assets/Assistant-ysfCwRha.js +1 -0
- package/dist/web/assets/Computers-B6RBtpNC.css +1 -0
- package/dist/web/assets/Computers-ChbQnbXv.js +7 -0
- package/dist/web/assets/{Conversation-BFT_YU_m.js → Conversation-Co9JjVu_.js} +1 -1
- package/dist/web/assets/Conversation-DKhKiqFy.css +1 -0
- package/dist/web/assets/{Dashboard-zwfEddfm.js → Dashboard-BOsfWF4x.js} +1 -1
- package/dist/web/assets/Dashboard-J2mog3Rs.css +1 -0
- package/dist/web/assets/{Dropdown-BVXg1qjS.js → Dropdown-nwEutrew.js} +1 -1
- package/dist/web/assets/Files-BQBS447m.js +1 -0
- package/dist/web/assets/{Help-D2wGnf7L.js → Help-B2IpMg05.js} +15 -6
- package/dist/web/assets/Help-BJ0x9N-8.css +1 -0
- package/dist/web/assets/{HtmlPreview-C3railXk.js → HtmlPreview-CuQjPwY9.js} +1 -1
- package/dist/web/assets/{Markdown-DwIYP3W0.js → Markdown-CE06iKkt.js} +4 -4
- package/dist/web/assets/MessageComposer--n424osS.js +1 -0
- package/dist/web/assets/MessageComposer-hKEluJsT.css +1 -0
- package/dist/web/assets/ResourceLibrary-CxfQ7WWY.css +1 -0
- package/dist/web/assets/ResourceLibrary-DgcocHeS.js +6 -0
- package/dist/web/assets/{TerminalPane-D6QTLh_P.js → TerminalPane-DCgjBDv7.js} +2 -2
- package/dist/web/assets/{WorkspaceTree-DPnUT5Zj.js → WorkspaceTree-BV7twy0b.js} +1 -1
- package/dist/web/assets/{file-links-BcFN8P1K.js → file-links-BiCe1fX2.js} +1 -1
- package/dist/web/assets/index-DDxaaPSE.js +10 -0
- package/dist/web/assets/index-Du6eplBD.css +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 +3 -3
- package/package.json +1 -1
- package/dist/web/assets/Assistant-DLyxXHVH.js +0 -1
- package/dist/web/assets/Computers-BNJeNZB6.css +0 -1
- package/dist/web/assets/Computers-Bnq9vurA.js +0 -7
- package/dist/web/assets/Conversation-BVNmvuHR.css +0 -1
- package/dist/web/assets/Dashboard-ChX6TZDn.css +0 -1
- package/dist/web/assets/Files-DvZhUMI0.js +0 -1
- package/dist/web/assets/Help-DX51vBK7.css +0 -1
- package/dist/web/assets/MessageComposer-Ddu83TIm.js +0 -1
- package/dist/web/assets/MessageComposer-e3g3t5jX.css +0 -1
- package/dist/web/assets/ResourceLibrary-BB5EdMby.css +0 -1
- package/dist/web/assets/ResourceLibrary-CwHQw2pF.js +0 -6
- package/dist/web/assets/index-4y82i1SF.css +0 -1
- package/dist/web/assets/index-DbOamGWI.js +0 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,vt as t,w as n}from"./Dropdown-nwEutrew.js";var r=t(),i=n();function a({value:t,onChange:n,onSubmit:a,label:s,placeholder:c=`输入消息…`,disabled:l=!1,sendDisabled:u=!1,sendLabel:d=`发送`,actions:f,beforeSend:p,heading:m,inset:h=!1,plain:g=!1,attachments:_,hasAttachments:v=!1,onFiles:y}){let b=o(t),[x,S]=(0,r.useState)(!1),C=(0,r.useRef)(0),w=!l&&!u&&(!!t.trim()||v);return(0,i.jsxs)(`form`,{className:`message-composer${h?` message-composer-inset`:``}${g?` message-composer-plain`:``}${x?` message-composer-dragging`:``}`,onDragEnter:e=>{y&&!l&&e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),C.current++,S(!0))},onDragLeave:()=>{C.current=Math.max(0,C.current-1),C.current||S(!1)},onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=y&&!l?`copy`:`none`)},onDrop:e=>{C.current=0,S(!1),e.dataTransfer.files.length&&(e.preventDefault(),y&&!l&&y(Array.from(e.dataTransfer.files)))},onSubmit:e=>{e.preventDefault(),w&&a(e)},children:[m&&(0,i.jsx)(`div`,{className:`message-composer-heading`,children:m}),_,(0,i.jsx)(`textarea`,{ref:b,value:t,onChange:e=>n(e.target.value),"aria-label":s,placeholder:c,disabled:l,onPaste:e=>{let r=e.clipboardData.files.length?Array.from(e.clipboardData.files):Array.from(e.clipboardData.items).flatMap(e=>{let t=e.kind===`file`?e.getAsFile():null;return t?[t]:[]});if(y&&!l&&r.length){e.preventDefault(),y(r);let i=e.clipboardData.getData(`text/plain`);if(i){let r=e.currentTarget.selectionStart;n(t.slice(0,r)+i+t.slice(e.currentTarget.selectionEnd)),requestAnimationFrame(()=>b.current?.setSelectionRange(r+i.length,r+i.length))}}},rows:1,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),w&&e.currentTarget.form?.requestSubmit())}}),(0,i.jsxs)(`div`,{className:`message-composer-footer`,children:[f&&(0,i.jsx)(`div`,{className:`message-composer-actions`,children:f}),p,(0,i.jsx)(`button`,{type:`submit`,className:`primary message-send`,"aria-label":d,title:d,disabled:!w,children:(0,i.jsx)(e,{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 @@
|
|
|
1
|
+
.message-composer{background:var(--color-surface);border:1px solid var(--color-line);border-radius:var(--radius-lg);flex-direction:column;flex:none;align-items:stretch;gap:12px;min-width:0;margin:0 28px 28px;padding:12px;display:flex;position:relative}.message-composer-dragging{border-color:var(--color-input-focus)}.message-composer-dragging:after{content:"松开以添加图片";border-radius:inherit;color:var(--color-muted);background:var(--color-surface);opacity:.94;pointer-events:none;font-size:var(--text-sm);z-index:1;place-items:center;display:grid;position:absolute;inset:0}.message-composer:focus-within{border-color:var(--color-input-focus)}.message-composer textarea{width:100%;min-width:0;box-shadow:none;resize:none;background:0 0;border:0;min-height:40px;max-height:min(220px,28dvh);padding:8px;line-height:24px;overflow-y:auto}.message-composer textarea:focus{box-shadow:none;outline:none}.message-composer-footer,.message-composer-actions{align-items:center;gap:8px;display:flex}.message-composer-footer{justify-content:flex-end}.message-composer-actions{flex-wrap:nowrap;gap:6px;min-width:0;margin-right:auto}.message-composer-actions .icon-button{width:32px;height:32px;min-height:32px;color:var(--color-muted);padding:7px}.message-composer-actions .icon-button:hover,.message-composer-actions .icon-button[aria-pressed=true]{color:var(--color-text);background:var(--color-soft)}.message-send{border-radius:50%;flex:0 0 32px;place-items:center;width:32px;height:32px;min-height:32px;padding:0;display:grid}.message-stop{width:32px;height:32px;min-height:32px;color:var(--color-muted);background:0 0;border:0;border-radius:50%;flex:0 0 32px;place-items:center;padding:0;display:grid;position:relative}.message-stop:hover:not(:disabled){color:var(--color-text);background:var(--color-soft)}.message-stop>.icon{fill:currentColor;width:10px;height:10px}.message-stop-ring{border:1.5px solid var(--color-line);border-top-color:currentColor;border-radius:50%;animation:1.2s linear infinite message-stop-spin;position:absolute;inset:2px}@keyframes message-stop-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){.message-stop-ring{animation:none}}.message-composer-heading input{width:100%}@media (width<=900px){.message-composer{margin:0 16px 16px}}@media (width<=600px){.message-composer{gap:4px;margin:0 8px 12px;padding:6px}}.message-composer-inset{margin:0}.message-composer-plain{background:0 0;border:0;border-radius:0;gap:16px;padding:0}.message-composer-plain .topic-title{border:0;border-bottom:1px solid var(--color-line);box-shadow:none;font-size:var(--text-lg);background:0 0;border-radius:0;padding:8px 0;font-weight:600}.message-composer-plain textarea{min-height:120px;padding:0}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.material-body>h1{margin-bottom:var(--space-4);overflow-wrap:anywhere}.material-form{max-width:780px}.material-form fieldset{border:0;margin:0;padding:0}.material-form textarea{resize:vertical}.material-link{color:var(--brand-orange);font-size:inherit;background:0 0;border:0;padding:0}.material-form>h1{margin:0 0 12px}.material-form>p{margin:0 0 28px}.attachment-grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;display:grid}@media (width<=680px){.attachment-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}.attachment-card,.attachment-add{border-radius:12px;min-width:0;min-height:174px}.attachment-card{border:1px solid var(--color-line);background:var(--color-surface);position:relative}.attachment-content{text-align:left;background:0 0;border:0;flex-direction:column;justify-content:flex-start;align-items:flex-start;gap:14px;width:100%;height:100%;padding:24px;font-weight:400;display:flex}.attachment-content>.icon{color:var(--color-muted);width:25px;height:25px}.attachment-name{-webkit-line-clamp:2;overflow-wrap:anywhere;-webkit-box-orient:vertical;font-weight:500;line-height:1.5;display:-webkit-box;overflow:hidden}.attachment-excerpt{-webkit-line-clamp:2;overflow-wrap:anywhere;color:var(--color-muted);-webkit-box-orient:vertical;font-size:13px;line-height:1.6;display:-webkit-box;overflow:hidden}.attachment-remove{opacity:0;position:absolute;top:7px;right:7px}.attachment-card:hover .attachment-remove,.attachment-card:focus-within .attachment-remove{opacity:1}.attachment-add{border:1px dashed var(--color-line);background:var(--color-surface);color:var(--color-muted);flex-direction:column;justify-content:center;align-items:center;gap:16px;font-weight:400;display:flex}.attachment-add:hover{border-color:var(--brand-orange);color:var(--brand-orange)}.attachment-add>.icon{width:26px;height:26px}.attachment-actions{margin-top:28px}.session-handoff{padding-block:10px}.session-handoff>summary{cursor:pointer;font-weight:600}.session-handoff[open]>summary{margin-bottom:12px}.session-handoff button{min-height:28px;padding:4px 10px;font-size:12px}.memory-page{flex:1;width:100%;max-width:1000px;min-height:0;padding:0 8px 24px 0;overflow-y:auto}.memory-cards{gap:14px;display:grid}.memory-card{background:var(--color-surface,white);border:1px solid var(--color-line);border-radius:14px;align-items:flex-start;gap:16px;min-width:0;padding:20px 22px;display:flex}.memory-status{color:var(--color-muted);flex:none;padding-top:7px;display:flex}.memory-status.is-kept{color:var(--brand-orange)}.memory-content{flex:1;min-width:0}.memory-text{text-align:left;width:100%;font:inherit;overflow-wrap:anywhere;white-space:pre-wrap;color:inherit;background:0 0;border:0;border-radius:0;padding:4px 0;line-height:1.7;display:block}.memory-text:hover{background:0 0}.memory-content textarea{resize:vertical;width:100%;min-height:64px;font:inherit;line-height:1.7;display:block}.memory-actions{flex-shrink:0;gap:4px;display:flex}.memory-empty{color:var(--color-muted);margin:24px 0}@media (width<=680px){.memory-card{gap:8px;padding:14px 12px}.memory-actions{gap:0}.memory-actions .icon-button{width:32px;height:32px;padding:4px}}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{$ as e,N as t,O as n,P as r,Q as i,S as a,T as o,X as s,_ as c,_t as l,at as u,b as d,bt as f,c as p,ct as m,d as h,ft as g,gt as _,ht as v,it as y,k as b,l as x,lt as S,m as C,nt as w,o as ee,p as T,pt as E,rt as D,s as O,tt as k,ut as A,vt as j,w as M,y as N,yt as P}from"./Dropdown-nwEutrew.js";import{D as F,E as I,N as L,k as R}from"./index-DDxaaPSE.js";import{t as z}from"./Conversation-Co9JjVu_.js";import{n as B,r as V,t as H}from"./Markdown-CE06iKkt.js";import{c as te,r as U}from"./WorkspaceTree-BV7twy0b.js";import{n as W}from"./project-links-Dy6-B89_.js";import{t as G}from"./HtmlPreview-CuQjPwY9.js";function K(e){return l(w,e)}var q=j(),ne=g().regex(/^R\d{6,}$/),J=A({name:g().min(1),sha256:i,size:S().int().nonnegative()}),Y=v().refine(e=>/^https?:\/\//i.test(e),`Use an HTTP or HTTPS URL.`);A({operationId:_(),title:g().trim().default(``),text:g().optional(),url:Y.optional(),originals:y(J).default([])}).strict().refine(e=>!!e.text?.trim()||!!e.url||e.originals.length>0,`Provide text, a link or a file.`),A({expectedRevision:e,title:g().trim().min(1).optional(),url:Y.nullable().optional(),content:g().optional(),summary:g().optional(),sourceVersion:g().optional(),contentDate:g().optional(),originals:y(J).optional()}).strict();var X=A({id:ne,projectId:g(),title:g(),submittedBy:g(),createdAt:g(),revision:e,source:A({kind:D([`web`,`chat`,`group`]),url:g().nullable(),groupId:g().optional(),messageId:g().optional(),sourceVersion:g().optional(),contentDate:g().optional()}),originals:y(J),content:g().nullable(),summary:g().nullable(),state:D([`waiting`,`running`,`ready`,`failed`]),error:g().nullable(),url:g()}),re=A({materials:y(X),nextCursor:S().nullable()});A({query:g().trim().min(1),scope:D([`all`,`workspace`,`materials`]).default(`all`),materialId:ne.optional(),originalHash:i.optional(),after:g().default(``),limit:K().int().min(1).max(200).default(30)}).strict();var ie=A({items:y(A({key:g(),kind:D([`workspace`,`materials`]),title:g(),snippet:g(),url:g(),path:g()})),nextCursor:g().nullable()}),Z=M();function ae(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 oe(){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 se({active:e,onActivate:t,children:r}){let{request:i,projectId:o}=L(),[s,c]=(0,q.useState)(oe),[l,u]=(0,q.useState)(s),[m,h]=(0,q.useState)(()=>new Set(s?[s.id]:[])),[g,_]=(0,q.useState)(!1),[v,y]=(0,q.useState)(``),[b,S]=(0,q.useState)(``),[C,w]=(0,q.useState)(``),[E,D]=(0,q.useState)([]),[O,k]=(0,q.useState)(),[A,j]=(0,q.useState)(!1),[M,N]=(0,q.useState)(``),F=(0,q.useRef)(null),I=(0,q.useCallback)(e=>i(`materials`,re,{signal:e}),[i]),z=d(I,5e3,a(o,`materials`)),B=(0,q.useCallback)(e=>s?i(`materials/${encodeURIComponent(s.id)}${s.revision?`?revision=${encodeURIComponent(s.revision)}`:``}`,X,{signal:e}):Promise.resolve(null),[i,s?.id,s?.revision]),V=d(B,5e3),U=V.data?.id===s?.id?V.data:null,W=[...new Map([...E,...z.data?.materials??[],...U?[U]:[]].map(e=>[e.id,e])).values()].sort((e,t)=>t.createdAt.localeCompare(e.createdAt)||t.id.localeCompare(e.id)),G=O===void 0?z.data?.nextCursor:O;function K(e,n=``){t(),c(e),u(e),S(``),w(n),_(!1),h(t=>new Set([...t,e.id])),history.replaceState(null,``,P(`/projects/${o}/materials?${new URLSearchParams({...e})}`))}(0,q.useEffect)(()=>{let e=()=>{if(!f().endsWith(`/materials`))return;let e=oe();c(e),u(e),S(``),y(``),w(``),_(!1),e&&h(t=>new Set([...t,e.id]))};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);async function ne(){if(G&&!A){j(!0),N(``);try{let e=await i(`materials?before=${G}`,re);D(t=>[...t,...e.materials]),k(e.nextCursor)}catch(e){N(n(e))}finally{j(!1)}}}let J=W.find(e=>e.id===l?.id),Y=J?.originals.find(e=>e.sha256===l?.original)?.name??J?.title??`当前资料`;function ie(){u(void 0),w(``),F.current?.focus()}let se=(0,Z.jsx)(x,{icon:`plus`,label:`新增资料`,onClick:()=>{t(),_(!0),N(``)}});return r({tree:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(T,{error:!0,children:z.error||M}),z.data?W.length===0?(0,Z.jsx)(`p`,{className:`tree-status`,children:`暂无资料`}):(0,Z.jsx)(Z.Fragment,{children:W.map(t=>(0,Z.jsxs)(`div`,{role:`none`,children:[(0,Z.jsxs)(R,{role:`treeitem`,"aria-level":1,"aria-expanded":m.has(t.id),"aria-selected":e&&!g&&s?.id===t.id&&!s.original,className:`tree-item tree-folder`,style:{"--tree-level":1},"data-testid":`material-folder`,title:t.title,onClick:()=>{let e=m.has(t.id);K({id:t.id}),e&&h(e=>{let n=new Set(e);return n.delete(t.id),n})},leading:(0,Z.jsx)(`span`,{className:`tree-chevron ${m.has(t.id)?`expanded`:``}`,children:(0,Z.jsx)(p,{name:`chevron`,size:`small`})}),children:[(0,Z.jsx)(p,{name:`files`}),(0,Z.jsx)(`span`,{className:`tree-name`,children:t.title})]}),m.has(t.id)&&(0,Z.jsx)(`div`,{role:`group`,children:[...t.originals].sort((e,t)=>te(e.name,t.name)).map((n,r)=>(0,Z.jsxs)(R,{role:`treeitem`,"aria-level":2,"aria-selected":e&&!g&&s?.id===t.id&&s.original===n.sha256,className:`tree-item`,style:{"--tree-level":2},"data-testid":`material-original`,title:n.name,onClick:()=>K({id:t.id,original:n.sha256,...t.id===s?.id&&s.revision?{revision:s.revision}:{}}),leading:(0,Z.jsx)(`span`,{className:`tree-chevron`}),children:[(0,Z.jsx)(p,{name:`file`}),(0,Z.jsx)(`span`,{className:`tree-name`,children:n.name})]},`${n.sha256}:${r}`))})]},t.id))}):(0,Z.jsx)(`p`,{className:`tree-status`,children:`加载中…`}),G&&(0,Z.jsx)(`button`,{className:`tree-action`,disabled:A,onClick:()=>void ne(),children:A?`加载中…`:`加载更多`})]}),reader:(0,Z.jsxs)(`section`,{className:`session-reader`,"aria-label":`资料内容与搜索`,children:[(0,Z.jsx)(`div`,{className:`session-reader-content`,children:g?(0,Z.jsx)(fe,{onCancel:()=>_(!1),onSaved:e=>{K({id:e}),z.reload()}}):b?(0,Z.jsx)(ce,{query:b,scope:l,onSelect:e=>K(e,b)},`${b}/${l?.id}/${l?.original}`):s?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(T,{error:!0,children:V.error}),U?s.original?(0,Z.jsx)(le,{material:U,hash:s.original,highlight:C},`${U.id}:${s.original}`):(0,Z.jsxs)(`article`,{className:`material-body`,children:[(0,Z.jsx)(`h1`,{children:U.title}),s.revision&&(0,Z.jsx)(`button`,{className:`material-link`,onClick:()=>K({id:s.id}),children:`查看最新内容`}),!s.revision&&(U.state===`waiting`||U.state===`running`)?(0,Z.jsx)(`p`,{className:`muted`,role:`status`,children:`正在整理…`}):null,(0,Z.jsx)(T,{error:!0,children:U.error??``}),!s.revision&&U.state===`failed`&&(0,Z.jsx)(`button`,{onClick:()=>void i(`materials/${s.id}/retry`,X,{method:`POST`}).then(()=>V.reload()).catch(e=>N(n(e))),children:`重试整理`}),U.content?(0,Z.jsx)(`div`,{className:`markdown`,children:(0,Z.jsx)(H,{highlight:C,children:ae(U)})}):(0,Z.jsx)(`p`,{className:`muted`,children:`正文尚未整理,可以先查看左侧原件。`})]}):(0,Z.jsx)(`p`,{role:`status`,children:`加载中…`})]}):(0,Z.jsx)(ee,{mascot:!0,title:`选择资料开始阅读`,description:`也可以在下方搜索资料内容。`})}),!g&&(0,Z.jsxs)(`form`,{className:`session-search-dock`,"data-testid":`material-search-form`,onSubmit:e=>{e.preventDefault(),S(v.trim()),w(``)},children:[l&&(0,Z.jsxs)(`button`,{type:`button`,className:`search-scope-chip`,title:`清除搜索范围`,"aria-label":`清除范围:${Y}`,onClick:ie,children:[(0,Z.jsxs)(`span`,{className:`scope-label`,children:[`搜索:`,Y]}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:`×`})]}),(0,Z.jsxs)(`div`,{className:`session-search-input-row`,children:[(0,Z.jsx)(`input`,{ref:F,"aria-label":`搜索资料`,placeholder:`搜索资料内容`,value:v,onChange:e=>y(e.target.value),onKeyDown:e=>{e.key===`Backspace`&&!v&&l&&(e.preventDefault(),ie())}}),(b||v||C)&&(0,Z.jsx)(x,{icon:`close`,label:`清空搜索`,onClick:()=>{y(``),S(``),w(``),F.current?.focus()}}),(0,Z.jsx)(x,{icon:`search`,type:`submit`,label:`搜索`,disabled:!v.trim()})]})]})]}),actions:se,href:`/projects/${o}/materials${s&&!g?`?${new URLSearchParams({...s})}`:``}`})}function ce({query:e,scope:t,onSelect:n}){let{request:r}=L(),[i,a]=(0,q.useState)(``),o=(0,q.useCallback)(n=>r(`resources/search?${new URLSearchParams({query:e,scope:`materials`,after:i,...t?{materialId:t.id}:{},...t?.original?{originalHash:t.original}:{}})}`,ie,{signal:n}),[r,e,t?.id,t?.original,i]),s=d(o);return(0,Z.jsxs)(`section`,{className:`session-results stack`,"aria-label":`搜索结果`,children:[(0,Z.jsx)(T,{error:!0,children:s.error}),s.loading?(0,Z.jsx)(`p`,{role:`status`,children:`正在搜索…`}):s.data?.items.length===0?(0,Z.jsx)(`p`,{className:`empty`,children:`没有找到匹配的资料`}):s.data?.items.map(t=>(0,Z.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,Z.jsx)(`strong`,{children:t.title.replace(/^R\d+ · /,``)}),(0,Z.jsx)(`span`,{className:`session-excerpt`,children:(0,Z.jsx)(B,{value:V(t.snippet,e),query:e})})]},t.key)),s.data?.nextCursor&&(0,Z.jsx)(`button`,{disabled:s.loading,onClick:()=>a(s.data.nextCursor),children:`下一页`})]})}function le({material:e,hash:t,highlight:n}){let{projectId:r}=L(),i=e.originals.find(e=>e.sha256===t),o=P(`/api/v1/projects/${r}/materials/${e.id}/originals/${t}?revision=${e.revision}`),[s,c]=(0,q.useState)(!1),l=(0,q.useCallback)(async e=>{let t=await fetch(o,{signal:e});if(!t.ok)throw Error(`原件暂时无法读取。`);let n=await t.arrayBuffer();try{let e=new TextDecoder(`utf8`,{fatal:!0}).decode(n);return e.includes(`\0`)?null:e}catch{return null}},[o]),u=d(l,!1,a(r,`material-original`,t));if(!i)return(0,Z.jsx)(T,{error:!0,children:`找不到此原件。`});let f=/\.(md|markdown)$/i.test(i.name),m=/\.html?$/i.test(i.name);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`header`,{className:`file-detail-header`,children:[(0,Z.jsx)(`h2`,{className:`file-detail-path`,title:i.name,children:i.name}),(0,Z.jsxs)(`div`,{className:`toolbar-actions`,children:[(f||m)&&(0,Z.jsx)(x,{icon:s?`preview`:`code`,label:s?`切换为预览`:`切换为原文`,"aria-pressed":s,onClick:()=>c(!s)}),(0,Z.jsx)(`a`,{className:`icon-button`,"aria-label":`下载原件`,title:`下载原件`,href:o,download:i.name,children:(0,Z.jsx)(p,{name:`download`})})]})]}),(0,Z.jsx)(T,{error:!0,children:u.error}),u.loading?(0,Z.jsx)(`p`,{role:`status`,children:`加载中…`}):u.data===null?(0,Z.jsx)(`p`,{className:`muted`,children:`此格式请下载后查看。`}):u.data!==void 0&&(0,Z.jsx)(`div`,{className:`preview-body${m&&!s?` preview-body-html`:``}`,"data-testid":`material-original-content`,children:m&&!s?(0,Z.jsx)(G,{url:o,name:i.name}):f&&!s?(0,Z.jsx)(`article`,{className:`markdown`,children:(0,Z.jsx)(H,{highlight:n,children:u.data})}):(0,Z.jsx)(`pre`,{className:`raw`,children:(0,Z.jsx)(B,{value:u.data,query:n})})})]})}function ue(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 Q(e){try{return new URL(e.trim()).hostname}catch{return e.trim().split(`
|
|
4
|
+
`)[0]?.slice(0,80)||`文本`}}function de(e){try{return new URL(e.trim()).href}catch{return e.trim().split(`
|
|
5
|
+
`).slice(1).join(`
|
|
6
|
+
`)}}function fe({onSaved:e,onCancel:t}){let{request:r,projectId:i}=L(),[a,o]=(0,q.useState)([]),[s,c]=(0,q.useState)(),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(``),m=(0,q.useRef)(null),g=(0,q.useRef)(b()),_=(0,q.useRef)(new Map);function v(e){o(e),g.current=b(),f(``)}async function y(){u(!0),f(``);try{let t=[];for(let[e,n]of a.entries()){let r=_.current.get(n.id);if(!r){let t=n.kind===`file`?n.file.name:`${Q(n.text)}.txt`,a=await fetch(P(`/api/v1/projects/${i}/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} 项上传失败。`);r={name:t,sha256:o.sha256,size:o.size},_.current.set(n.id,r)}t.push(r)}let n=a.length===1&&a[0]?.kind===`text`?a[0].text.trim():``,o;try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)&&(o=e.href)}catch{}e((await r(`materials`,X,{method:`POST`,body:{operationId:g.current,originals:t,...o?{url:o}:{}}})).id)}catch(e){f(n(e))}finally{u(!1)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`form`,{className:`material-form`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,Z.jsx)(`h1`,{children:`新增资料`}),(0,Z.jsx)(`p`,{className:`muted`,children:`上传附件到项目,以便于Tim进行理解`}),(0,Z.jsx)(T,{error:!0,children:d}),(0,Z.jsxs)(`fieldset`,{disabled:l,children:[(0,Z.jsxs)(`div`,{className:`attachment-grid`,children:[a.map(e=>(0,Z.jsxs)(`article`,{className:`attachment-card`,"data-testid":`attachment-card`,children:[e.kind===`text`?(0,Z.jsxs)(`button`,{type:`button`,className:`attachment-content`,"aria-label":`编辑:${Q(e.text)}`,onClick:()=>c({id:e.id,text:e.text}),children:[(0,Z.jsx)(p,{name:ue(e)}),(0,Z.jsx)(`span`,{className:`attachment-name`,children:Q(e.text)}),de(e.text)&&(0,Z.jsx)(`span`,{className:`attachment-excerpt`,children:de(e.text)})]}):(0,Z.jsxs)(`div`,{className:`attachment-content`,children:[(0,Z.jsx)(p,{name:ue(e)}),(0,Z.jsx)(`span`,{className:`attachment-name`,children:e.file.name})]}),(0,Z.jsx)(x,{className:`attachment-remove`,icon:`close`,label:`移除:${e.kind===`file`?e.file.name:Q(e.text)}`,onClick:()=>{_.current.delete(e.id),v(a.filter(t=>t.id!==e.id))}})]},e.id)),(0,Z.jsxs)(`button`,{type:`button`,className:`attachment-add`,onClick:()=>c({text:``}),children:[(0,Z.jsx)(p,{name:`addText`}),(0,Z.jsx)(`span`,{children:`添加文本/链接`})]}),(0,Z.jsxs)(`button`,{type:`button`,className:`attachment-add`,onClick:()=>m.current?.click(),children:[(0,Z.jsx)(p,{name:`addFile`}),(0,Z.jsx)(`span`,{children:`添加文件`})]})]}),(0,Z.jsx)(`input`,{ref:m,type:`file`,multiple:!0,hidden:!0,"aria-label":`原始文件`,onChange:e=>{v([...a,...[...e.target.files??[]].map(e=>({id:b(),kind:`file`,file:e}))]),e.target.value=``}}),(0,Z.jsxs)(`div`,{className:`actions attachment-actions`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:t,children:`取消`}),(0,Z.jsx)(`button`,{type:`submit`,className:`primary`,disabled:!a.length,children:l?`上传中…`:`提交资料`})]})]})]}),s&&(0,Z.jsx)(h,{id:`material-text-editor`,title:`添加文本/链接`,onClose:()=>c(void 0),children:(0,Z.jsxs)(`form`,{className:`stack`,onSubmit:e=>{if(e.preventDefault(),!s.text.trim())return;let t={id:s.id??b(),kind:`text`,text:s.text};_.current.delete(t.id),v(s.id?a.map(e=>e.id===s.id?t:e):[...a,t]),c(void 0)},children:[(0,Z.jsx)(O,{id:`material-attachment-text`,label:`文本或链接`,children:(0,Z.jsx)(`textarea`,{autoFocus:!0,rows:8,value:s.text,onChange:e=>c({...s,text:e.target.value}),placeholder:`粘贴文本或网页链接`})}),(0,Z.jsx)(`div`,{className:`actions`,children:(0,Z.jsx)(`button`,{type:`submit`,className:`primary`,disabled:!s.text.trim(),children:s.id?`保存`:`添加`})})]})})]})}var pe=D([`overview`,`handoff`]),me=A({title:g().trim().min(1),summary:g().trim().min(1)}),he=A({markdown:g().trim().min(1)}),ge=me.extend({sourceRevision:e,sourceHash:i,generatedAt:g(),stale:u()}),_e=A({kind:pe,status:D([`absent`,`queued`,`running`,`succeeded`,`failed`]),available:u(),currentRevision:e,sourceRevision:e.nullable(),stale:u(),result:E([me,he]).nullable(),generatedAt:g().nullable(),error:g().nullable()}),ve=D([`claude-code`,`codex`,`cursor`,`pi`,`dsh`]),ye=A({formatVersion:m(1),adapterVersion:m(1),agent:ve,nativeId:g().min(1).max(512),cwd:g().min(1).max(4096),messages:y(A({id:g().min(1).max(1024),role:D([`user`,`assistant`]),text:g().min(1),source:g().min(1).max(1024)}).strict())}).strict().refine(e=>new Set(e.messages.map(e=>e.id)).size===e.messages.length,`Duplicate message IDs.`);A({operationId:_(),sessionKey:i,parentRevision:e,blob:s}).strict(),A({revision:e,hash:i.nullable(),cleared:u()});var be=A({owner:k,sessionKey:i,agent:ve,nativeId:g(),cwd:g(),title:g(),revision:e,updatedAt:g(),messageCount:S().int().nonnegative(),blob:s,overview:ge.optional()}),xe=A({sessions:y(be),nextCursor:e.nullable()}),Se=A({totalSessions:S().int().nonnegative(),totalMessages:S().int().nonnegative(),memberCount:S().int().nonnegative(),updatedAt:g().nullable()});A({owner:k.optional(),sessionKey:i.optional()}).strict().refine(e=>!e.sessionKey||!!e.owner,`A session scope requires an owner.`);var Ce=A({matches:y(A({owner:k,sessionKey:i,revision:e,messageId:g(),source:D([`message`,`handoff`]).default(`message`),role:D([`user`,`assistant`]),snippet:g(),title:g()})),nextCursor:e.nullable()}),we=A({owner:k,key:i,revision:e.refine(e=>e>0).optional(),messageId:g().min(1).optional(),source:D([`message`,`handoff`]).optional()});function Te(e){let t=new URLSearchParams(e);if(![`owner`,`sessionKey`,`revision`,`messageId`].some(e=>t.has(e)))return{};let n=we.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 Ee({members:e,refresh:t,selected:n,onOwner:r,onSession:i,level:a=1}){let[o,s]=(0,q.useState)(()=>new Set(n?.key?[n.owner]:[])),[c,l]=(0,q.useState)(e[0]?.id??``);return(0,Z.jsx)(`div`,{role:a===1?`tree`:`group`,"aria-label":`成员对话`,"data-testid":`session-tree`,onKeyDown:a===1?U:void 0,children:[...e].sort((e,t)=>te(e.id,t.id)).map(e=>(0,Z.jsxs)(`div`,{role:`none`,children:[(0,Z.jsxs)(R,{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,Z.jsx)(`span`,{className:`tree-chevron ${o.has(e.id)?`expanded`:``}`,children:(0,Z.jsx)(p,{name:`chevron`,size:`small`})}),children:[(0,Z.jsx)(p,{name:`files`}),(0,Z.jsx)(`span`,{className:`tree-name`,title:e.id,children:e.id})]}),o.has(e.id)&&(0,Z.jsx)(De,{level:a+1,owner:e.id,selected:n,onSession:i,focused:c,onFocus:l},`${e.id}/${t}`)]},e.id))})}function De({level:e,owner:r,selected:i,onSession:o,focused:s,onFocus:c}){let{request:l,projectId:u}=L(),f=(0,q.useCallback)(e=>l(`sessions?${new URLSearchParams({owner:r,limit:`50`,order:`updated`})}`,xe,{signal:e}),[r,l]),m=d(f,15e3,a(u,`session-tree`,r)),[h,g]=(0,q.useState)(),[_,v]=(0,q.useState)(!1),[y,b]=(0,q.useState)(``),x=(0,q.useRef)(null);(0,q.useEffect)(()=>()=>x.current?.abort(),[]);let S=h?h.nextCursor:m.data?.nextCursor;return(0,Z.jsxs)(`div`,{role:`group`,"aria-busy":m.loading||_,children:[(0,Z.jsx)(T,{error:!0,children:m.error||y}),m.error&&(0,Z.jsx)(`button`,{onClick:()=>void m.reload(),children:`重试`}),m.loading&&!m.data&&(0,Z.jsx)(`span`,{className:`tree-status`,role:`status`,children:`正在加载…`}),[...new Map([...h?.sessions??[],...m.data?.sessions??[]].map(e=>[e.sessionKey,e])).values()].sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt)||e.sessionKey.localeCompare(t.sessionKey)).map(n=>(0,Z.jsxs)(R,{type:`button`,role:`treeitem`,"aria-level":e,"aria-selected":i?.owner===r&&i.key===n.sessionKey,className:`tree-item`,style:{"--tree-level":e},tabIndex:s===`${r}/${n.sessionKey}`?0:-1,"data-testid":`session-row`,"data-owner-id":r,"data-session-key":n.sessionKey,title:t(n.title||n.nativeId),onFocus:()=>c(`${r}/${n.sessionKey}`),onClick:()=>o({owner:r,key:n.sessionKey,title:n.title||n.nativeId}),leading:(0,Z.jsx)(`span`,{className:`tree-chevron`}),children:[(0,Z.jsx)(p,{name:`sessions`}),(0,Z.jsx)(`span`,{className:`tree-name`,children:t(n.title||n.nativeId)})]},n.sessionKey)),S!=null&&(0,Z.jsx)(`button`,{className:`tree-action`,"data-testid":`session-tree-more`,disabled:_,onClick:async()=>{v(!0),b(``);let e=new AbortController;x.current=e;try{let t=await l(`sessions?${new URLSearchParams({owner:r,after:String(S),limit:`50`,order:`updated`})}`,xe,{signal:e.signal});g(e=>({sessions:[...e?.sessions??[],...t.sessions],nextCursor:t.nextCursor}))}catch(t){e.signal.aborted||b(n(t))}finally{e.signal.aborted||v(!1)}},children:`加载更多`})]})}function Oe({info:e,targeted:t=!1,highlight:n=``}){let[r,i]=(0,q.useState)(t),a=(0,q.useRef)(null);return(0,q.useEffect)(()=>{t&&a.current?.scrollIntoView({block:`center`})},[t]),(0,Z.jsxs)(`details`,{ref:a,open:r,className:`session-handoff`,onToggle:e=>i(e.currentTarget.open),children:[(0,Z.jsx)(`summary`,{children:`交接说明`}),r&&(0,Z.jsx)(ke,{info:e,revision:t?e.revision:void 0,highlight:n})]})}function ke({info:e,revision:t,highlight:r}){let{request:i}=L(),a=`sessions/${encodeURIComponent(e.owner)}/${e.sessionKey}`,o=(0,q.useCallback)(e=>i(`${a}/analysis/handoff${t===void 0?``:`?revision=${t}`}`,_e,{signal:e}),[i,a,t]),s=d(o,5e3),l=N(),[u,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(``),h=s.data,g=u||h?.status===`queued`||h?.status===`running`,_=h?.result&&`markdown`in h.result?h.result.markdown:void 0;return(0,Z.jsxs)(`div`,{className:`stack`,"data-testid":`session-handoff`,children:[(0,Z.jsx)(T,{error:!0,children:p||s.error}),s.loading&&!h&&(0,Z.jsx)(`small`,{role:`status`,children:`正在加载…`}),h&&(0,Z.jsxs)(`div`,{className:`inline-actions`,children:[h.status===`failed`&&t===void 0&&(0,Z.jsx)(`button`,{"data-testid":`session-handoff-generate`,disabled:g||!h.available,onClick:async()=>{f(!0),m(``);try{await i(`${a}/handoff`,_e,{method:`POST`,signal:l}),await s.reload()}catch(e){l.aborted||m(n(e))}finally{l.aborted||f(!1)}},children:g?`正在整理…`:`重试`}),!h.available&&(0,Z.jsx)(`small`,{children:`请先配置项目模型接入点`}),h.status===`failed`&&(0,Z.jsx)(`small`,{children:`整理未完成,可重试`}),h.available&&h.status!==`failed`&&(!_||h.stale||g)&&(0,Z.jsx)(`small`,{role:`status`,children:h.status===`running`||u?`正在整理…`:_?`对话已有新内容,等待自动更新…`:`等待自动整理…`}),h.currentRevision!==e.revision&&(0,Z.jsx)(`small`,{children:`交接说明使用最新对话;当前阅读的是历史原文`})]}),_&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`small`,{children:[`基于版本 `,h.sourceRevision,` · `,(0,Z.jsx)(c,{value:h.generatedAt})]}),(0,Z.jsx)(`div`,{className:`markdown`,"data-testid":`session-handoff-body`,children:(0,Z.jsx)(H,{highlight:r,children:_})})]})]})}function Ae({members:e,active:n,onActivate:i,children:o}){let{request:s,projectId:c,api:l}=L(),u=(0,q.useCallback)(async e=>{let[t,n]=await Promise.all([s(`sessions/stats`,Se,{signal:e}),l.members(e)]);return{...t,members:n.members}},[s,l]),p=d(u,!0,a(c,`session-stats`)),[m,h]=(0,q.useState)(``),[g,_]=(0,q.useState)(``),[v,y]=(0,q.useState)(0),[b]=(0,q.useState)(()=>Te(location.search)),[S,w]=(0,q.useState)(b.target),[E,D]=(0,q.useState)(b.target),[O,k]=(0,q.useState)(b.error??``),[A,j]=(0,q.useState)(``),M=(0,q.useRef)(null),N=S?.key?S.title?`搜索对话:${t(S.title)}`:`搜索当前对话`:S?`搜索:${S.owner} 的对话内容`:``,F=()=>{w(void 0),j(``),I(),M.current?.focus()};function I(){if(!E?.messageId)return;let{messageId:e,...t}=E;D(t),history.replaceState(null,``,P(W(c,t.owner,t.key,t)))}let R=(0,q.useCallback)(e=>{w(t=>t?.owner===e.owner&&t.key===e.sessionKey&&t.title!==e.title?{...t,title:e.title}:t)},[]);(0,q.useEffect)(()=>{let e=()=>{if(!f().endsWith(`/sessions`))return;let e=Te(location.search);D(e.target),w(e.target),k(e.error??``),_(``),h(``),j(``)};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);let z=(e,t=``)=>{i(),D(e),w(e),_(``),j(t),k(``),history.replaceState(null,``,P(W(c,e.owner,e.key,e)))},B=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(T,{error:!0,children:p.error}),(0,Z.jsx)(Ee,{members:(p.data?.members??e).filter(e=>e.hasSessions),refresh:v,selected:n?S:void 0,level:2,onOwner:e=>{i(),w({owner:e}),D(void 0),_(``),j(``),k(``),history.replaceState(null,``,P(`/projects/${encodeURIComponent(c)}/sessions`))},onSession:z})]}),V=(0,Z.jsxs)(`section`,{className:`session-reader`,"aria-label":`对话内容与搜索`,children:[(0,Z.jsx)(C,{title:r.sessions,count:(0,Z.jsx)(`span`,{"data-testid":`session-total`,children:p.data?.totalSessions??`—`}),children:(0,Z.jsx)(x,{icon:`refresh`,label:`刷新${r.sessions}`,"data-testid":`sessions-refresh`,disabled:p.loading,onClick:()=>{p.reload(),y(e=>e+1)}})}),(0,Z.jsx)(`div`,{className:`session-reader-content`,children:O?(0,Z.jsx)(T,{error:!0,children:O}):g?(0,Z.jsx)(je,{query:g,refresh:v,scope:{...S?{owner:S.owner}:{},...S?.key?{sessionKey:S.key}:{}},onSelect:e=>z(e,g)},`${g}/${S?.owner??``}/${S?.key??``}`):E?(0,Z.jsx)(Me,{selection:E,highlight:A,onLoaded:R,onLatest:()=>z({owner:E.owner,key:E.key})},`${E.owner}/${E.key}/${E.revision}/${E.source}/${v}`):(0,Z.jsx)(ee,{mascot:!0,title:`选择对话开始阅读`,description:`也可以在下方搜索会话库内容。`})}),(0,Z.jsxs)(`form`,{className:`session-search-dock`,"data-testid":`session-search-form`,onSubmit:e=>{e.preventDefault(),_(m.trim()),j(``),k(``),y(e=>e+1)},children:[S&&(0,Z.jsxs)(`button`,{type:`button`,className:`search-scope-chip`,"data-testid":`session-search-scope`,title:`清除搜索范围`,"aria-label":`清除范围:${N}`,onClick:F,children:[(0,Z.jsx)(`span`,{className:`scope-label`,children:N}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:`×`})]}),(0,Z.jsxs)(`div`,{className:`session-search-input-row`,children:[(0,Z.jsx)(`input`,{ref:M,"aria-label":`搜索对话`,"data-testid":`session-query`,value:m,maxLength:500,placeholder:`搜索会话库内容`,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Backspace`&&!m&&S&&(e.preventDefault(),F())}}),(g||m||A)&&(0,Z.jsx)(x,{icon:`close`,label:`清空搜索`,"data-testid":`session-search-clear`,onClick:()=>{h(``),_(``),j(``),I(),M.current?.focus()}}),(0,Z.jsx)(x,{icon:`search`,type:`submit`,label:`搜索`,"data-testid":`session-search`,disabled:!m.trim()})]})]})]});return o({hasSelection:!!S,tree:B,reader:V,href:E?W(c,E.owner,E.key,E):`/projects/${c}/sessions`})}function je({query:e,refresh:n,scope:r,onSelect:i}){let{request:a}=L(),[o,s]=(0,q.useState)(0),c=(0,q.useCallback)(t=>a(`sessions/search?${new URLSearchParams({q:e,after:String(o),limit:`30`,order:`updated`,...r.owner?{owner:r.owner}:{},...r.sessionKey?{sessionKey:r.sessionKey}:{}})}`,Ce,{signal:t}),[a,e,o,n,r.owner,r.sessionKey]),l=d(c);return(0,Z.jsxs)(`section`,{className:`session-results stack`,"aria-label":`搜索结果`,"aria-busy":l.loading,children:[(0,Z.jsx)(T,{error:!0,children:l.error}),l.error&&(0,Z.jsx)(`button`,{onClick:()=>void l.reload(),children:`重试`}),l.loading&&(0,Z.jsx)(`p`,{role:`status`,children:`正在搜索…`}),!l.loading&&l.data?.matches.map(n=>(0,Z.jsxs)(`button`,{className:`session-item`,"data-testid":`session-match`,"data-message-id":n.messageId,onClick:()=>i({owner:n.owner,key:n.sessionKey,revision:n.revision,messageId:n.messageId||void 0,source:n.source,title:n.title}),children:[(0,Z.jsx)(`strong`,{children:t(n.title)}),(0,Z.jsxs)(`small`,{children:[n.owner,` ·`,` `,n.source===`handoff`?`交接说明`:n.role===`user`?`用户`:`助手`]}),(0,Z.jsx)(`span`,{className:`session-excerpt`,children:(0,Z.jsx)(B,{value:V(n.snippet,e),query:e})})]},`${n.owner}:${n.sessionKey}:${n.revision}:${n.source}:${n.messageId}`)),!l.loading&&l.data?.matches.length===0&&(0,Z.jsx)(`p`,{className:`empty`,children:`没有找到匹配的对话`}),l.data?.nextCursor!=null&&(0,Z.jsx)(`button`,{"data-testid":`sessions-next`,disabled:l.loading,onClick:()=>s(l.data.nextCursor),children:`下一页`}),o>0&&(0,Z.jsx)(`button`,{disabled:l.loading,onClick:()=>s(0),children:`返回第一页`})]})}function Me({selection:e,highlight:t,onLoaded:n,onLatest:r}){let{request:i}=L(),a=(0,q.useCallback)(async t=>{try{return await i(`sessions/${encodeURIComponent(e.owner)}/${e.key}${e.revision===void 0?``:`?revision=${e.revision}`}`,be,{signal:t})}catch(e){throw e instanceof o&&e.code===`SESSION_NOT_FOUND`?Error(`找不到这条对话或引用的版本,原链接可能已失效。`):e}},[i,e.owner,e.key,e.revision]),s=d(a,5e3);return(0,q.useEffect)(()=>{s.data&&n(s.data)},[s.data,n]),(0,Z.jsxs)(`section`,{className:`session-conversation stack`,"data-testid":`session-detail`,children:[(0,Z.jsx)(T,{error:!0,children:s.error}),s.error&&(0,Z.jsx)(`button`,{onClick:()=>void s.reload(),children:`重试`}),s.loading&&!s.data&&(0,Z.jsx)(`p`,{role:`status`,children:`正在读取对话…`}),s.data&&(0,Z.jsx)(Ne,{info:s.data,messageId:e.messageId,handoff:e.source===`handoff`,highlight:t,pinned:e.revision!==void 0,onLatest:r},s.data.blob.sha256)]})}function Ne({info:e,messageId:n,handoff:r,highlight:i,pinned:a,onLatest:o}){let{readTextBlob:s,projectId:l}=L(),u=(0,q.useCallback)(async t=>ye.parse(JSON.parse(await s(e.blob,t))),[e.blob.sha256,e.blob.size]),f=d(u),p=(0,q.useRef)(null);return(0,q.useEffect)(()=>{f.data&&n&&p.current?.scrollIntoView({block:`center`})},[f.data,n]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`header`,{className:`conversation-header`,children:[(0,Z.jsx)(`h2`,{className:`session-title`,children:t(e.title||e.nativeId)}),(0,Z.jsxs)(`p`,{children:[e.owner,` · `,e.agent,` · `,e.messageCount,` 条消息`]}),(0,Z.jsxs)(`small`,{children:[(0,Z.jsx)(c,{value:e.updatedAt}),a&&(0,Z.jsxs)(Z.Fragment,{children:[` `,`· 引用版本 `,e.revision,` ·`,` `,(0,Z.jsx)(`a`,{href:P(W(l,e.owner,e.sessionKey)),onClick:e=>{e.preventDefault(),o()},children:`查看最新`})]})]}),e.overview&&(0,Z.jsx)(`p`,{"data-testid":`session-summary`,children:e.overview.summary}),e.overview?.stale&&(0,Z.jsx)(`small`,{children:`摘要待更新`})]}),(0,Z.jsx)(Oe,{info:e,targeted:r,highlight:r?i:``}),(0,Z.jsx)(T,{error:!0,children:f.error}),f.error&&(0,Z.jsx)(`button`,{onClick:()=>void f.reload(),children:`重新读取`}),f.loading&&(0,Z.jsx)(`p`,{role:`status`,children:`正在读取对话…`}),f.data&&(0,Z.jsxs)(Z.Fragment,{children:[n&&!f.data.messages.some(e=>e.id===n)&&(0,Z.jsx)(T,{children:`该版本中找不到引用的消息,已打开对话原文。`}),(0,Z.jsx)(`div`,{className:`session-messages`,children:f.data.messages.map(e=>(0,Z.jsx)(z,{mine:e.role===`user`,author:e.role===`user`?`用户`:`助手`,className:`session-message ${e.role} ${e.id===n?`matched`:``}`,"data-testid":`session-message`,"data-message-id":e.id,ref:e.id===n?p:void 0,children:(0,Z.jsx)(`div`,{className:`markdown`,children:(0,Z.jsx)(H,{highlight:i,children:e.text})})},e.id))})]})]})}var $=g().trim().min(1),Pe=A({id:_(),text:$,state:D([`draft`,`kept`]),revision:S().int().positive(),createdAt:g(),updatedAt:g()}),Fe=A({cards:y(Pe)});A({id:_(),text:$}).strict(),A({expectedRevision:S().int().positive(),text:$.optional(),action:D([`keep`,`discard`,`delete`]).optional()}).strict().refine(e=>e.text!==void 0||e.action!==void 0,`没有需要保存的修改。`),A({text:$}).strict();function Ie(){let{request:e,projectId:t}=L(),n=(0,q.useCallback)(t=>e(`memory`,Fe,{signal:t}),[e]),r=d(n,5e3,a(t,`memory`)),[i,o]=(0,q.useState)(null),[s,c]=(0,q.useState)({}),l=(0,q.useRef)(null),u=[...r.data?.cards??[]];for(let e of Object.values(s))u.some(t=>t.id===e.id)||u.push(e);if(r.data&&!l.current&&(l.current=[...u].sort((e,t)=>Number(t.state===`kept`)-Number(e.state===`kept`)).map(e=>e.id)),l.current){let e=new Map(l.current.map((e,t)=>[e,t]));for(let t of u)e.has(t.id)||(e.set(t.id,l.current.length),l.current.push(t.id));u.sort((t,n)=>e.get(t.id)-e.get(n.id))}return(0,Z.jsxs)(`section`,{className:`memory-page`,children:[(0,Z.jsx)(C,{title:`记忆`,children:(0,Z.jsx)(x,{icon:`plus`,label:`新增记忆`,disabled:!!i,onClick:()=>o(b())})}),(0,Z.jsx)(T,{error:!0,children:r.error}),!r.data&&r.loading&&(0,Z.jsx)(`p`,{role:`status`,children:`加载中…`}),(0,Z.jsxs)(`div`,{className:`memory-cards`,children:[i&&(0,Z.jsx)(Le,{id:i,onDone:()=>o(null),reload:r.reload},i),u.map(e=>(0,Z.jsx)(Le,{id:e.id,card:e,reload:r.reload,onEditing:t=>c(n=>{let r={...n};return t?r[e.id]=e:delete r[e.id],r})},e.id))]}),r.data&&u.length===0&&!i&&(0,Z.jsx)(`p`,{className:`memory-empty`,children:`暂无记忆`})]})}function Le({id:e,card:t,reload:r,onDone:i,onEditing:a}){let{request:o}=L(),[s,c]=(0,q.useState)(!t),[l,d]=(0,q.useState)(t?.text??``),[f,m]=(0,q.useState)(t?.revision),[h,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(``),y=(0,q.useRef)(!1),b=(0,q.useRef)(!1);function S(){b.current=!1,a?.(!0),d(t?.text??``),m(t?.revision),v(``),c(!0)}function C(){b.current=!0,c(!1),v(``),a?.(!1),i?.()}async function w(d){if(!y.current){if(!d&&t&&l===t.text)c(!1),a?.(!1);else if((!d||d===`keep`)&&!$.safeParse(s?l:t?.text).success)v(`请填写记忆内容。`);else{y.current=!0,g(!0),v(``);try{t?await o(`memory/${e}`,A({saved:u()}),{method:`PATCH`,body:{expectedRevision:s?f:t.revision,...d?{action:d}:{},...s&&d!==`discard`&&d!==`delete`?{text:l}:{}}}):await o(`memory`,Pe,{method:`POST`,body:{id:e,text:l}}),c(!1),await r(),a?.(!1),i?.()}catch(e){v(n(e)),await r()}finally{y.current=!1,g(!1)}}}}return(0,Z.jsxs)(`article`,{className:`memory-card`,"data-testid":`memory-card`,"data-memory-id":e,children:[(0,Z.jsx)(`span`,{className:`memory-status ${t?.state===`kept`?`is-kept`:``}`,role:`img`,"aria-label":t?.state===`kept`?`已保留`:`待确认`,children:(0,Z.jsx)(p,{name:t?.state===`kept`?`check`:`question`})}),(0,Z.jsxs)(`div`,{className:`memory-content`,children:[s?(0,Z.jsx)(`textarea`,{autoFocus:!0,"aria-label":`记忆内容`,value:l,rows:2,disabled:h,onChange:e=>d(e.target.value),onBlur:e=>{b.current?b.current=!1:e.relatedTarget instanceof Element&&e.relatedTarget.closest(`.memory-actions`)||_||w()},onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Escape`&&(e.preventDefault(),C()),e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),w()))}}):(0,Z.jsx)(`button`,{type:`button`,className:`memory-text`,"aria-label":`编辑记忆:${t?.text??``}`,onClick:S,children:t?.text}),(0,Z.jsx)(T,{error:!0,children:_})]}),(0,Z.jsxs)(`div`,{className:`memory-actions`,onMouseDown:e=>{s&&e.preventDefault()},children:[(!t||t.state===`draft`)&&(0,Z.jsx)(x,{icon:`check`,label:t?`保留记忆`:`保存记忆`,disabled:h,onClick:()=>void w(t?`keep`:void 0)}),s&&t?.state===`kept`&&(0,Z.jsx)(x,{icon:`check`,label:`保存记忆`,disabled:h,onClick:()=>void w()}),(0,Z.jsx)(x,{icon:`close`,label:t?t.state===`draft`?`舍弃记忆`:`删除记忆`:`取消新增`,disabled:h,onClick:()=>{t?w(t.state===`draft`?`discard`:`delete`):C()}})]})]})}function Re({section:e,members:t,navigate:n}){let{projectId:r}=L(),[i,a]=(0,q.useState)(e===`sessions`);(0,q.useEffect)(()=>{e===`sessions`&&a(!0)},[e]);let o=t=>{e!==t&&n(`/projects/${r}/${t}`)};return(0,Z.jsx)(se,{active:e===`materials`,onActivate:()=>o(`materials`),children:r=>(0,Z.jsx)(Ae,{members:t,active:e===`sessions`,onActivate:()=>o(`sessions`),children:t=>(0,Z.jsx)(I,{reading:!0,className:`resource-library`,"data-testid":`materials-page`,label:`资料目录`,navigation:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(F,{title:`资料`,children:r.actions}),(0,Z.jsxs)(`div`,{role:`tree`,"aria-label":`项目资料`,onKeyDown:U,style:{"--tree-level":1},children:[(0,Z.jsxs)(R,{role:`treeitem`,"aria-level":1,"aria-selected":e===`memory`,className:`tree-item tree-folder`,"data-testid":`library-memory`,leading:(0,Z.jsx)(`span`,{className:`tree-chevron`}),onClick:()=>o(`memory`),children:[(0,Z.jsx)(p,{name:`files`}),(0,Z.jsx)(`span`,{className:`tree-name`,children:`记忆`})]}),(0,Z.jsxs)(R,{role:`treeitem`,"aria-level":1,"aria-expanded":i,"aria-selected":e===`sessions`&&!t.hasSelection,className:`tree-item tree-folder`,"data-testid":`library-sessions`,leading:(0,Z.jsx)(`span`,{className:`tree-chevron ${i?`expanded`:``}`,children:(0,Z.jsx)(p,{name:`chevron`,size:`small`})}),onClick:()=>{a(!i),e!==`sessions`&&n(t.href)},children:[(0,Z.jsx)(p,{name:`files`}),(0,Z.jsx)(`span`,{className:`tree-name`,children:`会话库`})]}),(0,Z.jsx)(`div`,{hidden:!i,children:t.tree}),r.tree]})]}),children:e===`materials`?r.reader:e===`sessions`?t.reader:(0,Z.jsx)(`section`,{className:`session-reader`,"aria-label":`项目记忆`,children:(0,Z.jsx)(Ie,{})})})})})}export{Re as ResourceLibrary};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{O as e,c as t,d as n,l as r,p as i,t as a,vt as o,w as s}from"./Dropdown-nwEutrew.js";import{n as c}from"./Conversation-Co9JjVu_.js";import{t as l}from"./Computers-ChbQnbXv.js";var u=o(),d=Object.defineProperty,f=Object.getOwnPropertyDescriptor,p=(e,t)=>{for(var n in t)d(e,n,{get:t[n],enumerable:!0})},m=(e,t,n,r)=>{for(var i=r>1?void 0:r?f(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&&d(t,n,i),i},h=(e,t)=>(n,r)=>t(n,r,e),g=`Terminal input`,_={get:()=>g,set:e=>g=e},v=`Too much output to announce, navigate to rows manually to read`,ee={get:()=>v,set:e=>v=e};function te(e){return e.replace(/\r?\n/g,`\r`)}function ne(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function re(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function ie(e,t,n,r){e.stopPropagation(),e.clipboardData&&ae(e.clipboardData.getData(`text/plain`),t,n,r)}function ae(e,t,n,r){e=te(e),e=ne(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function oe(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){oe(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function y(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 b=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}},le=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}},ue=``,de=` `,fe=class e{constructor(){this.fg=0,this.bg=0,this.extended=new pe}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}},pe=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}},x=class e extends fe{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new pe,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?y(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()]}},me=`di$target`,he=`di$dependencies`,ge=new Map;function _e(e){return e[he]||[]}function S(e){if(ge.has(e))return ge.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);C(t,e,r)};return t._id=e,ge.set(e,t),t}function C(e,t,n){t[me]===t?t[he].push({id:e,index:n}):(t[he]=[{id:e,index:n}],t[me]=t)}var w=S(`BufferService`),ve=S(`CoreMouseService`),ye=S(`CoreService`),be=S(`CharsetService`),xe=S(`InstantiationService`),Se=S(`LogService`),T=S(`OptionsService`),Ce=S(`OscLinkService`),we=S(`UnicodeService`),Te=S(`DecorationService`),Ee=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 x,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):De(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)}};Ee=m([h(0,w),h(1,T),h(2,Ce)],Ee);function De(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 Oe=S(`CharSizeService`),ke=S(`CoreBrowserService`),Ae=S(`MouseService`),je=S(`RenderService`),Me=S(`SelectionService`),Ne=S(`CharacterJoinerService`),Pe=S(`ThemeService`),Fe=S(`LinkProviderService`),Ie=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?He.isErrorNoTelemetry(e)?new He(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 vs(e){bs(e)||_s.onUnexpectedError(e)}var ys=`Canceled`;function bs(e){return e instanceof xs||e instanceof Error&&e.name===ys&&e.message===ys}var xs=class extends Error{constructor(){super(ys),this.name=this.message}},Ss=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`}},Cs;(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})(Cs||={});var ws=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||Cs.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};ws.empty=new ws(e=>{});function Ts(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 Es;(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})(Es||={});var Ds=null;function Os(e){return Ds?.trackDisposable(e),e}function ks(e){Ds?.markAsDisposed(e)}function As(e,t){Ds?.setParent(e,t)}function js(e){if(Es.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 Ms(...e){return Ns(()=>js(e))}function Ns(e){let t=Os({dispose:Ts(()=>{ks(t),e()})});return t}var Ps=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,Os(this)}dispose(){this._isDisposed||(ks(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{js(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return As(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),As(e,null))}};Ps.DISABLE_DISPOSED_WARNING=!1;var Fs=Ps,Is=class{constructor(){this._store=new Fs,Os(this),As(this._store,this)}dispose(){ks(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};Is.None=Object.freeze({dispose(){}});var Ls=class{constructor(){this._isDisposed=!1,Os(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&As(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,ks(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&As(e,null),e}},Rs=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};Rs.Undefined=new Rs(void 0);var zs=globalThis.performance&&typeof globalThis.performance.now==`function`,Bs=class e{static create(t){return new e(t)}constructor(e){this._now=zs&&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}},Vs;(e=>{e.None=()=>Is.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(Ms(...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 $s({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 $s({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 $s({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 $s({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 $s({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 $s;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=re;function ie(e,t){return e(e=>t.fire(e))}e.forward=ie;function ae(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=ae;class oe{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 $s(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 se(e,t){return new oe(e,t).emitter.event}e.fromObservable=se;function y(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 Fs?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=y})(Vs||={});var Hs=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 Bs,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}}};Hs.all=new Set,Hs._idPool=0;var Us=Hs,Ws=-1,Gs=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 Js(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}};Gs._idPool=1;var Ks=Gs,qs=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
|
-
`))}},Js=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},Ys=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},Xs=0,Zs=class{constructor(e){this.value=e,this.id=Xs++}},Qs=2,$s=class{constructor(e){this._size=0,this._options=e,this._leakageMon=Ws>0||this._options?.leakWarningThreshold?new Ks(e?.onListenerError??vs,this._options?.leakWarningThreshold??Ws):void 0,this._perfMon=this._options?._profName?new Us(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 Ys(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||vs)(n),Is.None}if(this._disposed)return Is.None;t&&(e=e.bind(t));let r=new Zs(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=qs.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Zs?(this._deliveryQueue??=new ec,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=Ns(()=>{i?.(),this._removeListener(r)});return n instanceof Fs?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*Qs<=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||vs;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 Zs)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}},ec=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}},tc=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),nc;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof rc?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Vs.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:tc})})(nc||={});var rc=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?tc:(this._emitter||=new $s,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},ic=`en`,ac=!1,oc=!1,sc=ic,cc,lc=globalThis,uc;typeof lc.vscode<`u`&&typeof lc.vscode.process<`u`?uc=lc.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(uc=process);var dc=typeof uc?.versions?.electron==`string`&&uc?.type===`renderer`;if(typeof uc==`object`){uc.platform,uc.platform,ac=uc.platform===`linux`,ac&&uc.env.SNAP&&uc.env.SNAP_REVISION,uc.env.CI||uc.env.BUILD_ARTIFACTSTAGINGDIRECTORY,sc=ic;let e=uc.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,sc=t.resolvedLanguage||ic,t.languagePack?.translationsConfigFile}catch{}}else typeof navigator==`object`&&!dc?(cc=navigator.userAgent,cc.indexOf(`Windows`),cc.indexOf(`Macintosh`),(cc.indexOf(`Macintosh`)>=0||cc.indexOf(`iPad`)>=0||cc.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,ac=cc.indexOf(`Linux`)>=0,cc?.indexOf(`Mobi`),oc=!0,sc=globalThis._VSCODE_NLS_LANGUAGE||ic,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);oc&&typeof lc.importScripts==`function`&&lc.origin;var fc=cc,pc=sc,mc;(e=>{function t(){return pc}e.value=t;function n(){return pc.length===2?pc===`en`:pc.length>=3&&pc[0]===`e`&&pc[1]===`n`&&pc[2]===`-`}e.isDefaultVariant=n;function r(){return pc===`en`}e.isDefault=r})(mc||={});var hc=typeof lc.postMessage==`function`&&!lc.importScripts;(()=>{if(hc){let e=[];lc.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}),lc.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var gc=!!(fc&&fc.indexOf(`Chrome`)>=0);fc&&fc.indexOf(`Firefox`),!gc&&fc&&fc.indexOf(`Safari`),fc&&fc.indexOf(`Edg/`),fc&&fc.indexOf(`Android`);function _c(e,t=0,n){let r=setTimeout(()=>{e(),n&&i.dispose()},t),i=Ns(()=>{clearTimeout(r),n?.deleteAndLeak(i)});return n?.add(i),i}(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var vc;(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})(vc||={});var yc=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 $s,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 Vs.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())}};yc.EMPTY=yc.fromArray([]);var bc=class extends Is{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new Ls),this._linesCacheDisposables=this._register(new Ls),this._register(Ns(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=Ms(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=_c(()=>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]}},xc=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}},Sc=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}},Cc=class extends Is{constructor(e){super(),this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(Ns(()=>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(){js(n)}}}clearHighlightDecorations(){js(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(()=>js(e))),s.push(i)}}return s.length===0?void 0:s}},wc=class extends Is{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new $s)}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()}},Tc=class extends Is{constructor(e){super(),this._highlightTimeout=this._register(new Ls),this._lineCache=this._register(new Ls),this._state=new xc,this._resultTracker=this._register(new wc),this._highlightLimit=e?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new bc(e),this._engine=new Sc(e,this._lineCache.value),this._decorationManager=new Cc(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(Ns(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=_c(()=>{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}},Ec=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=Oc.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 Dc(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 Oc=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(!Dc(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]}},kc=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Ac(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 jc=class{constructor(e=Ac,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||kc;this._linkProvider=this._terminal.registerLinkProvider(new Ec(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}},$=e();function Mc(){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 Nc({terminal:e,connection:n,onClosed:d}){let f=(0,u.useRef)(null),p=(0,u.useRef)(null),m=(0,u.useRef)(null),h=(0,u.useRef)(null),g=(0,u.useRef)(!1),_=(0,u.useRef)(e);_.current=e;let[v,ee]=(0,u.useState)(!1),[te,ne]=(0,u.useState)(``),[re,ie]=(0,u.useState)(!1),[ae,oe]=(0,u.useState)(``),[se,y]=(0,u.useState)(!1),[ce,b]=(0,u.useState)(!1),{send:le,subscribe:ue,request:de}=n,fe=n.connected&&n.directories.includes(e.directory),pe=n.terminals.some(t=>t.id===e.id),x=(0,u.useRef)(()=>{});(0,u.useEffect)(()=>{let n={id:e.id,directory:e.directory},r=new ps({documentOverride:Mc(),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`}}),i=new gs,a=new Tc;r.loadAddon(i),r.loadAddon(a),r.loadAddon(new jc((e,t)=>{(e.metaKey||e.ctrlKey)&&/^https?:\/\//i.test(t)&&window.open(t,`_blank`,`noopener,noreferrer`)}));for(let e of[`c`,`n`]){r.parser.registerCsiHandler({final:e},()=>!0);for(let t of[`?`,`>`,`=`])r.parser.registerCsiHandler({prefix:t,final:e},()=>!0)}r.parser.registerCsiHandler({prefix:`>`,final:`q`},()=>!0),r.parser.registerCsiHandler({intermediates:`$`,final:`p`},()=>!0),r.parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},()=>!0),r.parser.registerDcsHandler({intermediates:`$`,final:`q`},()=>!0);for(let e of[4,10,11,12])r.parser.registerOscHandler(e,e=>e.includes(`?`));r.open(f.current),p.current=r,m.current=i,h.current=a;let o=-1,s=!1,c=e=>{try{le(e)}catch(e){ne(t(e))}};x.current=()=>{f.current?.clientWidth&&f.current.clientHeight&&!document.hidden&&(i.fit(),g.current&&_.current.state===`running`&&c({...n,type:`resize`,cols:r.cols,rows:r.rows}))};let l=new ResizeObserver(()=>x.current());l.observe(f.current);let u=()=>{document.hidden||x.current()};document.addEventListener(`visibilitychange`,u);let d=ue(e=>{if(`id`in e&&e.id===n.id){if(e.type===`snapshot`)g.current=!0,o=e.seq,r.reset(),r.resize(e.cols,e.rows),r.write(e.data,()=>{s||(r.options.disableStdin=_.current.state!==`running`,ee(!0),ne(``),x.current(),r.focus())});else if(e.type===`size`)r.resize(e.cols,e.rows);else if(e.type===`output`){if(!g.current||e.seq<=o)return;if(e.seq!==o+1){g.current=!1,c({...n,type:`attach`});return}o=e.seq,r.write(e.data)}else e.type===`result`&&e.error&&ne(e.error)}}),v=r.onData(e=>{if(!g.current||_.current.state!==`running`)return;let t=e.match(/[\s\S]{1,16000}/gu)??[];for(let e of t)c({...n,type:`input`,data:e})});return r.attachCustomKeyEventHandler(e=>e.type===`keydown`&&(e.metaKey||e.ctrlKey&&e.shiftKey)&&e.key.toLowerCase()===`c`&&r.hasSelection()?(navigator.clipboard?.writeText(r.getSelection()),!1):!0),()=>{s=!0,g.current=!1;try{le({...n,type:`detach`})}catch{}d(),v.dispose(),l.disconnect(),document.removeEventListener(`visibilitychange`,u),r.dispose(),p.current=null,m.current=null,h.current=null}},[e.id,e.directory,le,ue]),(0,u.useEffect)(()=>{if(g.current=!1,ee(!1),p.current&&(p.current.options.disableStdin=!0),fe&&pe)try{le({type:`attach`,id:e.id,directory:e.directory})}catch(e){ne(t(e))}},[fe,pe,e.id,e.directory,le]),(0,u.useEffect)(()=>{p.current&&(p.current.options.disableStdin=!v||e.state!==`running`)},[v,e.state]);async function me(n,r){b(!0),ne(``);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`&&d()}catch(e){ne(t(e))}finally{b(!1),y(!1)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(c,{title:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(l,{title:e.title,busy:ce||!fe,onSave:e=>me(`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:()=>ie(!re)}),(0,$.jsx)(s,{id:`terminal-menu`,routeKey:e.id,triggerId:`terminal-actions`,label:`终端操作`,trigger:(0,$.jsx)(r,{name:`more`}),className:`computer-create-menu`,children:e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{role:`menuitem`,onClick:()=>{p.current?.clear(),e()},children:`清屏`}),(0,$.jsx)(`button`,{role:`menuitem`,disabled:!fe||!pe,onClick:()=>{e(),y(!0)},children:`关闭终端`})]})})]})}),re&&(0,$.jsxs)(`form`,{className:`terminal-search`,onSubmit:e=>{e.preventDefault(),h.current?.findNext(ae)},children:[(0,$.jsx)(`input`,{autoFocus:!0,"aria-label":`查找终端内容`,placeholder:`查找`,value:ae,onChange:e=>{oe(e.target.value),h.current?.findNext(e.target.value)}}),(0,$.jsx)(o,{icon:`close`,label:`关闭查找`,onClick:()=>{ie(!1),h.current?.clearDecorations(),p.current?.focus()}})]}),(0,$.jsx)(a,{error:!0,children:te}),(0,$.jsx)(`div`,{className:`terminal-surface`,"data-testid":`terminal-pane`,children:(0,$.jsx)(`div`,{className:`terminal-emulator`,ref:f,"aria-label":`交互终端`})}),(!v||e.state===`exited`||!pe)&&(0,$.jsx)(`p`,{className:`terminal-status`,role:`status`,children:fe?pe?e.state===`exited`?`进程已退出 · ${e.exitCode??0}`:`正在连接…`:`终端已结束,请新建终端。`:`连接已断开,正在重连…`}),se&&(0,$.jsxs)(i,{id:`terminal-close`,title:`关闭终端`,onClose:()=>y(!1),children:[(0,$.jsx)(`p`,{children:`结束此终端及其中运行的进程?`}),(0,$.jsxs)(`div`,{className:`actions`,children:[(0,$.jsx)(`button`,{onClick:()=>y(!1),children:`取消`}),(0,$.jsx)(`button`,{className:`primary`,disabled:ce,onClick:()=>void me(`close`),children:`关闭终端`})]})]})]})}export{Nc as default};
|
|
22
|
+
`))}},Js=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},Ys=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},Xs=0,Zs=class{constructor(e){this.value=e,this.id=Xs++}},Qs=2,$s=class{constructor(e){this._size=0,this._options=e,this._leakageMon=Ws>0||this._options?.leakWarningThreshold?new Ks(e?.onListenerError??vs,this._options?.leakWarningThreshold??Ws):void 0,this._perfMon=this._options?._profName?new Us(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 Ys(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||vs)(n),Is.None}if(this._disposed)return Is.None;t&&(e=e.bind(t));let r=new Zs(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=qs.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Zs?(this._deliveryQueue??=new ec,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=Ns(()=>{i?.(),this._removeListener(r)});return n instanceof Fs?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*Qs<=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||vs;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 Zs)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}},ec=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}},tc=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),nc;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof rc?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Vs.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:tc})})(nc||={});var rc=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?tc:(this._emitter||=new $s,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},ic=`en`,ac=!1,oc=!1,sc=ic,cc,lc=globalThis,uc;typeof lc.vscode<`u`&&typeof lc.vscode.process<`u`?uc=lc.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(uc=process);var dc=typeof uc?.versions?.electron==`string`&&uc?.type===`renderer`;if(typeof uc==`object`){uc.platform,uc.platform,ac=uc.platform===`linux`,ac&&uc.env.SNAP&&uc.env.SNAP_REVISION,uc.env.CI||uc.env.BUILD_ARTIFACTSTAGINGDIRECTORY,sc=ic;let e=uc.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,sc=t.resolvedLanguage||ic,t.languagePack?.translationsConfigFile}catch{}}else typeof navigator==`object`&&!dc?(cc=navigator.userAgent,cc.indexOf(`Windows`),cc.indexOf(`Macintosh`),(cc.indexOf(`Macintosh`)>=0||cc.indexOf(`iPad`)>=0||cc.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,ac=cc.indexOf(`Linux`)>=0,cc?.indexOf(`Mobi`),oc=!0,sc=globalThis._VSCODE_NLS_LANGUAGE||ic,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);oc&&typeof lc.importScripts==`function`&&lc.origin;var fc=cc,pc=sc,mc;(e=>{function t(){return pc}e.value=t;function n(){return pc.length===2?pc===`en`:pc.length>=3&&pc[0]===`e`&&pc[1]===`n`&&pc[2]===`-`}e.isDefaultVariant=n;function r(){return pc===`en`}e.isDefault=r})(mc||={});var hc=typeof lc.postMessage==`function`&&!lc.importScripts;(()=>{if(hc){let e=[];lc.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}),lc.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var gc=!!(fc&&fc.indexOf(`Chrome`)>=0);fc&&fc.indexOf(`Firefox`),!gc&&fc&&fc.indexOf(`Safari`),fc&&fc.indexOf(`Edg/`),fc&&fc.indexOf(`Android`);function _c(e,t=0,n){let r=setTimeout(()=>{e(),n&&i.dispose()},t),i=Ns(()=>{clearTimeout(r),n?.deleteAndLeak(i)});return n?.add(i),i}(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var vc;(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})(vc||={});var yc=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 $s,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 Vs.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())}};yc.EMPTY=yc.fromArray([]);var bc=class extends Is{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new Ls),this._linesCacheDisposables=this._register(new Ls),this._register(Ns(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=Ms(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=_c(()=>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]}},xc=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}},Sc=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}},Cc=class extends Is{constructor(e){super(),this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(Ns(()=>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(){js(n)}}}clearHighlightDecorations(){js(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(()=>js(e))),s.push(i)}}return s.length===0?void 0:s}},wc=class extends Is{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new $s)}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()}},Tc=class extends Is{constructor(e){super(),this._highlightTimeout=this._register(new Ls),this._lineCache=this._register(new Ls),this._state=new xc,this._resultTracker=this._register(new wc),this._highlightLimit=e?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new bc(e),this._engine=new Sc(e,this._lineCache.value),this._decorationManager=new Cc(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(Ns(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=_c(()=>{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}},Ec=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=Oc.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 Dc(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 Oc=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(!Dc(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]}},kc=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Ac(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 jc=class{constructor(e=Ac,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||kc;this._linkProvider=this._terminal.registerLinkProvider(new Ec(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}},$=s();function Mc(){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 Nc({terminal:o,connection:s,onClosed:d}){let f=(0,u.useRef)(null),p=(0,u.useRef)(null),m=(0,u.useRef)(null),h=(0,u.useRef)(null),g=(0,u.useRef)(!1),_=(0,u.useRef)(o);_.current=o;let[v,ee]=(0,u.useState)(!1),[te,ne]=(0,u.useState)(``),[re,ie]=(0,u.useState)(!1),[ae,oe]=(0,u.useState)(``),[se,y]=(0,u.useState)(!1),[ce,b]=(0,u.useState)(!1),{send:le,subscribe:ue,request:de}=s,fe=s.connected&&s.directories.includes(o.directory),pe=s.terminals.some(e=>e.id===o.id),x=(0,u.useRef)(()=>{});(0,u.useEffect)(()=>{let t={id:o.id,directory:o.directory},n=new ps({documentOverride:Mc(),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 gs,i=new Tc;n.loadAddon(r),n.loadAddon(i),n.loadAddon(new jc((e,t)=>{(e.metaKey||e.ctrlKey)&&/^https?:\/\//i.test(t)&&window.open(t,`_blank`,`noopener,noreferrer`)}));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(f.current),p.current=n,m.current=r,h.current=i;let a=-1,s=!1,c=t=>{try{le(t)}catch(t){ne(e(t))}};x.current=()=>{f.current?.clientWidth&&f.current.clientHeight&&!document.hidden&&(r.fit(),g.current&&_.current.state===`running`&&c({...t,type:`resize`,cols:n.cols,rows:n.rows}))};let l=new ResizeObserver(()=>x.current());l.observe(f.current);let u=()=>{document.hidden||x.current()};document.addEventListener(`visibilitychange`,u);let d=ue(e=>{if(`id`in e&&e.id===t.id){if(e.type===`snapshot`)g.current=!0,a=e.seq,n.reset(),n.resize(e.cols,e.rows),n.write(e.data,()=>{s||(n.options.disableStdin=_.current.state!==`running`,ee(!0),ne(``),x.current(),n.focus())});else if(e.type===`size`)n.resize(e.cols,e.rows);else if(e.type===`output`){if(!g.current||e.seq<=a)return;if(e.seq!==a+1){g.current=!1,c({...t,type:`attach`});return}a=e.seq,n.write(e.data)}else e.type===`result`&&e.error&&ne(e.error)}}),v=n.onData(e=>{if(!g.current||_.current.state!==`running`)return;let n=e.match(/[\s\S]{1,16000}/gu)??[];for(let e of n)c({...t,type:`input`,data:e})});return n.attachCustomKeyEventHandler(e=>e.type===`keydown`&&(e.metaKey||e.ctrlKey&&e.shiftKey)&&e.key.toLowerCase()===`c`&&n.hasSelection()?(navigator.clipboard?.writeText(n.getSelection()),!1):!0),()=>{s=!0,g.current=!1;try{le({...t,type:`detach`})}catch{}d(),v.dispose(),l.disconnect(),document.removeEventListener(`visibilitychange`,u),n.dispose(),p.current=null,m.current=null,h.current=null}},[o.id,o.directory,le,ue]),(0,u.useEffect)(()=>{if(g.current=!1,ee(!1),p.current&&(p.current.options.disableStdin=!0),fe&&pe)try{le({type:`attach`,id:o.id,directory:o.directory})}catch(t){ne(e(t))}},[fe,pe,o.id,o.directory,le]),(0,u.useEffect)(()=>{p.current&&(p.current.options.disableStdin=!v||o.state!==`running`)},[v,o.state]);async function me(t,n){b(!0),ne(``);try{await de(t===`rename`?{type:t,id:o.id,directory:o.directory,title:n}:{type:t,id:o.id,directory:o.directory}),t===`close`&&d()}catch(t){ne(e(t))}finally{b(!1),y(!1)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(c,{title:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(l,{title:o.title,busy:ce||!fe,onSave:e=>me(`rename`,e)}),(0,$.jsxs)(`p`,{className:`terminal-location`,title:o.cwd,children:[`执行位置:`,o.cwd]})]}),actions:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(r,{icon:`search`,label:`查找终端内容`,onClick:()=>ie(!re)}),(0,$.jsx)(a,{id:`terminal-menu`,routeKey:o.id,triggerId:`terminal-actions`,label:`终端操作`,trigger:(0,$.jsx)(t,{name:`more`}),className:`computer-create-menu`,children:e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{role:`menuitem`,onClick:()=>{p.current?.clear(),e()},children:`清屏`}),(0,$.jsx)(`button`,{role:`menuitem`,disabled:!fe||!pe,onClick:()=>{e(),y(!0)},children:`关闭终端`})]})})]})}),re&&(0,$.jsxs)(`form`,{className:`terminal-search`,onSubmit:e=>{e.preventDefault(),h.current?.findNext(ae)},children:[(0,$.jsx)(`input`,{autoFocus:!0,"aria-label":`查找终端内容`,placeholder:`查找`,value:ae,onChange:e=>{oe(e.target.value),h.current?.findNext(e.target.value)}}),(0,$.jsx)(r,{icon:`close`,label:`关闭查找`,onClick:()=>{ie(!1),h.current?.clearDecorations(),p.current?.focus()}})]}),(0,$.jsx)(i,{error:!0,children:te}),(0,$.jsx)(`div`,{className:`terminal-surface`,"data-testid":`terminal-pane`,children:(0,$.jsx)(`div`,{className:`terminal-emulator`,ref:f,"aria-label":`交互终端`})}),(!v||o.state===`exited`||!pe)&&(0,$.jsx)(`p`,{className:`terminal-status`,role:`status`,children:fe?pe?o.state===`exited`?`进程已退出 · ${o.exitCode??0}`:`正在连接…`:`终端已结束,请新建终端。`:`连接已断开,正在重连…`}),se&&(0,$.jsxs)(n,{id:`terminal-close`,title:`关闭终端`,onClose:()=>y(!1),children:[(0,$.jsx)(`p`,{children:`结束此终端及其中运行的进程?`}),(0,$.jsxs)(`div`,{className:`actions`,children:[(0,$.jsx)(`button`,{onClick:()=>y(!1),children:`取消`}),(0,$.jsx)(`button`,{className:`primary`,disabled:ce,onClick:()=>void me(`close`),children:`关闭终端`})]})]})]})}export{Nc as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{$ as e,O as t,S as n,Z as r,b as i,c as a,ct as o,ft as s,it as c,p as l,pt as u,tt as d,ut as f,vt as p,w as m}from"./Dropdown-nwEutrew.js";import{N as h,k as g}from"./index-DDxaaPSE.js";var _=p(),v=new Intl.Collator(`zh-CN`,{numeric:!0,sensitivity:`base`});function y(e,t){return v.compare(e,t)||(e<t?-1:+(e>t))}var b=`_project`,x=`_resources`,S=e=>e===`_project`||e===`_resources`,C=e=>/^_memory(?:\/|$)/i.test(e);u([d,o(b),o(x)]);var w=s().max(255).refine(e=>{let t=e.endsWith(`/`),n=t?e.slice(0,-1):e;return r.safeParse(n).success&&!n.includes(`/`)&&!n.startsWith(`.`)&&!/^_?teammy/i.test(n)&&!C(n)&&(t?n.startsWith(`_`):n.includes(`.`))},`Use a root file (README.md) or an underscore-prefixed directory (_template/).`);f({maintainer:d.nullable(),paths:c(w).max(30).refine(e=>new Set(e.map(e=>e.toLowerCase())).size===e.length),revision:e}).strict().omit({revision:!0}).extend({expectedRevision:e}).strict();function T(e){return e.split(`/`).some(e=>/^\.teammy(?:[-.]|$)/i.test(e))}var E=m();function D(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 O=(e,t)=>`${e}/${t}`,k=e=>({"--tree-level":e});function A({members:e,...t}){let[n,r]=(0,_.useState)(()=>`folder:${O(e.find(e=>e.hasFiles)?.id??`_project`,``)}`);return(0,E.jsx)(`div`,{role:`tree`,"aria-label":`工作区文件`,"data-testid":`workspace-tree`,onKeyDown:D,children:(0,E.jsx)(M,{owner:b,path:``,level:1,members:e.filter(e=>e.hasFiles),context:{...t,focused:n,onFocus:r}})})}function j({owner:e,path:t,level:n,context:r}){let i=r.expanded.has(O(e,t)),o=`folder:${O(e,t)}`;return(0,E.jsxs)(`div`,{role:`none`,children:[(0,E.jsxs)(g,{type:`button`,role:`treeitem`,className:`tree-item tree-folder`,style:k(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===o?0:-1,"data-testid":`directory-row`,"data-owner-id":e,"data-directory-path":t,onFocus:()=>r.onFocus(o),onClick:()=>r.onToggle(e,t),leading:(0,E.jsx)(`span`,{className:`tree-chevron ${i?`expanded`:``}`,children:(0,E.jsx)(a,{name:`chevron`,size:`small`})}),children:[(0,E.jsx)(a,{name:`files`}),(0,E.jsx)(`span`,{className:`tree-name`,children:t.split(`/`).at(-1)||e})]}),i&&(0,E.jsx)(M,{owner:e,path:t,level:n+1,context:r})]})}function M({owner:e,path:r,level:o,context:s,members:c=[]}){let{api:u,projectId:d}=h(),f=(0,_.useCallback)(t=>u.tree(e,r,void 0,``,t),[e,r]),p=i(f,!1,n(d,`file-tree`,e,r)),[m,v]=(0,_.useState)(),[b,x]=(0,_.useState)(!1),[w,D]=(0,_.useState)(``),A=(0,_.useRef)(null);(0,_.useEffect)(()=>()=>A.current?.abort(),[]);let M=m?.revision===p.data?.revision?m:void 0,N=M?M.nextCursor:p.data?.nextCursor;async function P(){if(!N||!p.data||b)return;x(!0),D(``);let n=new AbortController;A.current=n;try{let t=await u.tree(e,r,p.data.revision,N,n.signal);n.signal.aborted||v({...t,entries:[...M?.entries??[],...t.entries]})}catch(e){n.signal.aborted||D(t(e))}finally{n.signal.aborted||x(!1)}}let F=[...(p.data?.entries??[]).filter(e=>!T(e.path)),...(M?.entries??[]).filter(e=>!T(e.path))],I=s.revealed;if(I?.owner===e&&!T(I.path)&&(!r||I.path.startsWith(r+`/`))){let e=r?I.path.slice(r.length+1):I.path,t=e.indexOf(`/`),n=t<0?I.path:[r,e.slice(0,t)].filter(Boolean).join(`/`);F.some(e=>e.path===n)||F.push(t<0?{...I.file,kind:`file`}:{kind:`directory`,path:n})}let L=[...F.filter(t=>e!==`_project`||!C(t.path)).map(t=>({...t,owner:e})),...c.map(e=>({kind:`directory`,path:``,owner:e.id}))].sort((e,t)=>e.kind===t.kind?y(e.path.split(`/`).at(-1)||e.owner,t.path.split(`/`).at(-1)||t.owner):e.kind===`directory`?-1:1);return(0,E.jsxs)(`div`,{role:`group`,"aria-label":O(S(e)?`teamcontext`:e,r),"aria-busy":p.loading||b,children:[p.loading&&(0,E.jsx)(`p`,{className:`tree-status`,role:`status`,children:`正在加载…`}),(0,E.jsx)(l,{error:!0,children:p.error||w}),p.error&&(0,E.jsx)(`button`,{className:`tree-action`,onClick:()=>void p.reload(),children:`重试`}),L.map(t=>t.kind===`directory`?(0,E.jsx)(j,{owner:t.owner,path:t.path,level:o,context:s},O(t.owner,t.path)):(0,E.jsxs)(g,{type:`button`,role:`treeitem`,className:`tree-item`,style:k(o),"aria-label":t.path,"aria-level":o,"aria-selected":s.selected?.kind===`file`&&s.selected.owner===e&&s.selected.path===t.path,tabIndex:s.focused===`file:${O(e,t.path)}`?0:-1,"data-testid":`file-row`,"data-owner-id":e,"data-file-path":t.path,onFocus:()=>s.onFocus(`file:${O(e,t.path)}`),onClick:()=>s.onSelect(e,t.path),leading:(0,E.jsx)(`span`,{className:`tree-chevron`}),children:[(0,E.jsx)(a,{name:`file`}),(0,E.jsx)(`span`,{className:`tree-name`,children:t.path.split(`/`).at(-1)})]},t.path)),N&&(0,E.jsx)(`button`,{className:`tree-action`,"data-testid":`files-load-more`,disabled:b,onClick:()=>void P(),children:b?`正在加载…`:`加载更多`})]})}export{C as a,y as c,b as i,O as n,T as o,D as r,S as s,A as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Z as e}from"./Dropdown-nwEutrew.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};
|