Files
LangBot/web/.next/static/chunks/34896350a762285f.js
T

1 line
83 KiB
JavaScript

(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,68981,e=>{e.v({marketComponentBody:"plugins-module__lGF0uq__marketComponentBody",pageContainer:"plugins-module__lGF0uq__pageContainer",pluginListContainer:"plugins-module__lGF0uq__pluginListContainer"})},35948,e=>{"use strict";var t,s,a,l,r=e.i(60498),n=e.i(49311);class i{author;label;name;description;version;enabled;priority;debug;install_source;install_info;status;components;hasUpdate;constructor(e){this.author=e.author,this.label=e.label,this.description=e.description,this.enabled=e.enabled,this.components=e.components,this.name=e.name,this.priority=e.priority,this.status=e.status,this.version=e.version,this.debug=e.debug,this.install_source=e.install_source,this.install_info=e.install_info,this.hasUpdate=e.hasUpdate}}var o=e.i(78083);e.i(26128);var c=e.i(91830),d=e.i(83227);let m=(0,d.default)("bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);var u=e.i(56604),x=e.i(965),x=x;let p=(0,d.default)("trash",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]]),h=(0,d.default)("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);var g=e.i(79154),f=e.i(90210),v=e.i(15742);e.i(56907);var j=e.i(20317),y=e.i(74035),b=e.i(32100),w=e.i(78059);function N({cardVO:e,onCardClick:t,onDeleteClick:s,onUpgradeClick:a,onViewReadme:l}){let{t:i}=(0,c.useTranslation)(),[d,N]=(0,n.useState)(!1),[C,k]=(0,n.useState)(!1);return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"w-[100%] h-[10rem] bg-white rounded-[10px] shadow-[0px_2px_2px_0_rgba(0,0,0,0.2)] p-[1.2rem] cursor-pointer dark:bg-[#1f1f22] relative transition-all duration-200 hover:shadow-[0px_3px_6px_0_rgba(0,0,0,0.12)] hover:scale-[1.005]",onMouseEnter:()=>k(!0),onMouseLeave:()=>{d||k(!1)},children:[(0,r.jsxs)("div",{className:"w-full h-full flex flex-row items-start justify-start gap-[1.2rem]",children:[(0,r.jsx)("img",{src:j.httpClient.getPluginIconURL(e.author,e.name),alt:"plugin icon",className:"w-16 h-16 rounded-[8%] flex-shrink-0"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0 h-full flex flex-col items-start justify-between gap-[0.6rem]",children:[(0,r.jsxs)("div",{className:"flex flex-col items-start justify-start w-full min-w-0 flex-1 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex flex-col items-start justify-start w-full min-w-0",children:[(0,r.jsxs)("div",{className:"text-[0.7rem] text-[#666] dark:text-[#999] truncate w-full",children:[e.author," / ",e.name]}),(0,r.jsxs)("div",{className:"flex flex-row items-center justify-start gap-[0.4rem] flex-wrap max-w-full",children:[(0,r.jsx)("div",{className:"text-[1.2rem] text-black dark:text-[#f0f0f0] truncate max-w-[10rem]",children:e.label}),(0,r.jsxs)(o.Badge,{variant:"outline",className:"text-[0.7rem] flex-shrink-0",children:["v",e.version]}),e.debug&&(0,r.jsxs)(o.Badge,{variant:"outline",className:"text-[0.7rem] border-orange-400 text-orange-400 flex-shrink-0",children:[(0,r.jsx)(m,{className:"w-4 h-4"}),i("plugins.debugging")]}),!e.debug&&(0,r.jsxs)(r.Fragment,{children:["github"===e.install_source&&(0,r.jsx)(o.Badge,{variant:"outline",className:"text-[0.7rem] border-blue-400 text-blue-400 flex-shrink-0",children:i("plugins.fromGithub")}),"local"===e.install_source&&(0,r.jsx)(o.Badge,{variant:"outline",className:"text-[0.7rem] border-green-400 text-green-400 flex-shrink-0",children:i("plugins.fromLocal")}),"marketplace"===e.install_source&&(0,r.jsx)(o.Badge,{variant:"outline",className:"text-[0.7rem] border-purple-400 text-purple-400 flex-shrink-0",children:i("plugins.fromMarketplace")})]})]})]}),(0,r.jsx)("div",{className:"text-[0.8rem] text-[#666] line-clamp-2 dark:text-[#999] w-full",children:e.description})]}),(0,r.jsx)("div",{className:"w-full flex flex-row items-start justify-start gap-[0.6rem] flex-shrink-0 min-h-[1.5rem]",children:(0,r.jsx)(w.default,{components:(()=>{let t={};for(let s of e.components){let e=s.manifest.manifest.kind;t[e]?t[e]++:t[e]=1}return t})(),showComponentName:!1,showTitle:!0,useBadge:!1,t:i})})]}),(0,r.jsxs)("div",{className:"flex flex-col items-center justify-between h-full relative z-20 flex-shrink-0",children:[(0,r.jsx)("div",{className:"flex items-center justify-center"}),(0,r.jsx)("div",{className:"flex items-center justify-center",children:(0,r.jsxs)(b.DropdownMenu,{open:d,onOpenChange:e=>{N(e),e||k(!1)},children:[(0,r.jsx)(b.DropdownMenuTrigger,{asChild:!0,children:(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(y.Button,{variant:"ghost",className:"bg-white dark:bg-[#1f1f22] hover:bg-gray-100 dark:hover:bg-[#2a2a2d]",children:(0,r.jsx)(x.default,{className:"w-4 h-4"})}),e.hasUpdate&&(0,r.jsx)("div",{className:"absolute -top-0.5 -right-0.5 w-2.5 h-2.5 bg-red-500 rounded-full border-2 border-white dark:border-[#1f1f22]"})]})}),(0,r.jsxs)(b.DropdownMenuContent,{children:["marketplace"===e.install_source&&(0,r.jsxs)(b.DropdownMenuItem,{className:"flex flex-row items-center justify-start gap-[0.4rem] cursor-pointer",onClick:t=>{t.stopPropagation(),a(e),N(!1)},children:[(0,r.jsx)(h,{className:"w-4 h-4"}),(0,r.jsx)("span",{children:i("plugins.update")}),e.hasUpdate&&(0,r.jsx)(o.Badge,{className:"ml-auto bg-red-500 hover:bg-red-500 text-white text-[0.6rem] px-1.5 py-0 h-4",children:i("plugins.new")})]}),("github"===e.install_source||"marketplace"===e.install_source)&&(0,r.jsxs)(b.DropdownMenuItem,{className:"flex flex-row items-center justify-start gap-[0.4rem] cursor-pointer",onClick:t=>{t.stopPropagation(),"github"===e.install_source?window.open(e.install_info.github_url,"_blank"):"marketplace"===e.install_source&&window.open((0,v.getCloudServiceClientSync)().getPluginMarketplaceURL(v.systemInfo.cloud_service_url,e.author,e.name),"_blank"),N(!1)},children:[(0,r.jsx)(u.ExternalLink,{className:"w-4 h-4"}),(0,r.jsx)("span",{children:i("plugins.viewSource")})]}),(0,r.jsxs)(b.DropdownMenuItem,{className:"flex flex-row items-center justify-start gap-[0.4rem] cursor-pointer text-red-600 focus:text-red-600",onClick:t=>{t.stopPropagation(),s(e),N(!1)},children:[(0,r.jsx)(p,{className:"w-4 h-4"}),(0,r.jsx)("span",{children:i("plugins.delete")})]})]})]})})]})]}),(0,r.jsxs)("div",{className:`absolute inset-0 bg-gray-100/55 dark:bg-black/35 rounded-[10px] flex items-center justify-center gap-3 transition-all duration-200 z-10 ${C?"opacity-100":"opacity-0 pointer-events-none"}`,children:[(0,r.jsxs)(y.Button,{onClick:t=>{t.stopPropagation(),l(e)},className:`bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg shadow-sm flex items-center gap-2 transition-all duration-200 ${C?"translate-y-0 opacity-100":"translate-y-1 opacity-0"}`,style:{transitionDelay:C?"10ms":"0ms"},children:[(0,r.jsx)(f.FileText,{className:"w-4 h-4"}),i("plugins.readme")]}),(0,r.jsxs)(y.Button,{onClick:e=>{e.stopPropagation(),t()},variant:"outline",className:`bg-white hover:bg-gray-100 text-gray-900 dark:bg-white dark:hover:bg-gray-100 dark:text-gray-900 px-4 py-2 rounded-lg shadow-sm flex items-center gap-2 transition-all duration-200 ${C?"translate-y-0 opacity-100":"translate-y-1 opacity-0"}`,style:{transitionDelay:C?"20ms":"0ms"},children:[(0,r.jsx)(g.Settings,{className:"w-4 h-4"}),i("plugins.config")]})]})]})})}var C=e.i(71654),k=e.i(50098),_=e.i(11607);function S({pluginAuthor:e,pluginName:t,onFormSubmit:s,onFormCancel:a}){let{t:l}=(0,c.useTranslation)(),[i,o]=(0,n.useState)(),[d,m]=(0,n.useState)(),[u,x]=(0,n.useState)(!1),p=(0,n.useRef)({}),h=(0,n.useRef)(new Set),g=(0,n.useRef)(new Set);(0,n.useEffect)(()=>{j.httpClient.getPlugin(e,t).then(e=>{o(e.plugin)}),j.httpClient.getPluginConfig(e,t).then(e=>{m(e);let t=e=>{let s=[];if(e&&"object"==typeof e)for(let a of("file_key"in e&&"string"==typeof e.file_key&&s.push(e.file_key),Object.values(e)))Array.isArray(a)?a.forEach(e=>s.push(...t(e))):"object"==typeof a&&null!==a&&s.push(...t(a));return s};g.current=new Set(t(e.config))})},[e,t]);let f=async()=>{x(!0);try{await j.httpClient.updatePluginConfig(e,t,p.current);let a=e=>{let t=[];if(e&&"object"==typeof e)for(let s of("file_key"in e&&"string"==typeof e.file_key&&t.push(e.file_key),Object.values(e)))Array.isArray(s)?s.forEach(e=>t.push(...a(e))):"object"==typeof s&&null!==s&&t.push(...a(s));return t},r=new Set(a(p.current)),n=[];h.current.forEach(e=>{r.has(e)||n.push(e)}),g.current.forEach(e=>{r.has(e)||n.push(e)});let i=n.map(e=>j.httpClient.deletePluginConfigFile(e).catch(t=>{console.warn(`Failed to delete file ${e}:`,t)}));await Promise.all(i),k.toast.success(l("plugins.saveConfigSuccessNormal")),s(1e3)}catch(e){k.toast.error(l("plugins.saveConfigError")+e.message)}finally{x(!1)}};return i&&d?(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"text-lg font-medium",children:(0,_.extractI18nObject)(i.manifest.manifest.metadata.label)}),(0,r.jsx)("div",{className:"text-sm text-gray-500 pb-2",children:(0,_.extractI18nObject)(i.manifest.manifest.metadata.description??{en_US:"",zh_Hans:""})}),(0,r.jsx)("div",{className:"mb-4 flex flex-row items-center justify-start gap-[0.4rem]",children:(0,r.jsx)(w.default,{components:(()=>{let e={};for(let t of i.components){let s=t.manifest.manifest.kind;e[s]?e[s]++:e[s]=1}return e})(),showComponentName:!0,showTitle:!1,useBadge:!0,t:l})}),i.manifest.manifest.spec.config.length>0&&(0,r.jsx)(C.default,{itemConfigList:i.manifest.manifest.spec.config,initialValues:d.config,onSubmit:e=>{p.current=e},onFileUploaded:e=>{h.current.add(e)}}),0===i.manifest.manifest.spec.config.length&&(0,r.jsx)("div",{className:"text-sm text-gray-500",children:l("plugins.pluginNoConfig")})]}),(0,r.jsx)("div",{className:"sticky bottom-0 left-0 right-0 bg-background border-t p-4 mt-4",children:(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(y.Button,{type:"submit",onClick:()=>f(),disabled:u,children:u?l("plugins.saving"):l("plugins.saveConfig")}),(0,r.jsx)(y.Button,{type:"button",variant:"outline",onClick:a,children:l("plugins.cancel")})]})})]}):(0,r.jsx)("div",{className:"flex items-center justify-center h-full mb-[2rem]",children:l("plugins.loading")})}var E=e.i(93245),L=e.i(49230),T=e.i(37328),I=e.i(45880),D=e.i(28783),M=e.i(63946);function R({pluginAuthor:e,pluginName:t}){let{t:s}=(0,c.useTranslation)(),[a,l]=(0,n.useState)(""),[i,o]=(0,n.useState)(!1),d=(0,_.getAPILanguageCode)();return(0,n.useEffect)(()=>{o(!0),j.httpClient.getPluginReadme(e,t,d).then(e=>{l(e.readme)}).catch(()=>{l("")}).finally(()=>{o(!1)})},[e,t]),(0,r.jsx)("div",{className:"w-full h-full overflow-auto",children:i?(0,r.jsx)("div",{className:"p-6 text-sm text-gray-500 dark:text-gray-400",children:s("plugins.loadingReadme")}):a?(0,r.jsx)("div",{className:"markdown-body p-6 max-w-none pt-0",children:(0,r.jsx)(E.default,{remarkPlugins:[L.default],rehypePlugins:[T.default,I.default,D.default,[M.default,{behavior:"wrap",properties:{className:["anchor"]}}]],components:{ul:({children:e})=>(0,r.jsx)("ul",{className:"list-disc",children:e}),ol:({children:e})=>(0,r.jsx)("ol",{className:"list-decimal",children:e}),li:({children:e})=>(0,r.jsx)("li",{className:"ml-4",children:e}),img:({src:s,alt:a,...l})=>{let n=s||"";if("string"!=typeof n)return(0,r.jsx)("img",{src:s,alt:a||"",className:"max-w-full h-auto rounded-lg my-4",...l});if(n&&!n.startsWith("http://")&&!n.startsWith("https://")&&!n.startsWith("data:")){(n=n.replace(/^(\.\/|\/)+/,"")).startsWith("assets/")||(n=`assets/${n}`);let s=n.replace(/^assets\//,"");n=j.httpClient.getPluginAssetURL(e,t,s)}return(0,r.jsx)("img",{src:n,alt:a||"",className:"max-w-lg h-auto my-4",...l})}},children:a})}):(0,r.jsx)("div",{className:"p-6 text-sm text-gray-500 dark:text-gray-400",children:s("plugins.noReadme")})})}var F=e.i(68981),P=e.i(88274),B=e.i(74110),V=((t={}).WAIT_INPUT="WAIT_INPUT",t.RUNNING="RUNNING",t.SUCCESS="SUCCESS",t.ERROR="ERROR",t),z=((s=z||{}).DELETE="DELETE",s.UPDATE="UPDATE",s);let O=(0,n.forwardRef)((e,t)=>{let{t:s}=(0,c.useTranslation)(),[a,l]=(0,n.useState)([]),[o,d]=(0,n.useState)(!1),[m,u]=(0,n.useState)(null),[x,p]=(0,n.useState)(!1),[h,g]=(0,n.useState)(null),[f,b]=(0,n.useState)(!1),[w,C]=(0,n.useState)("DELETE"),[E,L]=(0,n.useState)(null),[T,I]=(0,n.useState)(!1),D=function(e={}){let{onSuccess:t,onError:s,pollInterval:a=1e3}=e,[l,r]=(0,n.useState)("WAIT_INPUT"),[i,o]=(0,n.useState)(null),c=(0,n.useRef)(null),d=(0,n.useRef)(!1),m=()=>{c.current&&(clearInterval(c.current),c.current=null)};return(0,n.useEffect)(()=>()=>{m()},[]),{status:l,error:i,startTask:e=>{r("RUNNING"),o(null),d.current=!1,c.current=setInterval(()=>{j.httpClient.getAsyncTask(e).then(e=>{e.runtime.done&&(m(),e.runtime.exception?(o(e.runtime.exception),r("ERROR"),s?.(e.runtime.exception)):d.current||(d.current=!0,r("SUCCESS"),t?.()))}).catch(e=>{m();let t=e.message||"Unknown error";o(t),r("ERROR"),s?.(t)})},a)},reset:()=>{m(),r("WAIT_INPUT"),o(null),d.current=!1}}}({onSuccess:()=>{let e="DELETE"===w?s("plugins.deleteSuccess"):s("plugins.updateSuccess");k.toast.success(e),b(!1),M()},onError:()=>{}});async function M(){try{let e=(await j.httpClient.getPlugins()).plugins,t=(0,v.getCloudServiceClientSync)(),s=(await t.getMarketplacePlugins(1,100)).plugins,a=new Map;s.forEach(e=>{let t=`${e.author}/${e.name}`;a.set(t,e)});let r=e.map(e=>{let t=new i({author:e.manifest.manifest.metadata.author??"",label:(0,_.extractI18nObject)(e.manifest.manifest.metadata.label),description:(0,_.extractI18nObject)(e.manifest.manifest.metadata.description??{en_US:"",zh_Hans:""}),debug:e.debug,enabled:e.enabled,name:e.manifest.manifest.metadata.name,version:e.manifest.manifest.metadata.version??"",status:e.status,components:e.components,priority:e.priority,install_source:e.install_source,install_info:e.install_info});if("marketplace"===t.install_source){let e=`${t.author}/${t.name}`,s=a.get(e);s&&s.latest_version&&(t.hasUpdate=function(e,t){if(!e||!t)return!1;let s=e.replace(/^v/,""),a=t.replace(/^v/,""),[l,r]=s.split("-"),[n,i]=a.split("-"),o=l.split(".").map(e=>parseInt(e,10)||0),c=n.split(".").map(e=>parseInt(e,10)||0),d=Math.max(o.length,c.length);for(;o.length<d;)o.push(0);for(;c.length<d;)c.push(0);for(let e=0;e<d;e++){if(o[e]>c[e])return!0;if(o[e]<c[e])return!1}return!r&&!!i||(!r||!!i)&&(!!r||!!i)&&r>i}(s.latest_version,t.version))}return t});l(r)}catch(e){console.error("获取插件列表失败:",e),l((await j.httpClient.getPlugins()).plugins.map(e=>new i({author:e.manifest.manifest.metadata.author??"",label:(0,_.extractI18nObject)(e.manifest.manifest.metadata.label),description:(0,_.extractI18nObject)(e.manifest.manifest.metadata.description??{en_US:"",zh_Hans:""}),debug:e.debug,enabled:e.enabled,name:e.manifest.manifest.metadata.name,version:e.manifest.manifest.metadata.version??"",status:e.status,components:e.components,priority:e.priority,install_source:e.install_source,install_info:e.install_info})))}}return(0,n.useEffect)(()=>{M()},[]),(0,n.useImperativeHandle)(t,()=>({refreshPluginList:M})),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(P.Dialog,{open:f,onOpenChange:e=>{e||(b(!1),L(null),D.reset())},children:(0,r.jsxs)(P.DialogContent,{children:[(0,r.jsx)(P.DialogHeader,{children:(0,r.jsx)(P.DialogTitle,{children:"DELETE"===w?s("plugins.deleteConfirm"):s("plugins.updateConfirm")})}),(0,r.jsxs)(P.DialogDescription,{children:[D.status===V.WAIT_INPUT&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)("div",{children:"DELETE"===w?s("plugins.confirmDeletePlugin",{author:E?.author??"",name:E?.name??""}):s("plugins.confirmUpdatePlugin",{author:E?.author??"",name:E?.name??""})}),"DELETE"===w&&(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)(B.Checkbox,{id:"delete-data",checked:T,onCheckedChange:e=>I(!0===e)}),(0,r.jsx)("label",{htmlFor:"delete-data",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer",children:s("plugins.deleteDataCheckbox")})]})]}),D.status===V.RUNNING&&(0,r.jsx)("div",{children:"DELETE"===w?s("plugins.deleting"):s("plugins.updating")}),D.status===V.ERROR&&(0,r.jsxs)("div",{children:["DELETE"===w?s("plugins.deleteError"):s("plugins.updateError"),(0,r.jsx)("div",{className:"text-red-500",children:D.error})]})]}),(0,r.jsxs)(P.DialogFooter,{children:[D.status===V.WAIT_INPUT&&(0,r.jsx)(y.Button,{variant:"outline",onClick:()=>{b(!1),L(null),D.reset()},children:s("plugins.cancel")}),D.status===V.WAIT_INPUT&&(0,r.jsx)(y.Button,{variant:"DELETE"===w?"destructive":"default",onClick:()=>{E&&("DELETE"===w?j.httpClient.removePlugin(E.author,E.name,T):j.httpClient.upgradePlugin(E.author,E.name)).then(e=>{D.startTask(e.task_id)}).catch(e=>{let t="DELETE"===w?s("plugins.deleteError")+e.message:s("plugins.updateError")+e.message;k.toast.error(t)})},children:"DELETE"===w?s("plugins.confirmDelete"):s("plugins.confirmUpdate")}),D.status===V.RUNNING&&(0,r.jsx)(y.Button,{variant:"DELETE"===w?"destructive":"default",disabled:!0,children:"DELETE"===w?s("plugins.deleting"):s("plugins.updating")}),D.status===V.ERROR&&(0,r.jsx)(y.Button,{variant:"default",onClick:()=>{b(!1),D.reset()},children:s("plugins.close")})]})]})}),0===a.length?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center text-gray-500 min-h-[60vh] w-full gap-2",children:[(0,r.jsx)("svg",{className:"h-[3rem] w-[3rem]",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,r.jsx)("path",{d:"M7 5C7 2.79086 8.79086 1 11 1C13.2091 1 15 2.79086 15 5H20C20.5523 5 21 5.44772 21 6V10.1707C21 10.4953 20.8424 10.7997 20.5774 10.9872C20.3123 11.1746 19.9728 11.2217 19.6668 11.1135C19.4595 11.0403 19.2355 11 19 11C17.8954 11 17 11.8954 17 13C17 14.1046 17.8954 15 19 15C19.2355 15 19.4595 14.9597 19.6668 14.8865C19.9728 14.7783 20.3123 14.8254 20.5774 15.0128C20.8424 15.2003 21 15.5047 21 15.8293V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V6C3 5.44772 3.44772 5 4 5H7ZM11 3C9.89543 3 9 3.89543 9 5C9 5.23554 9.0403 5.45952 9.11355 5.66675C9.22172 5.97282 9.17461 6.31235 8.98718 6.57739C8.79974 6.84243 8.49532 7 8.17071 7H5V19H19V17C16.7909 17 15 15.2091 15 13C15 10.7909 16.7909 9 19 9V7H13.8293C13.5047 7 13.2003 6.84243 13.0128 6.57739C12.8254 6.31235 12.7783 5.97282 12.8865 5.66675C12.9597 5.45952 13 5.23555 13 5C13 3.89543 12.1046 3 11 3Z"})}),(0,r.jsx)("div",{className:"text-lg mb-2",children:s("plugins.noPluginInstalled")})]}):(0,r.jsxs)("div",{className:`${F.default.pluginListContainer}`,children:[(0,r.jsx)(P.Dialog,{open:o,onOpenChange:d,children:(0,r.jsxs)(P.DialogContent,{className:"w-[700px] max-h-[80vh] p-0 flex flex-col",children:[(0,r.jsx)(P.DialogHeader,{className:"px-6 pt-6 pb-2",children:(0,r.jsx)(P.DialogTitle,{children:s("plugins.pluginConfig")})}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto px-6",children:m&&(0,r.jsx)(S,{pluginAuthor:m.author,pluginName:m.name,onFormSubmit:e=>{d(!1),e?setTimeout(()=>{M()},e):M()},onFormCancel:()=>{d(!1)}})})]})}),(0,r.jsx)(P.Dialog,{open:x,onOpenChange:p,children:(0,r.jsxs)(P.DialogContent,{className:"sm:max-w-[900px] max-w-[90vw] max-h-[85vh] p-0 flex flex-col",children:[(0,r.jsx)(P.DialogHeader,{className:"px-6 pt-6 pb-2 border-b",children:(0,r.jsx)(P.DialogTitle,{children:h&&`${h.author}/${h.name} - ${s("plugins.readme")}`})}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto",children:h&&(0,r.jsx)(R,{pluginAuthor:h.author,pluginName:h.name})})]})}),a.map((e,t)=>(0,r.jsx)("div",{children:(0,r.jsx)(N,{cardVO:e,onCardClick:()=>{u(e),d(!0)},onDeleteClick:()=>{L(e),C("DELETE"),b(!0),I(!1),D.reset()},onUpgradeClick:()=>{L(e),C("UPDATE"),b(!0),D.reset()},onViewReadme:()=>{g(e),p(!0)}})},t))]})]})});var U=e.i(87980),H=e.i(47977),A=e.i(67658),G=e.i(4372),$=e.i(86759),Z=e.i(15822),W=e.i(60677),q="Toggle",K=n.forwardRef((e,t)=>{let{pressed:s,defaultPressed:a,onPressedChange:l,...n}=e,[i,o]=(0,W.useControllableState)({prop:s,onChange:l,defaultProp:a??!1,caller:q});return(0,r.jsx)(G.Primitive.button,{type:"button","aria-pressed":i,"data-state":i?"on":"off","data-disabled":e.disabled?"":void 0,...n,ref:t,onClick:(0,Z.composeEventHandlers)(e.onClick,()=>{e.disabled||o(!i)})})});K.displayName=q;var J=e.i(9252),Q="ToggleGroup",[X,Y]=(0,A.createContextScope)(Q,[$.createRovingFocusGroupScope]),ee=(0,$.createRovingFocusGroupScope)(),et=n.default.forwardRef((e,t)=>{let{type:s,...a}=e;if("single"===s)return(0,r.jsx)(el,{...a,ref:t});if("multiple"===s)return(0,r.jsx)(er,{...a,ref:t});throw Error(`Missing prop \`type\` expected on \`${Q}\``)});et.displayName=Q;var[es,ea]=X(Q),el=n.default.forwardRef((e,t)=>{let{value:s,defaultValue:a,onValueChange:l=()=>{},...i}=e,[o,c]=(0,W.useControllableState)({prop:s,defaultProp:a??"",onChange:l,caller:Q});return(0,r.jsx)(es,{scope:e.__scopeToggleGroup,type:"single",value:n.default.useMemo(()=>o?[o]:[],[o]),onItemActivate:c,onItemDeactivate:n.default.useCallback(()=>c(""),[c]),children:(0,r.jsx)(eo,{...i,ref:t})})}),er=n.default.forwardRef((e,t)=>{let{value:s,defaultValue:a,onValueChange:l=()=>{},...i}=e,[o,c]=(0,W.useControllableState)({prop:s,defaultProp:a??[],onChange:l,caller:Q}),d=n.default.useCallback(e=>c((t=[])=>[...t,e]),[c]),m=n.default.useCallback(e=>c((t=[])=>t.filter(t=>t!==e)),[c]);return(0,r.jsx)(es,{scope:e.__scopeToggleGroup,type:"multiple",value:o,onItemActivate:d,onItemDeactivate:m,children:(0,r.jsx)(eo,{...i,ref:t})})});et.displayName=Q;var[en,ei]=X(Q),eo=n.default.forwardRef((e,t)=>{let{__scopeToggleGroup:s,disabled:a=!1,rovingFocus:l=!0,orientation:n,dir:i,loop:o=!0,...c}=e,d=ee(s),m=(0,J.useDirection)(i),u={role:"group",dir:m,...c};return(0,r.jsx)(en,{scope:s,rovingFocus:l,disabled:a,children:l?(0,r.jsx)($.Root,{asChild:!0,...d,orientation:n,dir:m,loop:o,children:(0,r.jsx)(G.Primitive.div,{...u,ref:t})}):(0,r.jsx)(G.Primitive.div,{...u,ref:t})})}),ec="ToggleGroupItem",ed=n.default.forwardRef((e,t)=>{let s=ea(ec,e.__scopeToggleGroup),a=ei(ec,e.__scopeToggleGroup),l=ee(e.__scopeToggleGroup),i=s.value.includes(e.value),o=a.disabled||e.disabled,c={...e,pressed:i,disabled:o},d=n.default.useRef(null);return a.rovingFocus?(0,r.jsx)($.Item,{asChild:!0,...l,focusable:!o,active:i,ref:d,children:(0,r.jsx)(em,{...c,ref:t})}):(0,r.jsx)(em,{...c,ref:t})});ed.displayName=ec;var em=n.default.forwardRef((e,t)=>{let{__scopeToggleGroup:s,value:a,...l}=e,n=ea(ec,s),i={role:"radio","aria-checked":e.pressed,"aria-pressed":void 0},o="single"===n.type?i:void 0;return(0,r.jsx)(K,{...o,...l,ref:t,onPressedChange:e=>{e?n.onItemActivate(a):n.onItemDeactivate(a)}})}),eu=e.i(14407);let ex=(0,e.i(63686).cva)("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground dark:data-[state=on]:bg-slate-700 dark:data-[state=on]:text-white [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 px-2 min-w-9",sm:"h-8 px-1.5 min-w-8",lg:"h-10 px-2.5 min-w-10"}},defaultVariants:{variant:"default",size:"default"}}),ep=n.createContext({size:"default",variant:"default",spacing:0});function eh({className:e,variant:t,size:s,spacing:a=0,children:l,...n}){return(0,r.jsx)(et,{"data-slot":"toggle-group","data-variant":t,"data-size":s,"data-spacing":a,style:{"--gap":a},className:(0,eu.cn)("group/toggle-group flex w-fit items-center gap-[--spacing(var(--gap))] rounded-md data-[spacing=default]:data-[variant=outline]:shadow-xs",e),...n,children:(0,r.jsx)(ep.Provider,{value:{variant:t,size:s,spacing:a},children:l})})}function eg({className:e,children:t,variant:s,size:a,...l}){let i=n.useContext(ep);return(0,r.jsx)(ed,{"data-slot":"toggle-group-item","data-variant":i.variant||s,"data-size":i.size||a,"data-spacing":i.spacing,className:(0,eu.cn)(ex({variant:i.variant||s,size:i.size||a}),"w-auto min-w-0 shrink-0 px-3 focus:z-10 focus-visible:z-10","data-[spacing=0]:rounded-none data-[spacing=0]:shadow-none data-[spacing=0]:first:rounded-l-md data-[spacing=0]:last:rounded-r-md data-[spacing=0]:data-[variant=outline]:border-l-0 data-[spacing=0]:data-[variant=outline]:first:border-l",e),...l,children:t})}let ef=(0,d.default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);var ev=e.i(53397),ej=e.i(8667),ey=e.i(91600),eb=e.i(4278),ew=e.i(3773);function eN({cardVO:e,onInstall:t,tagNames:s={}}){let{t:a}=(0,c.useTranslation)(),[l,i]=(0,n.useState)(!1),d={Tool:(0,r.jsx)(ev.Wrench,{className:"w-4 h-4"}),EventListener:(0,r.jsx)(ej.AudioWaveform,{className:"w-4 h-4"}),Command:(0,r.jsx)(ey.Hash,{className:"w-4 h-4"}),KnowledgeRetriever:(0,r.jsx)(eb.Book,{className:"w-4 h-4"})};return(0,r.jsxs)("div",{className:"w-[100%] h-auto min-h-[8rem] sm:min-h-[9rem] bg-white rounded-[10px] shadow-[0px_0px_4px_0_rgba(0,0,0,0.2)] p-3 sm:p-[1rem] hover:shadow-[0px_3px_6px_0_rgba(0,0,0,0.12)] transition-all duration-200 hover:scale-[1.005] dark:bg-[#1f1f22] relative",onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[(0,r.jsxs)("div",{className:"w-full h-full flex flex-col justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex flex-row items-start justify-start gap-2 sm:gap-[1.2rem] min-h-0",children:[(0,r.jsx)("img",{src:e.iconURL,alt:"plugin icon",className:"w-12 h-12 sm:w-16 sm:h-16 flex-shrink-0 rounded-[8%]"}),(0,r.jsxs)("div",{className:"flex-1 flex flex-col items-start justify-start gap-[0.4rem] sm:gap-[0.6rem] min-w-0 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex flex-col items-start justify-start w-full min-w-0",children:[(0,r.jsx)("div",{className:"text-[0.65rem] sm:text-[0.7rem] text-[#666] dark:text-[#999] truncate w-full",children:e.pluginId}),(0,r.jsx)("div",{className:"text-base sm:text-[1.2rem] text-black dark:text-[#f0f0f0] truncate w-full",children:e.label})]}),(0,r.jsx)("div",{className:"text-[0.7rem] sm:text-[0.8rem] text-[#666] dark:text-[#999] line-clamp-2 overflow-hidden",children:e.description})]}),(0,r.jsx)("div",{className:"flex flex-row items-start justify-center gap-[0.4rem] flex-shrink-0",children:e.githubURL&&(0,r.jsx)("svg",{className:"w-5 h-5 sm:w-[1.4rem] sm:h-[1.4rem] text-black cursor-pointer hover:text-gray-600 dark:text-[#f0f0f0] flex-shrink-0",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",onClick:t=>{t.stopPropagation(),window.open(e.githubURL,"_blank")},children:(0,r.jsx)("path",{d:"M12.001 2C6.47598 2 2.00098 6.475 2.00098 12C2.00098 16.425 4.86348 20.1625 8.83848 21.4875C9.33848 21.575 9.52598 21.275 9.52598 21.0125C9.52598 20.775 9.51348 19.9875 9.51348 19.15C7.00098 19.6125 6.35098 18.5375 6.15098 17.975C6.03848 17.6875 5.55098 16.8 5.12598 16.5625C4.77598 16.375 4.27598 15.9125 5.11348 15.9C5.90098 15.8875 6.46348 16.625 6.65098 16.925C7.55098 18.4375 8.98848 18.0125 9.56348 17.75C9.65098 17.1 9.91348 16.6625 10.201 16.4125C7.97598 16.1625 5.65098 15.3 5.65098 11.475C5.65098 10.3875 6.03848 9.4875 6.67598 8.7875C6.57598 8.5375 6.22598 7.5125 6.77598 6.1375C6.77598 6.1375 7.61348 5.875 9.52598 7.1625C10.326 6.9375 11.176 6.825 12.026 6.825C12.876 6.825 13.726 6.9375 14.526 7.1625C16.4385 5.8625 17.276 6.1375 17.276 6.1375C17.826 7.5125 17.476 8.5375 17.376 8.7875C18.0135 9.4875 18.401 10.375 18.401 11.475C18.401 15.3125 16.0635 16.1625 13.8385 16.4125C14.201 16.725 14.5135 17.325 14.5135 18.2625C14.5135 19.6 14.501 20.675 14.501 21.0125C14.501 21.275 14.6885 21.5875 15.1885 21.4875C19.259 20.1133 21.9999 16.2963 22.001 12C22.001 6.475 17.526 2 12.001 2Z"})})})]}),(0,r.jsxs)("div",{className:"w-full flex flex-row items-center justify-between gap-2 px-0 sm:px-[0.4rem] flex-shrink-0",children:[(0,r.jsxs)("div",{className:"flex flex-row items-center justify-start gap-2 flex-wrap",children:[(0,r.jsxs)("div",{className:"flex flex-row items-center gap-[0.3rem] sm:gap-[0.4rem]",children:[(0,r.jsxs)("svg",{className:"w-4 h-4 sm:w-[1.2rem] sm:h-[1.2rem] text-[#2563eb] dark:text-[#5b8def] flex-shrink-0",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,r.jsx)("polyline",{points:"7,10 12,15 17,10"}),(0,r.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),(0,r.jsx)("div",{className:"text-xs sm:text-sm text-[#2563eb] dark:text-[#5b8def] font-medium whitespace-nowrap",children:e.installCount?.toLocaleString()??"0"})]}),e.tags&&e.tags.length>0&&(0,r.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[e.tags.slice(0,2).map(e=>(0,r.jsxs)(o.Badge,{variant:"secondary",className:"text-[0.65rem] sm:text-[0.7rem] px-2 py-0.5 h-5 flex items-center gap-1 flex-shrink-0",children:[(0,r.jsxs)("svg",{className:"w-2.5 h-2.5 flex-shrink-0",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"}),(0,r.jsx)("line",{x1:"7",y1:"7",x2:"7.01",y2:"7"})]}),(0,r.jsx)("span",{className:"truncate",children:s[e]||e})]},e)),e.tags.length>2&&(0,r.jsxs)(o.Badge,{variant:"outline",className:"text-[0.65rem] sm:text-[0.7rem] px-2 py-0.5 h-5 flex items-center flex-shrink-0",children:["+",e.tags.length-2]})]})]}),e.components&&Object.keys(e.components).length>0&&(0,r.jsx)("div",{className:"flex flex-row items-center gap-1",children:Object.entries(e.components).map(([e,t])=>(0,r.jsxs)(o.Badge,{variant:"outline",className:"flex items-center gap-1",children:[d[e],(0,r.jsx)("span",{className:"ml-1",children:t})]},e))})]})]}),(0,r.jsxs)("div",{className:`absolute inset-0 bg-gray-100/55 dark:bg-black/35 rounded-[10px] flex items-center justify-center gap-3 transition-all duration-200 ${l?"opacity-100":"opacity-0 pointer-events-none"}`,children:[(0,r.jsxs)(y.Button,{onClick:function(s){s.stopPropagation(),t&&t(e.author,e.pluginName)},className:`bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg shadow-sm flex items-center gap-2 transition-all duration-200 ${l?"translate-y-0 opacity-100":"translate-y-1 opacity-0"}`,style:{transitionDelay:l?"10ms":"0ms"},children:[(0,r.jsx)(ew.Download,{className:"w-4 h-4"}),a("market.install")]}),(0,r.jsxs)(y.Button,{onClick:function(t){t.stopPropagation();let s=`https://space.langbot.app/market/${e.author}/${e.pluginName}`;window.open(s,"_blank")},variant:"outline",className:`bg-white hover:bg-gray-100 text-gray-900 dark:bg-white dark:hover:bg-gray-100 dark:text-gray-900 px-4 py-2 rounded-lg shadow-sm flex items-center gap-2 transition-all duration-200 ${l?"translate-y-0 opacity-100":"translate-y-1 opacity-0"}`,style:{transitionDelay:l?"20ms":"0ms"},children:[(0,r.jsx)(u.ExternalLink,{className:"w-4 h-4"}),a("market.viewDetails")]})]})]})}class eC{pluginId;description;label;author;pluginName;iconURL;githubURL;installCount;version;components;tags;constructor(e){this.description=e.description,this.label=e.label,this.author=e.author,this.pluginName=e.pluginName,this.iconURL=e.iconURL,this.githubURL=e.githubURL,this.installCount=e.installCount,this.pluginId=e.pluginId,this.version=e.version,this.components=e.components,this.tags=e.tags}}var ek=e.i(16700),e_=e.i(54647);let eS=(0,d.default)("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);function eE({availableTags:e,selectedTags:t,onTagsChange:s}){let{t:a,i18n:l}=(0,c.useTranslation)(),[i,o]=(0,n.useState)(!1),d=e=>{s(t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,r.jsxs)(H.Select,{open:i,onOpenChange:o,children:[(0,r.jsx)(H.SelectTrigger,{className:"w-[140px]",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 w-full",children:[(0,r.jsx)(eS,{className:"h-4 w-4 flex-shrink-0"}),0===t.length?(0,r.jsx)("span",{className:"text-muted-foreground truncate text-sm",children:a("market.tags.filterByTags")}):(0,r.jsxs)("span",{className:"text-sm truncate",children:[t.length," ",a("market.tags.selected")]})]})}),(0,r.jsx)(H.SelectContent,{className:"w-[240px]",children:(0,r.jsxs)(H.SelectGroup,{children:[(0,r.jsxs)("div",{className:"px-2 py-1.5 flex items-center justify-between border-b",children:[(0,r.jsx)("span",{className:"text-sm font-medium",children:a("market.tags.selectTags")}),t.length>0&&(0,r.jsx)(y.Button,{variant:"ghost",size:"sm",onClick:()=>{s([])},className:"h-auto p-0 text-xs hover:bg-transparent hover:text-destructive",children:a("market.tags.clearAll")})]}),0===e.length?(0,r.jsx)("div",{className:"px-2 py-6 text-center text-sm text-muted-foreground",children:a("market.tags.noTags")}):(0,r.jsx)("div",{className:"max-h-[300px] overflow-y-auto",children:e.map(e=>{var s;return(0,r.jsxs)("div",{className:"flex items-center space-x-2 px-2 py-2 hover:bg-accent cursor-pointer",onClick:t=>{t.preventDefault(),d(e.tag)},children:[(0,r.jsx)(B.Checkbox,{id:`tag-${e.tag}`,checked:t.includes(e.tag),onClick:e=>e.stopPropagation(),onCheckedChange:()=>d(e.tag)}),(0,r.jsx)(e_.Label,{htmlFor:`tag-${e.tag}`,className:"text-sm font-normal cursor-pointer flex-1",onClick:e=>e.preventDefault(),children:(s=e.display_name)[l.language||"en_US"]||s.zh_Hans||s.en_US||""})]},e.tag)})})]})})]})}let eL=(0,d.default)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);var eT=e.i(37106);let eI=(0,d.default)("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);function eD({list:e,tagNames:t,onInstall:s}){let{t:a}=(0,c.useTranslation)(),[l,i]=(0,n.useState)(0),o=e.plugins||[],d=Math.ceil(o.length/4),m=4*l,u=o.slice(m,m+4);return 0===o.length?null:(0,r.jsxs)("div",{className:"mb-6",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(eI,{className:"w-4 h-4 text-yellow-500"}),(0,r.jsx)("h3",{className:"font-semibold text-base",children:(0,_.extractI18nObject)(e.label)})]}),d>1&&(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)(y.Button,{variant:"ghost",size:"sm",onClick:()=>i(e=>Math.max(0,e-1)),disabled:0===l,className:"h-7 w-7 p-0",children:(0,r.jsx)(eL,{className:"w-4 h-4"})}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground px-1",children:[l+1," / ",d]}),(0,r.jsx)(y.Button,{variant:"ghost",size:"sm",onClick:()=>i(e=>Math.min(d-1,e+1)),disabled:l>=d-1,className:"h-7 w-7 p-0",children:(0,r.jsx)(eT.ChevronRight,{className:"w-4 h-4"})})]})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4 gap-6",children:u.map(e=>(0,r.jsx)(eN,{cardVO:new eC({pluginId:e.author+" / "+e.name,author:e.author,pluginName:e.name,label:(0,_.extractI18nObject)(e.label),description:(0,_.extractI18nObject)(e.description)||a("market.noDescription"),installCount:e.install_count,iconURL:(0,v.getCloudServiceClientSync)().getPluginIconURL(e.author,e.name),githubURL:e.repository,version:e.latest_version,components:e.components,tags:e.tags||[]}),tagNames:t,onInstall:s},e.author+" / "+e.name))}),d>1&&(0,r.jsx)("div",{className:"border-b border-border mt-6"})]})}function eM({lists:e,tagNames:t,onInstall:s}){return e&&0!==e.length?(0,r.jsxs)("div",{className:"mt-6",children:[e.map(e=>(0,r.jsx)(eD,{list:e,tagNames:t,onInstall:s},e.uuid)),(0,r.jsx)("div",{className:"border-b border-border mb-6"})]}):null}function eR({installPlugin:e}){let{t}=(0,c.useTranslation)(),[s,a]=(0,n.useState)(""),[l,i]=(0,n.useState)("all"),[o,d]=(0,n.useState)([]),[m,u]=(0,n.useState)([]),[x,p]=(0,n.useState)({}),[h,g]=(0,n.useState)([]),[f,j]=(0,n.useState)(!1),[y,b]=(0,n.useState)(!1),[w,N]=(0,n.useState)(!0),[C,S]=(0,n.useState)(1),[E,L]=(0,n.useState)(0),[T,I]=(0,n.useState)("install_count_desc"),[D,M]=(0,n.useState)([]),R=(0,n.useRef)(null),F=(0,n.useRef)(null),P=[{value:"created_at_desc",label:t("market.sort.recentlyAdded"),sortBy:"created_at",sortOrder:"DESC"},{value:"updated_at_desc",label:t("market.sort.recentlyUpdated"),sortBy:"updated_at",sortOrder:"DESC"},{value:"install_count_desc",label:t("market.sort.mostDownloads"),sortBy:"install_count",sortOrder:"DESC"},{value:"install_count_asc",label:t("market.sort.leastDownloads"),sortBy:"install_count",sortOrder:"ASC"}],B=(0,n.useCallback)(()=>{let e=P.find(e=>e.value===T);return e?{sortBy:e.sortBy,sortOrder:e.sortOrder}:{sortBy:"install_count",sortOrder:"DESC"}},[T]),V=(0,n.useCallback)(e=>new eC({pluginId:e.author+" / "+e.name,author:e.author,pluginName:e.name,label:(0,_.extractI18nObject)(e.label),description:(0,_.extractI18nObject)(e.description)||t("market.noDescription"),installCount:e.install_count,iconURL:(0,v.getCloudServiceClientSync)().getPluginIconURL(e.author,e.name),githubURL:e.repository,version:e.latest_version,components:e.components,tags:e.tags||[]}),[]),z=(0,n.useCallback)(async(e,a=!1,r=!1)=>{1===e?j(!0):b(!0);try{let{sortBy:t,sortOrder:n}=B(),i="all"===l?void 0:l,c=await (0,v.getCloudServiceClientSync)().searchMarketplacePlugins(a&&s.trim()?s.trim():"",e,16,t,n,i,o.length>0?o:void 0),d=c.plugins.map(V),m=c.total;r||1===e?g(d):g(e=>[...e,...d]),L(m),N(16===c.plugins.length&&h.length+d.length<m)}catch(e){console.error("Failed to fetch plugins:",e),k.toast.error(t("market.loadFailed"))}finally{j(!1),b(!1)}},[s,l,o,16,V,h.length,B]);(0,n.useEffect)(()=>{z(1,!1,!0),O()},[]);let O=async()=>{try{let e=(await (0,v.getCloudServiceClientSync)().getAllTags()).tags||[];u(e);let t={};e.forEach(e=>{let s={en_US:e.display_name.en_US||e.tag,zh_Hans:e.display_name.zh_Hans||e.tag,zh_Hant:e.display_name.zh_Hant,ja_JP:e.display_name.ja_JP};t[e.tag]=(0,_.extractI18nObject)(s)}),p(t)}catch(e){console.error("Failed to fetch tags:",e)}};(0,n.useEffect)(()=>{!async function(){try{let e=await (0,v.getCloudServiceClientSync)().getRecommendationLists();M(e.lists||[])}catch(e){console.error("Failed to fetch recommendation lists:",e)}}()},[]);let A=(0,n.useCallback)(e=>{a(e),S(1),g([]),z(1,!!e.trim(),!0)},[z]),G=(0,n.useCallback)(e=>{a(e),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{A(e)},300)},[A]),$=(0,n.useCallback)(e=>{I(e),S(1),g([])},[]),Z=(0,n.useCallback)(e=>{i(e),S(1),g([])},[]);(0,n.useEffect)(()=>{z(1,!!s.trim(),!0)},[T,l]),(0,n.useEffect)(()=>{f||(S(1),z(1,""!==s.trim(),!0))},[o]);let W=(0,n.useCallback)(e=>{d(e)},[]),q=(0,n.useCallback)(async(s,a)=>{try{if(!h.find(e=>e.author===s&&e.pluginName===a))return void console.error("Plugin not found:",s,a);let t=(await (0,v.getCloudServiceClientSync)().getPluginDetail(s,a)).plugin;e(t)}catch(e){console.error("Failed to install plugin:",e),k.toast.error(t("market.installFailed"))}},[h,e,t]);(0,n.useEffect)(()=>()=>{R.current&&clearTimeout(R.current)},[]);let K=(0,n.useMemo)(()=>{let e=new Set;return D.forEach(t=>{t.plugins.forEach(t=>{e.add(`${t.author} / ${t.name}`)})}),e},[D]),J=(0,n.useMemo)(()=>s||"all"!==l||0!==o.length?h:h.filter(e=>!K.has(e.pluginId)),[h,K,s,l,o]),Q=(0,n.useCallback)(()=>{if(!y&&w){let e=C+1;S(e),z(e,!!s.trim())}},[C,y,w,z,s]),X=(0,n.useCallback)(()=>{let e=F.current;if(!e||f||y||!w)return;let{scrollHeight:t,clientHeight:s}=e;t<=s&&Q()},[Q,f,y,w]);return(0,n.useEffect)(()=>{let e=F.current;if(!e)return;let t=()=>{let{scrollTop:t,scrollHeight:s,clientHeight:a}=e;t+a>=s-100&&Q()};return e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)},[Q]),(0,n.useEffect)(()=>{let e=setTimeout(()=>{X()},100);return()=>clearTimeout(e)},[h,X]),(0,n.useEffect)(()=>{let e=()=>{X()};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[X]),(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsxs)("div",{className:"flex-shrink-0 space-y-4 px-3 sm:px-4 py-4 sm:py-6",children:[(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-3",children:[(0,r.jsxs)("div",{className:"relative w-full max-w-2xl",children:[(0,r.jsx)(ef,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),(0,r.jsx)(U.Input,{placeholder:t("market.searchPlaceholder"),value:s,onChange:e=>G(e.target.value),onKeyPress:e=>{"Enter"===e.key&&(R.current&&clearTimeout(R.current),A(s))},className:"pl-10 pr-4 text-sm sm:text-base"})]}),(0,r.jsx)(eE,{availableTags:m,selectedTags:o,onTagsChange:W})]}),(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-3 sm:gap-4 px-3 sm:px-4",children:[(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row items-center gap-2",children:[(0,r.jsxs)("span",{className:"text-xs sm:text-sm text-muted-foreground whitespace-nowrap",children:[t("market.filterByComponent"),":"]}),(0,r.jsxs)(eh,{type:"single",spacing:2,size:"sm",value:l,onValueChange:e=>{e&&Z(e)},className:"justify-start",children:[(0,r.jsx)(eg,{value:"all","aria-label":"All components",className:"text-xs sm:text-sm cursor-pointer",children:t("market.allComponents")}),(0,r.jsxs)(eg,{value:"Tool","aria-label":"Tool",className:"text-xs sm:text-sm cursor-pointer",children:[(0,r.jsx)(ev.Wrench,{className:"h-4 w-4 mr-1"}),t("plugins.componentName.Tool")]}),(0,r.jsxs)(eg,{value:"Command","aria-label":"Command",className:"text-xs sm:text-sm cursor-pointer",children:[(0,r.jsx)(ey.Hash,{className:"h-4 w-4 mr-1"}),t("plugins.componentName.Command")]}),(0,r.jsxs)(eg,{value:"EventListener","aria-label":"EventListener",className:"text-xs sm:text-sm cursor-pointer",children:[(0,r.jsx)(ej.AudioWaveform,{className:"h-4 w-4 mr-1"}),t("plugins.componentName.EventListener")]}),(0,r.jsxs)(eg,{value:"KnowledgeRetriever","aria-label":"KnowledgeRetriever",className:"text-xs sm:text-sm cursor-pointer",children:[(0,r.jsx)(eb.Book,{className:"h-4 w-4 mr-1"}),t("plugins.componentName.KnowledgeRetriever")]})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 sm:gap-3",children:[(0,r.jsxs)("span",{className:"text-xs sm:text-sm text-muted-foreground whitespace-nowrap",children:[t("market.sortBy"),":"]}),(0,r.jsxs)(H.Select,{value:T,onValueChange:$,children:[(0,r.jsx)(H.SelectTrigger,{className:"w-40 sm:w-48 text-xs sm:text-sm",children:(0,r.jsx)(H.SelectValue,{})}),(0,r.jsx)(H.SelectContent,{children:P.map(e=>(0,r.jsx)(H.SelectItem,{value:e.value,children:e.label},e.value))})]})]})]}),E>0&&(0,r.jsx)("div",{className:"text-center text-muted-foreground text-sm",children:s?t("market.searchResults",{count:E}):t("market.totalPlugins",{count:E})})]}),(0,r.jsxs)("div",{ref:F,className:"flex-1 overflow-y-auto px-3 sm:px-4",children:[!s&&"all"===l&&0===o.length&&1===C&&(0,r.jsx)("div",{className:"pt-4",children:(0,r.jsx)(eM,{lists:D,tagNames:x,onInstall:q})}),f?(0,r.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,r.jsx)(ek.LoadingSpinner,{text:t("market.loading")})}):0===h.length?(0,r.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,r.jsx)("div",{className:"text-muted-foreground",children:s?t("market.noResults"):t("market.noPlugins")})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4 gap-6 pb-6 pt-4",children:J.map(e=>(0,r.jsx)(eN,{cardVO:e,onInstall:q,tagNames:x},e.pluginId))}),y&&(0,r.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,r.jsx)(ek.LoadingSpinner,{size:"sm",text:t("market.loadingMore")})}),!w&&h.length>0&&(0,r.jsxs)("div",{className:"text-center text-muted-foreground py-6",children:[t("market.allLoaded")," · ",(0,r.jsx)("a",{href:"https://github.com/langbot-app/langbot-plugin-demo/issues/new?template=plugin-request.yml",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:t("market.requestPlugin")})]})]})]})]})}function eF({installPlugin:e}){return(0,r.jsx)(n.Suspense,{fallback:(0,r.jsx)("div",{className:"container mx-auto px-4 py-6",children:(0,r.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,r.jsx)(ek.LoadingSpinner,{text:"加载中..."})})}),children:(0,r.jsx)(eR,{installPlugin:e})})}var eP=e.i(13781);let eB=(0,d.default)("refresh-ccw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]),eV=(0,d.default)("ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);var ez=e.i(92784),eO=e.i(48456),eU=((a={}).CONNECTING="connecting",a.CONNECTED="connected",a.ERROR="error",a);function eH({cardVO:e,onCardClick:t,onRefresh:s}){let{t:a}=(0,c.useTranslation)(),[l,i]=(0,n.useState)(e.enable),[d,m]=(0,n.useState)(!0),[u,x]=(0,n.useState)(!1),[p,h]=(0,n.useState)(e.tools),[g,f]=(0,n.useState)(e.status);return(0,n.useEffect)(()=>{f(e.status),h(e.tools),i(e.enable)},[e.status,e.tools,e.enable]),(0,r.jsx)("div",{className:"w-[100%] h-[10rem] bg-white dark:bg-[#1f1f22] rounded-[10px] shadow-[0px_2px_2px_0_rgba(0,0,0,0.2)] dark:shadow-none p-[1.2rem] cursor-pointer transition-all duration-200 hover:shadow-[0px_2px_8px_0_rgba(0,0,0,0.1)] dark:hover:shadow-none",onClick:t,children:(0,r.jsxs)("div",{className:"w-full h-full flex flex-row items-start justify-start gap-[1.2rem]",children:[(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"64",height:"64",fill:"rgba(70,146,221,1)",children:(0,r.jsx)("path",{d:"M17.6567 14.8284L16.2425 13.4142L17.6567 12C19.2188 10.4379 19.2188 7.90524 17.6567 6.34314C16.0946 4.78105 13.5619 4.78105 11.9998 6.34314L10.5856 7.75736L9.17139 6.34314L10.5856 4.92893C12.9287 2.58578 16.7277 2.58578 19.0709 4.92893C21.414 7.27208 21.414 11.0711 19.0709 13.4142L17.6567 14.8284ZM14.8282 17.6569L13.414 19.0711C11.0709 21.4142 7.27189 21.4142 4.92875 19.0711C2.5856 16.7279 2.5856 12.9289 4.92875 10.5858L6.34296 9.17157L7.75717 10.5858L6.34296 12C4.78086 13.5621 4.78086 16.0948 6.34296 17.6569C7.90506 19.2189 10.4377 19.2189 11.9998 17.6569L13.414 16.2426L14.8282 17.6569ZM14.8282 7.75736L16.2425 9.17157L9.17139 16.2426L7.75717 14.8284L14.8282 7.75736Z"})}),(0,r.jsxs)("div",{className:"w-full h-full flex flex-col items-start justify-between gap-[0.6rem]",children:[(0,r.jsx)("div",{className:"flex flex-col items-start justify-start gap-[0.3rem]",children:(0,r.jsxs)("div",{className:"flex flex-row items-center gap-[0.5rem]",children:[(0,r.jsx)("div",{className:"text-[1.2rem] text-black dark:text-[#f0f0f0] font-medium",children:e.name}),(0,r.jsx)(o.Badge,{variant:"secondary",className:"text-[0.65rem] px-1.5 py-0",children:e.mode.toUpperCase()})]})}),(0,r.jsx)("div",{className:"w-full flex flex-row items-start justify-start gap-[0.6rem]",children:l?g===eU.CONNECTED?(0,r.jsxs)("div",{className:"flex h-full flex-row items-center justify-center gap-[0.4rem]",children:[(0,r.jsx)(ev.Wrench,{className:"w-5 h-5"}),(0,r.jsx)("div",{className:"text-base text-black dark:text-[#f0f0f0] font-medium",children:a("mcp.toolCount",{count:p})})]}):g===eU.CONNECTING?(0,r.jsxs)("div",{className:"flex flex-row items-center gap-[0.4rem]",children:[(0,r.jsx)(eO.Loader2,{className:"w-4 h-4 text-blue-500 dark:text-blue-400 animate-spin"}),(0,r.jsx)("div",{className:"text-sm text-blue-500 dark:text-blue-400 font-medium",children:a("mcp.connecting")})]}):(0,r.jsxs)("div",{className:"flex flex-row items-center gap-[0.4rem]",children:[(0,r.jsx)(ez.AlertCircle,{className:"w-4 h-4 text-red-500 dark:text-red-400"}),(0,r.jsx)("div",{className:"text-sm text-red-500 dark:text-red-400 font-medium",children:a("mcp.connectionFailedStatus")})]}):(0,r.jsxs)("div",{className:"flex flex-row items-center gap-[0.4rem]",children:[(0,r.jsx)(eV,{className:"w-4 h-4 text-orange-500 dark:text-orange-400"}),(0,r.jsx)("div",{className:"text-sm text-orange-500 dark:text-orange-400 font-medium",children:a("mcp.statusDisabled")})]})})]}),(0,r.jsxs)("div",{className:"flex flex-col items-center justify-between h-full",children:[(0,r.jsx)("div",{className:"flex items-center justify-center",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(eP.Switch,{className:"cursor-pointer",checked:l,onCheckedChange:function(t){m(!1),j.httpClient.toggleMCPServer(e.name,t).then(()=>{i(t),k.toast.success(a("mcp.saveSuccess")),s(),m(!0)}).catch(e=>{k.toast.error(a("mcp.modifyFailed")+e.msg),m(!0)})},disabled:!d})}),(0,r.jsx)("div",{className:"flex items-center justify-center gap-[0.4rem]",children:(0,r.jsx)(y.Button,{variant:"ghost",size:"sm",className:"p-1 h-8 w-8",onClick:t=>{t.stopPropagation(),x(!0),j.httpClient.testMCPServer(e.name,{}).then(e=>{let t=e.task_id,l=setInterval(()=>{j.httpClient.getAsyncTask(t).then(e=>{e.runtime.done&&(clearInterval(l),x(!1),e.runtime.exception?k.toast.error(a("mcp.refreshFailed")+e.runtime.exception):k.toast.success(a("mcp.refreshSuccess")),s())})},1e3)}).catch(e=>{k.toast.error(a("mcp.refreshFailed")+e.msg),x(!1)})},disabled:u,children:(0,r.jsx)(eB,{className:"w-4 h-4"})})})]})]})})}class eA{name;mode;enable;status;tools;error;constructor(e){this.name=e.name,this.mode=e.mode,this.enable=e.enable,e.runtime_info?e.runtime_info.status===eU.CONNECTED?(this.status=e.runtime_info.status,this.tools=e.runtime_info.tool_count||0):(this.status=e.runtime_info.status,this.tools=0,this.error=e.runtime_info.error_message):(this.status=eU.ERROR,this.tools=0)}}function eG({onEditServer:e}){let{t}=(0,c.useTranslation)(),[s,a]=(0,n.useState)([]),[l,i]=(0,n.useState)(!1),o=(0,n.useRef)(null);function d(){i(!0),j.httpClient.getMCPServers().then(e=>{a(e.servers.map(e=>new eA(e))),i(!1)}).catch(e=>{console.error("Failed to fetch MCP servers:",e),i(!1)})}return(0,n.useEffect)(()=>(d(),()=>{o.current&&clearInterval(o.current)}),[]),(0,n.useEffect)(()=>{let e=s.some(e=>e.enable&&e.status===eU.CONNECTING);return e&&!o.current?o.current=setInterval(()=>{d()},3e3):!e&&o.current&&(clearInterval(o.current),o.current=null),()=>{o.current&&(clearInterval(o.current),o.current=null)}},[s]),(0,r.jsx)("div",{className:"w-full h-full",children:(0,r.jsx)("div",{className:"w-full h-full px-[0.8rem] pt-[0rem]",children:l?(0,r.jsx)("div",{className:"flex flex-col items-center justify-center text-gray-500 min-h-[60vh] w-full gap-2",children:t("mcp.loading")}):0===s.length?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center text-gray-500 min-h-[60vh] w-full gap-2",children:[(0,r.jsx)("svg",{className:"h-[3rem] w-[3rem]",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,r.jsx)("path",{d:"M4.5 7.65311V16.3469L12 20.689L19.5 16.3469V7.65311L12 3.311L4.5 7.65311ZM12 1L21.5 6.5V17.5L12 23L2.5 17.5V6.5L12 1ZM6.49896 9.97065L11 12.5765V17.625H13V12.5765L17.501 9.97066L16.499 8.2398L12 10.8445L7.50104 8.2398L6.49896 9.97065Z"})}),(0,r.jsx)("div",{className:"text-lg mb-2",children:t("mcp.noServerInstalled")})]}):(0,r.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 pt-[2rem] pb-6",children:s.map((t,s)=>(0,r.jsx)("div",{children:(0,r.jsx)(eH,{cardVO:t,onCardClick:()=>{e&&e(t.name)},onRefresh:d})},`${t.name}-${s}`))})})})}var e$=e.i(57728),eZ=e.i(16585),eW=e.i(19309),eq=e.i(81817),eK=e.i(64339);function eJ({testing:e,runtimeInfo:t,t:s}){return e?(0,r.jsxs)("div",{className:"flex items-center gap-2 text-blue-600",children:[(0,r.jsxs)("svg",{className:"w-5 h-5 animate-spin",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),(0,r.jsx)("span",{className:"font-medium",children:s("mcp.testing")})]}):t.status===eU.CONNECTING?(0,r.jsxs)("div",{className:"flex items-center gap-2 text-blue-600",children:[(0,r.jsxs)("svg",{className:"w-5 h-5 animate-spin",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),(0,r.jsx)("span",{className:"font-medium",children:s("mcp.connecting")})]}):(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-red-600",children:[(0,r.jsx)("svg",{className:"w-5 h-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,r.jsx)("span",{className:"font-medium",children:s("mcp.connectionFailed")})]}),t.error_message&&(0,r.jsx)("div",{className:"text-sm text-red-500 pl-7",children:t.error_message})]})}function eQ({tools:e}){return(0,r.jsx)("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:e.map((e,t)=>(0,r.jsx)(eq.Card,{className:"py-3 shadow-none",children:(0,r.jsxs)(eq.CardHeader,{children:[(0,r.jsx)(eq.CardTitle,{className:"text-sm",children:e.name}),e.description&&(0,r.jsx)(eq.CardDescription,{className:"text-xs",children:e.description})]})},t))})}function eX({open:e,onOpenChange:t,serverName:s,isEditMode:a=!1,onSuccess:l,onDelete:i}){let{t:o}=(0,c.useTranslation)(),d=eW.z.object({name:eW.z.string({required_error:o("mcp.nameRequired")}).min(1,{message:o("mcp.nameRequired")}),mode:eW.z.enum(["sse","stdio","http"]),timeout:eW.z.number({invalid_type_error:o("mcp.timeoutMustBeNumber")}).positive({message:o("mcp.timeoutMustBePositive")}).default(30),ssereadtimeout:eW.z.number({invalid_type_error:o("mcp.sseTimeoutMustBeNumber")}).positive({message:o("mcp.timeoutMustBePositive")}).default(300),url:eW.z.string().optional(),command:eW.z.string().optional(),args:eW.z.array(eW.z.object({value:eW.z.string()})).optional(),extra_args:eW.z.array(eW.z.object({key:eW.z.string(),type:eW.z.enum(["string","number","boolean"]),value:eW.z.string()})).optional()}).superRefine((e,t)=>{"sse"===e.mode||"http"===e.mode?e.url&&0!==e.url.length||t.addIssue({code:eW.z.ZodIssueCode.custom,message:o("mcp.urlRequired"),path:["url"]}):"stdio"!==e.mode||e.command&&0!==e.command.length||t.addIssue({code:eW.z.ZodIssueCode.custom,message:o("mcp.commandRequired"),path:["command"]})}),m=(0,e$.useForm)({resolver:(0,eZ.zodResolver)(d),defaultValues:{name:"",mode:"sse",url:"",command:"",args:[],timeout:30,ssereadtimeout:300,extra_args:[]}}),[u,x]=(0,n.useState)([]),[p,h]=(0,n.useState)([]),[g,f]=(0,n.useState)(!1),[v,b]=(0,n.useState)(null),w=(0,n.useRef)(null),N=m.watch("mode");async function C(e){try{let t=await j.httpClient.getMCPServer(e),s=t.server??t;if(m.setValue("name",s.name),m.setValue("mode",s.mode),"sse"===s.mode||"http"===s.mode){if(m.setValue("url",s.extra_args.url),m.setValue("timeout",s.extra_args.timeout),"sse"===s.mode&&m.setValue("ssereadtimeout",s.extra_args.ssereadtimeout),s.extra_args.headers){let e=Object.entries(s.extra_args.headers).map(([e,t])=>({key:e,type:"string",value:String(t)}));x(e),m.setValue("extra_args",e)}}else if("stdio"===s.mode){m.setValue("command",s.extra_args.command);let e=(s.extra_args.args||[]).map(e=>({value:e}));if(h(e),m.setValue("args",e),s.extra_args.env){let e=Object.entries(s.extra_args.env).map(([e,t])=>({key:e,type:"string",value:String(t)}));x(e),m.setValue("extra_args",e)}}s.runtime_info?b(s.runtime_info):b(null)}catch(e){console.error("Failed to load server:",e),k.toast.error(o("mcp.loadFailed"))}}async function _(e){try{let t;if("sse"===e.mode||"http"===e.mode){let s={};e.extra_args?.forEach(e=>{s[e.key]=String(e.value)}),t="sse"===e.mode?{name:e.name,mode:"sse",enable:!0,extra_args:{url:e.url,headers:s,timeout:e.timeout,ssereadtimeout:e.ssereadtimeout}}:{name:e.name,mode:"http",enable:!0,extra_args:{url:e.url,headers:s,timeout:e.timeout}}}else{let s={};e.extra_args?.forEach(e=>{s[e.key]=String(e.value)});let a=e.args?.map(e=>e.value)||[];t={name:e.name,mode:"stdio",enable:!0,extra_args:{command:e.command,args:a,env:s}}}a&&s?(await j.httpClient.updateMCPServer(s,t),k.toast.success(o("mcp.updateSuccess"))):(await j.httpClient.createMCPServer(t),k.toast.success(o("mcp.createSuccess"))),L(!1),l?.()}catch(t){console.error("Failed to save MCP server:",t);let e=t.msg||"";k.toast.error((a?o("mcp.updateFailed"):o("mcp.createFailed"))+e)}}async function S(){f(!0);try{let e,t=m.getValues("mode");e="sse"===t?{url:m.getValues("url"),timeout:m.getValues("timeout"),headers:Object.fromEntries(u.map(e=>[e.key,e.value])),ssereadtimeout:m.getValues("ssereadtimeout")}:"http"===t?{url:m.getValues("url"),timeout:m.getValues("timeout"),headers:Object.fromEntries(u.map(e=>[e.key,e.value]))}:{command:m.getValues("command"),args:p.map(e=>e.value),env:Object.fromEntries(u.map(e=>[e.key,e.value]))};let{task_id:s}=await j.httpClient.testMCPServer("_",{name:m.getValues("name"),mode:t,enable:!0,extra_args:e});if(!s)throw Error(o("mcp.noTaskId"));let l=setInterval(async()=>{try{let e=await j.httpClient.getAsyncTask(s);if(e.runtime?.done)if(clearInterval(l),f(!1),e.runtime.exception){let t=e.runtime.exception||o("mcp.unknownError");k.toast.error(`${o("mcp.testError")}: ${t}`),b({status:eU.ERROR,error_message:t,tool_count:0,tools:[]})}else a&&await C(m.getValues("name")),k.toast.success(o("mcp.testSuccess"))}catch(t){clearInterval(l),f(!1);let e=t.msg||o("mcp.getTaskFailed");k.toast.error(`${o("mcp.testError")}: ${e}`)}},1e3)}catch(t){f(!1);let e=t.message||o("mcp.unknownError");k.toast.error(`${o("mcp.testError")}: ${e}`)}}(0,n.useEffect)(()=>(e&&a&&s?C(s):e&&!a&&(m.reset({name:"",mode:"sse",url:"",command:"",args:[],timeout:30,ssereadtimeout:300,extra_args:[]}),x([]),h([]),b(null)),()=>{w.current&&(clearInterval(w.current),w.current=null)}),[e,a,s]),(0,n.useEffect)(()=>{if(!e||!a||!s||!v||v.status!==eU.CONNECTING){w.current&&(clearInterval(w.current),w.current=null);return}return w.current||(w.current=setInterval(()=>{C(s)},3e3)),()=>{w.current&&(clearInterval(w.current),w.current=null)}},[e,a,s,v?.status]);let E=(e,t,s)=>{let a=[...u];a[e]={...a[e],[t]:s},x(a),m.setValue("extra_args",a)},L=e=>{t(e),e||(m.reset(),x([]),h([]),b(null))};return(0,r.jsx)(P.Dialog,{open:e,onOpenChange:L,children:(0,r.jsxs)(P.DialogContent,{children:[(0,r.jsx)(P.DialogHeader,{children:(0,r.jsx)(P.DialogTitle,{children:a?o("mcp.editServer"):o("mcp.createServer")})}),a&&v&&(0,r.jsxs)("div",{className:"mb-0 space-y-3",children:[(g||v.status!==eU.CONNECTED)&&(0,r.jsx)("div",{className:"p-3 rounded-lg border",children:(0,r.jsx)(eJ,{testing:g,runtimeInfo:v,t:o})}),!g&&v.status===eU.CONNECTED&&v.tools?.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"text-sm font-medium",children:o("mcp.toolCount",{count:v.tools?.length||0})}),(0,r.jsx)(eQ,{tools:v.tools})]})]}),(0,r.jsx)(eK.Form,{...m,children:(0,r.jsx)("form",{onSubmit:m.handleSubmit(_),className:"space-y-4",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(eK.FormField,{control:m.control,name:"name",render:({field:e})=>(0,r.jsxs)(eK.FormItem,{children:[(0,r.jsx)(eK.FormLabel,{children:o("mcp.name")}),(0,r.jsx)(eK.FormControl,{children:(0,r.jsx)(U.Input,{...e})}),(0,r.jsx)(eK.FormMessage,{})]})}),(0,r.jsx)(eK.FormField,{control:m.control,name:"mode",render:({field:e})=>(0,r.jsxs)(eK.FormItem,{children:[(0,r.jsx)(eK.FormLabel,{children:o("mcp.serverMode")}),(0,r.jsxs)(H.Select,{onValueChange:e.onChange,defaultValue:e.value,value:e.value,children:[(0,r.jsx)(eK.FormControl,{children:(0,r.jsx)(H.SelectTrigger,{children:(0,r.jsx)(H.SelectValue,{placeholder:o("mcp.selectMode")})})}),(0,r.jsxs)(H.SelectContent,{children:[(0,r.jsx)(H.SelectItem,{value:"http",children:o("mcp.http")}),(0,r.jsx)(H.SelectItem,{value:"stdio",children:o("mcp.stdio")}),(0,r.jsx)(H.SelectItem,{value:"sse",children:o("mcp.sse")})]})]}),(0,r.jsx)(eK.FormMessage,{})]})}),("sse"===N||"http"===N)&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eK.FormField,{control:m.control,name:"url",render:({field:e})=>(0,r.jsxs)(eK.FormItem,{children:[(0,r.jsx)(eK.FormLabel,{children:o("mcp.url")}),(0,r.jsx)(eK.FormControl,{children:(0,r.jsx)(U.Input,{...e})}),(0,r.jsx)(eK.FormMessage,{})]})}),(0,r.jsx)(eK.FormField,{control:m.control,name:"timeout",render:({field:e})=>(0,r.jsxs)(eK.FormItem,{children:[(0,r.jsx)(eK.FormLabel,{children:o("mcp.timeout")}),(0,r.jsx)(eK.FormControl,{children:(0,r.jsx)(U.Input,{type:"number",placeholder:o("mcp.timeout"),...e,onChange:t=>e.onChange(Number(t.target.value))})}),(0,r.jsx)(eK.FormMessage,{})]})}),"sse"===N&&(0,r.jsx)(eK.FormField,{control:m.control,name:"ssereadtimeout",render:({field:e})=>(0,r.jsxs)(eK.FormItem,{children:[(0,r.jsx)(eK.FormLabel,{children:o("mcp.sseTimeout")}),(0,r.jsx)(eK.FormControl,{children:(0,r.jsx)(U.Input,{type:"number",placeholder:o("mcp.sseTimeoutDescription"),...e,onChange:t=>e.onChange(Number(t.target.value))})}),(0,r.jsx)(eK.FormMessage,{})]})})]}),"stdio"===N&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eK.FormField,{control:m.control,name:"command",render:({field:e})=>(0,r.jsxs)(eK.FormItem,{children:[(0,r.jsx)(eK.FormLabel,{children:o("mcp.command")}),(0,r.jsx)(eK.FormControl,{children:(0,r.jsx)(U.Input,{...e})}),(0,r.jsx)(eK.FormMessage,{})]})}),(0,r.jsxs)(eK.FormItem,{children:[(0,r.jsx)(eK.FormLabel,{children:o("mcp.args")}),(0,r.jsxs)("div",{className:"space-y-2",children:[p.map((e,t)=>(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(U.Input,{placeholder:o("mcp.args"),value:e.value,onChange:e=>{var s;let a;return s=e.target.value,void((a=[...p])[t]={value:s},h(a),m.setValue("args",a))}}),(0,r.jsx)("button",{type:"button",className:"p-2 hover:bg-gray-100 rounded",onClick:()=>{let e;h(e=p.filter((e,s)=>s!==t)),m.setValue("args",e)},children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5 text-red-500",children:(0,r.jsx)("path",{d:"M7 4V2H17V4H22V6H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V6H2V4H7ZM6 6V20H18V6H6ZM9 9H11V17H9V9ZM13 9H15V17H13V9Z"})})})]},t)),(0,r.jsx)(y.Button,{type:"button",variant:"outline",onClick:()=>{let e=[...p,{value:""}];h(e),m.setValue("args",e)},children:o("mcp.addArgument")})]})]})]}),(0,r.jsxs)(eK.FormItem,{children:[(0,r.jsx)(eK.FormLabel,{children:"sse"===N||"http"===N?o("mcp.headers"):o("mcp.env")}),(0,r.jsxs)("div",{className:"space-y-2",children:[u.map((e,t)=>(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(U.Input,{placeholder:o("models.keyName"),value:e.key,onChange:e=>E(t,"key",e.target.value)}),(0,r.jsx)(U.Input,{placeholder:o("models.value"),value:e.value,onChange:e=>E(t,"value",e.target.value)}),(0,r.jsx)("button",{type:"button",className:"p-2 hover:bg-gray-100 rounded",onClick:()=>{let e;x(e=u.filter((e,s)=>s!==t)),m.setValue("extra_args",e)},children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5 text-red-500",children:(0,r.jsx)("path",{d:"M7 4V2H17V4H22V6H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V6H2V4H7ZM6 6V20H18V6H6ZM9 9H11V17H9V9ZM13 9H15V17H13V9Z"})})})]},t)),(0,r.jsx)(y.Button,{type:"button",variant:"outline",onClick:()=>{let e=[...u,{key:"",type:"string",value:""}];x(e),m.setValue("extra_args",e)},children:"sse"===N||"http"===N?o("mcp.addHeader"):o("mcp.addEnvVar")})]}),(0,r.jsx)(eK.FormDescription,{children:o("mcp.extraParametersDescription")}),(0,r.jsx)(eK.FormMessage,{})]}),(0,r.jsxs)(P.DialogFooter,{children:[a&&i&&(0,r.jsx)(y.Button,{type:"button",variant:"destructive",onClick:i,children:o("common.delete")}),(0,r.jsx)(y.Button,{type:"submit",children:a?o("common.save"):o("common.submit")}),(0,r.jsx)(y.Button,{type:"button",variant:"outline",onClick:()=>S(),disabled:g,children:o("common.test")}),(0,r.jsx)(y.Button,{type:"button",variant:"outline",onClick:()=>L(!1),children:o("common.cancel")})]})]})})})]})})}function eY({open:e,onOpenChange:t,serverName:s,onSuccess:a}){let{t:l}=(0,c.useTranslation)();async function n(){if(s)try{await j.httpClient.deleteMCPServer(s),k.toast.success(l("mcp.deleteSuccess")),t(!1),a&&a()}catch(e){console.error("Failed to delete server:",e),k.toast.error(l("mcp.deleteFailed"))}}return(0,r.jsx)(P.Dialog,{open:e,onOpenChange:t,children:(0,r.jsxs)(P.DialogContent,{children:[(0,r.jsx)(P.DialogHeader,{children:(0,r.jsx)(P.DialogTitle,{children:l("mcp.confirmDeleteTitle")})}),(0,r.jsx)(P.DialogDescription,{children:l("mcp.confirmDeleteServer")}),(0,r.jsxs)(P.DialogFooter,{children:[(0,r.jsx)(y.Button,{variant:"outline",onClick:()=>t(!1),children:l("common.cancel")}),(0,r.jsx)(y.Button,{variant:"destructive",onClick:n,children:l("common.confirm")})]})]})})}var e0=e.i(70917),e1=e.i(19522),e1=e1,e2=e.i(30891);let e5=(0,d.default)("upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]),e4=(0,d.default)("store",[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7",key:"6c3vgh"}]]),e7=(0,d.default)("power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]),e6=(0,d.default)("github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]),e8=(0,d.default)("code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);var e9=e.i(17755),e3=e.i(18941),te=e.i(90285),tt=((l=tt||{}).WAIT_INPUT="wait_input",l.SELECT_RELEASE="select_release",l.SELECT_ASSET="select_asset",l.ASK_CONFIRM="ask_confirm",l.INSTALLING="installing",l.ERROR="error",l);function ts(){let{t:e}=(0,c.useTranslation)(),[t,s]=(0,n.useState)("installed"),[a,l]=(0,n.useState)(!1),[i,o]=(0,n.useState)("local"),[d,u]=(0,n.useState)({}),[x,p]=(0,n.useState)(!1),[h,g]=(0,n.useState)("wait_input"),[f,w]=(0,n.useState)(null),[N,C]=(0,n.useState)(""),[_,S]=(0,n.useState)([]),[E,L]=(0,n.useState)(null),[T,I]=(0,n.useState)([]),[D,M]=(0,n.useState)(null),[R,B]=(0,n.useState)(""),[V,z]=(0,n.useState)(""),[H,A]=(0,n.useState)(!1),[G,$]=(0,n.useState)(!1),[Z,W]=(0,n.useState)(!1),[q,K]=(0,n.useState)(null),[J,Q]=(0,n.useState)(!0),X=(0,n.useRef)(null),[Y,ee]=(0,n.useState)(!1),[et,es]=(0,n.useState)(null),[ea,el]=(0,n.useState)(!1),[er,en]=(0,n.useState)(0),[ei,eo]=(0,n.useState)(null),[ec,ed]=(0,n.useState)(!1),[em,eu]=(0,n.useState)(!1),[ex,ep]=(0,n.useState)(!1);function eh(t){let s=!1,a=setInterval(()=>{j.httpClient.getAsyncTask(t).then(t=>{t.runtime.done&&(clearInterval(a),t.runtime.exception?(w(t.runtime.exception),g("error")):(s||(k.toast.success(e("plugins.installSuccess")),s=!0),ef(),l(!1),eg.current?.refreshPluginList()))})},1e3)}(0,n.useEffect)(()=>{(async()=>{try{Q(!0);let e=await j.httpClient.getPluginSystemStatus();K(e)}catch(t){console.error("Failed to fetch plugin system status:",t),k.toast.error(e("plugins.failedToGetStatus"))}finally{Q(!1)}})()},[]);let eg=(0,n.useRef)(null);function ef(){C(""),S([]),L(null),I([]),M(null),B(""),z(""),A(!1),$(!1)}async function ev(){let t=v.systemInfo.limitation?.max_extensions??-1;if(t<0)return!0;try{let[s,a]=await Promise.all([j.httpClient.getPlugins(),j.httpClient.getMCPServers()]);if((s.plugins?.length??0)+(a.servers?.length??0)>=t)return k.toast.error(e("limitation.maxExtensionsReached",{max:t})),!1}catch{}return!0}async function ej(){if(!N.trim())return void k.toast.error(e("plugins.enterRepoUrl"));A(!0),w(null);try{let t=await j.httpClient.getGithubReleases(N);S(t.releases),B(t.owner),z(t.repo),0===t.releases.length?k.toast.warning(e("plugins.noReleasesFound")):g("select_release")}catch(t){console.error("Failed to fetch GitHub releases:",t),w((t instanceof Error?t.message:String(t))||e("plugins.fetchReleasesError")),g("error")}finally{A(!1)}}async function ey(t){L(t),$(!0),w(null);try{let s=await j.httpClient.getGithubReleaseAssets(R,V,t.id);I(s.assets),0===s.assets.length?k.toast.warning(e("plugins.noAssetsFound")):g("select_asset")}catch(t){console.error("Failed to fetch GitHub release assets:",t),w((t instanceof Error?t.message:String(t))||e("plugins.fetchAssetsError")),g("error")}finally{$(!1)}}function eb(e,t){g("installing"),"github"===e?j.httpClient.installPluginFromGithub(t.asset_url,t.owner,t.repo,t.release_tag).then(e=>{eh(e.task_id)}).catch(e=>{w(e.msg),g("error")}):"local"===e?j.httpClient.installPluginFromLocal(t.file).then(e=>{eh(e.task_id)}).catch(e=>{w(e.msg),g("error")}):"marketplace"===e&&j.httpClient.installPluginFromMarketplace(t.plugin_author,t.plugin_name,t.plugin_version).then(e=>{eh(e.task_id)})}let eN=(0,n.useCallback)(async t=>{let s;q?.is_enable&&q?.is_connected?(s=t.name.toLowerCase(),[".lbpkg",".zip"].some(e=>s.endsWith(e)))?await ev()&&(l(!0),g("installing"),w(null),eb("local",{file:t})):k.toast.error(e("plugins.unsupportedFileType")):k.toast.error(e("plugins.pluginSystemNotReady"))},[e,q,eb]),eC=(0,n.useCallback)(async()=>{await ev()&&X.current&&X.current.click()},[]),ek=(0,n.useCallback)(e=>{let t=e.target.files?.[0];t&&eN(t),e.target.value=""},[eN]),e_=q?.is_enable&&q?.is_connected,eS=(0,n.useCallback)(e=>{e.preventDefault(),e_&&W(!0)},[e_]),eE=(0,n.useCallback)(e=>{e.preventDefault(),W(!1)},[]),eT=(0,n.useCallback)(t=>{if(t.preventDefault(),W(!1),!e_)return void k.toast.error(e("plugins.pluginSystemNotReady"));let s=Array.from(t.dataTransfer.files);s.length>0&&eN(s[0])},[eN,e_,e]),eI=async()=>{try{let e=await j.httpClient.getPluginDebugInfo();eo(e),ed(!0)}catch(t){console.error("Failed to fetch debug info:",t),k.toast.error(e("plugins.failedToGetDebugInfo"))}},eD=(e,t)=>{try{navigator.clipboard.writeText(e),"url"===t?(eu(!0),setTimeout(()=>eu(!1),2e3)):(ep(!0),setTimeout(()=>ep(!1),2e3))}catch{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",document.body.appendChild(t),t.select(),t.setSelectionRange(0,99999);let s=document.execCommand("copy");document.body.removeChild(t),s?(eu(!0),setTimeout(()=>eu(!1),2e3)):(ep(!0),setTimeout(()=>ep(!1),2e3))}};return J?(0,r.jsx)("div",{className:"flex flex-col items-center justify-center h-[60vh] pt-[10vh]",children:(0,r.jsx)("p",{className:"text-gray-500 dark:text-gray-400",children:e("plugins.loadingStatus")})}):q?.is_enable?q?.is_connected?(0,r.jsxs)("div",{className:`${F.default.pageContainer} h-full flex flex-col ${Z?"bg-blue-50":""}`,onDragOver:eS,onDragLeave:eE,onDrop:eT,children:[(0,r.jsx)("input",{ref:X,type:"file",accept:".lbpkg,.zip",onChange:ek,style:{display:"none"}}),(0,r.jsxs)(e0.Tabs,{value:t,onValueChange:s,className:"w-full h-full flex flex-col",children:[(0,r.jsxs)("div",{className:"flex flex-row justify-between items-center px-[0.8rem] flex-shrink-0",children:[(0,r.jsxs)(e0.TabsList,{className:"shadow-md py-5 bg-[#f0f0f0] dark:bg-[#2a2a2e]",children:[(0,r.jsx)(e0.TabsTrigger,{value:"installed",className:"px-6 py-4 cursor-pointer",children:e("plugins.installed")}),v.systemInfo.enable_marketplace&&(0,r.jsx)(e0.TabsTrigger,{value:"market",className:"px-6 py-4 cursor-pointer",children:e("plugins.marketplace")}),(0,r.jsx)(e0.TabsTrigger,{value:"mcp-servers",className:"px-6 py-4 cursor-pointer",children:e("mcp.title")})]}),(0,r.jsxs)("div",{className:"flex flex-row justify-end items-center gap-2",children:["installed"===t&&(0,r.jsxs)(te.Popover,{open:ec,onOpenChange:ed,children:[(0,r.jsx)(te.PopoverTrigger,{asChild:!0,children:(0,r.jsxs)(y.Button,{variant:"outline",className:"px-4 py-5 cursor-pointer",onClick:eI,children:[(0,r.jsx)(e8,{className:"w-4 h-4 mr-2"}),e("plugins.debugInfo")]})}),(0,r.jsx)(te.PopoverContent,{className:"w-[380px]",align:"end",children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 pb-2 border-b",children:[(0,r.jsx)(m,{className:"w-4 h-4"}),(0,r.jsx)("h4",{className:"font-semibold text-sm",children:e("plugins.debugInfoTitle")})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("label",{className:"text-sm font-medium whitespace-nowrap min-w-[50px]",children:[e("plugins.debugUrl"),":"]}),(0,r.jsx)(U.Input,{value:ei?.debug_url||"",readOnly:!0,className:"w-[220px] font-mono text-xs h-8"}),(0,r.jsx)(y.Button,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>eD(ei?.debug_url||"","url"),children:em?(0,r.jsx)(e3.Check,{className:"w-3.5 h-3.5 text-green-600"}):(0,r.jsx)(e9.Copy,{className:"w-3.5 h-3.5"})})]}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("label",{className:"text-sm font-medium whitespace-nowrap min-w-[50px]",children:[e("plugins.debugKey"),":"]}),(0,r.jsx)(U.Input,{value:ei?.plugin_debug_key||e("plugins.noDebugKey"),readOnly:!0,className:"w-[220px] font-mono text-xs h-8"}),(0,r.jsx)(y.Button,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>eD(ei?.plugin_debug_key||"","key"),disabled:!ei?.plugin_debug_key,children:ex?(0,r.jsx)(e3.Check,{className:"w-3.5 h-3.5 text-green-600"}):(0,r.jsx)(e9.Copy,{className:"w-3.5 h-3.5"})})]}),!ei?.plugin_debug_key&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground ml-[58px]",children:e("plugins.debugKeyDisabled")})]})]})})]}),(0,r.jsxs)(b.DropdownMenu,{children:[(0,r.jsx)(b.DropdownMenuTrigger,{asChild:!0,children:(0,r.jsxs)(y.Button,{variant:"default",className:"px-6 py-4 cursor-pointer",children:[(0,r.jsx)(e1.default,{className:"w-4 h-4"}),"mcp-servers"===t?e("mcp.add"):e("plugins.install"),(0,r.jsx)(e2.ChevronDownIcon,{className:"ml-2 w-4 h-4"})]})}),(0,r.jsx)(b.DropdownMenuContent,{align:"end",children:"mcp-servers"===t?(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(b.DropdownMenuItem,{onClick:async()=>{await ev()&&(s("mcp-servers"),el(!1),es(null),p(!0))},children:[(0,r.jsx)(e1.default,{className:"w-4 h-4"}),e("mcp.createServer")]})}):(0,r.jsxs)(r.Fragment,{children:[v.systemInfo.enable_marketplace&&(0,r.jsxs)(b.DropdownMenuItem,{onClick:()=>{s("market")},children:[(0,r.jsx)(e4,{className:"w-4 h-4"}),e("plugins.marketplace")]}),(0,r.jsxs)(b.DropdownMenuItem,{onClick:eC,children:[(0,r.jsx)(e5,{className:"w-4 h-4"}),e("plugins.uploadLocal")]}),(0,r.jsxs)(b.DropdownMenuItem,{onClick:async()=>{await ev()&&(o("github"),g("wait_input"),w(null),ef(),l(!0))},children:[(0,r.jsx)(e6,{className:"w-4 h-4"}),e("plugins.installFromGithub")]})]})})]})]})]}),(0,r.jsx)(e0.TabsContent,{value:"installed",className:"flex-1 overflow-y-auto mt-0",children:(0,r.jsx)(O,{ref:eg})}),(0,r.jsx)(e0.TabsContent,{value:"market",className:"flex-1 overflow-y-auto mt-0",children:(0,r.jsx)(eF,{installPlugin:async e=>{await ev()&&(o("marketplace"),u({plugin_author:e.author,plugin_name:e.name,plugin_version:e.latest_version}),g("ask_confirm"),l(!0))}})}),(0,r.jsx)(e0.TabsContent,{value:"mcp-servers",className:"flex-1 overflow-y-auto mt-0",children:(0,r.jsx)(eG,{onEditServer:e=>{es(e),el(!0),p(!0)}},er)})]}),(0,r.jsx)(P.Dialog,{open:a,onOpenChange:e=>{l(e),e||(ef(),w(null))},children:(0,r.jsxs)(P.DialogContent,{className:"w-[500px] max-h-[80vh] p-6 bg-white dark:bg-[#1a1a1e] overflow-y-auto",children:[(0,r.jsx)(P.DialogHeader,{children:(0,r.jsxs)(P.DialogTitle,{className:"flex items-center gap-4",children:["github"===i?(0,r.jsx)(e6,{className:"size-6"}):(0,r.jsx)(ew.Download,{className:"size-6"}),(0,r.jsx)("span",{children:e("plugins.installPlugin")})]})}),"github"===i&&"wait_input"===h&&(0,r.jsxs)("div",{className:"mt-4",children:[(0,r.jsx)("p",{className:"mb-2",children:e("plugins.enterRepoUrl")}),(0,r.jsx)(U.Input,{placeholder:e("plugins.repoUrlPlaceholder"),value:N,onChange:e=>C(e.target.value),className:"mb-4"}),H&&(0,r.jsx)("p",{className:"text-sm text-gray-500",children:e("plugins.fetchingReleases")})]}),"github"===i&&"select_release"===h&&(0,r.jsxs)("div",{className:"mt-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsx)("p",{className:"font-medium",children:e("plugins.selectRelease")}),(0,r.jsxs)(y.Button,{variant:"ghost",size:"sm",onClick:()=>{g("wait_input"),S([])},children:[(0,r.jsx)(eL,{className:"w-4 h-4 mr-1"}),e("plugins.backToRepoUrl")]})]}),(0,r.jsx)("div",{className:"max-h-[400px] overflow-y-auto space-y-2 pb-2",children:_.map(t=>(0,r.jsx)(eq.Card,{className:"cursor-pointer hover:shadow-sm transition-shadow duration-200 shadow-none py-4",onClick:()=>ey(t),children:(0,r.jsxs)(eq.CardHeader,{className:"flex flex-row items-start justify-between px-3 space-y-0",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)(eq.CardTitle,{className:"text-sm",children:t.name||t.tag_name}),(0,r.jsxs)(eq.CardDescription,{className:"text-xs mt-1",children:[e("plugins.releaseTag",{tag:t.tag_name})," ","•"," ",e("plugins.publishedAt",{date:new Date(t.published_at).toLocaleDateString()})]})]}),t.prerelease&&(0,r.jsx)("span",{className:"text-xs bg-yellow-100 dark:bg-yellow-900 text-yellow-800 dark:text-yellow-200 px-2 py-0.5 rounded ml-2 shrink-0",children:e("plugins.prerelease")})]})},t.id))}),G&&(0,r.jsx)("p",{className:"text-sm text-gray-500 mt-4",children:e("plugins.loading")})]}),"github"===i&&"select_asset"===h&&(0,r.jsxs)("div",{className:"mt-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsx)("p",{className:"font-medium",children:e("plugins.selectAsset")}),(0,r.jsxs)(y.Button,{variant:"ghost",size:"sm",onClick:()=>{g("select_release"),I([]),M(null)},children:[(0,r.jsx)(eL,{className:"w-4 h-4 mr-1"}),e("plugins.backToReleases")]})]}),E&&(0,r.jsxs)("div",{className:"mb-4 p-2 bg-gray-50 dark:bg-gray-900 rounded",children:[(0,r.jsx)("div",{className:"text-sm font-medium",children:E.name||E.tag_name}),(0,r.jsx)("div",{className:"text-xs text-gray-500",children:E.tag_name})]}),(0,r.jsx)("div",{className:"max-h-[400px] overflow-y-auto space-y-2 pb-2",children:T.map(t=>(0,r.jsx)(eq.Card,{className:"cursor-pointer hover:shadow-sm transition-shadow duration-200 shadow-none py-3",onClick:()=>{M(t),g("ask_confirm")},children:(0,r.jsxs)(eq.CardHeader,{className:"px-3",children:[(0,r.jsx)(eq.CardTitle,{className:"text-sm",children:t.name}),(0,r.jsx)(eq.CardDescription,{className:"text-xs",children:e("plugins.assetSize",{size:function(e){if(0===e)return"0 Bytes";let t=Math.floor(Math.log(e)/Math.log(1024));return Math.round(e/Math.pow(1024,t)*100)/100+" "+["Bytes","KB","MB","GB"][t]}(t.size)})})]})},t.id))})]}),"marketplace"===i&&"ask_confirm"===h&&(0,r.jsx)("div",{className:"mt-4",children:(0,r.jsx)("p",{className:"mb-2",children:e("plugins.askConfirm",{name:d.plugin_name,version:d.plugin_version})})}),"github"===i&&"ask_confirm"===h&&(0,r.jsxs)("div",{className:"mt-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsx)("p",{className:"font-medium",children:e("plugins.confirmInstall")}),(0,r.jsxs)(y.Button,{variant:"ghost",size:"sm",onClick:()=>{g("select_asset"),M(null)},children:[(0,r.jsx)(eL,{className:"w-4 h-4 mr-1"}),e("plugins.backToAssets")]})]}),E&&D&&(0,r.jsxs)("div",{className:"p-3 bg-gray-50 dark:bg-gray-900 rounded space-y-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-sm font-medium",children:"Repository: "}),(0,r.jsxs)("span",{className:"text-sm",children:[R,"/",V]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-sm font-medium",children:"Release: "}),(0,r.jsx)("span",{className:"text-sm",children:E.tag_name})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-sm font-medium",children:"File: "}),(0,r.jsx)("span",{className:"text-sm",children:D.name})]})]})]}),"installing"===h&&(0,r.jsx)("div",{className:"mt-4",children:(0,r.jsx)("p",{className:"mb-2",children:e("plugins.installing")})}),"error"===h&&(0,r.jsxs)("div",{className:"mt-4",children:[(0,r.jsx)("p",{className:"mb-2",children:e("plugins.installFailed")}),(0,r.jsx)("p",{className:"mb-2 text-red-500",children:f})]}),(0,r.jsxs)(P.DialogFooter,{children:["wait_input"===h&&"github"===i&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(y.Button,{variant:"outline",onClick:()=>{l(!1),ef()},children:e("common.cancel")}),(0,r.jsx)(y.Button,{onClick:ej,disabled:!N.trim()||H,children:H?e("plugins.loading"):e("common.confirm")})]}),"ask_confirm"===h&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(y.Button,{variant:"outline",onClick:()=>l(!1),children:e("common.cancel")}),(0,r.jsx)(y.Button,{onClick:()=>void("github"===i&&D&&E?eb("github",{asset_url:D.download_url,owner:R,repo:V,release_tag:E.tag_name}):eb(i,d)),children:e("common.confirm")})]}),"error"===h&&(0,r.jsx)(y.Button,{variant:"default",onClick:()=>l(!1),children:e("common.close")})]})]})}),Z&&(0,r.jsx)("div",{className:"fixed inset-0 bg-gray-500 bg-opacity-50 flex items-center justify-center z-50 pointer-events-none",children:(0,r.jsx)("div",{className:"bg-white rounded-lg p-8 shadow-lg border-2 border-dashed border-gray-500",children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)(e5,{className:"mx-auto h-12 w-12 text-gray-500 mb-4"}),(0,r.jsx)("p",{className:"text-lg font-medium text-gray-700",children:e("plugins.dragToUpload")})]})})}),(0,r.jsx)(eX,{open:x,onOpenChange:p,serverName:et,isEditMode:ea,onSuccess:()=>{es(null),el(!1),en(e=>e+1)},onDelete:()=>{ee(!0)}}),(0,r.jsx)(eY,{open:Y,onOpenChange:ee,serverName:et,onSuccess:()=>{p(!1),es(null),el(!1),en(e=>e+1)}})]}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center h-[60vh] text-center pt-[10vh]",children:[(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"72",height:"72",fill:"#BDBDBD",children:(0,r.jsx)("path",{d:"M17.657 14.8284L16.2428 13.4142L17.657 12C19.2191 10.4379 19.2191 7.90526 17.657 6.34316C16.0949 4.78106 13.5622 4.78106 12.0001 6.34316L10.5859 7.75737L9.17171 6.34316L10.5859 4.92895C12.9291 2.5858 16.7281 2.5858 19.0712 4.92895C21.4143 7.27209 21.4143 11.0711 19.0712 13.4142L17.657 14.8284ZM14.8286 17.6569L13.4143 19.0711C11.0712 21.4142 7.27221 21.4142 4.92907 19.0711C2.58592 16.7279 2.58592 12.9289 4.92907 10.5858L6.34328 9.17159L7.75749 10.5858L6.34328 12C4.78118 13.5621 4.78118 16.0948 6.34328 17.6569C7.90538 19.219 10.438 19.219 12.0001 17.6569L13.4143 16.2427L14.8286 17.6569ZM14.8286 7.75737L16.2428 9.17159L9.17171 16.2427L7.75749 14.8284L14.8286 7.75737ZM5.77539 2.29291L7.70724 1.77527L8.74252 5.63897L6.81067 6.15661L5.77539 2.29291ZM15.2578 18.3611L17.1896 17.8434L18.2249 21.7071L16.293 22.2248L15.2578 18.3611ZM2.29303 5.77527L6.15673 6.81054L5.63909 8.7424L1.77539 7.70712L2.29303 5.77527ZM18.3612 15.2576L22.2249 16.2929L21.7072 18.2248L17.8435 17.1895L18.3612 15.2576Z"})}),(0,r.jsx)("h2",{className:"text-2xl font-semibold text-gray-700 dark:text-gray-300 mb-2",children:e("plugins.connectionError")}),(0,r.jsx)("p",{className:"text-gray-500 dark:text-gray-400 max-w-md mb-4",children:e("plugins.connectionErrorDesc")})]}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center h-[60vh] text-center pt-[10vh]",children:[(0,r.jsx)(e7,{className:"w-16 h-16 text-gray-400 mb-4"}),(0,r.jsx)("h2",{className:"text-2xl font-semibold text-gray-700 dark:text-gray-300 mb-2",children:e("plugins.systemDisabled")}),(0,r.jsx)("p",{className:"text-gray-500 dark:text-gray-400 max-w-md",children:e("plugins.systemDisabledDesc")})]})}e.s(["default",()=>ts],35948)}]);