@lemoncat7/dsh-ssh 1.4.5 → 1.4.6

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/README.md CHANGED
@@ -6,7 +6,13 @@
6
6
 
7
7
  ## 兼容性
8
8
 
9
- 正式版 `1.4.5` 针对 DeepSeek Harness `0.1.2-rc.1` 构建,需要 Node.js `22.19+` 或 `24+`。Agent、Session/Workspace Controller、Credentials、Tools 与客户端 UI 接口均对应 `0.1.2-rc.1`。
9
+ 正式版 `1.4.6` 针对 DeepSeek Harness `0.1.2-rc.1` 构建,需要 Node.js `22.19+` 或 `24+`。Agent、Session/Workspace Controller、Credentials、Tools 与客户端 UI 接口均对应 `0.1.2-rc.1`。
10
+
11
+ ## 1.4.6 更新
12
+
13
+ - 修复 FTP 文件弹窗下载图标缺少尺寸与描边,导致“下载到本地”竖排、图标变形的问题。
14
+ - 下载按钮保持单行并保留 44px 点击高度,补齐弹窗操作区边距;长文件名和路径在弹窗内换行,关闭按钮不被挤出。
15
+ - 保持现有材质、配色及下载逻辑。94 项测试通过,浏览器回归覆盖手机、窄窗口和桌面的深浅主题及万条目录虚拟列表。
10
16
 
11
17
  ## 1.4.5 更新
12
18
 
package/lib/client.js CHANGED
@@ -5511,7 +5511,7 @@ body[data-ds-dark-theme] :is(
5511
5511
  background: var(--ssh-surface-raised);
5512
5512
  }
5513
5513
  }
5514
- `;var sf=require("react");function rf(e){(0,sf.useEffect)(()=>{let t=e.current,s=t?.parentElement;if(t==null||s===null||s===void 0)return;let r=s,o=!1,i,n=()=>{let a=t.parentElement;for(;a!==null&&a!==document.body;){let h=a.previousElementSibling;if(h instanceof HTMLElement){let l=getComputedStyle(h),c=Number.parseFloat(l.flexGrow);if(l.display==="flex"&&l.flexDirection==="column"&&c>0)return h.insertBefore(t,h.firstChild),t.dataset.dshSshAnchored="true",o=!0,!0}a=a.parentElement}return!1};return n()||(i=new MutationObserver(()=>{n()&&i?.disconnect()}),i.observe(document.body,{childList:!0,subtree:!0})),()=>{i?.disconnect(),delete t.dataset.dshSshAnchored,o&&r.isConnected&&r.append(t)}},[e])}var pt=require("react"),it=require("@deepseek-ai/dsh-client-ui-primitives");var fs=require("react"),ur=require("@deepseek-ai/dsh-client-ui-primitives"),be=require("react/jsx-runtime");function nf({profile:e,project:t,workspaces:s,currentWorkspaceId:r,recentWorkspaceId:o,returnFocus:i,onClose:n,onCreate:a}){let h=s.some(x=>String(x.workspaceId)===r)?r:s.some(x=>String(x.workspaceId)===o)?o:s[0]===void 0?void 0:String(s[0].workspaceId),[l,c]=(0,fs.useState)(h),[f,v]=(0,fs.useState)(!1),[g,u]=(0,fs.useState)(),d=(0,fs.useRef)(null),m=(0,fs.useRef)(null);(0,fs.useEffect)(()=>((d.current??m.current)?.focus(),()=>{i.isConnected&&i.focus()}),[i]);let p=()=>{f||n()},b=async x=>{if(x.preventDefault(),l!==void 0){v(!0),u(void 0);try{await a(t,l)}catch(y){u(gx(y)),v(!1)}}};return(0,be.jsx)(ur.Modal,{open:!0,onClose:p,title:"\u9009\u62E9\u4F1A\u8BDD\u5F52\u5C5E\u7A7A\u95F4",headless:!0,className:"dsh-ssh-session-create-modal",children:(0,be.jsxs)("section",{className:"dsh-ssh-session-create-shell",onKeyDown:mx,children:[(0,be.jsxs)("header",{children:[(0,be.jsxs)("span",{children:[(0,be.jsx)("h2",{children:"\u65B0\u5EFA\u8FDC\u7AEF\u4F1A\u8BDD"}),(0,be.jsx)("p",{children:"\u9009\u62E9\u8FD9\u4E2A\u4F1A\u8BDD\u5728 DSH \u4E2D\u5F52\u5C5E\u7684\u672C\u5730\u9879\u76EE"})]}),(0,be.jsx)("button",{ref:m,type:"button",className:"dsh-ssh-icon-button",disabled:f,onClick:p,"aria-label":"\u5173\u95ED",children:(0,be.jsx)(ur.IconCloseOutline16,{size:16})})]}),(0,be.jsxs)("form",{onSubmit:x=>{b(x)},children:[(0,be.jsxs)("dl",{className:"dsh-ssh-session-create-target",children:[(0,be.jsxs)("div",{children:[(0,be.jsx)("dt",{children:"\u8FDC\u7AEF\u4E3B\u673A"}),(0,be.jsxs)("dd",{children:[e.name,(0,be.jsxs)("small",{children:[e.username,"@",e.host,":",e.port]})]})]}),(0,be.jsxs)("div",{children:[(0,be.jsx)("dt",{children:"\u8FDC\u7AEF\u5DE5\u4F5C\u76EE\u5F55"}),(0,be.jsxs)("dd",{children:[t.name,(0,be.jsx)("small",{title:t.path,children:t.path})]})]})]}),(0,be.jsxs)("fieldset",{className:"dsh-ssh-workspace-picker",children:[(0,be.jsx)("legend",{children:"\u4F1A\u8BDD\u5F52\u5C5E\u7A7A\u95F4"}),(0,be.jsx)("p",{children:"\u4F1A\u8BDD\u8BB0\u5F55\u4FDD\u5B58\u5728\u6240\u9009 DSH \u9879\u76EE\u4E2D\uFF0CSSH \u547D\u4EE4\u4E0E\u7EC8\u7AEF\u56FA\u5B9A\u4F7F\u7528\u4E0A\u9762\u7684\u8FDC\u7AEF\u76EE\u5F55\u3002"}),s.length===0?(0,be.jsxs)("div",{className:"dsh-ssh-workspace-picker-empty",children:[(0,be.jsx)(ur.IconFolderClose16,{size:18}),(0,be.jsxs)("span",{children:[(0,be.jsx)("strong",{children:"\u8FD8\u6CA1\u6709\u53EF\u7528\u7684 DSH \u9879\u76EE"}),(0,be.jsx)("small",{children:"\u8BF7\u5148\u5173\u95ED\u6B64\u7A97\u53E3\uFF0C\u5728 DSH \u5DE6\u4FA7\u7A7A\u95F4\u4E2D\u65B0\u5EFA\u6216\u6DFB\u52A0\u9879\u76EE\u3002"})]})]}):(0,be.jsx)("div",{className:"dsh-ssh-workspace-options dsh-ssh-scroll-surface",role:"radiogroup","aria-label":"\u9009\u62E9 DSH \u9879\u76EE",children:s.map(x=>{let y=String(x.workspaceId),S=y===r?"\u5F53\u524D\u9879\u76EE":y===o?"\u6700\u8FD1\u4F7F\u7528":void 0;return(0,be.jsxs)("label",{className:"dsh-ssh-workspace-option",children:[(0,be.jsx)("input",{ref:y===h?d:void 0,className:"sr-only",type:"radio",name:"dsh-ssh-session-workspace",value:y,checked:l===y,disabled:f,onChange:()=>c(y)}),(0,be.jsxs)("span",{children:[(0,be.jsx)("span",{className:"dsh-ssh-workspace-option-icon",children:(0,be.jsx)(ur.IconFolderClose16,{size:16})}),(0,be.jsxs)("span",{className:"dsh-ssh-workspace-option-copy",children:[(0,be.jsx)("strong",{children:x.title}),(0,be.jsx)("small",{title:x.path,children:x.path})]}),S&&(0,be.jsx)("em",{children:S}),(0,be.jsx)("i",{"aria-hidden":"true"})]})]},y)})})]}),g&&(0,be.jsx)("p",{className:"dsh-ssh-inline-error",role:"alert",children:g}),(0,be.jsxs)("div",{className:"dsh-ssh-dialog-actions",children:[(0,be.jsx)("button",{type:"button",className:"dsh-ssh-secondary-button",disabled:f,onClick:p,children:"\u53D6\u6D88"}),(0,be.jsx)("button",{type:"submit",className:"dsh-ssh-primary-button",disabled:f||l===void 0,children:f?"\u6B63\u5728\u65B0\u5EFA\u2026":"\u65B0\u5EFA\u5E76\u6253\u5F00"})]})]})]})})}function mx(e){if(e.key!=="Tab")return;let t=Array.from(e.currentTarget.querySelectorAll('button:not(:disabled), input:not(:disabled), a[href], [tabindex]:not([tabindex="-1"])')).filter(o=>o.getClientRects().length>0),s=t[0],r=t[t.length-1];s===void 0||r===void 0||(e.shiftKey&&document.activeElement===s?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),s.focus()))}function gx(e){return e instanceof Error?e.message:String(e)}var Vt=require("react"),zn=require("@deepseek-ai/dsh-client-ui-primitives");var Ut=require("react/jsx-runtime"),vx="project-directory-picker",bx=600;function of({profileId:e,value:t,disabled:s,onChange:r}){let o=(0,Vt.useId)(),i=(0,Vt.useId)(),n=(0,Vt.useRef)(0),[a,h]=(0,Vt.useState)({kind:"idle"}),l=`sftp:${e}`,c=(0,Vt.useMemo)(()=>a.kind==="ready"?a.directory.entries.filter(Ss):[],[a]);(0,Vt.useEffect)(()=>{let v=++n.current,g=t.trim();if(g.length===0){h({kind:"idle"});return}h({kind:"checking"});let u=window.setTimeout(()=>{Pi(vx,l,g).then(d=>{v===n.current&&h({kind:"ready",directory:d})}).catch(d=>{v===n.current&&h({kind:"error",message:_x(d)})})},bx);return()=>window.clearTimeout(u)},[l,t]);let f=a.kind==="idle"?"\u53EF\u76F4\u63A5\u8F93\u5165\uFF1B\u505C\u6B62\u8F93\u5165\u540E\u4F1A\u81EA\u52A8\u68C0\u67E5\u8FDC\u7AEF\u8DEF\u5F84\u3002":a.kind==="checking"?"\u6B63\u5728\u68C0\u67E5\u8FDC\u7AEF\u8DEF\u5F84\u2026":a.kind==="error"?`\u8DEF\u5F84\u4E0D\u5B58\u5728\u6216\u65E0\u6CD5\u8BBF\u95EE\uFF1A${a.message}\u3002\u4ECD\u53EF\u6309\u5F53\u524D\u8F93\u5165\u4FDD\u5B58\u3002`:c.length===0?"\u8DEF\u5F84\u53EF\u8BBF\u95EE\uFF0C\u5F53\u524D\u6CA1\u6709\u5B50\u76EE\u5F55\u3002":`\u8DEF\u5F84\u53EF\u8BBF\u95EE\uFF0C\u627E\u5230 ${c.length} \u4E2A\u5B50\u76EE\u5F55\u3002`;return(0,Ut.jsxs)("div",{className:"dsh-ssh-field dsh-ssh-remote-path-field",children:[(0,Ut.jsx)("label",{htmlFor:o,children:"\u8FDC\u7AEF\u8DEF\u5F84"}),(0,Ut.jsx)("input",{id:o,required:!0,maxLength:4096,value:t,disabled:s,spellCheck:!1,placeholder:"/var/www/example","aria-invalid":a.kind==="error"?"true":void 0,"aria-describedby":i,onChange:v=>r(v.target.value)}),(0,Ut.jsx)("small",{id:i,className:`dsh-ssh-remote-path-feedback is-${a.kind}`,role:a.kind==="error"?"alert":"status",children:f}),a.kind==="ready"&&c.length>0&&(0,Ut.jsx)("div",{className:"dsh-ssh-remote-path-options","aria-label":"\u53EF\u9009\u62E9\u7684\u8FDC\u7AEF\u5B50\u76EE\u5F55",children:c.map(v=>(0,Ut.jsxs)("button",{type:"button",disabled:s,title:`\u9009\u62E9 ${v.path}`,onClick:()=>r(v.path),children:[(0,Ut.jsx)(zn.IconFolderClose16,{size:15,"aria-hidden":"true"}),(0,Ut.jsx)("span",{children:v.name}),(0,Ut.jsx)(zn.IconChevronRightOutline14,{size:13,"aria-hidden":"true"})]},v.path))})]})}function _x(e){return e instanceof Error?e.message:String(e)}var re=require("react/jsx-runtime");function af(e){let t=dr(),[s,r]=(0,pt.useState)(""),[o,i]=(0,pt.useState)(()=>new Set),[n,a]=(0,pt.useState)(()=>new Set),[h,l]=(0,pt.useState)({}),[c,f]=(0,pt.useState)(),[v,g]=(0,pt.useState)(),[u,d]=(0,pt.useState)(),[m,p]=(0,pt.useState)(),b=s.trim().toLocaleLowerCase(),x=(0,pt.useMemo)(()=>wx(e.profiles.filter(P=>Sx(P).includes(b))),[b,e.profiles]),y=async P=>{f(P);try{let E=await rh(P);l(T=>({...T,[P]:E})),p(void 0)}catch(E){p(Ml(E))}finally{f(E=>E===P?void 0:E)}},S=P=>{a(new Set([P])),h[P]===void 0&&y(P),e.onSelect({profileId:P,path:"~"})},_=P=>{let E=e.access?.profileIds??[],T=E.includes(P);e.onProfiles(T?E.filter(R=>R!==P):[...E,P]),T&&e.onDirectory(P,void 0)},w=P=>i(E=>{let T=new Set(E);return T.has(P)?T.delete(P):T.add(P),T});return(0,re.jsxs)("aside",{ref:t.ref,onPointerMove:t.onPointerMove,onPointerLeave:t.onPointerLeave,className:"dsh-ssh-remote-tree dsh-ssh-border-surface",children:[(0,re.jsxs)("header",{className:"dsh-ssh-tree-header",children:[(0,re.jsxs)("span",{children:[(0,re.jsx)("strong",{children:"\u4E3B\u673A\u4E0E\u9879\u76EE"}),(0,re.jsxs)("small",{children:[e.profiles.length," \u53F0\u4E3B\u673A"]})]}),(0,re.jsx)("button",{type:"button",className:"dsh-ssh-icon-button",onClick:e.onNewProfile,"aria-label":"\u65B0\u5EFA\u8FDE\u63A5",title:"\u65B0\u5EFA\u8FDE\u63A5",children:(0,re.jsx)(it.IconPlusOutline16,{size:16})})]}),(0,re.jsxs)("label",{className:"dsh-ssh-search",children:[(0,re.jsx)("span",{className:"sr-only",children:"\u641C\u7D22\u4E3B\u673A"}),(0,re.jsx)("input",{value:s,onChange:P=>r(P.target.value),placeholder:"\u641C\u7D22\u4E3B\u673A\u3001\u5206\u7EC4\u3001\u6807\u7B7E\u2026"})]}),(0,re.jsxs)("div",{className:"dsh-ssh-tree-scroll dsh-ssh-scroll-surface",children:[x.map(P=>{let E=o.has(P.name);return(0,re.jsxs)("section",{className:"dsh-ssh-tree-group","data-collapsed":E,children:[(0,re.jsx)("h3",{children:(0,re.jsxs)("button",{type:"button","aria-expanded":!E,onClick:()=>w(P.name),children:[E?(0,re.jsx)(it.IconChevronRightOutline14,{size:14}):(0,re.jsx)(it.IconChevronDownOutline14,{size:14}),(0,re.jsx)("span",{children:P.name}),(0,re.jsx)("small",{children:P.profiles.length})]})}),!E&&P.profiles.map(T=>{let R=n.has(T.id),M=e.access?.profileIds.includes(T.id)===!0,B=h[T.id]??[],U=e.selected?.profileId===T.id&&e.selected.projectId===void 0;return(0,re.jsxs)("div",{className:"dsh-ssh-tree-host","data-open":R,children:[(0,re.jsxs)("div",{"data-ssh-interactive":"row","data-ssh-context-row":!0,className:`dsh-ssh-tree-host-row${M?" is-authorized":""}${U?" is-active":""}`,children:[(0,re.jsxs)("button",{type:"button",className:"dsh-ssh-tree-host-main","aria-pressed":U,"aria-expanded":R,title:`\u9009\u62E9\u5E76\u5C55\u5F00 ${T.name}`,onClick:()=>S(T.id),children:[(0,re.jsx)("span",{className:"dsh-ssh-host-monogram",children:T.name.slice(0,1).toUpperCase()}),(0,re.jsxs)("span",{children:[(0,re.jsx)("strong",{children:T.name}),(0,re.jsxs)("small",{children:[T.username,"@",T.host]})]})]}),(0,re.jsx)("button",{type:"button","data-ssh-interactive":"choice",className:`dsh-ssh-tree-mount dsh-ssh-context-action${M?" is-mounted":""}`,"aria-label":`${M?"\u5378\u8F7D":"\u6302\u8F7D"} ${T.name}`,"aria-pressed":M,title:e.access===null?"\u6253\u5F00\u4E00\u4E2A DSH \u4F1A\u8BDD\u540E\u624D\u80FD\u6302\u8F7D\u4E3B\u673A":M?"\u4ECE\u5F53\u524D\u4F1A\u8BDD\u5378\u8F7D":"\u6302\u8F7D\u5230\u5F53\u524D\u4F1A\u8BDD",disabled:e.access===null||e.accessLoading||e.accessSaving,onClick:()=>_(T.id),children:M?"\u5378\u8F7D":"\u6302\u8F7D"}),(0,re.jsx)("button",{type:"button",className:"dsh-ssh-tree-add","aria-label":`\u4E3A ${T.name} \u6DFB\u52A0\u56FA\u5B9A\u76EE\u5F55`,title:"\u6DFB\u52A0\u56FA\u5B9A\u76EE\u5F55",onClick:()=>g({profile:T}),children:(0,re.jsx)(it.IconPlusOutline16,{size:14})})]}),R&&(0,re.jsx)("div",{className:"dsh-ssh-tree-branches",children:c===T.id&&h[T.id]===void 0?(0,re.jsx)("p",{className:"dsh-ssh-tree-state",children:"\u6B63\u5728\u8BFB\u53D6\u56FA\u5B9A\u76EE\u5F55\u2026"}):B.length===0?(0,re.jsxs)("button",{type:"button",className:"dsh-ssh-tree-empty",onClick:()=>g({profile:T}),children:[(0,re.jsx)(it.IconPlusOutline16,{size:13}),"\u6DFB\u52A0\u9879\u76EE\u76EE\u5F55"]}):B.map(N=>{let V=e.selected?.projectId===N.id,k=e.access?.workingProjectIds[T.id]===N.id;return(0,re.jsx)("div",{className:"dsh-ssh-tree-project",children:(0,re.jsxs)("div",{"data-ssh-interactive":"row",className:`dsh-ssh-tree-project-row${V?" is-active":""}${k?" is-bound":""}`,children:[(0,re.jsxs)("button",{type:"button",className:"dsh-ssh-tree-project-main","aria-pressed":e.access===null?void 0:k,title:e.access===null?"\u5F53\u524D\u6CA1\u6709\u53EF\u56FA\u5B9A\u76EE\u5F55\u7684 DSH \u4F1A\u8BDD":M?k?"\u53D6\u6D88\u5F53\u524D\u4F1A\u8BDD\u7684\u56FA\u5B9A\u76EE\u5F55":"\u56FA\u5B9A\u4E3A\u5F53\u524D\u4F1A\u8BDD\u76EE\u5F55":"\u8BF7\u5148\u6302\u8F7D\u8BE5\u4E3B\u673A",onClick:()=>{M&&!e.accessLoading&&!e.accessSaving&&(e.onDirectory(T.id,k?void 0:N.path,k?void 0:N.id),e.onSelect(k?{profileId:T.id,path:"~"}:{profileId:T.id,path:N.path,projectId:N.id}))},children:[(0,re.jsx)("span",{children:k?(0,re.jsx)(it.IconFolderOpenOutline16,{size:15}):(0,re.jsx)(it.IconFolderClose16,{size:15})}),(0,re.jsxs)("span",{children:[(0,re.jsx)("strong",{children:N.name}),(0,re.jsx)("small",{children:N.path}),k&&(0,re.jsx)("em",{children:"\u5F53\u524D\u4F1A\u8BDD\u5DF2\u56FA\u5B9A\u8BE5\u8DEF\u5F84"})]})]}),(0,re.jsx)("button",{type:"button",className:"dsh-ssh-tree-project-new","aria-label":`\u5728 ${N.name} \u65B0\u5EFA\u4F1A\u8BDD`,title:"\u65B0\u5EFA\u4F1A\u8BDD",onClick:I=>{p(void 0),d({profile:T,project:N,returnFocus:I.currentTarget})},children:(0,re.jsx)(it.IconPlusOutline16,{size:13})}),(0,re.jsx)("button",{type:"button",className:"dsh-ssh-tree-project-edit","aria-label":`\u7F16\u8F91 ${N.name}`,title:"\u7F16\u8F91\u56FA\u5B9A\u76EE\u5F55",onClick:()=>g({profile:T,project:N}),children:(0,re.jsx)(it.IconEditOutline16,{size:13})})]})},N.id)})})]},T.id)})]},P.name)}),x.length===0&&(0,re.jsx)("p",{className:"dsh-ssh-tree-no-results",children:e.profiles.length===0?"\u8FD8\u6CA1\u6709 SSH \u4E3B\u673A":"\u6CA1\u6709\u5339\u914D\u7684\u4E3B\u673A"})]}),(0,re.jsx)(xx,{access:e.access,loading:e.accessLoading,saving:e.accessSaving,error:e.accessError??m,onPermission:e.onPermission,onApproval:e.onApproval}),v!==void 0&&(0,re.jsx)(yx,{profile:v.profile,project:v.project,onClose:()=>g(void 0),onSaved:async()=>{let P=v.profile.id;g(void 0),await y(P)}}),u!==void 0&&(0,re.jsx)(nf,{...u,workspaces:e.workspaces,currentWorkspaceId:e.currentWorkspaceId,recentWorkspaceId:e.recentWorkspaceId,onClose:()=>d(void 0),onCreate:e.onCreateSession})]})}function xx({access:e,loading:t,saving:s,error:r,onPermission:o,onApproval:i}){return(0,re.jsxs)("footer",{className:"dsh-ssh-access-footer",children:[(0,re.jsxs)("div",{className:"dsh-ssh-access-heading",children:[(0,re.jsxs)("span",{children:[(0,re.jsx)("strong",{children:"\u5F53\u524D\u4F1A\u8BDD\u6743\u9650"}),(0,re.jsxs)("small",{children:[e?.profileIds.length??0," \u53F0\u4E3B\u673A\u53EF\u7528"]})]}),(0,re.jsx)("em",{children:t?"\u8BFB\u53D6\u4E2D":s?"\u4FDD\u5B58\u4E2D":"\u5DF2\u540C\u6B65"})]}),(0,re.jsxs)("div",{className:"dsh-ssh-access-segments","aria-label":"SSH \u6743\u9650",children:[(0,re.jsx)("button",{type:"button","data-ssh-interactive":"choice",className:e?.permission==="exec"?"is-active":"","aria-pressed":e?.permission==="exec",disabled:e===null,onClick:()=>o("exec"),children:"\u4EC5\u547D\u4EE4"}),(0,re.jsx)("button",{type:"button","data-ssh-interactive":"choice",className:e?.permission==="terminal"?"is-active":"","aria-pressed":e?.permission==="terminal",disabled:e===null,onClick:()=>o("terminal"),children:"\u7EC8\u7AEF\u63A7\u5236"})]}),(0,re.jsxs)("label",{className:"dsh-ssh-access-approval",children:[(0,re.jsxs)("span",{children:[(0,re.jsx)("strong",{children:"\u6267\u884C\u524D\u786E\u8BA4"}),(0,re.jsx)("small",{children:e?.requireCommandApproval===!1?"\u5173\u95ED\u540E\u6309\u5F53\u524D\u4F1A\u8BDD\u6743\u9650\u76F4\u63A5\u6267\u884C":"\u9700 DSH \u4F7F\u7528 Ask\uFF1BFull Access \u4F1A\u76F4\u63A5\u62D2\u7EDD"})]}),(0,re.jsx)("input",{type:"checkbox",checked:e?.requireCommandApproval??!0,disabled:e===null,onChange:n=>i(n.target.checked)}),(0,re.jsx)("i",{"aria-hidden":"true"})]}),r&&(0,re.jsx)("p",{className:"dsh-ssh-inline-error",role:"alert",children:r})]})}function yx({profile:e,project:t,onClose:s,onSaved:r}){let[o,i]=(0,pt.useState)(t?.name??""),[n,a]=(0,pt.useState)(t?.path??""),[h,l]=(0,pt.useState)(!1),[c,f]=(0,pt.useState)(),v=async u=>{u.preventDefault(),l(!0),f(void 0);try{t===void 0?await ih(e.id,{name:o,path:n}):await nh(e.id,t.id,{name:o,path:n}),await r()}catch(d){f(Ml(d)),l(!1)}},g=async()=>{if(!(t===void 0||!window.confirm(`\u5220\u9664\u56FA\u5B9A\u76EE\u5F55\u201C${t.name}\u201D\uFF1F\u76F8\u5173 DSH \u4F1A\u8BDD\u4E0D\u4F1A\u5220\u9664\u3002`))){l(!0),f(void 0);try{await oh(e.id,t.id),await r()}catch(u){f(Ml(u)),l(!1)}}};return(0,re.jsx)(et,{className:"dsh-ssh-project-dialog",title:t===void 0?"\u6DFB\u52A0\u56FA\u5B9A\u76EE\u5F55":"\u7F16\u8F91\u56FA\u5B9A\u76EE\u5F55",subtitle:`${e.name} \xB7 \u7EC8\u7AEF\u4E0E SFTP \u7684\u9ED8\u8BA4\u8FDC\u7AEF\u8DEF\u5F84`,onClose:s,children:(0,re.jsxs)("form",{className:"dsh-ssh-form",onSubmit:u=>{v(u)},children:[(0,re.jsxs)("label",{className:"dsh-ssh-field",children:[(0,re.jsx)("span",{children:"\u540D\u79F0"}),(0,re.jsx)("input",{required:!0,maxLength:80,value:o,placeholder:"\u7F51\u7AD9\u9879\u76EE",onChange:u=>i(u.target.value)})]}),(0,re.jsx)(of,{profileId:e.id,value:n,disabled:h,onChange:a}),c&&(0,re.jsx)("p",{className:"dsh-ssh-inline-error",role:"alert",children:c}),(0,re.jsxs)("div",{className:"dsh-ssh-dialog-actions",children:[t!==void 0&&(0,re.jsxs)("button",{type:"button",className:"dsh-ssh-danger-button",disabled:h,onClick:()=>{g()},children:[(0,re.jsx)(it.IconTrashOutline16,{size:15}),"\u5220\u9664"]}),(0,re.jsx)("span",{className:"dsh-ssh-dialog-spacer"}),(0,re.jsx)("button",{type:"button",className:"dsh-ssh-secondary-button","data-ssh-dialog-close":!0,disabled:h,onClick:s,children:"\u53D6\u6D88"}),(0,re.jsx)("button",{className:"dsh-ssh-primary-button",disabled:h,children:h?"\u4FDD\u5B58\u4E2D\u2026":"\u4FDD\u5B58\u76EE\u5F55"})]})]})})}function wx(e){let t=new Map;for(let s of e){let r=s.group?.trim()||"\u672A\u5206\u7EC4",o=t.get(r);o===void 0?t.set(r,[s]):o.push(s)}return[...t].map(([s,r])=>({name:s,profiles:r}))}function Sx(e){return`${e.name} ${e.group??""} ${e.host} ${e.username} ${e.tags.join(" ")}`.toLocaleLowerCase()}function Ml(e){return e instanceof Error?e.message:String(e)}var ft=require("react");var Fl=new Set;function Hn(e){for(let t of Fl)t(e)}function lf(e){return Fl.add(e),()=>Fl.delete(e)}function cf(e){let[t,s]=(0,ft.useState)(null),[r,o]=(0,ft.useState)(e!==void 0),[i,n]=(0,ft.useState)(!1),[a,h]=(0,ft.useState)(),l=(0,ft.useRef)(null),c=(0,ft.useRef)(e),f=(0,ft.useRef)(Promise.resolve()),v=(0,ft.useRef)(0);c.current=e,(0,ft.useEffect)(()=>{let d=!1;return l.current=null,s(null),h(void 0),o(e!==void 0),e===void 0?()=>{d=!0}:(Di(e).then(m=>{if(d)return;let p=m??Si(e);l.current=p,s(p),Hn(p)}).catch(m=>{d||h(hf(m))}).finally(()=>{d||o(!1)}),()=>{d=!0})},[e]);let g=(0,ft.useCallback)(async d=>{l.current=d,s(d),Hn(d),h(void 0),v.current+=1,n(!0);let m=f.current.catch(()=>{}).then(()=>Ri(d));f.current=m;try{let p=await m;return c.current===p.sessionId&&l.current===d&&(l.current=p,s(p),Hn(p)),p}catch(p){throw c.current===d.sessionId&&h(hf(p)),p}finally{v.current=Math.max(0,v.current-1),c.current===d.sessionId&&v.current===0&&n(!1)}},[]),u=(0,ft.useCallback)(d=>{let m=c.current;if(m===void 0)return;let p=l.current??Si(m);g({...p,...d,sessionId:m}).catch(()=>{})},[g]);return{value:t,loading:r,saving:i,error:a,setProfiles:d=>u({profileIds:d}),setDirectory:(d,m,p)=>{let b=c.current;if(b===void 0)return;let x=l.current??Si(b),y={...x.workingDirectories},S={...x.workingProjectIds};m===void 0?delete y[d]:y[d]=m,p===void 0?delete S[d]:S[d]=p,u({workingDirectories:y,workingProjectIds:S})},setPermission:d=>u({permission:d}),setRequireCommandApproval:d=>u({requireCommandApproval:d}),setFileEndpoints:d=>u({fileEndpointIds:d}),setFilePermission:d=>u({filePermission:d}),setRequireFileApproval:d=>u({requireFileApproval:d}),replace:g}}function Si(e){return{sessionId:e,profileIds:[],permission:"exec",requireCommandApproval:!0,fileEndpointIds:[],filePermission:"browse",requireFileApproval:!0,workingDirectories:{},workingProjectIds:{},updatedAt:0}}function hf(e){return e instanceof Error?e.message:String(e)}var pr=require("react"),Vn=require("react/jsx-runtime"),Un=38,ki=28,Ci=66,kx=320,Cx=280,Ex=7;function df(e,t,s){return Math.min(s,Math.max(t,e))}function Tx(e){if(typeof window>"u")return Un;try{let t=Number.parseFloat(window.localStorage.getItem(e)??"");return Number.isFinite(t)?df(t,ki,Ci):Un}catch{return Un}}function Bl(e,t){try{window.localStorage.setItem(e,t.toFixed(2))}catch{}}function Px(e){if(e<=0)return{min:ki,max:Ci};let t=Cx/e*100,s=(e-kx-Ex)/e*100,r=Math.max(ki,t),o=Math.max(r,Math.min(Ci,s));return{min:r,max:o}}function uf({primary:e,secondary:t,storageKey:s,label:r}){let[o,i]=(0,pr.useState)(()=>Tx(s)),n=(0,pr.useRef)(null),a=(0,pr.useRef)(null),h=(0,pr.useRef)(o),l=(0,pr.useRef)(),c=p=>{let b=n.current;if(b===null)return p;let x=Px(b.getBoundingClientRect().width),y=df(p,x.min,x.max);return b.style.setProperty("--ssh-sftp-width",`${y}%`),a.current?.setAttribute("aria-valuenow",String(Math.round(y))),h.current=y,y},f=p=>{if(l.current===void 0)return;let b=a.current;l.current=void 0,p!==void 0&&b?.hasPointerCapture(p)&&b.releasePointerCapture(p),n.current?.classList.remove("is-resizing");let x=h.current;i(x),Bl(s,x)},v=p=>{p.button===0&&(l.current=p.pointerId,h.current=o,p.currentTarget.setPointerCapture(p.pointerId),n.current?.classList.add("is-resizing"),p.preventDefault())},g=p=>{if(l.current!==p.pointerId)return;let b=n.current?.getBoundingClientRect();b===void 0||b.width===0||(c((b.right-p.clientX)/b.width*100),p.preventDefault())},u=p=>{let b=p.shiftKey?5:2,x;if(p.key==="ArrowLeft"&&(x=o+b),p.key==="ArrowRight"&&(x=o-b),p.key==="Home"&&(x=ki),p.key==="End"&&(x=Ci),x===void 0)return;let y=c(x);i(y),Bl(s,y),p.preventDefault()},d=()=>{let p=c(Un);i(p),Bl(s,p)},m={"--ssh-sftp-width":`${o}%`};return(0,Vn.jsxs)("div",{ref:n,className:"dsh-ssh-workbench-split",style:m,children:[e,(0,Vn.jsx)("div",{ref:a,className:"dsh-ssh-workbench-resizer",role:"separator","aria-label":r,"aria-orientation":"vertical","aria-valuemin":ki,"aria-valuemax":Ci,"aria-valuenow":Math.round(o),tabIndex:0,title:"\u62D6\u52A8\u8C03\u6574\u5BBD\u5EA6\uFF0C\u53CC\u51FB\u6062\u590D\u9ED8\u8BA4",onDoubleClick:d,onKeyDown:u,onPointerDown:v,onPointerMove:g,onPointerUp:p=>f(p.pointerId),onPointerCancel:p=>f(p.pointerId),onLostPointerCapture:()=>f()}),t]})}var Qe=require("react"),Dt=require("@deepseek-ai/dsh-client-ui-primitives");function pf(e){let t=e.port??22;if(!Number.isSafeInteger(t)||t<1||t>65535)return;let s=e.host.trim().normalize("NFKC").toLocaleLowerCase();return s.startsWith("[")&&s.endsWith("]")&&(s=s.slice(1,-1)),s=s.replace(/\.+$/u,""),s.length===0?void 0:`${s}\0${t}`}function ff(e,t,s){let r=pf(t);if(r!==void 0)return e.find(o=>o.id!==s&&pf(o)===r)}var K=require("react/jsx-runtime");function mf({profile:e,dependents:t,onClose:s,onDeleted:r}){let[o,i]=(0,Qe.useState)(!1),[n,a]=(0,Qe.useState)(),h=async()=>{if(!(o||t.length>0)){i(!0),a(void 0);try{await ie(`/profiles/${encodeURIComponent(e.id)}`,{method:"DELETE"}),r()}catch(l){a(Ie(l))}finally{i(!1)}}};return(0,K.jsx)(et,{title:`\u5220\u9664 ${e.name}`,subtitle:rs(e),onClose:s,children:(0,K.jsxs)("div",{className:"dsh-ssh-delete-profile",children:[(0,K.jsx)("span",{className:"dsh-ssh-delete-profile-mark",children:(0,K.jsx)(Dt.IconTrashOutline16,{size:19})}),(0,K.jsxs)("div",{children:[(0,K.jsx)("strong",{children:"\u8FD9\u4E2A\u64CD\u4F5C\u65E0\u6CD5\u64A4\u9500"}),(0,K.jsx)("p",{children:"\u8FDE\u63A5\u914D\u7F6E\u3001\u8BE5\u4E3B\u673A\u7684\u72EC\u7ACB\u51ED\u636E\u548C\u5173\u8054\u7AEF\u53E3\u8F6C\u53D1\u4F1A\u4E00\u5E76\u5220\u9664\uFF1B\u5B83\u4E5F\u4F1A\u4ECE\u6240\u6709\u4F1A\u8BDD\u6388\u6743\u4E2D\u79FB\u9664\u3002\u5BC6\u94A5\u5E93\u4E2D\u7684\u5171\u4EAB\u51ED\u636E\u4E0D\u4F1A\u5220\u9664\u3002"})]}),t.length>0&&(0,K.jsxs)("div",{className:"dsh-ssh-delete-profile-block",role:"alert",children:[(0,K.jsx)("strong",{children:"\u6682\u65F6\u4E0D\u80FD\u5220\u9664"}),(0,K.jsxs)("p",{children:["\u4EE5\u4E0B\u8FDE\u63A5\u4ECD\u5C06\u5B83\u4F5C\u4E3A SSH \u8DF3\u677F\uFF1A",t.map(l=>l.name).join("\u3001"),"\u3002\u8BF7\u5148\u4FEE\u6539\u8FD9\u4E9B\u8FDE\u63A5\u7684\u8DF3\u677F\u94FE\u3002"]})]}),n&&(0,K.jsx)("p",{className:"dsh-ssh-inline-error",role:"alert",children:n}),(0,K.jsxs)("div",{className:"dsh-ssh-dialog-actions",children:[(0,K.jsx)("button",{type:"button",className:"dsh-ssh-secondary-button","data-ssh-dialog-close":!0,disabled:o,onClick:s,children:"\u53D6\u6D88"}),(0,K.jsx)("button",{type:"button",className:"dsh-ssh-danger-button",disabled:o||t.length>0,onClick:()=>{h()},children:o?"\u6B63\u5728\u5220\u9664\u2026":"\u5220\u9664\u4E3B\u673A"})]})]})})}function gf({profile:e,profiles:t,vaultEntries:s,proxyEntries:r,onClose:o,onSaved:i}){let[n,a]=(0,Qe.useState)(()=>({name:e?.name??"",group:e?.group??"",host:e?.host??"",port:String(e?.port??22),username:e?.username??"",authType:e?.authType??"password",credentialId:e?.credentialId??"",proxyType:e?.proxy.type??"none",proxyEntryId:e?.proxy.type==="saved"?e.proxy.proxyId:"",proxyHost:e?.proxy.type==="http"||e?.proxy.type==="socks5"?e.proxy.host:"",proxyPort:e?.proxy.type==="http"||e?.proxy.type==="socks5"?String(e.proxy.port):"1080",proxyUsername:e?.proxy.type==="http"||e?.proxy.type==="socks5"?e.proxy.username??"":"",jumpProfileIds:e?.proxy.type==="jump"?e.proxy.profileIds:[],tags:e?.tags.join(", ")??"",password:"",privateKey:"",passphrase:"",proxyPassword:"",hostFingerprint:e?.hostFingerprint??""})),[h,l]=(0,Qe.useState)(!1),[c,f]=(0,Qe.useState)(!1),[v,g]=(0,Qe.useState)(),[u,d]=(0,Qe.useState)(),[m,p]=(0,Qe.useState)(),[b,x]=(0,Qe.useState)(),[y,S]=(0,Qe.useState)(!1),_=(0,Qe.useId)(),w=(0,Qe.useRef)(null),P=k=>({value:n[k],onChange:I=>{a(A=>({...A,[k]:I.target.value})),(k==="host"||k==="port")&&x(void 0),g(void 0),d(void 0)}}),E=s.find(k=>k.id===n.credentialId),T=(0,Qe.useMemo)(()=>t.flatMap(k=>k.group===void 0?[]:[k.group]),[t]),R=(0,Qe.useMemo)(()=>t.flatMap(k=>k.tags),[t]),M=(0,Qe.useMemo)(()=>ff(t,{host:n.host,port:Number(n.port)},e?.id),[n.host,n.port,e?.id,t]),B=y?M===void 0?b:`\u8BE5\u5730\u5740\u548C\u7AEF\u53E3\u5DF2\u7531\u201C${M.name}\u201D\u4F7F\u7528\uFF0C\u8BF7\u4FEE\u6539\u4E3B\u673A\u6216\u7AEF\u53E3\u3002`:void 0,U=(k=n.hostFingerprint)=>{let I=n.proxyType==="none"?{type:"none"}:n.proxyType==="saved"?{type:"saved",proxyId:n.proxyEntryId}:n.proxyType==="jump"?{type:"jump",profileIds:n.jumpProfileIds}:{type:n.proxyType,host:n.proxyHost,port:Number(n.proxyPort),...n.proxyUsername.trim()?{username:n.proxyUsername.trim()}:{}};return{profile:{name:n.name,...n.group.trim()?{group:n.group.trim()}:{},host:n.host,port:Number(n.port),username:E?.username??n.username,authType:E?.authType??n.authType,...n.credentialId?{credentialId:n.credentialId}:{},...k?{hostFingerprint:k}:{},proxy:I,keepAliveIntervalMs:e?.keepAliveIntervalMs??15e3,connectTimeoutMs:e?.connectTimeoutMs??15e3,terminalType:e?.terminalType??"xterm-256color",tags:n.tags.split(",").map(A=>A.trim()).filter(Boolean)},secrets:{password:n.password,privateKey:n.privateKey,passphrase:n.passphrase,proxyPassword:n.proxyPassword}}},N=async k=>{if(S(!0),M!==void 0){w.current?.focus();return}f(!0),p(void 0),g(void 0),d(void 0);try{await ie("/profiles/test-draft",{method:"POST",body:JSON.stringify({...U(k),...e===void 0?{}:{profileId:e.id}})}),k!==void 0&&a(I=>({...I,hostFingerprint:k})),g("success")}catch(I){I instanceof $t&&I.body?.code==="HOST_KEY_REQUIRED"&&typeof I.body.fingerprint=="string"?d(I.body.fingerprint):I instanceof $t&&I.body?.code==="DUPLICATE_PROFILE_ENDPOINT"?(x(Ie(I)),w.current?.focus()):p(Ie(I))}finally{f(!1)}},V=async k=>{if(k.preventDefault(),S(!0),M!==void 0){w.current?.focus();return}l(!0),p(void 0);try{await ie(e===void 0?"/profiles":`/profiles/${e.id}`,{method:e===void 0?"POST":"PUT",body:JSON.stringify(U())}),i()}catch(I){I instanceof $t&&I.body?.code==="DUPLICATE_PROFILE_ENDPOINT"?(x(Ie(I)),w.current?.focus()):p(Ie(I))}finally{l(!1)}};return(0,K.jsx)(et,{title:e===void 0?"\u65B0\u5EFA SSH \u8FDE\u63A5":`\u7F16\u8F91 ${e.name}`,subtitle:"\u51ED\u636E\u4FDD\u5B58\u540E\u4E0D\u4F1A\u56DE\u663E",onClose:o,children:(0,K.jsxs)("form",{className:"dsh-ssh-form",onSubmit:k=>{V(k)},children:[(0,K.jsxs)("div",{className:"dsh-ssh-form-section",children:[(0,K.jsxs)("div",{className:"dsh-ssh-form-section-heading",children:[(0,K.jsx)("strong",{children:"\u8FDE\u63A5\u4FE1\u606F"}),(0,K.jsx)("small",{children:"\u4E3B\u673A\u5730\u5740\u4E0E\u663E\u793A\u65B9\u5F0F"})]}),(0,K.jsxs)("div",{className:"dsh-ssh-form-grid",children:[(0,K.jsx)(ae,{label:"\u540D\u79F0",children:(0,K.jsx)("input",{required:!0,maxLength:80,placeholder:"\u5F00\u53D1\u670D\u52A1\u5668",...P("name")})}),(0,K.jsx)(ae,{label:"\u5206\u7EC4",children:(0,K.jsx)(Mr,{ariaLabel:"\u4E3B\u673A\u5206\u7EC4",maxLength:64,options:T,placeholder:"\u9009\u62E9\u5DF2\u6709\u5206\u7EC4\u6216\u8F93\u5165\u65B0\u5206\u7EC4",value:n.group,onChange:k=>a(I=>({...I,group:k}))})})]}),(0,K.jsxs)("div",{className:"dsh-ssh-form-grid is-host",children:[(0,K.jsxs)(ae,{label:"\u4E3B\u673A",children:[(0,K.jsx)("input",{ref:w,required:!0,"aria-invalid":B===void 0?void 0:!0,"aria-describedby":B===void 0?void 0:_,placeholder:"server.example.com",spellCheck:!1,...P("host"),onBlur:()=>S(!0)}),B&&(0,K.jsx)("small",{id:_,className:"dsh-ssh-field-error",role:"alert",children:B})]}),(0,K.jsx)(ae,{label:"\u7AEF\u53E3",children:(0,K.jsx)("input",{required:!0,"aria-invalid":B===void 0?void 0:!0,"aria-describedby":B===void 0?void 0:_,type:"number",inputMode:"numeric",min:"1",max:"65535",...P("port"),onBlur:()=>S(!0)})})]}),(0,K.jsx)(ae,{label:"\u6807\u7B7E",hint:"\u53EF\u9009\u62E9\u5DF2\u6709\u6807\u7B7E\u6216\u76F4\u63A5\u8F93\u5165\uFF1B\u591A\u4E2A\u6807\u7B7E\u4F7F\u7528\u9017\u53F7\u5206\u9694\u3002",children:(0,K.jsx)(Mr,{ariaLabel:"\u4E3B\u673A\u6807\u7B7E",multiple:!0,options:R,placeholder:"\u9009\u62E9\u6216\u8F93\u5165\u6807\u7B7E",value:n.tags,onChange:k=>a(I=>({...I,tags:k}))})})]}),(0,K.jsxs)("div",{className:"dsh-ssh-form-section",children:[(0,K.jsxs)("div",{className:"dsh-ssh-form-section-heading",children:[(0,K.jsx)("strong",{children:"\u8EAB\u4EFD\u8BA4\u8BC1"}),(0,K.jsx)("small",{children:"\u9009\u62E9\u5171\u4EAB\u51ED\u636E\u6216\u5355\u72EC\u4FDD\u5B58"})]}),(0,K.jsx)(ae,{label:"\u51ED\u636E\u6765\u6E90",hint:"\u53EF\u4F7F\u7528\u6B64\u8FDE\u63A5\u81EA\u5DF1\u7684\u51ED\u636E\uFF0C\u6216\u5F15\u7528\u5BC6\u94A5\u5E93\u4E2D\u7684\u5E38\u7528\u8D26\u53F7\u3002",children:(0,K.jsxs)("select",{...P("credentialId"),children:[(0,K.jsx)("option",{value:"",children:"\u6B64\u8FDE\u63A5\u72EC\u7ACB\u4FDD\u5B58"}),s.map(k=>(0,K.jsxs)("option",{value:k.id,children:[k.name," \xB7 ",k.username]},k.id))]})}),E?(0,K.jsxs)("div",{className:"dsh-ssh-credential-reference",children:[(0,K.jsx)("span",{children:(0,K.jsx)(Dt.IconUserOutline16,{size:16})}),(0,K.jsxs)("span",{children:[(0,K.jsx)("strong",{children:E.name}),(0,K.jsxs)("small",{children:[E.username," \xB7 ",E.authType==="password"?"\u5BC6\u7801":"\u79C1\u94A5"]})]}),(0,K.jsx)("em",{children:E.credential.configured?"\u5DF2\u5C31\u7EEA":"\u7F3A\u5C11\u51ED\u636E"})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)("div",{className:"dsh-ssh-form-grid",children:[(0,K.jsx)(ae,{label:"\u7528\u6237\u540D",children:(0,K.jsx)("input",{required:!0,autoComplete:"username",...P("username")})}),(0,K.jsx)(ae,{label:"\u8BA4\u8BC1\u65B9\u5F0F",children:(0,K.jsxs)("select",{...P("authType"),children:[(0,K.jsx)("option",{value:"password",children:"\u5BC6\u7801"}),(0,K.jsx)("option",{value:"private-key",children:"\u79C1\u94A5"}),(0,K.jsx)("option",{value:"agent",children:"SSH Agent"})]})})]}),n.authType==="password"&&(0,K.jsx)(ae,{label:"\u5BC6\u7801",hint:e?.credential.source==="profile"&&e.credential.fields.includes("password")?"\u5DF2\u4FDD\u5B58\uFF1B\u7559\u7A7A\u4FDD\u6301\u4E0D\u53D8":"\u4FDD\u5B58\u540E\u4E0D\u53EF\u8BFB\u56DE",children:(0,K.jsx)("input",{required:e===void 0,type:"password",autoComplete:"new-password",placeholder:e?.credential.source==="profile"&&e.credential.fields.includes("password")?"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022":"",...P("password")})}),n.authType==="private-key"&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ae,{label:"\u79C1\u94A5",hint:e?.credential.source==="profile"&&e.credential.fields.includes("privateKey")?"\u5DF2\u4FDD\u5B58\uFF1B\u7559\u7A7A\u4FDD\u6301\u4E0D\u53D8":"\u7C98\u8D34 OpenSSH/PEM \u79C1\u94A5",children:(0,K.jsx)("textarea",{required:e===void 0,rows:5,spellCheck:!1,...P("privateKey")})}),(0,K.jsx)(ae,{label:"\u79C1\u94A5\u53E3\u4EE4",children:(0,K.jsx)("input",{type:"password",autoComplete:"new-password",...P("passphrase")})})]})]})]}),(0,K.jsxs)("div",{className:"dsh-ssh-form-section",children:[(0,K.jsxs)("div",{className:"dsh-ssh-form-section-heading",children:[(0,K.jsx)("strong",{children:"\u8FDE\u63A5\u8DEF\u5F84"}),(0,K.jsx)("small",{children:"\u76F4\u8FDE\u3001\u4EE3\u7406\u6216\u8DF3\u677F\u94FE"})]}),(0,K.jsx)(ae,{label:"\u8FDE\u63A5\u65B9\u5F0F",children:(0,K.jsxs)("select",{...P("proxyType"),children:[(0,K.jsx)("option",{value:"none",children:"\u76F4\u8FDE"}),(0,K.jsx)("option",{value:"saved",children:"\u5E38\u7528\u4EE3\u7406"}),(0,K.jsx)("option",{value:"http",children:"\u81EA\u5B9A\u4E49 HTTP CONNECT"}),(0,K.jsx)("option",{value:"socks5",children:"\u81EA\u5B9A\u4E49 SOCKS5"}),(0,K.jsx)("option",{value:"jump",children:"SSH \u8DF3\u677F"})]})}),n.proxyType==="saved"&&(0,K.jsx)(ae,{label:"\u5E38\u7528\u4EE3\u7406",hint:r.length===0?"\u8BF7\u5148\u5728\u4EE3\u7406\u5E93\u4E2D\u6DFB\u52A0 HTTP \u6216 SOCKS5 \u4EE3\u7406\u3002":"\u591A\u53F0\u4E3B\u673A\u53EF\u5F15\u7528\u540C\u4E00\u6761\u4EE3\u7406\u914D\u7F6E\u3002",children:(0,K.jsxs)("select",{required:!0,...P("proxyEntryId"),children:[(0,K.jsx)("option",{value:"",children:"\u9009\u62E9\u4EE3\u7406"}),r.map(k=>(0,K.jsxs)("option",{value:k.id,children:[k.name," \xB7 ",k.proxyType==="http"?"HTTP":"SOCKS5"," \xB7 ",k.host,":",k.port]},k.id))]})}),(n.proxyType==="http"||n.proxyType==="socks5")&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)("div",{className:"dsh-ssh-form-grid is-host",children:[(0,K.jsx)(ae,{label:"\u4EE3\u7406\u4E3B\u673A",children:(0,K.jsx)("input",{required:!0,spellCheck:!1,...P("proxyHost")})}),(0,K.jsx)(ae,{label:"\u4EE3\u7406\u7AEF\u53E3",children:(0,K.jsx)("input",{required:!0,type:"number",inputMode:"numeric",min:"1",max:"65535",...P("proxyPort")})})]}),(0,K.jsxs)("div",{className:"dsh-ssh-form-grid",children:[(0,K.jsx)(ae,{label:"\u4EE3\u7406\u7528\u6237\u540D",children:(0,K.jsx)("input",{autoComplete:"username",...P("proxyUsername")})}),(0,K.jsx)(ae,{label:"\u4EE3\u7406\u5BC6\u7801",children:(0,K.jsx)("input",{type:"password",autoComplete:"new-password",...P("proxyPassword")})})]})]}),n.proxyType==="jump"&&(0,K.jsx)(Dx,{profiles:t.filter(k=>k.id!==e?.id),value:n.jumpProfileIds,onChange:k=>a(I=>({...I,jumpProfileIds:k}))})]}),u&&(0,K.jsxs)("div",{className:"dsh-ssh-test-result is-warning",role:"alert",children:[(0,K.jsxs)("span",{children:[(0,K.jsx)("strong",{children:"\u9996\u6B21\u8FDE\u63A5\uFF0C\u8BF7\u6838\u5BF9\u4E3B\u673A\u6307\u7EB9"}),(0,K.jsx)("code",{children:u})]}),(0,K.jsx)("button",{type:"button",className:"dsh-ssh-small-primary",disabled:c,onClick:()=>{N(u)},children:"\u786E\u8BA4\u5E76\u91CD\u8BD5"})]}),v==="success"&&(0,K.jsxs)("p",{className:"dsh-ssh-test-result is-success",role:"status",children:[(0,K.jsx)(Dt.IconCheckOutline14,{size:14}),"\u8FDE\u63A5\u6D4B\u8BD5\u6210\u529F"]}),m&&(0,K.jsx)("p",{className:"dsh-ssh-inline-error",role:"alert",children:m}),(0,K.jsxs)("div",{className:"dsh-ssh-dialog-actions",children:[(0,K.jsx)("button",{type:"button",className:"dsh-ssh-secondary-button dsh-ssh-test-button",disabled:h||c,onClick:k=>{k.currentTarget.form?.reportValidity()&&N()},children:c?"\u6B63\u5728\u6D4B\u8BD5\u2026":"\u6D4B\u8BD5\u8FDE\u63A5"}),(0,K.jsx)("button",{type:"button",className:"dsh-ssh-secondary-button","data-ssh-dialog-close":!0,disabled:h||c,onClick:o,children:"\u53D6\u6D88"}),(0,K.jsx)("button",{className:"dsh-ssh-primary-button",disabled:h||c,children:h?"\u6B63\u5728\u4FDD\u5B58\u2026":"\u4FDD\u5B58\u8FDE\u63A5"})]})]})})}function Dx({profiles:e,value:t,onChange:s}){let r=()=>{let n=e.find(a=>!t.includes(a.id));n!==void 0&&t.length<8&&s([...t,n.id])},o=(n,a)=>s(t.map((h,l)=>l===n?a:h)),i=(n,a)=>{let h=n+a;if(h<0||h>=t.length)return;let l=[...t];[l[n],l[h]]=[l[h],l[n]],s(l)};return(0,K.jsxs)("fieldset",{className:"dsh-ssh-jump-chain",children:[(0,K.jsx)("legend",{children:"\u8DF3\u677F\u94FE"}),(0,K.jsx)("p",{children:"\u8FDE\u63A5\u4F1A\u6309\u4ECE\u4E0A\u5230\u4E0B\u7684\u987A\u5E8F\u9010\u7EA7\u5EFA\u7ACB\u3002"}),(0,K.jsx)("div",{children:t.map((n,a)=>(0,K.jsxs)("div",{className:"dsh-ssh-jump-row",children:[(0,K.jsx)("em",{children:a+1}),(0,K.jsxs)("select",{required:!0,value:n,onChange:h=>o(a,h.target.value),children:[(0,K.jsx)("option",{value:"",children:"\u9009\u62E9\u5DF2\u6709\u8FDE\u63A5"}),e.filter(h=>h.id===n||!t.includes(h.id)).map(h=>(0,K.jsxs)("option",{value:h.id,children:[h.name," \xB7 ",h.host]},h.id))]}),(0,K.jsx)("button",{type:"button",className:"dsh-ssh-icon-button",disabled:a===0,"aria-label":"\u4E0A\u79FB\u8DF3\u677F",onClick:()=>i(a,-1),children:(0,K.jsx)(Dt.IconChevronUpOutline14,{size:14})}),(0,K.jsx)("button",{type:"button",className:"dsh-ssh-icon-button",disabled:a===t.length-1,"aria-label":"\u4E0B\u79FB\u8DF3\u677F",onClick:()=>i(a,1),children:(0,K.jsx)(Dt.IconChevronDownOutline14,{size:14})}),(0,K.jsx)("button",{type:"button",className:"dsh-ssh-icon-button is-danger","aria-label":"\u79FB\u9664\u8DF3\u677F",onClick:()=>s(t.filter((h,l)=>l!==a)),children:(0,K.jsx)(Dt.IconTrashOutline16,{size:15})})]},`${n}-${a}`))}),t.length===0&&(0,K.jsx)("p",{className:"dsh-ssh-jump-empty",children:"\u81F3\u5C11\u6DFB\u52A0\u4E00\u53F0\u8DF3\u677F\u4E3B\u673A\u3002"}),(0,K.jsxs)("button",{type:"button",className:"dsh-ssh-secondary-button",disabled:t.length>=8||e.every(n=>t.includes(n.id)),onClick:r,children:[(0,K.jsx)(Dt.IconPlusOutline16,{size:15}),"\u6DFB\u52A0\u8DF3\u677F"]})]})}var _e=require("react"),yt=require("@deepseek-ai/dsh-client-ui-primitives");var Rt=require("react"),Bt=require("@deepseek-ai/dsh-client-ui-primitives");var j=require("react/jsx-runtime");function vf({profiles:e,vaultEntries:t,proxyEntries:s,onClose:r,onChanged:o}){let[i,n]=(0,Rt.useState)(),[a,h]=(0,Rt.useState)(),[l,c]=(0,Rt.useState)(),f=i!==void 0||a!==void 0,v=m=>{h(void 0),n(m),c(void 0)},g=()=>{h(void 0),n("new"),c(void 0)},u=m=>{n(void 0),h(m),c(void 0)},d=async m=>{c(void 0);try{await ie(`/ftp-profiles/${encodeURIComponent(m.id)}`,{method:"DELETE"}),h(void 0),o()}catch(p){c(Ie(p))}};return(0,j.jsx)(et,{className:"dsh-ssh-ftp-manager-dialog",title:"\u6587\u4EF6\u8FDE\u63A5",subtitle:"\u7BA1\u7406 FTP \u4E0E FTPS\uFF1BSFTP \u76F4\u63A5\u590D\u7528\u5DF2\u6709 SSH \u4E3B\u673A",onClose:r,children:(0,j.jsxs)("div",{className:`dsh-ssh-ftp-manager${f?" has-detail":""}`,children:[(0,j.jsxs)("aside",{className:"dsh-ssh-ftp-manager-list",children:[(0,j.jsxs)("header",{children:[(0,j.jsxs)("span",{children:[(0,j.jsx)("strong",{children:"FTP / FTPS"}),(0,j.jsxs)("small",{children:[e.length," \u4E2A\u8FDE\u63A5"]})]}),(0,j.jsxs)("button",{type:"button",className:"dsh-ssh-primary-button",onClick:g,children:[(0,j.jsx)(Bt.IconPlusOutline16,{size:15}),"\u65B0\u5EFA"]})]}),e.length===0?(0,j.jsxs)("div",{className:"dsh-ssh-ftp-list-empty",children:[(0,j.jsx)("span",{children:(0,j.jsx)(Bt.IconDataOutline16,{size:20})}),(0,j.jsx)("strong",{children:"\u8FD8\u6CA1\u6709\u72EC\u7ACB\u6587\u4EF6\u8FDE\u63A5"}),(0,j.jsx)("p",{children:"SFTP \u4F1A\u663E\u793A\u5728\u6587\u4EF6\u7A97\u683C\u7684\u8FDE\u63A5\u5217\u8868\u4E2D\uFF1B\u8FD9\u91CC\u53EA\u7BA1\u7406 FTP \u4E0E FTPS\u3002"}),(0,j.jsx)("button",{type:"button",className:"dsh-ssh-secondary-button",onClick:g,children:"\u65B0\u5EFA FTPS \u8FDE\u63A5"})]}):(0,j.jsx)("div",{className:"dsh-ssh-ftp-profile-list",role:"list",children:e.map(m=>{let p=i!=="new"&&i?.id===m.id||a?.id===m.id;return(0,j.jsxs)("article",{role:"listitem","data-ssh-interactive":"choice","aria-selected":p,className:p?"is-active":"",children:[(0,j.jsxs)("button",{type:"button",className:"dsh-ssh-ftp-profile-main",onClick:()=>v(m),children:[(0,j.jsx)("span",{className:`dsh-ssh-protocol-badge is-${m.protocol}`,children:Ax(m.protocol)}),(0,j.jsxs)("span",{children:[(0,j.jsx)("strong",{title:m.name,children:m.name}),(0,j.jsxs)("small",{title:`${m.username}@${m.host}:${m.port}`,children:[m.username,"@",m.host,":",m.port]})]}),(0,j.jsx)("i",{className:m.credential.configured?"is-ready":"is-missing",children:m.credential.configured?"\u53EF\u7528":"\u7F3A\u5C11\u5BC6\u7801"})]}),(0,j.jsx)("button",{type:"button",className:"dsh-ssh-icon-button is-danger","aria-label":`\u5220\u9664 ${m.name}`,onClick:()=>u(m),children:(0,j.jsx)(Bt.IconTrashOutline16,{size:15})})]},m.id)})})]}),(0,j.jsx)("main",{className:"dsh-ssh-ftp-manager-detail",children:a!==void 0?(0,j.jsx)(Rx,{profile:a,error:l,onBack:()=>h(void 0),onDelete:()=>d(a)}):i!==void 0?(0,j.jsx)(Ix,{value:i==="new"?void 0:i,profiles:e,vaultEntries:t,proxyEntries:s,onBack:()=>n(void 0),onSaved:()=>{n(void 0),o()}},i==="new"?"new":i.id):(0,j.jsxs)("div",{className:"dsh-ssh-ftp-manager-overview",children:[(0,j.jsx)("span",{children:(0,j.jsx)(Bt.IconDataOutline16,{size:22})}),(0,j.jsx)("h3",{children:"\u9009\u62E9\u4E00\u4E2A\u8FDE\u63A5\u8FDB\u884C\u7F16\u8F91"}),(0,j.jsx)("p",{children:"\u6587\u4EF6\u7A97\u683C\u4F1A\u628A\u8FD9\u91CC\u4FDD\u5B58\u7684 FTP\u3001FTPS \u4E0E SSH \u4E3B\u673A\u63D0\u4F9B\u7684 SFTP \u6C47\u603B\u6210\u8FDE\u63A5\u5217\u8868\u3002"}),(0,j.jsxs)("dl",{children:[(0,j.jsxs)("div",{children:[(0,j.jsx)("dt",{children:"FTPS"}),(0,j.jsx)("dd",{children:"\u52A0\u5BC6\u63A7\u5236\u4E0E\u6587\u4EF6\u6570\u636E\uFF0C\u9ED8\u8BA4\u4E25\u683C\u6821\u9A8C\u8BC1\u4E66"})]}),(0,j.jsxs)("div",{children:[(0,j.jsx)("dt",{children:"FTP"}),(0,j.jsx)("dd",{children:"\u517C\u5BB9\u65E7\u670D\u52A1\u5668\uFF0C\u4F46\u8D26\u53F7\u548C\u6587\u4EF6\u5185\u5BB9\u4E0D\u52A0\u5BC6"})]}),(0,j.jsxs)("div",{children:[(0,j.jsx)("dt",{children:"SFTP"}),(0,j.jsx)("dd",{children:"\u7531 SSH \u4E3B\u673A\u7BA1\u7406\uFF0C\u4E0D\u5728\u8FD9\u91CC\u91CD\u590D\u914D\u7F6E"})]})]})]})})]})})}function Rx({profile:e,error:t,onBack:s,onDelete:r}){let[o,i]=(0,Rt.useState)(!1);return(0,j.jsxs)("div",{className:"dsh-ssh-ftp-delete-panel",children:[(0,j.jsxs)("button",{type:"button",className:"dsh-ssh-ftp-detail-back",onClick:s,children:[(0,j.jsx)(Bt.IconChevronLeftOutline14,{size:14}),"\u8FD4\u56DE\u8FDE\u63A5\u5217\u8868"]}),(0,j.jsx)("span",{className:"dsh-ssh-ftp-delete-mark",children:(0,j.jsx)(Bt.IconWarningOutline16,{size:20})}),(0,j.jsxs)("h3",{children:["\u5220\u9664\u201C",e.name,"\u201D\uFF1F"]}),(0,j.jsx)("p",{children:"\u5C06\u79FB\u9664\u8BE5 FTP/FTPS \u8FDE\u63A5\u53CA\u5176\u72EC\u7ACB\u4FDD\u5B58\u7684\u5BC6\u7801\uFF0C\u4E0D\u4F1A\u5220\u9664\u8FDC\u7AEF\u670D\u52A1\u5668\u4E0A\u7684\u4EFB\u4F55\u6587\u4EF6\u3002"}),(0,j.jsxs)("code",{children:[e.username,"@",e.host,":",e.port]}),t&&(0,j.jsx)("p",{className:"dsh-ssh-inline-error",role:"alert",children:t}),(0,j.jsxs)("div",{className:"dsh-ssh-dialog-actions",children:[(0,j.jsx)("button",{type:"button",className:"dsh-ssh-secondary-button",onClick:s,disabled:o,children:"\u53D6\u6D88"}),(0,j.jsx)("button",{type:"button",className:"dsh-ssh-danger-button",disabled:o,onClick:()=>{i(!0),r().finally(()=>i(!1))},children:o?"\u6B63\u5728\u5220\u9664\u2026":"\u5220\u9664\u8FDE\u63A5"})]})]})}function Ix({value:e,profiles:t,vaultEntries:s,proxyEntries:r,onBack:o,onSaved:i}){let n=s.filter(w=>w.authType==="password"),[a,h]=(0,Rt.useState)({name:e?.name??"",group:e?.group??"",protocol:e?.protocol??"ftps-explicit",host:e?.host??"",port:String(e?.port??21),username:e?.username??"",credentialId:e?.credentialId??"",password:"",proxyId:e?.proxy.type==="saved"?e.proxy.proxyId:"",initialPath:e?.initialPath??"/",connectTimeoutMs:String(e?.connectTimeoutMs??15e3),tlsServerName:e?.tlsServerName??"",tags:e?.tags.join(", ")??""}),[l,c]=(0,Rt.useState)(!1),[f,v]=(0,Rt.useState)(!1),[g,u]=(0,Rt.useState)(),[d,m]=(0,Rt.useState)(),p=()=>({profile:{name:a.name,...a.group.trim()?{group:a.group.trim()}:{},protocol:a.protocol,host:a.host,port:Number(a.port),username:a.username,...a.credentialId?{credentialId:a.credentialId}:{},proxy:a.proxyId?{type:"saved",proxyId:a.proxyId}:{type:"none"},initialPath:a.initialPath,connectTimeoutMs:Number(a.connectTimeoutMs),...a.tlsServerName.trim()?{tlsServerName:a.tlsServerName.trim()}:{},tags:a.tags.split(/[,,]/u).map(w=>w.trim()).filter(Boolean)},secrets:{password:a.password}}),b=async w=>{w.preventDefault(),c(!0),m(void 0),u(void 0);try{await ie(e===void 0?"/ftp-profiles":`/ftp-profiles/${encodeURIComponent(e.id)}`,{method:e===void 0?"POST":"PUT",body:JSON.stringify(p())}),i()}catch(P){m(Ie(P))}finally{c(!1)}},x=async()=>{v(!0),m(void 0),u(void 0);try{await ie("/ftp-profiles/test-draft",{method:"POST",body:JSON.stringify({...p(),...e===void 0?{}:{profileId:e.id}})}),u("\u8FDE\u63A5\u6210\u529F\uFF0C\u521D\u59CB\u76EE\u5F55\u53EF\u8BFB\u53D6")}catch(w){m(Ie(w))}finally{v(!1)}},y=w=>h(P=>({...P,protocol:w,port:P.port==="21"||P.port==="990"?String(w==="ftps-implicit"?990:21):P.port})),S=(0,Rt.useMemo)(()=>t.flatMap(w=>w.group===void 0?[]:[w.group]),[t]),_=(0,Rt.useMemo)(()=>t.flatMap(w=>w.tags),[t]);return(0,j.jsxs)("form",{className:"dsh-ssh-ftp-editor-form",onSubmit:w=>{b(w)},children:[(0,j.jsxs)("header",{className:"dsh-ssh-ftp-editor-heading",children:[(0,j.jsxs)("button",{type:"button",className:"dsh-ssh-ftp-detail-back",onClick:o,children:[(0,j.jsx)(Bt.IconChevronLeftOutline14,{size:14}),"\u8FD4\u56DE\u8FDE\u63A5\u5217\u8868"]}),(0,j.jsxs)("span",{children:[(0,j.jsx)("strong",{children:e===void 0?"\u65B0\u5EFA\u6587\u4EF6\u8FDE\u63A5":e.name}),(0,j.jsx)("small",{children:e===void 0?"\u586B\u5199\u670D\u52A1\u5668\u548C\u8BA4\u8BC1\u4FE1\u606F":"\u4FEE\u6539\u540E\u53EF\u5148\u6D4B\u8BD5\u518D\u4FDD\u5B58"})]})]}),(0,j.jsxs)("div",{className:"dsh-ssh-ftp-editor-scroll",children:[(0,j.jsxs)("section",{className:"dsh-ssh-ftp-editor-section",children:[(0,j.jsxs)("div",{className:"dsh-ssh-form-section-heading",children:[(0,j.jsx)("strong",{children:"\u8FDE\u63A5\u7C7B\u578B"}),(0,j.jsx)("small",{children:"\u4F18\u5148\u4F7F\u7528 FTPS\uFF1B\u4EC5\u5728\u670D\u52A1\u5668\u4E0D\u652F\u6301 TLS \u65F6\u9009\u62E9 FTP"})]}),(0,j.jsx)("div",{className:"dsh-ssh-ftp-protocol-options",role:"radiogroup","aria-label":"\u8FDE\u63A5\u534F\u8BAE",children:[["ftps-explicit","FTPS","\u663E\u5F0F TLS \xB7 \u63A8\u8350"],["ftps-implicit","FTPS-I","\u9690\u5F0F TLS"],["ftp","FTP","\u672A\u52A0\u5BC6"]].map(w=>(0,j.jsxs)("button",{type:"button","data-ssh-interactive":"choice",role:"radio","aria-checked":a.protocol===w[0],className:a.protocol===w[0]?"is-active":"",onClick:()=>y(w[0]),children:[(0,j.jsx)("span",{className:`dsh-ssh-protocol-badge is-${w[0]}`,children:w[1]}),(0,j.jsxs)("span",{children:[(0,j.jsx)("strong",{children:w[1]}),(0,j.jsx)("small",{children:w[2]})]})]},w[0]))}),a.protocol==="ftp"&&(0,j.jsx)("p",{className:"dsh-ssh-form-warning",children:"\u666E\u901A FTP \u7684\u8D26\u53F7\u3001\u5BC6\u7801\u548C\u6587\u4EF6\u5185\u5BB9\u5747\u4E0D\u52A0\u5BC6\u3002"})]}),(0,j.jsxs)("section",{className:"dsh-ssh-ftp-editor-section",children:[(0,j.jsxs)("div",{className:"dsh-ssh-form-section-heading",children:[(0,j.jsx)("strong",{children:"\u670D\u52A1\u5668"}),(0,j.jsx)("small",{children:"\u540D\u79F0\u7528\u4E8E\u8FDE\u63A5\u5217\u8868\uFF0C\u5206\u7EC4\u4E0E\u6807\u7B7E\u53EF\u590D\u7528\u5DF2\u6709\u9009\u9879"})]}),(0,j.jsxs)("div",{className:"dsh-ssh-form-grid",children:[(0,j.jsx)(ae,{label:"\u8FDE\u63A5\u540D\u79F0",children:(0,j.jsx)("input",{autoFocus:e===void 0,required:!0,maxLength:80,value:a.name,onChange:w=>h({...a,name:w.target.value})})}),(0,j.jsx)(ae,{label:"\u5206\u7EC4\uFF08\u53EF\u9009\uFF09",children:(0,j.jsx)(Mr,{ariaLabel:"FTP \u5206\u7EC4",maxLength:64,options:S,placeholder:"\u9009\u62E9\u5DF2\u6709\u5206\u7EC4\u6216\u8F93\u5165\u65B0\u5206\u7EC4",value:a.group,onChange:w=>h(P=>({...P,group:w}))})})]}),(0,j.jsxs)("div",{className:"dsh-ssh-form-grid is-host",children:[(0,j.jsx)(ae,{label:"\u670D\u52A1\u5668\u5730\u5740",children:(0,j.jsx)("input",{required:!0,maxLength:253,spellCheck:!1,value:a.host,onChange:w=>h({...a,host:w.target.value})})}),(0,j.jsx)(ae,{label:"\u7AEF\u53E3",children:(0,j.jsx)("input",{required:!0,type:"number",min:"1",max:"65535",value:a.port,onChange:w=>h({...a,port:w.target.value})})})]}),(0,j.jsx)(ae,{label:"\u6807\u7B7E\uFF08\u53EF\u9009\uFF09",hint:"\u53EF\u9009\u62E9\u5DF2\u6709\u6807\u7B7E\u6216\u76F4\u63A5\u8F93\u5165\uFF1B\u591A\u4E2A\u6807\u7B7E\u4F7F\u7528\u9017\u53F7\u5206\u9694\u3002",children:(0,j.jsx)(Mr,{ariaLabel:"FTP \u6807\u7B7E",multiple:!0,options:_,placeholder:"\u9009\u62E9\u6216\u8F93\u5165\u6807\u7B7E",value:a.tags,onChange:w=>h(P=>({...P,tags:w}))})})]}),(0,j.jsxs)("section",{className:"dsh-ssh-ftp-editor-section",children:[(0,j.jsxs)("div",{className:"dsh-ssh-form-section-heading",children:[(0,j.jsx)("strong",{children:"\u8EAB\u4EFD\u8BA4\u8BC1"}),(0,j.jsx)("small",{children:"\u5BC6\u7801\u53EA\u5199\u5165 DSH \u51ED\u636E\u670D\u52A1\uFF0C\u4E0D\u4F1A\u5728\u754C\u9762\u56DE\u663E"})]}),(0,j.jsxs)("div",{className:"dsh-ssh-form-grid",children:[(0,j.jsx)(ae,{label:"\u7528\u6237\u540D",children:(0,j.jsx)("input",{required:!0,maxLength:128,autoComplete:"username",value:a.username,onChange:w=>h({...a,username:w.target.value})})}),(0,j.jsx)(ae,{label:"\u51ED\u636E\u6765\u6E90",children:(0,j.jsxs)("select",{value:a.credentialId,onChange:w=>h({...a,credentialId:w.target.value}),children:[(0,j.jsx)("option",{value:"",children:"\u6B64\u8FDE\u63A5\u5355\u72EC\u4FDD\u5B58\u5BC6\u7801"}),n.map(w=>(0,j.jsxs)("option",{value:w.id,children:[w.name," \xB7 ",w.username]},w.id))]})})]}),!a.credentialId&&(0,j.jsx)(ae,{label:"\u5BC6\u7801",hint:e?.credential.configured&&e.credential.source==="profile"?"\u5DF2\u4FDD\u5B58\uFF1B\u7559\u7A7A\u4FDD\u6301\u4E0D\u53D8":"\u4FDD\u5B58\u540E\u4E0D\u4F1A\u56DE\u663E",children:(0,j.jsx)("input",{required:e===void 0||e.credential.source!=="profile"||!e.credential.configured,type:"password",autoComplete:"new-password",value:a.password,onChange:w=>h({...a,password:w.target.value})})})]}),(0,j.jsxs)("section",{className:"dsh-ssh-ftp-editor-section",children:[(0,j.jsxs)("div",{className:"dsh-ssh-form-section-heading",children:[(0,j.jsx)("strong",{children:"\u8DEF\u5F84\u4E0E\u7F51\u7EDC"}),(0,j.jsx)("small",{children:"\u4EE3\u7406\u590D\u7528 SSH \u63D2\u4EF6\u7684\u4EE3\u7406\u5E93\uFF0C\u63A7\u5236\u548C\u6570\u636E\u8FDE\u63A5\u4F7F\u7528\u540C\u4E00\u8DEF\u5F84"})]}),(0,j.jsxs)("div",{className:"dsh-ssh-form-grid",children:[(0,j.jsx)(ae,{label:"\u521D\u59CB\u76EE\u5F55",children:(0,j.jsx)("input",{required:!0,maxLength:4096,spellCheck:!1,value:a.initialPath,onChange:w=>h({...a,initialPath:w.target.value})})}),(0,j.jsx)(ae,{label:"\u8FDE\u63A5\u4EE3\u7406",children:(0,j.jsxs)("select",{value:a.proxyId,onChange:w=>h({...a,proxyId:w.target.value}),children:[(0,j.jsx)("option",{value:"",children:"\u76F4\u8FDE"}),r.map(w=>(0,j.jsxs)("option",{value:w.id,children:[w.name," \xB7 ",w.proxyType.toUpperCase()]},w.id))]})})]}),(0,j.jsxs)("details",{className:"dsh-ssh-form-advanced",children:[(0,j.jsx)("summary",{children:"\u9AD8\u7EA7\u8FDE\u63A5\u8BBE\u7F6E"}),(0,j.jsxs)("div",{className:"dsh-ssh-form-grid",children:[(0,j.jsx)(ae,{label:"\u8FDE\u63A5\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09",children:(0,j.jsx)("input",{required:!0,type:"number",min:"1000",max:"120000",step:"1000",value:a.connectTimeoutMs,onChange:w=>h({...a,connectTimeoutMs:w.target.value})})}),(0,j.jsx)(ae,{label:"TLS \u670D\u52A1\u5668\u540D\u79F0",hint:"\u8BC1\u4E66\u540D\u79F0\u4E0E\u4E3B\u673A\u4E0D\u540C\u65F6\u586B\u5199",children:(0,j.jsx)("input",{maxLength:253,spellCheck:!1,value:a.tlsServerName,onChange:w=>h({...a,tlsServerName:w.target.value})})})]})]})]}),g&&(0,j.jsx)("p",{className:"dsh-ssh-inline-success",role:"status",children:g}),d&&(0,j.jsx)("p",{className:"dsh-ssh-inline-error",role:"alert",children:d})]}),(0,j.jsxs)("footer",{className:"dsh-ssh-ftp-editor-actions",children:[(0,j.jsx)("button",{type:"button",className:"dsh-ssh-secondary-button",onClick:()=>{x()},disabled:f||l,children:f?"\u6B63\u5728\u6D4B\u8BD5\u2026":"\u6D4B\u8BD5\u8FDE\u63A5"}),(0,j.jsx)("span",{}),(0,j.jsx)("button",{type:"button",className:"dsh-ssh-secondary-button",onClick:o,disabled:l||f,children:"\u53D6\u6D88"}),(0,j.jsx)("button",{type:"submit",className:"dsh-ssh-primary-button",disabled:l||f,children:l?"\u6B63\u5728\u4FDD\u5B58\u2026":"\u4FDD\u5B58\u8FDE\u63A5"})]})]})}function Ax(e){return e==="ftp"?"FTP":e==="ftps-explicit"?"FTPS":"FTPS-I"}var Lx=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}),Nl=Lx.compare;function bf(e,t,s){let r=s==="asc"?1:-1;return e.map((o,i)=>({entry:o,index:i})).sort((o,i)=>{let n=o.entry.kind==="directory"||o.entry.navigable===!0,a=i.entry.kind==="directory"||i.entry.navigable===!0;if(n!==a)return n?-1:1;let h=Ox(o.entry,i.entry,t);if(h!==0)return h*r;let l=t==="name"?0:Nl(o.entry.name,i.entry.name);return l!==0?l:o.index-i.index}).map(o=>o.entry)}function Ox(e,t,s){return s==="name"?Nl(e.name,t.name):e[s]-t[s]}var F=require("react/jsx-runtime"),yf="dsh-ssh:file-transfer:tabs:v2",zl=38,Mx=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"});function wf({ftpProfiles:e,vaultEntries:t,proxyEntries:s,access:r,onProfilesChanged:o}){let i=dr(),[n,a]=(0,_e.useState)([]),[h,l]=(0,_e.useState)([]),[c,f]=(0,_e.useState)(()=>qx()),[v,g]=(0,_e.useState)(()=>c[0]?.id??"transfer-1"),[u,d]=(0,_e.useState)(!1),[m,p]=(0,_e.useState)(!1),[b,x]=(0,_e.useState)(),[y,S]=(0,_e.useState)(),[_,w]=(0,_e.useState)(),[P,E]=(0,_e.useState)({}),T=(0,_e.useRef)(new Map),R=(0,_e.useCallback)(async()=>{try{let A=await Xl();a(A),f(C=>Kx(C,A))}catch(A){w(Ie(A))}},[]);(0,_e.useEffect)(()=>{R()},[R,e]),(0,_e.useEffect)(()=>{try{localStorage.setItem(yf,JSON.stringify(c))}catch{}},[c]),(0,_e.useEffect)(()=>{let A=T.current,C=h.filter(H=>_f(H.state)&&A.has(H.id)&&!_f(A.get(H.id)));T.current=new Map(h.map(H=>[H.id,H.state])),C.length!==0&&E(H=>{let q={...H};for(let O of C){let J=$n(O.request.destinationEndpointId,O.request.destinationDirectory);q[J]=(q[J]??0)+1}return q})},[h]),(0,_e.useEffect)(()=>{let A=!1,C,H=async()=>{if(document.visibilityState==="hidden"){C=window.setTimeout(()=>{H()},1800);return}try{let q=await Ql();A||l(q)}catch{}A||(C=window.setTimeout(()=>{H()},800))};return H(),()=>{A=!0,C!==void 0&&clearTimeout(C)}},[]);let M=c.find(A=>A.id===v)??c[0],B=A=>f(C=>C.map(H=>H.id===M?.id?A(H):H)),U=()=>{let A=`transfer-${Date.now().toString(36)}`,C=Ul(A,c.length+1);f(H=>[...H,C]),g(A)},N=A=>{if(c.length===1)return;let C=c.findIndex(q=>q.id===A),H=c.filter(q=>q.id!==A);f(H),v===A&&g(H[Math.max(0,C-1)].id)},V=A=>B(C=>({...C,panes:Array.from({length:A},(H,q)=>C.panes[q]??jn(`${C.id}-pane-${q}`))})),k=async(A,C,H,q,O)=>{let J={endpointId:A,directory:C},z={endpointId:q,directory:O};if(!(ni(J,z)||!oi(J,H,z)))try{w(void 0);let L=await $r({sourceEndpointId:A,sourcePaths:H,destinationEndpointId:q,destinationDirectory:O,conflictPolicy:"fail"});l(X=>[L,...X.filter(G=>G.id!==L.id)])}catch(L){w(Ie(L))}},I=async(A,C,H)=>{try{w(void 0);let q=await mn(A,{paneId:C.id,endpointId:C.endpointId,directory:H});q.job!==void 0&&l(O=>[q.job,...O.filter(J=>J.id!==q.job.id)]),q.operation==="move"&&E(O=>{let J={...O};for(let z of[$n(A.endpointId,A.directory),$n(C.endpointId,H)])J[z]=(J[z]??0)+1;return J})}catch(q){w(Ie(q))}};return(0,F.jsxs)("div",{className:"dsh-ssh-transfer-workspace",children:[(0,F.jsxs)("header",{className:"dsh-ssh-transfer-header",children:[(0,F.jsxs)("div",{children:[(0,F.jsx)("h1",{children:"\u6587\u4EF6\u4F20\u8F93"}),(0,F.jsx)("p",{children:"FTP\u3001FTPS \u4E0E SFTP \u4E4B\u95F4\u76F4\u63A5\u6D41\u5F0F\u4E92\u4F20"})]}),(0,F.jsxs)("div",{className:"dsh-ssh-transfer-actions",children:[(0,F.jsxs)("button",{type:"button","data-ssh-interactive":"control",className:"dsh-ssh-secondary-button",onClick:()=>p(!0),children:["\u4F1A\u8BDD\u8BBF\u95EE \xB7 ",r.value?.fileEndpointIds.length??0]}),(0,F.jsx)("button",{type:"button","data-ssh-interactive":"control",className:"dsh-ssh-secondary-button",onClick:()=>d(!0),children:"FTP \u7BA1\u7406"})]})]}),_&&(0,F.jsxs)("div",{className:"dsh-ssh-banner is-error",role:"alert",children:[(0,F.jsx)("span",{children:_}),(0,F.jsx)("button",{type:"button",onClick:()=>w(void 0),"aria-label":"\u5173\u95ED",children:(0,F.jsx)(yt.IconCloseOutline16,{size:16})})]}),(0,F.jsxs)("section",{ref:i.ref,onPointerMove:i.onPointerMove,onPointerLeave:i.onPointerLeave,className:"dsh-ssh-transfer-stage dsh-ssh-border-surface",children:[(0,F.jsxs)("div",{className:"dsh-ssh-transfer-tabbar",role:"tablist","aria-label":"\u6587\u4EF6\u4F20\u8F93\u4EFB\u52A1\u9875",children:[(0,F.jsxs)("div",{className:"dsh-ssh-transfer-tabs",children:[c.map(A=>(0,F.jsxs)("span",{"data-ssh-interactive":"choice",className:`dsh-ssh-transfer-tab${A.id===M?.id?" is-active":""}`,children:[(0,F.jsx)("button",{type:"button",role:"tab","aria-selected":A.id===M?.id,onClick:()=>g(A.id),children:A.name}),c.length>1&&(0,F.jsx)("button",{type:"button",className:"is-close","aria-label":`\u5173\u95ED ${A.name}`,onClick:()=>N(A.id),children:(0,F.jsx)(yt.IconCloseOutline16,{size:13})})]},A.id)),(0,F.jsx)("button",{type:"button","data-ssh-interactive":"control",className:"is-add","aria-label":"\u65B0\u5EFA\u4F20\u8F93\u4EFB\u52A1\u9875",onClick:U,children:(0,F.jsx)(yt.IconPlusOutline16,{size:15})})]}),(0,F.jsx)("div",{className:"dsh-ssh-pane-layout","aria-label":"\u7A97\u683C\u6570\u91CF",children:[2,3,4].map(A=>(0,F.jsxs)("button",{type:"button","data-ssh-interactive":"choice","aria-pressed":M?.panes.length===A,className:M?.panes.length===A?"is-active":"",onClick:()=>V(A),children:[A," \u680F"]},A))})]}),n.length===0?(0,F.jsxs)("div",{className:"dsh-ssh-transfer-empty",children:[(0,F.jsx)(yt.IconDataOutline16,{size:24}),(0,F.jsx)("strong",{children:"\u8FD8\u6CA1\u6709\u53EF\u7528\u6587\u4EF6\u8FDE\u63A5"}),(0,F.jsx)("p",{children:"\u65B0\u5EFA FTP/FTPS \u8FDE\u63A5\uFF0C\u6216\u5148\u6DFB\u52A0\u4E00\u53F0 SSH \u4E3B\u673A\u4F7F\u7528 SFTP\u3002"}),(0,F.jsx)("button",{type:"button",className:"dsh-ssh-primary-button",onClick:()=>d(!0),children:"\u65B0\u5EFA FTP \u8FDE\u63A5"})]}):M&&(0,F.jsx)("div",{className:`dsh-ssh-transfer-panes has-${M.panes.length}`,children:M.panes.map((A,C)=>{let H=M.panes[(C+1)%M.panes.length];return(0,F.jsx)(Fx,{pane:A,endpoints:n,dragSource:y,refreshRevision:P[$n(A.endpointId,A.path)]??0,...H===void 0?{}:{destination:H},onManageConnections:()=>d(!0),onDragSourceChange:S,onChange:q=>B(O=>({...O,panes:O.panes.map(J=>J.id===A.id?{...J,...q}:J)})),onTransfer:(q,O)=>{k(A.endpointId,A.path,q,O.endpointId,O.path)},onExternalDrop:(q,O)=>{I(q,A,O)}},A.id)})}),(0,F.jsx)(zx,{jobs:h,endpoints:n,onCancel:async A=>{try{await Zl(A),l(C=>C.map(H=>H.id===A?{...H,state:"cancelled"}:H))}catch(C){w(Ie(C))}},onConflict:x})]}),u&&(0,F.jsx)(vf,{profiles:e,vaultEntries:t,proxyEntries:s,onClose:()=>d(!1),onChanged:()=>{o(),R()}}),m&&(0,F.jsx)(Ux,{endpoints:n,access:r,onClose:()=>p(!1)}),b&&(0,F.jsx)(Hx,{job:b,onClose:()=>x(void 0),onRetry:async A=>{try{let C=await $r({...b.request,conflictPolicy:A});l(H=>[C,...H]),x(void 0)}catch(C){w(Ie(C))}}})]})}function Fx({pane:e,endpoints:t,destination:s,dragSource:r,refreshRevision:o,onChange:i,onTransfer:n,onExternalDrop:a,onDragSourceChange:h,onManageConnections:l}){let[c,f]=(0,_e.useState)(),[v,g]=(0,_e.useState)(),[u,d]=(0,_e.useState)([]),[m,p]=(0,_e.useState)(e.path),[b,x]=(0,_e.useState)(!1),[y,S]=(0,_e.useState)(0),[_,w]=(0,_e.useState)({key:"name",direction:"asc"}),[P,E]=(0,_e.useState)(!1),[T,R]=(0,_e.useState)(),[M,B]=(0,_e.useState)(),[U,N]=(0,_e.useState)(),V=(0,_e.useRef)(null),k=(0,_e.useRef)(0),I=t.find(Z=>Z.id===e.endpointId),A=(0,_e.useMemo)(()=>bf(v?.entries??[],_.key,_.direction),[v?.entries,_]),C=A.length>200,H=C?Math.max(0,Math.floor(y/zl)-8):0,q=(0,_e.useMemo)(()=>C?A.slice(H,Math.min(A.length,H+56)):A,[A,H,C]),O=(0,_e.useCallback)(async(Z=e.path)=>{if(I===void 0)return;let me=++k.current;x(!0),N(void 0);try{let ye=await Pi(e.id,I.id,Z);if(me!==k.current)return;g(ye),p(ye.path),d([]),S(0),V.current&&(V.current.scrollTop=0),i({endpointId:I.id,path:ye.path})}catch(ye){me===k.current&&N(Ie(ye))}finally{me===k.current&&x(!1)}},[I?.id,e.path]);(0,_e.useEffect)(()=>{I!==void 0&&O(e.path)},[I?.id,o]),(0,_e.useEffect)(()=>{r===void 0&&(E(!1),R(void 0))},[r]);let J=async Z=>{if(!I)return;let me=++k.current;x(!0),N(void 0);try{let ye=await Jl(e.id,I.id,Z);if(me!==k.current)return;Ss(ye)?await O(ye.path):f(ye)}catch(ye){me===k.current&&N(Ie(ye))}finally{me===k.current&&x(!1)}};(0,_e.useEffect)(()=>{f(void 0)},[I?.id]);let z=Z=>{Z.preventDefault(),J(m)},L=Z=>{w(me=>me.key===Z?{key:Z,direction:me.direction==="asc"?"desc":"asc"}:{key:Z,direction:"asc"}),S(0),V.current&&(V.current.scrollTop=0)},X=Z=>{k.current+=1,i({endpointId:Z.id,path:Z.initialPath}),p(Z.initialPath),g(void 0),N(void 0)},G=()=>{k.current+=1,i({endpointId:"",path:"/"}),g(void 0),d([]),N(void 0),x(!1)},se=(Z,me)=>d(ye=>me?ye.includes(Z.path)?ye.filter(ce=>ce!==Z.path):[...ye,Z.path]:[Z.path]),Q=async()=>{if(!(M===void 0||v===void 0||I===void 0))try{await Vr({paneId:e.id,endpointId:I.id,directory:v.path,paths:M.map(Z=>Z.path)}),d([])}finally{await O(v.path)}},fe=Z=>{Z.preventDefault(),E(!1);let me=kr(Z.dataTransfer.getData(Ht));h(void 0),!(me===void 0||me.paneId===e.id||ni(me,{endpointId:e.endpointId,directory:e.path}))&&a(me,e.path)};return I===void 0?(0,F.jsxs)("section",{className:"dsh-ssh-file-pane is-connections",children:[(0,F.jsxs)("header",{children:[(0,F.jsxs)("span",{className:"dsh-ssh-pane-heading",children:[(0,F.jsx)("strong",{children:"\u8FDE\u63A5\u5217\u8868"}),(0,F.jsx)("small",{children:"\u5355\u51FB\u8FDE\u63A5\u540E\u6D4F\u89C8\u8FDC\u7AEF\u6587\u4EF6"})]}),(0,F.jsx)("button",{type:"button","data-ssh-interactive":"control",className:"dsh-ssh-pane-manage-button",onClick:l,children:"FTP \u7BA1\u7406"})]}),(0,F.jsx)("div",{className:"dsh-ssh-endpoint-list",children:t.map(Z=>(0,F.jsxs)("button",{type:"button","data-ssh-interactive":"row",className:"dsh-ssh-endpoint-row",onClick:()=>X(Z),children:[(0,F.jsx)("span",{className:`dsh-ssh-protocol-badge is-${Z.protocol}`,children:Vl(Z.protocol)}),(0,F.jsxs)("span",{children:[(0,F.jsx)("strong",{title:Z.name,children:Z.name}),(0,F.jsx)("small",{title:Z.address,children:Z.address})]}),(0,F.jsxs)("span",{children:[(0,F.jsx)("i",{className:`dsh-ssh-protocol-dot is-${Z.protocol}`,"aria-hidden":"true"}),Z.group??(Z.kind==="sftp"?"SSH \u4E3B\u673A":"\u6587\u4EF6\u8FDE\u63A5")]})]},Z.id))}),(0,F.jsxs)("footer",{children:[(0,F.jsxs)("span",{children:[t.length," \u4E2A\u53EF\u7528\u8FDE\u63A5"]}),(0,F.jsx)("small",{children:"SFTP \u590D\u7528 SSH \u4E3B\u673A\u914D\u7F6E"})]})]}):(0,F.jsxs)("section",{className:`dsh-ssh-file-pane${P?" is-drop-target":""}`,onDragOver:Z=>{Z.dataTransfer.types.includes(Ht)&&Xx(r,e)?(Z.preventDefault(),Z.dataTransfer.dropEffect=r?.endpointId===e.endpointId?"move":"copy",R(void 0),E(!0)):P&&E(!1)},onDragLeave:Z=>{Z.currentTarget.contains(Z.relatedTarget)||(E(!1),R(void 0))},onDrop:fe,children:[(0,F.jsxs)("header",{children:[(0,F.jsx)("button",{type:"button",className:"dsh-ssh-pane-back","aria-label":"\u8FD4\u56DE\u8FDE\u63A5\u5217\u8868",onClick:G,children:(0,F.jsx)(yt.IconChevronLeftOutline14,{size:14})}),(0,F.jsxs)("span",{className:"dsh-ssh-pane-endpoint",children:[(0,F.jsx)("strong",{children:I.name}),(0,F.jsx)("small",{title:I.address,children:I.address})]}),(0,F.jsx)("span",{className:`dsh-ssh-protocol-badge is-${I.protocol}`,children:Vl(I.protocol)})]}),(0,F.jsxs)("form",{className:"dsh-ssh-file-pathbar",onSubmit:z,children:[(0,F.jsx)("button",{type:"button","aria-label":"\u4E0A\u4E00\u7EA7\u76EE\u5F55",disabled:v?.parent===null||b,onClick:()=>{v?.parent&&O(v.parent)},children:(0,F.jsx)(ey,{})}),(0,F.jsx)("button",{type:"button","aria-label":"\u5237\u65B0\u76EE\u5F55",disabled:b,onClick:()=>{O()},children:(0,F.jsx)(ty,{})}),(0,F.jsx)("input",{"aria-label":"\u8FDC\u7AEF\u8DEF\u5F84",value:m,onChange:Z=>p(Z.target.value)}),(0,F.jsx)("button",{type:"submit",disabled:b,children:"\u524D\u5F80"})]}),(0,F.jsxs)("div",{className:"dsh-ssh-file-table",role:"grid","aria-busy":b,children:[(0,F.jsxs)("div",{className:"dsh-ssh-file-table-head",role:"row",children:[(0,F.jsx)(Hl,{label:"\u540D\u79F0",sortKey:"name",current:_,onSort:L}),(0,F.jsx)(Hl,{label:"\u5927\u5C0F",sortKey:"size",current:_,onSort:L}),(0,F.jsx)(Hl,{label:"\u4FEE\u6539\u65F6\u95F4",sortKey:"modifiedAt",current:_,onSort:L}),(0,F.jsx)("span",{role:"columnheader","aria-label":"\u64CD\u4F5C"})]}),(0,F.jsx)("div",{ref:V,className:"dsh-ssh-file-table-body",onScroll:Z=>{C&&S(Z.currentTarget.scrollTop)},children:b&&!v?(0,F.jsx)("div",{className:"dsh-ssh-file-loading",children:"\u6B63\u5728\u8BFB\u53D6\u76EE\u5F55\u2026"}):U?(0,F.jsxs)("div",{className:"dsh-ssh-file-error",children:[(0,F.jsx)("span",{children:U}),(0,F.jsx)("button",{type:"button",onClick:()=>{O()},children:"\u91CD\u8BD5"})]}):A.length===0?(0,F.jsx)("div",{className:"dsh-ssh-table-empty",children:"\u8FD9\u4E2A\u76EE\u5F55\u662F\u7A7A\u7684\u3002"}):(0,F.jsx)("div",{className:C?"dsh-ssh-file-virtual-list":void 0,style:C?{height:`${A.length*zl}px`}:void 0,children:q.map((Z,me)=>(0,F.jsx)(Nx,{entry:Z,paneId:e.id,endpointId:I.id,sourceDirectory:v?.path??e.path,dragSource:r,dropTarget:T===Z.path,selected:u.includes(Z.path),selectedPaths:u,...C?{style:{position:"absolute",insetInline:0,transform:`translateY(${(H+me)*zl}px)`}}:{},onDelete:()=>B([Z]),onDirectoryTarget:ye=>{E(!1),R(ye)},onDropIntoDirectory:(ye,ce)=>{R(void 0),h(void 0),a(ye,ce)},onDragSourceChange:h,onSelect:ye=>se(Z,ye),onOpen:()=>{J(Z.path)}},Z.path))})})]}),(0,F.jsxs)("footer",{children:[(0,F.jsx)("span",{children:u.length>0?`\u5DF2\u9009\u62E9 ${u.length} \u9879`:`${v?.entries.length??0} \u9879`}),(0,F.jsx)("span",{className:"dsh-ssh-file-pane-actions",children:(0,F.jsxs)("button",{type:"button","data-ssh-interactive":"control",className:"dsh-ssh-transfer-to-button",disabled:u.length===0||s===void 0||!s.endpointId||b,onClick:()=>{s?.endpointId&&n(u,s)},children:["\u4F20\u9001\u5230\u4E0B\u4E00\u680F ",(0,F.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]})})]}),P&&(0,F.jsxs)("div",{className:"dsh-ssh-file-drop-overlay",children:[(0,F.jsx)("strong",{children:r?.endpointId===e.endpointId?"\u79FB\u52A8\u5230\u6B64\u76EE\u5F55":"\u590D\u5236\u5230\u6B64\u76EE\u5F55"}),(0,F.jsx)("span",{children:v?.path??e.path})]}),c!==void 0&&(0,F.jsx)(et,{title:c.name,subtitle:c.path,onClose:()=>f(void 0),children:(0,F.jsx)("div",{className:"dsh-ssh-dialog-actions",children:(0,F.jsxs)("a",{className:"dsh-ssh-secondary-button",href:Jn(I.id,c.path),download:!0,children:[(0,F.jsx)(Sf,{})," \u4E0B\u8F7D\u5230\u672C\u5730"]})})}),M!==void 0&&(0,F.jsx)(Mn,{locationName:I.name,locationKind:"remote",entries:M,onClose:()=>B(void 0),onDelete:Q})]})}function Hl({label:e,sortKey:t,current:s,onSort:r}){let o=s.key===t;return(0,F.jsx)("span",{role:"columnheader","aria-sort":o?s.direction==="asc"?"ascending":"descending":"none",children:(0,F.jsxs)("button",{type:"button",onClick:()=>r(t),children:[e,(0,F.jsx)(Bx,{active:o,direction:s.direction})]})})}function Bx({active:e,direction:t}){return(0,F.jsx)("svg",{className:e?"is-active":"",viewBox:"0 0 12 12","aria-hidden":"true",children:(0,F.jsx)("path",{d:"m3.5 5 2.5 2.5L8.5 5",transform:t==="desc"?void 0:"rotate(180 6 6)"})})}function Sf(){return(0,F.jsx)("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:(0,F.jsx)("path",{d:"M8 2v7m0 0 2.6-2.6M8 9 5.4 6.4M3 11.5v1.25h10V11.5"})})}function Nx({entry:e,paneId:t,endpointId:s,sourceDirectory:r,dragSource:o,dropTarget:i,selected:n,selectedPaths:a,style:h,onSelect:l,onOpen:c,onDelete:f,onDirectoryTarget:v,onDropIntoDirectory:g,onDragSourceChange:u}){let d=Ss(e),m=s.startsWith("ftp:")&&e.navigable===void 0&&(e.kind==="symlink"||e.kind==="other"),p=!0,b=d&&(o===void 0||oi(o,o.paths,{endpointId:s,directory:e.path})),x=y=>{if(!d)return;y.preventDefault(),y.stopPropagation(),v(void 0);let S=kr(y.dataTransfer.getData(Ht));S!==void 0&&oi(S,S.paths,{endpointId:s,directory:e.path})&&g(S,e.path)};return(0,F.jsxs)("div",{role:"row","data-ssh-interactive":"row","data-ssh-context-row":!0,tabIndex:0,"aria-selected":n,"aria-label":`${e.name}${d?"\uFF0C\u76EE\u5F55\uFF0C\u5355\u51FB\u8FDB\u5165\uFF1B\u53EF\u63A5\u6536\u62D6\u653E":m?"\uFF0C\u5355\u51FB\u67E5\u770B":""}`,draggable:e.kind==="file"||d,className:`dsh-ssh-file-row is-${d?"directory":e.kind}${n?" is-selected":""}${i?" is-drop-target":""}`,style:h,onClick:y=>{p&&!y.ctrlKey&&!y.metaKey&&!y.shiftKey?c():l(y.ctrlKey||y.metaKey)},onKeyDown:y=>{y.target===y.currentTarget&&(y.key==="Enter"&&p&&c(),y.key===" "&&(y.preventDefault(),l(y.ctrlKey||y.metaKey)))},onDragStart:y=>{let S=n?a:[e.path],_={paneId:t,endpointId:s,directory:r,paths:S};u(_),y.dataTransfer.effectAllowed="copyMove",y.dataTransfer.setData(Ht,JSON.stringify(_))},onDragEnd:()=>u(void 0),onDragOver:y=>{y.dataTransfer.types.includes(Ht)&&b&&(y.preventDefault(),y.stopPropagation(),y.dataTransfer.dropEffect=o?.endpointId===s?"move":"copy",v(e.path))},onDragLeave:y=>{i&&!y.currentTarget.contains(y.relatedTarget)&&v(void 0)},onDrop:x,children:[(0,F.jsxs)("span",{children:[(0,F.jsx)(sy,{directory:d}),(0,F.jsx)("i",{title:e.name,children:e.name})]}),(0,F.jsx)("span",{children:d?"\u2014":Cf(e.size)}),(0,F.jsx)("span",{children:e.modifiedAt>0?new Date(e.modifiedAt).toLocaleString():"\u2014"}),(0,F.jsxs)("span",{className:"dsh-ssh-file-row-actions dsh-ssh-context-action",children:[(0,F.jsx)("a",{className:"dsh-ssh-file-row-download",href:Jn(s,e.path),download:!0,draggable:!1,"aria-label":`\u4E0B\u8F7D ${e.name} \u5230\u672C\u5730`,title:e.kind==="directory"?`\u5C06 ${e.name} \u6253\u5305\u4E0B\u8F7D\u5230\u672C\u5730`:`\u4E0B\u8F7D ${e.name} \u5230\u672C\u5730`,onClick:y=>y.stopPropagation(),children:(0,F.jsx)(Sf,{})}),(0,F.jsx)("button",{type:"button",className:"dsh-ssh-file-row-delete",draggable:!1,"aria-label":`\u5220\u9664 ${e.name}`,title:`\u5220\u9664 ${e.name}`,onClick:y=>{y.stopPropagation(),f()},children:(0,F.jsx)(yt.IconTrashOutline16,{size:14})})]})]})}function zx({jobs:e,endpoints:t,onCancel:s,onConflict:r}){let[o,i]=(0,_e.useState)(!0),n=e.filter(a=>a.state==="queued"||a.state==="scanning"||a.state==="transferring");return(0,F.jsxs)("section",{className:`dsh-ssh-transfer-queue${o?" is-open":""}`,children:[(0,F.jsxs)("button",{type:"button",className:"dsh-ssh-transfer-queue-heading","aria-expanded":o,title:o?"\u6536\u8D77\u4F20\u8F93\u4EFB\u52A1":"\u5C55\u5F00\u4F20\u8F93\u4EFB\u52A1",onClick:()=>i(a=>!a),children:[(0,F.jsxs)("span",{children:[(0,F.jsx)("strong",{children:"\u4F20\u8F93\u4EFB\u52A1"}),(0,F.jsx)("small",{children:n.length>0?`${n.length} \u4E2A\u8FDB\u884C\u4E2D`:e.length>0?"\u6700\u8FD1\u4EFB\u52A1":"\u6682\u65E0\u4EFB\u52A1"})]}),(0,F.jsx)("span",{className:"dsh-ssh-transfer-queue-disclosure","aria-hidden":"true",children:(0,F.jsx)(yt.IconChevronDownOutline14,{size:14})})]}),o&&(0,F.jsx)("div",{className:"dsh-ssh-transfer-job-list",children:e.length===0?(0,F.jsx)("p",{children:"\u4ECE\u4E00\u4E2A\u7A97\u683C\u62D6\u5230\u53E6\u4E00\u4E2A\u7A97\u683C\uFF0C\u6216\u9009\u4E2D\u6587\u4EF6\u540E\u70B9\u51FB\u201C\u4F20\u9001\u5230\u4E0B\u4E00\u680F\u201D\u3002"}):e.slice(0,12).map(a=>{let h=a.totalBytes>0?Math.min(100,a.transferredBytes/a.totalBytes*100):a.state==="completed"?100:0;return(0,F.jsxs)("article",{children:[(0,F.jsx)("span",{className:`dsh-ssh-transfer-state is-${a.state}`,"aria-hidden":"true"}),(0,F.jsxs)("span",{className:"dsh-ssh-transfer-job-copy",children:[(0,F.jsxs)("strong",{children:[kf(a.request.sourcePaths)," ",(0,F.jsx)("i",{children:"\u2192"})," ",Gx(t,a.request.destinationEndpointId)]}),(0,F.jsx)("small",{children:a.error??Jx(a,h)}),(0,F.jsx)("span",{className:"dsh-ssh-transfer-job-time",children:Yx(a)}),(0,F.jsx)("span",{className:"dsh-ssh-transfer-progress",children:(0,F.jsx)("i",{style:{transform:`scaleX(${h/100})`}})})]}),a.state==="queued"||a.state==="scanning"||a.state==="transferring"?(0,F.jsx)("button",{type:"button",className:"dsh-ssh-icon-button","aria-label":"\u53D6\u6D88\u4F20\u8F93",onClick:()=>{s(a.id)},children:(0,F.jsx)(yt.IconCloseOutline16,{size:15})}):a.state==="failed"&&a.error?.includes("destination already contains")?(0,F.jsx)("button",{type:"button",className:"dsh-ssh-job-resolve",onClick:()=>r(a),children:"\u5904\u7406"}):null]},a.id)})})]})}function Hx({job:e,onClose:t,onRetry:s}){let[r,o]=(0,_e.useState)("rename"),[i,n]=(0,_e.useState)(!1);return(0,F.jsxs)(et,{className:"dsh-ssh-transfer-conflict-dialog",title:"\u76EE\u6807\u4E2D\u5B58\u5728\u540C\u540D\u6587\u4EF6",subtitle:"\u4E3A\u672C\u6279\u4F20\u8F93\u9009\u62E9\u5904\u7406\u65B9\u5F0F",onClose:t,children:[(0,F.jsxs)("div",{className:"dsh-ssh-transfer-conflict-copy",children:[(0,F.jsx)("strong",{children:kf(e.request.sourcePaths)}),(0,F.jsx)("span",{children:e.request.destinationDirectory})]}),(0,F.jsx)("div",{className:"dsh-ssh-conflict-options",children:[["rename","\u81EA\u52A8\u91CD\u547D\u540D","\u4FDD\u7559\u4E24\u4EFD\u6587\u4EF6\uFF0C\u5728\u540D\u79F0\u540E\u6DFB\u52A0\u5E8F\u53F7"],["skip","\u8DF3\u8FC7\u540C\u540D\u6587\u4EF6","\u7EE7\u7EED\u4F20\u8F93\u5176\u4ED6\u5185\u5BB9"],["overwrite","\u8986\u76D6\u76EE\u6807\u6587\u4EF6","\u4F7F\u7528\u6765\u6E90\u5185\u5BB9\u66FF\u6362\u76EE\u6807\u5185\u5BB9"]].map(a=>(0,F.jsxs)("button",{type:"button","data-ssh-interactive":"choice","aria-pressed":r===a[0],className:r===a[0]?"is-active":"",onClick:()=>o(a[0]),children:[(0,F.jsx)("i",{"aria-hidden":"true"}),(0,F.jsxs)("span",{children:[(0,F.jsx)("strong",{children:a[1]}),(0,F.jsx)("small",{children:a[2]})]})]},a[0]))}),(0,F.jsxs)("div",{className:"dsh-ssh-dialog-actions",children:[(0,F.jsx)("button",{type:"button",className:"dsh-ssh-secondary-button","data-ssh-dialog-close":!0,onClick:t,children:"\u53D6\u6D88"}),(0,F.jsx)("button",{type:"button",className:"dsh-ssh-primary-button",disabled:i,onClick:()=>{n(!0),s(r).finally(()=>n(!1))},children:i?"\u6B63\u5728\u91CD\u65B0\u52A0\u5165\u961F\u5217\u2026":"\u7EE7\u7EED\u4F20\u8F93"})]})]})}function Ux({endpoints:e,access:t,onClose:s}){let r=t.value,o=e.filter(n=>r?.fileEndpointIds.includes(n.id)).length,i=n=>t.setFileEndpoints(r?.fileEndpointIds.includes(n)?r.fileEndpointIds.filter(a=>a!==n):[...r?.fileEndpointIds??[],n]);return(0,F.jsxs)(et,{className:"dsh-ssh-file-access-dialog",title:"\u4F1A\u8BDD\u8BBF\u95EE",subtitle:"\u5355\u72EC\u7BA1\u7406\u5F53\u524D\u4F1A\u8BDD\u53EF\u4F7F\u7528\u7684\u8FDC\u7AEF\u6587\u4EF6\u8FDE\u63A5",onClose:s,children:[(0,F.jsxs)("div",{className:"dsh-ssh-file-access-body dsh-ssh-scroll-surface",children:[t.error&&(0,F.jsx)("p",{className:"dsh-ssh-inline-error",role:"alert",children:t.error}),(0,F.jsxs)("section",{className:"dsh-ssh-file-access-section","aria-labelledby":"dsh-ssh-file-access-connections",children:[(0,F.jsxs)("header",{children:[(0,F.jsxs)("span",{children:[(0,F.jsx)("strong",{id:"dsh-ssh-file-access-connections",children:"\u6587\u4EF6\u8FDE\u63A5"}),(0,F.jsx)("small",{children:"\u5141\u8BB8\u5F53\u524D\u4F1A\u8BDD\u6D4F\u89C8\u6307\u5B9A\u7684 FTP\u3001FTPS \u6216 SFTP"})]}),(0,F.jsxs)("i",{children:[o.toString().padStart(2,"0")," / ",e.length.toString().padStart(2,"0")]})]}),(0,F.jsx)("div",{className:"dsh-ssh-file-access-list",children:t.loading?(0,F.jsx)($x,{}):e.length===0?(0,F.jsxs)("div",{className:"dsh-ssh-file-access-empty",children:[(0,F.jsx)("strong",{children:"\u6CA1\u6709\u53EF\u7528\u8FDE\u63A5"}),(0,F.jsx)("small",{children:"\u8BF7\u5148\u5728\u6587\u4EF6\u4F20\u8F93\u4E2D\u6DFB\u52A0 FTP\uFF0C\u6216\u5728\u4E3B\u673A\u9762\u677F\u4E2D\u6DFB\u52A0 SSH \u4E3B\u673A\u3002"})]}):e.map(n=>(0,F.jsx)(Vx,{endpoint:n,enabled:r?.fileEndpointIds.includes(n.id)??!1,onToggle:()=>i(n.id)},n.id))})]}),(0,F.jsxs)("section",{className:"dsh-ssh-file-access-section is-options","aria-labelledby":"dsh-ssh-file-access-policy",children:[(0,F.jsx)("header",{children:(0,F.jsxs)("span",{children:[(0,F.jsx)("strong",{id:"dsh-ssh-file-access-policy",children:"\u8BBF\u95EE\u7B56\u7565"}),(0,F.jsx)("small",{children:"\u6587\u4EF6\u6743\u9650\u4E0E SSH \u547D\u4EE4\u3001\u7EC8\u7AEF\u6743\u9650\u76F8\u4E92\u72EC\u7ACB"})]})}),(0,F.jsxs)("div",{className:"dsh-ssh-file-access-options",children:[(0,F.jsxs)("div",{className:"dsh-ssh-file-access-policy-row",children:[(0,F.jsxs)("span",{children:[(0,F.jsx)("strong",{children:"\u6587\u4EF6\u64CD\u4F5C\u6743\u9650"}),(0,F.jsx)("small",{children:"\u6D4F\u89C8\u6A21\u5F0F\u4E0D\u4F1A\u5411 AI \u66B4\u9732\u8DE8\u7AEF\u4F20\u8F93\u5DE5\u5177"})]}),(0,F.jsx)(jx,{value:r?.filePermission??"browse",onChange:t.setFilePermission})]}),(0,F.jsxs)("div",{className:"dsh-ssh-file-access-policy-row",children:[(0,F.jsxs)("span",{children:[(0,F.jsx)("strong",{children:"\u4F20\u8F93\u524D\u786E\u8BA4"}),(0,F.jsx)("small",{children:"AI \u53D1\u8D77\u4F20\u8F93\u65F6\u8BF7\u6C42 DSH \u6388\u6743"})]}),(0,F.jsx)(Wx,{checked:r?.requireFileApproval??!0,onChange:t.setRequireFileApproval})]})]})]})]}),(0,F.jsxs)("footer",{className:"dsh-ssh-file-access-footer",children:[(0,F.jsxs)("span",{className:t.saving?"is-saving":"is-saved",children:[(0,F.jsx)("i",{"aria-hidden":"true"}),t.saving?"\u6B63\u5728\u4FDD\u5B58\u66F4\u6539":`${o>0?`\u5DF2\u6388\u6743 ${o} \u4E2A\u8FDE\u63A5`:"\u672A\u6388\u6743\u8FDE\u63A5"} \xB7 \u81EA\u52A8\u4FDD\u5B58`]}),(0,F.jsx)("button",{type:"button",className:"dsh-ssh-primary-button","data-ssh-dialog-close":!0,disabled:t.saving,onClick:s,children:t.saving?"\u4FDD\u5B58\u4E2D\u2026":"\u5B8C\u6210"})]})]})}function Vx({endpoint:e,enabled:t,onToggle:s}){return(0,F.jsxs)("button",{type:"button","data-ssh-interactive":"choice",className:`dsh-ssh-file-access-endpoint${t?" is-mounted":""}`,"aria-pressed":t,onClick:s,children:[(0,F.jsx)("span",{className:`dsh-ssh-protocol-badge is-${e.protocol}`,children:Vl(e.protocol)}),(0,F.jsxs)("span",{className:"dsh-ssh-file-access-endpoint-copy",children:[(0,F.jsx)("strong",{title:e.name,children:e.name}),(0,F.jsx)("small",{title:e.address,children:e.address})]}),(0,F.jsxs)("span",{className:"dsh-ssh-file-access-state",children:[(0,F.jsx)("i",{"aria-hidden":"true",children:(0,F.jsx)("b",{})}),(0,F.jsx)("em",{children:t?"\u5DF2\u6388\u6743":"\u672A\u6388\u6743"})]})]})}function $x(){return(0,F.jsx)("div",{className:"dsh-ssh-file-access-skeleton","aria-label":"\u6B63\u5728\u8BFB\u53D6\u4F1A\u8BDD\u6743\u9650",children:[0,1,2].map(e=>(0,F.jsxs)("span",{style:{"--ssh-skeleton-index":e},children:[(0,F.jsx)("i",{}),(0,F.jsxs)("b",{children:[(0,F.jsx)("i",{}),(0,F.jsx)("i",{})]}),(0,F.jsx)("em",{})]},e))})}function jx({value:e,onChange:t}){return(0,F.jsx)("div",{className:"dsh-ssh-file-permission-picker",role:"radiogroup","aria-label":"\u6587\u4EF6\u64CD\u4F5C\u6743\u9650",children:[["browse","\u4EC5\u6D4F\u89C8"],["transfer","\u5141\u8BB8\u4F20\u8F93"]].map(([s,r])=>(0,F.jsx)("button",{type:"button","data-ssh-interactive":"choice",role:"radio","aria-checked":e===s,className:e===s?"is-active":"",onClick:()=>t(s),children:r},s))})}function Wx({checked:e,onChange:t}){return(0,F.jsxs)("button",{type:"button","data-ssh-interactive":"choice",role:"switch","aria-checked":e,className:`dsh-ssh-file-approval-switch${e?" is-active":""}`,onClick:()=>t(!e),children:[(0,F.jsx)("i",{"aria-hidden":"true",children:(0,F.jsx)("b",{})}),(0,F.jsx)("span",{children:e?"\u9700\u8981\u786E\u8BA4":"\u76F4\u63A5\u6267\u884C"})]})}function qx(){try{let e=JSON.parse(localStorage.getItem(yf)??"[]");if(!Array.isArray(e))return[Ul("transfer-1",1)];let t=e.slice(0,8).flatMap(s=>{if(typeof s!="object"||s===null)return[];let r=s;if(typeof r.id!="string"||!/^[a-zA-Z0-9_-]{1,100}$/.test(r.id)||typeof r.name!="string"||!Array.isArray(r.panes))return[];let o=r.panes.slice(0,4).flatMap(i=>{if(typeof i!="object"||i===null)return[];let n=i;return typeof n.id=="string"&&/^[a-zA-Z0-9_-]{1,100}$/.test(n.id)&&typeof n.endpointId=="string"&&typeof n.path=="string"?[{id:n.id,endpointId:"",path:"/"}]:[]});return o.length>=2?[{id:r.id,name:r.name.slice(0,40),panes:o}]:[]});if(t.length>0)return t}catch{}return[Ul("transfer-1",1)]}function Ul(e,t){return{id:e,name:`\u4EFB\u52A1 ${t}`,panes:[jn(`${e}-a`),jn(`${e}-b`)]}}function jn(e){return{id:e,endpointId:"",path:"/"}}function Kx(e,t){return e.map(s=>({...s,panes:s.panes.map(r=>!r.endpointId||t.some(o=>o.id===r.endpointId)?r:jn(r.id))}))}function Gx(e,t){return e.find(s=>s.id===t)?.name??t}function kf(e){let t=e[0]?.replaceAll("\\","/").split("/").filter(Boolean).at(-1)??"\u6587\u4EF6";return e.length>1?`${t} \u7B49 ${e.length} \u9879`:t}function Vl(e){return e==="sftp"?"SFTP":e==="ftp"?"FTP":e==="ftps-explicit"?"FTPS":"FTPS-I"}function $n(e,t){return JSON.stringify([e,t.replaceAll("\\","/").replace(/\/+$/,"")||"/"])}function Xx(e,t){return e===void 0||e.paneId!==t.id&&!ni(e,{endpointId:t.endpointId,directory:t.path})}function _f(e){return e==="completed"||e==="failed"||e==="cancelled"}function Cf(e){return e<1024?`${e} B`:e<1024**2?`${(e/1024).toFixed(1)} KB`:e<1024**3?`${(e/1024**2).toFixed(1)} MB`:`${(e/1024**3).toFixed(2)} GB`}function Jx(e,t){if(e.state==="queued")return"\u7B49\u5F85\u4F20\u8F93";if(e.state==="scanning")return"\u6B63\u5728\u626B\u63CF\u76EE\u5F55";if(e.state==="transferring"){let s=Math.max(1,(Date.now()-(e.startedAt??Date.now()))/1e3),r=e.transferredBytes/s,o=r>0?Math.max(0,(e.totalBytes-e.transferredBytes)/r):0;return`${t.toFixed(0)}% \xB7 ${Cf(r)}/s${o>1?` \xB7 \u7EA6 ${Zx(o)}`:""}`}return e.state==="completed"?`\u5DF2\u5B8C\u6210 ${e.completedFiles} \u4E2A\u6587\u4EF6${e.skippedFiles?`\uFF0C\u8DF3\u8FC7 ${e.skippedFiles}`:""}`:e.state==="cancelled"?"\u5DF2\u53D6\u6D88":"\u4F20\u8F93\u5931\u8D25"}function Yx(e){if(e.startedAt===void 0)return`\u521B\u5EFA\u4E8E ${xf(e.createdAt)}`;let t=e.completedAt??Date.now(),s=Qx(Math.max(0,t-e.startedAt));return e.completedAt===void 0?`\u5DF2\u6267\u884C ${s}`:`\u8017\u65F6 ${s} \xB7 \u5B8C\u6210\u4E8E ${xf(e.completedAt)}`}function xf(e){return Mx.format(e)}function Qx(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t} \u79D2`;let s=Math.floor(t/60);return s<60?`${s} \u5206 ${String(t%60).padStart(2,"0")} \u79D2`:`${Math.floor(s/60)} \u5C0F\u65F6 ${String(s%60).padStart(2,"0")} \u5206`}function Zx(e){if(e<60)return`${Math.ceil(e)} \u79D2`;let t=Math.ceil(e/60);return t<60?`${t} \u5206\u949F`:`${Math.floor(t/60)} \u5C0F\u65F6 ${t%60} \u5206\u949F`}function ey(){return(0,F.jsx)("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:(0,F.jsx)("path",{d:"M8 12V4m0 0L4.8 7.2M8 4l3.2 3.2"})})}function ty(){return(0,F.jsx)("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:(0,F.jsx)("path",{d:"M12.2 5.2A5 5 0 1 0 13 9M12.2 5.2V2.5m0 2.7H9.5"})})}function sy({directory:e}){return(0,F.jsx)("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e?(0,F.jsx)("path",{d:"M2 4.3h4l1.2 1.4H14v6.8H2z"}):(0,F.jsx)("path",{d:"M3.2 2h6l3.6 3.6V14H3.2zm6 0v3.6h3.6"})})}var Ef=`.dsh-ssh-transfer-workspace {
5514
+ `;var sf=require("react");function rf(e){(0,sf.useEffect)(()=>{let t=e.current,s=t?.parentElement;if(t==null||s===null||s===void 0)return;let r=s,o=!1,i,n=()=>{let a=t.parentElement;for(;a!==null&&a!==document.body;){let h=a.previousElementSibling;if(h instanceof HTMLElement){let l=getComputedStyle(h),c=Number.parseFloat(l.flexGrow);if(l.display==="flex"&&l.flexDirection==="column"&&c>0)return h.insertBefore(t,h.firstChild),t.dataset.dshSshAnchored="true",o=!0,!0}a=a.parentElement}return!1};return n()||(i=new MutationObserver(()=>{n()&&i?.disconnect()}),i.observe(document.body,{childList:!0,subtree:!0})),()=>{i?.disconnect(),delete t.dataset.dshSshAnchored,o&&r.isConnected&&r.append(t)}},[e])}var pt=require("react"),it=require("@deepseek-ai/dsh-client-ui-primitives");var fs=require("react"),ur=require("@deepseek-ai/dsh-client-ui-primitives"),be=require("react/jsx-runtime");function nf({profile:e,project:t,workspaces:s,currentWorkspaceId:r,recentWorkspaceId:o,returnFocus:i,onClose:n,onCreate:a}){let h=s.some(x=>String(x.workspaceId)===r)?r:s.some(x=>String(x.workspaceId)===o)?o:s[0]===void 0?void 0:String(s[0].workspaceId),[l,c]=(0,fs.useState)(h),[f,v]=(0,fs.useState)(!1),[g,u]=(0,fs.useState)(),d=(0,fs.useRef)(null),m=(0,fs.useRef)(null);(0,fs.useEffect)(()=>((d.current??m.current)?.focus(),()=>{i.isConnected&&i.focus()}),[i]);let p=()=>{f||n()},b=async x=>{if(x.preventDefault(),l!==void 0){v(!0),u(void 0);try{await a(t,l)}catch(y){u(gx(y)),v(!1)}}};return(0,be.jsx)(ur.Modal,{open:!0,onClose:p,title:"\u9009\u62E9\u4F1A\u8BDD\u5F52\u5C5E\u7A7A\u95F4",headless:!0,className:"dsh-ssh-session-create-modal",children:(0,be.jsxs)("section",{className:"dsh-ssh-session-create-shell",onKeyDown:mx,children:[(0,be.jsxs)("header",{children:[(0,be.jsxs)("span",{children:[(0,be.jsx)("h2",{children:"\u65B0\u5EFA\u8FDC\u7AEF\u4F1A\u8BDD"}),(0,be.jsx)("p",{children:"\u9009\u62E9\u8FD9\u4E2A\u4F1A\u8BDD\u5728 DSH \u4E2D\u5F52\u5C5E\u7684\u672C\u5730\u9879\u76EE"})]}),(0,be.jsx)("button",{ref:m,type:"button",className:"dsh-ssh-icon-button",disabled:f,onClick:p,"aria-label":"\u5173\u95ED",children:(0,be.jsx)(ur.IconCloseOutline16,{size:16})})]}),(0,be.jsxs)("form",{onSubmit:x=>{b(x)},children:[(0,be.jsxs)("dl",{className:"dsh-ssh-session-create-target",children:[(0,be.jsxs)("div",{children:[(0,be.jsx)("dt",{children:"\u8FDC\u7AEF\u4E3B\u673A"}),(0,be.jsxs)("dd",{children:[e.name,(0,be.jsxs)("small",{children:[e.username,"@",e.host,":",e.port]})]})]}),(0,be.jsxs)("div",{children:[(0,be.jsx)("dt",{children:"\u8FDC\u7AEF\u5DE5\u4F5C\u76EE\u5F55"}),(0,be.jsxs)("dd",{children:[t.name,(0,be.jsx)("small",{title:t.path,children:t.path})]})]})]}),(0,be.jsxs)("fieldset",{className:"dsh-ssh-workspace-picker",children:[(0,be.jsx)("legend",{children:"\u4F1A\u8BDD\u5F52\u5C5E\u7A7A\u95F4"}),(0,be.jsx)("p",{children:"\u4F1A\u8BDD\u8BB0\u5F55\u4FDD\u5B58\u5728\u6240\u9009 DSH \u9879\u76EE\u4E2D\uFF0CSSH \u547D\u4EE4\u4E0E\u7EC8\u7AEF\u56FA\u5B9A\u4F7F\u7528\u4E0A\u9762\u7684\u8FDC\u7AEF\u76EE\u5F55\u3002"}),s.length===0?(0,be.jsxs)("div",{className:"dsh-ssh-workspace-picker-empty",children:[(0,be.jsx)(ur.IconFolderClose16,{size:18}),(0,be.jsxs)("span",{children:[(0,be.jsx)("strong",{children:"\u8FD8\u6CA1\u6709\u53EF\u7528\u7684 DSH \u9879\u76EE"}),(0,be.jsx)("small",{children:"\u8BF7\u5148\u5173\u95ED\u6B64\u7A97\u53E3\uFF0C\u5728 DSH \u5DE6\u4FA7\u7A7A\u95F4\u4E2D\u65B0\u5EFA\u6216\u6DFB\u52A0\u9879\u76EE\u3002"})]})]}):(0,be.jsx)("div",{className:"dsh-ssh-workspace-options dsh-ssh-scroll-surface",role:"radiogroup","aria-label":"\u9009\u62E9 DSH \u9879\u76EE",children:s.map(x=>{let y=String(x.workspaceId),S=y===r?"\u5F53\u524D\u9879\u76EE":y===o?"\u6700\u8FD1\u4F7F\u7528":void 0;return(0,be.jsxs)("label",{className:"dsh-ssh-workspace-option",children:[(0,be.jsx)("input",{ref:y===h?d:void 0,className:"sr-only",type:"radio",name:"dsh-ssh-session-workspace",value:y,checked:l===y,disabled:f,onChange:()=>c(y)}),(0,be.jsxs)("span",{children:[(0,be.jsx)("span",{className:"dsh-ssh-workspace-option-icon",children:(0,be.jsx)(ur.IconFolderClose16,{size:16})}),(0,be.jsxs)("span",{className:"dsh-ssh-workspace-option-copy",children:[(0,be.jsx)("strong",{children:x.title}),(0,be.jsx)("small",{title:x.path,children:x.path})]}),S&&(0,be.jsx)("em",{children:S}),(0,be.jsx)("i",{"aria-hidden":"true"})]})]},y)})})]}),g&&(0,be.jsx)("p",{className:"dsh-ssh-inline-error",role:"alert",children:g}),(0,be.jsxs)("div",{className:"dsh-ssh-dialog-actions",children:[(0,be.jsx)("button",{type:"button",className:"dsh-ssh-secondary-button",disabled:f,onClick:p,children:"\u53D6\u6D88"}),(0,be.jsx)("button",{type:"submit",className:"dsh-ssh-primary-button",disabled:f||l===void 0,children:f?"\u6B63\u5728\u65B0\u5EFA\u2026":"\u65B0\u5EFA\u5E76\u6253\u5F00"})]})]})]})})}function mx(e){if(e.key!=="Tab")return;let t=Array.from(e.currentTarget.querySelectorAll('button:not(:disabled), input:not(:disabled), a[href], [tabindex]:not([tabindex="-1"])')).filter(o=>o.getClientRects().length>0),s=t[0],r=t[t.length-1];s===void 0||r===void 0||(e.shiftKey&&document.activeElement===s?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),s.focus()))}function gx(e){return e instanceof Error?e.message:String(e)}var Vt=require("react"),zn=require("@deepseek-ai/dsh-client-ui-primitives");var Ut=require("react/jsx-runtime"),vx="project-directory-picker",bx=600;function of({profileId:e,value:t,disabled:s,onChange:r}){let o=(0,Vt.useId)(),i=(0,Vt.useId)(),n=(0,Vt.useRef)(0),[a,h]=(0,Vt.useState)({kind:"idle"}),l=`sftp:${e}`,c=(0,Vt.useMemo)(()=>a.kind==="ready"?a.directory.entries.filter(Ss):[],[a]);(0,Vt.useEffect)(()=>{let v=++n.current,g=t.trim();if(g.length===0){h({kind:"idle"});return}h({kind:"checking"});let u=window.setTimeout(()=>{Pi(vx,l,g).then(d=>{v===n.current&&h({kind:"ready",directory:d})}).catch(d=>{v===n.current&&h({kind:"error",message:_x(d)})})},bx);return()=>window.clearTimeout(u)},[l,t]);let f=a.kind==="idle"?"\u53EF\u76F4\u63A5\u8F93\u5165\uFF1B\u505C\u6B62\u8F93\u5165\u540E\u4F1A\u81EA\u52A8\u68C0\u67E5\u8FDC\u7AEF\u8DEF\u5F84\u3002":a.kind==="checking"?"\u6B63\u5728\u68C0\u67E5\u8FDC\u7AEF\u8DEF\u5F84\u2026":a.kind==="error"?`\u8DEF\u5F84\u4E0D\u5B58\u5728\u6216\u65E0\u6CD5\u8BBF\u95EE\uFF1A${a.message}\u3002\u4ECD\u53EF\u6309\u5F53\u524D\u8F93\u5165\u4FDD\u5B58\u3002`:c.length===0?"\u8DEF\u5F84\u53EF\u8BBF\u95EE\uFF0C\u5F53\u524D\u6CA1\u6709\u5B50\u76EE\u5F55\u3002":`\u8DEF\u5F84\u53EF\u8BBF\u95EE\uFF0C\u627E\u5230 ${c.length} \u4E2A\u5B50\u76EE\u5F55\u3002`;return(0,Ut.jsxs)("div",{className:"dsh-ssh-field dsh-ssh-remote-path-field",children:[(0,Ut.jsx)("label",{htmlFor:o,children:"\u8FDC\u7AEF\u8DEF\u5F84"}),(0,Ut.jsx)("input",{id:o,required:!0,maxLength:4096,value:t,disabled:s,spellCheck:!1,placeholder:"/var/www/example","aria-invalid":a.kind==="error"?"true":void 0,"aria-describedby":i,onChange:v=>r(v.target.value)}),(0,Ut.jsx)("small",{id:i,className:`dsh-ssh-remote-path-feedback is-${a.kind}`,role:a.kind==="error"?"alert":"status",children:f}),a.kind==="ready"&&c.length>0&&(0,Ut.jsx)("div",{className:"dsh-ssh-remote-path-options","aria-label":"\u53EF\u9009\u62E9\u7684\u8FDC\u7AEF\u5B50\u76EE\u5F55",children:c.map(v=>(0,Ut.jsxs)("button",{type:"button",disabled:s,title:`\u9009\u62E9 ${v.path}`,onClick:()=>r(v.path),children:[(0,Ut.jsx)(zn.IconFolderClose16,{size:15,"aria-hidden":"true"}),(0,Ut.jsx)("span",{children:v.name}),(0,Ut.jsx)(zn.IconChevronRightOutline14,{size:13,"aria-hidden":"true"})]},v.path))})]})}function _x(e){return e instanceof Error?e.message:String(e)}var re=require("react/jsx-runtime");function af(e){let t=dr(),[s,r]=(0,pt.useState)(""),[o,i]=(0,pt.useState)(()=>new Set),[n,a]=(0,pt.useState)(()=>new Set),[h,l]=(0,pt.useState)({}),[c,f]=(0,pt.useState)(),[v,g]=(0,pt.useState)(),[u,d]=(0,pt.useState)(),[m,p]=(0,pt.useState)(),b=s.trim().toLocaleLowerCase(),x=(0,pt.useMemo)(()=>wx(e.profiles.filter(P=>Sx(P).includes(b))),[b,e.profiles]),y=async P=>{f(P);try{let E=await rh(P);l(T=>({...T,[P]:E})),p(void 0)}catch(E){p(Ml(E))}finally{f(E=>E===P?void 0:E)}},S=P=>{a(new Set([P])),h[P]===void 0&&y(P),e.onSelect({profileId:P,path:"~"})},_=P=>{let E=e.access?.profileIds??[],T=E.includes(P);e.onProfiles(T?E.filter(R=>R!==P):[...E,P]),T&&e.onDirectory(P,void 0)},w=P=>i(E=>{let T=new Set(E);return T.has(P)?T.delete(P):T.add(P),T});return(0,re.jsxs)("aside",{ref:t.ref,onPointerMove:t.onPointerMove,onPointerLeave:t.onPointerLeave,className:"dsh-ssh-remote-tree dsh-ssh-border-surface",children:[(0,re.jsxs)("header",{className:"dsh-ssh-tree-header",children:[(0,re.jsxs)("span",{children:[(0,re.jsx)("strong",{children:"\u4E3B\u673A\u4E0E\u9879\u76EE"}),(0,re.jsxs)("small",{children:[e.profiles.length," \u53F0\u4E3B\u673A"]})]}),(0,re.jsx)("button",{type:"button",className:"dsh-ssh-icon-button",onClick:e.onNewProfile,"aria-label":"\u65B0\u5EFA\u8FDE\u63A5",title:"\u65B0\u5EFA\u8FDE\u63A5",children:(0,re.jsx)(it.IconPlusOutline16,{size:16})})]}),(0,re.jsxs)("label",{className:"dsh-ssh-search",children:[(0,re.jsx)("span",{className:"sr-only",children:"\u641C\u7D22\u4E3B\u673A"}),(0,re.jsx)("input",{value:s,onChange:P=>r(P.target.value),placeholder:"\u641C\u7D22\u4E3B\u673A\u3001\u5206\u7EC4\u3001\u6807\u7B7E\u2026"})]}),(0,re.jsxs)("div",{className:"dsh-ssh-tree-scroll dsh-ssh-scroll-surface",children:[x.map(P=>{let E=o.has(P.name);return(0,re.jsxs)("section",{className:"dsh-ssh-tree-group","data-collapsed":E,children:[(0,re.jsx)("h3",{children:(0,re.jsxs)("button",{type:"button","aria-expanded":!E,onClick:()=>w(P.name),children:[E?(0,re.jsx)(it.IconChevronRightOutline14,{size:14}):(0,re.jsx)(it.IconChevronDownOutline14,{size:14}),(0,re.jsx)("span",{children:P.name}),(0,re.jsx)("small",{children:P.profiles.length})]})}),!E&&P.profiles.map(T=>{let R=n.has(T.id),M=e.access?.profileIds.includes(T.id)===!0,B=h[T.id]??[],U=e.selected?.profileId===T.id&&e.selected.projectId===void 0;return(0,re.jsxs)("div",{className:"dsh-ssh-tree-host","data-open":R,children:[(0,re.jsxs)("div",{"data-ssh-interactive":"row","data-ssh-context-row":!0,className:`dsh-ssh-tree-host-row${M?" is-authorized":""}${U?" is-active":""}`,children:[(0,re.jsxs)("button",{type:"button",className:"dsh-ssh-tree-host-main","aria-pressed":U,"aria-expanded":R,title:`\u9009\u62E9\u5E76\u5C55\u5F00 ${T.name}`,onClick:()=>S(T.id),children:[(0,re.jsx)("span",{className:"dsh-ssh-host-monogram",children:T.name.slice(0,1).toUpperCase()}),(0,re.jsxs)("span",{children:[(0,re.jsx)("strong",{children:T.name}),(0,re.jsxs)("small",{children:[T.username,"@",T.host]})]})]}),(0,re.jsx)("button",{type:"button","data-ssh-interactive":"choice",className:`dsh-ssh-tree-mount dsh-ssh-context-action${M?" is-mounted":""}`,"aria-label":`${M?"\u5378\u8F7D":"\u6302\u8F7D"} ${T.name}`,"aria-pressed":M,title:e.access===null?"\u6253\u5F00\u4E00\u4E2A DSH \u4F1A\u8BDD\u540E\u624D\u80FD\u6302\u8F7D\u4E3B\u673A":M?"\u4ECE\u5F53\u524D\u4F1A\u8BDD\u5378\u8F7D":"\u6302\u8F7D\u5230\u5F53\u524D\u4F1A\u8BDD",disabled:e.access===null||e.accessLoading||e.accessSaving,onClick:()=>_(T.id),children:M?"\u5378\u8F7D":"\u6302\u8F7D"}),(0,re.jsx)("button",{type:"button",className:"dsh-ssh-tree-add","aria-label":`\u4E3A ${T.name} \u6DFB\u52A0\u56FA\u5B9A\u76EE\u5F55`,title:"\u6DFB\u52A0\u56FA\u5B9A\u76EE\u5F55",onClick:()=>g({profile:T}),children:(0,re.jsx)(it.IconPlusOutline16,{size:14})})]}),R&&(0,re.jsx)("div",{className:"dsh-ssh-tree-branches",children:c===T.id&&h[T.id]===void 0?(0,re.jsx)("p",{className:"dsh-ssh-tree-state",children:"\u6B63\u5728\u8BFB\u53D6\u56FA\u5B9A\u76EE\u5F55\u2026"}):B.length===0?(0,re.jsxs)("button",{type:"button",className:"dsh-ssh-tree-empty",onClick:()=>g({profile:T}),children:[(0,re.jsx)(it.IconPlusOutline16,{size:13}),"\u6DFB\u52A0\u9879\u76EE\u76EE\u5F55"]}):B.map(N=>{let V=e.selected?.projectId===N.id,k=e.access?.workingProjectIds[T.id]===N.id;return(0,re.jsx)("div",{className:"dsh-ssh-tree-project",children:(0,re.jsxs)("div",{"data-ssh-interactive":"row",className:`dsh-ssh-tree-project-row${V?" is-active":""}${k?" is-bound":""}`,children:[(0,re.jsxs)("button",{type:"button",className:"dsh-ssh-tree-project-main","aria-pressed":e.access===null?void 0:k,title:e.access===null?"\u5F53\u524D\u6CA1\u6709\u53EF\u56FA\u5B9A\u76EE\u5F55\u7684 DSH \u4F1A\u8BDD":M?k?"\u53D6\u6D88\u5F53\u524D\u4F1A\u8BDD\u7684\u56FA\u5B9A\u76EE\u5F55":"\u56FA\u5B9A\u4E3A\u5F53\u524D\u4F1A\u8BDD\u76EE\u5F55":"\u8BF7\u5148\u6302\u8F7D\u8BE5\u4E3B\u673A",onClick:()=>{M&&!e.accessLoading&&!e.accessSaving&&(e.onDirectory(T.id,k?void 0:N.path,k?void 0:N.id),e.onSelect(k?{profileId:T.id,path:"~"}:{profileId:T.id,path:N.path,projectId:N.id}))},children:[(0,re.jsx)("span",{children:k?(0,re.jsx)(it.IconFolderOpenOutline16,{size:15}):(0,re.jsx)(it.IconFolderClose16,{size:15})}),(0,re.jsxs)("span",{children:[(0,re.jsx)("strong",{children:N.name}),(0,re.jsx)("small",{children:N.path}),k&&(0,re.jsx)("em",{children:"\u5F53\u524D\u4F1A\u8BDD\u5DF2\u56FA\u5B9A\u8BE5\u8DEF\u5F84"})]})]}),(0,re.jsx)("button",{type:"button",className:"dsh-ssh-tree-project-new","aria-label":`\u5728 ${N.name} \u65B0\u5EFA\u4F1A\u8BDD`,title:"\u65B0\u5EFA\u4F1A\u8BDD",onClick:I=>{p(void 0),d({profile:T,project:N,returnFocus:I.currentTarget})},children:(0,re.jsx)(it.IconPlusOutline16,{size:13})}),(0,re.jsx)("button",{type:"button",className:"dsh-ssh-tree-project-edit","aria-label":`\u7F16\u8F91 ${N.name}`,title:"\u7F16\u8F91\u56FA\u5B9A\u76EE\u5F55",onClick:()=>g({profile:T,project:N}),children:(0,re.jsx)(it.IconEditOutline16,{size:13})})]})},N.id)})})]},T.id)})]},P.name)}),x.length===0&&(0,re.jsx)("p",{className:"dsh-ssh-tree-no-results",children:e.profiles.length===0?"\u8FD8\u6CA1\u6709 SSH \u4E3B\u673A":"\u6CA1\u6709\u5339\u914D\u7684\u4E3B\u673A"})]}),(0,re.jsx)(xx,{access:e.access,loading:e.accessLoading,saving:e.accessSaving,error:e.accessError??m,onPermission:e.onPermission,onApproval:e.onApproval}),v!==void 0&&(0,re.jsx)(yx,{profile:v.profile,project:v.project,onClose:()=>g(void 0),onSaved:async()=>{let P=v.profile.id;g(void 0),await y(P)}}),u!==void 0&&(0,re.jsx)(nf,{...u,workspaces:e.workspaces,currentWorkspaceId:e.currentWorkspaceId,recentWorkspaceId:e.recentWorkspaceId,onClose:()=>d(void 0),onCreate:e.onCreateSession})]})}function xx({access:e,loading:t,saving:s,error:r,onPermission:o,onApproval:i}){return(0,re.jsxs)("footer",{className:"dsh-ssh-access-footer",children:[(0,re.jsxs)("div",{className:"dsh-ssh-access-heading",children:[(0,re.jsxs)("span",{children:[(0,re.jsx)("strong",{children:"\u5F53\u524D\u4F1A\u8BDD\u6743\u9650"}),(0,re.jsxs)("small",{children:[e?.profileIds.length??0," \u53F0\u4E3B\u673A\u53EF\u7528"]})]}),(0,re.jsx)("em",{children:t?"\u8BFB\u53D6\u4E2D":s?"\u4FDD\u5B58\u4E2D":"\u5DF2\u540C\u6B65"})]}),(0,re.jsxs)("div",{className:"dsh-ssh-access-segments","aria-label":"SSH \u6743\u9650",children:[(0,re.jsx)("button",{type:"button","data-ssh-interactive":"choice",className:e?.permission==="exec"?"is-active":"","aria-pressed":e?.permission==="exec",disabled:e===null,onClick:()=>o("exec"),children:"\u4EC5\u547D\u4EE4"}),(0,re.jsx)("button",{type:"button","data-ssh-interactive":"choice",className:e?.permission==="terminal"?"is-active":"","aria-pressed":e?.permission==="terminal",disabled:e===null,onClick:()=>o("terminal"),children:"\u7EC8\u7AEF\u63A7\u5236"})]}),(0,re.jsxs)("label",{className:"dsh-ssh-access-approval",children:[(0,re.jsxs)("span",{children:[(0,re.jsx)("strong",{children:"\u6267\u884C\u524D\u786E\u8BA4"}),(0,re.jsx)("small",{children:e?.requireCommandApproval===!1?"\u5173\u95ED\u540E\u6309\u5F53\u524D\u4F1A\u8BDD\u6743\u9650\u76F4\u63A5\u6267\u884C":"\u9700 DSH \u4F7F\u7528 Ask\uFF1BFull Access \u4F1A\u76F4\u63A5\u62D2\u7EDD"})]}),(0,re.jsx)("input",{type:"checkbox",checked:e?.requireCommandApproval??!0,disabled:e===null,onChange:n=>i(n.target.checked)}),(0,re.jsx)("i",{"aria-hidden":"true"})]}),r&&(0,re.jsx)("p",{className:"dsh-ssh-inline-error",role:"alert",children:r})]})}function yx({profile:e,project:t,onClose:s,onSaved:r}){let[o,i]=(0,pt.useState)(t?.name??""),[n,a]=(0,pt.useState)(t?.path??""),[h,l]=(0,pt.useState)(!1),[c,f]=(0,pt.useState)(),v=async u=>{u.preventDefault(),l(!0),f(void 0);try{t===void 0?await ih(e.id,{name:o,path:n}):await nh(e.id,t.id,{name:o,path:n}),await r()}catch(d){f(Ml(d)),l(!1)}},g=async()=>{if(!(t===void 0||!window.confirm(`\u5220\u9664\u56FA\u5B9A\u76EE\u5F55\u201C${t.name}\u201D\uFF1F\u76F8\u5173 DSH \u4F1A\u8BDD\u4E0D\u4F1A\u5220\u9664\u3002`))){l(!0),f(void 0);try{await oh(e.id,t.id),await r()}catch(u){f(Ml(u)),l(!1)}}};return(0,re.jsx)(et,{className:"dsh-ssh-project-dialog",title:t===void 0?"\u6DFB\u52A0\u56FA\u5B9A\u76EE\u5F55":"\u7F16\u8F91\u56FA\u5B9A\u76EE\u5F55",subtitle:`${e.name} \xB7 \u7EC8\u7AEF\u4E0E SFTP \u7684\u9ED8\u8BA4\u8FDC\u7AEF\u8DEF\u5F84`,onClose:s,children:(0,re.jsxs)("form",{className:"dsh-ssh-form",onSubmit:u=>{v(u)},children:[(0,re.jsxs)("label",{className:"dsh-ssh-field",children:[(0,re.jsx)("span",{children:"\u540D\u79F0"}),(0,re.jsx)("input",{required:!0,maxLength:80,value:o,placeholder:"\u7F51\u7AD9\u9879\u76EE",onChange:u=>i(u.target.value)})]}),(0,re.jsx)(of,{profileId:e.id,value:n,disabled:h,onChange:a}),c&&(0,re.jsx)("p",{className:"dsh-ssh-inline-error",role:"alert",children:c}),(0,re.jsxs)("div",{className:"dsh-ssh-dialog-actions",children:[t!==void 0&&(0,re.jsxs)("button",{type:"button",className:"dsh-ssh-danger-button",disabled:h,onClick:()=>{g()},children:[(0,re.jsx)(it.IconTrashOutline16,{size:15}),"\u5220\u9664"]}),(0,re.jsx)("span",{className:"dsh-ssh-dialog-spacer"}),(0,re.jsx)("button",{type:"button",className:"dsh-ssh-secondary-button","data-ssh-dialog-close":!0,disabled:h,onClick:s,children:"\u53D6\u6D88"}),(0,re.jsx)("button",{className:"dsh-ssh-primary-button",disabled:h,children:h?"\u4FDD\u5B58\u4E2D\u2026":"\u4FDD\u5B58\u76EE\u5F55"})]})]})})}function wx(e){let t=new Map;for(let s of e){let r=s.group?.trim()||"\u672A\u5206\u7EC4",o=t.get(r);o===void 0?t.set(r,[s]):o.push(s)}return[...t].map(([s,r])=>({name:s,profiles:r}))}function Sx(e){return`${e.name} ${e.group??""} ${e.host} ${e.username} ${e.tags.join(" ")}`.toLocaleLowerCase()}function Ml(e){return e instanceof Error?e.message:String(e)}var ft=require("react");var Fl=new Set;function Hn(e){for(let t of Fl)t(e)}function lf(e){return Fl.add(e),()=>Fl.delete(e)}function cf(e){let[t,s]=(0,ft.useState)(null),[r,o]=(0,ft.useState)(e!==void 0),[i,n]=(0,ft.useState)(!1),[a,h]=(0,ft.useState)(),l=(0,ft.useRef)(null),c=(0,ft.useRef)(e),f=(0,ft.useRef)(Promise.resolve()),v=(0,ft.useRef)(0);c.current=e,(0,ft.useEffect)(()=>{let d=!1;return l.current=null,s(null),h(void 0),o(e!==void 0),e===void 0?()=>{d=!0}:(Di(e).then(m=>{if(d)return;let p=m??Si(e);l.current=p,s(p),Hn(p)}).catch(m=>{d||h(hf(m))}).finally(()=>{d||o(!1)}),()=>{d=!0})},[e]);let g=(0,ft.useCallback)(async d=>{l.current=d,s(d),Hn(d),h(void 0),v.current+=1,n(!0);let m=f.current.catch(()=>{}).then(()=>Ri(d));f.current=m;try{let p=await m;return c.current===p.sessionId&&l.current===d&&(l.current=p,s(p),Hn(p)),p}catch(p){throw c.current===d.sessionId&&h(hf(p)),p}finally{v.current=Math.max(0,v.current-1),c.current===d.sessionId&&v.current===0&&n(!1)}},[]),u=(0,ft.useCallback)(d=>{let m=c.current;if(m===void 0)return;let p=l.current??Si(m);g({...p,...d,sessionId:m}).catch(()=>{})},[g]);return{value:t,loading:r,saving:i,error:a,setProfiles:d=>u({profileIds:d}),setDirectory:(d,m,p)=>{let b=c.current;if(b===void 0)return;let x=l.current??Si(b),y={...x.workingDirectories},S={...x.workingProjectIds};m===void 0?delete y[d]:y[d]=m,p===void 0?delete S[d]:S[d]=p,u({workingDirectories:y,workingProjectIds:S})},setPermission:d=>u({permission:d}),setRequireCommandApproval:d=>u({requireCommandApproval:d}),setFileEndpoints:d=>u({fileEndpointIds:d}),setFilePermission:d=>u({filePermission:d}),setRequireFileApproval:d=>u({requireFileApproval:d}),replace:g}}function Si(e){return{sessionId:e,profileIds:[],permission:"exec",requireCommandApproval:!0,fileEndpointIds:[],filePermission:"browse",requireFileApproval:!0,workingDirectories:{},workingProjectIds:{},updatedAt:0}}function hf(e){return e instanceof Error?e.message:String(e)}var pr=require("react"),Vn=require("react/jsx-runtime"),Un=38,ki=28,Ci=66,kx=320,Cx=280,Ex=7;function df(e,t,s){return Math.min(s,Math.max(t,e))}function Tx(e){if(typeof window>"u")return Un;try{let t=Number.parseFloat(window.localStorage.getItem(e)??"");return Number.isFinite(t)?df(t,ki,Ci):Un}catch{return Un}}function Bl(e,t){try{window.localStorage.setItem(e,t.toFixed(2))}catch{}}function Px(e){if(e<=0)return{min:ki,max:Ci};let t=Cx/e*100,s=(e-kx-Ex)/e*100,r=Math.max(ki,t),o=Math.max(r,Math.min(Ci,s));return{min:r,max:o}}function uf({primary:e,secondary:t,storageKey:s,label:r}){let[o,i]=(0,pr.useState)(()=>Tx(s)),n=(0,pr.useRef)(null),a=(0,pr.useRef)(null),h=(0,pr.useRef)(o),l=(0,pr.useRef)(),c=p=>{let b=n.current;if(b===null)return p;let x=Px(b.getBoundingClientRect().width),y=df(p,x.min,x.max);return b.style.setProperty("--ssh-sftp-width",`${y}%`),a.current?.setAttribute("aria-valuenow",String(Math.round(y))),h.current=y,y},f=p=>{if(l.current===void 0)return;let b=a.current;l.current=void 0,p!==void 0&&b?.hasPointerCapture(p)&&b.releasePointerCapture(p),n.current?.classList.remove("is-resizing");let x=h.current;i(x),Bl(s,x)},v=p=>{p.button===0&&(l.current=p.pointerId,h.current=o,p.currentTarget.setPointerCapture(p.pointerId),n.current?.classList.add("is-resizing"),p.preventDefault())},g=p=>{if(l.current!==p.pointerId)return;let b=n.current?.getBoundingClientRect();b===void 0||b.width===0||(c((b.right-p.clientX)/b.width*100),p.preventDefault())},u=p=>{let b=p.shiftKey?5:2,x;if(p.key==="ArrowLeft"&&(x=o+b),p.key==="ArrowRight"&&(x=o-b),p.key==="Home"&&(x=ki),p.key==="End"&&(x=Ci),x===void 0)return;let y=c(x);i(y),Bl(s,y),p.preventDefault()},d=()=>{let p=c(Un);i(p),Bl(s,p)},m={"--ssh-sftp-width":`${o}%`};return(0,Vn.jsxs)("div",{ref:n,className:"dsh-ssh-workbench-split",style:m,children:[e,(0,Vn.jsx)("div",{ref:a,className:"dsh-ssh-workbench-resizer",role:"separator","aria-label":r,"aria-orientation":"vertical","aria-valuemin":ki,"aria-valuemax":Ci,"aria-valuenow":Math.round(o),tabIndex:0,title:"\u62D6\u52A8\u8C03\u6574\u5BBD\u5EA6\uFF0C\u53CC\u51FB\u6062\u590D\u9ED8\u8BA4",onDoubleClick:d,onKeyDown:u,onPointerDown:v,onPointerMove:g,onPointerUp:p=>f(p.pointerId),onPointerCancel:p=>f(p.pointerId),onLostPointerCapture:()=>f()}),t]})}var Qe=require("react"),Dt=require("@deepseek-ai/dsh-client-ui-primitives");function pf(e){let t=e.port??22;if(!Number.isSafeInteger(t)||t<1||t>65535)return;let s=e.host.trim().normalize("NFKC").toLocaleLowerCase();return s.startsWith("[")&&s.endsWith("]")&&(s=s.slice(1,-1)),s=s.replace(/\.+$/u,""),s.length===0?void 0:`${s}\0${t}`}function ff(e,t,s){let r=pf(t);if(r!==void 0)return e.find(o=>o.id!==s&&pf(o)===r)}var K=require("react/jsx-runtime");function mf({profile:e,dependents:t,onClose:s,onDeleted:r}){let[o,i]=(0,Qe.useState)(!1),[n,a]=(0,Qe.useState)(),h=async()=>{if(!(o||t.length>0)){i(!0),a(void 0);try{await ie(`/profiles/${encodeURIComponent(e.id)}`,{method:"DELETE"}),r()}catch(l){a(Ie(l))}finally{i(!1)}}};return(0,K.jsx)(et,{title:`\u5220\u9664 ${e.name}`,subtitle:rs(e),onClose:s,children:(0,K.jsxs)("div",{className:"dsh-ssh-delete-profile",children:[(0,K.jsx)("span",{className:"dsh-ssh-delete-profile-mark",children:(0,K.jsx)(Dt.IconTrashOutline16,{size:19})}),(0,K.jsxs)("div",{children:[(0,K.jsx)("strong",{children:"\u8FD9\u4E2A\u64CD\u4F5C\u65E0\u6CD5\u64A4\u9500"}),(0,K.jsx)("p",{children:"\u8FDE\u63A5\u914D\u7F6E\u3001\u8BE5\u4E3B\u673A\u7684\u72EC\u7ACB\u51ED\u636E\u548C\u5173\u8054\u7AEF\u53E3\u8F6C\u53D1\u4F1A\u4E00\u5E76\u5220\u9664\uFF1B\u5B83\u4E5F\u4F1A\u4ECE\u6240\u6709\u4F1A\u8BDD\u6388\u6743\u4E2D\u79FB\u9664\u3002\u5BC6\u94A5\u5E93\u4E2D\u7684\u5171\u4EAB\u51ED\u636E\u4E0D\u4F1A\u5220\u9664\u3002"})]}),t.length>0&&(0,K.jsxs)("div",{className:"dsh-ssh-delete-profile-block",role:"alert",children:[(0,K.jsx)("strong",{children:"\u6682\u65F6\u4E0D\u80FD\u5220\u9664"}),(0,K.jsxs)("p",{children:["\u4EE5\u4E0B\u8FDE\u63A5\u4ECD\u5C06\u5B83\u4F5C\u4E3A SSH \u8DF3\u677F\uFF1A",t.map(l=>l.name).join("\u3001"),"\u3002\u8BF7\u5148\u4FEE\u6539\u8FD9\u4E9B\u8FDE\u63A5\u7684\u8DF3\u677F\u94FE\u3002"]})]}),n&&(0,K.jsx)("p",{className:"dsh-ssh-inline-error",role:"alert",children:n}),(0,K.jsxs)("div",{className:"dsh-ssh-dialog-actions",children:[(0,K.jsx)("button",{type:"button",className:"dsh-ssh-secondary-button","data-ssh-dialog-close":!0,disabled:o,onClick:s,children:"\u53D6\u6D88"}),(0,K.jsx)("button",{type:"button",className:"dsh-ssh-danger-button",disabled:o||t.length>0,onClick:()=>{h()},children:o?"\u6B63\u5728\u5220\u9664\u2026":"\u5220\u9664\u4E3B\u673A"})]})]})})}function gf({profile:e,profiles:t,vaultEntries:s,proxyEntries:r,onClose:o,onSaved:i}){let[n,a]=(0,Qe.useState)(()=>({name:e?.name??"",group:e?.group??"",host:e?.host??"",port:String(e?.port??22),username:e?.username??"",authType:e?.authType??"password",credentialId:e?.credentialId??"",proxyType:e?.proxy.type??"none",proxyEntryId:e?.proxy.type==="saved"?e.proxy.proxyId:"",proxyHost:e?.proxy.type==="http"||e?.proxy.type==="socks5"?e.proxy.host:"",proxyPort:e?.proxy.type==="http"||e?.proxy.type==="socks5"?String(e.proxy.port):"1080",proxyUsername:e?.proxy.type==="http"||e?.proxy.type==="socks5"?e.proxy.username??"":"",jumpProfileIds:e?.proxy.type==="jump"?e.proxy.profileIds:[],tags:e?.tags.join(", ")??"",password:"",privateKey:"",passphrase:"",proxyPassword:"",hostFingerprint:e?.hostFingerprint??""})),[h,l]=(0,Qe.useState)(!1),[c,f]=(0,Qe.useState)(!1),[v,g]=(0,Qe.useState)(),[u,d]=(0,Qe.useState)(),[m,p]=(0,Qe.useState)(),[b,x]=(0,Qe.useState)(),[y,S]=(0,Qe.useState)(!1),_=(0,Qe.useId)(),w=(0,Qe.useRef)(null),P=k=>({value:n[k],onChange:I=>{a(A=>({...A,[k]:I.target.value})),(k==="host"||k==="port")&&x(void 0),g(void 0),d(void 0)}}),E=s.find(k=>k.id===n.credentialId),T=(0,Qe.useMemo)(()=>t.flatMap(k=>k.group===void 0?[]:[k.group]),[t]),R=(0,Qe.useMemo)(()=>t.flatMap(k=>k.tags),[t]),M=(0,Qe.useMemo)(()=>ff(t,{host:n.host,port:Number(n.port)},e?.id),[n.host,n.port,e?.id,t]),B=y?M===void 0?b:`\u8BE5\u5730\u5740\u548C\u7AEF\u53E3\u5DF2\u7531\u201C${M.name}\u201D\u4F7F\u7528\uFF0C\u8BF7\u4FEE\u6539\u4E3B\u673A\u6216\u7AEF\u53E3\u3002`:void 0,U=(k=n.hostFingerprint)=>{let I=n.proxyType==="none"?{type:"none"}:n.proxyType==="saved"?{type:"saved",proxyId:n.proxyEntryId}:n.proxyType==="jump"?{type:"jump",profileIds:n.jumpProfileIds}:{type:n.proxyType,host:n.proxyHost,port:Number(n.proxyPort),...n.proxyUsername.trim()?{username:n.proxyUsername.trim()}:{}};return{profile:{name:n.name,...n.group.trim()?{group:n.group.trim()}:{},host:n.host,port:Number(n.port),username:E?.username??n.username,authType:E?.authType??n.authType,...n.credentialId?{credentialId:n.credentialId}:{},...k?{hostFingerprint:k}:{},proxy:I,keepAliveIntervalMs:e?.keepAliveIntervalMs??15e3,connectTimeoutMs:e?.connectTimeoutMs??15e3,terminalType:e?.terminalType??"xterm-256color",tags:n.tags.split(",").map(A=>A.trim()).filter(Boolean)},secrets:{password:n.password,privateKey:n.privateKey,passphrase:n.passphrase,proxyPassword:n.proxyPassword}}},N=async k=>{if(S(!0),M!==void 0){w.current?.focus();return}f(!0),p(void 0),g(void 0),d(void 0);try{await ie("/profiles/test-draft",{method:"POST",body:JSON.stringify({...U(k),...e===void 0?{}:{profileId:e.id}})}),k!==void 0&&a(I=>({...I,hostFingerprint:k})),g("success")}catch(I){I instanceof $t&&I.body?.code==="HOST_KEY_REQUIRED"&&typeof I.body.fingerprint=="string"?d(I.body.fingerprint):I instanceof $t&&I.body?.code==="DUPLICATE_PROFILE_ENDPOINT"?(x(Ie(I)),w.current?.focus()):p(Ie(I))}finally{f(!1)}},V=async k=>{if(k.preventDefault(),S(!0),M!==void 0){w.current?.focus();return}l(!0),p(void 0);try{await ie(e===void 0?"/profiles":`/profiles/${e.id}`,{method:e===void 0?"POST":"PUT",body:JSON.stringify(U())}),i()}catch(I){I instanceof $t&&I.body?.code==="DUPLICATE_PROFILE_ENDPOINT"?(x(Ie(I)),w.current?.focus()):p(Ie(I))}finally{l(!1)}};return(0,K.jsx)(et,{title:e===void 0?"\u65B0\u5EFA SSH \u8FDE\u63A5":`\u7F16\u8F91 ${e.name}`,subtitle:"\u51ED\u636E\u4FDD\u5B58\u540E\u4E0D\u4F1A\u56DE\u663E",onClose:o,children:(0,K.jsxs)("form",{className:"dsh-ssh-form",onSubmit:k=>{V(k)},children:[(0,K.jsxs)("div",{className:"dsh-ssh-form-section",children:[(0,K.jsxs)("div",{className:"dsh-ssh-form-section-heading",children:[(0,K.jsx)("strong",{children:"\u8FDE\u63A5\u4FE1\u606F"}),(0,K.jsx)("small",{children:"\u4E3B\u673A\u5730\u5740\u4E0E\u663E\u793A\u65B9\u5F0F"})]}),(0,K.jsxs)("div",{className:"dsh-ssh-form-grid",children:[(0,K.jsx)(ae,{label:"\u540D\u79F0",children:(0,K.jsx)("input",{required:!0,maxLength:80,placeholder:"\u5F00\u53D1\u670D\u52A1\u5668",...P("name")})}),(0,K.jsx)(ae,{label:"\u5206\u7EC4",children:(0,K.jsx)(Mr,{ariaLabel:"\u4E3B\u673A\u5206\u7EC4",maxLength:64,options:T,placeholder:"\u9009\u62E9\u5DF2\u6709\u5206\u7EC4\u6216\u8F93\u5165\u65B0\u5206\u7EC4",value:n.group,onChange:k=>a(I=>({...I,group:k}))})})]}),(0,K.jsxs)("div",{className:"dsh-ssh-form-grid is-host",children:[(0,K.jsxs)(ae,{label:"\u4E3B\u673A",children:[(0,K.jsx)("input",{ref:w,required:!0,"aria-invalid":B===void 0?void 0:!0,"aria-describedby":B===void 0?void 0:_,placeholder:"server.example.com",spellCheck:!1,...P("host"),onBlur:()=>S(!0)}),B&&(0,K.jsx)("small",{id:_,className:"dsh-ssh-field-error",role:"alert",children:B})]}),(0,K.jsx)(ae,{label:"\u7AEF\u53E3",children:(0,K.jsx)("input",{required:!0,"aria-invalid":B===void 0?void 0:!0,"aria-describedby":B===void 0?void 0:_,type:"number",inputMode:"numeric",min:"1",max:"65535",...P("port"),onBlur:()=>S(!0)})})]}),(0,K.jsx)(ae,{label:"\u6807\u7B7E",hint:"\u53EF\u9009\u62E9\u5DF2\u6709\u6807\u7B7E\u6216\u76F4\u63A5\u8F93\u5165\uFF1B\u591A\u4E2A\u6807\u7B7E\u4F7F\u7528\u9017\u53F7\u5206\u9694\u3002",children:(0,K.jsx)(Mr,{ariaLabel:"\u4E3B\u673A\u6807\u7B7E",multiple:!0,options:R,placeholder:"\u9009\u62E9\u6216\u8F93\u5165\u6807\u7B7E",value:n.tags,onChange:k=>a(I=>({...I,tags:k}))})})]}),(0,K.jsxs)("div",{className:"dsh-ssh-form-section",children:[(0,K.jsxs)("div",{className:"dsh-ssh-form-section-heading",children:[(0,K.jsx)("strong",{children:"\u8EAB\u4EFD\u8BA4\u8BC1"}),(0,K.jsx)("small",{children:"\u9009\u62E9\u5171\u4EAB\u51ED\u636E\u6216\u5355\u72EC\u4FDD\u5B58"})]}),(0,K.jsx)(ae,{label:"\u51ED\u636E\u6765\u6E90",hint:"\u53EF\u4F7F\u7528\u6B64\u8FDE\u63A5\u81EA\u5DF1\u7684\u51ED\u636E\uFF0C\u6216\u5F15\u7528\u5BC6\u94A5\u5E93\u4E2D\u7684\u5E38\u7528\u8D26\u53F7\u3002",children:(0,K.jsxs)("select",{...P("credentialId"),children:[(0,K.jsx)("option",{value:"",children:"\u6B64\u8FDE\u63A5\u72EC\u7ACB\u4FDD\u5B58"}),s.map(k=>(0,K.jsxs)("option",{value:k.id,children:[k.name," \xB7 ",k.username]},k.id))]})}),E?(0,K.jsxs)("div",{className:"dsh-ssh-credential-reference",children:[(0,K.jsx)("span",{children:(0,K.jsx)(Dt.IconUserOutline16,{size:16})}),(0,K.jsxs)("span",{children:[(0,K.jsx)("strong",{children:E.name}),(0,K.jsxs)("small",{children:[E.username," \xB7 ",E.authType==="password"?"\u5BC6\u7801":"\u79C1\u94A5"]})]}),(0,K.jsx)("em",{children:E.credential.configured?"\u5DF2\u5C31\u7EEA":"\u7F3A\u5C11\u51ED\u636E"})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)("div",{className:"dsh-ssh-form-grid",children:[(0,K.jsx)(ae,{label:"\u7528\u6237\u540D",children:(0,K.jsx)("input",{required:!0,autoComplete:"username",...P("username")})}),(0,K.jsx)(ae,{label:"\u8BA4\u8BC1\u65B9\u5F0F",children:(0,K.jsxs)("select",{...P("authType"),children:[(0,K.jsx)("option",{value:"password",children:"\u5BC6\u7801"}),(0,K.jsx)("option",{value:"private-key",children:"\u79C1\u94A5"}),(0,K.jsx)("option",{value:"agent",children:"SSH Agent"})]})})]}),n.authType==="password"&&(0,K.jsx)(ae,{label:"\u5BC6\u7801",hint:e?.credential.source==="profile"&&e.credential.fields.includes("password")?"\u5DF2\u4FDD\u5B58\uFF1B\u7559\u7A7A\u4FDD\u6301\u4E0D\u53D8":"\u4FDD\u5B58\u540E\u4E0D\u53EF\u8BFB\u56DE",children:(0,K.jsx)("input",{required:e===void 0,type:"password",autoComplete:"new-password",placeholder:e?.credential.source==="profile"&&e.credential.fields.includes("password")?"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022":"",...P("password")})}),n.authType==="private-key"&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ae,{label:"\u79C1\u94A5",hint:e?.credential.source==="profile"&&e.credential.fields.includes("privateKey")?"\u5DF2\u4FDD\u5B58\uFF1B\u7559\u7A7A\u4FDD\u6301\u4E0D\u53D8":"\u7C98\u8D34 OpenSSH/PEM \u79C1\u94A5",children:(0,K.jsx)("textarea",{required:e===void 0,rows:5,spellCheck:!1,...P("privateKey")})}),(0,K.jsx)(ae,{label:"\u79C1\u94A5\u53E3\u4EE4",children:(0,K.jsx)("input",{type:"password",autoComplete:"new-password",...P("passphrase")})})]})]})]}),(0,K.jsxs)("div",{className:"dsh-ssh-form-section",children:[(0,K.jsxs)("div",{className:"dsh-ssh-form-section-heading",children:[(0,K.jsx)("strong",{children:"\u8FDE\u63A5\u8DEF\u5F84"}),(0,K.jsx)("small",{children:"\u76F4\u8FDE\u3001\u4EE3\u7406\u6216\u8DF3\u677F\u94FE"})]}),(0,K.jsx)(ae,{label:"\u8FDE\u63A5\u65B9\u5F0F",children:(0,K.jsxs)("select",{...P("proxyType"),children:[(0,K.jsx)("option",{value:"none",children:"\u76F4\u8FDE"}),(0,K.jsx)("option",{value:"saved",children:"\u5E38\u7528\u4EE3\u7406"}),(0,K.jsx)("option",{value:"http",children:"\u81EA\u5B9A\u4E49 HTTP CONNECT"}),(0,K.jsx)("option",{value:"socks5",children:"\u81EA\u5B9A\u4E49 SOCKS5"}),(0,K.jsx)("option",{value:"jump",children:"SSH \u8DF3\u677F"})]})}),n.proxyType==="saved"&&(0,K.jsx)(ae,{label:"\u5E38\u7528\u4EE3\u7406",hint:r.length===0?"\u8BF7\u5148\u5728\u4EE3\u7406\u5E93\u4E2D\u6DFB\u52A0 HTTP \u6216 SOCKS5 \u4EE3\u7406\u3002":"\u591A\u53F0\u4E3B\u673A\u53EF\u5F15\u7528\u540C\u4E00\u6761\u4EE3\u7406\u914D\u7F6E\u3002",children:(0,K.jsxs)("select",{required:!0,...P("proxyEntryId"),children:[(0,K.jsx)("option",{value:"",children:"\u9009\u62E9\u4EE3\u7406"}),r.map(k=>(0,K.jsxs)("option",{value:k.id,children:[k.name," \xB7 ",k.proxyType==="http"?"HTTP":"SOCKS5"," \xB7 ",k.host,":",k.port]},k.id))]})}),(n.proxyType==="http"||n.proxyType==="socks5")&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)("div",{className:"dsh-ssh-form-grid is-host",children:[(0,K.jsx)(ae,{label:"\u4EE3\u7406\u4E3B\u673A",children:(0,K.jsx)("input",{required:!0,spellCheck:!1,...P("proxyHost")})}),(0,K.jsx)(ae,{label:"\u4EE3\u7406\u7AEF\u53E3",children:(0,K.jsx)("input",{required:!0,type:"number",inputMode:"numeric",min:"1",max:"65535",...P("proxyPort")})})]}),(0,K.jsxs)("div",{className:"dsh-ssh-form-grid",children:[(0,K.jsx)(ae,{label:"\u4EE3\u7406\u7528\u6237\u540D",children:(0,K.jsx)("input",{autoComplete:"username",...P("proxyUsername")})}),(0,K.jsx)(ae,{label:"\u4EE3\u7406\u5BC6\u7801",children:(0,K.jsx)("input",{type:"password",autoComplete:"new-password",...P("proxyPassword")})})]})]}),n.proxyType==="jump"&&(0,K.jsx)(Dx,{profiles:t.filter(k=>k.id!==e?.id),value:n.jumpProfileIds,onChange:k=>a(I=>({...I,jumpProfileIds:k}))})]}),u&&(0,K.jsxs)("div",{className:"dsh-ssh-test-result is-warning",role:"alert",children:[(0,K.jsxs)("span",{children:[(0,K.jsx)("strong",{children:"\u9996\u6B21\u8FDE\u63A5\uFF0C\u8BF7\u6838\u5BF9\u4E3B\u673A\u6307\u7EB9"}),(0,K.jsx)("code",{children:u})]}),(0,K.jsx)("button",{type:"button",className:"dsh-ssh-small-primary",disabled:c,onClick:()=>{N(u)},children:"\u786E\u8BA4\u5E76\u91CD\u8BD5"})]}),v==="success"&&(0,K.jsxs)("p",{className:"dsh-ssh-test-result is-success",role:"status",children:[(0,K.jsx)(Dt.IconCheckOutline14,{size:14}),"\u8FDE\u63A5\u6D4B\u8BD5\u6210\u529F"]}),m&&(0,K.jsx)("p",{className:"dsh-ssh-inline-error",role:"alert",children:m}),(0,K.jsxs)("div",{className:"dsh-ssh-dialog-actions",children:[(0,K.jsx)("button",{type:"button",className:"dsh-ssh-secondary-button dsh-ssh-test-button",disabled:h||c,onClick:k=>{k.currentTarget.form?.reportValidity()&&N()},children:c?"\u6B63\u5728\u6D4B\u8BD5\u2026":"\u6D4B\u8BD5\u8FDE\u63A5"}),(0,K.jsx)("button",{type:"button",className:"dsh-ssh-secondary-button","data-ssh-dialog-close":!0,disabled:h||c,onClick:o,children:"\u53D6\u6D88"}),(0,K.jsx)("button",{className:"dsh-ssh-primary-button",disabled:h||c,children:h?"\u6B63\u5728\u4FDD\u5B58\u2026":"\u4FDD\u5B58\u8FDE\u63A5"})]})]})})}function Dx({profiles:e,value:t,onChange:s}){let r=()=>{let n=e.find(a=>!t.includes(a.id));n!==void 0&&t.length<8&&s([...t,n.id])},o=(n,a)=>s(t.map((h,l)=>l===n?a:h)),i=(n,a)=>{let h=n+a;if(h<0||h>=t.length)return;let l=[...t];[l[n],l[h]]=[l[h],l[n]],s(l)};return(0,K.jsxs)("fieldset",{className:"dsh-ssh-jump-chain",children:[(0,K.jsx)("legend",{children:"\u8DF3\u677F\u94FE"}),(0,K.jsx)("p",{children:"\u8FDE\u63A5\u4F1A\u6309\u4ECE\u4E0A\u5230\u4E0B\u7684\u987A\u5E8F\u9010\u7EA7\u5EFA\u7ACB\u3002"}),(0,K.jsx)("div",{children:t.map((n,a)=>(0,K.jsxs)("div",{className:"dsh-ssh-jump-row",children:[(0,K.jsx)("em",{children:a+1}),(0,K.jsxs)("select",{required:!0,value:n,onChange:h=>o(a,h.target.value),children:[(0,K.jsx)("option",{value:"",children:"\u9009\u62E9\u5DF2\u6709\u8FDE\u63A5"}),e.filter(h=>h.id===n||!t.includes(h.id)).map(h=>(0,K.jsxs)("option",{value:h.id,children:[h.name," \xB7 ",h.host]},h.id))]}),(0,K.jsx)("button",{type:"button",className:"dsh-ssh-icon-button",disabled:a===0,"aria-label":"\u4E0A\u79FB\u8DF3\u677F",onClick:()=>i(a,-1),children:(0,K.jsx)(Dt.IconChevronUpOutline14,{size:14})}),(0,K.jsx)("button",{type:"button",className:"dsh-ssh-icon-button",disabled:a===t.length-1,"aria-label":"\u4E0B\u79FB\u8DF3\u677F",onClick:()=>i(a,1),children:(0,K.jsx)(Dt.IconChevronDownOutline14,{size:14})}),(0,K.jsx)("button",{type:"button",className:"dsh-ssh-icon-button is-danger","aria-label":"\u79FB\u9664\u8DF3\u677F",onClick:()=>s(t.filter((h,l)=>l!==a)),children:(0,K.jsx)(Dt.IconTrashOutline16,{size:15})})]},`${n}-${a}`))}),t.length===0&&(0,K.jsx)("p",{className:"dsh-ssh-jump-empty",children:"\u81F3\u5C11\u6DFB\u52A0\u4E00\u53F0\u8DF3\u677F\u4E3B\u673A\u3002"}),(0,K.jsxs)("button",{type:"button",className:"dsh-ssh-secondary-button",disabled:t.length>=8||e.every(n=>t.includes(n.id)),onClick:r,children:[(0,K.jsx)(Dt.IconPlusOutline16,{size:15}),"\u6DFB\u52A0\u8DF3\u677F"]})]})}var _e=require("react"),yt=require("@deepseek-ai/dsh-client-ui-primitives");var Rt=require("react"),Bt=require("@deepseek-ai/dsh-client-ui-primitives");var j=require("react/jsx-runtime");function vf({profiles:e,vaultEntries:t,proxyEntries:s,onClose:r,onChanged:o}){let[i,n]=(0,Rt.useState)(),[a,h]=(0,Rt.useState)(),[l,c]=(0,Rt.useState)(),f=i!==void 0||a!==void 0,v=m=>{h(void 0),n(m),c(void 0)},g=()=>{h(void 0),n("new"),c(void 0)},u=m=>{n(void 0),h(m),c(void 0)},d=async m=>{c(void 0);try{await ie(`/ftp-profiles/${encodeURIComponent(m.id)}`,{method:"DELETE"}),h(void 0),o()}catch(p){c(Ie(p))}};return(0,j.jsx)(et,{className:"dsh-ssh-ftp-manager-dialog",title:"\u6587\u4EF6\u8FDE\u63A5",subtitle:"\u7BA1\u7406 FTP \u4E0E FTPS\uFF1BSFTP \u76F4\u63A5\u590D\u7528\u5DF2\u6709 SSH \u4E3B\u673A",onClose:r,children:(0,j.jsxs)("div",{className:`dsh-ssh-ftp-manager${f?" has-detail":""}`,children:[(0,j.jsxs)("aside",{className:"dsh-ssh-ftp-manager-list",children:[(0,j.jsxs)("header",{children:[(0,j.jsxs)("span",{children:[(0,j.jsx)("strong",{children:"FTP / FTPS"}),(0,j.jsxs)("small",{children:[e.length," \u4E2A\u8FDE\u63A5"]})]}),(0,j.jsxs)("button",{type:"button",className:"dsh-ssh-primary-button",onClick:g,children:[(0,j.jsx)(Bt.IconPlusOutline16,{size:15}),"\u65B0\u5EFA"]})]}),e.length===0?(0,j.jsxs)("div",{className:"dsh-ssh-ftp-list-empty",children:[(0,j.jsx)("span",{children:(0,j.jsx)(Bt.IconDataOutline16,{size:20})}),(0,j.jsx)("strong",{children:"\u8FD8\u6CA1\u6709\u72EC\u7ACB\u6587\u4EF6\u8FDE\u63A5"}),(0,j.jsx)("p",{children:"SFTP \u4F1A\u663E\u793A\u5728\u6587\u4EF6\u7A97\u683C\u7684\u8FDE\u63A5\u5217\u8868\u4E2D\uFF1B\u8FD9\u91CC\u53EA\u7BA1\u7406 FTP \u4E0E FTPS\u3002"}),(0,j.jsx)("button",{type:"button",className:"dsh-ssh-secondary-button",onClick:g,children:"\u65B0\u5EFA FTPS \u8FDE\u63A5"})]}):(0,j.jsx)("div",{className:"dsh-ssh-ftp-profile-list",role:"list",children:e.map(m=>{let p=i!=="new"&&i?.id===m.id||a?.id===m.id;return(0,j.jsxs)("article",{role:"listitem","data-ssh-interactive":"choice","aria-selected":p,className:p?"is-active":"",children:[(0,j.jsxs)("button",{type:"button",className:"dsh-ssh-ftp-profile-main",onClick:()=>v(m),children:[(0,j.jsx)("span",{className:`dsh-ssh-protocol-badge is-${m.protocol}`,children:Ax(m.protocol)}),(0,j.jsxs)("span",{children:[(0,j.jsx)("strong",{title:m.name,children:m.name}),(0,j.jsxs)("small",{title:`${m.username}@${m.host}:${m.port}`,children:[m.username,"@",m.host,":",m.port]})]}),(0,j.jsx)("i",{className:m.credential.configured?"is-ready":"is-missing",children:m.credential.configured?"\u53EF\u7528":"\u7F3A\u5C11\u5BC6\u7801"})]}),(0,j.jsx)("button",{type:"button",className:"dsh-ssh-icon-button is-danger","aria-label":`\u5220\u9664 ${m.name}`,onClick:()=>u(m),children:(0,j.jsx)(Bt.IconTrashOutline16,{size:15})})]},m.id)})})]}),(0,j.jsx)("main",{className:"dsh-ssh-ftp-manager-detail",children:a!==void 0?(0,j.jsx)(Rx,{profile:a,error:l,onBack:()=>h(void 0),onDelete:()=>d(a)}):i!==void 0?(0,j.jsx)(Ix,{value:i==="new"?void 0:i,profiles:e,vaultEntries:t,proxyEntries:s,onBack:()=>n(void 0),onSaved:()=>{n(void 0),o()}},i==="new"?"new":i.id):(0,j.jsxs)("div",{className:"dsh-ssh-ftp-manager-overview",children:[(0,j.jsx)("span",{children:(0,j.jsx)(Bt.IconDataOutline16,{size:22})}),(0,j.jsx)("h3",{children:"\u9009\u62E9\u4E00\u4E2A\u8FDE\u63A5\u8FDB\u884C\u7F16\u8F91"}),(0,j.jsx)("p",{children:"\u6587\u4EF6\u7A97\u683C\u4F1A\u628A\u8FD9\u91CC\u4FDD\u5B58\u7684 FTP\u3001FTPS \u4E0E SSH \u4E3B\u673A\u63D0\u4F9B\u7684 SFTP \u6C47\u603B\u6210\u8FDE\u63A5\u5217\u8868\u3002"}),(0,j.jsxs)("dl",{children:[(0,j.jsxs)("div",{children:[(0,j.jsx)("dt",{children:"FTPS"}),(0,j.jsx)("dd",{children:"\u52A0\u5BC6\u63A7\u5236\u4E0E\u6587\u4EF6\u6570\u636E\uFF0C\u9ED8\u8BA4\u4E25\u683C\u6821\u9A8C\u8BC1\u4E66"})]}),(0,j.jsxs)("div",{children:[(0,j.jsx)("dt",{children:"FTP"}),(0,j.jsx)("dd",{children:"\u517C\u5BB9\u65E7\u670D\u52A1\u5668\uFF0C\u4F46\u8D26\u53F7\u548C\u6587\u4EF6\u5185\u5BB9\u4E0D\u52A0\u5BC6"})]}),(0,j.jsxs)("div",{children:[(0,j.jsx)("dt",{children:"SFTP"}),(0,j.jsx)("dd",{children:"\u7531 SSH \u4E3B\u673A\u7BA1\u7406\uFF0C\u4E0D\u5728\u8FD9\u91CC\u91CD\u590D\u914D\u7F6E"})]})]})]})})]})})}function Rx({profile:e,error:t,onBack:s,onDelete:r}){let[o,i]=(0,Rt.useState)(!1);return(0,j.jsxs)("div",{className:"dsh-ssh-ftp-delete-panel",children:[(0,j.jsxs)("button",{type:"button",className:"dsh-ssh-ftp-detail-back",onClick:s,children:[(0,j.jsx)(Bt.IconChevronLeftOutline14,{size:14}),"\u8FD4\u56DE\u8FDE\u63A5\u5217\u8868"]}),(0,j.jsx)("span",{className:"dsh-ssh-ftp-delete-mark",children:(0,j.jsx)(Bt.IconWarningOutline16,{size:20})}),(0,j.jsxs)("h3",{children:["\u5220\u9664\u201C",e.name,"\u201D\uFF1F"]}),(0,j.jsx)("p",{children:"\u5C06\u79FB\u9664\u8BE5 FTP/FTPS \u8FDE\u63A5\u53CA\u5176\u72EC\u7ACB\u4FDD\u5B58\u7684\u5BC6\u7801\uFF0C\u4E0D\u4F1A\u5220\u9664\u8FDC\u7AEF\u670D\u52A1\u5668\u4E0A\u7684\u4EFB\u4F55\u6587\u4EF6\u3002"}),(0,j.jsxs)("code",{children:[e.username,"@",e.host,":",e.port]}),t&&(0,j.jsx)("p",{className:"dsh-ssh-inline-error",role:"alert",children:t}),(0,j.jsxs)("div",{className:"dsh-ssh-dialog-actions",children:[(0,j.jsx)("button",{type:"button",className:"dsh-ssh-secondary-button",onClick:s,disabled:o,children:"\u53D6\u6D88"}),(0,j.jsx)("button",{type:"button",className:"dsh-ssh-danger-button",disabled:o,onClick:()=>{i(!0),r().finally(()=>i(!1))},children:o?"\u6B63\u5728\u5220\u9664\u2026":"\u5220\u9664\u8FDE\u63A5"})]})]})}function Ix({value:e,profiles:t,vaultEntries:s,proxyEntries:r,onBack:o,onSaved:i}){let n=s.filter(w=>w.authType==="password"),[a,h]=(0,Rt.useState)({name:e?.name??"",group:e?.group??"",protocol:e?.protocol??"ftps-explicit",host:e?.host??"",port:String(e?.port??21),username:e?.username??"",credentialId:e?.credentialId??"",password:"",proxyId:e?.proxy.type==="saved"?e.proxy.proxyId:"",initialPath:e?.initialPath??"/",connectTimeoutMs:String(e?.connectTimeoutMs??15e3),tlsServerName:e?.tlsServerName??"",tags:e?.tags.join(", ")??""}),[l,c]=(0,Rt.useState)(!1),[f,v]=(0,Rt.useState)(!1),[g,u]=(0,Rt.useState)(),[d,m]=(0,Rt.useState)(),p=()=>({profile:{name:a.name,...a.group.trim()?{group:a.group.trim()}:{},protocol:a.protocol,host:a.host,port:Number(a.port),username:a.username,...a.credentialId?{credentialId:a.credentialId}:{},proxy:a.proxyId?{type:"saved",proxyId:a.proxyId}:{type:"none"},initialPath:a.initialPath,connectTimeoutMs:Number(a.connectTimeoutMs),...a.tlsServerName.trim()?{tlsServerName:a.tlsServerName.trim()}:{},tags:a.tags.split(/[,,]/u).map(w=>w.trim()).filter(Boolean)},secrets:{password:a.password}}),b=async w=>{w.preventDefault(),c(!0),m(void 0),u(void 0);try{await ie(e===void 0?"/ftp-profiles":`/ftp-profiles/${encodeURIComponent(e.id)}`,{method:e===void 0?"POST":"PUT",body:JSON.stringify(p())}),i()}catch(P){m(Ie(P))}finally{c(!1)}},x=async()=>{v(!0),m(void 0),u(void 0);try{await ie("/ftp-profiles/test-draft",{method:"POST",body:JSON.stringify({...p(),...e===void 0?{}:{profileId:e.id}})}),u("\u8FDE\u63A5\u6210\u529F\uFF0C\u521D\u59CB\u76EE\u5F55\u53EF\u8BFB\u53D6")}catch(w){m(Ie(w))}finally{v(!1)}},y=w=>h(P=>({...P,protocol:w,port:P.port==="21"||P.port==="990"?String(w==="ftps-implicit"?990:21):P.port})),S=(0,Rt.useMemo)(()=>t.flatMap(w=>w.group===void 0?[]:[w.group]),[t]),_=(0,Rt.useMemo)(()=>t.flatMap(w=>w.tags),[t]);return(0,j.jsxs)("form",{className:"dsh-ssh-ftp-editor-form",onSubmit:w=>{b(w)},children:[(0,j.jsxs)("header",{className:"dsh-ssh-ftp-editor-heading",children:[(0,j.jsxs)("button",{type:"button",className:"dsh-ssh-ftp-detail-back",onClick:o,children:[(0,j.jsx)(Bt.IconChevronLeftOutline14,{size:14}),"\u8FD4\u56DE\u8FDE\u63A5\u5217\u8868"]}),(0,j.jsxs)("span",{children:[(0,j.jsx)("strong",{children:e===void 0?"\u65B0\u5EFA\u6587\u4EF6\u8FDE\u63A5":e.name}),(0,j.jsx)("small",{children:e===void 0?"\u586B\u5199\u670D\u52A1\u5668\u548C\u8BA4\u8BC1\u4FE1\u606F":"\u4FEE\u6539\u540E\u53EF\u5148\u6D4B\u8BD5\u518D\u4FDD\u5B58"})]})]}),(0,j.jsxs)("div",{className:"dsh-ssh-ftp-editor-scroll",children:[(0,j.jsxs)("section",{className:"dsh-ssh-ftp-editor-section",children:[(0,j.jsxs)("div",{className:"dsh-ssh-form-section-heading",children:[(0,j.jsx)("strong",{children:"\u8FDE\u63A5\u7C7B\u578B"}),(0,j.jsx)("small",{children:"\u4F18\u5148\u4F7F\u7528 FTPS\uFF1B\u4EC5\u5728\u670D\u52A1\u5668\u4E0D\u652F\u6301 TLS \u65F6\u9009\u62E9 FTP"})]}),(0,j.jsx)("div",{className:"dsh-ssh-ftp-protocol-options",role:"radiogroup","aria-label":"\u8FDE\u63A5\u534F\u8BAE",children:[["ftps-explicit","FTPS","\u663E\u5F0F TLS \xB7 \u63A8\u8350"],["ftps-implicit","FTPS-I","\u9690\u5F0F TLS"],["ftp","FTP","\u672A\u52A0\u5BC6"]].map(w=>(0,j.jsxs)("button",{type:"button","data-ssh-interactive":"choice",role:"radio","aria-checked":a.protocol===w[0],className:a.protocol===w[0]?"is-active":"",onClick:()=>y(w[0]),children:[(0,j.jsx)("span",{className:`dsh-ssh-protocol-badge is-${w[0]}`,children:w[1]}),(0,j.jsxs)("span",{children:[(0,j.jsx)("strong",{children:w[1]}),(0,j.jsx)("small",{children:w[2]})]})]},w[0]))}),a.protocol==="ftp"&&(0,j.jsx)("p",{className:"dsh-ssh-form-warning",children:"\u666E\u901A FTP \u7684\u8D26\u53F7\u3001\u5BC6\u7801\u548C\u6587\u4EF6\u5185\u5BB9\u5747\u4E0D\u52A0\u5BC6\u3002"})]}),(0,j.jsxs)("section",{className:"dsh-ssh-ftp-editor-section",children:[(0,j.jsxs)("div",{className:"dsh-ssh-form-section-heading",children:[(0,j.jsx)("strong",{children:"\u670D\u52A1\u5668"}),(0,j.jsx)("small",{children:"\u540D\u79F0\u7528\u4E8E\u8FDE\u63A5\u5217\u8868\uFF0C\u5206\u7EC4\u4E0E\u6807\u7B7E\u53EF\u590D\u7528\u5DF2\u6709\u9009\u9879"})]}),(0,j.jsxs)("div",{className:"dsh-ssh-form-grid",children:[(0,j.jsx)(ae,{label:"\u8FDE\u63A5\u540D\u79F0",children:(0,j.jsx)("input",{autoFocus:e===void 0,required:!0,maxLength:80,value:a.name,onChange:w=>h({...a,name:w.target.value})})}),(0,j.jsx)(ae,{label:"\u5206\u7EC4\uFF08\u53EF\u9009\uFF09",children:(0,j.jsx)(Mr,{ariaLabel:"FTP \u5206\u7EC4",maxLength:64,options:S,placeholder:"\u9009\u62E9\u5DF2\u6709\u5206\u7EC4\u6216\u8F93\u5165\u65B0\u5206\u7EC4",value:a.group,onChange:w=>h(P=>({...P,group:w}))})})]}),(0,j.jsxs)("div",{className:"dsh-ssh-form-grid is-host",children:[(0,j.jsx)(ae,{label:"\u670D\u52A1\u5668\u5730\u5740",children:(0,j.jsx)("input",{required:!0,maxLength:253,spellCheck:!1,value:a.host,onChange:w=>h({...a,host:w.target.value})})}),(0,j.jsx)(ae,{label:"\u7AEF\u53E3",children:(0,j.jsx)("input",{required:!0,type:"number",min:"1",max:"65535",value:a.port,onChange:w=>h({...a,port:w.target.value})})})]}),(0,j.jsx)(ae,{label:"\u6807\u7B7E\uFF08\u53EF\u9009\uFF09",hint:"\u53EF\u9009\u62E9\u5DF2\u6709\u6807\u7B7E\u6216\u76F4\u63A5\u8F93\u5165\uFF1B\u591A\u4E2A\u6807\u7B7E\u4F7F\u7528\u9017\u53F7\u5206\u9694\u3002",children:(0,j.jsx)(Mr,{ariaLabel:"FTP \u6807\u7B7E",multiple:!0,options:_,placeholder:"\u9009\u62E9\u6216\u8F93\u5165\u6807\u7B7E",value:a.tags,onChange:w=>h(P=>({...P,tags:w}))})})]}),(0,j.jsxs)("section",{className:"dsh-ssh-ftp-editor-section",children:[(0,j.jsxs)("div",{className:"dsh-ssh-form-section-heading",children:[(0,j.jsx)("strong",{children:"\u8EAB\u4EFD\u8BA4\u8BC1"}),(0,j.jsx)("small",{children:"\u5BC6\u7801\u53EA\u5199\u5165 DSH \u51ED\u636E\u670D\u52A1\uFF0C\u4E0D\u4F1A\u5728\u754C\u9762\u56DE\u663E"})]}),(0,j.jsxs)("div",{className:"dsh-ssh-form-grid",children:[(0,j.jsx)(ae,{label:"\u7528\u6237\u540D",children:(0,j.jsx)("input",{required:!0,maxLength:128,autoComplete:"username",value:a.username,onChange:w=>h({...a,username:w.target.value})})}),(0,j.jsx)(ae,{label:"\u51ED\u636E\u6765\u6E90",children:(0,j.jsxs)("select",{value:a.credentialId,onChange:w=>h({...a,credentialId:w.target.value}),children:[(0,j.jsx)("option",{value:"",children:"\u6B64\u8FDE\u63A5\u5355\u72EC\u4FDD\u5B58\u5BC6\u7801"}),n.map(w=>(0,j.jsxs)("option",{value:w.id,children:[w.name," \xB7 ",w.username]},w.id))]})})]}),!a.credentialId&&(0,j.jsx)(ae,{label:"\u5BC6\u7801",hint:e?.credential.configured&&e.credential.source==="profile"?"\u5DF2\u4FDD\u5B58\uFF1B\u7559\u7A7A\u4FDD\u6301\u4E0D\u53D8":"\u4FDD\u5B58\u540E\u4E0D\u4F1A\u56DE\u663E",children:(0,j.jsx)("input",{required:e===void 0||e.credential.source!=="profile"||!e.credential.configured,type:"password",autoComplete:"new-password",value:a.password,onChange:w=>h({...a,password:w.target.value})})})]}),(0,j.jsxs)("section",{className:"dsh-ssh-ftp-editor-section",children:[(0,j.jsxs)("div",{className:"dsh-ssh-form-section-heading",children:[(0,j.jsx)("strong",{children:"\u8DEF\u5F84\u4E0E\u7F51\u7EDC"}),(0,j.jsx)("small",{children:"\u4EE3\u7406\u590D\u7528 SSH \u63D2\u4EF6\u7684\u4EE3\u7406\u5E93\uFF0C\u63A7\u5236\u548C\u6570\u636E\u8FDE\u63A5\u4F7F\u7528\u540C\u4E00\u8DEF\u5F84"})]}),(0,j.jsxs)("div",{className:"dsh-ssh-form-grid",children:[(0,j.jsx)(ae,{label:"\u521D\u59CB\u76EE\u5F55",children:(0,j.jsx)("input",{required:!0,maxLength:4096,spellCheck:!1,value:a.initialPath,onChange:w=>h({...a,initialPath:w.target.value})})}),(0,j.jsx)(ae,{label:"\u8FDE\u63A5\u4EE3\u7406",children:(0,j.jsxs)("select",{value:a.proxyId,onChange:w=>h({...a,proxyId:w.target.value}),children:[(0,j.jsx)("option",{value:"",children:"\u76F4\u8FDE"}),r.map(w=>(0,j.jsxs)("option",{value:w.id,children:[w.name," \xB7 ",w.proxyType.toUpperCase()]},w.id))]})})]}),(0,j.jsxs)("details",{className:"dsh-ssh-form-advanced",children:[(0,j.jsx)("summary",{children:"\u9AD8\u7EA7\u8FDE\u63A5\u8BBE\u7F6E"}),(0,j.jsxs)("div",{className:"dsh-ssh-form-grid",children:[(0,j.jsx)(ae,{label:"\u8FDE\u63A5\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09",children:(0,j.jsx)("input",{required:!0,type:"number",min:"1000",max:"120000",step:"1000",value:a.connectTimeoutMs,onChange:w=>h({...a,connectTimeoutMs:w.target.value})})}),(0,j.jsx)(ae,{label:"TLS \u670D\u52A1\u5668\u540D\u79F0",hint:"\u8BC1\u4E66\u540D\u79F0\u4E0E\u4E3B\u673A\u4E0D\u540C\u65F6\u586B\u5199",children:(0,j.jsx)("input",{maxLength:253,spellCheck:!1,value:a.tlsServerName,onChange:w=>h({...a,tlsServerName:w.target.value})})})]})]})]}),g&&(0,j.jsx)("p",{className:"dsh-ssh-inline-success",role:"status",children:g}),d&&(0,j.jsx)("p",{className:"dsh-ssh-inline-error",role:"alert",children:d})]}),(0,j.jsxs)("footer",{className:"dsh-ssh-ftp-editor-actions",children:[(0,j.jsx)("button",{type:"button",className:"dsh-ssh-secondary-button",onClick:()=>{x()},disabled:f||l,children:f?"\u6B63\u5728\u6D4B\u8BD5\u2026":"\u6D4B\u8BD5\u8FDE\u63A5"}),(0,j.jsx)("span",{}),(0,j.jsx)("button",{type:"button",className:"dsh-ssh-secondary-button",onClick:o,disabled:l||f,children:"\u53D6\u6D88"}),(0,j.jsx)("button",{type:"submit",className:"dsh-ssh-primary-button",disabled:l||f,children:l?"\u6B63\u5728\u4FDD\u5B58\u2026":"\u4FDD\u5B58\u8FDE\u63A5"})]})]})}function Ax(e){return e==="ftp"?"FTP":e==="ftps-explicit"?"FTPS":"FTPS-I"}var Lx=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}),Nl=Lx.compare;function bf(e,t,s){let r=s==="asc"?1:-1;return e.map((o,i)=>({entry:o,index:i})).sort((o,i)=>{let n=o.entry.kind==="directory"||o.entry.navigable===!0,a=i.entry.kind==="directory"||i.entry.navigable===!0;if(n!==a)return n?-1:1;let h=Ox(o.entry,i.entry,t);if(h!==0)return h*r;let l=t==="name"?0:Nl(o.entry.name,i.entry.name);return l!==0?l:o.index-i.index}).map(o=>o.entry)}function Ox(e,t,s){return s==="name"?Nl(e.name,t.name):e[s]-t[s]}var F=require("react/jsx-runtime"),yf="dsh-ssh:file-transfer:tabs:v2",zl=38,Mx=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"});function wf({ftpProfiles:e,vaultEntries:t,proxyEntries:s,access:r,onProfilesChanged:o}){let i=dr(),[n,a]=(0,_e.useState)([]),[h,l]=(0,_e.useState)([]),[c,f]=(0,_e.useState)(()=>qx()),[v,g]=(0,_e.useState)(()=>c[0]?.id??"transfer-1"),[u,d]=(0,_e.useState)(!1),[m,p]=(0,_e.useState)(!1),[b,x]=(0,_e.useState)(),[y,S]=(0,_e.useState)(),[_,w]=(0,_e.useState)(),[P,E]=(0,_e.useState)({}),T=(0,_e.useRef)(new Map),R=(0,_e.useCallback)(async()=>{try{let A=await Xl();a(A),f(C=>Kx(C,A))}catch(A){w(Ie(A))}},[]);(0,_e.useEffect)(()=>{R()},[R,e]),(0,_e.useEffect)(()=>{try{localStorage.setItem(yf,JSON.stringify(c))}catch{}},[c]),(0,_e.useEffect)(()=>{let A=T.current,C=h.filter(H=>_f(H.state)&&A.has(H.id)&&!_f(A.get(H.id)));T.current=new Map(h.map(H=>[H.id,H.state])),C.length!==0&&E(H=>{let q={...H};for(let O of C){let J=$n(O.request.destinationEndpointId,O.request.destinationDirectory);q[J]=(q[J]??0)+1}return q})},[h]),(0,_e.useEffect)(()=>{let A=!1,C,H=async()=>{if(document.visibilityState==="hidden"){C=window.setTimeout(()=>{H()},1800);return}try{let q=await Ql();A||l(q)}catch{}A||(C=window.setTimeout(()=>{H()},800))};return H(),()=>{A=!0,C!==void 0&&clearTimeout(C)}},[]);let M=c.find(A=>A.id===v)??c[0],B=A=>f(C=>C.map(H=>H.id===M?.id?A(H):H)),U=()=>{let A=`transfer-${Date.now().toString(36)}`,C=Ul(A,c.length+1);f(H=>[...H,C]),g(A)},N=A=>{if(c.length===1)return;let C=c.findIndex(q=>q.id===A),H=c.filter(q=>q.id!==A);f(H),v===A&&g(H[Math.max(0,C-1)].id)},V=A=>B(C=>({...C,panes:Array.from({length:A},(H,q)=>C.panes[q]??jn(`${C.id}-pane-${q}`))})),k=async(A,C,H,q,O)=>{let J={endpointId:A,directory:C},z={endpointId:q,directory:O};if(!(ni(J,z)||!oi(J,H,z)))try{w(void 0);let L=await $r({sourceEndpointId:A,sourcePaths:H,destinationEndpointId:q,destinationDirectory:O,conflictPolicy:"fail"});l(X=>[L,...X.filter(G=>G.id!==L.id)])}catch(L){w(Ie(L))}},I=async(A,C,H)=>{try{w(void 0);let q=await mn(A,{paneId:C.id,endpointId:C.endpointId,directory:H});q.job!==void 0&&l(O=>[q.job,...O.filter(J=>J.id!==q.job.id)]),q.operation==="move"&&E(O=>{let J={...O};for(let z of[$n(A.endpointId,A.directory),$n(C.endpointId,H)])J[z]=(J[z]??0)+1;return J})}catch(q){w(Ie(q))}};return(0,F.jsxs)("div",{className:"dsh-ssh-transfer-workspace",children:[(0,F.jsxs)("header",{className:"dsh-ssh-transfer-header",children:[(0,F.jsxs)("div",{children:[(0,F.jsx)("h1",{children:"\u6587\u4EF6\u4F20\u8F93"}),(0,F.jsx)("p",{children:"FTP\u3001FTPS \u4E0E SFTP \u4E4B\u95F4\u76F4\u63A5\u6D41\u5F0F\u4E92\u4F20"})]}),(0,F.jsxs)("div",{className:"dsh-ssh-transfer-actions",children:[(0,F.jsxs)("button",{type:"button","data-ssh-interactive":"control",className:"dsh-ssh-secondary-button",onClick:()=>p(!0),children:["\u4F1A\u8BDD\u8BBF\u95EE \xB7 ",r.value?.fileEndpointIds.length??0]}),(0,F.jsx)("button",{type:"button","data-ssh-interactive":"control",className:"dsh-ssh-secondary-button",onClick:()=>d(!0),children:"FTP \u7BA1\u7406"})]})]}),_&&(0,F.jsxs)("div",{className:"dsh-ssh-banner is-error",role:"alert",children:[(0,F.jsx)("span",{children:_}),(0,F.jsx)("button",{type:"button",onClick:()=>w(void 0),"aria-label":"\u5173\u95ED",children:(0,F.jsx)(yt.IconCloseOutline16,{size:16})})]}),(0,F.jsxs)("section",{ref:i.ref,onPointerMove:i.onPointerMove,onPointerLeave:i.onPointerLeave,className:"dsh-ssh-transfer-stage dsh-ssh-border-surface",children:[(0,F.jsxs)("div",{className:"dsh-ssh-transfer-tabbar",role:"tablist","aria-label":"\u6587\u4EF6\u4F20\u8F93\u4EFB\u52A1\u9875",children:[(0,F.jsxs)("div",{className:"dsh-ssh-transfer-tabs",children:[c.map(A=>(0,F.jsxs)("span",{"data-ssh-interactive":"choice",className:`dsh-ssh-transfer-tab${A.id===M?.id?" is-active":""}`,children:[(0,F.jsx)("button",{type:"button",role:"tab","aria-selected":A.id===M?.id,onClick:()=>g(A.id),children:A.name}),c.length>1&&(0,F.jsx)("button",{type:"button",className:"is-close","aria-label":`\u5173\u95ED ${A.name}`,onClick:()=>N(A.id),children:(0,F.jsx)(yt.IconCloseOutline16,{size:13})})]},A.id)),(0,F.jsx)("button",{type:"button","data-ssh-interactive":"control",className:"is-add","aria-label":"\u65B0\u5EFA\u4F20\u8F93\u4EFB\u52A1\u9875",onClick:U,children:(0,F.jsx)(yt.IconPlusOutline16,{size:15})})]}),(0,F.jsx)("div",{className:"dsh-ssh-pane-layout","aria-label":"\u7A97\u683C\u6570\u91CF",children:[2,3,4].map(A=>(0,F.jsxs)("button",{type:"button","data-ssh-interactive":"choice","aria-pressed":M?.panes.length===A,className:M?.panes.length===A?"is-active":"",onClick:()=>V(A),children:[A," \u680F"]},A))})]}),n.length===0?(0,F.jsxs)("div",{className:"dsh-ssh-transfer-empty",children:[(0,F.jsx)(yt.IconDataOutline16,{size:24}),(0,F.jsx)("strong",{children:"\u8FD8\u6CA1\u6709\u53EF\u7528\u6587\u4EF6\u8FDE\u63A5"}),(0,F.jsx)("p",{children:"\u65B0\u5EFA FTP/FTPS \u8FDE\u63A5\uFF0C\u6216\u5148\u6DFB\u52A0\u4E00\u53F0 SSH \u4E3B\u673A\u4F7F\u7528 SFTP\u3002"}),(0,F.jsx)("button",{type:"button",className:"dsh-ssh-primary-button",onClick:()=>d(!0),children:"\u65B0\u5EFA FTP \u8FDE\u63A5"})]}):M&&(0,F.jsx)("div",{className:`dsh-ssh-transfer-panes has-${M.panes.length}`,children:M.panes.map((A,C)=>{let H=M.panes[(C+1)%M.panes.length];return(0,F.jsx)(Fx,{pane:A,endpoints:n,dragSource:y,refreshRevision:P[$n(A.endpointId,A.path)]??0,...H===void 0?{}:{destination:H},onManageConnections:()=>d(!0),onDragSourceChange:S,onChange:q=>B(O=>({...O,panes:O.panes.map(J=>J.id===A.id?{...J,...q}:J)})),onTransfer:(q,O)=>{k(A.endpointId,A.path,q,O.endpointId,O.path)},onExternalDrop:(q,O)=>{I(q,A,O)}},A.id)})}),(0,F.jsx)(zx,{jobs:h,endpoints:n,onCancel:async A=>{try{await Zl(A),l(C=>C.map(H=>H.id===A?{...H,state:"cancelled"}:H))}catch(C){w(Ie(C))}},onConflict:x})]}),u&&(0,F.jsx)(vf,{profiles:e,vaultEntries:t,proxyEntries:s,onClose:()=>d(!1),onChanged:()=>{o(),R()}}),m&&(0,F.jsx)(Ux,{endpoints:n,access:r,onClose:()=>p(!1)}),b&&(0,F.jsx)(Hx,{job:b,onClose:()=>x(void 0),onRetry:async A=>{try{let C=await $r({...b.request,conflictPolicy:A});l(H=>[C,...H]),x(void 0)}catch(C){w(Ie(C))}}})]})}function Fx({pane:e,endpoints:t,destination:s,dragSource:r,refreshRevision:o,onChange:i,onTransfer:n,onExternalDrop:a,onDragSourceChange:h,onManageConnections:l}){let[c,f]=(0,_e.useState)(),[v,g]=(0,_e.useState)(),[u,d]=(0,_e.useState)([]),[m,p]=(0,_e.useState)(e.path),[b,x]=(0,_e.useState)(!1),[y,S]=(0,_e.useState)(0),[_,w]=(0,_e.useState)({key:"name",direction:"asc"}),[P,E]=(0,_e.useState)(!1),[T,R]=(0,_e.useState)(),[M,B]=(0,_e.useState)(),[U,N]=(0,_e.useState)(),V=(0,_e.useRef)(null),k=(0,_e.useRef)(0),I=t.find(Z=>Z.id===e.endpointId),A=(0,_e.useMemo)(()=>bf(v?.entries??[],_.key,_.direction),[v?.entries,_]),C=A.length>200,H=C?Math.max(0,Math.floor(y/zl)-8):0,q=(0,_e.useMemo)(()=>C?A.slice(H,Math.min(A.length,H+56)):A,[A,H,C]),O=(0,_e.useCallback)(async(Z=e.path)=>{if(I===void 0)return;let me=++k.current;x(!0),N(void 0);try{let ye=await Pi(e.id,I.id,Z);if(me!==k.current)return;g(ye),p(ye.path),d([]),S(0),V.current&&(V.current.scrollTop=0),i({endpointId:I.id,path:ye.path})}catch(ye){me===k.current&&N(Ie(ye))}finally{me===k.current&&x(!1)}},[I?.id,e.path]);(0,_e.useEffect)(()=>{I!==void 0&&O(e.path)},[I?.id,o]),(0,_e.useEffect)(()=>{r===void 0&&(E(!1),R(void 0))},[r]);let J=async Z=>{if(!I)return;let me=++k.current;x(!0),N(void 0);try{let ye=await Jl(e.id,I.id,Z);if(me!==k.current)return;Ss(ye)?await O(ye.path):f(ye)}catch(ye){me===k.current&&N(Ie(ye))}finally{me===k.current&&x(!1)}};(0,_e.useEffect)(()=>{f(void 0)},[I?.id]);let z=Z=>{Z.preventDefault(),J(m)},L=Z=>{w(me=>me.key===Z?{key:Z,direction:me.direction==="asc"?"desc":"asc"}:{key:Z,direction:"asc"}),S(0),V.current&&(V.current.scrollTop=0)},X=Z=>{k.current+=1,i({endpointId:Z.id,path:Z.initialPath}),p(Z.initialPath),g(void 0),N(void 0)},G=()=>{k.current+=1,i({endpointId:"",path:"/"}),g(void 0),d([]),N(void 0),x(!1)},se=(Z,me)=>d(ye=>me?ye.includes(Z.path)?ye.filter(ce=>ce!==Z.path):[...ye,Z.path]:[Z.path]),Q=async()=>{if(!(M===void 0||v===void 0||I===void 0))try{await Vr({paneId:e.id,endpointId:I.id,directory:v.path,paths:M.map(Z=>Z.path)}),d([])}finally{await O(v.path)}},fe=Z=>{Z.preventDefault(),E(!1);let me=kr(Z.dataTransfer.getData(Ht));h(void 0),!(me===void 0||me.paneId===e.id||ni(me,{endpointId:e.endpointId,directory:e.path}))&&a(me,e.path)};return I===void 0?(0,F.jsxs)("section",{className:"dsh-ssh-file-pane is-connections",children:[(0,F.jsxs)("header",{children:[(0,F.jsxs)("span",{className:"dsh-ssh-pane-heading",children:[(0,F.jsx)("strong",{children:"\u8FDE\u63A5\u5217\u8868"}),(0,F.jsx)("small",{children:"\u5355\u51FB\u8FDE\u63A5\u540E\u6D4F\u89C8\u8FDC\u7AEF\u6587\u4EF6"})]}),(0,F.jsx)("button",{type:"button","data-ssh-interactive":"control",className:"dsh-ssh-pane-manage-button",onClick:l,children:"FTP \u7BA1\u7406"})]}),(0,F.jsx)("div",{className:"dsh-ssh-endpoint-list",children:t.map(Z=>(0,F.jsxs)("button",{type:"button","data-ssh-interactive":"row",className:"dsh-ssh-endpoint-row",onClick:()=>X(Z),children:[(0,F.jsx)("span",{className:`dsh-ssh-protocol-badge is-${Z.protocol}`,children:Vl(Z.protocol)}),(0,F.jsxs)("span",{children:[(0,F.jsx)("strong",{title:Z.name,children:Z.name}),(0,F.jsx)("small",{title:Z.address,children:Z.address})]}),(0,F.jsxs)("span",{children:[(0,F.jsx)("i",{className:`dsh-ssh-protocol-dot is-${Z.protocol}`,"aria-hidden":"true"}),Z.group??(Z.kind==="sftp"?"SSH \u4E3B\u673A":"\u6587\u4EF6\u8FDE\u63A5")]})]},Z.id))}),(0,F.jsxs)("footer",{children:[(0,F.jsxs)("span",{children:[t.length," \u4E2A\u53EF\u7528\u8FDE\u63A5"]}),(0,F.jsx)("small",{children:"SFTP \u590D\u7528 SSH \u4E3B\u673A\u914D\u7F6E"})]})]}):(0,F.jsxs)("section",{className:`dsh-ssh-file-pane${P?" is-drop-target":""}`,onDragOver:Z=>{Z.dataTransfer.types.includes(Ht)&&Xx(r,e)?(Z.preventDefault(),Z.dataTransfer.dropEffect=r?.endpointId===e.endpointId?"move":"copy",R(void 0),E(!0)):P&&E(!1)},onDragLeave:Z=>{Z.currentTarget.contains(Z.relatedTarget)||(E(!1),R(void 0))},onDrop:fe,children:[(0,F.jsxs)("header",{children:[(0,F.jsx)("button",{type:"button",className:"dsh-ssh-pane-back","aria-label":"\u8FD4\u56DE\u8FDE\u63A5\u5217\u8868",onClick:G,children:(0,F.jsx)(yt.IconChevronLeftOutline14,{size:14})}),(0,F.jsxs)("span",{className:"dsh-ssh-pane-endpoint",children:[(0,F.jsx)("strong",{children:I.name}),(0,F.jsx)("small",{title:I.address,children:I.address})]}),(0,F.jsx)("span",{className:`dsh-ssh-protocol-badge is-${I.protocol}`,children:Vl(I.protocol)})]}),(0,F.jsxs)("form",{className:"dsh-ssh-file-pathbar",onSubmit:z,children:[(0,F.jsx)("button",{type:"button","aria-label":"\u4E0A\u4E00\u7EA7\u76EE\u5F55",disabled:v?.parent===null||b,onClick:()=>{v?.parent&&O(v.parent)},children:(0,F.jsx)(ey,{})}),(0,F.jsx)("button",{type:"button","aria-label":"\u5237\u65B0\u76EE\u5F55",disabled:b,onClick:()=>{O()},children:(0,F.jsx)(ty,{})}),(0,F.jsx)("input",{"aria-label":"\u8FDC\u7AEF\u8DEF\u5F84",value:m,onChange:Z=>p(Z.target.value)}),(0,F.jsx)("button",{type:"submit",disabled:b,children:"\u524D\u5F80"})]}),(0,F.jsxs)("div",{className:"dsh-ssh-file-table",role:"grid","aria-busy":b,children:[(0,F.jsxs)("div",{className:"dsh-ssh-file-table-head",role:"row",children:[(0,F.jsx)(Hl,{label:"\u540D\u79F0",sortKey:"name",current:_,onSort:L}),(0,F.jsx)(Hl,{label:"\u5927\u5C0F",sortKey:"size",current:_,onSort:L}),(0,F.jsx)(Hl,{label:"\u4FEE\u6539\u65F6\u95F4",sortKey:"modifiedAt",current:_,onSort:L}),(0,F.jsx)("span",{role:"columnheader","aria-label":"\u64CD\u4F5C"})]}),(0,F.jsx)("div",{ref:V,className:"dsh-ssh-file-table-body",onScroll:Z=>{C&&S(Z.currentTarget.scrollTop)},children:b&&!v?(0,F.jsx)("div",{className:"dsh-ssh-file-loading",children:"\u6B63\u5728\u8BFB\u53D6\u76EE\u5F55\u2026"}):U?(0,F.jsxs)("div",{className:"dsh-ssh-file-error",children:[(0,F.jsx)("span",{children:U}),(0,F.jsx)("button",{type:"button",onClick:()=>{O()},children:"\u91CD\u8BD5"})]}):A.length===0?(0,F.jsx)("div",{className:"dsh-ssh-table-empty",children:"\u8FD9\u4E2A\u76EE\u5F55\u662F\u7A7A\u7684\u3002"}):(0,F.jsx)("div",{className:C?"dsh-ssh-file-virtual-list":void 0,style:C?{height:`${A.length*zl}px`}:void 0,children:q.map((Z,me)=>(0,F.jsx)(Nx,{entry:Z,paneId:e.id,endpointId:I.id,sourceDirectory:v?.path??e.path,dragSource:r,dropTarget:T===Z.path,selected:u.includes(Z.path),selectedPaths:u,...C?{style:{position:"absolute",insetInline:0,transform:`translateY(${(H+me)*zl}px)`}}:{},onDelete:()=>B([Z]),onDirectoryTarget:ye=>{E(!1),R(ye)},onDropIntoDirectory:(ye,ce)=>{R(void 0),h(void 0),a(ye,ce)},onDragSourceChange:h,onSelect:ye=>se(Z,ye),onOpen:()=>{J(Z.path)}},Z.path))})})]}),(0,F.jsxs)("footer",{children:[(0,F.jsx)("span",{children:u.length>0?`\u5DF2\u9009\u62E9 ${u.length} \u9879`:`${v?.entries.length??0} \u9879`}),(0,F.jsx)("span",{className:"dsh-ssh-file-pane-actions",children:(0,F.jsxs)("button",{type:"button","data-ssh-interactive":"control",className:"dsh-ssh-transfer-to-button",disabled:u.length===0||s===void 0||!s.endpointId||b,onClick:()=>{s?.endpointId&&n(u,s)},children:["\u4F20\u9001\u5230\u4E0B\u4E00\u680F ",(0,F.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]})})]}),P&&(0,F.jsxs)("div",{className:"dsh-ssh-file-drop-overlay",children:[(0,F.jsx)("strong",{children:r?.endpointId===e.endpointId?"\u79FB\u52A8\u5230\u6B64\u76EE\u5F55":"\u590D\u5236\u5230\u6B64\u76EE\u5F55"}),(0,F.jsx)("span",{children:v?.path??e.path})]}),c!==void 0&&(0,F.jsx)(et,{className:"dsh-ssh-file-download-dialog",title:c.name,subtitle:c.path,onClose:()=>f(void 0),children:(0,F.jsx)("div",{className:"dsh-ssh-dialog-actions",children:(0,F.jsxs)("a",{className:"dsh-ssh-secondary-button",href:Jn(I.id,c.path),download:!0,children:[(0,F.jsx)(Sf,{}),(0,F.jsx)("span",{children:"\u4E0B\u8F7D\u5230\u672C\u5730"})]})})}),M!==void 0&&(0,F.jsx)(Mn,{locationName:I.name,locationKind:"remote",entries:M,onClose:()=>B(void 0),onDelete:Q})]})}function Hl({label:e,sortKey:t,current:s,onSort:r}){let o=s.key===t;return(0,F.jsx)("span",{role:"columnheader","aria-sort":o?s.direction==="asc"?"ascending":"descending":"none",children:(0,F.jsxs)("button",{type:"button",onClick:()=>r(t),children:[e,(0,F.jsx)(Bx,{active:o,direction:s.direction})]})})}function Bx({active:e,direction:t}){return(0,F.jsx)("svg",{className:e?"is-active":"",viewBox:"0 0 12 12","aria-hidden":"true",children:(0,F.jsx)("path",{d:"m3.5 5 2.5 2.5L8.5 5",transform:t==="desc"?void 0:"rotate(180 6 6)"})})}function Sf(){return(0,F.jsx)("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:(0,F.jsx)("path",{d:"M8 2v7m0 0 2.6-2.6M8 9 5.4 6.4M3 11.5v1.25h10V11.5"})})}function Nx({entry:e,paneId:t,endpointId:s,sourceDirectory:r,dragSource:o,dropTarget:i,selected:n,selectedPaths:a,style:h,onSelect:l,onOpen:c,onDelete:f,onDirectoryTarget:v,onDropIntoDirectory:g,onDragSourceChange:u}){let d=Ss(e),m=s.startsWith("ftp:")&&e.navigable===void 0&&(e.kind==="symlink"||e.kind==="other"),p=!0,b=d&&(o===void 0||oi(o,o.paths,{endpointId:s,directory:e.path})),x=y=>{if(!d)return;y.preventDefault(),y.stopPropagation(),v(void 0);let S=kr(y.dataTransfer.getData(Ht));S!==void 0&&oi(S,S.paths,{endpointId:s,directory:e.path})&&g(S,e.path)};return(0,F.jsxs)("div",{role:"row","data-ssh-interactive":"row","data-ssh-context-row":!0,tabIndex:0,"aria-selected":n,"aria-label":`${e.name}${d?"\uFF0C\u76EE\u5F55\uFF0C\u5355\u51FB\u8FDB\u5165\uFF1B\u53EF\u63A5\u6536\u62D6\u653E":m?"\uFF0C\u5355\u51FB\u67E5\u770B":""}`,draggable:e.kind==="file"||d,className:`dsh-ssh-file-row is-${d?"directory":e.kind}${n?" is-selected":""}${i?" is-drop-target":""}`,style:h,onClick:y=>{p&&!y.ctrlKey&&!y.metaKey&&!y.shiftKey?c():l(y.ctrlKey||y.metaKey)},onKeyDown:y=>{y.target===y.currentTarget&&(y.key==="Enter"&&p&&c(),y.key===" "&&(y.preventDefault(),l(y.ctrlKey||y.metaKey)))},onDragStart:y=>{let S=n?a:[e.path],_={paneId:t,endpointId:s,directory:r,paths:S};u(_),y.dataTransfer.effectAllowed="copyMove",y.dataTransfer.setData(Ht,JSON.stringify(_))},onDragEnd:()=>u(void 0),onDragOver:y=>{y.dataTransfer.types.includes(Ht)&&b&&(y.preventDefault(),y.stopPropagation(),y.dataTransfer.dropEffect=o?.endpointId===s?"move":"copy",v(e.path))},onDragLeave:y=>{i&&!y.currentTarget.contains(y.relatedTarget)&&v(void 0)},onDrop:x,children:[(0,F.jsxs)("span",{children:[(0,F.jsx)(sy,{directory:d}),(0,F.jsx)("i",{title:e.name,children:e.name})]}),(0,F.jsx)("span",{children:d?"\u2014":Cf(e.size)}),(0,F.jsx)("span",{children:e.modifiedAt>0?new Date(e.modifiedAt).toLocaleString():"\u2014"}),(0,F.jsxs)("span",{className:"dsh-ssh-file-row-actions dsh-ssh-context-action",children:[(0,F.jsx)("a",{className:"dsh-ssh-file-row-download",href:Jn(s,e.path),download:!0,draggable:!1,"aria-label":`\u4E0B\u8F7D ${e.name} \u5230\u672C\u5730`,title:e.kind==="directory"?`\u5C06 ${e.name} \u6253\u5305\u4E0B\u8F7D\u5230\u672C\u5730`:`\u4E0B\u8F7D ${e.name} \u5230\u672C\u5730`,onClick:y=>y.stopPropagation(),children:(0,F.jsx)(Sf,{})}),(0,F.jsx)("button",{type:"button",className:"dsh-ssh-file-row-delete",draggable:!1,"aria-label":`\u5220\u9664 ${e.name}`,title:`\u5220\u9664 ${e.name}`,onClick:y=>{y.stopPropagation(),f()},children:(0,F.jsx)(yt.IconTrashOutline16,{size:14})})]})]})}function zx({jobs:e,endpoints:t,onCancel:s,onConflict:r}){let[o,i]=(0,_e.useState)(!0),n=e.filter(a=>a.state==="queued"||a.state==="scanning"||a.state==="transferring");return(0,F.jsxs)("section",{className:`dsh-ssh-transfer-queue${o?" is-open":""}`,children:[(0,F.jsxs)("button",{type:"button",className:"dsh-ssh-transfer-queue-heading","aria-expanded":o,title:o?"\u6536\u8D77\u4F20\u8F93\u4EFB\u52A1":"\u5C55\u5F00\u4F20\u8F93\u4EFB\u52A1",onClick:()=>i(a=>!a),children:[(0,F.jsxs)("span",{children:[(0,F.jsx)("strong",{children:"\u4F20\u8F93\u4EFB\u52A1"}),(0,F.jsx)("small",{children:n.length>0?`${n.length} \u4E2A\u8FDB\u884C\u4E2D`:e.length>0?"\u6700\u8FD1\u4EFB\u52A1":"\u6682\u65E0\u4EFB\u52A1"})]}),(0,F.jsx)("span",{className:"dsh-ssh-transfer-queue-disclosure","aria-hidden":"true",children:(0,F.jsx)(yt.IconChevronDownOutline14,{size:14})})]}),o&&(0,F.jsx)("div",{className:"dsh-ssh-transfer-job-list",children:e.length===0?(0,F.jsx)("p",{children:"\u4ECE\u4E00\u4E2A\u7A97\u683C\u62D6\u5230\u53E6\u4E00\u4E2A\u7A97\u683C\uFF0C\u6216\u9009\u4E2D\u6587\u4EF6\u540E\u70B9\u51FB\u201C\u4F20\u9001\u5230\u4E0B\u4E00\u680F\u201D\u3002"}):e.slice(0,12).map(a=>{let h=a.totalBytes>0?Math.min(100,a.transferredBytes/a.totalBytes*100):a.state==="completed"?100:0;return(0,F.jsxs)("article",{children:[(0,F.jsx)("span",{className:`dsh-ssh-transfer-state is-${a.state}`,"aria-hidden":"true"}),(0,F.jsxs)("span",{className:"dsh-ssh-transfer-job-copy",children:[(0,F.jsxs)("strong",{children:[kf(a.request.sourcePaths)," ",(0,F.jsx)("i",{children:"\u2192"})," ",Gx(t,a.request.destinationEndpointId)]}),(0,F.jsx)("small",{children:a.error??Jx(a,h)}),(0,F.jsx)("span",{className:"dsh-ssh-transfer-job-time",children:Yx(a)}),(0,F.jsx)("span",{className:"dsh-ssh-transfer-progress",children:(0,F.jsx)("i",{style:{transform:`scaleX(${h/100})`}})})]}),a.state==="queued"||a.state==="scanning"||a.state==="transferring"?(0,F.jsx)("button",{type:"button",className:"dsh-ssh-icon-button","aria-label":"\u53D6\u6D88\u4F20\u8F93",onClick:()=>{s(a.id)},children:(0,F.jsx)(yt.IconCloseOutline16,{size:15})}):a.state==="failed"&&a.error?.includes("destination already contains")?(0,F.jsx)("button",{type:"button",className:"dsh-ssh-job-resolve",onClick:()=>r(a),children:"\u5904\u7406"}):null]},a.id)})})]})}function Hx({job:e,onClose:t,onRetry:s}){let[r,o]=(0,_e.useState)("rename"),[i,n]=(0,_e.useState)(!1);return(0,F.jsxs)(et,{className:"dsh-ssh-transfer-conflict-dialog",title:"\u76EE\u6807\u4E2D\u5B58\u5728\u540C\u540D\u6587\u4EF6",subtitle:"\u4E3A\u672C\u6279\u4F20\u8F93\u9009\u62E9\u5904\u7406\u65B9\u5F0F",onClose:t,children:[(0,F.jsxs)("div",{className:"dsh-ssh-transfer-conflict-copy",children:[(0,F.jsx)("strong",{children:kf(e.request.sourcePaths)}),(0,F.jsx)("span",{children:e.request.destinationDirectory})]}),(0,F.jsx)("div",{className:"dsh-ssh-conflict-options",children:[["rename","\u81EA\u52A8\u91CD\u547D\u540D","\u4FDD\u7559\u4E24\u4EFD\u6587\u4EF6\uFF0C\u5728\u540D\u79F0\u540E\u6DFB\u52A0\u5E8F\u53F7"],["skip","\u8DF3\u8FC7\u540C\u540D\u6587\u4EF6","\u7EE7\u7EED\u4F20\u8F93\u5176\u4ED6\u5185\u5BB9"],["overwrite","\u8986\u76D6\u76EE\u6807\u6587\u4EF6","\u4F7F\u7528\u6765\u6E90\u5185\u5BB9\u66FF\u6362\u76EE\u6807\u5185\u5BB9"]].map(a=>(0,F.jsxs)("button",{type:"button","data-ssh-interactive":"choice","aria-pressed":r===a[0],className:r===a[0]?"is-active":"",onClick:()=>o(a[0]),children:[(0,F.jsx)("i",{"aria-hidden":"true"}),(0,F.jsxs)("span",{children:[(0,F.jsx)("strong",{children:a[1]}),(0,F.jsx)("small",{children:a[2]})]})]},a[0]))}),(0,F.jsxs)("div",{className:"dsh-ssh-dialog-actions",children:[(0,F.jsx)("button",{type:"button",className:"dsh-ssh-secondary-button","data-ssh-dialog-close":!0,onClick:t,children:"\u53D6\u6D88"}),(0,F.jsx)("button",{type:"button",className:"dsh-ssh-primary-button",disabled:i,onClick:()=>{n(!0),s(r).finally(()=>n(!1))},children:i?"\u6B63\u5728\u91CD\u65B0\u52A0\u5165\u961F\u5217\u2026":"\u7EE7\u7EED\u4F20\u8F93"})]})]})}function Ux({endpoints:e,access:t,onClose:s}){let r=t.value,o=e.filter(n=>r?.fileEndpointIds.includes(n.id)).length,i=n=>t.setFileEndpoints(r?.fileEndpointIds.includes(n)?r.fileEndpointIds.filter(a=>a!==n):[...r?.fileEndpointIds??[],n]);return(0,F.jsxs)(et,{className:"dsh-ssh-file-access-dialog",title:"\u4F1A\u8BDD\u8BBF\u95EE",subtitle:"\u5355\u72EC\u7BA1\u7406\u5F53\u524D\u4F1A\u8BDD\u53EF\u4F7F\u7528\u7684\u8FDC\u7AEF\u6587\u4EF6\u8FDE\u63A5",onClose:s,children:[(0,F.jsxs)("div",{className:"dsh-ssh-file-access-body dsh-ssh-scroll-surface",children:[t.error&&(0,F.jsx)("p",{className:"dsh-ssh-inline-error",role:"alert",children:t.error}),(0,F.jsxs)("section",{className:"dsh-ssh-file-access-section","aria-labelledby":"dsh-ssh-file-access-connections",children:[(0,F.jsxs)("header",{children:[(0,F.jsxs)("span",{children:[(0,F.jsx)("strong",{id:"dsh-ssh-file-access-connections",children:"\u6587\u4EF6\u8FDE\u63A5"}),(0,F.jsx)("small",{children:"\u5141\u8BB8\u5F53\u524D\u4F1A\u8BDD\u6D4F\u89C8\u6307\u5B9A\u7684 FTP\u3001FTPS \u6216 SFTP"})]}),(0,F.jsxs)("i",{children:[o.toString().padStart(2,"0")," / ",e.length.toString().padStart(2,"0")]})]}),(0,F.jsx)("div",{className:"dsh-ssh-file-access-list",children:t.loading?(0,F.jsx)($x,{}):e.length===0?(0,F.jsxs)("div",{className:"dsh-ssh-file-access-empty",children:[(0,F.jsx)("strong",{children:"\u6CA1\u6709\u53EF\u7528\u8FDE\u63A5"}),(0,F.jsx)("small",{children:"\u8BF7\u5148\u5728\u6587\u4EF6\u4F20\u8F93\u4E2D\u6DFB\u52A0 FTP\uFF0C\u6216\u5728\u4E3B\u673A\u9762\u677F\u4E2D\u6DFB\u52A0 SSH \u4E3B\u673A\u3002"})]}):e.map(n=>(0,F.jsx)(Vx,{endpoint:n,enabled:r?.fileEndpointIds.includes(n.id)??!1,onToggle:()=>i(n.id)},n.id))})]}),(0,F.jsxs)("section",{className:"dsh-ssh-file-access-section is-options","aria-labelledby":"dsh-ssh-file-access-policy",children:[(0,F.jsx)("header",{children:(0,F.jsxs)("span",{children:[(0,F.jsx)("strong",{id:"dsh-ssh-file-access-policy",children:"\u8BBF\u95EE\u7B56\u7565"}),(0,F.jsx)("small",{children:"\u6587\u4EF6\u6743\u9650\u4E0E SSH \u547D\u4EE4\u3001\u7EC8\u7AEF\u6743\u9650\u76F8\u4E92\u72EC\u7ACB"})]})}),(0,F.jsxs)("div",{className:"dsh-ssh-file-access-options",children:[(0,F.jsxs)("div",{className:"dsh-ssh-file-access-policy-row",children:[(0,F.jsxs)("span",{children:[(0,F.jsx)("strong",{children:"\u6587\u4EF6\u64CD\u4F5C\u6743\u9650"}),(0,F.jsx)("small",{children:"\u6D4F\u89C8\u6A21\u5F0F\u4E0D\u4F1A\u5411 AI \u66B4\u9732\u8DE8\u7AEF\u4F20\u8F93\u5DE5\u5177"})]}),(0,F.jsx)(jx,{value:r?.filePermission??"browse",onChange:t.setFilePermission})]}),(0,F.jsxs)("div",{className:"dsh-ssh-file-access-policy-row",children:[(0,F.jsxs)("span",{children:[(0,F.jsx)("strong",{children:"\u4F20\u8F93\u524D\u786E\u8BA4"}),(0,F.jsx)("small",{children:"AI \u53D1\u8D77\u4F20\u8F93\u65F6\u8BF7\u6C42 DSH \u6388\u6743"})]}),(0,F.jsx)(Wx,{checked:r?.requireFileApproval??!0,onChange:t.setRequireFileApproval})]})]})]})]}),(0,F.jsxs)("footer",{className:"dsh-ssh-file-access-footer",children:[(0,F.jsxs)("span",{className:t.saving?"is-saving":"is-saved",children:[(0,F.jsx)("i",{"aria-hidden":"true"}),t.saving?"\u6B63\u5728\u4FDD\u5B58\u66F4\u6539":`${o>0?`\u5DF2\u6388\u6743 ${o} \u4E2A\u8FDE\u63A5`:"\u672A\u6388\u6743\u8FDE\u63A5"} \xB7 \u81EA\u52A8\u4FDD\u5B58`]}),(0,F.jsx)("button",{type:"button",className:"dsh-ssh-primary-button","data-ssh-dialog-close":!0,disabled:t.saving,onClick:s,children:t.saving?"\u4FDD\u5B58\u4E2D\u2026":"\u5B8C\u6210"})]})]})}function Vx({endpoint:e,enabled:t,onToggle:s}){return(0,F.jsxs)("button",{type:"button","data-ssh-interactive":"choice",className:`dsh-ssh-file-access-endpoint${t?" is-mounted":""}`,"aria-pressed":t,onClick:s,children:[(0,F.jsx)("span",{className:`dsh-ssh-protocol-badge is-${e.protocol}`,children:Vl(e.protocol)}),(0,F.jsxs)("span",{className:"dsh-ssh-file-access-endpoint-copy",children:[(0,F.jsx)("strong",{title:e.name,children:e.name}),(0,F.jsx)("small",{title:e.address,children:e.address})]}),(0,F.jsxs)("span",{className:"dsh-ssh-file-access-state",children:[(0,F.jsx)("i",{"aria-hidden":"true",children:(0,F.jsx)("b",{})}),(0,F.jsx)("em",{children:t?"\u5DF2\u6388\u6743":"\u672A\u6388\u6743"})]})]})}function $x(){return(0,F.jsx)("div",{className:"dsh-ssh-file-access-skeleton","aria-label":"\u6B63\u5728\u8BFB\u53D6\u4F1A\u8BDD\u6743\u9650",children:[0,1,2].map(e=>(0,F.jsxs)("span",{style:{"--ssh-skeleton-index":e},children:[(0,F.jsx)("i",{}),(0,F.jsxs)("b",{children:[(0,F.jsx)("i",{}),(0,F.jsx)("i",{})]}),(0,F.jsx)("em",{})]},e))})}function jx({value:e,onChange:t}){return(0,F.jsx)("div",{className:"dsh-ssh-file-permission-picker",role:"radiogroup","aria-label":"\u6587\u4EF6\u64CD\u4F5C\u6743\u9650",children:[["browse","\u4EC5\u6D4F\u89C8"],["transfer","\u5141\u8BB8\u4F20\u8F93"]].map(([s,r])=>(0,F.jsx)("button",{type:"button","data-ssh-interactive":"choice",role:"radio","aria-checked":e===s,className:e===s?"is-active":"",onClick:()=>t(s),children:r},s))})}function Wx({checked:e,onChange:t}){return(0,F.jsxs)("button",{type:"button","data-ssh-interactive":"choice",role:"switch","aria-checked":e,className:`dsh-ssh-file-approval-switch${e?" is-active":""}`,onClick:()=>t(!e),children:[(0,F.jsx)("i",{"aria-hidden":"true",children:(0,F.jsx)("b",{})}),(0,F.jsx)("span",{children:e?"\u9700\u8981\u786E\u8BA4":"\u76F4\u63A5\u6267\u884C"})]})}function qx(){try{let e=JSON.parse(localStorage.getItem(yf)??"[]");if(!Array.isArray(e))return[Ul("transfer-1",1)];let t=e.slice(0,8).flatMap(s=>{if(typeof s!="object"||s===null)return[];let r=s;if(typeof r.id!="string"||!/^[a-zA-Z0-9_-]{1,100}$/.test(r.id)||typeof r.name!="string"||!Array.isArray(r.panes))return[];let o=r.panes.slice(0,4).flatMap(i=>{if(typeof i!="object"||i===null)return[];let n=i;return typeof n.id=="string"&&/^[a-zA-Z0-9_-]{1,100}$/.test(n.id)&&typeof n.endpointId=="string"&&typeof n.path=="string"?[{id:n.id,endpointId:"",path:"/"}]:[]});return o.length>=2?[{id:r.id,name:r.name.slice(0,40),panes:o}]:[]});if(t.length>0)return t}catch{}return[Ul("transfer-1",1)]}function Ul(e,t){return{id:e,name:`\u4EFB\u52A1 ${t}`,panes:[jn(`${e}-a`),jn(`${e}-b`)]}}function jn(e){return{id:e,endpointId:"",path:"/"}}function Kx(e,t){return e.map(s=>({...s,panes:s.panes.map(r=>!r.endpointId||t.some(o=>o.id===r.endpointId)?r:jn(r.id))}))}function Gx(e,t){return e.find(s=>s.id===t)?.name??t}function kf(e){let t=e[0]?.replaceAll("\\","/").split("/").filter(Boolean).at(-1)??"\u6587\u4EF6";return e.length>1?`${t} \u7B49 ${e.length} \u9879`:t}function Vl(e){return e==="sftp"?"SFTP":e==="ftp"?"FTP":e==="ftps-explicit"?"FTPS":"FTPS-I"}function $n(e,t){return JSON.stringify([e,t.replaceAll("\\","/").replace(/\/+$/,"")||"/"])}function Xx(e,t){return e===void 0||e.paneId!==t.id&&!ni(e,{endpointId:t.endpointId,directory:t.path})}function _f(e){return e==="completed"||e==="failed"||e==="cancelled"}function Cf(e){return e<1024?`${e} B`:e<1024**2?`${(e/1024).toFixed(1)} KB`:e<1024**3?`${(e/1024**2).toFixed(1)} MB`:`${(e/1024**3).toFixed(2)} GB`}function Jx(e,t){if(e.state==="queued")return"\u7B49\u5F85\u4F20\u8F93";if(e.state==="scanning")return"\u6B63\u5728\u626B\u63CF\u76EE\u5F55";if(e.state==="transferring"){let s=Math.max(1,(Date.now()-(e.startedAt??Date.now()))/1e3),r=e.transferredBytes/s,o=r>0?Math.max(0,(e.totalBytes-e.transferredBytes)/r):0;return`${t.toFixed(0)}% \xB7 ${Cf(r)}/s${o>1?` \xB7 \u7EA6 ${Zx(o)}`:""}`}return e.state==="completed"?`\u5DF2\u5B8C\u6210 ${e.completedFiles} \u4E2A\u6587\u4EF6${e.skippedFiles?`\uFF0C\u8DF3\u8FC7 ${e.skippedFiles}`:""}`:e.state==="cancelled"?"\u5DF2\u53D6\u6D88":"\u4F20\u8F93\u5931\u8D25"}function Yx(e){if(e.startedAt===void 0)return`\u521B\u5EFA\u4E8E ${xf(e.createdAt)}`;let t=e.completedAt??Date.now(),s=Qx(Math.max(0,t-e.startedAt));return e.completedAt===void 0?`\u5DF2\u6267\u884C ${s}`:`\u8017\u65F6 ${s} \xB7 \u5B8C\u6210\u4E8E ${xf(e.completedAt)}`}function xf(e){return Mx.format(e)}function Qx(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t} \u79D2`;let s=Math.floor(t/60);return s<60?`${s} \u5206 ${String(t%60).padStart(2,"0")} \u79D2`:`${Math.floor(s/60)} \u5C0F\u65F6 ${String(s%60).padStart(2,"0")} \u5206`}function Zx(e){if(e<60)return`${Math.ceil(e)} \u79D2`;let t=Math.ceil(e/60);return t<60?`${t} \u5206\u949F`:`${Math.floor(t/60)} \u5C0F\u65F6 ${t%60} \u5206\u949F`}function ey(){return(0,F.jsx)("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:(0,F.jsx)("path",{d:"M8 12V4m0 0L4.8 7.2M8 4l3.2 3.2"})})}function ty(){return(0,F.jsx)("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:(0,F.jsx)("path",{d:"M12.2 5.2A5 5 0 1 0 13 9M12.2 5.2V2.5m0 2.7H9.5"})})}function sy({directory:e}){return(0,F.jsx)("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e?(0,F.jsx)("path",{d:"M2 4.3h4l1.2 1.4H14v6.8H2z"}):(0,F.jsx)("path",{d:"M3.2 2h6l3.6 3.6V14H3.2zm6 0v3.6h3.6"})})}var Ef=`.dsh-ssh-transfer-workspace {
5515
5515
  display: flex;
5516
5516
  width: 100%;
5517
5517
  height: 100%;
@@ -6529,6 +6529,14 @@ body[data-ds-dark-theme] :is(
6529
6529
  background: var(--ssh-modal-surface);
6530
6530
  }
6531
6531
  }
6532
+ .dsh-ssh-file-download-dialog > header { gap: 12px; padding-block: 14px; }
6533
+ .dsh-ssh-file-download-dialog > header > span { flex: 1; min-width: 0; }
6534
+ .dsh-ssh-file-download-dialog > header h2 { overflow-wrap: anywhere; }
6535
+ .dsh-ssh-file-download-dialog > header p { overflow-wrap: anywhere; }
6536
+ .dsh-ssh-file-download-dialog > header > button { flex: none; }
6537
+ .dsh-ssh-file-download-dialog > .dsh-ssh-dialog-actions { padding: 16px 18px max(18px, env(safe-area-inset-bottom)); }
6538
+ .dsh-ssh-file-download-dialog .dsh-ssh-dialog-actions > a { flex: none; white-space: nowrap; text-decoration: none; min-height: 44px; padding-inline: 14px; }
6539
+ .dsh-ssh-file-download-dialog .dsh-ssh-dialog-actions > a > svg { flex: 0 0 16px; width: 16px; height: 16px; }
6532
6540
  `;var D=require("react/jsx-runtime"),Wn="@lemoncat7/dsh-ssh",$l=`${Wn}/client`,iy=["slots","layout","sessions","workspaces"];function ny(e){e.effect(Py,"dsh-ssh: styles");let t=ay(e),s=oy(e,()=>t.close());e.effect(()=>Yp(Wn,()=>{s.close(),t.close()}),"dsh-ssh: exclusive workspace"),e.effect(()=>()=>{s.close(),t.dispose()},"dsh-ssh: workspace lifecycle"),e.slots.inject("sidebar.footer.action",()=>e.slots.register({name:"sidebar.footer.action",id:"ssh-remote",order:-100},r=>(0,D.jsx)(ly,{...r,controller:s,activityController:t,collapseSidebar:()=>e.layout.toggleSidebar()})))}function oy(e,t){let s=e,r=new Set,o,i,n=()=>{for(let h of r)h()},a={open(h){t(),h!==void 0&&(o=h),i===void 0&&(Ol(Wn),i=e.slots.register({name:"conversation",priority:-2},l=>(0,D.jsx)(hy,{...l,controller:a}))),n()},toggle(){i===void 0?a.open():a.close()},close(){if(i===void 0)return;let h=i;i=void 0,h(),n()},isOpen:()=>i!==void 0,selected:()=>o,subscribe(h){return r.add(h),()=>r.delete(h)},async createProjectSession(h,l,c,f){let v=await s.sessions.create({workspaceId:h});return await Ri({...Si(String(v)),profileIds:[l.profileId],permission:c,requireCommandApproval:f,workingDirectories:{[l.profileId]:l.path},workingProjectIds:{[l.profileId]:l.id}}),s.sessions.open(v),String(v)}};return a}function ay(e){let t=e,s=new Set,r=new Map,o=Tf(t.sessions.list.getSnapshot().current),i,n,a,h=()=>{for(let d of s)d()},l=()=>{n!==void 0&&(window.cancelAnimationFrame(n),n=void 0)},c=()=>{if(a===void 0)return!1;let d=a;return a=void 0,i=void 0,d(),!0},f=(d,m=!0)=>{i===d&&a!==void 0||(c(),i=d,a=e.slots.register({name:"details",priority:-2},p=>(0,D.jsx)(Wp,{...p,controller:g})),m&&e.layout.openDetails())},v=()=>{let d=t.sessions.list.getSnapshot(),m=Tf(d.current);if(m===o)return;l();let p=c();o=m,m!==void 0&&r.get(m)?.open===!0?(f(m,!1),n=window.requestAnimationFrame(()=>{n=void 0,o===m&&i===m&&r.get(m)?.open===!0&&e.layout.openDetails()})):p&&e.layout.closeDetails(),h()},g={open(d,m,p){let b=p??(m===void 0?"local-directory":"remote-directory"),x=r.get(d),y=m??x?.selectedProfileId;r.set(d,{open:!0,...y===void 0?{}:{selectedProfileId:y},requestedView:b}),Ol(Wn),d===o&&(l(),f(d),e.layout.openDetails()),h()},toggle(d){if(r.get(d)?.open===!0)return g.close(d);g.open(d)},close(d){let m=d??o;if(m===void 0)return;let p=r.get(m);p!==void 0&&r.set(m,{...p,open:!1}),m===o&&(l(),c()&&e.layout.closeDetails()),h()},isOpen:d=>r.get(d)?.open===!0,selected:d=>r.get(d)?.selectedProfileId,requestedView:d=>r.get(d)?.requestedView,subscribe(d){return s.add(d),()=>s.delete(d)},dispose(){u(),l(),c(),r.clear(),s.clear()}},u=t.sessions.list.subscribe(v);return g}function Tf(e){return typeof e=="string"&&e.length>0?e:void 0}function ly(e){let t=(0,oe.useRef)(null);rf(t);let s=e.useSessions(p=>p.current),r=s===void 0?void 0:String(s),[o,i]=(0,oe.useState)([]),[n,a]=(0,oe.useState)(null),[h,l]=(0,oe.useState)(!0),c=(0,oe.useSyncExternalStore)(e.controller.subscribe,e.controller.isOpen),f=(0,oe.useSyncExternalStore)(e.activityController.subscribe,()=>r!==void 0&&e.activityController.isOpen(r));(0,oe.useEffect)(()=>lf(p=>{p.sessionId===r&&a(p)}),[r]);let v=(0,oe.useCallback)(async()=>{let p=await Xn().catch(()=>[]);i(p),a(s===void 0?null:await Di(String(s)).catch(()=>null))},[s]);(0,oe.useEffect)(()=>{v()},[v,c]);let g=n===null?[]:n.profileIds.map(p=>o.find(b=>b.id===p)).filter(p=>p!==void 0);(0,oe.useEffect)(()=>{if(r===void 0||n?.permission!=="terminal")return;let p=new EventSource(lh(r)),b=x=>{let y=Cy(x);y===void 0||y.sessionId!==r||(e.controller.close(),e.activityController.open(r,y.profileId,"terminals"))};return p.addEventListener("terminal-opened",b),()=>{p.removeEventListener("terminal-opened",b),p.close()}},[r,n?.permission,e.activityController,e.controller]);let u=p=>{r!==void 0&&(e.controller.close(),e.activityController.open(r,p,p===void 0?"local-directory":"remote-directory"))},d=()=>{r!==void 0&&(f?e.activityController.close(r):u())},m=()=>{e.controller.open(),e.wide&&window.matchMedia("(max-width: 820px)").matches&&e.collapseSidebar()};return e.wide?(0,D.jsxs)("section",{ref:t,className:"dsh-ssh-sidebar",children:[(0,D.jsxs)("div",{className:"dsh-ssh-sidebar-heading",children:[(0,D.jsxs)("button",{type:"button",className:"dsh-ssh-sidebar-title","aria-expanded":h,onClick:()=>l(p=>!p),children:[(0,D.jsx)("span",{className:"dsh-ssh-disclosure","data-open":h,children:(0,D.jsx)(Ee.IconChevronDownOutline14,{size:14})}),(0,D.jsx)("span",{children:"\u8FDC\u7AEF"})]}),(0,D.jsx)("button",{type:"button","data-ssh-interactive":"choice",className:`dsh-ssh-icon-button${f?" is-active":""}`,"aria-label":f?"\u6536\u8D77 SSH \u4FA7\u680F":"\u5C55\u5F00 SSH \u4FA7\u680F",title:r===void 0?"\u6253\u5F00\u4F1A\u8BDD\u540E\u53EF\u67E5\u770B SSH \u4FA7\u680F":f?"\u6536\u8D77 SSH \u4FA7\u680F":"\u5C55\u5F00 SSH \u4FA7\u680F","aria-pressed":f,disabled:r===void 0,onClick:d,children:(0,D.jsx)(Ee.IconPanelLeftOutline16,{size:16,className:"dsh-ssh-panel-right-icon"})})]}),h&&(0,D.jsxs)("div",{className:"dsh-ssh-sidebar-list",children:[(0,D.jsxs)("button",{type:"button",className:"dsh-ssh-sidebar-panel",onClick:m,children:[(0,D.jsx)(Os,{}),(0,D.jsx)("span",{children:"SSH \u9762\u677F"})]}),r===void 0?(0,D.jsx)("p",{className:"dsh-ssh-sidebar-note",children:"\u6253\u5F00\u4F1A\u8BDD\u540E\u663E\u793A\u53EF\u7528\u8FDC\u7AEF"}):g.length===0?(0,D.jsx)("p",{className:"dsh-ssh-sidebar-note",children:"\u5F53\u524D\u4F1A\u8BDD\u672A\u6388\u6743\u8FDC\u7AEF"}):g.slice(0,6).map(p=>(0,D.jsxs)("button",{type:"button","data-ssh-interactive":"choice","aria-pressed":f&&e.activityController.selected(r)===p.id,className:`dsh-ssh-sidebar-row${f&&e.activityController.selected(r)===p.id?" is-active":""}`,onClick:()=>u(p.id),children:[(0,D.jsx)("span",{className:"dsh-ssh-status-dot is-injected","aria-hidden":"true"}),(0,D.jsxs)("span",{className:"dsh-ssh-sidebar-copy",children:[(0,D.jsx)("strong",{children:p.name}),(0,D.jsx)("small",{children:p.host})]}),(0,D.jsx)("span",{className:"dsh-ssh-injected-mark",children:"\u5DF2\u6302\u8F7D"})]},p.id)),g.length>6&&(0,D.jsxs)("button",{type:"button",className:"dsh-ssh-sidebar-more",onClick:d,children:["\u8FD8\u6709 ",g.length-6," \u53F0\u53EF\u7528\u8FDC\u7AEF"]})]})]}):(0,D.jsx)("section",{ref:t,className:"dsh-ssh-sidebar is-rail",children:(0,D.jsx)("button",{type:"button","data-ssh-interactive":"choice",className:`dsh-ssh-rail-button${f?" is-active":""}`,title:r===void 0?"\u6253\u5F00\u4F1A\u8BDD\u540E\u53EF\u67E5\u770B SSH \u4FA7\u680F":f?"\u6536\u8D77 SSH \u4FA7\u680F":"\u5C55\u5F00 SSH \u4FA7\u680F","aria-label":f?"\u6536\u8D77 SSH \u4FA7\u680F":"\u5C55\u5F00 SSH \u4FA7\u680F","aria-pressed":f,disabled:r===void 0,onClick:d,children:(0,D.jsx)(Os,{})})})}function hy(e){let t=dr(),s=e.useSessions(N=>N.current),r=e.useWorkspaces(N=>N),[o,i]=(0,oe.useState)([]),[n,a]=(0,oe.useState)([]),[h,l]=(0,oe.useState)([]),[c,f]=(0,oe.useState)([]),[v,g]=(0,oe.useState)(()=>e.controller.selected()===void 0?null:{profileId:e.controller.selected(),path:"~"}),[u,d]=(0,oe.useState)("workspace"),[m,p]=(0,oe.useState)(),[b,x]=(0,oe.useState)(),[y,S]=(0,oe.useState)(0),[_,w]=(0,oe.useState)(),P=cf(s===void 0?void 0:String(s)),E=(0,oe.useRef)(s),T=(0,oe.useCallback)(async()=>{try{let[N,V,k,I]=await Promise.all([Xn(),Gl(),eh(),th()]);i(N),f(V),a(k),l(I),g(A=>A!==null&&N.some(C=>C.id===A.profileId)?A:N[0]===void 0?null:{profileId:N[0].id,path:"~"}),w(void 0)}catch(N){w(Xe(N))}},[]);(0,oe.useEffect)(()=>{let N=()=>{let V=e.controller.selected();V!==void 0&&g(k=>({profileId:V,path:k?.profileId===V?k.path:"~"}))};return N(),e.controller.subscribe(N)},[e.controller]),(0,oe.useEffect)(()=>{T()},[T,y]),(0,oe.useEffect)(()=>{E.current!==s&&e.controller.close()},[e.controller,s]);let R=o.find(N=>N.id===v?.profileId),M=r.items.find(N=>s!==void 0&&N.sessionIds.includes(s))?.workspaceId,B=(0,D.jsxs)("header",{ref:t.ref,onPointerMove:t.onPointerMove,onPointerLeave:t.onPointerLeave,className:"dsh-ssh-toolbar dsh-ssh-border-surface",children:[(0,D.jsxs)("div",{className:"dsh-ssh-brand",children:[(0,D.jsx)("button",{type:"button",className:"dsh-ssh-icon-button","aria-label":"\u8FD4\u56DE\u4F1A\u8BDD",title:"\u8FD4\u56DE\u4F1A\u8BDD",onClick:()=>e.controller.close(),children:(0,D.jsx)(Ee.IconChevronLeftOutline14,{size:15})}),(0,D.jsx)("span",{className:"dsh-ssh-brand-glyph",children:(0,D.jsx)(Os,{})}),(0,D.jsxs)("span",{children:[(0,D.jsx)("strong",{children:"SSH \u5DE5\u4F5C\u53F0"}),(0,D.jsx)("small",{children:u==="transfer"?"FTP \xB7 FTPS \xB7 SFTP":R===void 0?"\u9009\u62E9\u4E00\u53F0\u4E3B\u673A":`${R.username}@${R.host}`})]})]}),(0,D.jsxs)("nav",{className:"dsh-ssh-segments",role:"tablist","aria-label":"SSH \u5DE5\u4F5C\u53F0\u89C6\u56FE",children:[(0,D.jsx)(hr,{active:u==="workspace",onClick:()=>d("workspace"),children:"\u7EC8\u7AEF\u4E0E\u6587\u4EF6"}),(0,D.jsx)(hr,{active:u==="transfer",onClick:()=>d("transfer"),children:"\u6587\u4EF6\u4F20\u8F93"}),(0,D.jsx)(hr,{active:u==="forwards",onClick:()=>d("forwards"),children:"\u7AEF\u53E3\u8F6C\u53D1"}),(0,D.jsx)(hr,{active:u==="vault",onClick:()=>d("vault"),children:"\u5BC6\u94A5\u5E93"}),(0,D.jsx)(hr,{active:u==="proxies",onClick:()=>d("proxies"),children:"\u4EE3\u7406\u5E93"}),(0,D.jsx)(hr,{active:u==="settings",onClick:()=>d("settings"),children:"\u8BBE\u7F6E"})]})]});return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(Kp,{className:`dsh-ssh-workspace${u==="transfer"?" is-transfer":""}`,toolbar:B,notice:_&&(0,D.jsxs)("div",{className:"dsh-ssh-banner is-error",role:"alert",children:[(0,D.jsx)("span",{children:_}),(0,D.jsx)("button",{onClick:()=>w(void 0),"aria-label":"\u5173\u95ED",children:(0,D.jsx)(Ee.IconCloseOutline16,{size:16})})]}),navigationLabel:"\u4E3B\u673A",navigationIcon:(0,D.jsx)(Ee.IconDataOutline16,{size:15}),navigation:N=>(0,D.jsx)(af,{profiles:o,access:P.value,accessLoading:P.loading,accessSaving:P.saving,accessError:P.error,workspaces:r.items,currentWorkspaceId:M===void 0?void 0:String(M),recentWorkspaceId:r.recentWorkspaceId===void 0?void 0:String(r.recentWorkspaceId),selected:v,onSelect:V=>{g(V),d("workspace"),e.controller.open(V.profileId),N.closePanel()},onProfiles:P.setProfiles,onDirectory:(V,k,I)=>{P.setDirectory(V,k,I),k!==void 0&&(g({profileId:V,path:k,...I===void 0?{}:{projectId:I}}),d("workspace"))},onPermission:P.setPermission,onApproval:P.setRequireCommandApproval,onCreateSession:async(V,k)=>{await e.controller.createProjectSession(k,V,P.value?.permission??"exec",P.value?.requireCommandApproval??!0),e.controller.close()},onNewProfile:()=>{p("new"),N.closePanel()}}),children:(0,D.jsx)("section",{className:"dsh-ssh-main-panel dsh-ssh-scroll-surface",children:u==="transfer"?(0,D.jsx)(wf,{ftpProfiles:c,vaultEntries:n,proxyEntries:h,access:P,onProfilesChanged:()=>S(N=>N+1)}):u==="vault"?(0,D.jsx)(py,{entries:n,onChanged:()=>S(N=>N+1)}):u==="proxies"?(0,D.jsx)(my,{entries:h,onChanged:()=>S(N=>N+1)}):R===void 0?(0,D.jsx)(Dp,{}):u==="workspace"?(0,D.jsx)(cy,{profile:R,initialPath:v?.path??"~",onEdit:()=>p(R),onDelete:()=>x(R)},R.id):u==="forwards"?(0,D.jsx)(uy,{profiles:o,selected:R}):(0,D.jsx)(vy,{})})}),m!==void 0&&(0,D.jsx)(gf,{profile:m==="new"?void 0:m,profiles:o,vaultEntries:n,proxyEntries:h,onClose:()=>p(void 0),onSaved:()=>{p(void 0),S(N=>N+1)}}),b!==void 0&&(0,D.jsx)(mf,{profile:b,dependents:o.filter(N=>N.id!==b.id&&N.proxy.type==="jump"&&N.proxy.profileIds.includes(b.id)),onClose:()=>x(void 0),onDeleted:()=>{x(void 0),p(void 0),S(N=>N+1)}})]})}function cy({profile:e,initialPath:t,onEdit:s,onDelete:r}){let[o,i]=(0,oe.useState)(!1),n=dr();return(0,D.jsxs)("div",{className:"dsh-ssh-host-workbench",children:[(0,D.jsxs)("header",{ref:n.ref,onPointerMove:n.onPointerMove,onPointerLeave:n.onPointerLeave,className:"dsh-ssh-workbench-heading dsh-ssh-border-surface",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{className:"dsh-ssh-host-monogram",children:e.name.slice(0,1).toUpperCase()}),(0,D.jsxs)("span",{children:[(0,D.jsx)("h1",{children:e.name}),(0,D.jsxs)("p",{children:[rs(e)," \xB7 ",Rf(e)]})]})]}),(0,D.jsxs)("div",{className:"dsh-ssh-heading-actions",children:[(0,D.jsx)("button",{type:"button",className:"dsh-ssh-icon-button is-danger","aria-label":`\u5220\u9664\u4E3B\u673A ${e.name}`,title:"\u5220\u9664\u4E3B\u673A",onClick:r,children:(0,D.jsx)(Ee.IconTrashOutline16,{size:16})}),(0,D.jsxs)("button",{type:"button",className:"dsh-ssh-secondary-button",onClick:s,children:[(0,D.jsx)(Ee.IconEditOutline16,{size:16}),"\u7F16\u8F91\u4E3B\u673A"]})]})]}),(0,D.jsx)(uf,{storageKey:"dsh-ssh:workbench:sftp-width",label:"\u8C03\u6574\u7EC8\u7AEF\u4E0E SFTP \u7684\u5BBD\u5EA6",primary:(0,D.jsx)("section",{className:"dsh-ssh-workbench-terminal","aria-label":`${e.name} \u7EC8\u7AEF`,children:(0,D.jsx)(dy,{profile:e,onEdit:s,onDelete:r,onConnected:()=>i(!0),embedded:!0})}),secondary:(0,D.jsx)("section",{className:"dsh-ssh-workbench-files","aria-label":`${e.name} SFTP`,children:o?(0,D.jsx)(zp,{profile:e,initialPath:t,embedded:!0},`${e.id}:${t}`):(0,D.jsxs)("div",{className:"dsh-ssh-sftp-deferred",children:[(0,D.jsx)("span",{children:"SFTP"}),(0,D.jsx)("strong",{children:"\u7B49\u5F85\u7EC8\u7AEF\u8FDE\u63A5"}),(0,D.jsx)("p",{children:"\u6253\u5F00\u7EC8\u7AEF\u540E\u518D\u8BFB\u53D6\u8FDC\u7AEF\u76EE\u5F55\u3002"})]})})})]})}function dy({profile:e,onEdit:t,onDelete:s,onConnected:r,embedded:o=!1}){let i=(0,oe.useRef)(null),n=(0,oe.useRef)(),a=(0,oe.useRef)(),h=(0,oe.useRef)(),[l,c]=(0,oe.useState)(),[f,v]=(0,oe.useState)("idle"),[g,u]=(0,oe.useState)();(0,oe.useEffect)(()=>{let p=i.current;if(p===null)return;let b=Bn({scrollback:5e3}),x=new Pf.FitAddon;b.loadAddon(x),b.open(p),n.current=b,a.current=x;let y=Nn(p,b,x,(S,_)=>{let w=h.current;w!==void 0&&ie(`/terminals/${w}/resize`,{method:"POST",body:JSON.stringify({cols:S,rows:_})}).catch(()=>{})});return()=>{y.dispose(),b.dispose(),n.current=void 0,a.current=void 0}},[]),(0,oe.useEffect)(()=>{h.current=l},[l]),(0,oe.useEffect)(()=>{if(l===void 0)return;let p=n.current;if(p===void 0)return;let b=new Nr({streamUrl:Ch(l),read:S=>ie(`/terminals/${l}/output?cursor=${S}`),send:(S,_)=>ie(`/terminals/${l}/input`,{method:"POST",body:JSON.stringify({text:S,sequence:_})})}),x=p.onData(S=>b.sendInput(S,_=>u(Xe(_)))),y=b.observe({output:S=>{S.truncated&&p.write(`\r
6533
6541
  \x1B[33m[\u8F83\u65E9\u8F93\u51FA\u5DF2\u622A\u65AD]\x1B[0m\r
6534
6542
  `),S.data&&p.write(S.data),S.closed&&(v("idle"),c(void 0))},error:S=>{u(Xe(S)),v("error")}});return()=>{y(),b.dispose(),x.dispose()}},[l]),(0,oe.useEffect)(()=>()=>{l!==void 0&&ie(`/terminals/${l}`,{method:"DELETE"}).catch(()=>{})},[l]),(0,oe.useEffect)(()=>{c(void 0),v("idle"),n.current?.clear()},[e.id]);let d=async()=>{let p=n.current;if(p!==void 0){v("connecting"),u(void 0),p.clear(),p.write(`\x1B[2m\u6B63\u5728\u8FDE\u63A5 ${rs(e)}\u2026\x1B[0m\r