@samanhappy/mcphub 0.12.16 → 0.12.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/index.js +9 -9
- package/dist/config/index.js.map +1 -1
- package/dist/middlewares/userContext.js +17 -2
- package/dist/middlewares/userContext.js.map +1 -1
- package/dist/services/mcpService.js +7 -2
- package/dist/services/mcpService.js.map +1 -1
- package/dist/services/vectorSearchService.js +5 -1
- package/dist/services/vectorSearchService.js.map +1 -1
- package/frontend/dist/assets/ActivityPage-ClgKeihP.js +2 -0
- package/frontend/dist/assets/ActivityPage-ClgKeihP.js.map +1 -0
- package/frontend/dist/assets/Badge-Ck2fhRdl.js +2 -0
- package/frontend/dist/assets/Badge-Ck2fhRdl.js.map +1 -0
- package/frontend/dist/assets/ConfirmDialog-uYjffH4V.js +2 -0
- package/frontend/dist/assets/ConfirmDialog-uYjffH4V.js.map +1 -0
- package/frontend/dist/assets/Dashboard-BIXrLobn.js +2 -0
- package/frontend/dist/assets/Dashboard-BIXrLobn.js.map +1 -0
- package/frontend/dist/assets/DeleteDialog-BAfrV8EB.js +2 -0
- package/frontend/dist/assets/DeleteDialog-BAfrV8EB.js.map +1 -0
- package/frontend/dist/assets/GroupsPage-BjrvyHwu.js +33 -0
- package/frontend/dist/assets/GroupsPage-BjrvyHwu.js.map +1 -0
- package/frontend/dist/assets/LoginPage-BBHt_TfF.js +2 -0
- package/frontend/dist/assets/LoginPage-BBHt_TfF.js.map +1 -0
- package/frontend/dist/assets/LogsPage-D8Znq5NB.js +2 -0
- package/frontend/dist/assets/LogsPage-D8Znq5NB.js.map +1 -0
- package/frontend/dist/assets/MarketPage-haRuzjCw.js +3 -0
- package/frontend/dist/assets/MarketPage-haRuzjCw.js.map +1 -0
- package/frontend/dist/assets/Pagination-y-gVO8ms.js +2 -0
- package/frontend/dist/assets/Pagination-y-gVO8ms.js.map +1 -0
- package/frontend/dist/assets/PromptsPage-ByHWPyGe.js +2 -0
- package/frontend/dist/assets/PromptsPage-ByHWPyGe.js.map +1 -0
- package/frontend/dist/assets/ResourcesPage-Bodw5OY9.js +2 -0
- package/frontend/dist/assets/ResourcesPage-Bodw5OY9.js.map +1 -0
- package/frontend/dist/assets/ServersPage-CtS1I4yS.js +37 -0
- package/frontend/dist/assets/ServersPage-CtS1I4yS.js.map +1 -0
- package/frontend/dist/assets/SettingsPage-DxVigf7p.js +12 -0
- package/frontend/dist/assets/SettingsPage-DxVigf7p.js.map +1 -0
- package/frontend/dist/assets/ToggleGroup-HfxdlkGi.js +2 -0
- package/frontend/dist/assets/ToggleGroup-HfxdlkGi.js.map +1 -0
- package/frontend/dist/assets/UsersPage-Bipw33cS.js +2 -0
- package/frontend/dist/assets/UsersPage-Bipw33cS.js.map +1 -0
- package/frontend/dist/assets/framework-vendor-_OBebcuv.js +61 -0
- package/frontend/dist/assets/framework-vendor-_OBebcuv.js.map +1 -0
- package/frontend/dist/assets/i18n-vendor-MQ921plD.js +2 -0
- package/frontend/dist/assets/i18n-vendor-MQ921plD.js.map +1 -0
- package/frontend/dist/assets/icons-vendor-B67NtVuR.js +172 -0
- package/frontend/dist/assets/icons-vendor-B67NtVuR.js.map +1 -0
- package/frontend/dist/assets/index-CmnA4an8.js +5 -0
- package/frontend/dist/assets/index-CmnA4an8.js.map +1 -0
- package/frontend/dist/assets/index-DfFHVARX.css +1 -0
- package/frontend/dist/assets/resourceService-BfCTSBsr.js +2 -0
- package/frontend/dist/assets/{resourceService-CUz722Nb.js.map → resourceService-BfCTSBsr.js.map} +1 -1
- package/frontend/dist/assets/useGroupData-DLhbP6zd.js +2 -0
- package/frontend/dist/assets/useGroupData-DLhbP6zd.js.map +1 -0
- package/frontend/dist/assets/useServerData-QZqQTYcv.js +2 -0
- package/frontend/dist/assets/useServerData-QZqQTYcv.js.map +1 -0
- package/frontend/dist/assets/useSettingsData-D3VROqS7.js +2 -0
- package/frontend/dist/assets/useSettingsData-D3VROqS7.js.map +1 -0
- package/frontend/dist/assets/variableDetection-C3Xi21av.js +16 -0
- package/frontend/dist/assets/variableDetection-C3Xi21av.js.map +1 -0
- package/frontend/dist/index.html +5 -2
- package/package.json +2 -2
- package/frontend/dist/assets/index-CVDuCISB.js +0 -323
- package/frontend/dist/assets/index-CVDuCISB.js.map +0 -1
- package/frontend/dist/assets/index-PEyR1nSL.css +0 -1
- package/frontend/dist/assets/resourceService-CUz722Nb.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{j as t}from"./framework-vendor-_OBebcuv.js";import{u as l}from"./i18n-vendor-MQ921plD.js";const c=({currentPage:s,totalPages:r,onPageChange:e,disabled:a=!1})=>{const{t:x}=l(),y=()=>{const n=[];n.push(t.jsx("button",{onClick:()=>e(1),className:`px-3 py-1 mx-1 rounded ${s===1?"bg-blue-500 text-white btn-primary":"bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary"}`,children:"1"},"first"));const o=Math.max(2,s-Math.floor(5/2));o>2&&n.push(t.jsx("span",{className:"px-3 py-1",children:"..."},"ellipsis1"));for(let i=o;i<=Math.min(r-1,o+5-3);i++)n.push(t.jsx("button",{onClick:()=>e(i),className:`px-3 py-1 mx-1 rounded ${s===i?"bg-blue-500 text-white btn-primary":"bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary"}`,children:i},i));return o+5-3<r-1&&n.push(t.jsx("span",{className:"px-3 py-1",children:"..."},"ellipsis2")),r>1&&n.push(t.jsx("button",{onClick:()=>e(r),className:`px-3 py-1 mx-1 rounded ${s===r?"bg-blue-500 text-white btn-primary":"bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary"}`,children:r},"last")),n};return r<=1?null:t.jsxs("div",{className:"flex justify-center items-center my-6",children:[t.jsxs("button",{onClick:()=>e(Math.max(1,s-1)),disabled:a||s===1,className:`px-3 py-1 rounded mr-2 ${a||s===1?"bg-gray-100 text-gray-400 cursor-not-allowed":"bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary"}`,children:["« ",x("common.previous")]}),t.jsx("div",{className:"flex",children:y()}),t.jsxs("button",{onClick:()=>e(Math.min(r,s+1)),disabled:a||s===r,className:`px-3 py-1 rounded ml-2 ${a||s===r?"bg-gray-100 text-gray-400 cursor-not-allowed":"bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary"}`,children:[x("common.next")," »"]})]})};export{c as P};
|
|
2
|
+
//# sourceMappingURL=Pagination-y-gVO8ms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pagination-y-gVO8ms.js","sources":["../../src/components/ui/Pagination.tsx"],"sourcesContent":["import React from 'react';\nimport { useTranslation } from 'react-i18next';\n\ninterface PaginationProps {\n currentPage: number;\n totalPages: number;\n onPageChange: (page: number) => void;\n disabled?: boolean;\n}\n\nconst Pagination: React.FC<PaginationProps> = ({\n currentPage,\n totalPages,\n onPageChange,\n disabled = false\n}) => {\n const { t } = useTranslation();\n // Generate page buttons\n const getPageButtons = () => {\n const buttons = [];\n const maxDisplayedPages = 5; // Maximum number of page buttons to display\n\n // Always display first page\n buttons.push(\n <button\n key=\"first\"\n onClick={() => onPageChange(1)}\n className={`px-3 py-1 mx-1 rounded ${currentPage === 1\n ? 'bg-blue-500 text-white btn-primary'\n : 'bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary'\n }`}\n >\n 1\n </button>\n );\n\n // Start range\n const startPage = Math.max(2, currentPage - Math.floor(maxDisplayedPages / 2));\n\n // If we're showing ellipsis after first page\n if (startPage > 2) {\n buttons.push(\n <span key=\"ellipsis1\" className=\"px-3 py-1\">\n ...\n </span>\n );\n }\n\n // Middle pages\n for (let i = startPage; i <= Math.min(totalPages - 1, startPage + maxDisplayedPages - 3); i++) {\n buttons.push(\n <button\n key={i}\n onClick={() => onPageChange(i)}\n className={`px-3 py-1 mx-1 rounded ${currentPage === i\n ? 'bg-blue-500 text-white btn-primary'\n : 'bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary'\n }`}\n >\n {i}\n </button>\n );\n }\n\n // If we're showing ellipsis before last page\n if (startPage + maxDisplayedPages - 3 < totalPages - 1) {\n buttons.push(\n <span key=\"ellipsis2\" className=\"px-3 py-1\">\n ...\n </span>\n );\n }\n\n // Always display last page if there's more than one page\n if (totalPages > 1) {\n buttons.push(\n <button\n key=\"last\"\n onClick={() => onPageChange(totalPages)}\n className={`px-3 py-1 mx-1 rounded ${currentPage === totalPages\n ? 'bg-blue-500 text-white btn-primary'\n : 'bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary'\n }`}\n >\n {totalPages}\n </button>\n );\n }\n\n return buttons;\n };\n\n // If there's only one page, don't render pagination\n if (totalPages <= 1) {\n return null;\n }\n\n return (\n <div className=\"flex justify-center items-center my-6\">\n <button\n onClick={() => onPageChange(Math.max(1, currentPage - 1))}\n disabled={disabled || currentPage === 1}\n className={`px-3 py-1 rounded mr-2 ${disabled || currentPage === 1\n ? 'bg-gray-100 text-gray-400 cursor-not-allowed'\n : 'bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary'\n }`}\n >\n « {t('common.previous')}\n </button>\n\n <div className=\"flex\">{getPageButtons()}</div>\n\n <button\n onClick={() => onPageChange(Math.min(totalPages, currentPage + 1))}\n disabled={disabled || currentPage === totalPages}\n className={`px-3 py-1 rounded ml-2 ${disabled || currentPage === totalPages\n ? 'bg-gray-100 text-gray-400 cursor-not-allowed'\n : 'bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary'\n }`}\n >\n {t('common.next')} »\n </button>\n </div>\n );\n};\n\nexport default Pagination;"],"names":["Pagination","currentPage","totalPages","onPageChange","disabled","t","useTranslation","getPageButtons","buttons","jsx","startPage","jsxs"],"mappings":"iGAUA,MAAMA,EAAwC,CAAC,CAC7C,YAAAC,EACA,WAAAC,EACA,aAAAC,EACA,SAAAC,EAAW,EACb,IAAM,CACJ,KAAM,CAAE,EAAAC,CAAA,EAAMC,EAAA,EAERC,EAAiB,IAAM,CAC3B,MAAMC,EAAU,CAAA,EAIhBA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AA,CACC,QAAS,IAAMR,EAAa,KAAK,IAAID,EAAYD,EAAc,CAAC,CAAC,EACjE,SAAUG,GAAYH,IAAgBC,EACtC,UAAW,0BAA0BE,GAAYH,IAAgBC,EAC7D,+CACA,2DACF,GAED,SAAA,CAAAG,EAAE,aAAa,EAAE,IAAA,CAAA,CAAA,CACpB,EACF,CAEJ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as o,j as e}from"./framework-vendor-_OBebcuv.js";import{i as T,e as $,f as I,d as H,u as K}from"./index-CmnA4an8.js";import{u as z}from"./i18n-vendor-MQ921plD.js";import{C as M}from"./ConfirmDialog-uYjffH4V.js";import{o as F,X as R,b as A,h as W,T as G,p as L,j as O}from"./icons-vendor-B67NtVuR.js";const U=async()=>{const t=await T("/prompts");if(!t.success)throw new Error(t.message||"Failed to fetch built-in prompts");return t.data||[]},V=async t=>{const c=await H("/prompts",t);if(!c.success)throw new Error(c.message||"Failed to create built-in prompt");return c.data},X=async(t,c)=>{const g=await I(`/prompts/${t}`,c);if(!g.success)throw new Error(g.message||"Failed to update built-in prompt");return g.data},_=async t=>{const c=await $(`/prompts/${t}`);if(!c.success)throw new Error(c.message||"Failed to delete built-in prompt")},J=()=>{const{t}=z(),[c,g]=o.useState([]),[r,y]=o.useState(!0),[h,l]=o.useState(null),[N,k]=o.useState(0),w=o.useCallback(async()=>{try{y(!0);const i=await U();g(i),l(null)}catch(i){console.error("Error fetching built-in prompts:",i),l(i instanceof Error?i.message:t("builtinPrompts.fetchError")),g([])}finally{y(!1)}},[t]),x=o.useCallback(()=>{k(i=>i+1)},[]),p=async i=>{try{const u=await V(i);return x(),{success:!0,data:u}}catch(u){const d=u instanceof Error?u.message:t("builtinPrompts.createError");return l(d),{success:!1,message:d}}},f=async(i,u)=>{try{const d=await X(i,u);return x(),{success:!0,data:d}}catch(d){const j=d instanceof Error?d.message:t("builtinPrompts.updateError");return l(j),{success:!1,message:j}}},b=async i=>{try{return await _(i),x(),{success:!0}}catch(u){const d=u instanceof Error?u.message:t("builtinPrompts.deleteError");return l(d),{success:!1,message:d}}};return o.useEffect(()=>{w()},[w,N]),{prompts:c,loading:r,error:h,setError:l,triggerRefresh:x,addPrompt:p,editPrompt:f,removePrompt:b}},D=({prompt:t,onSave:c,onCancel:g})=>{const{t:r}=z(),[y,h]=o.useState(null),[l,N]=o.useState(!1),[k,w]=o.useState((t==null?void 0:t.name)||""),[x,p]=o.useState((t==null?void 0:t.title)||""),[f,b]=o.useState((t==null?void 0:t.description)||""),[i,u]=o.useState((t==null?void 0:t.template)||""),[d,j]=o.useState((t==null?void 0:t.enabled)!==!1),[v,C]=o.useState((t==null?void 0:t.arguments)||[]),E=()=>{C([...v,{name:"",description:"",required:!1}])},S=s=>{C(v.filter((a,m)=>m!==s))},P=(s,a,m)=>{C(v.map((q,B)=>B===s?{...q,[a]:m}:q))},n=async s=>{if(s.preventDefault(),h(null),!k.trim()){h(r("builtinPrompts.nameRequired"));return}if(!i.trim()){h(r("builtinPrompts.templateRequired"));return}N(!0);try{const a=await c({name:k.trim(),title:x.trim()||void 0,description:f.trim()||void 0,template:i,arguments:v.length>0?v.filter(m=>m.name.trim()):void 0,enabled:d});a.success||h(a.message||r("builtinPrompts.saveError"))}catch(a){h(a instanceof Error?a.message:r("builtinPrompts.saveError"))}finally{N(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 p-8 rounded-xl shadow-2xl max-w-3xl w-full mx-4 border border-gray-100 dark:border-gray-700 max-h-[90vh] overflow-y-auto",children:e.jsxs("form",{onSubmit:n,children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900 dark:text-gray-100 mb-6",children:r(t?"builtinPrompts.edit":"builtinPrompts.addNew")}),y&&e.jsx("div",{className:"bg-red-50 border-l-4 border-red-500 text-red-700 p-4 mb-6 rounded-md",children:e.jsx("p",{className:"text-sm font-medium",children:y})}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[r("builtinPrompts.name")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:k,onChange:s=>w(s.target.value),placeholder:r("builtinPrompts.namePlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",required:!0,disabled:l})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:r("builtinPrompts.title")}),e.jsx("input",{type:"text",value:x,onChange:s=>p(s.target.value),placeholder:r("builtinPrompts.titlePlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",disabled:l})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:r("builtinPrompts.description")}),e.jsx("input",{type:"text",value:f,onChange:s=>b(s.target.value),placeholder:r("builtinPrompts.descriptionPlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",disabled:l})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[r("builtinPrompts.template")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("textarea",{value:i,onChange:s=>u(s.target.value),placeholder:r("builtinPrompts.templatePlaceholder"),rows:6,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 font-mono text-sm transition-all duration-200",required:!0,disabled:l}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:r("builtinPrompts.templateHint")})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:r("builtinPrompts.arguments")}),e.jsxs("button",{type:"button",onClick:E,className:"text-blue-600 hover:text-blue-800 text-sm flex items-center",disabled:l,children:[e.jsx(F,{size:14,className:"mr-1"}),r("builtinPrompts.addArgument")]})]}),v.map((s,a)=>e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[e.jsx("input",{type:"text",value:s.name,onChange:m=>P(a,"name",m.target.value),placeholder:r("builtinPrompts.argName"),className:"flex-1 px-3 py-1.5 border border-gray-300 dark:border-gray-600 rounded-lg text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500",disabled:l}),e.jsx("input",{type:"text",value:s.description||"",onChange:m=>P(a,"description",m.target.value),placeholder:r("builtinPrompts.argDescription"),className:"flex-1 px-3 py-1.5 border border-gray-300 dark:border-gray-600 rounded-lg text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500",disabled:l}),e.jsxs("label",{className:"flex items-center text-sm text-gray-600 dark:text-gray-400 whitespace-nowrap",children:[e.jsx("input",{type:"checkbox",checked:s.required||!1,onChange:m=>P(a,"required",m.target.checked),className:"mr-1",disabled:l}),r("builtinPrompts.argRequired")]}),e.jsx("button",{type:"button",onClick:()=>S(a),className:"text-red-500 hover:text-red-700 p-1",disabled:l,children:e.jsx(R,{size:16})})]},a))]}),e.jsxs("div",{className:"flex items-center pt-2",children:[e.jsx("input",{type:"checkbox",id:"enabled",checked:d,onChange:s=>j(s.target.checked),className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500",disabled:l}),e.jsx("label",{htmlFor:"enabled",className:"ml-2 block text-sm text-gray-700 dark:text-gray-300",children:r("builtinPrompts.enabled")})]})]}),e.jsxs("div",{className:"flex justify-end space-x-3 mt-8",children:[e.jsx("button",{type:"button",onClick:g,className:"px-4 py-2 text-gray-600 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200 btn-secondary",disabled:l,children:r("common.cancel")}),e.jsx("button",{type:"submit",disabled:l,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 btn-primary transition-all duration-200 shadow-sm disabled:opacity-50",children:r(l?"common.saving":"common.save")})]})]})})})},se=()=>{var P;const{t}=z(),{auth:c}=K(),{prompts:g,loading:r,error:y,setError:h,addPrompt:l,editPrompt:N,removePrompt:k}=J(),[w,x]=o.useState(!1),[p,f]=o.useState(null),[b,i]=o.useState(null),[u,d]=o.useState(new Set),j=(P=c.user)==null?void 0:P.isAdmin,v=n=>{d(s=>{const a=new Set(s);return a.has(n)?a.delete(n):a.add(n),a})},C=async n=>{const s=await l(n);return s.success&&x(!1),s},E=async n=>{if(!p)return{success:!1,message:"No prompt selected"};const s=await N(p.id,n);return s.success&&f(null),s},S=async()=>{b&&(await k(b.id),i(null))};return e.jsxs("div",{className:"container mx-auto",children:[e.jsxs("div",{className:"flex justify-between items-center mb-8",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:t("pages.prompts.title")}),j&&e.jsxs("button",{onClick:()=>x(!0),className:"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 flex items-center btn-primary transition-all duration-200 shadow-sm",children:[e.jsx(F,{size:16,className:"mr-2"}),t("builtinPrompts.add")]})]}),y&&e.jsx("div",{className:"bg-red-50 border-l-4 border-red-500 text-red-700 p-4 mb-6 error-box rounded-lg shadow-sm",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("p",{children:y}),e.jsx("button",{onClick:()=>h(null),className:"text-red-500 hover:text-red-700",children:e.jsx(R,{size:20})})]})}),r?e.jsx("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 loading-container flex justify-center items-center h-64",children:e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsxs("svg",{className:"animate-spin h-10 w-10 text-blue-500 mb-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.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"})]}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:t("app.loading")})]})}):g.length===0?e.jsx("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 empty-state dashboard-card",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"p-4 bg-gray-100 dark:bg-gray-700 rounded-full mb-4",children:e.jsx(A,{className:"h-8 w-8 text-gray-400"})}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 text-lg font-medium",children:t("builtinPrompts.noPrompts")}),j&&e.jsx("button",{onClick:()=>x(!0),className:"mt-4 text-blue-600 hover:text-blue-800 font-medium",children:t("builtinPrompts.addFirst")})]})}):e.jsx("div",{className:"space-y-3",children:g.map(n=>{const s=u.has(n.id);return e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg overflow-hidden dashboard-card",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 cursor-pointer hover:bg-gray-50 dark:bg-gray-800 dark:hover:bg-gray-700",onClick:()=>v(n.id),children:[e.jsxs("div",{className:"flex items-center flex-1 min-w-0",children:[e.jsx(A,{size:18,className:`mr-3 flex-shrink-0 ${n.enabled!==!1?"text-blue-500":"text-gray-400"}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100 truncate",children:n.title||n.name}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:n.name}),e.jsx("span",{className:`px-2 py-0.5 text-xs rounded-full ${n.enabled!==!1?"bg-green-100 text-green-800 border border-green-200":"bg-gray-100 text-gray-600 border border-gray-200"}`,children:n.enabled!==!1?t("builtinPrompts.active"):t("builtinPrompts.inactive")})]}),n.description&&e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-0.5 truncate",children:n.description})]})]}),e.jsxs("div",{className:"flex items-center ml-4 gap-2",children:[j&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:a=>{a.stopPropagation(),f(n)},className:"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-1 rounded hover:bg-blue-50 dark:hover:bg-blue-900/40 transition-colors",title:t("builtinPrompts.edit"),children:e.jsx(W,{size:18})}),e.jsx("button",{onClick:a=>{a.stopPropagation(),i(n)},className:"text-red-600 dark:text-red-400 hover:text-red-900 dark:hover:text-red-300 p-1 rounded hover:bg-red-50 dark:hover:bg-red-900/40 transition-colors",title:t("builtinPrompts.delete"),children:e.jsx(G,{size:18})})]}),s?e.jsx(L,{size:18,className:"text-gray-400"}):e.jsx(O,{size:18,className:"text-gray-400"})]})]}),s&&e.jsxs("div",{className:"px-6 pb-4 border-t border-gray-100 dark:border-gray-700",children:[e.jsxs("div",{className:"mt-3",children:[e.jsx("h4",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase mb-1",children:t("builtinPrompts.template")}),e.jsx("pre",{className:"text-sm text-gray-800 dark:text-gray-200 bg-gray-50 dark:bg-gray-900 rounded p-3 overflow-x-auto whitespace-pre-wrap font-mono",children:n.template})]}),n.arguments&&n.arguments.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("h4",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase mb-1",children:t("builtinPrompts.arguments")}),e.jsx("div",{className:"space-y-1",children:n.arguments.map((a,m)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("code",{className:"px-1.5 py-0.5 bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 rounded text-xs font-mono",children:"{{"+a.name+"}}"}),a.required&&e.jsx("span",{className:"text-red-500 text-xs",children:"*"}),a.description&&e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 text-xs",children:["— ",a.description]})]},m))})]})]})]},n.id)})}),w&&e.jsx(D,{onSave:C,onCancel:()=>x(!1)}),p&&e.jsx(D,{prompt:p,onSave:E,onCancel:()=>f(null)}),e.jsx(M,{isOpen:!!b,onClose:()=>i(null),onConfirm:S,title:t("builtinPrompts.confirmDelete"),message:t("builtinPrompts.deleteWarning",{name:(b==null?void 0:b.name)||""}),variant:"danger"})]})};export{se as default};
|
|
2
|
+
//# sourceMappingURL=PromptsPage-ByHWPyGe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromptsPage-ByHWPyGe.js","sources":["../../src/services/builtinPromptService.ts","../../src/hooks/useBuiltinPromptData.ts","../../src/pages/PromptsPage.tsx"],"sourcesContent":["import { BuiltinPrompt, ApiResponse } from '@/types';\nimport { apiGet, apiPost, apiPut, apiDelete } from '../utils/fetchInterceptor';\n\n/**\n * Get all built-in prompts\n */\nexport const getBuiltinPrompts = async (): Promise<BuiltinPrompt[]> => {\n const response: ApiResponse<BuiltinPrompt[]> = await apiGet('/prompts');\n if (!response.success) {\n throw new Error(response.message || 'Failed to fetch built-in prompts');\n }\n return response.data || [];\n};\n\n/**\n * Get a single built-in prompt by ID\n */\nexport const getBuiltinPromptById = async (id: string): Promise<BuiltinPrompt> => {\n const response: ApiResponse<BuiltinPrompt> = await apiGet(`/prompts/${id}`);\n if (!response.success) {\n throw new Error(response.message || 'Failed to fetch built-in prompt');\n }\n return response.data!;\n};\n\n/**\n * Create a new built-in prompt\n */\nexport const createBuiltinPrompt = async (\n prompt: Omit<BuiltinPrompt, 'id'>,\n): Promise<BuiltinPrompt> => {\n const response: ApiResponse<BuiltinPrompt> = await apiPost('/prompts', prompt);\n if (!response.success) {\n throw new Error(response.message || 'Failed to create built-in prompt');\n }\n return response.data!;\n};\n\n/**\n * Update an existing built-in prompt\n */\nexport const updateBuiltinPrompt = async (\n id: string,\n prompt: Partial<BuiltinPrompt>,\n): Promise<BuiltinPrompt> => {\n const response: ApiResponse<BuiltinPrompt> = await apiPut(`/prompts/${id}`, prompt);\n if (!response.success) {\n throw new Error(response.message || 'Failed to update built-in prompt');\n }\n return response.data!;\n};\n\n/**\n * Delete a built-in prompt\n */\nexport const deleteBuiltinPrompt = async (id: string): Promise<void> => {\n const response: ApiResponse = await apiDelete(`/prompts/${id}`);\n if (!response.success) {\n throw new Error(response.message || 'Failed to delete built-in prompt');\n }\n};\n","import { useState, useEffect, useCallback } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { BuiltinPrompt } from '@/types';\nimport {\n getBuiltinPrompts,\n createBuiltinPrompt,\n updateBuiltinPrompt,\n deleteBuiltinPrompt,\n} from '@/services/builtinPromptService';\n\nexport const useBuiltinPromptData = () => {\n const { t } = useTranslation();\n const [prompts, setPrompts] = useState<BuiltinPrompt[]>([]);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<string | null>(null);\n const [refreshKey, setRefreshKey] = useState(0);\n\n const fetchPrompts = useCallback(async () => {\n try {\n setLoading(true);\n const data = await getBuiltinPrompts();\n setPrompts(data);\n setError(null);\n } catch (err) {\n console.error('Error fetching built-in prompts:', err);\n setError(err instanceof Error ? err.message : t('builtinPrompts.fetchError'));\n setPrompts([]);\n } finally {\n setLoading(false);\n }\n }, [t]);\n\n const triggerRefresh = useCallback(() => {\n setRefreshKey((prev) => prev + 1);\n }, []);\n\n const addPrompt = async (prompt: Omit<BuiltinPrompt, 'id'>) => {\n try {\n const result = await createBuiltinPrompt(prompt);\n triggerRefresh();\n return { success: true, data: result };\n } catch (err) {\n const message = err instanceof Error ? err.message : t('builtinPrompts.createError');\n setError(message);\n return { success: false, message };\n }\n };\n\n const editPrompt = async (id: string, prompt: Partial<BuiltinPrompt>) => {\n try {\n const result = await updateBuiltinPrompt(id, prompt);\n triggerRefresh();\n return { success: true, data: result };\n } catch (err) {\n const message = err instanceof Error ? err.message : t('builtinPrompts.updateError');\n setError(message);\n return { success: false, message };\n }\n };\n\n const removePrompt = async (id: string) => {\n try {\n await deleteBuiltinPrompt(id);\n triggerRefresh();\n return { success: true };\n } catch (err) {\n const message = err instanceof Error ? err.message : t('builtinPrompts.deleteError');\n setError(message);\n return { success: false, message };\n }\n };\n\n useEffect(() => {\n fetchPrompts();\n }, [fetchPrompts, refreshKey]);\n\n return {\n prompts,\n loading,\n error,\n setError,\n triggerRefresh,\n addPrompt,\n editPrompt,\n removePrompt,\n };\n};\n","import React, { useState } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { BuiltinPrompt, PromptArgument } from '@/types';\nimport { useBuiltinPromptData } from '@/hooks/useBuiltinPromptData';\nimport { useAuth } from '@/contexts/AuthContext';\nimport { Edit, Trash, Plus, MessageSquare, X, ChevronDown, ChevronUp } from 'lucide-react';\nimport ConfirmDialog from '@/components/ui/ConfirmDialog';\n\n// Form dialog for creating/editing a built-in prompt\ninterface PromptFormDialogProps {\n prompt?: BuiltinPrompt | null;\n onSave: (data: Omit<BuiltinPrompt, 'id'>) => Promise<{ success: boolean; message?: string }>;\n onCancel: () => void;\n}\n\nconst PromptFormDialog: React.FC<PromptFormDialogProps> = ({ prompt, onSave, onCancel }) => {\n const { t } = useTranslation();\n const [error, setError] = useState<string | null>(null);\n const [isSubmitting, setIsSubmitting] = useState(false);\n\n const [name, setName] = useState(prompt?.name || '');\n const [title, setTitle] = useState(prompt?.title || '');\n const [description, setDescription] = useState(prompt?.description || '');\n const [template, setTemplate] = useState(prompt?.template || '');\n const [enabled, setEnabled] = useState(prompt?.enabled !== false);\n const [args, setArgs] = useState<PromptArgument[]>(prompt?.arguments || []);\n\n const handleAddArg = () => {\n setArgs([...args, { name: '', description: '', required: false }]);\n };\n\n const handleRemoveArg = (index: number) => {\n setArgs(args.filter((_, i) => i !== index));\n };\n\n const handleArgChange = (index: number, field: keyof PromptArgument, value: string | boolean) => {\n setArgs(args.map((a, i) => (i === index ? { ...a, [field]: value } : a)));\n };\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n setError(null);\n\n if (!name.trim()) {\n setError(t('builtinPrompts.nameRequired'));\n return;\n }\n if (!template.trim()) {\n setError(t('builtinPrompts.templateRequired'));\n return;\n }\n\n setIsSubmitting(true);\n try {\n const result = await onSave({\n name: name.trim(),\n title: title.trim() || undefined,\n description: description.trim() || undefined,\n template,\n arguments: args.length > 0 ? args.filter((a) => a.name.trim()) : undefined,\n enabled,\n });\n if (!result.success) {\n setError(result.message || t('builtinPrompts.saveError'));\n }\n } catch (err) {\n setError(err instanceof Error ? err.message : t('builtinPrompts.saveError'));\n } finally {\n setIsSubmitting(false);\n }\n };\n\n return (\n <div className=\"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4\">\n <div className=\"bg-white dark:bg-gray-800 p-8 rounded-xl shadow-2xl max-w-3xl w-full mx-4 border border-gray-100 dark:border-gray-700 max-h-[90vh] overflow-y-auto\">\n <form onSubmit={handleSubmit}>\n <h2 className=\"text-xl font-bold text-gray-900 dark:text-gray-100 mb-6\">\n {prompt ? t('builtinPrompts.edit') : t('builtinPrompts.addNew')}\n </h2>\n\n {error && (\n <div className=\"bg-red-50 border-l-4 border-red-500 text-red-700 p-4 mb-6 rounded-md\">\n <p className=\"text-sm font-medium\">{error}</p>\n </div>\n )}\n\n <div className=\"space-y-5\">\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinPrompts.name')} <span className=\"text-red-500\">*</span>\n </label>\n <input\n type=\"text\"\n value={name}\n onChange={(e) => setName(e.target.value)}\n placeholder={t('builtinPrompts.namePlaceholder')}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200\"\n required\n disabled={isSubmitting}\n />\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinPrompts.title')}\n </label>\n <input\n type=\"text\"\n value={title}\n onChange={(e) => setTitle(e.target.value)}\n placeholder={t('builtinPrompts.titlePlaceholder')}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200\"\n disabled={isSubmitting}\n />\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinPrompts.description')}\n </label>\n <input\n type=\"text\"\n value={description}\n onChange={(e) => setDescription(e.target.value)}\n placeholder={t('builtinPrompts.descriptionPlaceholder')}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200\"\n disabled={isSubmitting}\n />\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinPrompts.template')} <span className=\"text-red-500\">*</span>\n </label>\n <textarea\n value={template}\n onChange={(e) => setTemplate(e.target.value)}\n placeholder={t('builtinPrompts.templatePlaceholder')}\n rows={6}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 font-mono text-sm transition-all duration-200\"\n required\n disabled={isSubmitting}\n />\n <p className=\"mt-1 text-xs text-gray-500 dark:text-gray-400\">\n {t('builtinPrompts.templateHint')}\n </p>\n </div>\n\n {/* Arguments */}\n <div>\n <div className=\"flex items-center justify-between mb-2\">\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300\">\n {t('builtinPrompts.arguments')}\n </label>\n <button\n type=\"button\"\n onClick={handleAddArg}\n className=\"text-blue-600 hover:text-blue-800 text-sm flex items-center\"\n disabled={isSubmitting}\n >\n <Plus size={14} className=\"mr-1\" />\n {t('builtinPrompts.addArgument')}\n </button>\n </div>\n {args.map((arg, index) => (\n <div key={index} className=\"flex items-start gap-2 mb-2\">\n <input\n type=\"text\"\n value={arg.name}\n onChange={(e) => handleArgChange(index, 'name', e.target.value)}\n placeholder={t('builtinPrompts.argName')}\n className=\"flex-1 px-3 py-1.5 border border-gray-300 dark:border-gray-600 rounded-lg text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500\"\n disabled={isSubmitting}\n />\n <input\n type=\"text\"\n value={arg.description || ''}\n onChange={(e) => handleArgChange(index, 'description', e.target.value)}\n placeholder={t('builtinPrompts.argDescription')}\n className=\"flex-1 px-3 py-1.5 border border-gray-300 dark:border-gray-600 rounded-lg text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500\"\n disabled={isSubmitting}\n />\n <label className=\"flex items-center text-sm text-gray-600 dark:text-gray-400 whitespace-nowrap\">\n <input\n type=\"checkbox\"\n checked={arg.required || false}\n onChange={(e) => handleArgChange(index, 'required', e.target.checked)}\n className=\"mr-1\"\n disabled={isSubmitting}\n />\n {t('builtinPrompts.argRequired')}\n </label>\n <button\n type=\"button\"\n onClick={() => handleRemoveArg(index)}\n className=\"text-red-500 hover:text-red-700 p-1\"\n disabled={isSubmitting}\n >\n <X size={16} />\n </button>\n </div>\n ))}\n </div>\n\n <div className=\"flex items-center pt-2\">\n <input\n type=\"checkbox\"\n id=\"enabled\"\n checked={enabled}\n onChange={(e) => setEnabled(e.target.checked)}\n className=\"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500\"\n disabled={isSubmitting}\n />\n <label htmlFor=\"enabled\" className=\"ml-2 block text-sm text-gray-700 dark:text-gray-300\">\n {t('builtinPrompts.enabled')}\n </label>\n </div>\n </div>\n\n <div className=\"flex justify-end space-x-3 mt-8\">\n <button\n type=\"button\"\n onClick={onCancel}\n className=\"px-4 py-2 text-gray-600 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200 btn-secondary\"\n disabled={isSubmitting}\n >\n {t('common.cancel')}\n </button>\n <button\n type=\"submit\"\n disabled={isSubmitting}\n className=\"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 btn-primary transition-all duration-200 shadow-sm disabled:opacity-50\"\n >\n {isSubmitting ? t('common.saving') : t('common.save')}\n </button>\n </div>\n </form>\n </div>\n </div>\n );\n};\n\nconst PromptsPage: React.FC = () => {\n const { t } = useTranslation();\n const { auth } = useAuth();\n const {\n prompts,\n loading,\n error,\n setError,\n addPrompt,\n editPrompt,\n removePrompt,\n } = useBuiltinPromptData();\n\n const [showForm, setShowForm] = useState(false);\n const [editingPrompt, setEditingPrompt] = useState<BuiltinPrompt | null>(null);\n const [promptToDelete, setPromptToDelete] = useState<BuiltinPrompt | null>(null);\n const [expandedIds, setExpandedIds] = useState<Set<string>>(new Set());\n\n const isAdmin = auth.user?.isAdmin;\n\n const toggleExpand = (id: string) => {\n setExpandedIds((prev) => {\n const next = new Set(prev);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n return next;\n });\n };\n\n const handleCreate = async (data: Omit<BuiltinPrompt, 'id'>) => {\n const result = await addPrompt(data);\n if (result.success) {\n setShowForm(false);\n }\n return result;\n };\n\n const handleEdit = async (data: Omit<BuiltinPrompt, 'id'>) => {\n if (!editingPrompt) return { success: false, message: 'No prompt selected' };\n const result = await editPrompt(editingPrompt.id, data);\n if (result.success) {\n setEditingPrompt(null);\n }\n return result;\n };\n\n const handleConfirmDelete = async () => {\n if (promptToDelete) {\n await removePrompt(promptToDelete.id);\n setPromptToDelete(null);\n }\n };\n\n return (\n <div className=\"container mx-auto\">\n <div className=\"flex justify-between items-center mb-8\">\n <h1 className=\"text-2xl font-bold text-gray-900 dark:text-gray-100\">\n {t('pages.prompts.title')}\n </h1>\n {isAdmin && (\n <button\n onClick={() => setShowForm(true)}\n className=\"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 flex items-center btn-primary transition-all duration-200 shadow-sm\"\n >\n <Plus size={16} className=\"mr-2\" />\n {t('builtinPrompts.add')}\n </button>\n )}\n </div>\n\n {error && (\n <div className=\"bg-red-50 border-l-4 border-red-500 text-red-700 p-4 mb-6 error-box rounded-lg shadow-sm\">\n <div className=\"flex justify-between items-center\">\n <p>{error}</p>\n <button onClick={() => setError(null)} className=\"text-red-500 hover:text-red-700\">\n <X size={20} />\n </button>\n </div>\n </div>\n )}\n\n {loading ? (\n <div className=\"bg-white dark:bg-gray-800 shadow rounded-lg p-6 loading-container flex justify-center items-center h-64\">\n <div className=\"flex flex-col items-center justify-center\">\n <svg\n className=\"animate-spin h-10 w-10 text-blue-500 mb-4\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n >\n <circle className=\"opacity-25\" cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" strokeWidth=\"4\" />\n <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\" />\n </svg>\n <p className=\"text-gray-600 dark:text-gray-400\">{t('app.loading')}</p>\n </div>\n </div>\n ) : prompts.length === 0 ? (\n <div className=\"bg-white dark:bg-gray-800 shadow rounded-lg p-6 empty-state dashboard-card\">\n <div className=\"flex flex-col items-center justify-center py-12\">\n <div className=\"p-4 bg-gray-100 dark:bg-gray-700 rounded-full mb-4\">\n <MessageSquare className=\"h-8 w-8 text-gray-400\" />\n </div>\n <p className=\"text-gray-600 dark:text-gray-400 text-lg font-medium\">\n {t('builtinPrompts.noPrompts')}\n </p>\n {isAdmin && (\n <button\n onClick={() => setShowForm(true)}\n className=\"mt-4 text-blue-600 hover:text-blue-800 font-medium\"\n >\n {t('builtinPrompts.addFirst')}\n </button>\n )}\n </div>\n </div>\n ) : (\n <div className=\"space-y-3\">\n {prompts.map((prompt) => {\n const isExpanded = expandedIds.has(prompt.id);\n return (\n <div\n key={prompt.id}\n className=\"bg-white dark:bg-gray-800 shadow rounded-lg overflow-hidden dashboard-card\"\n >\n <div\n className=\"flex items-center justify-between px-6 py-4 cursor-pointer hover:bg-gray-50 dark:bg-gray-800 dark:hover:bg-gray-700\"\n onClick={() => toggleExpand(prompt.id)}\n >\n <div className=\"flex items-center flex-1 min-w-0\">\n <MessageSquare\n size={18}\n className={`mr-3 flex-shrink-0 ${prompt.enabled !== false ? 'text-blue-500' : 'text-gray-400'}`}\n />\n <div className=\"min-w-0\">\n <div className=\"flex items-center gap-2\">\n <span className=\"font-medium text-gray-900 dark:text-gray-100 truncate\">\n {prompt.title || prompt.name}\n </span>\n <span className=\"text-xs text-gray-500 dark:text-gray-400 font-mono\">\n {prompt.name}\n </span>\n <span\n className={`px-2 py-0.5 text-xs rounded-full ${\n prompt.enabled !== false\n ? 'bg-green-100 text-green-800 border border-green-200'\n : 'bg-gray-100 text-gray-600 border border-gray-200'\n }`}\n >\n {prompt.enabled !== false ? t('builtinPrompts.active') : t('builtinPrompts.inactive')}\n </span>\n </div>\n {prompt.description && (\n <p className=\"text-sm text-gray-500 dark:text-gray-400 mt-0.5 truncate\">\n {prompt.description}\n </p>\n )}\n </div>\n </div>\n <div className=\"flex items-center ml-4 gap-2\">\n {isAdmin && (\n <>\n <button\n onClick={(e) => {\n e.stopPropagation();\n setEditingPrompt(prompt);\n }}\n className=\"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-1 rounded hover:bg-blue-50 dark:hover:bg-blue-900/40 transition-colors\"\n title={t('builtinPrompts.edit')}\n >\n <Edit size={18} />\n </button>\n <button\n onClick={(e) => {\n e.stopPropagation();\n setPromptToDelete(prompt);\n }}\n className=\"text-red-600 dark:text-red-400 hover:text-red-900 dark:hover:text-red-300 p-1 rounded hover:bg-red-50 dark:hover:bg-red-900/40 transition-colors\"\n title={t('builtinPrompts.delete')}\n >\n <Trash size={18} />\n </button>\n </>\n )}\n {isExpanded ? (\n <ChevronUp size={18} className=\"text-gray-400\" />\n ) : (\n <ChevronDown size={18} className=\"text-gray-400\" />\n )}\n </div>\n </div>\n {isExpanded && (\n <div className=\"px-6 pb-4 border-t border-gray-100 dark:border-gray-700\">\n <div className=\"mt-3\">\n <h4 className=\"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase mb-1\">\n {t('builtinPrompts.template')}\n </h4>\n <pre className=\"text-sm text-gray-800 dark:text-gray-200 bg-gray-50 dark:bg-gray-900 rounded p-3 overflow-x-auto whitespace-pre-wrap font-mono\">\n {prompt.template}\n </pre>\n </div>\n {prompt.arguments && prompt.arguments.length > 0 && (\n <div className=\"mt-3\">\n <h4 className=\"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase mb-1\">\n {t('builtinPrompts.arguments')}\n </h4>\n <div className=\"space-y-1\">\n {prompt.arguments.map((arg, i) => (\n <div key={i} className=\"flex items-center gap-2 text-sm\">\n <code className=\"px-1.5 py-0.5 bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 rounded text-xs font-mono\">\n {'{{' + arg.name + '}}'}\n </code>\n {arg.required && (\n <span className=\"text-red-500 text-xs\">*</span>\n )}\n {arg.description && (\n <span className=\"text-gray-500 dark:text-gray-400 text-xs\">\n — {arg.description}\n </span>\n )}\n </div>\n ))}\n </div>\n </div>\n )}\n </div>\n )}\n </div>\n );\n })}\n </div>\n )}\n\n {/* Add form dialog */}\n {showForm && (\n <PromptFormDialog onSave={handleCreate} onCancel={() => setShowForm(false)} />\n )}\n\n {/* Edit form dialog */}\n {editingPrompt && (\n <PromptFormDialog\n prompt={editingPrompt}\n onSave={handleEdit}\n onCancel={() => setEditingPrompt(null)}\n />\n )}\n\n {/* Delete confirmation */}\n <ConfirmDialog\n isOpen={!!promptToDelete}\n onClose={() => setPromptToDelete(null)}\n onConfirm={handleConfirmDelete}\n title={t('builtinPrompts.confirmDelete')}\n message={t('builtinPrompts.deleteWarning', { name: promptToDelete?.name || '' })}\n variant=\"danger\"\n />\n </div>\n );\n};\n\nexport default PromptsPage;\n"],"names":["getBuiltinPrompts","response","apiGet","createBuiltinPrompt","prompt","apiPost","updateBuiltinPrompt","id","apiPut","deleteBuiltinPrompt","apiDelete","useBuiltinPromptData","useTranslation","prompts","setPrompts","useState","loading","setLoading","error","setError","refreshKey","setRefreshKey","fetchPrompts","useCallback","data","err","triggerRefresh","prev","addPrompt","result","message","editPrompt","removePrompt","useEffect","PromptFormDialog","onSave","onCancel","t","isSubmitting","setIsSubmitting","name","setName","title","setTitle","description","setDescription","template","setTemplate","enabled","setEnabled","args","setArgs","handleAddArg","handleRemoveArg","index","_","i","handleArgChange","field","value","a","handleSubmit","e","jsx","jsxs","Plus","arg","X","PromptsPage","auth","useAuth","showForm","setShowForm","editingPrompt","setEditingPrompt","promptToDelete","setPromptToDelete","expandedIds","setExpandedIds","isAdmin","_a","toggleExpand","next","handleCreate","handleEdit","handleConfirmDelete","MessageSquare","isExpanded","Fragment","Edit","Trash","ChevronUp","ChevronDown","ConfirmDialog"],"mappings":"qTAMO,MAAMA,EAAoB,SAAsC,CACrE,MAAMC,EAAyC,MAAMC,EAAO,UAAU,EACtE,GAAI,CAACD,EAAS,QACZ,MAAM,IAAI,MAAMA,EAAS,SAAW,kCAAkC,EAExE,OAAOA,EAAS,MAAQ,CAAA,CAC1B,EAgBaE,EAAsB,MACjCC,GAC2B,CAC3B,MAAMH,EAAuC,MAAMI,EAAQ,WAAYD,CAAM,EAC7E,GAAI,CAACH,E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rB,SAAA,CAAAD,MAAC,QAAK,UAAU,0GACb,SAAA,KAAOG,EAAI,KAAO,KACrB,EACCA,EAAI,UACHH,EAAAA,IAAC,OAAA,CAAK,UAAU,uBAAuB,SAAA,IAAC,EAEzCG,EAAI,aACHF,OAAC,OAAA,CAAK,UAAU,2CAA2C,SAAA,CAAA,KACtDE,EAAI,WAAA,CAAA,CACT,CAAA,CAAA,EAVMV,CAYV,CACD,CAAA,CACH,CAAA,CAAA,CACF,CAAA,CAAA,CAEJ,CAAA,CAAA,EAvGGpD,EAAO,EAAA,CA2GlB,CAAC,CAAA,CACH,EAIDmE,SACErC,EAAA,CAAiB,OAAQiD,EAAc,SAAU,IAAMX,EAAY,EAAK,EAAG,EAI7EC,GACCV,EAAAA,IAAC7B,EAAA,CACC,OAAQuC,EACR,OAAQW,EACR,SAAU,IAAMV,EAAiB,IAAI,CAAA,CAAA,EAKzCX,EAAAA,IAAC8B,EAAA,CACC,OAAQ,CAAC,CAAClB,EACV,QAAS,IAAMC,EAAkB,IAAI,EACrC,UAAWS,EACX,MAAO,EAAE,8BAA8B,EACvC,QAAS,EAAE,+BAAgC,CAAE,MAAMV,GAAA,YAAAA,EAAgB,OAAQ,GAAI,EAC/E,QAAQ,QAAA,CAAA,CACV,EACF,CAEJ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as n,j as e}from"./framework-vendor-_OBebcuv.js";import{i as z,e as T,f as D,d as B,u as q}from"./index-CmnA4an8.js";import{u as S}from"./i18n-vendor-MQ921plD.js";import{C as A}from"./ConfirmDialog-uYjffH4V.js";import{o as $,X as I,F,h as K,T as M,p as U,j as W}from"./icons-vendor-B67NtVuR.js";const G=async()=>{const t=await z("/resources");if(!t.success)throw new Error(t.message||"Failed to fetch built-in resources");return t.data||[]},H=async t=>{const d=await B("/resources",t);if(!d.success)throw new Error(d.message||"Failed to create built-in resource");return d.data},L=async(t,d)=>{const m=await D(`/resources/${t}`,d);if(!m.success)throw new Error(m.message||"Failed to update built-in resource");return m.data},O=async t=>{const d=await T(`/resources/${t}`);if(!d.success)throw new Error(d.message||"Failed to delete built-in resource")},V=()=>{const{t}=S(),[d,m]=n.useState([]),[r,h]=n.useState(!0),[g,i]=n.useState(null),[w,k]=n.useState(0),N=n.useCallback(async()=>{try{h(!0);const a=await G();m(a),i(null)}catch(a){console.error("Error fetching built-in resources:",a),i(a instanceof Error?a.message:t("builtinResources.fetchError")),m([])}finally{h(!1)}},[t]),x=n.useCallback(()=>{k(a=>a+1)},[]),y=async a=>{try{const u=await H(a);return x(),{success:!0,data:u}}catch(u){const l=u instanceof Error?u.message:t("builtinResources.createError");return i(l),{success:!1,message:l}}},p=async(a,u)=>{try{const l=await L(a,u);return x(),{success:!0,data:l}}catch(l){const f=l instanceof Error?l.message:t("builtinResources.updateError");return i(f),{success:!1,message:f}}},c=async a=>{try{return await O(a),x(),{success:!0}}catch(u){const l=u instanceof Error?u.message:t("builtinResources.deleteError");return i(l),{success:!1,message:l}}};return n.useEffect(()=>{N()},[N,w]),{resources:d,loading:r,error:g,setError:i,triggerRefresh:x,addResource:y,editResource:p,removeResource:c}},P=({resource:t,onSave:d,onCancel:m})=>{const{t:r}=S(),[h,g]=n.useState(null),[i,w]=n.useState(!1),[k,N]=n.useState((t==null?void 0:t.uri)||""),[x,y]=n.useState((t==null?void 0:t.name)||""),[p,c]=n.useState((t==null?void 0:t.description)||""),[a,u]=n.useState((t==null?void 0:t.mimeType)||"text/plain"),[l,f]=n.useState((t==null?void 0:t.content)||""),[R,C]=n.useState((t==null?void 0:t.enabled)!==!1),E=async o=>{if(o.preventDefault(),g(null),!k.trim()){g(r("builtinResources.uriRequired"));return}if(!l.trim()){g(r("builtinResources.contentRequired"));return}w(!0);try{const j=await d({uri:k.trim(),name:x.trim()||void 0,description:p.trim()||void 0,mimeType:a.trim()||"text/plain",content:l,enabled:R});j.success||g(j.message||r("builtinResources.saveError"))}catch(j){g(j instanceof Error?j.message:r("builtinResources.saveError"))}finally{w(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 p-8 rounded-xl shadow-2xl max-w-3xl w-full mx-4 border border-gray-100 dark:border-gray-700 max-h-[90vh] overflow-y-auto",children:e.jsxs("form",{onSubmit:E,children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900 dark:text-gray-100 mb-6",children:r(t?"builtinResources.edit":"builtinResources.addNew")}),h&&e.jsx("div",{className:"bg-red-50 border-l-4 border-red-500 text-red-700 p-4 mb-6 rounded-md",children:e.jsx("p",{className:"text-sm font-medium",children:h})}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[r("builtinResources.uri")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:k,onChange:o=>N(o.target.value),placeholder:r("builtinResources.uriPlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 font-mono text-sm transition-all duration-200",required:!0,disabled:i})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:r("builtinResources.name")}),e.jsx("input",{type:"text",value:x,onChange:o=>y(o.target.value),placeholder:r("builtinResources.namePlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",disabled:i})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:r("builtinResources.description")}),e.jsx("input",{type:"text",value:p,onChange:o=>c(o.target.value),placeholder:r("builtinResources.descriptionPlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",disabled:i})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:r("builtinResources.mimeType")}),e.jsx("input",{type:"text",value:a,onChange:o=>u(o.target.value),placeholder:"text/plain",className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",disabled:i})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[r("builtinResources.content")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("textarea",{value:l,onChange:o=>f(o.target.value),placeholder:r("builtinResources.contentPlaceholder"),rows:8,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 font-mono text-sm transition-all duration-200",required:!0,disabled:i})]}),e.jsxs("div",{className:"flex items-center pt-2",children:[e.jsx("input",{type:"checkbox",id:"enabled",checked:R,onChange:o=>C(o.target.checked),className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500",disabled:i}),e.jsx("label",{htmlFor:"enabled",className:"ml-2 block text-sm text-gray-700 dark:text-gray-300",children:r("builtinResources.enabled")})]})]}),e.jsxs("div",{className:"flex justify-end space-x-3 mt-8",children:[e.jsx("button",{type:"button",onClick:m,className:"px-4 py-2 text-gray-600 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200 btn-secondary",disabled:i,children:r("common.cancel")}),e.jsx("button",{type:"submit",disabled:i,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 btn-primary transition-all duration-200 shadow-sm disabled:opacity-50",children:r(i?"common.saving":"common.save")})]})]})})})},_=()=>{var j;const{t}=S(),{auth:d}=q(),{resources:m,loading:r,error:h,setError:g,addResource:i,editResource:w,removeResource:k}=V(),[N,x]=n.useState(!1),[y,p]=n.useState(null),[c,a]=n.useState(null),[u,l]=n.useState(new Set),f=(j=d.user)==null?void 0:j.isAdmin,R=s=>{l(b=>{const v=new Set(b);return v.has(s)?v.delete(s):v.add(s),v})},C=async s=>{const b=await i(s);return b.success&&x(!1),b},E=async s=>{if(!y)return{success:!1,message:"No resource selected"};const b=await w(y.id,s);return b.success&&p(null),b},o=async()=>{c&&(await k(c.id),a(null))};return e.jsxs("div",{className:"container mx-auto",children:[e.jsxs("div",{className:"flex justify-between items-center mb-8",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:t("pages.resources.title")}),f&&e.jsxs("button",{onClick:()=>x(!0),className:"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 flex items-center btn-primary transition-all duration-200 shadow-sm",children:[e.jsx($,{size:16,className:"mr-2"}),t("builtinResources.add")]})]}),h&&e.jsx("div",{className:"bg-red-50 border-l-4 border-red-500 text-red-700 p-4 mb-6 error-box rounded-lg shadow-sm",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("p",{children:h}),e.jsx("button",{onClick:()=>g(null),className:"text-red-500 hover:text-red-700",children:e.jsx(I,{size:20})})]})}),r?e.jsx("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 loading-container flex justify-center items-center h-64",children:e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsxs("svg",{className:"animate-spin h-10 w-10 text-blue-500 mb-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.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"})]}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:t("app.loading")})]})}):m.length===0?e.jsx("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 empty-state dashboard-card",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"p-4 bg-gray-100 dark:bg-gray-700 rounded-full mb-4",children:e.jsx(F,{className:"h-8 w-8 text-gray-400"})}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 text-lg font-medium",children:t("builtinResources.noResources")}),f&&e.jsx("button",{onClick:()=>x(!0),className:"mt-4 text-blue-600 hover:text-blue-800 font-medium",children:t("builtinResources.addFirst")})]})}):e.jsx("div",{className:"space-y-3",children:m.map(s=>{const b=u.has(s.id);return e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg overflow-hidden dashboard-card",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 cursor-pointer hover:bg-gray-50 dark:bg-gray-800 dark:hover:bg-gray-700",onClick:()=>R(s.id),children:[e.jsxs("div",{className:"flex items-center flex-1 min-w-0",children:[e.jsx(F,{size:18,className:`mr-3 flex-shrink-0 ${s.enabled!==!1?"text-green-500":"text-gray-400"}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100 truncate",children:s.name||s.uri}),s.name&&e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono truncate",children:s.uri}),e.jsx("span",{className:`px-2 py-0.5 text-xs rounded-full flex-shrink-0 ${s.enabled!==!1?"bg-green-100 text-green-800 border border-green-200":"bg-gray-100 text-gray-600 border border-gray-200"}`,children:s.enabled!==!1?t("builtinResources.active"):t("builtinResources.inactive")}),s.mimeType&&e.jsx("span",{className:"px-2 py-0.5 text-xs bg-blue-50 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300 rounded-full border border-blue-200 dark:border-blue-800 flex-shrink-0",children:s.mimeType})]}),s.description&&e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-0.5 truncate",children:s.description})]})]}),e.jsxs("div",{className:"flex items-center ml-4 gap-2",children:[f&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:v=>{v.stopPropagation(),p(s)},className:"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-1 rounded hover:bg-blue-50 dark:hover:bg-blue-900/40 transition-colors",title:t("builtinResources.edit"),children:e.jsx(K,{size:18})}),e.jsx("button",{onClick:v=>{v.stopPropagation(),a(s)},className:"text-red-600 dark:text-red-400 hover:text-red-900 dark:hover:text-red-300 p-1 rounded hover:bg-red-50 dark:hover:bg-red-900/40 transition-colors",title:t("builtinResources.delete"),children:e.jsx(M,{size:18})})]}),b?e.jsx(U,{size:18,className:"text-gray-400"}):e.jsx(W,{size:18,className:"text-gray-400"})]})]}),b&&e.jsx("div",{className:"px-6 pb-4 border-t border-gray-100 dark:border-gray-700",children:e.jsxs("div",{className:"mt-3",children:[e.jsx("h4",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase mb-1",children:t("builtinResources.content")}),e.jsx("pre",{className:"text-sm text-gray-800 dark:text-gray-200 bg-gray-50 dark:bg-gray-900 rounded p-3 overflow-x-auto whitespace-pre-wrap font-mono max-h-64 overflow-y-auto",children:s.content})]})})]},s.id)})}),N&&e.jsx(P,{onSave:C,onCancel:()=>x(!1)}),y&&e.jsx(P,{resource:y,onSave:E,onCancel:()=>p(null)}),e.jsx(A,{isOpen:!!c,onClose:()=>a(null),onConfirm:o,title:t("builtinResources.confirmDelete"),message:t("builtinResources.deleteWarning",{name:(c==null?void 0:c.name)||(c==null?void 0:c.uri)||""}),variant:"danger"})]})};export{_ as default};
|
|
2
|
+
//# sourceMappingURL=ResourcesPage-Bodw5OY9.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResourcesPage-Bodw5OY9.js","sources":["../../src/services/builtinResourceService.ts","../../src/hooks/useBuiltinResourceData.ts","../../src/pages/ResourcesPage.tsx"],"sourcesContent":["import { BuiltinResource, ApiResponse } from '@/types';\nimport { apiGet, apiPost, apiPut, apiDelete } from '../utils/fetchInterceptor';\n\n/**\n * Get all built-in resources\n */\nexport const getBuiltinResources = async (): Promise<BuiltinResource[]> => {\n const response: ApiResponse<BuiltinResource[]> = await apiGet('/resources');\n if (!response.success) {\n throw new Error(response.message || 'Failed to fetch built-in resources');\n }\n return response.data || [];\n};\n\n/**\n * Get a single built-in resource by ID\n */\nexport const getBuiltinResourceById = async (id: string): Promise<BuiltinResource> => {\n const response: ApiResponse<BuiltinResource> = await apiGet(`/resources/${id}`);\n if (!response.success) {\n throw new Error(response.message || 'Failed to fetch built-in resource');\n }\n return response.data!;\n};\n\n/**\n * Create a new built-in resource\n */\nexport const createBuiltinResource = async (\n resource: Omit<BuiltinResource, 'id'>,\n): Promise<BuiltinResource> => {\n const response: ApiResponse<BuiltinResource> = await apiPost('/resources', resource);\n if (!response.success) {\n throw new Error(response.message || 'Failed to create built-in resource');\n }\n return response.data!;\n};\n\n/**\n * Update an existing built-in resource\n */\nexport const updateBuiltinResource = async (\n id: string,\n resource: Partial<BuiltinResource>,\n): Promise<BuiltinResource> => {\n const response: ApiResponse<BuiltinResource> = await apiPut(`/resources/${id}`, resource);\n if (!response.success) {\n throw new Error(response.message || 'Failed to update built-in resource');\n }\n return response.data!;\n};\n\n/**\n * Delete a built-in resource\n */\nexport const deleteBuiltinResource = async (id: string): Promise<void> => {\n const response: ApiResponse = await apiDelete(`/resources/${id}`);\n if (!response.success) {\n throw new Error(response.message || 'Failed to delete built-in resource');\n }\n};\n","import { useState, useEffect, useCallback } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { BuiltinResource } from '@/types';\nimport {\n getBuiltinResources,\n createBuiltinResource,\n updateBuiltinResource,\n deleteBuiltinResource,\n} from '@/services/builtinResourceService';\n\nexport const useBuiltinResourceData = () => {\n const { t } = useTranslation();\n const [resources, setResources] = useState<BuiltinResource[]>([]);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<string | null>(null);\n const [refreshKey, setRefreshKey] = useState(0);\n\n const fetchResources = useCallback(async () => {\n try {\n setLoading(true);\n const data = await getBuiltinResources();\n setResources(data);\n setError(null);\n } catch (err) {\n console.error('Error fetching built-in resources:', err);\n setError(err instanceof Error ? err.message : t('builtinResources.fetchError'));\n setResources([]);\n } finally {\n setLoading(false);\n }\n }, [t]);\n\n const triggerRefresh = useCallback(() => {\n setRefreshKey((prev) => prev + 1);\n }, []);\n\n const addResource = async (resource: Omit<BuiltinResource, 'id'>) => {\n try {\n const result = await createBuiltinResource(resource);\n triggerRefresh();\n return { success: true, data: result };\n } catch (err) {\n const message = err instanceof Error ? err.message : t('builtinResources.createError');\n setError(message);\n return { success: false, message };\n }\n };\n\n const editResource = async (id: string, resource: Partial<BuiltinResource>) => {\n try {\n const result = await updateBuiltinResource(id, resource);\n triggerRefresh();\n return { success: true, data: result };\n } catch (err) {\n const message = err instanceof Error ? err.message : t('builtinResources.updateError');\n setError(message);\n return { success: false, message };\n }\n };\n\n const removeResource = async (id: string) => {\n try {\n await deleteBuiltinResource(id);\n triggerRefresh();\n return { success: true };\n } catch (err) {\n const message = err instanceof Error ? err.message : t('builtinResources.deleteError');\n setError(message);\n return { success: false, message };\n }\n };\n\n useEffect(() => {\n fetchResources();\n }, [fetchResources, refreshKey]);\n\n return {\n resources,\n loading,\n error,\n setError,\n triggerRefresh,\n addResource,\n editResource,\n removeResource,\n };\n};\n","import React, { useState } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { BuiltinResource } from '@/types';\nimport { useBuiltinResourceData } from '@/hooks/useBuiltinResourceData';\nimport { useAuth } from '@/contexts/AuthContext';\nimport { Edit, Trash, Plus, FileText, X, ChevronDown, ChevronUp } from 'lucide-react';\nimport ConfirmDialog from '@/components/ui/ConfirmDialog';\n\n// Form dialog for creating/editing a built-in resource\ninterface ResourceFormDialogProps {\n resource?: BuiltinResource | null;\n onSave: (data: Omit<BuiltinResource, 'id'>) => Promise<{ success: boolean; message?: string }>;\n onCancel: () => void;\n}\n\nconst ResourceFormDialog: React.FC<ResourceFormDialogProps> = ({ resource, onSave, onCancel }) => {\n const { t } = useTranslation();\n const [error, setError] = useState<string | null>(null);\n const [isSubmitting, setIsSubmitting] = useState(false);\n\n const [uri, setUri] = useState(resource?.uri || '');\n const [name, setName] = useState(resource?.name || '');\n const [description, setDescription] = useState(resource?.description || '');\n const [mimeType, setMimeType] = useState(resource?.mimeType || 'text/plain');\n const [content, setContent] = useState(resource?.content || '');\n const [enabled, setEnabled] = useState(resource?.enabled !== false);\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n setError(null);\n\n if (!uri.trim()) {\n setError(t('builtinResources.uriRequired'));\n return;\n }\n if (!content.trim()) {\n setError(t('builtinResources.contentRequired'));\n return;\n }\n\n setIsSubmitting(true);\n try {\n const result = await onSave({\n uri: uri.trim(),\n name: name.trim() || undefined,\n description: description.trim() || undefined,\n mimeType: mimeType.trim() || 'text/plain',\n content,\n enabled,\n });\n if (!result.success) {\n setError(result.message || t('builtinResources.saveError'));\n }\n } catch (err) {\n setError(err instanceof Error ? err.message : t('builtinResources.saveError'));\n } finally {\n setIsSubmitting(false);\n }\n };\n\n return (\n <div className=\"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4\">\n <div className=\"bg-white dark:bg-gray-800 p-8 rounded-xl shadow-2xl max-w-3xl w-full mx-4 border border-gray-100 dark:border-gray-700 max-h-[90vh] overflow-y-auto\">\n <form onSubmit={handleSubmit}>\n <h2 className=\"text-xl font-bold text-gray-900 dark:text-gray-100 mb-6\">\n {resource ? t('builtinResources.edit') : t('builtinResources.addNew')}\n </h2>\n\n {error && (\n <div className=\"bg-red-50 border-l-4 border-red-500 text-red-700 p-4 mb-6 rounded-md\">\n <p className=\"text-sm font-medium\">{error}</p>\n </div>\n )}\n\n <div className=\"space-y-5\">\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinResources.uri')} <span className=\"text-red-500\">*</span>\n </label>\n <input\n type=\"text\"\n value={uri}\n onChange={(e) => setUri(e.target.value)}\n placeholder={t('builtinResources.uriPlaceholder')}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 font-mono text-sm transition-all duration-200\"\n required\n disabled={isSubmitting}\n />\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinResources.name')}\n </label>\n <input\n type=\"text\"\n value={name}\n onChange={(e) => setName(e.target.value)}\n placeholder={t('builtinResources.namePlaceholder')}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200\"\n disabled={isSubmitting}\n />\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinResources.description')}\n </label>\n <input\n type=\"text\"\n value={description}\n onChange={(e) => setDescription(e.target.value)}\n placeholder={t('builtinResources.descriptionPlaceholder')}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200\"\n disabled={isSubmitting}\n />\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinResources.mimeType')}\n </label>\n <input\n type=\"text\"\n value={mimeType}\n onChange={(e) => setMimeType(e.target.value)}\n placeholder=\"text/plain\"\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200\"\n disabled={isSubmitting}\n />\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinResources.content')} <span className=\"text-red-500\">*</span>\n </label>\n <textarea\n value={content}\n onChange={(e) => setContent(e.target.value)}\n placeholder={t('builtinResources.contentPlaceholder')}\n rows={8}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 font-mono text-sm transition-all duration-200\"\n required\n disabled={isSubmitting}\n />\n </div>\n\n <div className=\"flex items-center pt-2\">\n <input\n type=\"checkbox\"\n id=\"enabled\"\n checked={enabled}\n onChange={(e) => setEnabled(e.target.checked)}\n className=\"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500\"\n disabled={isSubmitting}\n />\n <label htmlFor=\"enabled\" className=\"ml-2 block text-sm text-gray-700 dark:text-gray-300\">\n {t('builtinResources.enabled')}\n </label>\n </div>\n </div>\n\n <div className=\"flex justify-end space-x-3 mt-8\">\n <button\n type=\"button\"\n onClick={onCancel}\n className=\"px-4 py-2 text-gray-600 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200 btn-secondary\"\n disabled={isSubmitting}\n >\n {t('common.cancel')}\n </button>\n <button\n type=\"submit\"\n disabled={isSubmitting}\n className=\"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 btn-primary transition-all duration-200 shadow-sm disabled:opacity-50\"\n >\n {isSubmitting ? t('common.saving') : t('common.save')}\n </button>\n </div>\n </form>\n </div>\n </div>\n );\n};\n\nconst ResourcesPage: React.FC = () => {\n const { t } = useTranslation();\n const { auth } = useAuth();\n const {\n resources,\n loading,\n error,\n setError,\n addResource,\n editResource,\n removeResource,\n } = useBuiltinResourceData();\n\n const [showForm, setShowForm] = useState(false);\n const [editingResource, setEditingResource] = useState<BuiltinResource | null>(null);\n const [resourceToDelete, setResourceToDelete] = useState<BuiltinResource | null>(null);\n const [expandedIds, setExpandedIds] = useState<Set<string>>(new Set());\n\n const isAdmin = auth.user?.isAdmin;\n\n const toggleExpand = (id: string) => {\n setExpandedIds((prev) => {\n const next = new Set(prev);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n return next;\n });\n };\n\n const handleCreate = async (data: Omit<BuiltinResource, 'id'>) => {\n const result = await addResource(data);\n if (result.success) {\n setShowForm(false);\n }\n return result;\n };\n\n const handleEdit = async (data: Omit<BuiltinResource, 'id'>) => {\n if (!editingResource) return { success: false, message: 'No resource selected' };\n const result = await editResource(editingResource.id, data);\n if (result.success) {\n setEditingResource(null);\n }\n return result;\n };\n\n const handleConfirmDelete = async () => {\n if (resourceToDelete) {\n await removeResource(resourceToDelete.id);\n setResourceToDelete(null);\n }\n };\n\n return (\n <div className=\"container mx-auto\">\n <div className=\"flex justify-between items-center mb-8\">\n <h1 className=\"text-2xl font-bold text-gray-900 dark:text-gray-100\">\n {t('pages.resources.title')}\n </h1>\n {isAdmin && (\n <button\n onClick={() => setShowForm(true)}\n className=\"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 flex items-center btn-primary transition-all duration-200 shadow-sm\"\n >\n <Plus size={16} className=\"mr-2\" />\n {t('builtinResources.add')}\n </button>\n )}\n </div>\n\n {error && (\n <div className=\"bg-red-50 border-l-4 border-red-500 text-red-700 p-4 mb-6 error-box rounded-lg shadow-sm\">\n <div className=\"flex justify-between items-center\">\n <p>{error}</p>\n <button onClick={() => setError(null)} className=\"text-red-500 hover:text-red-700\">\n <X size={20} />\n </button>\n </div>\n </div>\n )}\n\n {loading ? (\n <div className=\"bg-white dark:bg-gray-800 shadow rounded-lg p-6 loading-container flex justify-center items-center h-64\">\n <div className=\"flex flex-col items-center justify-center\">\n <svg\n className=\"animate-spin h-10 w-10 text-blue-500 mb-4\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n >\n <circle className=\"opacity-25\" cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" strokeWidth=\"4\" />\n <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\" />\n </svg>\n <p className=\"text-gray-600 dark:text-gray-400\">{t('app.loading')}</p>\n </div>\n </div>\n ) : resources.length === 0 ? (\n <div className=\"bg-white dark:bg-gray-800 shadow rounded-lg p-6 empty-state dashboard-card\">\n <div className=\"flex flex-col items-center justify-center py-12\">\n <div className=\"p-4 bg-gray-100 dark:bg-gray-700 rounded-full mb-4\">\n <FileText className=\"h-8 w-8 text-gray-400\" />\n </div>\n <p className=\"text-gray-600 dark:text-gray-400 text-lg font-medium\">\n {t('builtinResources.noResources')}\n </p>\n {isAdmin && (\n <button\n onClick={() => setShowForm(true)}\n className=\"mt-4 text-blue-600 hover:text-blue-800 font-medium\"\n >\n {t('builtinResources.addFirst')}\n </button>\n )}\n </div>\n </div>\n ) : (\n <div className=\"space-y-3\">\n {resources.map((resource) => {\n const isExpanded = expandedIds.has(resource.id);\n return (\n <div\n key={resource.id}\n className=\"bg-white dark:bg-gray-800 shadow rounded-lg overflow-hidden dashboard-card\"\n >\n <div\n className=\"flex items-center justify-between px-6 py-4 cursor-pointer hover:bg-gray-50 dark:bg-gray-800 dark:hover:bg-gray-700\"\n onClick={() => toggleExpand(resource.id)}\n >\n <div className=\"flex items-center flex-1 min-w-0\">\n <FileText\n size={18}\n className={`mr-3 flex-shrink-0 ${resource.enabled !== false ? 'text-green-500' : 'text-gray-400'}`}\n />\n <div className=\"min-w-0\">\n <div className=\"flex items-center gap-2\">\n <span className=\"font-medium text-gray-900 dark:text-gray-100 truncate\">\n {resource.name || resource.uri}\n </span>\n {resource.name && (\n <span className=\"text-xs text-gray-500 dark:text-gray-400 font-mono truncate\">\n {resource.uri}\n </span>\n )}\n <span\n className={`px-2 py-0.5 text-xs rounded-full flex-shrink-0 ${\n resource.enabled !== false\n ? 'bg-green-100 text-green-800 border border-green-200'\n : 'bg-gray-100 text-gray-600 border border-gray-200'\n }`}\n >\n {resource.enabled !== false ? t('builtinResources.active') : t('builtinResources.inactive')}\n </span>\n {resource.mimeType && (\n <span className=\"px-2 py-0.5 text-xs bg-blue-50 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300 rounded-full border border-blue-200 dark:border-blue-800 flex-shrink-0\">\n {resource.mimeType}\n </span>\n )}\n </div>\n {resource.description && (\n <p className=\"text-sm text-gray-500 dark:text-gray-400 mt-0.5 truncate\">\n {resource.description}\n </p>\n )}\n </div>\n </div>\n <div className=\"flex items-center ml-4 gap-2\">\n {isAdmin && (\n <>\n <button\n onClick={(e) => {\n e.stopPropagation();\n setEditingResource(resource);\n }}\n className=\"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-1 rounded hover:bg-blue-50 dark:hover:bg-blue-900/40 transition-colors\"\n title={t('builtinResources.edit')}\n >\n <Edit size={18} />\n </button>\n <button\n onClick={(e) => {\n e.stopPropagation();\n setResourceToDelete(resource);\n }}\n className=\"text-red-600 dark:text-red-400 hover:text-red-900 dark:hover:text-red-300 p-1 rounded hover:bg-red-50 dark:hover:bg-red-900/40 transition-colors\"\n title={t('builtinResources.delete')}\n >\n <Trash size={18} />\n </button>\n </>\n )}\n {isExpanded ? (\n <ChevronUp size={18} className=\"text-gray-400\" />\n ) : (\n <ChevronDown size={18} className=\"text-gray-400\" />\n )}\n </div>\n </div>\n {isExpanded && (\n <div className=\"px-6 pb-4 border-t border-gray-100 dark:border-gray-700\">\n <div className=\"mt-3\">\n <h4 className=\"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase mb-1\">\n {t('builtinResources.content')}\n </h4>\n <pre className=\"text-sm text-gray-800 dark:text-gray-200 bg-gray-50 dark:bg-gray-900 rounded p-3 overflow-x-auto whitespace-pre-wrap font-mono max-h-64 overflow-y-auto\">\n {resource.content}\n </pre>\n </div>\n </div>\n )}\n </div>\n );\n })}\n </div>\n )}\n\n {/* Add form dialog */}\n {showForm && (\n <ResourceFormDialog onSave={handleCreate} onCancel={() => setShowForm(false)} />\n )}\n\n {/* Edit form dialog */}\n {editingResource && (\n <ResourceFormDialog\n resource={editingResource}\n onSave={handleEdit}\n onCancel={() => setEditingResource(null)}\n />\n )}\n\n {/* Delete confirmation */}\n <ConfirmDialog\n isOpen={!!resourceToDelete}\n onClose={() => setResourceToDelete(null)}\n onConfirm={handleConfirmDelete}\n title={t('builtinResources.confirmDelete')}\n message={t('builtinResources.deleteWarning', { name: resourceToDelete?.name || resourceToDelete?.uri || '' })}\n variant=\"danger\"\n />\n </div>\n );\n};\n\nexport default ResourcesPage;\n"],"names":["getBuiltinResources","response","apiGet","createBuiltinResource","resource","apiPost","updateBuiltinResource","id","apiPut","deleteBuiltinResource","apiDelete","useBuiltinResourceData","useTranslation","resources","setResources","useState","loading","setLoading","error","setError","refreshKey","setRefreshKey","fetchResources","useCallback","data","err","triggerRefresh","prev","addResource","result","message","editResource","removeResource","useEffect","ResourceFormDialog","onSave","onCancel","t","isSubmitting","setIsSubmitting","uri","setUri","name","setName","description","setDescription","mimeType","setMimeType","content","setContent","enabled","setEnabled","handleSubmit","e","jsx","jsxs","ResourcesPage","auth","useAuth","showForm","setShowForm","editingResource","setEditingResource","resourceToDelete","setResourceToDelete","expandedIds","setExpandedIds","isAdmin","_a","toggleExpand","next","handleCreate","handleEdit","handleConfirmDelete","Plus","X","FileText","isExpanded","Fragment","Edit","Trash","ChevronUp","ChevronDown","ConfirmDialog"],"mappings":"gTAMO,MAAMA,EAAsB,SAAwC,CACzE,MAAMC,EAA2C,MAAMC,EAAO,YAAY,EAC1E,GAAI,CAACD,EAAS,QACZ,MAAM,IAAI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EAAoB,IAAI,EACvC,UAAWS,EACX,MAAO,EAAE,gCAAgC,EACzC,QAAS,EAAE,iCAAkC,CAAE,MAAMV,GAAA,YAAAA,EAAkB,QAAQA,GAAA,YAAAA,EAAkB,MAAO,GAAI,EAC5G,QAAQ,QAAA,CAAA,CACV,EACF,CAEJ"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./resourceService-BfCTSBsr.js","./index-CmnA4an8.js","./framework-vendor-_OBebcuv.js","./i18n-vendor-MQ921plD.js","./icons-vendor-B67NtVuR.js","./index-DfFHVARX.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as u,j as e,u as ze}from"./framework-vendor-_OBebcuv.js";import{d as Y,e as ve,f as me,h as ge,_ as de,i as Oe,j as Ae,k as _e}from"./index-CmnA4an8.js";import{S as Me}from"./Badge-Ck2fhRdl.js";import{u as he}from"./useSettingsData-D3VROqS7.js";import{S as be}from"./ToggleGroup-HfxdlkGi.js";import{u as Z}from"./i18n-vendor-MQ921plD.js";import{c as Ne,d as we,e as fe,f as Je,C as ce,g as Ce,h as ye,i as ke,P as Se,j as ue,k as xe,W as Ve,b as Ue,F as Be}from"./icons-vendor-B67NtVuR.js";import{D as We}from"./DeleteDialog-BAfrV8EB.js";import{S as Ee,d as Le}from"./variableDetection-C3Xi21av.js";import{u as He}from"./useServerData-QZqQTYcv.js";import{C as qe}from"./ConfirmDialog-uYjffH4V.js";import{P as Ge}from"./Pagination-y-gVO8ms.js";const De=async(s,o)=>{try{const t=o?`/tools/${encodeURIComponent(o)}/${encodeURIComponent(s.toolName)}`:"/tools/call",a=await Y(t,s.arguments,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return a.success===!1?{success:!1,error:a.message||"Tool call failed"}:{success:!0,content:(a==null?void 0:a.content)||[]}}catch(t){return console.error("Error calling tool",{toolName:s.toolName,server:o,error:t}),{success:!1,error:t instanceof Error?t.message:"Unknown error occurred"}}},Ke=async(s,o,t)=>{try{const a=await Y(`/servers/${encodeURIComponent(s)}/tools/${encodeURIComponent(o)}/toggle`,{enabled:t},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:a.success,error:a.success?void 0:a.message}}catch(a){return console.error("Error toggling tool",{serverName:s,toolName:o,enabled:t,error:a}),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}},Pe=async(s,o,t)=>{try{const a=await me(`/servers/${encodeURIComponent(s)}/tools/${encodeURIComponent(o)}/description`,{description:t},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:a.success,error:a.success?void 0:a.message}}catch(a){return console.error("Error updating tool description",{serverName:s,toolName:o,error:a}),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}},Re=async(s,o)=>{var t;try{const a=await ve(`/servers/${encodeURIComponent(s)}/tools/${encodeURIComponent(o)}/description`,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:a.success,error:a.success?void 0:a.message,description:(t=a.data)==null?void 0:t.description}}catch(a){return console.error("Error resetting tool description",{serverName:s,toolName:o,error:a}),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}},Xe=Object.freeze(Object.defineProperty({__proto__:null,callTool:De,resetToolDescription:Re,toggleTool:Ke,updateToolDescription:Pe},Symbol.toStringTag,{value:"Module"})),Te=({schema:s,onSubmit:o,onCancel:t,loading:a=!1,storageKey:d,title:g})=>{const{t:r}=Z(),[x,S]=u.useState({}),[$,l]=u.useState({}),[h,T]=u.useState(!1),[j,R]=u.useState(""),[f,w]=u.useState(""),b=u.useMemo(()=>(c=>{const N=n=>{if(typeof n=="object"&&n!==null){const m=n;return{type:m.type||"string",description:m.description,enum:m.enum,default:m.default,properties:m.properties?Object.fromEntries(Object.entries(m.properties).map(([i,y])=>[i,N(y)])):void 0,required:m.required,items:m.items?N(m.items):void 0}}return{type:"string"}};return{type:c.type,properties:c.properties?Object.fromEntries(Object.entries(c.properties).map(([n,m])=>[n,N(m)])):void 0,required:c.required}})(s),[s]);u.useEffect(()=>{const p=(N,n="")=>{const m={};return N.type==="object"&&N.properties&&Object.entries(N.properties).forEach(([i,y])=>{const A=n?`${n}.${i}`:i;y.default!==void 0?m[i]=y.default:y.type==="string"?m[i]="":y.type==="number"||y.type==="integer"?m[i]=0:y.type==="boolean"?m[i]=!1:y.type==="array"?m[i]=[]:y.type==="object"&&(y.properties?m[i]=p(y,A):m[i]={})}),m};let c=p(b);if(d)try{const N=localStorage.getItem(d);if(N){const n=JSON.parse(N);c={...c,...n}}}catch(N){console.warn("Failed to load saved form data:",N)}S(c)},[b,d]),u.useEffect(()=>{h&&Object.keys(x).length>0&&(R(JSON.stringify(x,null,2)),w(""))},[h,x]);const F=p=>{R(p),w("");try{const c=JSON.parse(p);if(S(c),d)try{localStorage.setItem(d,JSON.stringify(c))}catch(N){console.warn("Failed to save form data to localStorage:",N)}}catch{w(r("tool.invalidJsonFormat"))}},I=()=>{R(JSON.stringify(x,null,2)),w(""),T(!0)},P=()=>{if(j.trim())try{const p=JSON.parse(j);S(p),w(""),T(!1)}catch{w(r("tool.fixJsonBeforeSwitching"));return}else T(!1)},M=(p,c)=>{S(N=>{const n={...N},m=p.split(".");let i=n;for(let y=0;y<m.length-1;y++)i[m[y]]||(i[m[y]]={}),i=i[m[y]];if(i[m[m.length-1]]=c,d)try{localStorage.setItem(d,JSON.stringify(n))}catch(y){console.warn("Failed to save form data to localStorage:",y)}return n}),$[p]&&l(N=>{const n={...N};return delete n[p],n})},B=()=>{const p={},c=(N,n,m="")=>{N.type==="object"&&N.properties&&Object.entries(N.properties).forEach(([i,y])=>{var L;const A=m?`${m}.${i}`:i,z=n==null?void 0:n[i];if((L=N.required)!=null&&L.includes(i)&&(z==null||z===""||Array.isArray(z)&&z.length===0)){p[A]=`${i} is required`;return}z!=null&&z!==""&&(y.type==="string"&&typeof z!="string"?p[A]=`${i} must be a string`:y.type==="number"&&typeof z!="number"?p[A]=`${i} must be a number`:y.type==="integer"&&(!Number.isInteger(z)||typeof z!="number")?p[A]=`${i} must be an integer`:y.type==="boolean"&&typeof z!="boolean"?p[A]=`${i} must be a boolean`:y.type==="array"&&Array.isArray(z)?y.items&&z.forEach((k,J)=>{var E;((E=y.items)==null?void 0:E.type)==="object"&&y.items.properties&&c(y.items,k,`${A}.${J}`)}):y.type==="object"&&typeof z=="object"&&c(y,z,A))})};return c(b,x),l(p),Object.keys(p).length===0},U=p=>{p.preventDefault(),B()&&o(x)},W=(p,c)=>c.split(".").reduce((N,n)=>N==null?void 0:N[n],p),K=(p,c,N,n)=>{const m=N==null?void 0:N[p];return c.type==="string"?c.enum?e.jsxs("select",{value:m||"",onChange:i=>n(i.target.value),className:"w-full border rounded-md px-2 py-1 text-sm border-gray-300 focus:outline-none focus:ring-1 focus:ring-blue-500",children:[e.jsx("option",{value:"",children:r("tool.selectOption")}),c.enum.map((i,y)=>e.jsx("option",{value:i,children:i},y))]}):e.jsx("input",{type:"text",value:m||"",onChange:i=>n(i.target.value),className:"w-full border rounded-md px-2 py-1 text-sm border-gray-300 focus:outline-none focus:ring-1 focus:ring-blue-500 form-input",placeholder:c.description||r("tool.enterKey",{key:p})}):c.type==="number"||c.type==="integer"?e.jsx("input",{type:"number",step:c.type==="integer"?"1":"any",value:m??"",onChange:i=>{const y=i.target.value===""?"":c.type==="integer"?parseInt(i.target.value):parseFloat(i.target.value);n(y)},className:"w-full border rounded-md px-2 py-1 text-sm border-gray-300 focus:outline-none focus:ring-1 focus:ring-blue-500 form-input"}):c.type==="boolean"?e.jsx("input",{type:"checkbox",checked:m||!1,onChange:i=>n(i.target.checked),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}):e.jsx("input",{type:"text",value:m||"",onChange:i=>n(i.target.value),className:"w-full border rounded-md px-2 py-1 text-sm border-gray-300 focus:outline-none focus:ring-1 focus:ring-blue-500 form-input",placeholder:c.description||r("tool.enterKey",{key:p})})},H=(p,c,N="")=>{var y,A,z,L,k,J,E,V,Q,se,re,ae,ne,oe;const n=N?`${N}.${p}`:p,m=W(x,n),i=$[n];if(c.type==="array"){const _=W(x,n)||[];return e.jsxs("div",{className:"mb-6",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[p,(N?(A=(y=W(b,N))==null?void 0:y.required)==null?void 0:A.includes(p):(z=b.required)==null?void 0:z.includes(p))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:c.description}),e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-md p-3 bg-gray-50 dark:bg-gray-800",children:[_.map((q,X)=>{var le,v,D;return e.jsxs("div",{className:"mb-3 p-3 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-md",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-600",children:r("tool.item",{index:X+1})}),e.jsx("button",{type:"button",onClick:()=>{const C=[..._];C.splice(X,1),M(n,C)},className:"text-status-red hover:text-red-700 text-sm",children:r("common.remove")})]}),((le=c.items)==null?void 0:le.type)==="string"&&c.items.enum?e.jsxs("select",{value:q||"",onChange:C=>{const O=[..._];O[X]=C.target.value,M(n,O)},className:"w-full border rounded-md px-3 py-2 border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"",children:r("tool.selectOption")}),c.items.enum.map((C,O)=>e.jsx("option",{value:C,children:C},O))]}):((v=c.items)==null?void 0:v.type)==="object"&&c.items.properties?e.jsx("div",{className:"space-y-3",children:Object.entries(c.items.properties).map(([C,O])=>{var G,ee;return e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:[C,((ee=(G=c.items)==null?void 0:G.required)==null?void 0:ee.includes(C))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),K(C,O,q,pe=>{const ie=[..._];ie[X]={...ie[X],[C]:pe},M(n,ie)})]},C)})}):e.jsx("input",{type:"text",value:q||"",onChange:C=>{const O=[..._];O[X]=C.target.value,M(n,O)},className:"w-full border rounded-md px-3 py-2 border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 form-input",placeholder:r("tool.enterValue",{type:((D=c.items)==null?void 0:D.type)||"value"})})]},X)}),e.jsx("button",{type:"button",onClick:()=>{var X;const q=((X=c.items)==null?void 0:X.type)==="object"?{}:"";M(n,[..._,q])},className:"w-full mt-2 px-3 py-2 text-sm text-blue-600 border border-blue-300 rounded-md hover:bg-blue-50",children:r("tool.addItem",{key:p})})]}),i&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:i})]},n)}return c.type==="object"?c.properties?e.jsxs("div",{className:"mb-6",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[p,(N?(k=(L=W(b,N))==null?void 0:L.required)==null?void 0:k.includes(p):(J=b.required)==null?void 0:J.includes(p))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:c.description}),e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-md p-4 bg-gray-50 dark:bg-gray-800",children:Object.entries(c.properties).map(([_,q])=>H(_,q,n))}),i&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:i})]},n):e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[p,(N?(V=(E=W(b,N))==null?void 0:E.required)==null?void 0:V.includes(p):(Q=b.required)==null?void 0:Q.includes(p))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"}),e.jsx("span",{className:"text-xs text-gray-500 ml-1",children:"(JSON object)"})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:c.description}),e.jsx("textarea",{value:typeof m=="object"?JSON.stringify(m,null,2):m||"{}",onChange:_=>{try{const q=JSON.parse(_.target.value);M(n,q)}catch{M(n,_.target.value)}},placeholder:`{
|
|
3
|
+
"key": "value"
|
|
4
|
+
}`,className:`w-full border rounded-md px-3 py-2 font-mono text-sm ${i?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`,rows:4}),i&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:i})]},n):c.type==="string"?c.enum?e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[p,(N?!1:(se=b.required)==null?void 0:se.includes(p))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:c.description}),e.jsxs("select",{value:m||"",onChange:_=>M(n,_.target.value),className:`w-full border rounded-md px-3 py-2 ${i?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[e.jsx("option",{value:"",children:r("tool.selectOption")}),c.enum.map((_,q)=>e.jsx("option",{value:_,children:_},q))]}),i&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:i})]},n):e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[p,(N?!1:(re=b.required)==null?void 0:re.includes(p))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:c.description}),e.jsx("input",{type:"text",value:m||"",onChange:_=>M(n,_.target.value),className:`w-full border rounded-md px-3 py-2 ${i?"border-red":"border-gray-200"} focus:outline-none form-input`}),i&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:i})]},n):c.type==="number"||c.type==="integer"?e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[p,(N?!1:(ae=b.required)==null?void 0:ae.includes(p))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:c.description}),e.jsx("input",{type:"number",step:c.type==="integer"?"1":"any",value:m??"",onChange:_=>{const q=_.target.value===""?"":c.type==="integer"?parseInt(_.target.value):parseFloat(_.target.value);M(n,q)},className:`w-full border rounded-md px-3 py-2 form-input ${i?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`}),i&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:i})]},n):c.type==="boolean"?e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("input",{type:"checkbox",checked:m||!1,onChange:_=>M(n,_.target.checked),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),e.jsxs("label",{className:"ml-2 block text-sm text-gray-700",children:[p,(N?!1:(ne=b.required)==null?void 0:ne.includes(p))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:c.description}),i&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:i})]},n):e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[p,(N?!1:(oe=b.required)==null?void 0:oe.includes(p))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"}),e.jsxs("span",{className:"text-xs text-gray-500 ml-1",children:["(",c.type,")"]})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:c.description}),e.jsx("input",{type:"text",value:m||"",onChange:_=>M(n,_.target.value),placeholder:r("tool.enterValue",{type:c.type}),className:`w-full border rounded-md px-3 py-2 ${i?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500 form-input`}),i&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:i})]},n)};return b.properties?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-center pb-3",children:[e.jsx("h6",{className:"text-md font-medium text-gray-900",children:g}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx("button",{type:"button",onClick:P,className:`px-3 py-1 text-sm rounded-md transition-colors ${h?"text-sm text-gray-600 bg-gray-200 rounded hover:bg-gray-300 btn-secondary":"bg-blue-100 text-blue-800 rounded hover:bg-blue-200 text-sm btn-primary"}`,children:r("tool.formMode")}),e.jsx("button",{type:"button",onClick:I,className:`px-3 py-1 text-sm rounded-md transition-colors ${h?"px-4 py-1 bg-blue-100 text-blue-800 rounded hover:bg-blue-200 text-sm btn-primary":"text-sm text-gray-600 bg-gray-200 rounded hover:bg-gray-300 btn-secondary"}`,children:r("tool.jsonMode")})]})]}),h?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:r("tool.jsonConfiguration")}),e.jsx("textarea",{value:j,onChange:p=>F(p.target.value),placeholder:`{
|
|
5
|
+
"key": "value"
|
|
6
|
+
}`,className:`w-full h-64 border rounded-md px-3 py-2 font-mono text-sm resize-y form-input ${f?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`}),f&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:f})]}),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx("button",{type:"button",onClick:t,className:"px-4 py-1 text-sm text-gray-600 bg-gray-200 rounded hover:bg-gray-300 btn-secondary",children:r("tool.cancel")}),e.jsx("button",{onClick:()=>{try{const p=JSON.parse(j);o(p)}catch{w(r("tool.invalidJsonFormat"))}},disabled:a||!!f,className:"px-4 py-1 bg-blue-100 text-blue-800 rounded hover:bg-blue-200 text-sm btn-primary",children:r(a?"tool.running":"tool.runTool")})]})]}):e.jsxs("form",{onSubmit:U,className:"space-y-4",children:[Object.entries(b.properties||{}).map(([p,c])=>H(p,c)),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx("button",{type:"button",onClick:t,className:"px-4 py-1 text-sm text-gray-600 bg-gray-200 rounded hover:bg-gray-300 btn-secondary",children:r("tool.cancel")}),e.jsx("button",{type:"submit",disabled:a,className:"px-4 py-1 bg-blue-100 text-blue-800 rounded hover:bg-blue-200 text-sm btn-primary",children:r(a?"tool.running":"tool.runTool")})]})]})]}):e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsx("p",{className:"text-sm text-gray-600",children:r("tool.noParameters")}),e.jsxs("div",{className:"flex justify-end space-x-2 mt-4",children:[e.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm text-gray-600 bg-gray-100 dark:bg-gray-800 rounded-md hover:bg-gray-200",children:r("tool.cancel")}),e.jsx("button",{onClick:()=>o({}),disabled:a,className:"px-4 py-2 text-sm text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:opacity-50",children:r(a?"tool.running":"tool.runTool")})]})]})},Ze=({result:s,onClose:o})=>{const{t}=Z(),a=s.content,d=l=>l?l.startsWith("image/")?l:`image/${l}`:"image/png",g=l=>{if(!l)return[];if(Array.isArray(l))return l.flatMap(j=>g(j));if(typeof l!="object")return[];const h=[];l.type==="image"&&l.data&&h.push({data:String(l.data),mimeType:d(l.mimeType||l.mime_type)});const T=l.image_base64||l.imageBase64||l.image_data||l.imageData||l.base64;return T&&h.push({data:String(T),mimeType:d(l.image_mimeType||l.image_mime_type||l.mimeType||l.mime_type)}),l.image&&typeof l.image=="object"&&h.push(...g(l.image)),Array.isArray(l.images)&&h.push(...g(l.images)),Array.isArray(l.content)&&h.push(...g(l.content)),h},r=l=>{const h=[];try{const R=JSON.parse(l);if(h.push(...g(R)),h.length>0)return h}catch{}const T=/data:image\/(png|jpe?g|gif|webp);base64,([A-Za-z0-9+/=]+)/g;let j;for(;(j=T.exec(l))!==null;){const R=`image/${j[1]==="jpg"?"jpeg":j[1]}`;h.push({data:j[2],mimeType:R})}return h},x=l=>{try{const h=JSON.parse(l),T=j=>{if(Array.isArray(j))return j.map(T);if(j&&typeof j=="object"){const R={};for(const[f,w]of Object.entries(j))typeof w=="string"&&f.toLowerCase().includes("base64")?R[f]="[base64 omitted]":R[f]=T(w);return R}return j};return JSON.stringify(T(h),null,2)}catch{return l.replace(/data:image\/(png|jpe?g|gif|webp);base64,[A-Za-z0-9+/=]+/g,"[image data omitted]")}},S=l=>Array.isArray(l)?l.map((h,T)=>e.jsx("div",{className:"mb-3 last:mb-0",children:$(h)},T)):$(l),$=l=>{if(typeof l=="string"){const h=r(l),T=x(l);return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[h.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:h.map((j,R)=>e.jsx("img",{src:`data:${j.mimeType||"image/png"};base64,${j.data}`,alt:t("tool.toolResult"),className:"max-w-full h-auto rounded-md"},R))}),e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:T})]})}if(typeof l=="object"&&l!==null){if(l.type==="text"&&l.text){const h=r(l.text),T=x(l.text);return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[h.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:h.map((j,R)=>e.jsx("img",{src:`data:${j.mimeType||"image/png"};base64,${j.data}`,alt:t("tool.toolResult"),className:"max-w-full h-auto rounded-md"},R))}),e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:T})]})}if(l.type==="image"&&l.data)return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("img",{src:`data:${l.mimeType||"image/png"};base64,${l.data}`,alt:t("tool.toolResult"),className:"max-w-full h-auto rounded-md"})});try{const h=typeof l=="string"?JSON.parse(l):l;return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-2",children:t("tool.jsonResponse")}),e.jsx("pre",{className:"text-sm text-gray-800 overflow-auto",children:JSON.stringify(h,null,2)})]})}catch{return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:String(l)})})}}return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:String(l)})})};return e.jsxs("div",{className:"border border-gray-300 rounded-lg bg-white dark:bg-gray-800 shadow-sm",children:[e.jsx("div",{className:"border-b border-gray-300 px-4 py-3 bg-gray-50 dark:bg-gray-800 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[s.success?e.jsx(Ne,{size:20,className:"text-status-green"}):e.jsx(we,{size:20,className:"text-status-red"}),e.jsx("div",{children:e.jsxs("h4",{className:"text-sm font-medium text-gray-900",children:[t("tool.execution")," ",s.success?t("tool.successful"):t("tool.failed")]})})]}),e.jsx("button",{onClick:o,className:"text-gray-400 hover:text-gray-600 text-sm",children:"✕"})]})}),e.jsx("div",{className:"p-4",children:s.success?e.jsx("div",{children:s.content&&s.content.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-600 mb-3",children:t("tool.result")}),S(s.content)]}):e.jsx("div",{className:"text-sm text-gray-500 italic",children:t("tool.noContent")})}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-3",children:[e.jsx(fe,{size:16,className:"text-red-500"}),e.jsx("span",{className:"text-sm font-medium text-red-700",children:t("tool.error")})]}),a&&a.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-600 mb-3",children:t("tool.errorDetails")}),S(a)]}):e.jsx("div",{className:"bg-red-50 border border-red-300 rounded-md p-3",children:e.jsx("pre",{className:"text-sm text-red-800 whitespace-pre-wrap",children:s.error||s.message||t("tool.unknownError")})})]})})]})},te=({title:s,onClick:o,disabled:t=!1,loading:a=!1})=>e.jsx("button",{type:"button",className:"ml-2 p-1 text-amber-600 hover:text-amber-700 cursor-pointer transition-colors disabled:opacity-60 disabled:cursor-not-allowed",onClick:o,disabled:t,title:s,"aria-label":s,children:e.jsx(Je,{size:14,className:a?"animate-spin":""})});function Ye(s){return s==null?!0:typeof s=="string"?s.trim()==="":Array.isArray(s)?s.length===0:typeof s=="object"?Object.keys(s).length===0:!1}const Qe=({tool:s,server:o,onToggle:t,onDescriptionUpdate:a})=>{const{t:d}=Z(),{showToast:g}=ge(),{nameSeparator:r}=he(),[x,S]=u.useState(!1),[$,l]=u.useState(!1),[h,T]=u.useState(!1),[j,R]=u.useState(null),[f,w]=u.useState(!1),[b,F]=u.useState(!1),[I,P]=u.useState(s.description||""),M=u.useRef(null),B=u.useRef(null),[U,W]=u.useState(0),[K,H]=u.useState(!1);u.useEffect(()=>{f&&M.current&&(M.current.focus(),U>0&&(M.current.style.width=`${U+20}px`))},[f,U]),u.useEffect(()=>{!f&&B.current&&W(B.current.offsetWidth)},[f,I]),u.useEffect(()=>{P(s.description||"")},[s.description]);const p=u.useCallback(()=>`mcphub_tool_form_${o?`${o}_`:""}${s.name}`,[s.name,o]),c=u.useCallback(()=>{localStorage.removeItem(p())},[p]),N=E=>{t&&t(s.name,E)},n=()=>{w(!0)},m=async()=>{try{const E=await Pe(o,s.name,I);E.success?(w(!1),a&&a(s.name,I)):(P(s.description||""),console.error("Failed to update tool description:",E.error))}catch(E){console.error("Error updating tool description:",E),P(s.description||""),w(!1)}},i=E=>{P(E.target.value)},y=async()=>{F(!0);try{const E=await Re(o,s.name);if(E.success){const V=E.description||"";P(V),w(!1),a==null||a(s.name,V,{restored:!0})}else g(E.error||d("tool.restoreDefaultFailed"),"error")}catch(E){console.error("Error resetting tool description:",E),g(d("tool.restoreDefaultFailed"),"error")}finally{F(!1)}},A=E=>{E.key==="Enter"?m():E.key==="Escape"&&(P(s.description||""),w(!1))},z=async E=>{E.stopPropagation();try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(s.name),H(!0),g(d("common.copySuccess"),"success"),setTimeout(()=>H(!1),2e3);else{const V=document.createElement("textarea");V.value=s.name,V.style.position="fixed",V.style.left="-9999px",document.body.appendChild(V),V.focus(),V.select();try{document.execCommand("copy"),H(!0),g(d("common.copySuccess"),"success"),setTimeout(()=>H(!1),2e3)}catch(Q){g(d("common.copyFailed"),"error"),console.error("Copy to clipboard failed:",Q)}document.body.removeChild(V)}}catch(V){g(d("common.copyFailed"),"error"),console.error("Copy to clipboard failed:",V)}},L=async E=>{T(!0);try{E=Object.fromEntries(Object.entries(E).filter(([Q,se])=>!Ye(se)));const V=await De({toolName:s.name,arguments:E},o);R(V)}catch(V){R({success:!1,error:V instanceof Error?V.message:"Unknown error occurred"})}finally{T(!1)}},k=()=>{l(!1),c(),R(null)},J=()=>{R(null)};return e.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 shadow rounded-lg mb-4",children:[e.jsxs("div",{className:"flex justify-between items-center cursor-pointer p-2",onClick:E=>{E.stopPropagation(),S(!x)},children:[e.jsx("div",{className:"flex-1",children:e.jsxs("h3",{className:"text-lg font-medium text-gray-900 inline-flex items-center",children:[s.name.replace(o+r,""),e.jsx("button",{className:"ml-2 p-1 text-gray-500 hover:text-blue-600 cursor-pointer transition-colors",onClick:z,title:d("common.copy"),children:K?e.jsx(ce,{size:16,className:"text-green-500"}):e.jsx(Ce,{size:16})}),e.jsx("span",{className:"ml-2 text-sm font-normal text-gray-600 inline-flex items-center",children:f?e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:M,type:"text",className:"px-2 py-1 border border-blue-300 rounded bg-white dark:bg-gray-800 text-sm focus:outline-none form-input",value:I,onChange:i,onKeyDown:A,onClick:E=>E.stopPropagation(),style:{minWidth:"100px",width:U>0?`${U+20}px`:"auto"}}),e.jsx("button",{className:"ml-2 p-1 text-green-600 hover:text-green-800 cursor-pointer transition-colors",onClick:E=>{E.stopPropagation(),m()},disabled:b,children:e.jsx(ce,{size:16})}),e.jsx(te,{title:d("tool.restoreDefault"),onClick:E=>{E.stopPropagation(),y()},disabled:b,loading:b})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:B,children:I||d("tool.noDescription")}),e.jsx("button",{className:"ml-2 p-1 text-gray-500 hover:text-blue-600 cursor-pointer transition-colors",onClick:E=>{E.stopPropagation(),n()},children:e.jsx(ye,{size:14})}),e.jsx(te,{title:d("tool.restoreDefault"),onClick:E=>{E.stopPropagation(),y()},disabled:b,loading:b})]})})]})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"flex items-center space-x-2",onClick:E=>E.stopPropagation(),children:e.jsx(be,{checked:s.enabled??!0,onCheckedChange:N,disabled:h})}),e.jsxs("button",{onClick:E=>{E.stopPropagation(),S(!0),l(!0)},className:"flex items-center space-x-1 px-3 py-1 text-sm text-blue-600 bg-blue-50 hover:bg-blue-100 rounded-md transition-colors btn-primary",disabled:h||!s.enabled,children:[h?e.jsx(ke,{size:14,className:"animate-spin"}):e.jsx(Se,{size:14}),e.jsx("span",{children:d(h?"tool.running":"tool.run")})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",children:x?e.jsx(ue,{size:18}):e.jsx(xe,{size:18})})]})]}),x&&e.jsxs("div",{className:"mt-4 space-y-4",children:[!$&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded p-3 border border-gray-300",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 mb-2",children:d("tool.inputSchema")}),e.jsx("pre",{className:"text-xs text-gray-600 overflow-auto",children:JSON.stringify(s.inputSchema,null,2)})]}),$&&e.jsxs("div",{className:"border border-gray-300 rounded-lg p-4",children:[e.jsx(Te,{schema:s.inputSchema||{type:"object"},onSubmit:L,onCancel:k,loading:h,storageKey:p(),title:d("tool.runToolWithName",{name:s.name.replace(o+r,"")})}),j&&e.jsx("div",{className:"mt-4",children:e.jsx(Ze,{result:j,onClose:J})})]})]})]})},es=async(s,o)=>{try{const t=o?`/prompts/call/${o}`:"/prompts/call",a=await Y(t,{promptName:s.promptName,arguments:s.arguments});return a.success?{success:!0,data:a.data}:{success:!1,error:a.message||"Prompt call failed"}}catch(t){return console.error("Error calling prompt",{promptName:s.promptName,server:o,error:t}),{success:!1,error:t instanceof Error?t.message:"Unknown error occurred"}}},$e=async(s,o)=>{try{const t=await Y(`/mcp/${encodeURIComponent(o||"")}/prompts/${encodeURIComponent(s.promptName)}`,{name:s.promptName,arguments:s.arguments});if(!t.success)throw new Error(`Failed to get prompt: ${t.message||"Unknown error"}`);return{success:!0,data:t.data}}catch(t){return console.error("Error getting prompt",{promptName:s.promptName,server:o,error:t}),{success:!1,error:t instanceof Error?t.message:"Unknown error occurred"}}},ss=async(s,o,t)=>{try{const a=await Y(`/servers/${encodeURIComponent(s)}/prompts/${encodeURIComponent(o)}/toggle`,{enabled:t});return{success:a.success,error:a.success?void 0:a.message}}catch(a){return console.error("Error toggling prompt",{serverName:s,promptName:o,enabled:t,error:a}),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}},Ie=async(s,o,t)=>{try{const a=await me(`/servers/${encodeURIComponent(s)}/prompts/${encodeURIComponent(o)}/description`,{description:t},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:a.success,error:a.success?void 0:a.message}}catch(a){return console.error("Error updating prompt description",{serverName:s,promptName:o,error:a}),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}},Fe=async(s,o)=>{var t;try{const a=await ve(`/servers/${encodeURIComponent(s)}/prompts/${encodeURIComponent(o)}/description`,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:a.success,error:a.success?void 0:a.message,description:(t=a.data)==null?void 0:t.description}}catch(a){return console.error("Error resetting prompt description",{serverName:s,promptName:o,error:a}),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}},ts=Object.freeze(Object.defineProperty({__proto__:null,callPrompt:es,getPrompt:$e,resetPromptDescription:Fe,togglePrompt:ss,updatePromptDescription:Ie},Symbol.toStringTag,{value:"Module"})),je=({result:s,onClose:o})=>{const{t}=Z(),a=d=>{if(typeof d=="string")return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:d})});if(typeof d=="object"&&d!==null){if(d.description||d.messages)return e.jsxs("div",{className:"space-y-4",children:[d.description&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 mb-2",children:t("prompt.description")}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("p",{className:"text-sm text-gray-800",children:d.description})})]}),d.messages&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 mb-2",children:t("prompt.messages")}),e.jsx("div",{className:"space-y-3",children:d.messages.map((g,r)=>e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[e.jsx("div",{className:"flex items-center mb-2",children:e.jsxs("span",{className:"inline-block w-16 text-xs font-medium text-gray-500",children:[g.role,":"]})}),typeof g.content=="string"?e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:g.content}):typeof g.content=="object"&&g.content.type==="text"?e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:g.content.text}):e.jsx("pre",{className:"text-sm text-gray-800 overflow-auto",children:JSON.stringify(g.content,null,2)})]},r))})]})]});try{const g=typeof d=="string"?JSON.parse(d):d;return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-2",children:t("prompt.jsonResponse")}),e.jsx("pre",{className:"text-sm text-gray-800 overflow-auto",children:JSON.stringify(g,null,2)})]})}catch{return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:String(d)})})}}return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:String(d)})})};return e.jsxs("div",{className:"border border-gray-300 rounded-lg bg-white dark:bg-gray-800 shadow-sm",children:[e.jsx("div",{className:"border-b border-gray-300 px-4 py-3 bg-gray-50 dark:bg-gray-800 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[s.success?e.jsx(Ne,{size:20,className:"text-status-green"}):e.jsx(we,{size:20,className:"text-status-red"}),e.jsx("div",{children:e.jsxs("h4",{className:"text-sm font-medium text-gray-900",children:[t("prompt.execution")," ",s.success?t("prompt.successful"):t("prompt.failed")]})})]}),e.jsx("button",{onClick:o,className:"text-gray-400 hover:text-gray-600 text-sm",children:"✕"})]})}),e.jsx("div",{className:"p-4",children:s.success?e.jsx("div",{children:s.data?e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-600 mb-3",children:t("prompt.result")}),a(s.data)]}):e.jsx("div",{className:"text-sm text-gray-500 italic",children:t("prompt.noContent")})}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-3",children:[e.jsx(fe,{size:16,className:"text-red-500"}),e.jsx("span",{className:"text-sm font-medium text-red-700",children:t("prompt.error")})]}),e.jsx("div",{className:"bg-red-50 border border-red-300 rounded-md p-3",children:e.jsx("pre",{className:"text-sm text-red-800 whitespace-pre-wrap",children:s.error||s.message||t("prompt.unknownError")})})]})})]})},rs=({prompt:s,server:o,onToggle:t,onDescriptionUpdate:a})=>{const{t:d}=Z(),{showToast:g}=ge(),{nameSeparator:r}=he(),[x,S]=u.useState(!1),[$,l]=u.useState(!1),[h,T]=u.useState(!1),[j,R]=u.useState(null),[f,w]=u.useState(!1),[b,F]=u.useState(!1),[I,P]=u.useState(s.description||""),M=u.useRef(null),B=u.useRef(null),[U,W]=u.useState(0);u.useEffect(()=>{f&&M.current&&(M.current.focus(),U>0&&(M.current.style.width=`${U+20}px`))},[f,U]),u.useEffect(()=>{!f&&B.current&&W(B.current.offsetWidth)},[f,I]),u.useEffect(()=>{P(s.description||"")},[s.description]);const K=u.useCallback(()=>`mcphub_prompt_form_${o?`${o}_`:""}${s.name}`,[s.name,o]),H=u.useCallback(()=>{localStorage.removeItem(K())},[K]),p=k=>{t&&t(s.name,k)},c=()=>{w(!0)},N=async()=>{w(!1);try{const k=await Ie(o,s.name,I);k.success?a&&a(s.name,I):(g(k.error||d("prompt.descriptionUpdateFailed"),"error"),P(s.description||""))}catch(k){console.error("Error updating prompt description:",k),g(d("prompt.descriptionUpdateFailed"),"error"),P(s.description||"")}},n=async()=>{F(!0);try{const k=await Fe(o,s.name);if(k.success){const J=k.description||"";P(J),w(!1),a==null||a(s.name,J,{restored:!0})}else g(k.error||d("prompt.restoreDefaultFailed"),"error")}catch(k){console.error("Error resetting prompt description:",k),g(d("prompt.restoreDefaultFailed"),"error")}finally{F(!1)}},m=k=>{P(k.target.value)},i=k=>{k.key==="Enter"?N():k.key==="Escape"&&(P(s.description||""),w(!1))},y=async k=>{T(!0);try{const J=await $e({promptName:s.name,arguments:k},o);console.log("GetPrompt result:",J),R({success:J.success,data:J.data,error:J.error})}catch(J){R({success:!1,error:J instanceof Error?J.message:"Unknown error occurred"})}finally{T(!1)}},A=()=>{l(!1),H(),R(null)},z=()=>{R(null)},L=()=>{if(!s.arguments||s.arguments.length===0)return{type:"object",properties:{},required:[]};const k={},J=[];return s.arguments.forEach(E=>{k[E.name]={type:"string",description:E.description||""},E.required&&J.push(E.name)}),{type:"object",properties:k,required:J}};return e.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 shadow rounded-lg mb-4",children:[e.jsxs("div",{className:"flex justify-between items-center p-2 cursor-pointer",onClick:()=>S(!x),children:[e.jsx("div",{className:"flex-1",children:e.jsxs("h3",{className:"text-lg font-medium text-gray-900",children:[s.name.replace(o+r,""),s.title&&e.jsx("span",{className:"ml-2 text-sm font-normal text-gray-600",children:s.title}),e.jsx("span",{className:"ml-2 text-sm font-normal text-gray-500 inline-flex items-center",children:f?e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:M,type:"text",className:"px-2 py-1 border border-blue-300 rounded bg-white dark:bg-gray-800 text-sm focus:outline-none form-input",value:I,onChange:m,onKeyDown:i,onClick:k=>k.stopPropagation(),style:{minWidth:"100px",width:U>0?`${U+20}px`:"auto"}}),e.jsx("button",{className:"ml-2 p-1 text-green-600 hover:text-green-800 cursor-pointer transition-colors",onClick:k=>{k.stopPropagation(),N()},disabled:b,children:e.jsx(ce,{size:16})}),e.jsx(te,{title:d("prompt.restoreDefault"),onClick:k=>{k.stopPropagation(),n()},disabled:b,loading:b})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:B,children:I||d("tool.noDescription")}),e.jsx("button",{className:"ml-2 p-1 text-gray-500 hover:text-blue-600 cursor-pointer transition-colors",onClick:k=>{k.stopPropagation(),c()},children:e.jsx(ye,{size:14})}),e.jsx(te,{title:d("prompt.restoreDefault"),onClick:k=>{k.stopPropagation(),n()},disabled:b,loading:b})]})})]})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"flex items-center space-x-2",onClick:k=>k.stopPropagation(),children:s.enabled!==void 0&&e.jsx(be,{checked:s.enabled,onCheckedChange:p,disabled:h})}),e.jsxs("button",{onClick:k=>{k.stopPropagation(),S(!0),l(!0)},className:"flex items-center space-x-1 px-3 py-1 text-sm text-blue-600 bg-blue-50 hover:bg-blue-100 rounded-md transition-colors btn-primary",disabled:h||!s.enabled,children:[h?e.jsx(ke,{size:14,className:"animate-spin"}):e.jsx(Se,{size:14}),e.jsx("span",{children:d(h?"tool.running":"tool.run")})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",children:x?e.jsx(ue,{size:18}):e.jsx(xe,{size:18})})]})]}),x&&e.jsxs("div",{className:"mt-4 space-y-4",children:[$&&e.jsxs("div",{className:"border border-gray-300 rounded-lg p-4",children:[e.jsx(Te,{schema:L(),onSubmit:y,onCancel:A,loading:h,storageKey:K(),title:d("prompt.runPromptWithName",{name:s.name.replace(o+r,"")})}),j&&e.jsx("div",{className:"mt-4",children:e.jsx(je,{result:j,onClose:z})})]}),!$&&s.arguments&&s.arguments.length>0&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded p-3 border border-gray-300",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 mb-2",children:d("tool.parameters")}),e.jsx("div",{className:"space-y-2",children:s.arguments.map((k,J)=>e.jsxs("div",{className:"flex items-start",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{className:"font-medium text-gray-700",children:k.name}),k.required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),k.description&&e.jsx("p",{className:"text-sm text-gray-600 mt-1",children:k.description})]}),e.jsx("div",{className:"text-xs text-gray-500 ml-2",children:k.title||""})]},J))})]}),!$&&j&&e.jsx("div",{className:"mt-4",children:e.jsx(je,{result:j,onClose:z})})]})]})},as=({resource:s,onToggle:o,onDescriptionUpdate:t})=>{const{t:a}=Z(),[d,g]=u.useState(!1),[r,x]=u.useState(!1),[S,$]=u.useState(!1),[l,h]=u.useState(s.description||""),T=u.useRef(null),j=u.useRef(null),[R,f]=u.useState(0);u.useEffect(()=>{r&&T.current&&(T.current.focus(),R>0&&(T.current.style.width=`${R+20}px`))},[r,R]),u.useEffect(()=>{!r&&j.current&&f(j.current.offsetWidth)},[r,l]),u.useEffect(()=>{h(s.description||"")},[s.description]);const w=P=>{o&&o(s.uri,P)},b=async()=>{x(!1),t&&await t(s.uri,l)},F=async()=>{$(!0);try{await(t==null?void 0:t(s.uri,"",{restored:!0})),x(!1)}finally{$(!1)}},I=P=>{P.key==="Enter"?b():P.key==="Escape"&&(h(s.description||""),x(!1))};return e.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 shadow rounded-lg mb-4",children:[e.jsxs("div",{className:"flex justify-between items-center p-2 cursor-pointer",onClick:()=>g(!d),children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900 truncate",children:s.name||s.uri}),e.jsx("div",{className:"text-sm text-gray-500 truncate",children:s.uri}),e.jsx("span",{className:"text-sm font-normal text-gray-500 inline-flex items-center mt-1",children:r?e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:T,type:"text",className:"px-2 py-1 border border-blue-300 rounded bg-white dark:bg-gray-800 text-sm focus:outline-none form-input",value:l,onChange:P=>h(P.target.value),onKeyDown:I,onClick:P=>P.stopPropagation(),style:{minWidth:"100px",width:R>0?`${R+20}px`:"auto"}}),e.jsx("button",{className:"ml-2 p-1 text-green-600 hover:text-green-800 cursor-pointer transition-colors",onClick:P=>{P.stopPropagation(),b()},disabled:S,children:e.jsx(ce,{size:16})}),e.jsx(te,{title:a("builtinResources.restoreDefault"),onClick:P=>{P.stopPropagation(),F()},disabled:S,loading:S})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:j,children:l||a("tool.noDescription")}),e.jsx("button",{className:"ml-2 p-1 text-gray-500 hover:text-blue-600 cursor-pointer transition-colors",onClick:P=>{P.stopPropagation(),x(!0)},children:e.jsx(ye,{size:14})}),e.jsx(te,{title:a("builtinResources.restoreDefault"),onClick:P=>{P.stopPropagation(),F()},disabled:S,loading:S})]})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"flex items-center space-x-2",onClick:P=>P.stopPropagation(),children:e.jsx(be,{checked:s.enabled!==!1,onCheckedChange:w})}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",children:d?e.jsx(ue,{size:18}):e.jsx(xe,{size:18})})]})]}),d&&e.jsx("div",{className:"mt-2 px-3 pb-3 text-sm text-gray-600 border-t border-gray-100 dark:border-gray-800",children:e.jsxs("div",{className:"pt-2",children:[e.jsxs("span",{className:"font-medium",children:[a("builtinResources.mimeType"),":"]})," ",s.mimeType||"text/plain"]})})]})},ns=({server:s,onRemove:o,onEdit:t,onToggle:a,onRefresh:d,onReload:g})=>{var re,ae,ne,oe,_,q,X,le;const{t:r}=Z(),{showToast:x}=ge(),[S,$]=u.useState(null),[l,h]=u.useState(!1),[T,j]=u.useState(!1),[R,f]=u.useState(!1),[w,b]=u.useState(!1),[F,I]=u.useState(!1),P=u.useRef(null);u.useEffect(()=>{const v=D=>{P.current&&!P.current.contains(D.target)&&b(!1)};return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[]);const{exportMCPSettings:M}=he(),B=((re=s.tools)==null?void 0:re.length)||0,U=((ae=s.tools)==null?void 0:ae.filter(v=>v.enabled!==!1).length)||0,W=((ne=s.prompts)==null?void 0:ne.length)||0,K=((oe=s.prompts)==null?void 0:oe.filter(v=>v.enabled!==!1).length)||0,H=((_=s.resources)==null?void 0:_.length)||0,p=((q=s.resources)==null?void 0:q.filter(v=>v.enabled!==!1).length)||0,c=v=>{v.stopPropagation(),h(!0)},N=v=>{v.stopPropagation(),t(s)},n=async v=>{if(v.stopPropagation(),!(T||!a)){j(!0);try{await a(s,s.enabled===!1)}finally{j(!1)}}},m=async v=>{if(v.stopPropagation(),!(R||!g)){f(!0);try{await g(s)?x(r("server.reloadSuccess")||"Server reloaded successfully","success"):x(r("server.reloadError",{serverName:s.name})||"Failed to reload server","error")}finally{f(!1)}}},i=v=>{v.stopPropagation(),b(!w)},y=v=>{if(v.stopPropagation(),!!s.error)if(navigator.clipboard&&window.isSecureContext)navigator.clipboard.writeText(s.error).then(()=>{I(!0),x(r("common.copySuccess")||"Copied to clipboard","success"),setTimeout(()=>I(!1),2e3)});else{const D=document.createElement("textarea");D.value=s.error,D.style.position="fixed",D.style.left="-9999px",document.body.appendChild(D),D.focus(),D.select();try{document.execCommand("copy"),I(!0),x(r("common.copySuccess")||"Copied to clipboard","success"),setTimeout(()=>I(!1),2e3)}catch(C){x(r("common.copyFailed")||"Copy failed","error"),console.error("Copy to clipboard failed:",C)}document.body.removeChild(D)}},A=async v=>{v.stopPropagation();try{const D=await M(s.name);if(!D||!D.success||!D.data){x((D==null?void 0:D.message)||r("common.copyFailed")||"Copy failed","error");return}const C=JSON.stringify(D.data,null,2);if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(C),x(r("common.copySuccess")||"Copied to clipboard","success");else{const O=document.createElement("textarea");O.value=C,O.style.position="fixed",O.style.left="-9999px",document.body.appendChild(O),O.focus(),O.select();try{document.execCommand("copy"),x(r("common.copySuccess")||"Copied to clipboard","success")}catch(G){x(r("common.copyFailed")||"Copy failed","error"),console.error("Copy to clipboard failed:",G)}document.body.removeChild(O)}}catch(D){console.error("Error copying server configuration:",D),x(r("common.copyFailed")||"Copy failed","error")}},z=()=>{o(s.name),h(!1)},L=async(v,D)=>{try{const{toggleTool:C}=await de(async()=>{const{toggleTool:G}=await Promise.resolve().then(()=>Xe);return{toggleTool:G}},void 0,import.meta.url),O=await C(s.name,v,D);O.success?(x(r(D?"tool.enableSuccess":"tool.disableSuccess",{name:v}),"success"),d&&d()):x(O.error||r("tool.toggleFailed"),"error")}catch(C){console.error("Error toggling tool:",C),x(r("tool.toggleFailed"),"error")}},k=async(v,D)=>{try{const{togglePrompt:C}=await de(async()=>{const{togglePrompt:G}=await Promise.resolve().then(()=>ts);return{togglePrompt:G}},void 0,import.meta.url),O=await C(s.name,v,D);O.success?(x(r(D?"tool.enableSuccess":"tool.disableSuccess",{name:v}),"success"),d&&d()):x(O.error||r("tool.toggleFailed"),"error")}catch(C){console.error("Error toggling prompt:",C),x(r("tool.toggleFailed"),"error")}},J=(v,D,C)=>{x(C!=null&&C.restored?r("tool.restoreDefaultSuccess"):r("tool.descriptionUpdateSuccess"),"success"),d&&d()},E=(v,D,C)=>{x(C!=null&&C.restored?r("prompt.restoreDefaultSuccess"):r("prompt.descriptionUpdateSuccess"),"success"),d&&d()},V=v=>{var D;if(v.stopPropagation(),(D=s.oauth)!=null&&D.authorizationUrl){const G=window.screen.width/2-300,ee=window.screen.height/2-700/2;window.open(s.oauth.authorizationUrl,"OAuth Authorization",`width=600,height=700,left=${G},top=${ee}`),x(r("status.oauthWindowOpened"),"info")}},Q=async(v,D)=>{try{const{toggleResource:C}=await de(async()=>{const{toggleResource:G}=await import("./resourceService-BfCTSBsr.js");return{toggleResource:G}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url),O=await C(s.name,v,D);O.success?(x(r(D?"tool.enableSuccess":"tool.disableSuccess",{name:v}),"success"),d&&d()):x(O.error||r("tool.toggleFailed"),"error")}catch(C){console.error("Error toggling resource:",C),x(r("tool.toggleFailed"),"error")}},se=async(v,D,C)=>{try{const{updateResourceDescription:O,resetResourceDescription:G}=await de(async()=>{const{updateResourceDescription:pe,resetResourceDescription:ie}=await import("./resourceService-BfCTSBsr.js");return{updateResourceDescription:pe,resetResourceDescription:ie}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url),ee=C!=null&&C.restored?await G(s.name,v):await O(s.name,v,D);ee.success?(x(C!=null&&C.restored?r("builtinResources.restoreDefaultSuccess"):r("builtinResources.descriptionUpdateSuccess"),"success"),d&&d()):x(ee.error||(C!=null&&C.restored?r("builtinResources.restoreDefaultFailed"):r("builtinResources.descriptionUpdateFailed")),"error")}catch(O){console.error("Error updating resource description:",O),x(C!=null&&C.restored?r("builtinResources.restoreDefaultFailed"):r("builtinResources.descriptionUpdateFailed"),"error")}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg mb-6 page-card transition-all duration-200",children:[e.jsxs("div",{className:"flex justify-between items-center p-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("h2",{className:`text-xl font-semibold ${s.enabled===!1?"text-gray-600":"text-gray-900"}`,children:s.name}),((X=s.config)==null?void 0:X.description)&&e.jsxs("span",{className:"text-sm text-gray-500",children:["(",s.config.description,")"]}),e.jsx(Me,{status:s.status,onAuthClick:V}),((le=s.config)==null?void 0:le.type)&&e.jsx("div",{className:"flex items-center px-2 py-1 bg-gray-100 dark:bg-gray-800 text-gray-700 rounded-full text-xs",children:e.jsxs("span",{children:[s.config.type==="stdio"&&r("server.typeStdio"),s.config.type==="sse"&&r("server.typeSse"),s.config.type==="streamable-http"&&r("server.typeStreamableHttp"),s.config.type==="openapi"&&r("server.typeOpenapi")]})}),e.jsxs("div",{className:`flex items-center px-2 py-1 rounded-full text-sm cursor-pointer transition-colors ${S==="tools"?"bg-blue-100 text-blue-800 dark:bg-blue-900/50 dark:text-blue-300":"bg-blue-50 text-blue-700 hover:bg-blue-100 dark:bg-gray-800 dark:text-blue-400 dark:hover:bg-gray-700"}`,onClick:v=>{v.stopPropagation(),$(D=>D==="tools"?null:"tools")},children:[e.jsx(Ve,{className:"w-4 h-4 mr-1"}),e.jsxs("span",{children:[B===0?"0":`${U}/${B}`," ",r("server.tools")]})]}),e.jsxs("div",{className:`flex items-center px-2 py-1 rounded-full text-sm cursor-pointer transition-colors ${S==="prompts"?"bg-purple-100 text-purple-800 dark:bg-purple-900/50 dark:text-purple-300":"bg-purple-50 text-purple-700 hover:bg-purple-100 dark:bg-gray-800 dark:text-purple-400 dark:hover:bg-gray-700"}`,onClick:v=>{v.stopPropagation(),$(D=>D==="prompts"?null:"prompts")},children:[e.jsx(Ue,{className:"w-4 h-4 mr-1"}),e.jsxs("span",{children:[W===0?"0":`${K}/${W}`," ",r("server.prompts")]})]}),e.jsxs("div",{className:`flex items-center px-2 py-1 rounded-full text-sm cursor-pointer transition-colors ${S==="resources"?"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-300":"bg-emerald-50 text-emerald-700 hover:bg-emerald-100 dark:bg-gray-800 dark:text-emerald-400 dark:hover:bg-gray-700"}`,onClick:v=>{v.stopPropagation(),$(D=>D==="resources"?null:"resources")},children:[e.jsx(Be,{className:"w-4 h-4 mr-1"}),e.jsxs("span",{children:[H===0?"0":`${p}/${H}`," ",r("nav.resources")]})]}),s.error&&e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"cursor-pointer",onClick:i,"aria-label":r("server.viewErrorDetails"),children:e.jsx(fe,{className:"text-red-500 hover:text-red-600",size:18})}),w&&e.jsxs("div",{ref:P,className:"absolute z-10 mt-2 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-md shadow-lg p-0 w-120",style:{left:"-231px",top:"24px",maxHeight:"300px",overflowY:"auto",width:"480px",transform:"translateX(50%)"},onClick:v=>v.stopPropagation(),children:[e.jsxs("div",{className:"flex justify-between items-center sticky top-0 bg-white dark:bg-gray-800 py-2 px-4 border-b border-gray-200 dark:border-gray-700 z-20 shadow-sm",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("h4",{className:"text-sm font-medium text-red-600",children:r("server.errorDetails")}),e.jsx("button",{onClick:y,className:"p-1 text-gray-400 hover:text-gray-600 transition-colors btn-secondary",title:r("common.copy"),children:F?e.jsx(ce,{size:14,className:"text-green-500"}):e.jsx(Ce,{size:14})})]}),e.jsx("button",{onClick:v=>{v.stopPropagation(),b(!1)},className:"text-gray-400 hover:text-gray-600",children:"✕"})]}),e.jsx("div",{className:"p-4 pt-2",children:e.jsx("pre",{className:"text-sm text-gray-700 break-words whitespace-pre-wrap",children:s.error})})]})]})]}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx("button",{onClick:A,className:"px-3 py-1 btn-secondary",children:r("server.copy")}),e.jsx("button",{onClick:N,className:"px-3 py-1 bg-blue-100 text-blue-800 rounded hover:bg-blue-200 text-sm btn-primary",children:r("server.edit")}),e.jsx("div",{className:"flex items-center",children:e.jsx("button",{onClick:n,className:`px-3 py-1 text-sm rounded transition-colors ${T?"bg-gray-200 text-gray-500":s.enabled!==!1?"bg-green-100 text-green-800 hover:bg-green-200 btn-secondary":"bg-blue-100 text-blue-800 hover:bg-blue-200 btn-primary"}`,disabled:T||R,children:T?r("common.processing"):s.enabled!==!1?r("server.disable"):r("server.enable")})}),g&&e.jsx("button",{onClick:m,className:"px-3 py-1 bg-purple-100 text-purple-800 rounded hover:bg-purple-200 text-sm btn-secondary disabled:opacity-70 disabled:cursor-not-allowed",disabled:R||T||s.enabled===!1,children:r(R?"common.processing":"server.reload")}),e.jsx("button",{onClick:c,className:"px-3 py-1 bg-red-100 text-red-800 rounded hover:bg-red-200 text-sm btn-danger",children:r("server.delete")}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600 btn-secondary",children:S?e.jsx(ue,{size:18}):e.jsx(xe,{size:18})})]})]}),S==="tools"&&s.tools&&e.jsxs("div",{className:"px-4",children:[e.jsx("h6",{className:`font-medium ${s.enabled===!1?"text-gray-600":"text-gray-900"} mb-2`,children:r("server.tools")}),e.jsx("div",{className:"space-y-4",children:s.tools.map((v,D)=>e.jsx(Qe,{server:s.name,tool:v,onToggle:L,onDescriptionUpdate:J},D))})]}),S==="prompts"&&s.prompts&&e.jsxs("div",{className:"px-4 pb-2",children:[e.jsx("h6",{className:`font-medium ${s.enabled===!1?"text-gray-600":"text-gray-900"}`,children:r("server.prompts")}),e.jsx("div",{className:"space-y-4",children:s.prompts.map((v,D)=>e.jsx(rs,{server:s.name,prompt:v,onToggle:k,onDescriptionUpdate:E},D))})]}),S==="resources"&&s.resources&&e.jsxs("div",{className:"px-4 pb-2",children:[e.jsx("h6",{className:`font-medium ${s.enabled===!1?"text-gray-600":"text-gray-900"}`,children:r("nav.resources")}),s.resources.length===0?e.jsx("div",{className:"text-sm text-gray-500 py-2",children:r("builtinResources.noResources")}):e.jsx("div",{className:"space-y-4",children:s.resources.map((v,D)=>e.jsx(as,{resource:v,onToggle:Q,onDescriptionUpdate:se},`${v.uri}-${D}`))})]})]}),e.jsx(We,{isOpen:l,onClose:()=>h(!1),onConfirm:z,serverName:s.name})]})},os=({onAdd:s})=>{const{t:o}=Z(),[t,a]=u.useState(!1),[d,g]=u.useState(null),[r,x]=u.useState(!1),[S,$]=u.useState(null),[l,h]=u.useState([]),T=()=>{a(!t),g(null),x(!1),$(null)},j=async()=>{S&&(await R(S),x(!1),$(null))},R=async w=>{try{g(null);const b=await Y("/servers",w);if(!b.success){b&&b.message?g(b.message):g(o("server.addError"));return}a(!1),s()}catch(b){console.error("Error adding server:",b),navigator.onLine?b instanceof TypeError&&(b.message.includes("NetworkError")||b.message.includes("Failed to fetch"))?g(o("errors.serverConnection")):g(o("errors.serverAdd")):g(o("errors.network"))}},f=async w=>{try{const b=Le(w);b.length>0?(h(b),$(w),x(!0)):await R(w)}catch(b){console.error("Error processing server submission:",b),g(o("errors.serverAdd"))}};return e.jsxs("div",{children:[e.jsxs("button",{onClick:T,className:"w-full bg-blue-100 text-blue-800 rounded hover:bg-blue-200 py-2 px-4 flex items-center justify-center btn-primary",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-2",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})}),o("server.add")]}),t&&e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx(Ee,{onSubmit:f,onCancel:T,modalTitle:o("server.addServer"),formError:d})}),r&&e.jsx("div",{className:"fixed inset-0 bg-black/50 z-[60] flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-md",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:o("server.confirmVariables")}),e.jsx("p",{className:"text-gray-600 mb-4",children:o("server.variablesDetected")}),e.jsx("div",{className:"bg-yellow-50 border border-yellow-200 rounded p-3 mb-4",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("svg",{className:"h-5 w-5 text-yellow-400",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"ml-3",children:[e.jsxs("h4",{className:"text-sm font-medium text-yellow-800",children:[o("server.detectedVariables"),":"]}),e.jsx("ul",{className:"mt-1 text-sm text-yellow-700",children:l.map((w,b)=>e.jsxs("li",{className:"font-mono",children:["$",`{${w}}`]},b))})]})]})}),e.jsx("p",{className:"text-gray-600 text-sm mb-6",children:o("server.confirmVariablesMessage")}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>{x(!1),$(null)},className:"px-4 py-2 text-gray-600 border border-gray-300 rounded hover:bg-gray-50 dark:bg-gray-800 dark:hover:bg-gray-700 btn-secondary",children:o("common.cancel")}),e.jsx("button",{onClick:j,className:"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 btn-primary",children:o("server.confirmAndAdd")})]})]})})]})},ls=({server:s,onEdit:o,onCancel:t})=>{const{t:a}=Z(),[d,g]=u.useState(null),r=async x=>{try{g(null);const S=encodeURIComponent(s.name),$=x.name&&x.name!==s.name,l={config:x.config,...$?{newName:x.name}:{}},h=await me(`/servers/${S}`,l);if(!h.success){h&&h.message?g(h.message):g(a("server.updateError",{serverName:s.name}));return}o()}catch(S){console.error("Error updating server:",S),navigator.onLine?S instanceof TypeError&&(S.message.includes("NetworkError")||S.message.includes("Failed to fetch"))?g(a("errors.serverConnection")):g(a("errors.serverUpdate",{serverName:s.name})):g(a("errors.network"))}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx(Ee,{onSubmit:r,onCancel:t,initialData:s,modalTitle:a("server.editTitle",{serverName:s.name}),formError:d})})},is=({onSuccess:s,onCancel:o})=>{const{t}=Z(),[a,d]=u.useState(!1),[g,r]=u.useState(!1),[x,S]=u.useState(null),[$,l]=u.useState(null),[h,T]=u.useState(!1),[j,R]=u.useState(null),[f,w]=u.useState(""),[b,F]=u.useState(!1),[I,P]=u.useState(""),M=n=>{n.preventDefault(),d(!0)},B=n=>{n.preventDefault(),d(!1)},U=n=>{n.preventDefault(),d(!1);const m=n.dataTransfer.files;if(m.length>0){const i=m[0];i.name.endsWith(".mcpb")?(l(i),S(null)):S(t("mcpb.invalidFileType"))}},W=n=>{const m=n.target.files;if(m&&m.length>0){const i=m[0];i.name.endsWith(".mcpb")?(l(i),S(null)):S(t("mcpb.invalidFileType"))}},K=async()=>{if(!$){S(t("mcpb.noFileSelected"));return}r(!0),S(null);try{const n=new FormData;n.append("mcpbFile",$);const m=await Ae(_e("/mcpb/upload"),{method:"POST",body:n}),i=await m.json();if(!m.ok)throw new Error(i.message||`HTTP error! Status: ${m.status}`);if(i.success&&i.data)R(i.data.manifest),w(i.data.extractDir),T(!0);else throw new Error(i.message||t("mcpb.uploadFailed"))}catch(n){console.error("MCPB upload error:",n),S(n instanceof Error?n.message:t("mcpb.uploadFailed"))}finally{r(!1)}},H=async(n,m=!1)=>{var i;r(!0),S(null);try{const y=N(j,f,n);if(!m){const z=await Oe("/servers");if(z.success&&((i=z.data)==null?void 0:i.find(k=>k.name===n))){P(n),F(!0),r(!1);return}}let A;if(m?A=await me(`/servers/${encodeURIComponent(n)}`,{name:n,config:y}):A=await Y("/servers",{name:n,config:y}),A.success)s(y);else throw new Error(A.message||t("mcpb.installFailed"))}catch(y){console.error("MCPB install error:",y),S(y instanceof Error?y.message:t("mcpb.installFailed")),r(!1)}},p=()=>{F(!1),I&&H(I,!0)},c=()=>{F(!1),P(""),r(!1)},N=(n,m,i)=>{var z;const y=((z=n.server)==null?void 0:z.mcp_config)||{},A={type:"stdio",command:y.command||"node",args:(y.args||[]).map(L=>L.replace("${__dirname}",m))};return y.env&&Object.keys(y.env).length>0&&(A.env={...y.env},Object.keys(A.env).forEach(L=>{typeof A.env[L]=="string"&&(A.env[L]=A.env[L].replace("${__dirname}",m))})),A};return h&&j?e.jsxs(e.Fragment,{children:[e.jsx(qe,{isOpen:b,onClose:c,onConfirm:p,title:t("mcpb.serverExistsTitle"),message:t("mcpb.serverExistsConfirm",{serverName:I}),confirmText:t("mcpb.override"),cancelText:t("common.cancel"),variant:"warning"}),e.jsx("div",{className:`fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4 ${b?"opacity-50 pointer-events-none":""}`,children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 w-full max-w-3xl max-h-screen overflow-y-auto",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:t("mcpb.installServer")}),e.jsx("button",{onClick:o,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),x&&e.jsx("div",{className:"mb-4 bg-red-50 border-l-4 border-red-500 p-4 rounded",children:e.jsx("p",{className:"text-red-700",children:x})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 p-4 rounded-lg",children:[e.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:t("mcpb.extensionInfo")}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.name"),":"]})," ",j.display_name||j.name]}),e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.version"),":"]})," ",j.version]}),e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.description"),":"]})," ",j.description]}),j.author&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.author"),":"]})," ",j.author.name]}),j.tools&&j.tools.length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.tools"),":"]}),e.jsx("ul",{className:"list-disc list-inside ml-4",children:j.tools.map((n,m)=>e.jsxs("li",{children:[n.name," - ",n.description]},m))})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:t("mcpb.serverName")}),e.jsx("input",{type:"text",id:"serverName",defaultValue:j.name,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 form-input",placeholder:t("mcpb.serverNamePlaceholder")})]}),e.jsxs("div",{className:"flex justify-end space-x-4",children:[e.jsx("button",{onClick:o,disabled:g,className:"px-4 py-2 text-gray-700 bg-gray-200 rounded hover:bg-gray-300 disabled:opacity-50 btn-secondary",children:t("common.cancel")}),e.jsx("button",{onClick:()=>{const n=document.getElementById("serverName"),m=(n==null?void 0:n.value.trim())||j.name;H(m)},disabled:g,className:"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50 flex items-center btn-primary",children:g?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.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"})]}),t("mcpb.installing")]}):t("mcpb.install")})]})]})]})})]}):e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 w-full max-w-lg",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:t("mcpb.uploadTitle")}),e.jsx("button",{onClick:o,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),x&&e.jsx("div",{className:"mb-4 bg-red-50 border-l-4 border-red-500 p-4 rounded",children:e.jsx("p",{className:"text-red-700",children:x})}),e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg p-8 text-center transition-colors ${a?"border-blue-500 bg-blue-50":$?"border-gray-500 ":"border-gray-300 hover:border-gray-400"}`,onDragOver:M,onDragLeave:B,onDrop:U,children:[$?e.jsxs("div",{className:"space-y-2",children:[e.jsx("svg",{className:"mx-auto h-12 w-12 text-green-200",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("p",{className:"text-sm text-gray-900 font-medium",children:$.name}),e.jsxs("p",{className:"text-xs text-gray-500",children:[($.size/1024/1024).toFixed(2)," MB"]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("svg",{className:"mx-auto h-12 w-12 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-900",children:t("mcpb.dropFileHere")}),e.jsx("p",{className:"text-xs text-gray-500",children:t("mcpb.orClickToSelect")})]})]}),e.jsx("input",{type:"file",accept:".mcpb",onChange:W,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer"})]}),e.jsxs("div",{className:"mt-6 flex justify-end space-x-4",children:[e.jsx("button",{onClick:o,disabled:g,className:"px-4 py-2 text-gray-700 bg-gray-200 rounded hover:bg-gray-300 disabled:opacity-50 btn-secondary",children:t("common.cancel")}),e.jsx("button",{onClick:K,disabled:!$||g,className:"px-4 py-2 text-white rounded hover:bg-blue-700 disabled:opacity-50 flex items-center btn-primary",children:g?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.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"})]}),t("mcpb.uploading")]}):t("mcpb.upload")})]})]})})},cs=({onSuccess:s,onCancel:o})=>{const{t}=Z(),[a,d]=u.useState(""),[g,r]=u.useState(null),[x,S]=u.useState(!1),[$,l]=u.useState(null),h=`{
|
|
7
|
+
"mcpServers": {
|
|
8
|
+
"stdio-server-example": {
|
|
9
|
+
"command": "npx",
|
|
10
|
+
"args": ["-y", "mcp-server-example"]
|
|
11
|
+
},
|
|
12
|
+
"sse-server-example": {
|
|
13
|
+
"type": "sse",
|
|
14
|
+
"url": "http://localhost:3000"
|
|
15
|
+
},
|
|
16
|
+
"http-server-example": {
|
|
17
|
+
"type": "streamable-http",
|
|
18
|
+
"url": "http://localhost:3001",
|
|
19
|
+
"headers": {
|
|
20
|
+
"Content-Type": "application/json",
|
|
21
|
+
"Authorization": "Bearer your-token"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"openapi-server-example": {
|
|
25
|
+
"type": "openapi",
|
|
26
|
+
"openapi": {
|
|
27
|
+
"url": "https://petstore.swagger.io/v2/swagger.json"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
Supports: STDIO, SSE, HTTP (streamable-http), OpenAPI
|
|
34
|
+
All servers will be imported in a single efficient batch operation.`,T=f=>{try{const w=JSON.parse(f.trim());return!w.mcpServers||typeof w.mcpServers!="object"?(r(t("jsonImport.invalidFormat")),null):w}catch{return r(t("jsonImport.parseError")),null}},j=()=>{r(null);const f=T(a);if(!f)return;const w=Object.entries(f.mcpServers).map(([b,F])=>{const I={};return F.type==="sse"||F.type==="streamable-http"?(I.type=F.type,I.url=F.url,F.headers&&(I.headers=F.headers)):F.type==="openapi"?(I.type="openapi",I.openapi=F.openapi):(I.type="stdio",I.command=F.command,I.args=F.args||[],F.env&&(I.env=F.env)),{name:b,config:I}});l(w)},R=async()=>{if($){S(!0),r(null);try{const f=await Y("/servers/batch",{servers:$});if(f.success&&f.data){const{successCount:w,failureCount:b,results:F}=f.data;if(b>0){const I=F.filter(P=>!P.success).map(P=>`${P.name}: ${P.message||t("jsonImport.addFailed")}`);r(t("jsonImport.partialSuccess",{count:w,total:$.length})+`
|
|
35
|
+
`+I.join(`
|
|
36
|
+
`))}w>0&&s()}else r(f.message||t("jsonImport.importFailed"))}catch(f){console.error("Import error:",f),r(t("jsonImport.importFailed"))}finally{S(!1)}}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:t("jsonImport.title")}),e.jsx("button",{onClick:o,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),g&&e.jsx("div",{className:"mb-4 bg-red-50 border-l-4 border-red-500 p-4 rounded",children:e.jsx("p",{className:"text-red-700 whitespace-pre-wrap",children:g})}),$?e.jsxs("div",{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-3",children:t("jsonImport.previewTitle")}),e.jsx("div",{className:"space-y-3",children:$.map((f,w)=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 p-4 rounded-lg border border-gray-200 dark:border-gray-700",children:e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-medium text-gray-900",children:f.name}),e.jsxs("div",{className:"mt-2 space-y-1 text-sm text-gray-600",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.type"),":"]})," ",f.config.type||"stdio"]}),f.config.command&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.command"),":"]})," ",f.config.command]}),f.config.args&&f.config.args.length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.arguments"),":"]})," ",f.config.args.join(" ")]}),f.config.url&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.url"),":"]})," ",f.config.url]}),f.config.env&&Object.keys(f.config.env).length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.envVars"),":"]})," ",Object.keys(f.config.env).join(", ")]}),f.config.headers&&Object.keys(f.config.headers).length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.headers"),":"]})," ",Object.keys(f.config.headers).join(", ")]})]})]})})},w))})]}),e.jsxs("div",{className:"flex justify-end space-x-4",children:[e.jsx("button",{onClick:()=>l(null),disabled:x,className:"px-4 py-2 text-gray-700 bg-gray-200 rounded hover:bg-gray-300 disabled:opacity-50 btn-secondary",children:t("common.back")}),e.jsx("button",{onClick:R,disabled:x,className:"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50 flex items-center btn-primary",children:x?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.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"})]}),t("jsonImport.importing")]}):t("jsonImport.import")})]})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:t("jsonImport.inputLabel")}),e.jsx("textarea",{value:a,onChange:f=>d(f.target.value),className:"w-full h-96 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono text-sm",placeholder:h}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:t("jsonImport.inputHelp")})]}),e.jsxs("div",{className:"flex justify-end space-x-4",children:[e.jsx("button",{onClick:o,className:"px-4 py-2 text-gray-700 bg-gray-200 rounded hover:bg-gray-300 btn-secondary",children:t("common.cancel")}),e.jsx("button",{onClick:j,disabled:!a.trim(),className:"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50 btn-primary",children:t("jsonImport.preview")})]})]})]})})},Ns=()=>{const{t:s}=Z(),o=ze(),{servers:t,error:a,setError:d,isLoading:g,pagination:r,currentPage:x,serversPerPage:S,setCurrentPage:$,setServersPerPage:l,handleServerAdd:h,handleServerEdit:T,handleServerRemove:j,handleServerToggle:R,handleServerReload:f,triggerRefresh:w}=He({refreshOnMount:!0}),[b,F]=u.useState(null),[I,P]=u.useState(!1),[M,B]=u.useState(!1),[U,W]=u.useState(!1),K=async n=>{const m=await T(n);m&&F(m)},H=()=>{F(null),w()},p=async()=>{P(!0);try{w(),await new Promise(n=>setTimeout(n,500))}finally{P(!1)}},c=n=>{B(!1),w()},N=()=>{W(!1),w()};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-8",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:s("pages.servers.title")}),e.jsxs("div",{className:"flex space-x-4",children:[e.jsxs("button",{onClick:()=>o("/market"),className:"px-4 py-2 bg-blue-100 text-blue-800 rounded hover:bg-blue-200 flex items-center btn-primary transition-all duration-200",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-2",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{d:"M3 1a1 1 0 000 2h1.22l.305 1.222a.997.997 0 00.01.042l1.358 5.43-.893.892C3.74 11.846 4.632 14 6.414 14H15a1 1 0 000-2H6.414l1-1H14a1 1 0 00.894-.553l3-6A1 1 0 0017 3H6.28l-.31-1.243A1 1 0 005 1H3z"})}),s("nav.market")]}),e.jsx(os,{onAdd:h}),e.jsxs("button",{onClick:()=>W(!0),className:"px-4 py-2 bg-blue-100 text-blue-800 rounded hover:bg-blue-200 flex items-center btn-primary transition-all duration-200",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-2",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM6.293 6.707a1 1 0 010-1.414l3-3a1 1 0 011.414 0l3 3a1 1 0 01-1.414 1.414L11 5.414V13a1 1 0 11-2 0V5.414L7.707 6.707a1 1 0 01-1.414 0z",clipRule:"evenodd"})}),s("jsonImport.button")]}),e.jsxs("button",{onClick:()=>B(!0),className:"px-4 py-2 bg-blue-100 text-blue-800 rounded hover:bg-blue-200 flex items-center btn-primary transition-all duration-200",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-2",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{d:"M5.5 13a3.5 3.5 0 01-.369-6.98 4 4 0 117.753-1.977A4.5 4.5 0 1113.5 13H11V9.413l1.293 1.293a1 1 0 001.414-1.414l-3-3a1 1 0 00-1.414 0l-3 3a1 1 0 001.414 1.414L9 9.413V13H5.5z"})}),s("mcpb.upload")]}),e.jsxs("button",{onClick:p,disabled:I,className:`px-4 py-2 bg-blue-100 text-blue-800 rounded hover:bg-blue-200 flex items-center btn-primary transition-all duration-200 ${I?"opacity-70 cursor-not-allowed":""}`,children:[I?e.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.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"})]}):e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-2",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z",clipRule:"evenodd"})}),s("common.refresh")]})]})]}),a&&e.jsx("div",{className:"mb-6 bg-red-50 border-l-4 border-red-500 p-4 rounded shadow-sm error-box",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsx("p",{className:"text-gray-600 mt-1",children:a})}),e.jsx("button",{onClick:()=>d(null),className:"ml-4 text-gray-500 hover:text-gray-700 transition-colors duration-200 btn-secondary","aria-label":s("app.closeButton"),children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 011.414 0L10 8.586l4.293-4.293a1 1 111.414 1.414L11.414 10l4.293 4.293a1 1 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 01-1.414-1.414L8.586 10 4.293 5.707a1 1 010-1.414z",clipRule:"evenodd"})})})]})}),g?e.jsx("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 flex items-center justify-center loading-container",children:e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsxs("svg",{className:"animate-spin h-10 w-10 text-blue-500 mb-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.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"})]}),e.jsx("p",{className:"text-gray-600",children:s("app.loading")})]})}):t.length===0?e.jsx("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 empty-state",children:e.jsx("p",{className:"text-gray-600",children:s("app.noServers")})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-6",children:t.map((n,m)=>e.jsx(ns,{server:n,onRemove:j,onEdit:K,onToggle:R,onRefresh:w,onReload:f},m))}),e.jsxs("div",{className:"flex items-center mb-4",children:[e.jsx("div",{className:"flex-[2] text-sm text-gray-500",children:r?s("common.showing",{start:(r.page-1)*r.limit+1,end:Math.min(r.page*r.limit,r.total),total:r.total}):s("common.showing",{start:1,end:t.length,total:t.length})}),e.jsx("div",{className:"flex-[4] flex justify-center",children:r&&r.totalPages>1&&e.jsx(Ge,{currentPage:x,totalPages:r.totalPages,onPageChange:$,disabled:g})}),e.jsxs("div",{className:"flex-[2] flex items-center justify-end space-x-2",children:[e.jsxs("label",{htmlFor:"perPage",className:"text-sm text-gray-600",children:[s("common.itemsPerPage"),":"]}),e.jsxs("select",{id:"perPage",value:S,onChange:n=>l(Number(n.target.value)),disabled:g,className:"border rounded p-1 text-sm btn-secondary outline-none disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx("option",{value:5,children:"5"}),e.jsx("option",{value:10,children:"10"}),e.jsx("option",{value:20,children:"20"}),e.jsx("option",{value:50,children:"50"})]})]})]})]}),b&&e.jsx(ls,{server:b,onEdit:H,onCancel:()=>F(null)}),M&&e.jsx(is,{onSuccess:c,onCancel:()=>B(!1)}),U&&e.jsx(cs,{onSuccess:N,onCancel:()=>W(!1)})]})};export{Ns as default};
|
|
37
|
+
//# sourceMappingURL=ServersPage-CtS1I4yS.js.map
|