@deepseekcode/cli 1.0.37 → 1.0.38
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 +10 -1
- package/package.json +9 -9
- package/web/dist/assets/AssistantsView-Bh6ajWIo.js +1 -0
- package/web/dist/assets/AutomationView-D2Z-_4qe.js +1 -0
- package/web/dist/assets/{ChannelConfigView-JDljUn42.js → ChannelConfigView-DlakOI5z.js} +5 -5
- package/web/dist/assets/ConnectorsView-ELXDmM9m.js +1 -0
- package/web/dist/assets/FileTreeView-Ciq1vhTf.js +11 -0
- package/web/dist/assets/HookConfigView-DR8TP3QG.js +1 -0
- package/web/dist/assets/ModelsView-BW6eRUwf.js +1 -0
- package/web/dist/assets/PluginsView-CrHGk_JC.js +1 -0
- package/web/dist/assets/SessionGrid-DYYsm2dT.js +52 -0
- package/web/dist/assets/SettingsModal-DNxIKsKC.js +10 -0
- package/web/dist/assets/SkillsView-DS0nnKig.js +1 -0
- package/web/dist/assets/TemplatesTab-pXElHCnz.js +1 -0
- package/web/dist/assets/{ThreeScene-CMqkpyKO.js → ThreeScene-DFL_qzB1.js} +1 -1
- package/web/dist/assets/ToolsView-Bk4hckku.js +1 -0
- package/web/dist/assets/{icons-f1hlMKvD.js → icons-YJcunJnw.js} +195 -140
- package/web/dist/assets/index-CtPliI0f.css +1 -0
- package/web/dist/assets/index-D1N4vQ9I.js +591 -0
- package/web/dist/assets/{markdown-DEtuzEyz.js → markdown-CrVimah5.js} +1 -1
- package/web/dist/assets/{panels-Bn-2wCur.js → panels-BykQW6E1.js} +1 -1
- package/web/dist/assets/{react-vendor-ClBKp0t-.js → react-vendor-DM-M1fu_.js} +1 -1
- package/web/dist/assets/{state-xD58vmym.js → state-D8omNTWe.js} +1 -1
- package/web/dist/assets/sttLanguages-D4JbRJc6.js +1 -0
- package/web/dist/index.html +7 -7
- package/web/dist/assets/AssistantsView-OMdgsTIj.js +0 -1
- package/web/dist/assets/AutomationView-BPwjLbkL.js +0 -1
- package/web/dist/assets/ConnectorsView-AemNT1Ae.js +0 -1
- package/web/dist/assets/FileTreeView-DYx-0jFV.js +0 -11
- package/web/dist/assets/HookConfigView-CS1QqgPx.js +0 -1
- package/web/dist/assets/ModelsView-B3nHezvJ.js +0 -1
- package/web/dist/assets/PluginsView-C4Xc70ec.js +0 -1
- package/web/dist/assets/SessionGrid-C9-LeJH0.js +0 -47
- package/web/dist/assets/SettingsModal-CjWT1C66.js +0 -4
- package/web/dist/assets/SkillsView-DTZyXald.js +0 -1
- package/web/dist/assets/TemplatesTab-CE-CfCf2.js +0 -1
- package/web/dist/assets/ToolsView-CrEHDTEO.js +0 -1
- package/web/dist/assets/index-BCHbHIbw.css +0 -1
- package/web/dist/assets/index-u1vYyqna.js +0 -592
- package/web/dist/assets/sttLanguages-BNRptAQA.js +0 -1
package/README.md
CHANGED
|
@@ -201,7 +201,7 @@ On startup, `dscode` checks npm for the latest version asynchronously (non-block
|
|
|
201
201
|
|
|
202
202
|
## Terminal Verdict Figures
|
|
203
203
|
|
|
204
|
-
The `terminal_figure` tool
|
|
204
|
+
The `terminal_figure` tool replays captured ANSI bytes through xterm.js and Playwright, then composes a PNG with Python Pillow. It is an internal verification path rather than a user-facing feature: the Web UI entry point has been removed, so drive it from the CLI or let the agent call the tool (see [`packages/prompts/skills/figure.md`](../prompts/skills/figure.md)).
|
|
205
205
|
|
|
206
206
|
The published package includes the replay/composition scripts and declares its Node dependencies. The host still needs:
|
|
207
207
|
|
|
@@ -210,6 +210,15 @@ The published package includes the replay/composition scripts and declares its N
|
|
|
210
210
|
|
|
211
211
|
If either prerequisite is unavailable, the feature returns an actionable setup error and does not silently write outside the workspace. Capture remains a separate CLI/TUI step because it depends on the specific interface under test.
|
|
212
212
|
|
|
213
|
+
## Contributing: terminal renderer
|
|
214
|
+
|
|
215
|
+
The TUI renders in **fullscreen** (alt-screen) mode by default; `--inline` opts back
|
|
216
|
+
into main-screen mode. Before changing anything under `src/ink/` or `src/ink-yoga/`,
|
|
217
|
+
read [`docs/terminal-rendering-invariants.md`](../../docs/terminal-rendering-invariants.md)
|
|
218
|
+
— it lists the hard invariants (layout-cache generations, the alt-screen trailing
|
|
219
|
+
newline, the fd-write ban), the bug behind each one, and the regression test that
|
|
220
|
+
guards it.
|
|
221
|
+
|
|
213
222
|
## License
|
|
214
223
|
|
|
215
224
|
Proprietary — © 2026 DeepSeekCode. All rights reserved.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseekcode/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.38",
|
|
4
4
|
"description": "DeepSeekCode TypeScript CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
"xterm": "5.3.0"
|
|
20
20
|
},
|
|
21
21
|
"optionalDependencies": {
|
|
22
|
-
"@deepseekcode/cli-darwin-arm64": "1.0.
|
|
23
|
-
"@deepseekcode/cli-darwin-x64": "1.0.
|
|
24
|
-
"@deepseekcode/cli-linux-x64": "1.0.
|
|
25
|
-
"@deepseekcode/cli-linux-arm64": "1.0.
|
|
26
|
-
"@deepseekcode/cli-linux-x64-musl": "1.0.
|
|
27
|
-
"@deepseekcode/cli-linux-arm64-musl": "1.0.
|
|
28
|
-
"@deepseekcode/cli-win32-x64": "1.0.
|
|
29
|
-
"@deepseekcode/cli-win32-arm64": "1.0.
|
|
22
|
+
"@deepseekcode/cli-darwin-arm64": "1.0.38",
|
|
23
|
+
"@deepseekcode/cli-darwin-x64": "1.0.38",
|
|
24
|
+
"@deepseekcode/cli-linux-x64": "1.0.38",
|
|
25
|
+
"@deepseekcode/cli-linux-arm64": "1.0.38",
|
|
26
|
+
"@deepseekcode/cli-linux-x64-musl": "1.0.38",
|
|
27
|
+
"@deepseekcode/cli-linux-arm64-musl": "1.0.38",
|
|
28
|
+
"@deepseekcode/cli-win32-x64": "1.0.38",
|
|
29
|
+
"@deepseekcode/cli-win32-arm64": "1.0.38"
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
32
32
|
"bin/",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./markdown-CrVimah5.js";import{a as r,ax as v,j as C,L as w,aq as S,ar as z,b6 as y,aO as I,ab as q,n as E}from"./icons-YJcunJnw.js";import{u as k,a as N,ao as A,aq as R,ap as $}from"./index-D1N4vQ9I.js";import"./react-vendor-DM-M1fu_.js";import"./state-D8omNTWe.js";import"./panels-BykQW6E1.js";const F=r.memo(function({selectedSessionId:s,onSelectionChange:c,onOpenSession:i,onNavigate:m}){const{t:n}=k(),[d,h]=r.useState([]),[a,u]=r.useState(!0),[p,b]=r.useState(null),[f,j]=r.useState(null),x=r.useCallback(async()=>{try{const t=await N.assistants.list();t.success&&Array.isArray(t.data)?(h(t.data),b(null)):b(t.error||n("assistants.loadFailed"))}catch(t){b(t instanceof Error?t.message:String(t))}finally{u(!1)}},[n]);r.useEffect(()=>{x();const t=window.setInterval(()=>{x()},8e3);return()=>window.clearInterval(t)},[x]);const l=r.useCallback(async(t,g)=>{(await N.assistants.update(t,g)).success&&x()},[x]);return r.useEffect(()=>{if(!s)return;const t=d.find(g=>g.sessionId===s);t&&c(t)},[d,s,c]),e.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-dark-border px-4 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{size:16,className:"text-accent-blue","aria-hidden":"true"}),e.jsx("h2",{className:"text-sm font-semibold text-dark-text",children:n("assistants.title")}),!a&&e.jsx("span",{className:"rounded-full bg-dark-hover px-1.5 py-0.5 text-[10px] text-dark-muted",children:d.length})]}),e.jsxs("button",{type:"button",onClick:()=>void x(),className:"flex items-center gap-1 rounded px-2 py-1 text-xs text-dark-muted hover:bg-dark-hover hover:text-dark-text",title:n("common.refresh"),children:[e.jsx(C,{size:12,className:a?"animate-spin":"","aria-hidden":"true"}),n("common.refresh")]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:a&&d.length===0?e.jsxs("div",{className:"flex items-center justify-center py-12 text-xs text-dark-muted",children:[e.jsx(w,{size:14,className:"mr-1.5 animate-spin","aria-hidden":"true"}),n("assistants.loading")]}):p&&d.length===0?e.jsx("div",{className:"py-8 text-center text-xs text-red-400",children:p}):d.length===0?e.jsxs("div",{className:"py-10 text-center text-xs text-dark-muted",children:[e.jsx(v,{size:24,className:"mx-auto mb-2 text-dark-muted","aria-hidden":"true"}),e.jsx("p",{children:n("assistants.empty")}),e.jsx("p",{className:"mt-1 text-[11px]",children:n("assistants.emptyHint")}),e.jsx("button",{type:"button",onClick:()=>m("channels"),className:"mt-3 rounded border border-dark-border px-2.5 py-1 text-[11px] text-dark-text hover:bg-dark-hover",children:n("assistants.goChannels")})]}):e.jsx("div",{className:"flex flex-col gap-2",children:d.map(t=>e.jsx(M,{assistant:t,selected:s===t.sessionId,onSelect:()=>c(t),expanded:f===t.sessionId,onToggleExpand:()=>j(f===t.sessionId?null:t.sessionId),onOpen:()=>i(t.sessionId,t.title),onUpdate:g=>void l(t.sessionId,g)},t.sessionId))})})]})}),M=r.memo(function({assistant:s,selected:c,onSelect:i,expanded:m,onToggleExpand:n,onOpen:d,onUpdate:h}){const{t:a}=k(),u=s.channel.peerKind==="group";return e.jsxs("div",{className:`rounded-lg border bg-dark-surface transition-colors ${c?"border-accent-blue/60 ring-1 ring-accent-blue/30":"border-dark-border"}`,children:[e.jsxs("button",{type:"button",onClick:i,"aria-current":c?"true":void 0,className:`flex w-full items-center gap-2 rounded-t-lg px-3 py-2 text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent-blue/60 ${c?"bg-accent-blue/5":"hover:bg-dark-hover/40"}`,children:[e.jsx("span",{className:"text-base leading-none","aria-hidden":"true",children:A(s.channel.type)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-dark-text",title:s.title,children:s.title}),e.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${R(s.status)}`,title:a(`assistants.status.${s.status}`,{defaultValue:s.status})}),u?e.jsx(S,{size:11,className:"shrink-0 text-dark-muted","aria-label":a("assistants.group")}):e.jsx(z,{size:11,className:"shrink-0 text-dark-muted","aria-label":a("assistants.dm")})]}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5 text-[10px] text-dark-muted",children:[e.jsx("span",{className:"shrink-0",children:$(s.channel.type)}),e.jsx("span",{className:"min-w-0 flex-1 truncate",title:s.channel.peerId,children:s.channel.peerId}),s.stats.unread>0&&e.jsx("span",{className:"shrink-0 rounded-full bg-red-500/80 px-1.5 text-[9px] font-medium text-white",children:s.stats.unread})]}),s.preview&&e.jsx("p",{className:"mt-1 line-clamp-2 text-[11px] leading-snug text-dark-muted",title:s.preview,children:s.preview})]}),e.jsx(L,{mode:s.mode}),s.trust.level==="owner"?e.jsx(y,{size:12,className:"shrink-0 text-green-500","aria-label":a("assistants.trust.owner")}):s.trust.level==="public"?e.jsx(I,{size:12,className:"shrink-0 text-yellow-600","aria-label":a("assistants.trust.public")}):e.jsx(y,{size:12,className:"shrink-0 text-accent-blue","aria-label":a("assistants.trust.team")})]}),e.jsxs("div",{className:"flex items-center gap-1.5 border-t border-dark-border px-3 py-1.5",children:[e.jsxs("button",{type:"button",onClick:d,className:"flex items-center gap-1 rounded px-2 py-0.5 text-[11px] text-accent-blue hover:bg-dark-hover",children:[e.jsx(q,{size:11,"aria-hidden":"true"}),a("assistants.openSession")]}),e.jsx("button",{type:"button",onClick:n,className:"flex items-center gap-1 rounded px-2 py-0.5 text-[11px] text-dark-muted hover:bg-dark-hover hover:text-dark-text",children:a("assistants.policy")}),e.jsx("span",{className:"flex-1"}),e.jsx("span",{className:"text-[10px] text-dark-muted",children:a("assistants.groupPolicy",{mention:String(u?s.policy.mentionRequired:!1)})})]}),m&&e.jsx(U,{assistant:s,isGroup:u,onUpdate:h})]})});function L({mode:o}){const{t:s}=k();return e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[9px] font-medium ${o==="delegate"?"bg-accent-blue/15 text-accent-blue":"bg-dark-hover text-dark-muted"}`,children:s(`assistants.mode.${o}`)})}function U({assistant:o,isGroup:s,onUpdate:c}){const{t:i}=k(),[m,n]=r.useState(o.mode),[d,h]=r.useState(o.policy.mentionRequired),[a,u]=r.useState(String(o.policy.cooldownSeconds)),[p,b]=r.useState((o.policy.keywords??[]).join(", ")),[f,j]=r.useState(!1),x=()=>{j(!0),c({mode:m,policy:{mentionRequired:s?d:!1,cooldownSeconds:Math.max(0,Number(a)||0),...p.trim()?{keywords:p.split(/[,,]/).map(l=>l.trim()).filter(Boolean)}:{}}}),window.setTimeout(()=>j(!1),600)};return e.jsxs("div",{className:"border-t border-dark-border px-3 py-2.5 text-[11px]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-dark-muted",children:[i("assistants.mode.label"),e.jsxs("select",{value:m,onChange:l=>n(l.target.value),className:"rounded border border-dark-border bg-dark-surface px-1.5 py-0.5 text-dark-text",children:[e.jsx("option",{value:"delegate",children:i("assistants.mode.delegate")}),e.jsx("option",{value:"direct",children:i("assistants.mode.direct")})]})]}),s&&e.jsxs("label",{className:"flex items-center gap-1.5 text-dark-muted",children:[e.jsx("input",{type:"checkbox",checked:d,onChange:l=>h(l.target.checked)}),i("assistants.mentionRequired")]}),e.jsxs("label",{className:"flex items-center gap-1.5 text-dark-muted",children:[i("assistants.cooldown"),e.jsx("input",{type:"number",min:0,value:a,onChange:l=>u(l.target.value),className:"w-14 rounded border border-dark-border bg-dark-surface px-1.5 py-0.5 text-dark-text"}),"s"]})]}),e.jsxs("label",{className:"mt-2 flex items-center gap-1.5 text-dark-muted",children:[i("assistants.keywords"),e.jsx("input",{type:"text",value:p,placeholder:i("assistants.keywordsPlaceholder")??"",onChange:l=>b(l.target.value),className:"min-w-0 flex-1 rounded border border-dark-border bg-dark-surface px-1.5 py-0.5 text-dark-text"})]}),e.jsx("div",{className:"mt-2 flex justify-end",children:e.jsxs("button",{type:"button",onClick:x,disabled:f,className:"flex items-center gap-1 rounded bg-accent-blue px-2.5 py-1 text-[11px] font-medium text-white disabled:opacity-60",children:[f?e.jsx(w,{size:11,className:"animate-spin","aria-hidden":"true"}):e.jsx(E,{size:11,"aria-hidden":"true"}),i("common.save")]})})]})}export{F as AssistantsView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./markdown-CrVimah5.js";import{a as i,aB as H,j as ve,A as te,l as ye,bB as Ne,ac as ae,ah as we,by as Ae,i as Ce,aH as Ie,b5 as $e,v as ze,X as q,b9 as se,L as ie,bd as Se,aA as re,bC as ne,F as K,b6 as De,bg as Pe,bh as Ee,T as qe}from"./icons-YJcunJnw.js";import{u as ce,ar as Re,N as Te,a as R,t as oe}from"./index-D1N4vQ9I.js";import"./react-vendor-DM-M1fu_.js";import"./state-D8omNTWe.js";import"./panels-BykQW6E1.js";const v={name:"",instructions:"",freq:"daily",time:"09:00",dow:"1",onceAt:"",cron:"0 9 * * *",modelRef:"",connectorIds:[],channelIds:[],workspaceDir:"",readAutoAllow:!0},Le=".deepseekcode/automation-attachments",j=a=>String(a).padStart(2,"0");function Oe(a){const n=a.schedule,h={modelRef:a.modelRef??"",connectorIds:Array.isArray(a.connectorIds)?[...a.connectorIds]:[],channelIds:Array.isArray(a.notificationChannelIds)?[...a.notificationChannelIds]:[],workspaceDir:a.workspaceDir??"",readAutoAllow:a.readAutoAllow};if(n.kind==="once"&&n.fireAt){const x=new Date(n.fireAt);return{...v,name:a.name,instructions:a.instructions,freq:"once",time:`${j(x.getHours())}:${j(x.getMinutes())}`,onceAt:`${x.getFullYear()}-${j(x.getMonth()+1)}-${j(x.getDate())}T${j(x.getHours())}:${j(x.getMinutes())}`,...h}}const o=(n.cron||"").trim().split(/\s+/),l={...v,name:a.name,instructions:a.instructions,...h};if(o.length===5){const x=o[0]??"",g=o[1]??"",k=o[4]??"",y=`${j(parseInt(g,10)||0)}:${j(parseInt(x,10)||0)}`;if(k==="*")return{...l,freq:"daily",time:y};if(k==="1-5")return{...l,freq:"weekdays",time:y};if(/^\d+$/.test(k))return{...l,freq:"weekly",time:y,dow:k}}return{...l,freq:"custom",cron:n.cron||""}}function de(a){const[n,h]=a.time.split(":"),o=parseInt(n??"",10),l=parseInt(h??"",10);switch(a.freq){case"daily":return Number.isInteger(o)&&Number.isInteger(l)?{kind:"cron",cron:`${l} ${o} * * *`}:null;case"weekdays":return Number.isInteger(o)&&Number.isInteger(l)?{kind:"cron",cron:`${l} ${o} * * 1-5`}:null;case"weekly":return Number.isInteger(o)&&Number.isInteger(l)?{kind:"cron",cron:`${l} ${o} * * ${a.dow}`}:null;case"once":return a.onceAt?{kind:"once",fireAt:new Date(a.onceAt).toISOString()}:null;case"custom":return a.cron.trim()?{kind:"cron",cron:a.cron.trim()}:null}}function le(a,n){if(a.kind==="once"&&a.fireAt){const k=new Date(a.fireAt);return`${n("automation.badgeOnce")} ${k.toLocaleString()}`}const h=(a.cron||"").trim().split(/\s+/);if(h.length!==5)return a.cron||"";const o=h[0]??"",l=h[1]??"",x=h[4]??"",g=`${j(parseInt(l,10)||0)}:${j(parseInt(o,10)||0)}`;return x==="*"?n("automation.badgeDaily",{time:g}):x==="1-5"?n("automation.badgeWeekdays",{time:g}):/^\d+$/.test(x)?n("automation.badgeWeekly",{day:n(`automation.dow.${["sunday","monday","tuesday","wednesday","thursday","friday","saturday"][parseInt(x,10)%7]}`),time:g}):a.cron||""}const Me=[{value:"1",key:"automation.dow.monday"},{value:"2",key:"automation.dow.tuesday"},{value:"3",key:"automation.dow.wednesday"},{value:"4",key:"automation.dow.thursday"},{value:"5",key:"automation.dow.friday"},{value:"6",key:"automation.dow.saturday"},{value:"0",key:"automation.dow.sunday"}];function He(a){const n=a.replace(/[\\/]+$/,""),h=Math.max(n.lastIndexOf("\\"),n.lastIndexOf("/"));return h===-1?n:n.slice(h+1)}function Ke({initial:a,onClose:n,onConfirm:h}){const{t:o}=ce(),[l,x]=i.useState(a),[g,k]=i.useState(null),[y,M]=i.useState([]),[C,D]=i.useState(!1),[S,I]=i.useState(""),[N,r]=i.useState(a),m=i.useRef(null),w=async b=>{D(!0),I("");try{const u=await R.dirs.list(b);if(!u.success||!u.data){I(u.error||"加载目录失败");return}x(u.data.path),k(u.data.parent),M(u.data.dirs||[]),r(u.data.path)}catch(u){I(u instanceof Error?u.message:"加载目录失败")}finally{D(!1)}};return i.useEffect(()=>{w(a)},[a]),i.useEffect(()=>{var b;(b=m.current)==null||b.focus()},[]),i.useEffect(()=>{const b=u=>{u.key==="Escape"&&(u.preventDefault(),u.stopPropagation(),n())};return document.addEventListener("keydown",b),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",b),document.body.style.overflow=""}},[n]),e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center overflow-hidden p-4",role:"dialog","aria-modal":"true",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:n}),e.jsxs("div",{className:"relative w-full max-w-lg mx-4 bg-dark-surface border border-dark-border rounded-xl shadow-2xl flex flex-col max-h-[70vh]",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-dark-border shrink-0",children:[e.jsxs("span",{className:"flex items-center gap-2 text-[13px] font-semibold text-dark-text",children:[e.jsx(K,{size:15,className:"text-accent-blue"}),o("automation.workspacePick")]}),e.jsx("button",{type:"button",onClick:n,className:"rounded p-1 text-dark-muted hover:bg-dark-hover",children:e.jsx(q,{size:15})})]}),e.jsxs("div",{className:"p-4 flex flex-col gap-3 min-h-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Pe,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-dark-muted/60"}),e.jsx("input",{ref:m,value:N,onChange:b=>r(b.target.value),onKeyDown:b=>{b.key==="Enter"&&w(N.trim())},spellCheck:!1,className:"w-full rounded-lg border border-dark-border bg-dark-bg pl-8 pr-2.5 py-1.5 text-xs font-mono focus:outline-none focus:border-accent-blue/50"})]}),e.jsx("button",{type:"button",onClick:()=>void w(N.trim()),disabled:C||!N.trim(),className:"shrink-0 rounded-lg border border-dark-border px-2.5 py-1.5 text-xs text-dark-muted hover:bg-dark-hover disabled:opacity-40",children:o("chat.dirPickerGo")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex-1 truncate font-mono text-[11px] text-dark-muted bg-dark-bg rounded-md px-2 py-1 border border-dark-border",title:l,children:l||"—"}),e.jsxs("button",{type:"button",onClick:()=>g&&void w(g),disabled:C||!g,className:"shrink-0 flex items-center gap-1 rounded-md border border-dark-border px-2 py-1 text-[11px] text-dark-muted hover:bg-dark-hover disabled:opacity-40",children:[e.jsx(Ee,{size:12}),o("chat.dirPickerUp")]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto rounded-lg border border-dark-border bg-dark-bg divide-y divide-dark-border/60",children:C?e.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-xs text-dark-muted",children:[e.jsx(ie,{size:14,className:"animate-spin"}),o("chat.loading")]}):S?e.jsx("div",{className:"px-3 py-4 text-xs text-accent-red",children:S}):y.length===0?e.jsx("div",{className:"px-3 py-4 text-xs text-dark-muted/60 text-center",children:"—"}):y.map(b=>{const u=l.includes("\\")?"\\":"/",T=l.endsWith(u)?l+b:l+u+b;return e.jsxs("button",{type:"button",onClick:()=>void w(T),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left text-xs text-dark-text hover:bg-dark-hover",children:[e.jsx(qe,{size:13,className:"shrink-0 text-accent-yellow/80"}),e.jsx("span",{className:"truncate",children:b})]},b)})}),e.jsx("button",{type:"button",onClick:()=>h(l),disabled:!l||C,className:"w-full rounded-lg bg-accent-blue/90 text-white text-xs font-medium py-2 hover:bg-accent-blue disabled:opacity-40",children:o("chat.dirPickerConfirm")})]})]})]})}function Je(){const{t:a}=ce(),{automations:n,runsByAutomation:h,fetchAutomations:o,createAutomation:l,updateAutomation:x,deleteAutomation:g,toggleAutomation:k,runAutomation:y,fetchRuns:M,error:C}=Re(),[D,S]=i.useState(!1),[I,N]=i.useState(null),[r,m]=i.useState(v),[w,b]=i.useState(null),[u,T]=i.useState(""),[F,W]=i.useState(!1),[me,L]=i.useState(!1),[B,G]=i.useState([]),[U,_]=i.useState([]),[J,V]=i.useState([]),[X,Y]=i.useState(!1),[P,A]=i.useState([]),Q=i.useRef(null);i.useEffect(()=>{o()},[o]);const Z=async t=>{N(null),m(t?{...t.form}:{...v}),A([]),S(!0),await ee()},ue=async t=>{N(t.id),m(Oe(t)),A((t.attachments??[]).map((s,d)=>({id:`existing-${d}-${s}`,name:He(s),file:null,uploading:!1,path:s}))),S(!0),await ee()},O=()=>{S(!1),N(null),m(v),A([]),L(!1)},ee=async()=>{var t,s;Y(!0);try{const[d,c,p]=await Promise.all([R.models.list().catch(()=>({success:!1,data:void 0})),R.connectors.list().catch(()=>({success:!1,data:void 0})),R.channels.list().catch(()=>({success:!1,data:void 0}))]);d.success&&((t=d.data)!=null&&t.models)?G(d.data.models.filter(f=>f.enabled!==!1)):G([]),c.success&&((s=c.data)!=null&&s.connectors)?_(c.data.connectors.filter(f=>f.installed)):_([]),p.success&&Array.isArray(p.data)?V(p.data):V([])}finally{Y(!1)}},xe=async()=>{const t=de(r);if(!r.name.trim()||!r.instructions.trim()||!t)return;if(P.some(p=>p.uploading)){oe.warning("附件上传中,请稍候…");return}const s=P.filter(p=>p.error).map(p=>p.name);if(s.length>0){oe.warning(`附件上传失败:${s.join(", ")}`);return}W(!0);const d={name:r.name.trim(),instructions:r.instructions.trim(),schedule:t,workspaceDir:r.workspaceDir.trim(),readAutoAllow:r.readAutoAllow,modelRef:r.modelRef.trim()||null,attachments:P.map(p=>p.path).filter(p=>!!p),connectorIds:[...r.connectorIds],notificationChannelIds:[...r.channelIds]},c=I?await x(I,d):await l(d)!==null;W(!1),c&&O()},be=async t=>{const s=u.trim();if(!s)return;const[d,...c]=s.split(/\s+/),p=c.join(" ");d&&p&&(await fetch(`/api/automations/${encodeURIComponent(t)}/permissions`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tool:d,target:p})})).ok&&(T(""),await o())},pe=async(t,s)=>{(await fetch(`/api/automations/${encodeURIComponent(t)}/permissions`,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({entry:s})})).ok&&await o()},he=async t=>{const s=w===t?null:t;b(s),s&&await M(t)},fe=async t=>{var d;if(!t||t.length===0)return;const s=Array.from(t).map(c=>({id:`f-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:c.name,file:c,uploading:!0}));A(c=>[...c,...s]);for(const c of s){const p=`${Le}/${c.name}`;try{const f=await R.files.upload(c.file,p);if(f.success&&((d=f.data)!=null&&d.path)){const E=f.data.path.replace(/\\/g,"/");A($=>$.map(z=>z.id===c.id?{...z,uploading:!1,path:E}:z))}else A(E=>E.map($=>$.id===c.id?{...$,uploading:!1,error:f.error||"upload failed"}:$))}catch(f){const E=f instanceof Error?f.message:"upload failed";A($=>$.map(z=>z.id===c.id?{...z,uploading:!1,error:E}:z))}}},ge=t=>{A(s=>s.filter(d=>d.id!==t))},ke=[{id:"movie",nameKey:"automation.tplMovieName",descKey:"automation.tplMovieDesc",form:{...v,name:a("automation.tplMovieName"),instructions:a("automation.tplMovieInstr"),freq:"daily",time:"20:00"}},{id:"health",nameKey:"automation.tplHealthName",descKey:"automation.tplHealthDesc",form:{...v,name:a("automation.tplHealthName"),instructions:a("automation.tplHealthInstr"),freq:"daily",time:"14:00"}},{id:"why",nameKey:"automation.tplWhyName",descKey:"automation.tplWhyDesc",form:{...v,name:a("automation.tplWhyName"),instructions:a("automation.tplWhyInstr"),freq:"daily",time:"16:00"}},{id:"git",nameKey:"automation.tplGitName",descKey:"automation.tplGitDesc",form:{...v,name:a("automation.tplGitName"),instructions:a("automation.tplGitInstr"),freq:"weekdays",time:"09:00"}}],je=r.name.trim()&&r.instructions.trim()&&(r.freq==="custom"?!!r.cron.trim():r.freq==="once"?!!r.onceAt:!0);return e.jsxs("div",{className:"flex-1 flex flex-col overflow-y-auto p-6",children:[e.jsxs("div",{className:"max-w-4xl w-full mx-auto",children:[e.jsxs("div",{className:"flex items-start justify-between mb-1",children:[e.jsxs("h2",{className:"text-xl font-semibold flex items-center gap-2",children:[e.jsx(H,{size:20,className:"text-accent-blue"}),a("automation.title")]}),e.jsx("button",{onClick:()=>void o(),className:"p-2 rounded-lg hover:bg-dark-hover text-dark-muted",title:a("automation.refresh"),children:e.jsx(ve,{size:16})})]}),e.jsx("p",{className:"text-sm text-dark-muted mb-5",children:a("automation.subtitle")}),C&&e.jsxs("div",{className:"mb-4 p-3 rounded-lg bg-accent-red/10 text-accent-red text-sm flex items-center gap-2",children:[e.jsx(te,{size:16})," ",C]}),e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(ye,{size:16,className:"text-accent-yellow"}),e.jsx("h3",{className:"text-sm font-semibold",children:a("automation.recommendedTitle")})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 gap-3 mb-8",children:ke.map(t=>e.jsxs("button",{onClick:()=>void Z(t),className:"text-left rounded-xl border border-dark-border bg-dark-surface p-4 hover:border-accent-blue/60 hover:bg-dark-hover/50 transition-colors flex flex-col gap-2",children:[e.jsx("span",{className:"text-sm font-semibold",children:a(t.nameKey)}),e.jsx("span",{className:"text-xs text-dark-muted leading-relaxed line-clamp-3 flex-1",children:a(t.descKey)}),e.jsxs("span",{className:"inline-flex items-center gap-1 self-start px-2 py-0.5 rounded-md bg-dark-hover text-xs text-dark-muted",children:[e.jsx(H,{size:12})," ",le(de(t.form),a)]})]},t.id))}),e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-sm font-semibold",children:a("automation.mineTitle")}),e.jsx("span",{className:"text-xs text-dark-muted",children:n.length})]}),n.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-dark-border py-12 flex flex-col items-center gap-2 text-center",children:[e.jsx(Ne,{size:32,className:"text-dark-muted"}),e.jsx("p",{className:"text-sm font-medium",children:a("automation.emptyTitle")}),e.jsx("p",{className:"text-xs text-dark-muted",children:a("automation.emptyDesc")}),e.jsxs("button",{onClick:()=>void Z(),className:"mt-2 flex items-center gap-1 px-4 py-1.5 rounded-lg border border-dark-border bg-dark-surface hover:bg-dark-hover text-sm font-medium",children:[e.jsx(ae,{size:15})," ",a("automation.new")]})]}):e.jsx("div",{className:"space-y-2",children:n.map(t=>e.jsxs("div",{className:"rounded-xl border border-dark-border bg-dark-surface",children:[e.jsxs("div",{className:"flex items-center justify-between p-3",children:[e.jsxs("button",{onClick:()=>void he(t.id),className:"flex items-center gap-2 min-w-0 text-left",children:[e.jsx(H,{size:16,className:"text-accent-blue shrink-0"}),e.jsx("span",{className:"font-medium text-sm truncate",children:t.name}),e.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded shrink-0 ${t.status==="enabled"?"bg-accent-green/20 text-accent-green":"bg-dark-hover text-dark-muted"}`,children:t.status==="enabled"?a("automation.enabled"):a("automation.disabled")}),e.jsx("span",{className:"text-xs text-dark-muted shrink-0 hidden md:inline",children:le(t.schedule,a)})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.nextRunAt&&e.jsxs("span",{className:"text-xs text-dark-muted hidden lg:inline mr-1",children:[a("automation.nextRun"),": ",new Date(t.nextRunAt).toLocaleString()]}),e.jsx("button",{onClick:()=>void ue(t),className:"p-1.5 rounded-lg hover:bg-dark-hover text-dark-muted",title:a("automation.edit"),children:e.jsx(we,{size:15})}),e.jsx("button",{onClick:()=>void k(t.id,t.status!=="enabled"),className:"p-1.5 rounded-lg hover:bg-dark-hover text-dark-muted",title:t.status==="enabled"?a("automation.disable"):a("automation.enable"),children:e.jsx(Ae,{size:15})}),e.jsx("button",{onClick:()=>void y(t.id),className:"p-1.5 rounded-lg hover:bg-dark-hover text-accent-green",title:a("automation.runNow"),children:e.jsx(Ce,{size:15})}),e.jsx("button",{onClick:()=>void g(t.id),className:"p-1.5 rounded-lg hover:bg-dark-hover text-accent-red",title:a("automation.delete"),children:e.jsx(Ie,{size:15})})]})]}),w===t.id&&e.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t border-dark-border pt-3",children:[e.jsx("p",{className:"text-xs text-dark-muted whitespace-pre-wrap",children:t.instructions}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-semibold text-dark-muted mb-1 flex items-center gap-1",children:[e.jsx($e,{size:12})," ",a("automation.historyTitle")]}),(h[t.id]||[]).length===0&&e.jsx("p",{className:"text-xs text-dark-muted",children:a("automation.noRuns")}),(h[t.id]||[]).slice(0,10).map(s=>e.jsxs("div",{className:"flex items-center gap-2 text-xs py-1",children:[e.jsxs("span",{className:`px-1.5 py-0.5 rounded flex items-center gap-1 ${s.status==="ok"?"bg-accent-green/20 text-accent-green":s.status==="error"?"bg-accent-red/20 text-accent-red":"bg-accent-yellow/20 text-accent-yellow"}`,children:[s.status==="ok"&&e.jsx(ze,{size:11}),s.status]}),e.jsx("span",{className:"text-dark-muted",children:new Date(s.startedAt).toLocaleString()}),e.jsxs("span",{className:"text-dark-muted truncate flex-1",children:["#",s.id.slice(0,8)," · ",s.trigger]})]},s.id))]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-semibold text-dark-muted mb-1",children:a("automation.permissionsTitle")}),t.permissions.length===0&&e.jsx("p",{className:"text-xs text-dark-muted",children:a("automation.permissionsEmpty")}),e.jsx("div",{className:"flex flex-wrap gap-1 mb-1",children:t.permissions.map(s=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded bg-accent-blue/10 text-accent-blue text-xs",children:[s,e.jsx("button",{onClick:()=>void pe(t.id,s),className:"hover:text-accent-red",children:e.jsx(q,{size:12})})]},s))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:u,onChange:s=>T(s.target.value),placeholder:a("automation.permissionPlaceholder"),className:"flex-1 px-2 py-1.5 rounded-lg bg-dark-bg border border-dark-border text-xs focus:outline-none focus:border-accent-blue"}),e.jsx("button",{onClick:()=>void be(t.id),className:"px-3 py-1.5 rounded-lg bg-dark-hover text-dark-muted hover:text-dark-text text-xs",children:a("automation.add")})]})]})]})]},t.id))})]}),D&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:O,children:e.jsxs("div",{className:"w-full max-w-2xl rounded-xl border border-dark-border bg-dark-surface p-5 space-y-4 shadow-xl max-h-[90vh] overflow-y-auto custom-scrollbar",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold",children:a(I?"automation.editTitle":"automation.createTitle")}),e.jsx("p",{className:"text-xs text-dark-muted mt-0.5",children:a("automation.subtitle")})]}),e.jsx("button",{onClick:O,className:"p-1.5 rounded-lg hover:bg-dark-hover text-dark-muted",children:e.jsx(q,{size:16})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-dark-muted mb-1.5",children:a("automation.nameLabel")}),e.jsx("input",{autoFocus:!0,value:r.name,onChange:t=>m(s=>({...s,name:t.target.value})),placeholder:a("automation.namePlaceholder"),className:"w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-dark-muted mb-1.5",children:a("automation.scheduleLabel")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("select",{value:r.freq,onChange:t=>m(s=>({...s,freq:t.target.value})),className:"px-2.5 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue",children:[e.jsx("option",{value:"daily",children:a("automation.freqDaily")}),e.jsx("option",{value:"weekly",children:a("automation.freqWeekly")}),e.jsx("option",{value:"weekdays",children:a("automation.freqWeekdays")}),e.jsx("option",{value:"once",children:a("automation.freqOnce")}),e.jsx("option",{value:"custom",children:a("automation.freqCustom")})]}),r.freq==="weekly"&&e.jsx("select",{value:r.dow,onChange:t=>m(s=>({...s,dow:t.target.value})),className:"px-2.5 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue",children:Me.map(t=>e.jsx("option",{value:t.value,children:a(t.key)},t.value))}),(r.freq==="daily"||r.freq==="weekly"||r.freq==="weekdays")&&e.jsx("input",{type:"time",value:r.time,onChange:t=>m(s=>({...s,time:t.target.value})),className:"flex-1 px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue"}),r.freq==="once"&&e.jsx("input",{type:"datetime-local",value:r.onceAt,onChange:t=>m(s=>({...s,onceAt:t.target.value})),className:"flex-1 px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue"}),r.freq==="custom"&&e.jsx("input",{value:r.cron,onChange:t=>m(s=>({...s,cron:t.target.value})),placeholder:"*/30 * * * *",className:"flex-1 px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm font-mono focus:outline-none focus:border-accent-blue"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-dark-muted mb-1.5",children:a("automation.instructionLabel")}),e.jsx("textarea",{value:r.instructions,onChange:t=>m(s=>({...s,instructions:t.target.value})),placeholder:a("automation.instructionsPlaceholder"),rows:4,className:"w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue resize-none"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-xs font-medium text-dark-muted mb-1.5",children:[e.jsx(se,{size:12})," ",a("automation.attachmentsLabel")]}),e.jsx("p",{className:"text-[10px] text-dark-muted/70 mb-1.5",children:a("automation.attachmentsHint")}),P.length===0?e.jsx("div",{className:"text-xs text-dark-muted/60 italic",children:a("automation.attachmentsEmpty")}):e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:P.map(t=>e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-1 rounded-md text-xs ${t.error?"bg-accent-red/10 text-accent-red":t.uploading?"bg-dark-hover text-dark-muted":"bg-accent-blue/10 text-accent-blue"}`,title:t.path??t.error,children:[e.jsx(se,{size:11}),e.jsx("span",{className:"truncate max-w-[180px]",children:t.name}),t.uploading&&e.jsx(ie,{size:11,className:"animate-spin"}),t.error&&e.jsx(te,{size:11}),e.jsx("button",{onClick:()=>ge(t.id),className:"hover:text-accent-red ml-0.5",children:e.jsx(q,{size:11})})]},t.id))}),e.jsx("input",{ref:Q,type:"file",multiple:!0,className:"hidden",onChange:t=>{fe(t.target.files),t.target.value=""}}),e.jsxs("button",{type:"button",onClick:()=>{var t;return(t=Q.current)==null?void 0:t.click()},className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-lg border border-dashed border-dark-border text-xs text-dark-muted hover:border-accent-blue/60 hover:text-accent-blue",children:[e.jsx(ae,{size:12})," ",a("automation.attachmentsAdd")]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-xs font-medium text-dark-muted mb-1.5",children:[e.jsx(Se,{size:12})," ",a("automation.modelLabel")]}),e.jsxs("select",{value:r.modelRef,onChange:t=>m(s=>({...s,modelRef:t.target.value})),className:"w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue",disabled:X,children:[e.jsx("option",{value:"",children:a("automation.modelAuto")}),B.map(t=>e.jsxs("option",{value:`${t.provider}:${t.id}`,children:[t.name," · ",t.provider]},`${t.provider}:${t.id}`))]}),!X&&B.length===0&&e.jsx("p",{className:"text-[10px] text-dark-muted/70 mt-1",children:a("automation.modelNoModels")})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-xs font-medium text-dark-muted mb-1.5",children:[e.jsx(re,{size:12})," ",a("automation.connectorsLabel")]}),e.jsx("p",{className:"text-[10px] text-dark-muted/70 mb-1.5",children:a("automation.connectorsHint")}),U.length===0?e.jsx("div",{className:"text-xs text-dark-muted/60 italic",children:a("automation.connectorsEmpty")}):e.jsx("div",{className:"flex flex-wrap gap-1.5",children:U.map(t=>{const s=r.connectorIds.includes(t.id);return e.jsxs("button",{type:"button",onClick:()=>m(d=>({...d,connectorIds:s?d.connectorIds.filter(c=>c!==t.id):[...d.connectorIds,t.id]})),className:`inline-flex items-center gap-1 px-2 py-1 rounded-md text-xs transition-colors ${s?"bg-accent-blue/15 text-accent-blue border border-accent-blue/40":"bg-dark-bg text-dark-muted border border-dark-border hover:border-accent-blue/40 hover:text-accent-blue"}`,children:[e.jsx(re,{size:11}),t.name]},t.id)})})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-xs font-medium text-dark-muted mb-1.5",children:[e.jsx(ne,{size:12})," ",a("automation.channelsLabel")]}),e.jsx("p",{className:"text-[10px] text-dark-muted/70 mb-1.5",children:a("automation.channelsHint")}),J.length===0?e.jsx("div",{className:"text-xs text-dark-muted/60 italic",children:a("automation.channelsEmpty")}):e.jsx("div",{className:"flex flex-wrap gap-1.5",children:J.map(t=>{const s=r.channelIds.includes(t.id);return e.jsxs("button",{type:"button",disabled:!t.enabled,onClick:()=>m(d=>({...d,channelIds:s?d.channelIds.filter(c=>c!==t.id):[...d.channelIds,t.id]})),className:`inline-flex items-center gap-1 px-2 py-1 rounded-md text-xs transition-colors ${s?"bg-accent-blue/15 text-accent-blue border border-accent-blue/40":t.enabled?"bg-dark-bg text-dark-muted border border-dark-border hover:border-accent-blue/40 hover:text-accent-blue":"bg-dark-bg text-dark-muted/50 border border-dark-border opacity-60 cursor-not-allowed"}`,children:[e.jsx(ne,{size:11}),t.name,!t.enabled&&e.jsx("span",{className:"text-[9px]",children:"·off"})]},t.id)})})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-xs font-medium text-dark-muted mb-1.5",children:[e.jsx(K,{size:12})," ",a("automation.workspaceLabel")]}),e.jsx("p",{className:"text-[10px] text-dark-muted/70 mb-1.5",children:a("automation.workspaceHint")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:r.workspaceDir,onChange:t=>m(s=>({...s,workspaceDir:t.target.value})),placeholder:"留空使用当前工作目录",className:"flex-1 px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm font-mono focus:outline-none focus:border-accent-blue"}),e.jsxs("button",{type:"button",onClick:()=>L(!0),className:"shrink-0 inline-flex items-center gap-1 px-3 py-2 rounded-lg border border-dark-border text-xs text-dark-muted hover:bg-dark-hover hover:text-dark-text",children:[e.jsx(K,{size:12})," ",a("automation.workspacePick")]}),r.workspaceDir&&e.jsx("button",{type:"button",onClick:()=>m(t=>({...t,workspaceDir:""})),className:"shrink-0 inline-flex items-center gap-1 px-2 py-2 rounded-lg border border-dark-border text-xs text-dark-muted hover:bg-dark-hover hover:text-accent-red",title:a("automation.workspaceClear"),children:e.jsx(q,{size:12})})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-xs font-medium text-dark-muted mb-1.5",children:[e.jsx(De,{size:12})," ",a("automation.permissionAccess")]}),e.jsxs("div",{className:"flex items-start gap-2 p-2.5 rounded-lg border border-dark-border bg-dark-bg",children:[e.jsx("button",{type:"button",role:"switch","aria-checked":r.readAutoAllow,onClick:()=>m(t=>({...t,readAutoAllow:!t.readAutoAllow})),className:`relative shrink-0 mt-0.5 inline-flex h-5 w-9 items-center rounded-full transition-colors ${r.readAutoAllow?"bg-accent-blue":"bg-dark-hover"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${r.readAutoAllow?"translate-x-4":"translate-x-0.5"}`})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-xs font-medium text-dark-text",children:a("automation.fullAccessLabel")}),e.jsx("p",{className:"text-[10px] text-dark-muted/80 mt-0.5",children:a("automation.fullAccessHint")})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[e.jsx("button",{onClick:O,className:"px-4 py-2 rounded-lg bg-dark-hover text-dark-muted hover:text-dark-text text-sm",children:a("automation.cancel")}),e.jsx("button",{onClick:()=>void xe(),disabled:!je||F,className:"px-5 py-2 rounded-lg bg-accent-blue text-white text-sm font-medium hover:bg-accent-blue/80 disabled:opacity-40 disabled:cursor-not-allowed",children:a(F?"automation.saving":"automation.save")})]})]})}),me&&D&&Te.createPortal(e.jsx(Ke,{initial:r.workspaceDir||"",onClose:()=>L(!1),onConfirm:t=>{m(s=>({...s,workspaceDir:t})),L(!1)}}),document.body)]})}export{Je as AutomationView};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{j as a}from"./markdown-DEtuzEyz.js";import{a as I,bq as ft,aJ as gt,aI as mt,ax as kt,aa as ne,A as vt,br as Be,aE as xt,l as Et,g as Bt,h as Tt}from"./icons-f1hlMKvD.js";import{u as D,a7 as Te,a8 as G,a9 as W,aa as Q,M as St,a as Me,t as re}from"./index-u1vYyqna.js";import"./react-vendor-ClBKp0t-.js";import"./state-xD58vmym.js";import"./panels-Bn-2wCur.js";const Pe=[{labelKey:"im",types:["wechat","feishu","dingtalk"]},{labelKey:"international",types:["telegram","discord","slack","signal","whatsapp"]},{labelKey:"eastAsia",types:["line","qqbot"]},{labelKey:"collaboration",types:["matrix","mattermost","msteams","googlechat"]},{labelKey:"classic",types:["irc","imessage","sms"]},{labelKey:"other",types:["nextcloud-talk","nostr","synology-chat","tlon","twitch","zalo","zalouser"]},{labelKey:"builtin",types:["clickclack","raft","qa-channel"]}];function Rt(){const{t:n}=D(),{channels:i,availableTypes:s,typesLoaded:t,selectedType:e,selectType:r,loadTypes:o}=Te();I.useEffect(()=>{o()},[o]);const c=I.useMemo(()=>{if(s.length===0)return[];const x=new Set(s),h=Pe.map(y=>({...y,types:y.types.filter(A=>x.has(A))})).filter(y=>y.types.length>0),d=new Set(Pe.flatMap(y=>y.types)),p=s.filter(y=>!d.has(y));return p.length>0?[...h,{labelKey:"plugins",types:p}]:h},[s]),l=I.useMemo(()=>{const x=new Map;for(const h of i){const d=x.get(h.type)??{count:0,connected:0};x.set(h.type,{count:d.count+1,connected:d.connected+(h.connected?1:0)})}return x},[i]),u=s.length>0,g=I.useMemo(()=>u?i.filter(x=>s.includes(x.type)):[],[u,i,s]);return a.jsxs("div",{className:"flex flex-col h-full min-h-0 border-r border-dark-border bg-dark-surface",children:[a.jsxs("div",{className:"shrink-0 px-4 py-3 border-b border-dark-border",children:[a.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-dark-muted",children:n("channels.sidebar.title")}),a.jsx("p",{className:"text-[11px] text-dark-muted mt-0.5",children:g.length>0?n("channels.sidebar.configuredCount",{n:g.length}):n(u?"channels.sidebar.clickToConfigure":"channels.sidebar.emptyHint")})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:[t&&!u&&a.jsxs("div",{className:"px-4 py-10 text-center",children:[a.jsx("p",{className:"text-xs text-dark-muted",children:n("channels.sidebar.empty")}),a.jsx("p",{className:"text-[11px] text-dark-muted/70 mt-1.5 leading-relaxed",children:n("channels.sidebar.emptyHint")})]}),c.map(x=>{const h=x.types.filter(d=>l.has(d));return h.length===0?null:a.jsxs("div",{children:[a.jsx("div",{className:"sticky top-0 bg-dark-surface/95 backdrop-blur px-4 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-dark-muted/60",children:n(`channels.categories.${x.labelKey}`)}),h.map(d=>{const p=l.get(d);return a.jsx(Le,{label:Q(d),icon:W(d),isSelected:e===d,experimental:G(d),info:p,onClick:()=>r(d)},d)})]},x.labelKey)}),(()=>{const x=c.flatMap(h=>h.types).filter(h=>!l.has(h));return x.length===0?null:a.jsxs("div",{children:[a.jsx("div",{className:"sticky top-0 bg-dark-surface/95 backdrop-blur px-4 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-dark-muted/60",children:n("channels.sidebar.unconfigured")}),x.map(h=>a.jsx(Le,{label:Q(h),icon:W(h),isSelected:e===h,experimental:G(h),onClick:()=>r(h)},h))]})})()]})]})}function Le({label:n,icon:i,isSelected:s,experimental:t,info:e,onClick:r}){const{t:o}=D();return a.jsxs("button",{onClick:r,className:`w-full flex items-center gap-2.5 px-4 py-2.5 text-left transition-colors hover:bg-dark-hover ${s?"bg-accent-blue/10 border-l-2 border-accent-blue":"border-l-2 border-transparent"}`,children:[a.jsx("span",{className:"text-lg shrink-0 w-7 h-7 flex items-center justify-center rounded-md bg-dark-bg",children:i}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"text-sm font-medium text-dark-text truncate",children:n}),t&&a.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[9px] text-yellow-500 bg-yellow-500/10 px-1 py-0.5 rounded shrink-0",title:o("channels.experimentalTip"),children:[a.jsx(ft,{className:"w-2.5 h-2.5"})," ",o("channels.experimentalShort")]}),e&&a.jsx("span",{className:"text-[10px] text-dark-muted bg-dark-hover px-1.5 py-0.5 rounded shrink-0",children:e.count})]}),a.jsx("div",{className:"flex items-center gap-1 mt-0.5",children:e?e.connected>0?a.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-green-400",children:[a.jsx(gt,{className:"w-3 h-3"}),e.connected===e.count?o("channels.status.connected"):o("channels.sidebar.partialConnected",{connected:e.connected,count:e.count})]}):a.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-dark-muted",children:[a.jsx(mt,{className:"w-3 h-3"}),o("channels.status.disconnected")]}):a.jsx("span",{className:"text-[11px] text-dark-muted",children:o("channels.sidebar.unconfigured")})})]})]})}const z={name:"",type:"wechat",appId:"",appSecret:"",token:"",encodingAESKey:"",enabled:!0};function At(){const{t:n}=D(),{channels:i,selectedType:s,availableTypes:t,create:e,update:r,remove:o,toggle:c,error:l,clearError:u,openQr:g,load:x}=Te(),h=I.useMemo(()=>t.length>0&&!!s&&!t.includes(s),[t,s]),d=I.useMemo(()=>s?i.filter(f=>f.type===s):[],[i,s]),[p,y]=I.useState(""),[A,N]=I.useState(z),[R,B]=I.useState(!1),j=p==="__new__",k=I.useMemo(()=>j?null:d.find(f=>f.id===p)??null,[d,p,j]);I.useEffect(()=>{y(""),N(z),B(!1),u()},[s]),I.useEffect(()=>{s==="wechat"&&d.length===0&&!h&&g(null)},[s,d.length,h,g]),I.useEffect(()=>{k?N({name:k.name,type:k.type,appId:k.appId||"",appSecret:"",token:"",encodingAESKey:k.encodingAESKey||"",enabled:k.enabled}):j&&N(f=>({...f,type:s}))},[p]);const m=(f,T)=>{u(),N(M=>({...M,[f]:T}))},b=f=>{y(f),u()},C=()=>{y("__new__"),N({...z,type:s}),u()},w=()=>{y(""),N(z),u()},S=async()=>{if(!A.name.trim())return;B(!0);const f=k?await r(k.id,A):await e(A);B(!1),f&&(y(""),N(z))},v=async f=>{if(!confirm(n("channels.actions.deleteConfirmShort")))return;await o(f)&&p===f&&(y(""),N(z))},E=(f,T)=>{c(f,T)};return s?a.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[a.jsx("div",{className:"shrink-0 px-6 py-4 border-b border-dark-border",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"text-2xl",children:W(s)}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h2",{className:"font-semibold text-base text-dark-text",children:Q(s)}),G(s)&&a.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[10px] text-yellow-500 bg-yellow-500/10 px-1.5 py-0.5 rounded",title:n("channels.experimentalTip"),children:[a.jsx(ft,{className:"w-3 h-3"})," ",n("channels.experimentalLabel")]})]}),a.jsx("p",{className:"text-xs text-dark-muted mt-0.5",children:d.length>0?n("channels.instancesCount",{n:d.length}):n("channels.notConfiguredYet")}),G(s)&&a.jsx("p",{className:"text-[10px] text-yellow-600/70 mt-1",children:n("channels.experimentalDesc")})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:()=>x(),className:"text-xs px-3 py-1.5 rounded-lg border border-dark-border text-dark-muted hover:text-dark-text hover:bg-dark-hover transition-colors",children:n("channels.actions.refresh")}),a.jsxs("button",{onClick:C,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg bg-accent-blue hover:bg-accent-blue/90 text-white transition-colors",children:[a.jsx(ne,{className:"w-3.5 h-3.5"})," ",n("channels.createInstance")]})]})]})}),l&&a.jsxs("div",{className:"shrink-0 mx-6 mt-3 bg-red-500/10 border border-red-500/40 text-red-400 px-3 py-2 rounded-lg text-sm flex justify-between items-center",children:[a.jsx("span",{children:l}),a.jsx("button",{onClick:u,className:"text-red-400 hover:text-red-300",children:a.jsx("span",{className:"w-4 h-4 inline-flex items-center justify-center",children:"×"})})]}),h&&a.jsxs("div",{className:"shrink-0 mx-6 mt-3 flex items-start gap-2 bg-amber-500/10 border border-amber-500/40 text-amber-400 px-3 py-2 rounded-lg text-xs",children:[a.jsx(vt,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),a.jsx("span",{children:n("channels.pluginMissingWarning",{name:s==="wechat"?" WeChat Channel":` ${Q(s)}`})})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto custom-scrollbar p-6",children:[d.length>1&&!j&&a.jsxs("div",{className:"mb-4",children:[a.jsx("label",{className:"block text-xs text-dark-muted mb-1.5",children:n("channels.selectInstance")}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[d.map(f=>a.jsxs("button",{onClick:()=>b(f.id),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs border transition-colors ${p===f.id?"bg-accent-blue/10 border-accent-blue/40 text-accent-blue":"border-dark-border text-dark-muted hover:text-dark-text hover:bg-dark-hover"}`,children:[a.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${f.connected?"bg-green-500":"bg-gray-500"}`}),f.name]},f.id)),a.jsxs("button",{onClick:C,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs border border-dashed border-dark-border text-dark-muted hover:text-dark-text hover:bg-dark-hover transition-colors",children:[a.jsx(ne,{className:"w-3 h-3"})," ",n("channels.createShort")]})]})]}),d.length===0&&p===""&&a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[a.jsx("div",{className:"text-4xl mb-3",children:W(s)}),a.jsx("p",{className:"text-dark-text font-medium",children:n("channels.emptyWithType",{type:Q(s)})}),a.jsx("p",{className:"text-sm text-dark-muted mt-1 mb-4",children:n(s==="wechat"?"channels.wechatBindHint":"channels.startWithCreate")}),s==="wechat"&&a.jsxs("button",{onClick:()=>g(null),className:"flex items-center gap-1.5 text-sm px-4 py-2 rounded-lg bg-green-600/15 hover:bg-green-600/25 text-green-400 border border-green-600/40 transition-colors mb-3",children:[a.jsx(Be,{className:"w-4 h-4"})," ",n("channels.scanToBind")]}),a.jsxs("button",{onClick:C,className:"flex items-center gap-1.5 text-sm px-4 py-2 rounded-lg bg-accent-blue hover:bg-accent-blue/90 text-white transition-colors",children:[a.jsx(ne,{className:"w-4 h-4"})," ",n("channels.createInstance")]})]}),d.length===1&&p===""&&d[0]&&a.jsx(qe,{channel:d[0],onEdit:()=>b(d[0].id),onDelete:()=>v(d[0].id),onToggle:f=>E(d[0].id,f),onQr:()=>g(d[0])}),d.length>1&&p===""&&a.jsx("div",{className:"space-y-3",children:d.map(f=>a.jsx(qe,{channel:f,onEdit:()=>b(f.id),onDelete:()=>v(f.id),onToggle:T=>E(f.id,T),onQr:()=>g(f)},f.id))}),p!==""&&(j||k)&&a.jsx(It,{form:A,upd:m,saving:R,editing:!!k,channel:k??void 0,onSave:S,onCancel:w,onDelete:k?()=>v(k.id):void 0,onQr:k?()=>g(k):void 0})]})]}):a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsxs("div",{className:"text-center",children:[a.jsx(kt,{className:"w-12 h-12 mx-auto mb-3 text-dark-muted/40"}),a.jsx("p",{className:"text-dark-muted text-sm",children:n("channels.selectTypeHint")})]})})}function qe({channel:n,onEdit:i,onDelete:s,onToggle:t,onQr:e}){const{t:r}=D();return a.jsxs("div",{className:"border border-dark-border rounded-lg bg-dark-surface overflow-hidden",children:[a.jsx("div",{className:"p-5",children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium text-dark-text",children:n.name}),a.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[a.jsx("span",{className:`flex items-center gap-1 text-xs ${n.connected?"text-green-400":"text-dark-muted"}`,children:n.connected?a.jsxs(a.Fragment,{children:[a.jsx(gt,{className:"w-3 h-3"})," ",r("channels.status.connected")]}):a.jsxs(a.Fragment,{children:[a.jsx(mt,{className:"w-3 h-3"})," ",r("channels.status.disconnected")]})}),a.jsxs("span",{className:"text-xs text-dark-muted",children:["AppID: ",n.appId||"—"]})]})]}),a.jsx("button",{onClick:()=>t(!n.enabled),className:`w-9 h-5 rounded-full relative transition-colors shrink-0 ${n.enabled?"bg-green-600":"bg-gray-600"}`,children:a.jsx("span",{className:`absolute top-0.5 w-4 h-4 bg-white rounded-full transition-all ${n.enabled?"left-[18px]":"left-0.5"}`})})]})}),a.jsxs("div",{className:"flex items-center gap-1 px-5 py-2.5 bg-dark-bg/50 border-t border-dark-border",children:[n.type==="wechat"&&a.jsxs("button",{onClick:e,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-green-400 hover:bg-green-500/10 transition-colors",children:[a.jsx(Be,{className:"w-3.5 h-3.5"})," ",r("channels.actions.qrLogin")]}),a.jsxs("button",{onClick:i,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-accent-blue hover:bg-accent-blue/10 transition-colors",children:[a.jsx("span",{className:"w-3.5 h-3.5 inline-flex items-center justify-center",children:"✎"})," ",r("channels.actions.edit")]}),a.jsxs("button",{onClick:s,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-red-400 hover:bg-red-500/10 transition-colors ml-auto",children:[a.jsx(xt,{className:"w-3.5 h-3.5"})," ",r("channels.actions.delete")]})]})]})}function It({form:n,upd:i,saving:s,editing:t,channel:e,onSave:r,onCancel:o,onDelete:c,onQr:l}){const{t:u}=D();return a.jsxs("div",{className:"border border-dark-border rounded-lg bg-dark-surface overflow-hidden",children:[a.jsx("div",{className:"px-5 py-4 border-b border-dark-border",children:a.jsx("h3",{className:"font-medium text-dark-text",children:u(t?"channels.editConfig":"channels.createConfig")})}),a.jsxs("div",{className:"p-5 space-y-4",children:[a.jsx(_e,{label:u("channels.form.name"),required:!0,children:a.jsx("input",{value:n.name,onChange:g=>i("name",g.target.value),placeholder:u("channels.form.namePlaceholderDev"),className:O})}),a.jsxs(_e,{label:u("channels.form.credentials"),children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-[10px] text-dark-muted mb-1",children:u("channels.form.appId")}),a.jsx("input",{value:n.appId,onChange:g=>i("appId",g.target.value),placeholder:"AppID",className:O})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-[10px] text-dark-muted mb-1",children:"AppSecret"}),a.jsx("input",{type:"password",value:n.appSecret,onChange:g=>i("appSecret",g.target.value),placeholder:u(t?"channels.form.leaveBlankUnchanged":"channels.form.appSecretValue"),className:O})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-[10px] text-dark-muted mb-1",children:"Token"}),a.jsx("input",{value:n.token,onChange:g=>i("token",g.target.value),placeholder:u(t?"channels.form.leaveBlankUnchanged":"channels.form.tokenCallback"),className:O})]}),n.type==="wechat"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-[10px] text-dark-muted mb-1",children:"EncodingAESKey"}),a.jsx("input",{value:n.encodingAESKey,onChange:g=>i("encodingAESKey",g.target.value),placeholder:u("channels.form.optionalShort"),className:O})]})]}),n.type==="wechat"&&a.jsx("p",{className:"text-xs text-dark-muted mt-2",children:u("channels.form.wechatIlinkHint")})]}),a.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-dark-border px-3 py-2.5",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-dark-text",children:u("channels.form.enabled")}),a.jsx("p",{className:"text-xs text-dark-muted",children:u("channels.form.enabledOffHint")})]}),a.jsx("button",{onClick:()=>i("enabled",!n.enabled),className:`w-9 h-5 rounded-full relative transition-colors shrink-0 ${n.enabled?"bg-green-600":"bg-gray-600"}`,children:a.jsx("span",{className:`absolute top-0.5 w-4 h-4 bg-white rounded-full transition-all ${n.enabled?"left-[18px]":"left-0.5"}`})})]}),t&&(e==null?void 0:e.type)==="wechat"&&l&&a.jsxs("button",{onClick:l,className:"w-full flex items-center justify-center gap-2 text-sm bg-green-600/15 hover:bg-green-600/25 text-green-400 border border-green-600/40 px-3 py-2.5 rounded-lg transition-colors",children:[a.jsx(Be,{className:"w-4 h-4"})," ",u("channels.qrLoginReauth")]})]}),a.jsxs("div",{className:"flex items-center justify-between px-5 py-3 bg-dark-bg/50 border-t border-dark-border",children:[a.jsx("div",{children:t&&c&&a.jsxs("button",{onClick:c,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-red-400 hover:bg-red-500/10 transition-colors",children:[a.jsx(xt,{className:"w-3.5 h-3.5"})," ",u("channels.actions.delete")]})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:o,className:"px-4 py-2 text-sm text-dark-muted hover:text-dark-text transition-colors",children:u("channels.actions.cancel")}),a.jsxs("button",{onClick:r,disabled:s||!n.name.trim(),className:"flex items-center gap-1.5 px-4 py-2 text-sm bg-accent-blue hover:bg-accent-blue/90 text-white rounded-lg disabled:opacity-50 transition-colors",children:[a.jsx(Et,{className:"w-3.5 h-3.5"}),u(s?"channels.saving":"channels.save")]})]})]})]})}function _e({label:n,required:i,children:s}){return a.jsxs("div",{children:[a.jsxs("label",{className:"block text-xs text-dark-muted mb-1.5",children:[n,i&&a.jsx("span",{className:"text-red-400 ml-0.5",children:"*"})]}),s]})}const O="w-full bg-dark-bg border border-dark-border rounded-lg px-3 py-2 text-sm text-dark-text placeholder-dark-muted/60 focus:outline-none focus:border-accent-blue transition-colors";var V={},se,De;function Mt(){return De||(De=1,se=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),se}var ie={},_={},Ue;function U(){if(Ue)return _;Ue=1;let n;const i=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return _.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17},_.getSymbolTotalCodewords=function(t){return i[t]},_.getBCHDigit=function(s){let t=0;for(;s!==0;)t++,s>>>=1;return t},_.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');n=t},_.isKanjiModeEnabled=function(){return typeof n<"u"},_.toSJIS=function(t){return n(t)},_}var ae={},Fe;function Se(){return Fe||(Fe=1,(function(n){n.L={bit:1},n.M={bit:0},n.Q={bit:3},n.H={bit:2};function i(s){if(typeof s!="string")throw new Error("Param is not a string");switch(s.toLowerCase()){case"l":case"low":return n.L;case"m":case"medium":return n.M;case"q":case"quartile":return n.Q;case"h":case"high":return n.H;default:throw new Error("Unknown EC Level: "+s)}}n.isValid=function(t){return t&&typeof t.bit<"u"&&t.bit>=0&&t.bit<4},n.from=function(t,e){if(n.isValid(t))return t;try{return i(t)}catch{return e}}})(ae)),ae}var oe,Ke;function Pt(){if(Ke)return oe;Ke=1;function n(){this.buffer=[],this.length=0}return n.prototype={get:function(i){const s=Math.floor(i/8);return(this.buffer[s]>>>7-i%8&1)===1},put:function(i,s){for(let t=0;t<s;t++)this.putBit((i>>>s-t-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(i){const s=Math.floor(this.length/8);this.buffer.length<=s&&this.buffer.push(0),i&&(this.buffer[s]|=128>>>this.length%8),this.length++}},oe=n,oe}var le,ze;function Lt(){if(ze)return le;ze=1;function n(i){if(!i||i<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=i,this.data=new Uint8Array(i*i),this.reservedBit=new Uint8Array(i*i)}return n.prototype.set=function(i,s,t,e){const r=i*this.size+s;this.data[r]=t,e&&(this.reservedBit[r]=!0)},n.prototype.get=function(i,s){return this.data[i*this.size+s]},n.prototype.xor=function(i,s,t){this.data[i*this.size+s]^=t},n.prototype.isReserved=function(i,s){return this.reservedBit[i*this.size+s]},le=n,le}var ce={},Ve;function qt(){return Ve||(Ve=1,(function(n){const i=U().getSymbolSize;n.getRowColCoords=function(t){if(t===1)return[];const e=Math.floor(t/7)+2,r=i(t),o=r===145?26:Math.ceil((r-13)/(2*e-2))*2,c=[r-7];for(let l=1;l<e-1;l++)c[l]=c[l-1]-o;return c.push(6),c.reverse()},n.getPositions=function(t){const e=[],r=n.getRowColCoords(t),o=r.length;for(let c=0;c<o;c++)for(let l=0;l<o;l++)c===0&&l===0||c===0&&l===o-1||c===o-1&&l===0||e.push([r[c],r[l]]);return e}})(ce)),ce}var de={},He;function _t(){if(He)return de;He=1;const n=U().getSymbolSize,i=7;return de.getPositions=function(t){const e=n(t);return[[0,0],[e-i,0],[0,e-i]]},de}var ue={},Oe;function Dt(){return Oe||(Oe=1,(function(n){n.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const i={N1:3,N2:3,N3:40,N4:10};n.isValid=function(e){return e!=null&&e!==""&&!isNaN(e)&&e>=0&&e<=7},n.from=function(e){return n.isValid(e)?parseInt(e,10):void 0},n.getPenaltyN1=function(e){const r=e.size;let o=0,c=0,l=0,u=null,g=null;for(let x=0;x<r;x++){c=l=0,u=g=null;for(let h=0;h<r;h++){let d=e.get(x,h);d===u?c++:(c>=5&&(o+=i.N1+(c-5)),u=d,c=1),d=e.get(h,x),d===g?l++:(l>=5&&(o+=i.N1+(l-5)),g=d,l=1)}c>=5&&(o+=i.N1+(c-5)),l>=5&&(o+=i.N1+(l-5))}return o},n.getPenaltyN2=function(e){const r=e.size;let o=0;for(let c=0;c<r-1;c++)for(let l=0;l<r-1;l++){const u=e.get(c,l)+e.get(c,l+1)+e.get(c+1,l)+e.get(c+1,l+1);(u===4||u===0)&&o++}return o*i.N2},n.getPenaltyN3=function(e){const r=e.size;let o=0,c=0,l=0;for(let u=0;u<r;u++){c=l=0;for(let g=0;g<r;g++)c=c<<1&2047|e.get(u,g),g>=10&&(c===1488||c===93)&&o++,l=l<<1&2047|e.get(g,u),g>=10&&(l===1488||l===93)&&o++}return o*i.N3},n.getPenaltyN4=function(e){let r=0;const o=e.data.length;for(let l=0;l<o;l++)r+=e.data[l];return Math.abs(Math.ceil(r*100/o/5)-10)*i.N4};function s(t,e,r){switch(t){case n.Patterns.PATTERN000:return(e+r)%2===0;case n.Patterns.PATTERN001:return e%2===0;case n.Patterns.PATTERN010:return r%3===0;case n.Patterns.PATTERN011:return(e+r)%3===0;case n.Patterns.PATTERN100:return(Math.floor(e/2)+Math.floor(r/3))%2===0;case n.Patterns.PATTERN101:return e*r%2+e*r%3===0;case n.Patterns.PATTERN110:return(e*r%2+e*r%3)%2===0;case n.Patterns.PATTERN111:return(e*r%3+(e+r)%2)%2===0;default:throw new Error("bad maskPattern:"+t)}}n.applyMask=function(e,r){const o=r.size;for(let c=0;c<o;c++)for(let l=0;l<o;l++)r.isReserved(l,c)||r.xor(l,c,s(e,l,c))},n.getBestMask=function(e,r){const o=Object.keys(n.Patterns).length;let c=0,l=1/0;for(let u=0;u<o;u++){r(u),n.applyMask(u,e);const g=n.getPenaltyN1(e)+n.getPenaltyN2(e)+n.getPenaltyN3(e)+n.getPenaltyN4(e);n.applyMask(u,e),g<l&&(l=g,c=u)}return c}})(ue)),ue}var $={},Je;function pt(){if(Je)return $;Je=1;const n=Se(),i=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],s=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return $.getBlocksCount=function(e,r){switch(r){case n.L:return i[(e-1)*4+0];case n.M:return i[(e-1)*4+1];case n.Q:return i[(e-1)*4+2];case n.H:return i[(e-1)*4+3];default:return}},$.getTotalCodewordsCount=function(e,r){switch(r){case n.L:return s[(e-1)*4+0];case n.M:return s[(e-1)*4+1];case n.Q:return s[(e-1)*4+2];case n.H:return s[(e-1)*4+3];default:return}},$}var he={},J={},Qe;function Ut(){if(Qe)return J;Qe=1;const n=new Uint8Array(512),i=new Uint8Array(256);return(function(){let t=1;for(let e=0;e<255;e++)n[e]=t,i[t]=e,t<<=1,t&256&&(t^=285);for(let e=255;e<512;e++)n[e]=n[e-255]})(),J.log=function(t){if(t<1)throw new Error("log("+t+")");return i[t]},J.exp=function(t){return n[t]},J.mul=function(t,e){return t===0||e===0?0:n[i[t]+i[e]]},J}var Ye;function Ft(){return Ye||(Ye=1,(function(n){const i=Ut();n.mul=function(t,e){const r=new Uint8Array(t.length+e.length-1);for(let o=0;o<t.length;o++)for(let c=0;c<e.length;c++)r[o+c]^=i.mul(t[o],e[c]);return r},n.mod=function(t,e){let r=new Uint8Array(t);for(;r.length-e.length>=0;){const o=r[0];for(let l=0;l<e.length;l++)r[l]^=i.mul(e[l],o);let c=0;for(;c<r.length&&r[c]===0;)c++;r=r.slice(c)}return r},n.generateECPolynomial=function(t){let e=new Uint8Array([1]);for(let r=0;r<t;r++)e=n.mul(e,new Uint8Array([1,i.exp(r)]));return e}})(he)),he}var fe,$e;function Kt(){if($e)return fe;$e=1;const n=Ft();function i(s){this.genPoly=void 0,this.degree=s,this.degree&&this.initialize(this.degree)}return i.prototype.initialize=function(t){this.degree=t,this.genPoly=n.generateECPolynomial(this.degree)},i.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const e=new Uint8Array(t.length+this.degree);e.set(t);const r=n.mod(e,this.genPoly),o=this.degree-r.length;if(o>0){const c=new Uint8Array(this.degree);return c.set(r,o),c}return r},fe=i,fe}var ge={},me={},xe={},Ge;function bt(){return Ge||(Ge=1,xe.isValid=function(i){return!isNaN(i)&&i>=1&&i<=40}),xe}var P={},We;function wt(){if(We)return P;We=1;const n="[0-9]+",i="[A-Z $%*+\\-./:]+";let s="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";s=s.replace(/u/g,"\\u");const t="(?:(?![A-Z0-9 $%*+\\-./:]|"+s+`)(?:.|[\r
|
|
2
|
-
]))+`;P.KANJI=new RegExp(s,"g"),P.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),P.BYTE=new RegExp(t,"g"),P.NUMERIC=new RegExp(n,"g"),P.ALPHANUMERIC=new RegExp(i,"g");const e=new RegExp("^"+s+"$"),r=new RegExp("^"+n+"$"),o=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return P.testKanji=function(l){return e.test(l)},P.testNumeric=function(l){return r.test(l)},P.testAlphanumeric=function(l){return o.test(l)},P}var Xe;function F(){return Xe||(Xe=1,(function(n){const i=bt(),s=wt();n.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},n.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},n.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},n.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},n.MIXED={bit:-1},n.getCharCountIndicator=function(r,o){if(!r.ccBits)throw new Error("Invalid mode: "+r);if(!i.isValid(o))throw new Error("Invalid version: "+o);return o>=1&&o<10?r.ccBits[0]:o<27?r.ccBits[1]:r.ccBits[2]},n.getBestModeForData=function(r){return s.testNumeric(r)?n.NUMERIC:s.testAlphanumeric(r)?n.ALPHANUMERIC:s.testKanji(r)?n.KANJI:n.BYTE},n.toString=function(r){if(r&&r.id)return r.id;throw new Error("Invalid mode")},n.isValid=function(r){return r&&r.bit&&r.ccBits};function t(e){if(typeof e!="string")throw new Error("Param is not a string");switch(e.toLowerCase()){case"numeric":return n.NUMERIC;case"alphanumeric":return n.ALPHANUMERIC;case"kanji":return n.KANJI;case"byte":return n.BYTE;default:throw new Error("Unknown mode: "+e)}}n.from=function(r,o){if(n.isValid(r))return r;try{return t(r)}catch{return o}}})(me)),me}var Ze;function zt(){return Ze||(Ze=1,(function(n){const i=U(),s=pt(),t=Se(),e=F(),r=bt(),o=7973,c=i.getBCHDigit(o);function l(h,d,p){for(let y=1;y<=40;y++)if(d<=n.getCapacity(y,p,h))return y}function u(h,d){return e.getCharCountIndicator(h,d)+4}function g(h,d){let p=0;return h.forEach(function(y){const A=u(y.mode,d);p+=A+y.getBitsLength()}),p}function x(h,d){for(let p=1;p<=40;p++)if(g(h,p)<=n.getCapacity(p,d,e.MIXED))return p}n.from=function(d,p){return r.isValid(d)?parseInt(d,10):p},n.getCapacity=function(d,p,y){if(!r.isValid(d))throw new Error("Invalid QR Code version");typeof y>"u"&&(y=e.BYTE);const A=i.getSymbolTotalCodewords(d),N=s.getTotalCodewordsCount(d,p),R=(A-N)*8;if(y===e.MIXED)return R;const B=R-u(y,d);switch(y){case e.NUMERIC:return Math.floor(B/10*3);case e.ALPHANUMERIC:return Math.floor(B/11*2);case e.KANJI:return Math.floor(B/13);case e.BYTE:default:return Math.floor(B/8)}},n.getBestVersionForData=function(d,p){let y;const A=t.from(p,t.M);if(Array.isArray(d)){if(d.length>1)return x(d,A);if(d.length===0)return 1;y=d[0]}else y=d;return l(y.mode,y.getLength(),A)},n.getEncodedBits=function(d){if(!r.isValid(d)||d<7)throw new Error("Invalid QR Code version");let p=d<<12;for(;i.getBCHDigit(p)-c>=0;)p^=o<<i.getBCHDigit(p)-c;return d<<12|p}})(ge)),ge}var pe={},et;function Vt(){if(et)return pe;et=1;const n=U(),i=1335,s=21522,t=n.getBCHDigit(i);return pe.getEncodedBits=function(r,o){const c=r.bit<<3|o;let l=c<<10;for(;n.getBCHDigit(l)-t>=0;)l^=i<<n.getBCHDigit(l)-t;return(c<<10|l)^s},pe}var be={},we,tt;function Ht(){if(tt)return we;tt=1;const n=F();function i(s){this.mode=n.NUMERIC,this.data=s.toString()}return i.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let e,r,o;for(e=0;e+3<=this.data.length;e+=3)r=this.data.substr(e,3),o=parseInt(r,10),t.put(o,10);const c=this.data.length-e;c>0&&(r=this.data.substr(e),o=parseInt(r,10),t.put(o,c*3+1))},we=i,we}var ye,nt;function Ot(){if(nt)return ye;nt=1;const n=F(),i=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function s(t){this.mode=n.ALPHANUMERIC,this.data=t}return s.getBitsLength=function(e){return 11*Math.floor(e/2)+6*(e%2)},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(e){let r;for(r=0;r+2<=this.data.length;r+=2){let o=i.indexOf(this.data[r])*45;o+=i.indexOf(this.data[r+1]),e.put(o,11)}this.data.length%2&&e.put(i.indexOf(this.data[r]),6)},ye=s,ye}var Ne,rt;function
|
|
3
|
-
Make sure your charset is UTF-8`);r=(r>>>8&255)*192+(r&255),t.put(r,13)}},Ce=s,Ce}var je={exports:{}},it;function Yt(){return it||(it=1,(function(n){var i={single_source_shortest_paths:function(s,t,e){var r={},o={};o[t]=0;var c=i.PriorityQueue.make();c.push(t,0);for(var l,u,g,x,h,d,p,y,A;!c.empty();){l=c.pop(),u=l.value,x=l.cost,h=s[u]||{};for(g in h)h.hasOwnProperty(g)&&(d=h[g],p=x+d,y=o[g],A=typeof o[g]>"u",(A||y>p)&&(o[g]=p,c.push(g,p),r[g]=u))}if(typeof e<"u"&&typeof o[e]>"u"){var N=["Could not find a path from ",t," to ",e,"."].join("");throw new Error(N)}return r},extract_shortest_path_from_predecessor_list:function(s,t){for(var e=[],r=t;r;)e.push(r),s[r],r=s[r];return e.reverse(),e},find_path:function(s,t,e){var r=i.single_source_shortest_paths(s,t,e);return i.extract_shortest_path_from_predecessor_list(r,e)},PriorityQueue:{make:function(s){var t=i.PriorityQueue,e={},r;s=s||{};for(r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e.queue=[],e.sorter=s.sorter||t.default_sorter,e},default_sorter:function(s,t){return s.cost-t.cost},push:function(s,t){var e={value:s,cost:t};this.queue.push(e),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};n.exports=i})(je)),je.exports}var at;function $t(){return at||(at=1,(function(n){const i=F(),s=Ht(),t=Ot(),e=
|
|
4
|
-
Suggested mode is: `+i.toString(j));switch(B===i.KANJI&&!c.isKanjiModeEnabled()&&(B=i.BYTE),B){case i.NUMERIC:return new s(N);case i.ALPHANUMERIC:return new t(N);case i.KANJI:return new r(N);case i.BYTE:return new e(N)}}n.fromArray=function(R){return R.reduce(function(B,j){return typeof j=="string"?B.push(A(j,null)):j.data&&B.push(A(j.data,j.mode)),B},[])},n.fromString=function(R,B){const j=x(R,c.isKanjiModeEnabled()),k=p(j),m=y(k,B),b=l.find_path(m.map,"start","end"),C=[];for(let w=1;w<b.length-1;w++)C.push(m.table[b[w]].node);return n.fromArray(d(C))},n.rawSplit=function(R){return n.fromArray(x(R,c.isKanjiModeEnabled()))}})(be)),be}var ot;function Gt(){if(ot)return ie;ot=1;const n=U(),i=Se(),s=Pt(),t=Lt(),e=qt(),r=_t(),o=Dt(),c=pt(),l=Kt(),u=zt(),g=Vt(),x=F(),h=$t();function d(m,b){const C=m.size,w=r.getPositions(b);for(let S=0;S<w.length;S++){const v=w[S][0],E=w[S][1];for(let f=-1;f<=7;f++)if(!(v+f<=-1||C<=v+f))for(let T=-1;T<=7;T++)E+T<=-1||C<=E+T||(f>=0&&f<=6&&(T===0||T===6)||T>=0&&T<=6&&(f===0||f===6)||f>=2&&f<=4&&T>=2&&T<=4?m.set(v+f,E+T,!0,!0):m.set(v+f,E+T,!1,!0))}}function p(m){const b=m.size;for(let C=8;C<b-8;C++){const w=C%2===0;m.set(C,6,w,!0),m.set(6,C,w,!0)}}function y(m,b){const C=e.getPositions(b);for(let w=0;w<C.length;w++){const S=C[w][0],v=C[w][1];for(let E=-2;E<=2;E++)for(let f=-2;f<=2;f++)E===-2||E===2||f===-2||f===2||E===0&&f===0?m.set(S+E,v+f,!0,!0):m.set(S+E,v+f,!1,!0)}}function A(m,b){const C=m.size,w=u.getEncodedBits(b);let S,v,E;for(let f=0;f<18;f++)S=Math.floor(f/3),v=f%3+C-8-3,E=(w>>f&1)===1,m.set(S,v,E,!0),m.set(v,S,E,!0)}function N(m,b,C){const w=m.size,S=g.getEncodedBits(b,C);let v,E;for(v=0;v<15;v++)E=(S>>v&1)===1,v<6?m.set(v,8,E,!0):v<8?m.set(v+1,8,E,!0):m.set(w-15+v,8,E,!0),v<8?m.set(8,w-v-1,E,!0):v<9?m.set(8,15-v-1+1,E,!0):m.set(8,15-v-1,E,!0);m.set(w-8,8,1,!0)}function R(m,b){const C=m.size;let w=-1,S=C-1,v=7,E=0;for(let f=C-1;f>0;f-=2)for(f===6&&f--;;){for(let T=0;T<2;T++)if(!m.isReserved(S,f-T)){let
|
|
1
|
+
import{j as a}from"./markdown-CrVimah5.js";import{a as M,bz as ft,aM as gt,aL as mt,aA as kt,ac as ne,A as vt,bA as Be,aH as xt,n as Et,g as Bt,j as Tt}from"./icons-YJcunJnw.js";import{u as D,am as Te,an as G,ao as W,ap as J,M as St,a as Ie,t as re}from"./index-D1N4vQ9I.js";import"./react-vendor-DM-M1fu_.js";import"./state-D8omNTWe.js";import"./panels-BykQW6E1.js";const Pe=[{labelKey:"im",types:["wechat","feishu","dingtalk"]},{labelKey:"international",types:["telegram","discord","slack","signal","whatsapp"]},{labelKey:"eastAsia",types:["line","qqbot"]},{labelKey:"collaboration",types:["matrix","mattermost","msteams","googlechat"]},{labelKey:"classic",types:["irc","imessage","sms"]},{labelKey:"other",types:["nextcloud-talk","nostr","synology-chat","tlon","twitch","zalo","zalouser"]},{labelKey:"builtin",types:["clickclack","raft","qa-channel"]}];function Rt(){const{t:n}=D(),{channels:i,availableTypes:s,typesLoaded:t,selectedType:e,selectType:r,loadTypes:o}=Te();M.useEffect(()=>{o()},[o]);const c=M.useMemo(()=>{if(s.length===0)return[];const x=new Set(s),h=Pe.map(y=>({...y,types:y.types.filter(A=>x.has(A))})).filter(y=>y.types.length>0),d=new Set(Pe.flatMap(y=>y.types)),p=s.filter(y=>!d.has(y));return p.length>0?[...h,{labelKey:"plugins",types:p}]:h},[s]),l=M.useMemo(()=>{const x=new Map;for(const h of i){const d=x.get(h.type)??{count:0,connected:0};x.set(h.type,{count:d.count+1,connected:d.connected+(h.connected?1:0)})}return x},[i]),u=s.length>0,g=M.useMemo(()=>u?i.filter(x=>s.includes(x.type)):[],[u,i,s]);return a.jsxs("div",{className:"flex flex-col h-full min-h-0 border-r border-dark-border bg-dark-surface",children:[a.jsxs("div",{className:"shrink-0 px-4 py-3 border-b border-dark-border",children:[a.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-dark-muted",children:n("channels.sidebar.title")}),a.jsx("p",{className:"text-[11px] text-dark-muted mt-0.5",children:g.length>0?n("channels.sidebar.configuredCount",{n:g.length}):n(u?"channels.sidebar.clickToConfigure":"channels.sidebar.emptyHint")})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:[t&&!u&&a.jsxs("div",{className:"px-4 py-10 text-center",children:[a.jsx("p",{className:"text-xs text-dark-muted",children:n("channels.sidebar.empty")}),a.jsx("p",{className:"text-[11px] text-dark-muted/70 mt-1.5 leading-relaxed",children:n("channels.sidebar.emptyHint")})]}),c.map(x=>{const h=x.types.filter(d=>l.has(d));return h.length===0?null:a.jsxs("div",{children:[a.jsx("div",{className:"sticky top-0 bg-dark-surface/95 backdrop-blur px-4 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-dark-muted/60",children:n(`channels.categories.${x.labelKey}`)}),h.map(d=>{const p=l.get(d);return a.jsx(Le,{label:J(d),icon:W(d),isSelected:e===d,experimental:G(d),info:p,onClick:()=>r(d)},d)})]},x.labelKey)}),(()=>{const x=c.flatMap(h=>h.types).filter(h=>!l.has(h));return x.length===0?null:a.jsxs("div",{children:[a.jsx("div",{className:"sticky top-0 bg-dark-surface/95 backdrop-blur px-4 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-dark-muted/60",children:n("channels.sidebar.unconfigured")}),x.map(h=>a.jsx(Le,{label:J(h),icon:W(h),isSelected:e===h,experimental:G(h),onClick:()=>r(h)},h))]})})()]})]})}function Le({label:n,icon:i,isSelected:s,experimental:t,info:e,onClick:r}){const{t:o}=D();return a.jsxs("button",{onClick:r,className:`w-full flex items-center gap-2.5 px-4 py-2.5 text-left transition-colors hover:bg-dark-hover ${s?"bg-accent-blue/10 border-l-2 border-accent-blue":"border-l-2 border-transparent"}`,children:[a.jsx("span",{className:"text-lg shrink-0 w-7 h-7 flex items-center justify-center rounded-md bg-dark-bg",children:i}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"text-sm font-medium text-dark-text truncate",children:n}),t&&a.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[9px] text-yellow-500 bg-yellow-500/10 px-1 py-0.5 rounded shrink-0",title:o("channels.experimentalTip"),children:[a.jsx(ft,{className:"w-2.5 h-2.5"})," ",o("channels.experimentalShort")]}),e&&a.jsx("span",{className:"text-[10px] text-dark-muted bg-dark-hover px-1.5 py-0.5 rounded shrink-0",children:e.count})]}),a.jsx("div",{className:"flex items-center gap-1 mt-0.5",children:e?e.connected>0?a.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-green-400",children:[a.jsx(gt,{className:"w-3 h-3"}),e.connected===e.count?o("channels.status.connected"):o("channels.sidebar.partialConnected",{connected:e.connected,count:e.count})]}):a.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-dark-muted",children:[a.jsx(mt,{className:"w-3 h-3"}),o("channels.status.disconnected")]}):a.jsx("span",{className:"text-[11px] text-dark-muted",children:o("channels.sidebar.unconfigured")})})]})]})}const z={name:"",type:"wechat",appId:"",appSecret:"",token:"",encodingAESKey:"",enabled:!0};function At(){const{t:n}=D(),{channels:i,selectedType:s,availableTypes:t,create:e,update:r,remove:o,toggle:c,error:l,clearError:u,openQr:g,load:x}=Te(),h=M.useMemo(()=>t.length>0&&!!s&&!t.includes(s),[t,s]),d=M.useMemo(()=>s?i.filter(f=>f.type===s):[],[i,s]),[p,y]=M.useState(""),[A,N]=M.useState(z),[R,B]=M.useState(!1),j=p==="__new__",k=M.useMemo(()=>j?null:d.find(f=>f.id===p)??null,[d,p,j]);M.useEffect(()=>{y(""),N(z),B(!1),u()},[s]),M.useEffect(()=>{s==="wechat"&&d.length===0&&!h&&g(null)},[s,d.length,h,g]),M.useEffect(()=>{k?N({name:k.name,type:k.type,appId:k.appId||"",appSecret:"",token:"",encodingAESKey:k.encodingAESKey||"",enabled:k.enabled}):j&&N(f=>({...f,type:s}))},[p]);const m=(f,T)=>{u(),N(I=>({...I,[f]:T}))},b=f=>{y(f),u()},C=()=>{y("__new__"),N({...z,type:s}),u()},w=()=>{y(""),N(z),u()},S=async()=>{if(!A.name.trim())return;B(!0);const f=k?await r(k.id,A):await e(A);B(!1),f&&(y(""),N(z))},v=async f=>{if(!confirm(n("channels.actions.deleteConfirmShort")))return;await o(f)&&p===f&&(y(""),N(z))},E=(f,T)=>{c(f,T)};return s?a.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[a.jsx("div",{className:"shrink-0 px-6 py-4 border-b border-dark-border",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"text-2xl",children:W(s)}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h2",{className:"font-semibold text-base text-dark-text",children:J(s)}),G(s)&&a.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[10px] text-yellow-500 bg-yellow-500/10 px-1.5 py-0.5 rounded",title:n("channels.experimentalTip"),children:[a.jsx(ft,{className:"w-3 h-3"})," ",n("channels.experimentalLabel")]})]}),a.jsx("p",{className:"text-xs text-dark-muted mt-0.5",children:d.length>0?n("channels.instancesCount",{n:d.length}):n("channels.notConfiguredYet")}),G(s)&&a.jsx("p",{className:"text-[10px] text-yellow-600/70 mt-1",children:n("channels.experimentalDesc")})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:()=>x(),className:"text-xs px-3 py-1.5 rounded-lg border border-dark-border text-dark-muted hover:text-dark-text hover:bg-dark-hover transition-colors",children:n("channels.actions.refresh")}),a.jsxs("button",{onClick:C,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg bg-accent-blue hover:bg-accent-blue/90 text-white transition-colors",children:[a.jsx(ne,{className:"w-3.5 h-3.5"})," ",n("channels.createInstance")]})]})]})}),l&&a.jsxs("div",{className:"shrink-0 mx-6 mt-3 bg-red-500/10 border border-red-500/40 text-red-400 px-3 py-2 rounded-lg text-sm flex justify-between items-center",children:[a.jsx("span",{children:l}),a.jsx("button",{onClick:u,className:"text-red-400 hover:text-red-300",children:a.jsx("span",{className:"w-4 h-4 inline-flex items-center justify-center",children:"×"})})]}),h&&a.jsxs("div",{className:"shrink-0 mx-6 mt-3 flex items-start gap-2 bg-amber-500/10 border border-amber-500/40 text-amber-400 px-3 py-2 rounded-lg text-xs",children:[a.jsx(vt,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),a.jsx("span",{children:n("channels.pluginMissingWarning",{name:s==="wechat"?" WeChat Channel":` ${J(s)}`})})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto custom-scrollbar p-6",children:[d.length>1&&!j&&a.jsxs("div",{className:"mb-4",children:[a.jsx("label",{className:"block text-xs text-dark-muted mb-1.5",children:n("channels.selectInstance")}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[d.map(f=>a.jsxs("button",{onClick:()=>b(f.id),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs border transition-colors ${p===f.id?"bg-accent-blue/10 border-accent-blue/40 text-accent-blue":"border-dark-border text-dark-muted hover:text-dark-text hover:bg-dark-hover"}`,children:[a.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${f.connected?"bg-green-500":"bg-gray-500"}`}),f.name]},f.id)),a.jsxs("button",{onClick:C,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs border border-dashed border-dark-border text-dark-muted hover:text-dark-text hover:bg-dark-hover transition-colors",children:[a.jsx(ne,{className:"w-3 h-3"})," ",n("channels.createShort")]})]})]}),d.length===0&&p===""&&a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[a.jsx("div",{className:"text-4xl mb-3",children:W(s)}),a.jsx("p",{className:"text-dark-text font-medium",children:n("channels.emptyWithType",{type:J(s)})}),a.jsx("p",{className:"text-sm text-dark-muted mt-1 mb-4",children:n(s==="wechat"?"channels.wechatBindHint":"channels.startWithCreate")}),s==="wechat"&&a.jsxs("button",{onClick:()=>g(null),className:"flex items-center gap-1.5 text-sm px-4 py-2 rounded-lg bg-green-600/15 hover:bg-green-600/25 text-green-400 border border-green-600/40 transition-colors mb-3",children:[a.jsx(Be,{className:"w-4 h-4"})," ",n("channels.scanToBind")]}),a.jsxs("button",{onClick:C,className:"flex items-center gap-1.5 text-sm px-4 py-2 rounded-lg bg-accent-blue hover:bg-accent-blue/90 text-white transition-colors",children:[a.jsx(ne,{className:"w-4 h-4"})," ",n("channels.createInstance")]})]}),d.length===1&&p===""&&d[0]&&a.jsx(qe,{channel:d[0],onEdit:()=>b(d[0].id),onDelete:()=>v(d[0].id),onToggle:f=>E(d[0].id,f),onQr:()=>g(d[0])}),d.length>1&&p===""&&a.jsx("div",{className:"space-y-3",children:d.map(f=>a.jsx(qe,{channel:f,onEdit:()=>b(f.id),onDelete:()=>v(f.id),onToggle:T=>E(f.id,T),onQr:()=>g(f)},f.id))}),p!==""&&(j||k)&&a.jsx(Mt,{form:A,upd:m,saving:R,editing:!!k,channel:k??void 0,onSave:S,onCancel:w,onDelete:k?()=>v(k.id):void 0,onQr:k?()=>g(k):void 0})]})]}):a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsxs("div",{className:"text-center",children:[a.jsx(kt,{className:"w-12 h-12 mx-auto mb-3 text-dark-muted/40"}),a.jsx("p",{className:"text-dark-muted text-sm",children:n("channels.selectTypeHint")})]})})}function qe({channel:n,onEdit:i,onDelete:s,onToggle:t,onQr:e}){const{t:r}=D();return a.jsxs("div",{className:"border border-dark-border rounded-lg bg-dark-surface overflow-hidden",children:[a.jsx("div",{className:"p-5",children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium text-dark-text",children:n.name}),a.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[a.jsx("span",{className:`flex items-center gap-1 text-xs ${n.connected?"text-green-400":"text-dark-muted"}`,children:n.connected?a.jsxs(a.Fragment,{children:[a.jsx(gt,{className:"w-3 h-3"})," ",r("channels.status.connected")]}):a.jsxs(a.Fragment,{children:[a.jsx(mt,{className:"w-3 h-3"})," ",r("channels.status.disconnected")]})}),a.jsxs("span",{className:"text-xs text-dark-muted",children:["AppID: ",n.appId||"—"]})]})]}),a.jsx("button",{onClick:()=>t(!n.enabled),className:`w-9 h-5 rounded-full relative transition-colors shrink-0 ${n.enabled?"bg-green-600":"bg-gray-600"}`,children:a.jsx("span",{className:`absolute top-0.5 w-4 h-4 bg-white rounded-full transition-all ${n.enabled?"left-[18px]":"left-0.5"}`})})]})}),a.jsxs("div",{className:"flex items-center gap-1 px-5 py-2.5 bg-dark-bg/50 border-t border-dark-border",children:[n.type==="wechat"&&a.jsxs("button",{onClick:e,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-green-400 hover:bg-green-500/10 transition-colors",children:[a.jsx(Be,{className:"w-3.5 h-3.5"})," ",r("channels.actions.qrLogin")]}),a.jsxs("button",{onClick:i,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-accent-blue hover:bg-accent-blue/10 transition-colors",children:[a.jsx("span",{className:"w-3.5 h-3.5 inline-flex items-center justify-center",children:"✎"})," ",r("channels.actions.edit")]}),a.jsxs("button",{onClick:s,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-red-400 hover:bg-red-500/10 transition-colors ml-auto",children:[a.jsx(xt,{className:"w-3.5 h-3.5"})," ",r("channels.actions.delete")]})]})]})}function Mt({form:n,upd:i,saving:s,editing:t,channel:e,onSave:r,onCancel:o,onDelete:c,onQr:l}){const{t:u}=D();return a.jsxs("div",{className:"border border-dark-border rounded-lg bg-dark-surface overflow-hidden",children:[a.jsx("div",{className:"px-5 py-4 border-b border-dark-border",children:a.jsx("h3",{className:"font-medium text-dark-text",children:u(t?"channels.editConfig":"channels.createConfig")})}),a.jsxs("div",{className:"p-5 space-y-4",children:[a.jsx(_e,{label:u("channels.form.name"),required:!0,children:a.jsx("input",{value:n.name,onChange:g=>i("name",g.target.value),placeholder:u("channels.form.namePlaceholderDev"),className:O})}),a.jsxs(_e,{label:u("channels.form.credentials"),children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-[10px] text-dark-muted mb-1",children:u("channels.form.appId")}),a.jsx("input",{value:n.appId,onChange:g=>i("appId",g.target.value),placeholder:"AppID",className:O})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-[10px] text-dark-muted mb-1",children:"AppSecret"}),a.jsx("input",{type:"password",value:n.appSecret,onChange:g=>i("appSecret",g.target.value),placeholder:u(t?"channels.form.leaveBlankUnchanged":"channels.form.appSecretValue"),className:O})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-[10px] text-dark-muted mb-1",children:"Token"}),a.jsx("input",{value:n.token,onChange:g=>i("token",g.target.value),placeholder:u(t?"channels.form.leaveBlankUnchanged":"channels.form.tokenCallback"),className:O})]}),n.type==="wechat"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-[10px] text-dark-muted mb-1",children:"EncodingAESKey"}),a.jsx("input",{value:n.encodingAESKey,onChange:g=>i("encodingAESKey",g.target.value),placeholder:u("channels.form.optionalShort"),className:O})]})]}),n.type==="wechat"&&a.jsx("p",{className:"text-xs text-dark-muted mt-2",children:u("channels.form.wechatIlinkHint")})]}),a.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-dark-border px-3 py-2.5",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-dark-text",children:u("channels.form.enabled")}),a.jsx("p",{className:"text-xs text-dark-muted",children:u("channels.form.enabledOffHint")})]}),a.jsx("button",{onClick:()=>i("enabled",!n.enabled),className:`w-9 h-5 rounded-full relative transition-colors shrink-0 ${n.enabled?"bg-green-600":"bg-gray-600"}`,children:a.jsx("span",{className:`absolute top-0.5 w-4 h-4 bg-white rounded-full transition-all ${n.enabled?"left-[18px]":"left-0.5"}`})})]}),t&&(e==null?void 0:e.type)==="wechat"&&l&&a.jsxs("button",{onClick:l,className:"w-full flex items-center justify-center gap-2 text-sm bg-green-600/15 hover:bg-green-600/25 text-green-400 border border-green-600/40 px-3 py-2.5 rounded-lg transition-colors",children:[a.jsx(Be,{className:"w-4 h-4"})," ",u("channels.qrLoginReauth")]})]}),a.jsxs("div",{className:"flex items-center justify-between px-5 py-3 bg-dark-bg/50 border-t border-dark-border",children:[a.jsx("div",{children:t&&c&&a.jsxs("button",{onClick:c,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-red-400 hover:bg-red-500/10 transition-colors",children:[a.jsx(xt,{className:"w-3.5 h-3.5"})," ",u("channels.actions.delete")]})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:o,className:"px-4 py-2 text-sm text-dark-muted hover:text-dark-text transition-colors",children:u("channels.actions.cancel")}),a.jsxs("button",{onClick:r,disabled:s||!n.name.trim(),className:"flex items-center gap-1.5 px-4 py-2 text-sm bg-accent-blue hover:bg-accent-blue/90 text-white rounded-lg disabled:opacity-50 transition-colors",children:[a.jsx(Et,{className:"w-3.5 h-3.5"}),u(s?"channels.saving":"channels.save")]})]})]})]})}function _e({label:n,required:i,children:s}){return a.jsxs("div",{children:[a.jsxs("label",{className:"block text-xs text-dark-muted mb-1.5",children:[n,i&&a.jsx("span",{className:"text-red-400 ml-0.5",children:"*"})]}),s]})}const O="w-full bg-dark-bg border border-dark-border rounded-lg px-3 py-2 text-sm text-dark-text placeholder-dark-muted/60 focus:outline-none focus:border-accent-blue transition-colors";var V={},se,De;function It(){return De||(De=1,se=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),se}var ie={},_={},Ue;function U(){if(Ue)return _;Ue=1;let n;const i=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return _.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17},_.getSymbolTotalCodewords=function(t){return i[t]},_.getBCHDigit=function(s){let t=0;for(;s!==0;)t++,s>>>=1;return t},_.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');n=t},_.isKanjiModeEnabled=function(){return typeof n<"u"},_.toSJIS=function(t){return n(t)},_}var ae={},Fe;function Se(){return Fe||(Fe=1,(function(n){n.L={bit:1},n.M={bit:0},n.Q={bit:3},n.H={bit:2};function i(s){if(typeof s!="string")throw new Error("Param is not a string");switch(s.toLowerCase()){case"l":case"low":return n.L;case"m":case"medium":return n.M;case"q":case"quartile":return n.Q;case"h":case"high":return n.H;default:throw new Error("Unknown EC Level: "+s)}}n.isValid=function(t){return t&&typeof t.bit<"u"&&t.bit>=0&&t.bit<4},n.from=function(t,e){if(n.isValid(t))return t;try{return i(t)}catch{return e}}})(ae)),ae}var oe,Ke;function Pt(){if(Ke)return oe;Ke=1;function n(){this.buffer=[],this.length=0}return n.prototype={get:function(i){const s=Math.floor(i/8);return(this.buffer[s]>>>7-i%8&1)===1},put:function(i,s){for(let t=0;t<s;t++)this.putBit((i>>>s-t-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(i){const s=Math.floor(this.length/8);this.buffer.length<=s&&this.buffer.push(0),i&&(this.buffer[s]|=128>>>this.length%8),this.length++}},oe=n,oe}var le,ze;function Lt(){if(ze)return le;ze=1;function n(i){if(!i||i<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=i,this.data=new Uint8Array(i*i),this.reservedBit=new Uint8Array(i*i)}return n.prototype.set=function(i,s,t,e){const r=i*this.size+s;this.data[r]=t,e&&(this.reservedBit[r]=!0)},n.prototype.get=function(i,s){return this.data[i*this.size+s]},n.prototype.xor=function(i,s,t){this.data[i*this.size+s]^=t},n.prototype.isReserved=function(i,s){return this.reservedBit[i*this.size+s]},le=n,le}var ce={},Ve;function qt(){return Ve||(Ve=1,(function(n){const i=U().getSymbolSize;n.getRowColCoords=function(t){if(t===1)return[];const e=Math.floor(t/7)+2,r=i(t),o=r===145?26:Math.ceil((r-13)/(2*e-2))*2,c=[r-7];for(let l=1;l<e-1;l++)c[l]=c[l-1]-o;return c.push(6),c.reverse()},n.getPositions=function(t){const e=[],r=n.getRowColCoords(t),o=r.length;for(let c=0;c<o;c++)for(let l=0;l<o;l++)c===0&&l===0||c===0&&l===o-1||c===o-1&&l===0||e.push([r[c],r[l]]);return e}})(ce)),ce}var de={},He;function _t(){if(He)return de;He=1;const n=U().getSymbolSize,i=7;return de.getPositions=function(t){const e=n(t);return[[0,0],[e-i,0],[0,e-i]]},de}var ue={},Oe;function Dt(){return Oe||(Oe=1,(function(n){n.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const i={N1:3,N2:3,N3:40,N4:10};n.isValid=function(e){return e!=null&&e!==""&&!isNaN(e)&&e>=0&&e<=7},n.from=function(e){return n.isValid(e)?parseInt(e,10):void 0},n.getPenaltyN1=function(e){const r=e.size;let o=0,c=0,l=0,u=null,g=null;for(let x=0;x<r;x++){c=l=0,u=g=null;for(let h=0;h<r;h++){let d=e.get(x,h);d===u?c++:(c>=5&&(o+=i.N1+(c-5)),u=d,c=1),d=e.get(h,x),d===g?l++:(l>=5&&(o+=i.N1+(l-5)),g=d,l=1)}c>=5&&(o+=i.N1+(c-5)),l>=5&&(o+=i.N1+(l-5))}return o},n.getPenaltyN2=function(e){const r=e.size;let o=0;for(let c=0;c<r-1;c++)for(let l=0;l<r-1;l++){const u=e.get(c,l)+e.get(c,l+1)+e.get(c+1,l)+e.get(c+1,l+1);(u===4||u===0)&&o++}return o*i.N2},n.getPenaltyN3=function(e){const r=e.size;let o=0,c=0,l=0;for(let u=0;u<r;u++){c=l=0;for(let g=0;g<r;g++)c=c<<1&2047|e.get(u,g),g>=10&&(c===1488||c===93)&&o++,l=l<<1&2047|e.get(g,u),g>=10&&(l===1488||l===93)&&o++}return o*i.N3},n.getPenaltyN4=function(e){let r=0;const o=e.data.length;for(let l=0;l<o;l++)r+=e.data[l];return Math.abs(Math.ceil(r*100/o/5)-10)*i.N4};function s(t,e,r){switch(t){case n.Patterns.PATTERN000:return(e+r)%2===0;case n.Patterns.PATTERN001:return e%2===0;case n.Patterns.PATTERN010:return r%3===0;case n.Patterns.PATTERN011:return(e+r)%3===0;case n.Patterns.PATTERN100:return(Math.floor(e/2)+Math.floor(r/3))%2===0;case n.Patterns.PATTERN101:return e*r%2+e*r%3===0;case n.Patterns.PATTERN110:return(e*r%2+e*r%3)%2===0;case n.Patterns.PATTERN111:return(e*r%3+(e+r)%2)%2===0;default:throw new Error("bad maskPattern:"+t)}}n.applyMask=function(e,r){const o=r.size;for(let c=0;c<o;c++)for(let l=0;l<o;l++)r.isReserved(l,c)||r.xor(l,c,s(e,l,c))},n.getBestMask=function(e,r){const o=Object.keys(n.Patterns).length;let c=0,l=1/0;for(let u=0;u<o;u++){r(u),n.applyMask(u,e);const g=n.getPenaltyN1(e)+n.getPenaltyN2(e)+n.getPenaltyN3(e)+n.getPenaltyN4(e);n.applyMask(u,e),g<l&&(l=g,c=u)}return c}})(ue)),ue}var $={},Qe;function pt(){if(Qe)return $;Qe=1;const n=Se(),i=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],s=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return $.getBlocksCount=function(e,r){switch(r){case n.L:return i[(e-1)*4+0];case n.M:return i[(e-1)*4+1];case n.Q:return i[(e-1)*4+2];case n.H:return i[(e-1)*4+3];default:return}},$.getTotalCodewordsCount=function(e,r){switch(r){case n.L:return s[(e-1)*4+0];case n.M:return s[(e-1)*4+1];case n.Q:return s[(e-1)*4+2];case n.H:return s[(e-1)*4+3];default:return}},$}var he={},Q={},Je;function Ut(){if(Je)return Q;Je=1;const n=new Uint8Array(512),i=new Uint8Array(256);return(function(){let t=1;for(let e=0;e<255;e++)n[e]=t,i[t]=e,t<<=1,t&256&&(t^=285);for(let e=255;e<512;e++)n[e]=n[e-255]})(),Q.log=function(t){if(t<1)throw new Error("log("+t+")");return i[t]},Q.exp=function(t){return n[t]},Q.mul=function(t,e){return t===0||e===0?0:n[i[t]+i[e]]},Q}var Ye;function Ft(){return Ye||(Ye=1,(function(n){const i=Ut();n.mul=function(t,e){const r=new Uint8Array(t.length+e.length-1);for(let o=0;o<t.length;o++)for(let c=0;c<e.length;c++)r[o+c]^=i.mul(t[o],e[c]);return r},n.mod=function(t,e){let r=new Uint8Array(t);for(;r.length-e.length>=0;){const o=r[0];for(let l=0;l<e.length;l++)r[l]^=i.mul(e[l],o);let c=0;for(;c<r.length&&r[c]===0;)c++;r=r.slice(c)}return r},n.generateECPolynomial=function(t){let e=new Uint8Array([1]);for(let r=0;r<t;r++)e=n.mul(e,new Uint8Array([1,i.exp(r)]));return e}})(he)),he}var fe,$e;function Kt(){if($e)return fe;$e=1;const n=Ft();function i(s){this.genPoly=void 0,this.degree=s,this.degree&&this.initialize(this.degree)}return i.prototype.initialize=function(t){this.degree=t,this.genPoly=n.generateECPolynomial(this.degree)},i.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const e=new Uint8Array(t.length+this.degree);e.set(t);const r=n.mod(e,this.genPoly),o=this.degree-r.length;if(o>0){const c=new Uint8Array(this.degree);return c.set(r,o),c}return r},fe=i,fe}var ge={},me={},xe={},Ge;function bt(){return Ge||(Ge=1,xe.isValid=function(i){return!isNaN(i)&&i>=1&&i<=40}),xe}var P={},We;function wt(){if(We)return P;We=1;const n="[0-9]+",i="[A-Z $%*+\\-./:]+";let s="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";s=s.replace(/u/g,"\\u");const t="(?:(?![A-Z0-9 $%*+\\-./:]|"+s+`)(?:.|[\r
|
|
2
|
+
]))+`;P.KANJI=new RegExp(s,"g"),P.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),P.BYTE=new RegExp(t,"g"),P.NUMERIC=new RegExp(n,"g"),P.ALPHANUMERIC=new RegExp(i,"g");const e=new RegExp("^"+s+"$"),r=new RegExp("^"+n+"$"),o=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return P.testKanji=function(l){return e.test(l)},P.testNumeric=function(l){return r.test(l)},P.testAlphanumeric=function(l){return o.test(l)},P}var Xe;function F(){return Xe||(Xe=1,(function(n){const i=bt(),s=wt();n.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},n.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},n.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},n.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},n.MIXED={bit:-1},n.getCharCountIndicator=function(r,o){if(!r.ccBits)throw new Error("Invalid mode: "+r);if(!i.isValid(o))throw new Error("Invalid version: "+o);return o>=1&&o<10?r.ccBits[0]:o<27?r.ccBits[1]:r.ccBits[2]},n.getBestModeForData=function(r){return s.testNumeric(r)?n.NUMERIC:s.testAlphanumeric(r)?n.ALPHANUMERIC:s.testKanji(r)?n.KANJI:n.BYTE},n.toString=function(r){if(r&&r.id)return r.id;throw new Error("Invalid mode")},n.isValid=function(r){return r&&r.bit&&r.ccBits};function t(e){if(typeof e!="string")throw new Error("Param is not a string");switch(e.toLowerCase()){case"numeric":return n.NUMERIC;case"alphanumeric":return n.ALPHANUMERIC;case"kanji":return n.KANJI;case"byte":return n.BYTE;default:throw new Error("Unknown mode: "+e)}}n.from=function(r,o){if(n.isValid(r))return r;try{return t(r)}catch{return o}}})(me)),me}var Ze;function zt(){return Ze||(Ze=1,(function(n){const i=U(),s=pt(),t=Se(),e=F(),r=bt(),o=7973,c=i.getBCHDigit(o);function l(h,d,p){for(let y=1;y<=40;y++)if(d<=n.getCapacity(y,p,h))return y}function u(h,d){return e.getCharCountIndicator(h,d)+4}function g(h,d){let p=0;return h.forEach(function(y){const A=u(y.mode,d);p+=A+y.getBitsLength()}),p}function x(h,d){for(let p=1;p<=40;p++)if(g(h,p)<=n.getCapacity(p,d,e.MIXED))return p}n.from=function(d,p){return r.isValid(d)?parseInt(d,10):p},n.getCapacity=function(d,p,y){if(!r.isValid(d))throw new Error("Invalid QR Code version");typeof y>"u"&&(y=e.BYTE);const A=i.getSymbolTotalCodewords(d),N=s.getTotalCodewordsCount(d,p),R=(A-N)*8;if(y===e.MIXED)return R;const B=R-u(y,d);switch(y){case e.NUMERIC:return Math.floor(B/10*3);case e.ALPHANUMERIC:return Math.floor(B/11*2);case e.KANJI:return Math.floor(B/13);case e.BYTE:default:return Math.floor(B/8)}},n.getBestVersionForData=function(d,p){let y;const A=t.from(p,t.M);if(Array.isArray(d)){if(d.length>1)return x(d,A);if(d.length===0)return 1;y=d[0]}else y=d;return l(y.mode,y.getLength(),A)},n.getEncodedBits=function(d){if(!r.isValid(d)||d<7)throw new Error("Invalid QR Code version");let p=d<<12;for(;i.getBCHDigit(p)-c>=0;)p^=o<<i.getBCHDigit(p)-c;return d<<12|p}})(ge)),ge}var pe={},et;function Vt(){if(et)return pe;et=1;const n=U(),i=1335,s=21522,t=n.getBCHDigit(i);return pe.getEncodedBits=function(r,o){const c=r.bit<<3|o;let l=c<<10;for(;n.getBCHDigit(l)-t>=0;)l^=i<<n.getBCHDigit(l)-t;return(c<<10|l)^s},pe}var be={},we,tt;function Ht(){if(tt)return we;tt=1;const n=F();function i(s){this.mode=n.NUMERIC,this.data=s.toString()}return i.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let e,r,o;for(e=0;e+3<=this.data.length;e+=3)r=this.data.substr(e,3),o=parseInt(r,10),t.put(o,10);const c=this.data.length-e;c>0&&(r=this.data.substr(e),o=parseInt(r,10),t.put(o,c*3+1))},we=i,we}var ye,nt;function Ot(){if(nt)return ye;nt=1;const n=F(),i=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function s(t){this.mode=n.ALPHANUMERIC,this.data=t}return s.getBitsLength=function(e){return 11*Math.floor(e/2)+6*(e%2)},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(e){let r;for(r=0;r+2<=this.data.length;r+=2){let o=i.indexOf(this.data[r])*45;o+=i.indexOf(this.data[r+1]),e.put(o,11)}this.data.length%2&&e.put(i.indexOf(this.data[r]),6)},ye=s,ye}var Ne,rt;function Qt(){if(rt)return Ne;rt=1;const n=F();function i(s){this.mode=n.BYTE,typeof s=="string"?this.data=new TextEncoder().encode(s):this.data=new Uint8Array(s)}return i.getBitsLength=function(t){return t*8},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(s){for(let t=0,e=this.data.length;t<e;t++)s.put(this.data[t],8)},Ne=i,Ne}var Ce,st;function Jt(){if(st)return Ce;st=1;const n=F(),i=U();function s(t){this.mode=n.KANJI,this.data=t}return s.getBitsLength=function(e){return e*13},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(t){let e;for(e=0;e<this.data.length;e++){let r=i.toSJIS(this.data[e]);if(r>=33088&&r<=40956)r-=33088;else if(r>=57408&&r<=60351)r-=49472;else throw new Error("Invalid SJIS character: "+this.data[e]+`
|
|
3
|
+
Make sure your charset is UTF-8`);r=(r>>>8&255)*192+(r&255),t.put(r,13)}},Ce=s,Ce}var je={exports:{}},it;function Yt(){return it||(it=1,(function(n){var i={single_source_shortest_paths:function(s,t,e){var r={},o={};o[t]=0;var c=i.PriorityQueue.make();c.push(t,0);for(var l,u,g,x,h,d,p,y,A;!c.empty();){l=c.pop(),u=l.value,x=l.cost,h=s[u]||{};for(g in h)h.hasOwnProperty(g)&&(d=h[g],p=x+d,y=o[g],A=typeof o[g]>"u",(A||y>p)&&(o[g]=p,c.push(g,p),r[g]=u))}if(typeof e<"u"&&typeof o[e]>"u"){var N=["Could not find a path from ",t," to ",e,"."].join("");throw new Error(N)}return r},extract_shortest_path_from_predecessor_list:function(s,t){for(var e=[],r=t;r;)e.push(r),s[r],r=s[r];return e.reverse(),e},find_path:function(s,t,e){var r=i.single_source_shortest_paths(s,t,e);return i.extract_shortest_path_from_predecessor_list(r,e)},PriorityQueue:{make:function(s){var t=i.PriorityQueue,e={},r;s=s||{};for(r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e.queue=[],e.sorter=s.sorter||t.default_sorter,e},default_sorter:function(s,t){return s.cost-t.cost},push:function(s,t){var e={value:s,cost:t};this.queue.push(e),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};n.exports=i})(je)),je.exports}var at;function $t(){return at||(at=1,(function(n){const i=F(),s=Ht(),t=Ot(),e=Qt(),r=Jt(),o=wt(),c=U(),l=Yt();function u(N){return unescape(encodeURIComponent(N)).length}function g(N,R,B){const j=[];let k;for(;(k=N.exec(B))!==null;)j.push({data:k[0],index:k.index,mode:R,length:k[0].length});return j}function x(N){const R=g(o.NUMERIC,i.NUMERIC,N),B=g(o.ALPHANUMERIC,i.ALPHANUMERIC,N);let j,k;return c.isKanjiModeEnabled()?(j=g(o.BYTE,i.BYTE,N),k=g(o.KANJI,i.KANJI,N)):(j=g(o.BYTE_KANJI,i.BYTE,N),k=[]),R.concat(B,j,k).sort(function(b,C){return b.index-C.index}).map(function(b){return{data:b.data,mode:b.mode,length:b.length}})}function h(N,R){switch(R){case i.NUMERIC:return s.getBitsLength(N);case i.ALPHANUMERIC:return t.getBitsLength(N);case i.KANJI:return r.getBitsLength(N);case i.BYTE:return e.getBitsLength(N)}}function d(N){return N.reduce(function(R,B){const j=R.length-1>=0?R[R.length-1]:null;return j&&j.mode===B.mode?(R[R.length-1].data+=B.data,R):(R.push(B),R)},[])}function p(N){const R=[];for(let B=0;B<N.length;B++){const j=N[B];switch(j.mode){case i.NUMERIC:R.push([j,{data:j.data,mode:i.ALPHANUMERIC,length:j.length},{data:j.data,mode:i.BYTE,length:j.length}]);break;case i.ALPHANUMERIC:R.push([j,{data:j.data,mode:i.BYTE,length:j.length}]);break;case i.KANJI:R.push([j,{data:j.data,mode:i.BYTE,length:u(j.data)}]);break;case i.BYTE:R.push([{data:j.data,mode:i.BYTE,length:u(j.data)}])}}return R}function y(N,R){const B={},j={start:{}};let k=["start"];for(let m=0;m<N.length;m++){const b=N[m],C=[];for(let w=0;w<b.length;w++){const S=b[w],v=""+m+w;C.push(v),B[v]={node:S,lastCount:0},j[v]={};for(let E=0;E<k.length;E++){const f=k[E];B[f]&&B[f].node.mode===S.mode?(j[f][v]=h(B[f].lastCount+S.length,S.mode)-h(B[f].lastCount,S.mode),B[f].lastCount+=S.length):(B[f]&&(B[f].lastCount=S.length),j[f][v]=h(S.length,S.mode)+4+i.getCharCountIndicator(S.mode,R))}}k=C}for(let m=0;m<k.length;m++)j[k[m]].end=0;return{map:j,table:B}}function A(N,R){let B;const j=i.getBestModeForData(N);if(B=i.from(R,j),B!==i.BYTE&&B.bit<j.bit)throw new Error('"'+N+'" cannot be encoded with mode '+i.toString(B)+`.
|
|
4
|
+
Suggested mode is: `+i.toString(j));switch(B===i.KANJI&&!c.isKanjiModeEnabled()&&(B=i.BYTE),B){case i.NUMERIC:return new s(N);case i.ALPHANUMERIC:return new t(N);case i.KANJI:return new r(N);case i.BYTE:return new e(N)}}n.fromArray=function(R){return R.reduce(function(B,j){return typeof j=="string"?B.push(A(j,null)):j.data&&B.push(A(j.data,j.mode)),B},[])},n.fromString=function(R,B){const j=x(R,c.isKanjiModeEnabled()),k=p(j),m=y(k,B),b=l.find_path(m.map,"start","end"),C=[];for(let w=1;w<b.length-1;w++)C.push(m.table[b[w]].node);return n.fromArray(d(C))},n.rawSplit=function(R){return n.fromArray(x(R,c.isKanjiModeEnabled()))}})(be)),be}var ot;function Gt(){if(ot)return ie;ot=1;const n=U(),i=Se(),s=Pt(),t=Lt(),e=qt(),r=_t(),o=Dt(),c=pt(),l=Kt(),u=zt(),g=Vt(),x=F(),h=$t();function d(m,b){const C=m.size,w=r.getPositions(b);for(let S=0;S<w.length;S++){const v=w[S][0],E=w[S][1];for(let f=-1;f<=7;f++)if(!(v+f<=-1||C<=v+f))for(let T=-1;T<=7;T++)E+T<=-1||C<=E+T||(f>=0&&f<=6&&(T===0||T===6)||T>=0&&T<=6&&(f===0||f===6)||f>=2&&f<=4&&T>=2&&T<=4?m.set(v+f,E+T,!0,!0):m.set(v+f,E+T,!1,!0))}}function p(m){const b=m.size;for(let C=8;C<b-8;C++){const w=C%2===0;m.set(C,6,w,!0),m.set(6,C,w,!0)}}function y(m,b){const C=e.getPositions(b);for(let w=0;w<C.length;w++){const S=C[w][0],v=C[w][1];for(let E=-2;E<=2;E++)for(let f=-2;f<=2;f++)E===-2||E===2||f===-2||f===2||E===0&&f===0?m.set(S+E,v+f,!0,!0):m.set(S+E,v+f,!1,!0)}}function A(m,b){const C=m.size,w=u.getEncodedBits(b);let S,v,E;for(let f=0;f<18;f++)S=Math.floor(f/3),v=f%3+C-8-3,E=(w>>f&1)===1,m.set(S,v,E,!0),m.set(v,S,E,!0)}function N(m,b,C){const w=m.size,S=g.getEncodedBits(b,C);let v,E;for(v=0;v<15;v++)E=(S>>v&1)===1,v<6?m.set(v,8,E,!0):v<8?m.set(v+1,8,E,!0):m.set(w-15+v,8,E,!0),v<8?m.set(8,w-v-1,E,!0):v<9?m.set(8,15-v-1+1,E,!0):m.set(8,15-v-1,E,!0);m.set(w-8,8,1,!0)}function R(m,b){const C=m.size;let w=-1,S=C-1,v=7,E=0;for(let f=C-1;f>0;f-=2)for(f===6&&f--;;){for(let T=0;T<2;T++)if(!m.isReserved(S,f-T)){let I=!1;E<b.length&&(I=(b[E]>>>v&1)===1),m.set(S,f-T,I),v--,v===-1&&(E++,v=7)}if(S+=w,S<0||C<=S){S-=w,w=-w;break}}}function B(m,b,C){const w=new s;C.forEach(function(T){w.put(T.mode.bit,4),w.put(T.getLength(),x.getCharCountIndicator(T.mode,m)),T.write(w)});const S=n.getSymbolTotalCodewords(m),v=c.getTotalCodewordsCount(m,b),E=(S-v)*8;for(w.getLengthInBits()+4<=E&&w.put(0,4);w.getLengthInBits()%8!==0;)w.putBit(0);const f=(E-w.getLengthInBits())/8;for(let T=0;T<f;T++)w.put(T%2?17:236,8);return j(w,m,b)}function j(m,b,C){const w=n.getSymbolTotalCodewords(b),S=c.getTotalCodewordsCount(b,C),v=w-S,E=c.getBlocksCount(b,C),f=w%E,T=E-f,I=Math.floor(w/E),H=Math.floor(v/E),Nt=H+1,Re=I-H,Ct=new l(Re);let X=0;const Y=new Array(E),Ae=new Array(E);let Z=0;const jt=new Uint8Array(m.buffer);for(let K=0;K<E;K++){const te=K<T?H:Nt;Y[K]=jt.slice(X,X+te),Ae[K]=Ct.encode(Y[K]),X+=te,Z=Math.max(Z,te)}const ee=new Uint8Array(w);let Me=0,L,q;for(L=0;L<Z;L++)for(q=0;q<E;q++)L<Y[q].length&&(ee[Me++]=Y[q][L]);for(L=0;L<Re;L++)for(q=0;q<E;q++)ee[Me++]=Ae[q][L];return ee}function k(m,b,C,w){let S;if(Array.isArray(m))S=h.fromArray(m);else if(typeof m=="string"){let I=b;if(!I){const H=h.rawSplit(m);I=u.getBestVersionForData(H,C)}S=h.fromString(m,I||40)}else throw new Error("Invalid data");const v=u.getBestVersionForData(S,C);if(!v)throw new Error("The amount of data is too big to be stored in a QR Code");if(!b)b=v;else if(b<v)throw new Error(`
|
|
5
5
|
The chosen QR Code version cannot contain this amount of data.
|
|
6
6
|
Minimum version required to store current data is: `+v+`.
|
|
7
7
|
`);const E=B(b,C,S),f=n.getSymbolSize(b),T=new t(f);return d(T,b),p(T),y(T,b),N(T,C,0),b>=7&&A(T,b),R(T,E),isNaN(w)&&(w=o.getBestMask(T,N.bind(null,T,C))),o.applyMask(w,T),N(T,C,w),{modules:T,version:b,errorCorrectionLevel:C,maskPattern:w,segments:S}}return ie.create=function(b,C){if(typeof b>"u"||b==="")throw new Error("No input text");let w=i.M,S,v;return typeof C<"u"&&(w=i.from(C.errorCorrectionLevel,i.M),S=u.from(C.version),v=o.from(C.maskPattern),C.toSJISFunc&&n.setToSJISFunction(C.toSJISFunc)),k(b,S,w,v)},ie}var ke={},ve={},lt;function yt(){return lt||(lt=1,(function(n){function i(s){if(typeof s=="number"&&(s=s.toString()),typeof s!="string")throw new Error("Color should be defined as hex string");let t=s.slice().replace("#","").split("");if(t.length<3||t.length===5||t.length>8)throw new Error("Invalid hex color: "+s);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(r){return[r,r]}))),t.length===6&&t.push("F","F");const e=parseInt(t.join(""),16);return{r:e>>24&255,g:e>>16&255,b:e>>8&255,a:e&255,hex:"#"+t.slice(0,6).join("")}}n.getOptions=function(t){t||(t={}),t.color||(t.color={});const e=typeof t.margin>"u"||t.margin===null||t.margin<0?4:t.margin,r=t.width&&t.width>=21?t.width:void 0,o=t.scale||4;return{width:r,scale:r?4:o,margin:e,color:{dark:i(t.color.dark||"#000000ff"),light:i(t.color.light||"#ffffffff")},type:t.type,rendererOpts:t.rendererOpts||{}}},n.getScale=function(t,e){return e.width&&e.width>=t+e.margin*2?e.width/(t+e.margin*2):e.scale},n.getImageWidth=function(t,e){const r=n.getScale(t,e);return Math.floor((t+e.margin*2)*r)},n.qrToImageData=function(t,e,r){const o=e.modules.size,c=e.modules.data,l=n.getScale(o,r),u=Math.floor((o+r.margin*2)*l),g=r.margin*l,x=[r.color.light,r.color.dark];for(let h=0;h<u;h++)for(let d=0;d<u;d++){let p=(h*u+d)*4,y=r.color.light;if(h>=g&&d>=g&&h<u-g&&d<u-g){const A=Math.floor((h-g)/l),N=Math.floor((d-g)/l);y=x[c[A*o+N]?1:0]}t[p++]=y.r,t[p++]=y.g,t[p++]=y.b,t[p]=y.a}}})(ve)),ve}var ct;function Wt(){return ct||(ct=1,(function(n){const i=yt();function s(e,r,o){e.clearRect(0,0,r.width,r.height),r.style||(r.style={}),r.height=o,r.width=o,r.style.height=o+"px",r.style.width=o+"px"}function t(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}n.render=function(r,o,c){let l=c,u=o;typeof l>"u"&&(!o||!o.getContext)&&(l=o,o=void 0),o||(u=t()),l=i.getOptions(l);const g=i.getImageWidth(r.modules.size,l),x=u.getContext("2d"),h=x.createImageData(g,g);return i.qrToImageData(h.data,r,l),s(x,u,g),x.putImageData(h,0,0),u},n.renderToDataURL=function(r,o,c){let l=c;typeof l>"u"&&(!o||!o.getContext)&&(l=o,o=void 0),l||(l={});const u=n.render(r,o,l),g=l.type||"image/png",x=l.rendererOpts||{};return u.toDataURL(g,x.quality)}})(ke)),ke}var Ee={},dt;function Xt(){if(dt)return Ee;dt=1;const n=yt();function i(e,r){const o=e.a/255,c=r+'="'+e.hex+'"';return o<1?c+" "+r+'-opacity="'+o.toFixed(2).slice(1)+'"':c}function s(e,r,o){let c=e+r;return typeof o<"u"&&(c+=" "+o),c}function t(e,r,o){let c="",l=0,u=!1,g=0;for(let x=0;x<e.length;x++){const h=Math.floor(x%r),d=Math.floor(x/r);!h&&!u&&(u=!0),e[x]?(g++,x>0&&h>0&&e[x-1]||(c+=u?s("M",h+o,.5+d+o):s("m",l,0),l=0,u=!1),h+1<r&&e[x+1]||(c+=s("h",g),g=0)):l++}return c}return Ee.render=function(r,o,c){const l=n.getOptions(o),u=r.modules.size,g=r.modules.data,x=u+l.margin*2,h=l.color.light.a?"<path "+i(l.color.light,"fill")+' d="M0 0h'+x+"v"+x+'H0z"/>':"",d="<path "+i(l.color.dark,"stroke")+' d="'+t(g,u,l.margin)+'"/>',p='viewBox="0 0 '+x+" "+x+'"',A='<svg xmlns="http://www.w3.org/2000/svg" '+(l.width?'width="'+l.width+'" height="'+l.width+'" ':"")+p+' shape-rendering="crispEdges">'+h+d+`</svg>
|
|
8
|
-
`;return typeof c=="function"&&c(null,A),A},Ee}var ut;function Zt(){if(ut)return V;ut=1;const n=
|
|
8
|
+
`;return typeof c=="function"&&c(null,A),A},Ee}var ut;function Zt(){if(ut)return V;ut=1;const n=It(),i=Gt(),s=Wt(),t=Xt();function e(r,o,c,l,u){const g=[].slice.call(arguments,1),x=g.length,h=typeof g[x-1]=="function";if(!h&&!n())throw new Error("Callback required as last argument");if(h){if(x<2)throw new Error("Too few arguments provided");x===2?(u=c,c=o,o=l=void 0):x===3&&(o.getContext&&typeof u>"u"?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0))}else{if(x<1)throw new Error("Too few arguments provided");return x===1?(c=o,o=l=void 0):x===2&&!o.getContext&&(l=c,c=o,o=void 0),new Promise(function(d,p){try{const y=i.create(c,l);d(r(y,o,l))}catch(y){p(y)}})}try{const d=i.create(c,l);u(null,r(d,o,l))}catch(d){u(d)}}return V.create=i.create,V.toCanvas=e.bind(null,s.render),V.toDataURL=e.bind(null,s.renderToDataURL),V.toString=e.bind(null,function(r,o,c){return t.render(r,c)}),V}var en=Zt();const tn=Bt(en),nn=2e3,ht=5;function rn({channel:n,onClose:i}){const{t:s}=D(),[t,e]=M.useState("loading"),[r,o]=M.useState(null),[c,l]=M.useState(null),[u,g]=M.useState(""),x=M.useRef(null),h=M.useRef(0),d=M.useRef(null),p=M.useRef(!1),y=()=>{d.current&&(clearTimeout(d.current),d.current=null),p.current=!0},A=async k=>{if(x.current)try{await tn.toCanvas(x.current,k,{width:240,margin:2,color:{dark:"#000000ff",light:"#ffffffff"}})}catch(m){console.warn("[WechatQr] Canvas QR generation failed, falling back to URL:",m)}},N=async()=>{if(!(p.current||!c))try{const k=await Ie.channels.weixin.bindStatus(c),m=(k==null?void 0:k.data)??k,b=(m==null?void 0:m.status)??"";if(h.current=0,b==="confirmed"){e("confirmed"),re.success(n?s("channels.toastReauthSuccess",{name:n.name}):s("channels.toastBindSuccess")),setTimeout(i,2400);return}if(b==="scaned")e("scanned");else if(b==="expired"){e("expired");return}p.current||(d.current=setTimeout(N,nn))}catch(k){if(h.current++,console.warn("[WechatQr] poll error ("+h.current+"/"+ht+")",k),h.current>=ht)e("error"),g(s("channels.pollFailedRefresh")),re.error(s("channels.pollFailedToast"));else if(!p.current){const m=Math.min(1e3*Math.pow(2,h.current),1e4);d.current=setTimeout(N,m)}}},R=()=>{y(),p.current=!1,h.current=0,d.current=setTimeout(N,1e3)},B=async()=>{e("loading"),o(null),l(null),g(""),h.current=0;try{const k=await Ie.channels.weixin.bind(),m=(k==null?void 0:k.data)??k,b=(m==null?void 0:m.qrcode_img_content)??"",C=(m==null?void 0:m.qrcode)??"";if(!b||!C){e("error"),g(s("channels.qrDataMissing",{data:JSON.stringify(m)}));return}o(b),l(C),await A(b),e("waiting")}catch(k){e("error");const m=String((k==null?void 0:k.message)??k);g(m),re.error(s("channels.fetchWechatQrFailed",{error:m}))}},j=()=>{B()};return M.useEffect(()=>(B(),y),[]),M.useEffect(()=>(c&&R(),y),[c]),a.jsx(St,{isOpen:!0,onClose:i,title:s("channels.bindTitle",{name:(n==null?void 0:n.name)??s("channels.typeLabels.wechat")}),size:"sm",children:a.jsxs("div",{className:"flex flex-col items-center gap-4 py-2",children:[a.jsxs("div",{className:"relative w-60 h-60 rounded-lg bg-white flex items-center justify-center overflow-hidden",children:[t==="loading"&&a.jsx("span",{className:"text-gray-400 text-sm",children:s("channels.qr.generating")}),t!=="error"&&t!=="expired"&&a.jsx("canvas",{ref:x,width:240,height:240,className:`w-full h-full object-contain ${t==="waiting"?"":"opacity-30"}`}),t==="scanned"&&a.jsxs("div",{className:"absolute inset-0 bg-black/70 flex flex-col items-center justify-center text-white gap-1",children:[a.jsx("span",{className:"text-2xl",children:"✓"}),a.jsx("span",{className:"text-sm",children:s("channels.qr.scanned")})]}),t==="confirmed"&&a.jsxs("div",{className:"absolute inset-0 bg-green-600/90 flex flex-col items-center justify-center text-white gap-2 px-4 text-center",children:[a.jsx("span",{className:"text-2xl",children:"🎉"}),a.jsx("span",{className:"text-sm font-medium",children:s("channels.bindSuccess")}),a.jsx("span",{className:"text-xs opacity-90",children:n?s("channels.connectedReady",{name:n.name}):s("channels.createdConnectedReady")}),a.jsx("button",{onClick:i,className:"mt-1 text-xs bg-white/20 hover:bg-white/30 px-3 py-1.5 rounded-md transition-colors",children:s("channels.startUsing")})]}),t==="expired"&&a.jsxs("div",{className:"absolute inset-0 bg-black/80 flex flex-col items-center justify-center text-white gap-2",children:[a.jsx("span",{className:"text-sm",children:s("channels.qr.expired")}),a.jsx("button",{onClick:j,className:"text-xs bg-green-600 hover:bg-green-500 px-3 py-1 rounded",children:s("channels.clickToRefresh")})]}),t==="error"&&a.jsxs("div",{className:"absolute inset-0 bg-black/80 flex flex-col items-center justify-center text-red-300 gap-2 px-4 text-center",children:[a.jsx("span",{className:"text-xs",children:u||s("channels.unknownError")}),a.jsx("button",{onClick:j,className:"text-xs bg-blue-600 hover:bg-blue-500 px-3 py-1 rounded text-white",children:s("channels.retry")})]})]}),a.jsxs("p",{className:"text-sm text-dark-muted text-center",children:[t==="waiting"&&s("channels.waitingAuthorize"),t==="scanned"&&s("channels.scannedConfirming"),t==="confirmed"&&s("channels.confirmedClosing"),t==="loading"&&s("channels.connectingIlink"),(t==="expired"||t==="error")&&(t==="expired"?s("channels.qr.expired"):"")]}),r&&t==="waiting"&&a.jsxs("button",{onClick:()=>window.open(r,"_blank","width=480,height=600,noopener"),className:"w-full flex items-center justify-center gap-2 text-sm bg-green-600/15 hover:bg-green-600/25 text-green-400 border border-green-600/40 px-3 py-2.5 rounded-lg transition-colors",children:[a.jsx("span",{children:"🔔"})," ",s("channels.openInNewTabFallback")]})]})})}function un(){const{t:n}=D(),{load:i,loading:s,qrOpen:t,qrChannel:e,closeQr:r}=Te();return M.useEffect(()=>{i()},[]),a.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-dark-bg text-dark-text",children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-dark-border shrink-0",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"font-semibold text-base",children:n("channels.title")}),a.jsx("p",{className:"text-xs text-dark-muted mt-0.5",children:n("channels.viewSubtitle")})]}),a.jsx("div",{className:"flex items-center gap-2",children:a.jsx("button",{onClick:()=>i(),title:n("channels.actions.refresh"),className:"p-2 rounded-lg text-dark-muted hover:text-dark-text hover:bg-dark-hover transition-colors",children:a.jsx(Tt,{className:`w-4 h-4 ${s?"animate-spin":""}`})})})]}),a.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[a.jsx("div",{className:"w-[260px] shrink-0",children:a.jsx(Rt,{})}),a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx(At,{})})]}),t&&a.jsx(rn,{channel:e,onClose:r})]})}export{un as ChannelConfigView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as s}from"./markdown-CrVimah5.js";import{a as c,L as w,A as q,aA as G,ac as pe,j as be,b4 as ge,bd as he,b as H,aw as fe,ae as I,_ as V,S as D,ao as je,b8 as M,aH as ve,D as Y,v as ke}from"./icons-YJcunJnw.js";import{u as Ne,w as ye,a as p}from"./index-D1N4vQ9I.js";import"./react-vendor-DM-M1fu_.js";import"./state-D8omNTWe.js";import"./panels-BykQW6E1.js";const we={"code-intelligence":"🧠 代码智能",filesystem:"📂 文件系统",databases:"🗄️ 数据库","browser-automation":"🌐 浏览器自动化","knowledge-memory":"🧠 知识/记忆","search-web":"🔎 搜索/网页","cloud-platforms":"☁️ 云平台",communication:"💬 通讯","developer-tools":"🛠️ 开发者工具",security:"🔒 安全","test-demo":"🧪 测试/Demo",other:"📦 其他"};function Ae({onNavigate:C}){const{t:n}=Ne(),[b,i]=c.useState([]),[Q,T]=c.useState(!0),[A,L]=c.useState(null),[S,m]=c.useState({}),[_,u]=c.useState(null),[E,W]=c.useState(""),[g,B]=c.useState(null),[z,J]=c.useState("all"),[X,j]=c.useState(null),[Z,P]=c.useState({}),[ee,$]=c.useState(!1),[o,x]=c.useState({name:"",command:"",args:"",env:"",transport:"stdio",url:"",headers:""}),[h,F]=c.useState(null),[R,v]=c.useState(!1),[U,f]=c.useState(null),se=async()=>{v(!0),f(null);try{const e=await p.tools.get("computer_use");F(e.success&&e.data?!!e.data.enabled:!1)}catch(e){f(e instanceof Error?e.message:String(e))}v(!1)},te=async()=>{if(h===null)return;const e=!h;v(!0),f(null);try{const t=await p.tools.toggle("computer_use",e);t.success?F(e):f(t.error||"切换 Computer Use 失败")}catch(t){f(t instanceof Error?t.message:String(t))}v(!1)},re=()=>x({name:"",command:"",args:"",env:"",transport:"stdio",url:"",headers:""}),K=e=>Object.fromEntries(e.split(",").map(t=>t.trim()).filter(Boolean).map(t=>{const a=t.indexOf("=");return a>0?[t.slice(0,a).trim(),t.slice(a+1).trim()]:[t,""]})),ae=async()=>{const e=o.transport!=="stdio";if(!o.name.trim()||!e&&!o.command.trim()||e&&!o.url.trim()){u(n("connectors.customFormRequired"));return}m(t=>({...t,__add:!0})),u(null);try{const t=await p.connectors.addCustom({name:o.name.trim(),command:e?void 0:o.command.trim(),args:e?void 0:o.args.split(/\s+/).filter(Boolean),env:K(o.env),url:e?o.url.trim():void 0,transport:e?o.transport:void 0,headers:e?K(o.headers):void 0});t.success&&t.data?(i(a=>[...a,t.data]),$(!1),re()):u(t.error||"添加失败")}catch(t){u(t instanceof Error?t.message:String(t))}finally{m(t=>({...t,__add:!1}))}},ne=async e=>{m(t=>({...t,[e.id]:!0}));try{const t=await p.connectors.removeCustom(e.id);t.success?i(a=>a.filter(r=>r.id!==e.id)):u(t.error||"删除失败")}finally{m(t=>({...t,[e.id]:!1}))}},k=async()=>{var t;T(!0),L(null);const e=await p.connectors.list();e.success&&Array.isArray((t=e.data)==null?void 0:t.connectors)?i(e.data.connectors):L(e.error||"加载连接器失败"),T(!1)};c.useEffect(()=>{k(),se()},[]),c.useEffect(()=>{let e=null;const t=r=>{if(!r||r.type!=="mcp_update")return;let l;try{l=typeof r.data=="string"?JSON.parse(r.data):r.data||{}}catch{return}const d=String(l.server||l.name||"");/^(managed|custom)-connector-/.test(d)&&(e&&clearTimeout(e),e=setTimeout(()=>{e=null,k()},150))},a=ye.onMessage(t);return()=>{e&&clearTimeout(e),a()}},[]);const N=(e,t,a,r)=>{u(a||null),i(l=>l.map(d=>d.id===e?{...d,enabled:!!r,status:"error"}:d))},le=async(e,t,a)=>{u(null),m(r=>({...r,[e.id]:!0})),i(r=>r.map(l=>l.id===e.id?{...l,enabled:t,status:t?"connecting":"installed"}:l));try{const r=await p.connectors.toggle(e.id,t,a);r.success&&r.data?i(l=>l.map(d=>d.id===e.id?r.data:d)):N(e.id,void 0,r.error||`切换 ${e.name} 失败`,!t)}catch(r){N(e.id,void 0,r instanceof Error?r.message:String(r),!t)}finally{m(r=>({...r,[e.id]:!1}))}},oe=e=>{var t,a;if(!e.enabled&&((t=e.requiresEnv)!=null&&t.length)&&((a=e.missingEnv)!=null&&a.length)){j(e.id);return}j(null),le(e,!e.enabled)},ce=async(e,t)=>{j(null),u(null),m(a=>({...a,[e.id]:!0})),i(a=>a.map(r=>r.id===e.id?{...r,enabled:!0,status:"connecting"}:r));try{const a=await p.connectors.connect(e.id,t);a.success&&a.data?(i(r=>r.map(l=>l.id===e.id?a.data:l)),P(r=>({...r,[e.id]:{}}))):N(e.id,void 0,a.error||`连接 ${e.name} 失败`,!1)}catch(a){N(e.id,void 0,a instanceof Error?a.message:String(a),!1)}finally{m(a=>({...a,[e.id]:!1}))}},de=e=>{const t="inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium";if(!e.installed)return s.jsxs("span",{className:`${t} bg-dark-hover text-dark-muted`,children:[s.jsx(Y,{size:12}),n("connectors.notInstalled")]});switch(e.status){case"ready":return s.jsxs("span",{className:`${t} bg-accent-green/15 text-accent-green`,children:[s.jsx(ke,{size:12}),n("connectors.ready")]});case"connecting":return s.jsxs("span",{className:`${t} bg-accent-blue/15 text-accent-blue`,children:[s.jsx(w,{size:12,className:"animate-spin"}),n("connectors.connecting")]});case"error":return s.jsxs("span",{className:`${t} bg-accent-red/15 text-accent-red`,children:[s.jsx(q,{size:12}),n("connectors.error")]});case"disabled":return s.jsx("span",{className:`${t} bg-dark-hover text-dark-muted`,children:n("connectors.disabled")});default:return s.jsx("span",{className:`${t} bg-dark-hover text-dark-muted`,children:n("connectors.installed")})}},y=b.filter(e=>z==="all"||e.kind===z),O=y.filter(e=>{if(E){const t=E.toLowerCase();if(![e.name,e.id,e.description,e.category??"",e.kind,...e.languages??[]].join(" ").toLowerCase().includes(t))return!1}return!(g&&e.category!==g)}).sort((e,t)=>e.enabled!==t.enabled?e.enabled?-1:1:e.name.localeCompare(t.name)),ie=[...new Set(y.map(e=>e.category).filter(Boolean))];if(Q)return s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsxs("div",{className:"text-center",children:[s.jsx(w,{size:32,className:"animate-spin mx-auto mb-2 text-accent-blue"}),s.jsx("p",{className:"text-dark-muted",children:n("common.loading")})]})});if(A)return s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsxs("div",{className:"text-center",children:[s.jsx(q,{size:32,className:"mx-auto mb-2 text-accent-red"}),s.jsx("p",{className:"text-accent-red mb-4",children:A}),s.jsx("button",{onClick:()=>void k(),className:"px-4 py-2 bg-accent-blue text-white rounded-lg",children:n("common.retry")})]})});const me=e=>{const t=Z[e.id]??{},a=(r,l)=>P(d=>({...d,[e.id]:{...d[e.id]??{},[r]:l}}));return s.jsxs("div",{className:"mt-3 pt-3 border-t border-dark-border",children:[s.jsxs("div",{className:"text-xs text-dark-muted mb-2 flex items-center gap-1",children:[s.jsx(M,{size:12}),n("connectors.needCredentials")]}),s.jsx("div",{className:"space-y-2",children:(e.requiresEnv??[]).map(r=>s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:r.label}),s.jsx("input",{type:r.secret?"password":"text",value:t[r.key]??"",onChange:l=>a(r.key,l.target.value),placeholder:r.key,className:"w-full px-3 py-1.5 bg-dark-bg border border-dark-border rounded-lg text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]},r.key))}),s.jsxs("div",{className:"flex gap-2 mt-2",children:[s.jsx("button",{onClick:()=>void ce(e,t),className:"px-3 py-1.5 bg-accent-blue text-white rounded-lg text-sm",children:n("connectors.connect")}),s.jsx("button",{onClick:()=>j(null),className:"px-3 py-1.5 bg-dark-surface border border-dark-border rounded-lg text-sm",children:n("common.cancel")})]})]})},ue=e=>{var r,l,d;const t=!!S[e.id],a=X===e.id;return s.jsxs("div",{className:`bg-dark-surface border border-dark-border rounded-lg p-4 transition-opacity ${e.enabled?"":"opacity-80"}`,children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[s.jsx("span",{className:`mt-0.5 shrink-0 px-2 py-1 rounded-md text-[11px] font-semibold uppercase ${e.kind==="lsp"?"bg-accent-purple/15 text-accent-purple":"bg-accent-green/15 text-accent-green"}`,children:e.kind==="lsp"?"LSP":"MCP"}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"font-medium text-sm truncate",children:e.name}),e.custom?s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-purple/15 text-accent-purple",children:n("connectors.custom")}):null,e.official?s.jsxs("span",{title:"Official",className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-yellow/15 text-accent-yellow",children:["🎖️ ",n("connectors.official")]}):null,e.scope==="cloud"?s.jsxs("span",{title:"Cloud",className:"inline-flex items-center gap-0.5 text-[10px] px-1.5 py-0.5 rounded bg-accent-blue/15 text-accent-blue",children:[s.jsx(V,{size:9}),n("connectors.cloud")]}):s.jsxs("span",{title:"Local",className:"inline-flex items-center gap-0.5 text-[10px] px-1.5 py-0.5 rounded bg-dark-hover text-dark-muted",children:[s.jsx(D,{size:9}),n("connectors.local")]}),e.language?s.jsx("span",{className:"text-[10px]",children:e.language}):null,de(e)]}),s.jsx("p",{className:"text-xs text-dark-muted mt-1 line-clamp-2",children:e.description}),s.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[11px] text-dark-muted flex-wrap",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(D,{size:11}),s.jsx("code",{className:"text-[10px]",children:e.installHint})]}),e.transport&&e.transport!=="stdio"?s.jsxs("span",{className:"inline-flex items-center gap-1 text-accent-blue",children:[s.jsx(V,{size:11}),e.transport==="sse"?"SSE":"Streamable HTTP"]}):null,(r=e.languages)!=null&&r.length?s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(je,{size:11}),e.languages.join(", ")]}):null,e.kind==="mcp"&&e.toolCount!==void 0?s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(G,{size:11}),n("connectors.toolCount",{count:e.toolCount})]}):null,(l=e.requiresEnv)!=null&&l.length?s.jsxs("span",{className:"inline-flex items-center gap-1 text-accent-yellow",children:[s.jsx(M,{size:11}),(d=e.missingEnv)!=null&&d.length?`${e.missingEnv.join(", ")} ${n("connectors.missing")}`:n("connectors.envConfigured")]}):null,e.docsUrl?s.jsxs("a",{href:e.docsUrl,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 hover:text-accent-blue",onClick:xe=>xe.stopPropagation(),children:[s.jsx(H,{size:11}),n("connectors.docs")]}):null]}),e.error?s.jsx("p",{className:"text-[11px] text-accent-red mt-1",children:e.error}):null]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.custom?s.jsx("button",{onClick:()=>void ne(e),disabled:t,title:n("connectors.removeCustom"),className:"p-1.5 rounded-lg text-dark-muted hover:text-accent-red hover:bg-accent-red/10 transition-colors disabled:opacity-40",children:s.jsx(ve,{size:14})}):null,!e.installed&&e.enabled?s.jsxs("span",{className:"text-[11px] text-accent-blue flex items-center gap-1",children:[s.jsx(Y,{size:11,className:"animate-pulse"}),n("connectors.installing")]}):null,s.jsx("button",{role:"switch","aria-checked":e.enabled,disabled:t,onClick:()=>oe(e),className:`relative w-12 h-6 rounded-full transition-colors disabled:opacity-50 ${e.enabled?"bg-accent-green":"bg-dark-border"}`,children:s.jsx("span",{className:`absolute top-1 w-4 h-4 bg-white rounded-full transition-transform ${e.enabled?"left-7":"left-1"}`})})]})]}),a?me(e):null]},e.id)};return s.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[s.jsx(G,{size:20}),n("nav.connectors"),s.jsxs("span",{className:"text-sm font-normal text-dark-muted",children:["· ",b.filter(e=>e.enabled).length,"/",b.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>$(e=>!e),className:"flex items-center gap-2 px-3 py-1.5 bg-accent-blue text-white rounded hover:bg-accent-blue/90 transition-colors",children:[s.jsx(pe,{size:14}),n("connectors.addCustom")]}),s.jsxs("button",{onClick:()=>void k(),className:"flex items-center gap-2 px-3 py-1.5 bg-dark-surface border border-dark-border rounded hover:bg-dark-hover transition-colors",children:[s.jsx(be,{size:14}),n("common.refresh")]})]})]}),s.jsxs("div",{className:"mb-4 p-4 bg-dark-surface border border-dark-border rounded-lg space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 flex items-start gap-2",children:[s.jsx(ge,{size:16,className:"text-accent-blue mt-0.5 shrink-0"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm text-dark-text",children:"Computer Use"}),s.jsx("div",{className:"text-xs text-dark-muted mt-0.5",children:"GUI 截屏 + 鼠标键盘操控(Windows)。每次调用需审批;需要视觉模型读屏。"})]})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":!!h,disabled:R,onClick:()=>void te(),className:`relative w-9 h-5 rounded-full transition-colors shrink-0 disabled:opacity-50 ${h?"bg-accent-blue":"bg-dark-border"}`,children:R?s.jsx(w,{size:12,className:"absolute left-[7px] top-[3px] animate-spin text-white"}):s.jsx("span",{className:`absolute top-0.5 left-0 w-4 h-4 rounded-full bg-white shadow transition-transform ${h?"translate-x-[18px]":"translate-x-0.5"}`})})]}),s.jsxs("div",{className:"pt-3 border-t border-dark-border flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 flex items-start gap-2",children:[s.jsx(he,{size:16,className:"text-accent-yellow mt-0.5 shrink-0"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm text-dark-text",children:"xAI (Grok) API"}),s.jsx("div",{className:"text-xs text-dark-muted mt-0.5",children:"官方 OpenAI 兼容端点,支持 X 实时数据的 Grok 系列模型。"})]})]}),s.jsxs("button",{onClick:()=>C==null?void 0:C("models"),className:"flex items-center gap-1.5 px-3 py-1.5 bg-accent-blue/10 text-accent-blue border border-accent-blue/30 rounded-lg hover:bg-accent-blue/20 transition-colors text-xs shrink-0",children:["配置",s.jsx(H,{size:11})]})]}),U?s.jsx("div",{className:"text-xs text-accent-red bg-accent-red/10 border border-accent-red/30 rounded-lg px-3 py-2",children:U}):null]}),ee?s.jsxs("div",{className:"mb-4 p-4 bg-dark-surface border border-dark-border rounded-lg",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[s.jsx(fe,{size:15,className:"text-accent-purple"}),n("connectors.customTitle")]}),s.jsx("div",{className:"flex gap-1",children:[["stdio","🖥️ "+n("connectors.customLocal")],["http","🌐 HTTP"],["sse","📡 SSE"]].map(([e,t])=>s.jsx("button",{onClick:()=>x(a=>({...a,transport:e})),className:`px-3 py-1.5 rounded-lg text-xs transition-colors ${o.transport===e?"bg-accent-blue text-white":"bg-dark-bg border border-dark-border hover:bg-dark-hover"}`,children:t},e))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:n("connectors.customName")}),s.jsx("input",{value:o.name,onChange:e=>x(t=>({...t,name:e.target.value})),placeholder:"my-server",className:"w-full px-3 py-1.5 bg-dark-bg border border-dark-border rounded-lg text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]}),o.transport==="stdio"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:n("connectors.customCommand")}),s.jsx("input",{value:o.command,onChange:e=>x(t=>({...t,command:e.target.value})),placeholder:"npx -y @some/mcp-server",className:"w-full px-3 py-1.5 bg-dark-bg border border-dark-border rounded-lg text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:n("connectors.customArgs")}),s.jsx("input",{value:o.args,onChange:e=>x(t=>({...t,args:e.target.value})),placeholder:"--arg value",className:"w-full px-3 py-1.5 bg-dark-bg border border-dark-border rounded-lg text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]})]}):s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:n("connectors.customUrl")}),s.jsx("input",{value:o.url,onChange:e=>x(t=>({...t,url:e.target.value})),placeholder:"https://mcp.example.com/mcp",className:"w-full px-3 py-1.5 bg-dark-bg border border-dark-border rounded-lg text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]}),o.transport==="stdio"?s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:n("connectors.customEnv")}),s.jsx("input",{value:o.env,onChange:e=>x(t=>({...t,env:e.target.value})),placeholder:"KEY=value, KEY2=value2",className:"w-full px-3 py-1.5 bg-dark-bg border border-dark-border rounded-lg text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]}):s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:n("connectors.customHeaders")}),s.jsx("input",{value:o.headers,onChange:e=>x(t=>({...t,headers:e.target.value})),placeholder:"Authorization=Bearer xxx",className:"w-full px-3 py-1.5 bg-dark-bg border border-dark-border rounded-lg text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]})]}),s.jsxs("div",{className:"flex gap-2 mt-3",children:[s.jsx("button",{onClick:()=>void ae(),disabled:!!S.__add,className:"px-3 py-1.5 bg-accent-blue text-white rounded-lg text-sm disabled:opacity-50",children:S.__add?s.jsx(w,{size:14,className:"animate-spin"}):n("connectors.add")}),s.jsx("button",{onClick:()=>$(!1),className:"px-3 py-1.5 bg-dark-surface border border-dark-border rounded-lg text-sm",children:n("common.cancel")})]})]}):null,s.jsx("div",{className:"flex gap-1 mb-3",children:[["all",`${n("connectors.all")} (${b.length})`],["lsp",`LSP (${b.filter(e=>e.kind==="lsp").length})`],["mcp",`MCP (${b.filter(e=>e.kind==="mcp").length})`]].map(([e,t])=>s.jsx("button",{onClick:()=>J(e),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${z===e?"bg-accent-blue text-white":"bg-dark-surface border border-dark-border hover:bg-dark-hover"}`,children:t},e))}),s.jsx("div",{className:"flex gap-3 mb-3",children:s.jsxs("div",{className:"flex-1 relative",children:[s.jsx(I,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-dark-muted"}),s.jsx("input",{type:"text",value:E,onChange:e=>W(e.target.value),placeholder:n("connectors.searchPlaceholder"),className:"w-full pl-10 pr-4 py-2 bg-dark-surface border border-dark-border rounded-lg text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]})}),s.jsxs("div",{className:"flex gap-1 mb-4 flex-wrap",children:[s.jsxs("button",{onClick:()=>B(null),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${g?"bg-dark-surface border border-dark-border hover:bg-dark-hover":"bg-accent-blue text-white"}`,children:[n("connectors.all")," ",s.jsxs("span",{className:"opacity-70 text-xs",children:["(",y.length,")"]})]}),ie.map(e=>{const t=y.filter(a=>a.category===e).length;return s.jsxs("button",{onClick:()=>B(g===e?null:e),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${g===e?"bg-accent-blue text-white":"bg-dark-surface border border-dark-border hover:bg-dark-hover"}`,children:[we[e]??e," ",s.jsxs("span",{className:"opacity-70 text-xs",children:["(",t,")"]})]},e)})]}),_?s.jsx("div",{className:"mb-4 px-3 py-2 bg-accent-red/10 border border-accent-red/30 rounded-lg text-accent-red text-sm",children:_}):null,s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar",children:O.length===0?s.jsxs("div",{className:"text-center text-dark-muted text-sm py-10",children:[s.jsx(I,{size:24,className:"mx-auto mb-2 opacity-50"}),n("connectors.noResults")]}):s.jsx("div",{className:"space-y-2",children:O.map(ue)})})]})}export{Ae as ConnectorsView};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{j as s}from"./markdown-CrVimah5.js";import{a as o,W as J,aN as Ne,j as Te,bg as Pe,ae as Ee,a7 as Le,a3 as de,n as Re,D as fe,f as Fe,ag as De,T as Ae}from"./icons-YJcunJnw.js";import{u as ze,a as Q,t as F,d as pe}from"./index-D1N4vQ9I.js";import"./react-vendor-DM-M1fu_.js";import"./state-D8omNTWe.js";import"./panels-BykQW6E1.js";function he(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function $e(e){if(Array.isArray(e))return e}function Ie(e,t,r){return(t=Ke(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ve(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,i,c,p,y=[],b=!0,O=!1;try{if(c=(r=r.call(e)).next,t!==0)for(;!(b=(n=c.call(r)).done)&&(y.push(n.value),y.length!==t);b=!0);}catch(N){O=!0,i=N}finally{try{if(!b&&r.return!=null&&(p=r.return(),Object(p)!==p))return}finally{if(O)throw i}}return y}}function Ue(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function me(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function ge(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?me(Object(r),!0).forEach(function(n){Ie(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):me(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function qe(e,t){if(e==null)return{};var r,n,i=He(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function He(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function We(e,t){return $e(e)||Ve(e,t)||Qe(e,t)||Ue()}function Be(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ke(e){var t=Be(e,"string");return typeof t=="symbol"?t:t+""}function Qe(e,t){if(e){if(typeof e=="string")return he(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?he(e,t):void 0}}function Ge(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ve(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function be(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ve(Object(r),!0).forEach(function(n){Ge(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ve(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Je(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(n){return t.reduceRight(function(i,c){return c(i)},n)}}function _(e){return function t(){for(var r=this,n=arguments.length,i=new Array(n),c=0;c<n;c++)i[c]=arguments[c];return i.length>=e.length?e.apply(this,i):function(){for(var p=arguments.length,y=new Array(p),b=0;b<p;b++)y[b]=arguments[b];return t.apply(r,[].concat(i,y))}}}function ie(e){return{}.toString.call(e).includes("Object")}function Ye(e){return!Object.keys(e).length}function Z(e){return typeof e=="function"}function _e(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Xe(e,t){return ie(t)||I("changeType"),Object.keys(t).some(function(r){return!_e(e,r)})&&I("changeField"),t}function Ze(e){Z(e)||I("selectorType")}function et(e){Z(e)||ie(e)||I("handlerType"),ie(e)&&Object.values(e).some(function(t){return!Z(t)})&&I("handlersType")}function tt(e){e||I("initialIsRequired"),ie(e)||I("initialType"),Ye(e)&&I("initialContent")}function rt(e,t){throw new Error(e[t]||e.default)}var nt={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},I=_(rt)(nt),ne={changes:Xe,selector:Ze,handler:et,initial:tt};function at(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};ne.initial(e),ne.handler(t);var r={current:e},n=_(st)(r,t),i=_(ot)(r),c=_(ne.changes)(e),p=_(it)(r);function y(){var O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(N){return N};return ne.selector(O),O(r.current)}function b(O){Je(n,i,c,p)(O)}return[y,b]}function it(e,t){return Z(t)?t(e.current):t}function ot(e,t){return e.current=be(be({},e.current),t),t}function st(e,t,r){return Z(t)?t(e.current):Object.keys(r).forEach(function(n){var i;return(i=t[n])===null||i===void 0?void 0:i.call(t,e.current[n])}),r}var ct={create:at},lt={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function ut(e){return function t(){for(var r=this,n=arguments.length,i=new Array(n),c=0;c<n;c++)i[c]=arguments[c];return i.length>=e.length?e.apply(this,i):function(){for(var p=arguments.length,y=new Array(p),b=0;b<p;b++)y[b]=arguments[b];return t.apply(r,[].concat(i,y))}}}function dt(e){return{}.toString.call(e).includes("Object")}function ft(e){return e||ye("configIsRequired"),dt(e)||ye("configType"),e.urls?(pt(),{paths:{vs:e.urls.monacoBase}}):e}function pt(){console.warn(xe.deprecation)}function ht(e,t){throw new Error(e[t]||e.default)}var xe={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
3
|
+
You are using deprecated way of configuration.
|
|
4
|
+
|
|
5
|
+
Instead of using
|
|
6
|
+
monaco.config({ urls: { monacoBase: '...' } })
|
|
7
|
+
use
|
|
8
|
+
monaco.config({ paths: { vs: '...' } })
|
|
9
|
+
|
|
10
|
+
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
11
|
+
`},ye=ut(ht)(xe),mt={config:ft},gt=function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return function(i){return r.reduceRight(function(c,p){return p(c)},i)}};function we(e,t){return Object.keys(t).forEach(function(r){t[r]instanceof Object&&e[r]&&Object.assign(t[r],we(e[r],t[r]))}),ge(ge({},e),t)}var vt={type:"cancelation",msg:"operation is manually canceled"};function ce(e){var t=!1,r=new Promise(function(n,i){e.then(function(c){return t?i(vt):n(c)}),e.catch(i)});return r.cancel=function(){return t=!0},r}var bt=["monaco"],yt=ct.create({config:lt,isInitialized:!1,resolve:null,reject:null,monaco:null}),je=We(yt,2),ee=je[0],oe=je[1];function xt(e){var t=mt.config(e),r=t.monaco,n=qe(t,bt);oe(function(i){return{config:we(i.config,n),monaco:r}})}function wt(){var e=ee(function(t){var r=t.monaco,n=t.isInitialized,i=t.resolve;return{monaco:r,isInitialized:n,resolve:i}});if(!e.isInitialized){if(oe({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),ce(le);if(window.monaco&&window.monaco.editor)return Oe(window.monaco),e.resolve(window.monaco),ce(le);gt(jt,St)(Ct)}return ce(le)}function jt(e){return document.body.appendChild(e)}function Ot(e){var t=document.createElement("script");return e&&(t.src=e),t}function St(e){var t=ee(function(n){var i=n.config,c=n.reject;return{config:i,reject:c}}),r=Ot("".concat(t.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=t.reject,r}function Ct(){var e=ee(function(r){var n=r.config,i=r.resolve,c=r.reject;return{config:n,resolve:i,reject:c}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(r){var n=r.m||r;Oe(n),e.resolve(n)},function(r){e.reject(r)})}function Oe(e){ee().monaco||oe({monaco:e})}function Mt(){return ee(function(e){var t=e.monaco;return t})}var le=new Promise(function(e,t){return oe({resolve:e,reject:t})}),Se={config:xt,init:wt,__getMonacoInstance:Mt},kt={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},ue=kt,Nt={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Tt=Nt;function Pt({children:e}){return J.createElement("div",{style:Tt.container},e)}var Et=Pt,Lt=Et;function Rt({width:e,height:t,isEditorReady:r,loading:n,_ref:i,className:c,wrapperProps:p}){return J.createElement("section",{style:{...ue.wrapper,width:e,height:t},...p},!r&&J.createElement(Lt,null,n),J.createElement("div",{ref:i,style:{...ue.fullWidth,...!r&&ue.hide},className:c}))}var Ft=Rt,Ce=o.memo(Ft);function Dt(e){o.useEffect(e,[])}var Me=Dt;function At(e,t,r=!0){let n=o.useRef(!0);o.useEffect(n.current||!r?()=>{n.current=!1}:e,t)}var k=At;function X(){}function G(e,t,r,n){return zt(e,n)||$t(e,t,r,n)}function zt(e,t){return e.editor.getModel(ke(e,t))}function $t(e,t,r,n){return e.editor.createModel(t,r,n?ke(e,n):void 0)}function ke(e,t){return e.Uri.parse(t)}function It({original:e,modified:t,language:r,originalLanguage:n,modifiedLanguage:i,originalModelPath:c,modifiedModelPath:p,keepCurrentOriginalModel:y=!1,keepCurrentModifiedModel:b=!1,theme:O="light",loading:N="Loading...",options:M={},height:Y="100%",width:U="100%",className:q,wrapperProps:H={},beforeMount:W=X,onMount:B=X}){let[S,T]=o.useState(!1),[L,w]=o.useState(!0),j=o.useRef(null),x=o.useRef(null),D=o.useRef(null),C=o.useRef(B),h=o.useRef(W),R=o.useRef(!1);Me(()=>{let d=Se.init();return d.then(m=>(x.current=m)&&w(!1)).catch(m=>(m==null?void 0:m.type)!=="cancelation"&&console.error("Monaco initialization: error:",m)),()=>j.current?A():d.cancel()}),k(()=>{if(j.current&&x.current){let d=j.current.getOriginalEditor(),m=G(x.current,e||"",n||r||"text",c||"");m!==d.getModel()&&d.setModel(m)}},[c],S),k(()=>{if(j.current&&x.current){let d=j.current.getModifiedEditor(),m=G(x.current,t||"",i||r||"text",p||"");m!==d.getModel()&&d.setModel(m)}},[p],S),k(()=>{let d=j.current.getModifiedEditor();d.getOption(x.current.editor.EditorOption.readOnly)?d.setValue(t||""):t!==d.getValue()&&(d.executeEdits("",[{range:d.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),d.pushUndoStop())},[t],S),k(()=>{var d,m;(m=(d=j.current)==null?void 0:d.getModel())==null||m.original.setValue(e||"")},[e],S),k(()=>{let{original:d,modified:m}=j.current.getModel();x.current.editor.setModelLanguage(d,n||r||"text"),x.current.editor.setModelLanguage(m,i||r||"text")},[r,n,i],S),k(()=>{var d;(d=x.current)==null||d.editor.setTheme(O)},[O],S),k(()=>{var d;(d=j.current)==null||d.updateOptions(M)},[M],S);let V=o.useCallback(()=>{var E;if(!x.current)return;h.current(x.current);let d=G(x.current,e||"",n||r||"text",c||""),m=G(x.current,t||"",i||r||"text",p||"");(E=j.current)==null||E.setModel({original:d,modified:m})},[r,t,i,e,n,c,p]),K=o.useCallback(()=>{var d;!R.current&&D.current&&(j.current=x.current.editor.createDiffEditor(D.current,{automaticLayout:!0,...M}),V(),(d=x.current)==null||d.editor.setTheme(O),T(!0),R.current=!0)},[M,O,V]);o.useEffect(()=>{S&&C.current(j.current,x.current)},[S]),o.useEffect(()=>{!L&&!S&&K()},[L,S,K]);function A(){var m,E,P,z;let d=(m=j.current)==null?void 0:m.getModel();y||((E=d==null?void 0:d.original)==null||E.dispose()),b||((P=d==null?void 0:d.modified)==null||P.dispose()),(z=j.current)==null||z.dispose()}return J.createElement(Ce,{width:U,height:Y,isEditorReady:S,loading:N,_ref:D,className:q,wrapperProps:H})}var Vt=It;o.memo(Vt);function Ut(e){let t=o.useRef();return o.useEffect(()=>{t.current=e},[e]),t.current}var qt=Ut,ae=new Map;function Ht({defaultValue:e,defaultLanguage:t,defaultPath:r,value:n,language:i,path:c,theme:p="light",line:y,loading:b="Loading...",options:O={},overrideServices:N={},saveViewState:M=!0,keepCurrentModel:Y=!1,width:U="100%",height:q="100%",className:H,wrapperProps:W={},beforeMount:B=X,onMount:S=X,onChange:T,onValidate:L=X}){let[w,j]=o.useState(!1),[x,D]=o.useState(!0),C=o.useRef(null),h=o.useRef(null),R=o.useRef(null),V=o.useRef(S),K=o.useRef(B),A=o.useRef(),d=o.useRef(n),m=qt(c),E=o.useRef(!1),P=o.useRef(!1);Me(()=>{let f=Se.init();return f.then(g=>(C.current=g)&&D(!1)).catch(g=>(g==null?void 0:g.type)!=="cancelation"&&console.error("Monaco initialization: error:",g)),()=>h.current?se():f.cancel()}),k(()=>{var g,a,l,u;let f=G(C.current,e||n||"",t||i||"",c||r||"");f!==((g=h.current)==null?void 0:g.getModel())&&(M&&ae.set(m,(a=h.current)==null?void 0:a.saveViewState()),(l=h.current)==null||l.setModel(f),M&&((u=h.current)==null||u.restoreViewState(ae.get(c))))},[c],w),k(()=>{var f;(f=h.current)==null||f.updateOptions(O)},[O],w),k(()=>{!h.current||n===void 0||(h.current.getOption(C.current.editor.EditorOption.readOnly)?h.current.setValue(n):n!==h.current.getValue()&&(P.current=!0,h.current.executeEdits("",[{range:h.current.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),h.current.pushUndoStop(),P.current=!1))},[n],w),k(()=>{var g,a;let f=(g=h.current)==null?void 0:g.getModel();f&&i&&((a=C.current)==null||a.editor.setModelLanguage(f,i))},[i],w),k(()=>{var f;y!==void 0&&((f=h.current)==null||f.revealLine(y))},[y],w),k(()=>{var f;(f=C.current)==null||f.editor.setTheme(p)},[p],w);let z=o.useCallback(()=>{var f;if(!(!R.current||!C.current)&&!E.current){K.current(C.current);let g=c||r,a=G(C.current,n||e||"",t||i||"",g||"");h.current=(f=C.current)==null?void 0:f.editor.create(R.current,{model:a,automaticLayout:!0,...O},N),M&&h.current.restoreViewState(ae.get(g)),C.current.editor.setTheme(p),y!==void 0&&h.current.revealLine(y),j(!0),E.current=!0}},[e,t,r,n,i,c,O,N,M,p,y]);o.useEffect(()=>{w&&V.current(h.current,C.current)},[w]),o.useEffect(()=>{!x&&!w&&z()},[x,w,z]),d.current=n,o.useEffect(()=>{var f,g;w&&T&&((f=A.current)==null||f.dispose(),A.current=(g=h.current)==null?void 0:g.onDidChangeModelContent(a=>{P.current||T(h.current.getValue(),a)}))},[w,T]),o.useEffect(()=>{if(w){let f=C.current.editor.onDidChangeMarkers(g=>{var l;let a=(l=h.current.getModel())==null?void 0:l.uri;if(a&&g.find(u=>u.path===a.path)){let u=C.current.editor.getModelMarkers({resource:a});L==null||L(u)}});return()=>{f==null||f.dispose()}}return()=>{}},[w,L]);function se(){var f,g;(f=A.current)==null||f.dispose(),Y?M&&ae.set(c,h.current.saveViewState()):(g=h.current.getModel())==null||g.dispose(),h.current.dispose()}return J.createElement(Ce,{width:U,height:q,isEditorReady:w,loading:b,_ref:R,className:H,wrapperProps:W})}var Wt=Ht,Bt=o.memo(Wt),Kt=Bt;function Qt(e){var n;const t=(n=e.split(".").pop())==null?void 0:n.toLowerCase();return{ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",py:"python",rs:"rust",go:"go",rb:"ruby",json:"json",xml:"xml",html:"html",css:"css",scss:"scss",md:"markdown",yaml:"yaml",yml:"yaml",toml:"toml",sql:"sql",sh:"shell",bat:"bat",ps1:"powershell",dockerfile:"dockerfile",properties:"properties",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",vue:"html",svelte:"html",svg:"xml"}[t||""]||"plaintext"}function er(){const{t:e}=ze(),[t,r]=o.useState([]),[n,i]=o.useState(null),[c,p]=o.useState(""),[y,b]=o.useState(""),[O,N]=o.useState(!1),[M,Y]=o.useState(""),[U,q]=o.useState(!1),[H,W]=o.useState(!1),[B,S]=o.useState(!1),[T,L]=o.useState(""),w=o.useRef(null);o.useEffect(()=>{if(!n){p(""),b("");return}N(!0),Q.files.read(n).then(a=>{if(a.success&&a.data){const l=typeof a.data=="string"?a.data:JSON.stringify(a.data);p(l),b(l)}else F.error(a.error||e("fileTree.readFail"))}).catch(()=>F.error(e("fileTree.readFail"))).finally(()=>N(!1))},[n]);const j=async a=>{q(!0);try{const l=await Q.files.list(a);l.success&&Array.isArray(l.data)&&r(l.data.map(u=>({...u,expanded:!1})))}finally{q(!1)}},x=async a=>{if(a.type==="directory")try{const l=await Q.files.list(a.path);if(l.success&&Array.isArray(l.data)){const u=l.data.map(v=>({...v,expanded:!1}));r(v=>D(v,a.id,u))}}catch{}},D=(a,l,u)=>a.map(v=>v.id===l?{...v,children:u,expanded:!0}:v.children?{...v,children:D(v.children,l,u)}:v);o.useEffect(()=>{j()},[]);const C=a=>{const l=R(t,a);if(l&&l.type==="directory"&&!l.children){x(l);return}r(u=>h(u,a))},h=(a,l)=>a.map(u=>u.id===l&&u.type==="directory"?{...u,expanded:!u.expanded}:u.children?{...u,children:h(u.children,l)}:u),R=(a,l)=>{for(const u of a){if(u.id===l)return u;if(u.children){const v=R(u.children,l);if(v)return v}}return null},V=(a,l)=>l?a.reduce((u,v)=>{if(v.name.toLowerCase().includes(l.toLowerCase()))u.push(v);else if(v.children){const $=V(v.children,l);$.length>0&&u.push({...v,children:$,expanded:!0})}return u},[]):a,K=o.useCallback(async()=>{if(n){W(!0);try{const a=await Q.files.update(n,c);a.success?(b(c),F.success(e("fileTree.saved"))):F.error(a.error||e("fileTree.saveFail"))}catch{F.error(e("fileTree.saveFail"))}finally{W(!1)}}},[n,c,e]),A=()=>{i(null),p(""),b("")},d=o.useCallback(async a=>{const l=await Q.files.download(a);l.success?F.success(e("fileTree.downloadStarted")):F.error(l.error||e("fileTree.downloadFail"))},[e]),m=()=>{var a;return(a=w.current)==null?void 0:a.click()},E=o.useCallback(async a=>{if(!a||a.length===0)return;const l=T||(n?n.replace(/[\\/][^\\/]+$/,""):"");S(!0);let u=0,v=0;for(const $ of Array.from(a)){const te=l?`${l}/${$.name}`:$.name;(await Q.files.upload($,te)).success?u++:v++}S(!1),u>0&&F.success(e("fileTree.uploadedCount",{count:u})),v>0&&F.error(e("fileTree.uploadFailedCount",{count:v})),await j()},[T,n,e]),P=c!==y,z=()=>P?typeof window>"u"||typeof window.confirm!="function"?!1:window.confirm(e("fileTree.discardConfirm",{file:n||""})):!0,se=()=>{z()&&A()},f=(a,l=0)=>{var te;const u=a.type==="directory",v=n===a.path,$=T===a.path;return s.jsxs("div",{children:[s.jsxs("div",{className:`group flex items-center gap-1 px-2 py-0.5 cursor-pointer rounded text-xs transition-colors ${v?"bg-accent-blue/20 text-accent-blue":$?"bg-accent-blue/10":"hover:bg-dark-hover"}`,style:{paddingLeft:`${l*14+6}px`},onClick:()=>u?(L(a.path),C(a.id)):i(a.path),title:u?e("fileTree.setUploadDirHint"):a.path,children:[u&&s.jsx("span",{className:"text-dark-muted shrink-0",children:a.expanded?s.jsx(Fe,{size:12}):s.jsx(De,{size:12})}),u?s.jsx(Ae,{size:12,className:"text-accent-yellow shrink-0"}):s.jsx("span",{className:"w-3"}),s.jsx("span",{className:"truncate flex-1",children:a.name}),!u&&s.jsx("button",{onClick:re=>{re.stopPropagation(),d(a.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 rounded hover:bg-dark-border text-dark-muted hover:text-dark-text shrink-0",title:e("fileTree.download"),children:s.jsx(fe,{size:11})})]}),u&&a.expanded&&((te=a.children)==null?void 0:te.map(re=>f(re,l+1)))]},a.id)},g=M?V(t,M):t;return s.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[s.jsxs("div",{className:pe("flex flex-col overflow-hidden flex-1 min-h-0",n&&"hidden"),children:[s.jsx("div",{className:"flex items-center justify-between px-3 py-2 border-b border-dark-border",children:s.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[s.jsx("button",{onClick:m,disabled:B,className:"p-1 rounded hover:bg-dark-hover disabled:opacity-50",title:T?e("fileTree.uploadTo",{dir:T}):e("fileTree.uploadToRoot"),children:s.jsx(Ne,{size:12,className:B?"animate-pulse":""})}),s.jsx("button",{onClick:()=>j(),disabled:U,className:"p-1 rounded hover:bg-dark-hover",title:e("fileTree.refresh"),children:s.jsx(Te,{size:12,className:U?"animate-spin":""})}),s.jsx("button",{onClick:()=>{z()&&(r(t.map(a=>({...a,expanded:!1}))),A())},className:"p-1 rounded hover:bg-dark-hover",title:e("fileTree.collapse"),children:s.jsx(Pe,{size:12})})]})}),s.jsx("div",{className:"p-1.5 border-b border-dark-border",children:s.jsxs("div",{className:"relative",children:[s.jsx(Ee,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-dark-muted"}),s.jsx("input",{type:"text",value:M,onChange:a=>Y(a.target.value),placeholder:e("fileTree.searchPlaceholder"),className:"w-full pl-6 pr-2 py-1 text-xs bg-dark-bg border border-dark-border rounded focus:border-accent-blue focus:outline-none"})]})}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar py-1",children:g.map(a=>f(a))}),s.jsx("input",{ref:w,type:"file",multiple:!0,className:"hidden",onChange:a=>{E(a.target.files),a.currentTarget.value=""}})]}),s.jsx("div",{className:pe("flex-1 flex flex-col min-w-0 bg-dark-bg",!n&&"hidden"),children:n?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-dark-border bg-dark-surface",children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[s.jsx("button",{onClick:se,className:"p-0.5 -ml-1 rounded hover:bg-dark-hover text-dark-muted hover:text-dark-text shrink-0",title:e("fileTree.backToList"),"aria-label":e("fileTree.backToList"),"data-testid":"file-tree-back",children:s.jsx(Le,{size:13})}),s.jsx(de,{size:12,className:"text-dark-muted shrink-0"}),s.jsx("span",{className:"truncate",children:n}),P&&s.jsxs("span",{className:"text-accent-yellow text-[10px] shrink-0",children:["● ",e("fileTree.modified")]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{onClick:K,disabled:!P||H,className:`px-2 py-0.5 text-[10px] rounded flex items-center gap-1 transition-colors ${P?"bg-accent-green text-white hover:opacity-90":"bg-dark-border text-dark-muted cursor-not-allowed"}`,children:[s.jsx(Re,{size:10}),e(H?"fileTree.saving":"fileTree.save")]}),s.jsx("button",{onClick:()=>void d(n),className:"p-1 rounded hover:bg-dark-hover",title:e("fileTree.download"),children:s.jsx(fe,{size:12})})]})]}),s.jsx("div",{className:"flex-1 min-h-0",children:O?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx("div",{className:"w-4 h-4 border-2 border-accent-blue border-t-transparent rounded-full animate-spin"})}):s.jsx(Kt,{language:Qt(n),value:c,onChange:a=>p(a||""),theme:"vs-dark",options:{fontSize:13,fontFamily:'"Cascadia Code", "Fira Code", Consolas, monospace',minimap:{enabled:!0,renderCharacters:!1,maxColumn:80,showSlider:"mouseover"},lineNumbers:"on",scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0,tabSize:2}})})]}):s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsxs("div",{className:"text-center",children:[s.jsx(de,{size:32,className:"text-dark-muted mx-auto mb-2"}),s.jsx("p",{className:"text-sm text-dark-muted",children:e("fileTree.selectFileHint")})]})})})]})}export{er as FileTreeView};
|