@samanhappy/mcphub 0.12.17 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.fr.md +1 -1
- package/dist/services/mcpService.js +42 -10
- package/dist/services/mcpService.js.map +1 -1
- package/dist/services/sseService.js +5 -3
- package/dist/services/sseService.js.map +1 -1
- package/frontend/dist/assets/ActivityPage-VwilVMvp.js +2 -0
- package/frontend/dist/assets/ActivityPage-VwilVMvp.js.map +1 -0
- package/frontend/dist/assets/ConfirmDialog-CxlizGia.js +2 -0
- package/frontend/dist/assets/ConfirmDialog-CxlizGia.js.map +1 -0
- package/frontend/dist/assets/Dashboard-DuBJTbbA.js +2 -0
- package/frontend/dist/assets/Dashboard-DuBJTbbA.js.map +1 -0
- package/frontend/dist/assets/DeleteDialog-DRbWonMu.js +2 -0
- package/frontend/dist/assets/DeleteDialog-DRbWonMu.js.map +1 -0
- package/frontend/dist/assets/EndpointCopy-C59moJ3Y.js +2 -0
- package/frontend/dist/assets/EndpointCopy-C59moJ3Y.js.map +1 -0
- package/frontend/dist/assets/GroupsPage-Bhg51kbu.js +33 -0
- package/frontend/dist/assets/GroupsPage-Bhg51kbu.js.map +1 -0
- package/frontend/dist/assets/LoginPage-C8RkMoJN.js +2 -0
- package/frontend/dist/assets/LoginPage-C8RkMoJN.js.map +1 -0
- package/frontend/dist/assets/LogsPage-HBGNLtyN.js +2 -0
- package/frontend/dist/assets/LogsPage-HBGNLtyN.js.map +1 -0
- package/frontend/dist/assets/MarketPage-C5ATZ4WS.js +3 -0
- package/frontend/dist/assets/MarketPage-C5ATZ4WS.js.map +1 -0
- package/frontend/dist/assets/{Pagination-y-gVO8ms.js → Pagination-BFi-X7qY.js} +2 -2
- package/frontend/dist/assets/{Pagination-y-gVO8ms.js.map → Pagination-BFi-X7qY.js.map} +1 -1
- package/frontend/dist/assets/PromptsPage-DUge8OO4.js +2 -0
- package/frontend/dist/assets/PromptsPage-DUge8OO4.js.map +1 -0
- package/frontend/dist/assets/ResourcesPage-5J3JYGVC.js +2 -0
- package/frontend/dist/assets/ResourcesPage-5J3JYGVC.js.map +1 -0
- package/frontend/dist/assets/ServersPage-DtnlfwJF.js +37 -0
- package/frontend/dist/assets/ServersPage-DtnlfwJF.js.map +1 -0
- package/frontend/dist/assets/SettingsPage-BeLZKC1d.js +12 -0
- package/frontend/dist/assets/SettingsPage-BeLZKC1d.js.map +1 -0
- package/frontend/dist/assets/StatusDot-DR803YdX.js +2 -0
- package/frontend/dist/assets/StatusDot-DR803YdX.js.map +1 -0
- package/frontend/dist/assets/{ToggleGroup-HfxdlkGi.js → ToggleGroup-DE8t8Ni4.js} +2 -2
- package/frontend/dist/assets/{ToggleGroup-HfxdlkGi.js.map → ToggleGroup-DE8t8Ni4.js.map} +1 -1
- package/frontend/dist/assets/UsersPage-CMscqAmn.js +2 -0
- package/frontend/dist/assets/UsersPage-CMscqAmn.js.map +1 -0
- package/frontend/dist/assets/{framework-vendor-_OBebcuv.js → framework-vendor-BUhDPOUZ.js} +2 -2
- package/frontend/dist/assets/{framework-vendor-_OBebcuv.js.map → framework-vendor-BUhDPOUZ.js.map} +1 -1
- package/frontend/dist/assets/{i18n-vendor-MQ921plD.js → i18n-vendor-Kbr87Ofu.js} +2 -2
- package/frontend/dist/assets/{i18n-vendor-MQ921plD.js.map → i18n-vendor-Kbr87Ofu.js.map} +1 -1
- package/frontend/dist/assets/icons-vendor-CKgJB3SC.js +292 -0
- package/frontend/dist/assets/icons-vendor-CKgJB3SC.js.map +1 -0
- package/frontend/dist/assets/index-B9cW2F0H.js +3 -0
- package/frontend/dist/assets/index-B9cW2F0H.js.map +1 -0
- package/frontend/dist/assets/index-Crcbkt8x.css +1 -0
- package/frontend/dist/assets/{resourceService-BfCTSBsr.js → resourceService-BFMkDDIh.js} +2 -2
- package/frontend/dist/assets/{resourceService-BfCTSBsr.js.map → resourceService-BFMkDDIh.js.map} +1 -1
- package/frontend/dist/assets/useServerData-BnLmpLAC.js +2 -0
- package/frontend/dist/assets/{useServerData-QZqQTYcv.js.map → useServerData-BnLmpLAC.js.map} +1 -1
- package/frontend/dist/assets/useSettingsData-Cqi9d7Ug.js +2 -0
- package/frontend/dist/assets/{useSettingsData-D3VROqS7.js.map → useSettingsData-Cqi9d7Ug.js.map} +1 -1
- package/frontend/dist/assets/variableDetection-BigiltQM.js +16 -0
- package/frontend/dist/assets/variableDetection-BigiltQM.js.map +1 -0
- package/frontend/dist/index.html +5 -5
- package/package.json +1 -1
- package/frontend/dist/assets/ActivityPage-ClgKeihP.js +0 -2
- package/frontend/dist/assets/ActivityPage-ClgKeihP.js.map +0 -1
- package/frontend/dist/assets/Badge-Ck2fhRdl.js +0 -2
- package/frontend/dist/assets/Badge-Ck2fhRdl.js.map +0 -1
- package/frontend/dist/assets/ConfirmDialog-uYjffH4V.js +0 -2
- package/frontend/dist/assets/ConfirmDialog-uYjffH4V.js.map +0 -1
- package/frontend/dist/assets/Dashboard-BIXrLobn.js +0 -2
- package/frontend/dist/assets/Dashboard-BIXrLobn.js.map +0 -1
- package/frontend/dist/assets/DeleteDialog-BAfrV8EB.js +0 -2
- package/frontend/dist/assets/DeleteDialog-BAfrV8EB.js.map +0 -1
- package/frontend/dist/assets/GroupsPage-BjrvyHwu.js +0 -33
- package/frontend/dist/assets/GroupsPage-BjrvyHwu.js.map +0 -1
- package/frontend/dist/assets/LoginPage-BBHt_TfF.js +0 -2
- package/frontend/dist/assets/LoginPage-BBHt_TfF.js.map +0 -1
- package/frontend/dist/assets/LogsPage-D8Znq5NB.js +0 -2
- package/frontend/dist/assets/LogsPage-D8Znq5NB.js.map +0 -1
- package/frontend/dist/assets/MarketPage-haRuzjCw.js +0 -3
- package/frontend/dist/assets/MarketPage-haRuzjCw.js.map +0 -1
- package/frontend/dist/assets/PromptsPage-ByHWPyGe.js +0 -2
- package/frontend/dist/assets/PromptsPage-ByHWPyGe.js.map +0 -1
- package/frontend/dist/assets/ResourcesPage-Bodw5OY9.js +0 -2
- package/frontend/dist/assets/ResourcesPage-Bodw5OY9.js.map +0 -1
- package/frontend/dist/assets/ServersPage-CtS1I4yS.js +0 -37
- package/frontend/dist/assets/ServersPage-CtS1I4yS.js.map +0 -1
- package/frontend/dist/assets/SettingsPage-DxVigf7p.js +0 -12
- package/frontend/dist/assets/SettingsPage-DxVigf7p.js.map +0 -1
- package/frontend/dist/assets/UsersPage-Bipw33cS.js +0 -2
- package/frontend/dist/assets/UsersPage-Bipw33cS.js.map +0 -1
- package/frontend/dist/assets/icons-vendor-B67NtVuR.js +0 -172
- package/frontend/dist/assets/icons-vendor-B67NtVuR.js.map +0 -1
- package/frontend/dist/assets/index-CmnA4an8.js +0 -5
- package/frontend/dist/assets/index-CmnA4an8.js.map +0 -1
- package/frontend/dist/assets/index-DfFHVARX.css +0 -1
- package/frontend/dist/assets/useGroupData-DLhbP6zd.js +0 -2
- package/frontend/dist/assets/useGroupData-DLhbP6zd.js.map +0 -1
- package/frontend/dist/assets/useServerData-QZqQTYcv.js +0 -2
- package/frontend/dist/assets/useSettingsData-D3VROqS7.js +0 -2
- package/frontend/dist/assets/variableDetection-C3Xi21av.js +0 -16
- package/frontend/dist/assets/variableDetection-C3Xi21av.js.map +0 -1
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{r as s,j as e,u as Be,e as tr,h as ar}from"./framework-vendor-_OBebcuv.js";import{i as J,d as ue,h as nr}from"./index-CmnA4an8.js";import{u as le}from"./i18n-vendor-MQ921plD.js";import{S as Ce,d as lr}from"./variableDetection-C3Xi21av.js";import{u as or}from"./useSettingsData-D3VROqS7.js";import{P as ir}from"./Pagination-y-gVO8ms.js";import"./icons-vendor-B67NtVuR.js";const cr=()=>{const{t:r}=le(),[C,f]=s.useState([]),[c,x]=s.useState([]),[g,i]=s.useState([]),[l,j]=s.useState([]),[m,_]=s.useState(""),[D,M]=s.useState(""),[z,O]=s.useState(""),[L,N]=s.useState(!0),[H,S]=s.useState(null),[P,U]=s.useState(null),[Z,T]=s.useState([]),[R,W]=s.useState(1),[A,re]=s.useState(9),[K,y]=s.useState(1),k=s.useCallback(async()=>{try{N(!0);const a=await J("/market/servers");a&&a.success&&Array.isArray(a.data)?(x(a.data),V(a.data,R)):(console.error("Invalid market servers data format",{data:a}),S(r("market.fetchError")))}catch(a){console.error("Error fetching market servers",{err:a}),S(a instanceof Error?a.message:String(a))}finally{N(!1)}},[r]),V=s.useCallback((a,t,u=A)=>{const I=a.length,B=Math.ceil(I/u);y(B);const ee=Math.max(1,Math.min(t,B));ee!==t&&W(ee);const ne=(ee-1)*u,ae=a.slice(ne,ne+u);f(ae)},[A]),te=s.useCallback(a=>{W(a),V(c,a,A)},[c,V,A]),b=s.useCallback(async()=>{try{const a=await J("/market/categories");a&&a.success&&Array.isArray(a.data)?i(a.data):console.error("Invalid categories data format",{data:a})}catch(a){console.error("Error fetching categories",{err:a})}},[]),E=s.useCallback(async()=>{try{const a=await J("/market/tags");a&&a.success&&Array.isArray(a.data)?j(a.data):console.error("Invalid tags data format",{data:a})}catch(a){console.error("Error fetching tags",{err:a})}},[]),w=s.useCallback(async a=>{try{N(!0);const t=await J(`/market/servers/${a}`);return t&&t.success&&t.data?(U(t.data),t.data):(console.error("Invalid market server data format",{name:a,data:t}),S(r("market.serverNotFound")),null)}catch(t){return console.error("Error fetching market server",{name:a,err:t}),S(t instanceof Error?t.message:String(t)),null}finally{N(!1)}},[r]),F=s.useCallback(async a=>{try{if(N(!0),O(a),!a.trim()){k();return}const t=await J(`/market/servers/search?query=${encodeURIComponent(a)}`);t&&t.success&&Array.isArray(t.data)?(x(t.data),W(1),V(t.data,1)):(console.error("Invalid market search results format",{query:a,data:t}),S(r("market.searchError")))}catch(t){console.error("Error searching market servers",{query:a,err:t}),S(t instanceof Error?t.message:String(t))}finally{N(!1)}},[r,c,V,k]),d=s.useCallback(async a=>{try{if(N(!0),_(a),M(""),!a){k();return}const t=await J(`/market/categories/${encodeURIComponent(a)}`);t&&t.success&&Array.isArray(t.data)?(x(t.data),W(1),V(t.data,1)):(console.error("Invalid market category filter results format",{category:a,data:t}),S(r("market.filterError")))}catch(t){console.error("Error filtering market servers by category",{category:a,err:t}),S(t instanceof Error?t.message:String(t))}finally{N(!1)}},[r,k,V]),p=s.useCallback(async a=>{try{if(N(!0),M(a),_(""),!a){k();return}const t=await J(`/market/tags/${encodeURIComponent(a)}`);t&&t.success&&Array.isArray(t.data)?(x(t.data),W(1),V(t.data,1)):(console.error("Invalid market tag filter results format",{tag:a,data:t}),S(r("market.tagFilterError")))}catch(t){console.error("Error filtering market servers by tag",{tag:a,err:t}),S(t instanceof Error?t.message:String(t))}finally{N(!1)}},[r,k,V]),h=s.useCallback(async()=>{try{const a=await J("/servers");if(a&&a.success&&Array.isArray(a.data)){const t=a.data.map(u=>u.name);T(t)}}catch(a){console.error("Error fetching installed servers",{err:a})}},[]),n=s.useCallback(a=>Z.includes(a),[Z]),o=s.useCallback(async(a,t)=>{var u,I;try{const B=(u=a.installations)!=null&&u.npm?"npm":Object.keys(a.installations||{}).length>0?Object.keys(a.installations)[0]:null;if(!B||!((I=a.installations)!=null&&I[B]))return S(r("market.noInstallationMethod")),!1;const ee=a.installations[B],ne={name:a.name,config:t.type==="stdio"?{command:t.command||ee.command||"",args:t.args||ee.args||[],env:{...ee.env,...t.env}}:t},ae=await ue("/servers",ne);if(!ae.success)throw new Error(ae.message||"Failed to install server");return await h(),!0}catch(B){return console.error("Error installing market server",{serverName:a.name,err:B}),S(B instanceof Error?B.message:String(B)),!1}},[r,h]),X=s.useCallback(a=>{re(a),W(1),V(c,1,a)},[c,V]);return s.useEffect(()=>{k(),b(),E(),h()},[k,b,E,h]),{servers:C,allServers:c,categories:g,tags:l,selectedCategory:m,selectedTag:D,searchQuery:z,loading:L,error:H,setError:S,currentServer:P,fetchMarketServers:k,fetchServerByName:w,searchServers:F,filterByCategory:d,filterByTag:p,installServer:o,currentPage:R,totalPages:K,serversPerPage:A,changePage:te,changeServersPerPage:X,isServerInstalled:n}},dr=()=>{const{t:r}=le(),[C,f]=s.useState([]),[c,x]=s.useState([]),[g,i]=s.useState([]),[l,j]=s.useState([]),[m,_]=s.useState(""),[D,M]=s.useState(""),[z,O]=s.useState(""),[L,N]=s.useState(!0),[H,S]=s.useState(null),[P,U]=s.useState(null),[Z,T]=s.useState(1),[R,W]=s.useState(9),[A,re]=s.useState(1),K=s.useCallback(async()=>{try{N(!0);const n=await J("/cloud/servers");n&&n.success&&Array.isArray(n.data)?(x(n.data),y(n.data,Z)):(console.error("Invalid cloud market servers data format",{data:n}),S(r("cloud.fetchError")))}catch(n){console.error("Error fetching cloud market servers",{err:n});const o=n instanceof Error?n.message:String(n);o==="MCPROUTER_API_KEY_NOT_CONFIGURED"||o.toLowerCase().includes("mcprouter api key not configured"),S(o)}finally{N(!1)}},[r]),y=s.useCallback((n,o,X=R)=>{const a=n.length,t=Math.ceil(a/X);re(t);const u=Math.max(1,Math.min(o,t));u!==o&&T(u);const I=(u-1)*X,B=n.slice(I,I+X);f(B)},[R]),k=s.useCallback(n=>{T(n),y(c,n,R)},[c,y,R]),V=s.useCallback(async()=>{try{const n=await J("/cloud/categories");n&&n.success&&Array.isArray(n.data)?i(n.data):console.error("Invalid cloud market categories data format",{data:n})}catch(n){console.error("Error fetching cloud market categories",{err:n})}},[]),te=s.useCallback(async()=>{try{const n=await J("/cloud/tags");n&&n.success&&Array.isArray(n.data)?j(n.data):console.error("Invalid cloud market tags data format",{data:n})}catch(n){console.error("Error fetching cloud market tags",{err:n})}},[]),b=s.useCallback(async n=>{try{N(!0);const o=await J(`/cloud/servers/${n}`);return o&&o.success&&o.data?(U(o.data),o.data):(console.error("Invalid cloud server data format",{name:n,data:o}),S(r("cloud.serverNotFound")),null)}catch(o){console.error("Error fetching cloud server",{name:n,err:o});const X=o instanceof Error?o.message:String(o);return X==="MCPROUTER_API_KEY_NOT_CONFIGURED"||X.toLowerCase().includes("mcprouter api key not configured"),S(X),null}finally{N(!1)}},[r]),E=s.useCallback(async n=>{try{if(N(!0),O(n),!n.trim()){K();return}const o=await J(`/cloud/servers/search?query=${encodeURIComponent(n)}`);o&&o.success&&Array.isArray(o.data)?(x(o.data),T(1),y(o.data,1)):(console.error("Invalid cloud search results format",{query:n,data:o}),S(r("cloud.searchError")))}catch(o){console.error("Error searching cloud servers",{query:n,err:o}),S(o instanceof Error?o.message:String(o))}finally{N(!1)}},[r,c,y,K]),w=s.useCallback(async n=>{try{if(N(!0),_(n),M(""),!n){K();return}const o=await J(`/cloud/categories/${encodeURIComponent(n)}`);o&&o.success&&Array.isArray(o.data)?(x(o.data),T(1),y(o.data,1)):(console.error("Invalid cloud category filter results format",{category:n,data:o}),S(r("cloud.filterError")))}catch(o){console.error("Error filtering cloud servers by category",{category:n,err:o}),S(o instanceof Error?o.message:String(o))}finally{N(!1)}},[r,K,y]),F=s.useCallback(async n=>{try{if(N(!0),M(n),_(""),!n){K();return}const o=await J(`/cloud/tags/${encodeURIComponent(n)}`);o&&o.success&&Array.isArray(o.data)?(x(o.data),T(1),y(o.data,1)):(console.error("Invalid cloud tag filter results format",{tag:n,data:o}),S(r("cloud.tagFilterError")))}catch(o){console.error("Error filtering cloud servers by tag",{tag:n,err:o}),S(o instanceof Error?o.message:String(o))}finally{N(!1)}},[r,K,y]),d=s.useCallback(async n=>{try{const o=await J(`/cloud/servers/${n}/tools`);if(!o.success)throw console.error("Failed to fetch cloud server tools",{serverName:n,data:o}),new Error(o.message||"Failed to fetch cloud server tools");return o&&o.success&&Array.isArray(o.data)?o.data:(console.error("Invalid cloud server tools data format",{serverName:n,data:o}),[])}catch(o){console.error("Error fetching tools for cloud server",{serverName:n,err:o});const X=o instanceof Error?o.message:String(o);if(X==="MCPROUTER_API_KEY_NOT_CONFIGURED"||X.toLowerCase().includes("mcprouter api key not configured"))throw o;return[]}},[]),p=s.useCallback(async(n,o,X)=>{try{const a=await ue(`/cloud/servers/${encodeURIComponent(n)}/tools/${encodeURIComponent(o)}/call`,{arguments:X});if(a&&a.success)return a.data;throw new Error(a.message||"Failed to call tool")}catch(a){throw console.error("Error calling tool on cloud server",{serverName:n,toolName:o,err:a}),a}},[]),h=s.useCallback(n=>{W(n),T(1),y(c,1,n)},[c,y]);return s.useEffect(()=>{K(),V(),te()},[K,V,te]),{servers:C,allServers:c,categories:g,tags:l,selectedCategory:m,selectedTag:D,searchQuery:z,loading:L,error:H,setError:S,currentServer:P,fetchCloudServers:K,fetchServerByName:b,searchServers:E,filterByCategory:w,filterByTag:F,fetchServerTools:d,callServerTool:p,currentPage:Z,totalPages:A,serversPerPage:R,changePage:k,changeServersPerPage:h}},mr=()=>{const{t:r}=le(),[C,f]=s.useState([]),[c,x]=s.useState([]),[g,i]=s.useState(!0),[l,j]=s.useState(null),[m,_]=s.useState(""),[D,M]=s.useState(1),[z,O]=s.useState(9),[L,N]=s.useState(null),[H,S]=s.useState(!1),[P,U]=s.useState([]),[Z]=s.useState(1),T=s.useCallback(async(b,E)=>{try{i(!0),j(null);const w=new URLSearchParams;w.append("limit",z.toString()),b&&w.append("cursor",b);const F=E!==void 0?E:m;F.trim()&&w.append("search",F.trim());const d=await J(`/registry/servers?${w.toString()}`);if(d&&d.success&&d.data){const p=d.data;if(p.servers&&Array.isArray(p.servers)){f(p.servers);const h=p.metadata.count===z&&!!p.metadata.nextCursor;S(h),N(p.metadata.nextCursor||null),x(b?n=>[...n,...p.servers]:p.servers)}else console.error("Invalid registry servers data format",{data:p}),j(r("registry.fetchError"))}else j(r("registry.fetchError"))}catch(w){console.error("Error fetching registry servers",{cursor:b,search:E,err:w});const F=w instanceof Error?w.message:String(w);j(F)}finally{i(!1)}},[r,z]),R=s.useCallback(async()=>{if(!H||!L)return;const b=P[P.length-1]||"";U(E=>[...E,b]),M(E=>E+1),await T(L,m)},[H,L,P,m,T]),W=s.useCallback(async()=>{if(D<=1)return;const b=[...P];b.pop();const E=b[b.length-1];U(b),M(w=>w-1),await T(E||void 0,m)},[D,P,m,T]),A=s.useCallback(async b=>{b!==D&&(b>D&&H?await R():b<D&&D>1&&await W())},[D,H,R,W]),re=s.useCallback(async b=>{O(b),M(1),U([]),x([]),await T(void 0,m)},[m,T]),K=s.useCallback(async b=>{try{i(!0),j(null);const E=encodeURIComponent(b),w=await J(`/registry/servers/versions?serverName=${E}`);if(w&&w.success&&w.data){const F=w.data;return F.servers&&Array.isArray(F.servers)&&F.servers.length>0?F.servers[0]:(console.error("Invalid registry server data format",{serverName:b,data:F}),j(r("registry.serverNotFound")),null)}else return j(r("registry.serverNotFound")),null}catch(E){console.error("Error fetching registry server",{serverName:b,err:E});const w=E instanceof Error?E.message:String(E);return j(w),null}finally{i(!1)}},[r]),y=s.useCallback(async b=>{try{j(null);const E=encodeURIComponent(b),w=await J(`/registry/servers/versions?serverName=${E}`);if(w&&w.success&&w.data){const F=w.data;return F.servers&&Array.isArray(F.servers)?F.servers:(console.error("Invalid registry server versions data format",{serverName:b,data:F}),[])}else return[]}catch(E){console.error("Error fetching versions for registry server",{serverName:b,err:E});const w=E instanceof Error?E.message:String(E);return j(w),[]}},[]),k=s.useCallback(async(b,E)=>{try{j(null);const w=encodeURIComponent(b),F=encodeURIComponent(E),d=await J(`/registry/servers/version?serverName=${w}&version=${F}`);if(d&&d.success&&d.data){const p=d.data;return p&&p.server?p:(console.error("Invalid registry server version data format",{serverName:b,version:E,data:p}),null)}else return null}catch(w){console.error("Error fetching specific registry server version",{serverName:b,version:E,err:w});const F=w instanceof Error?w.message:String(w);return j(F),null}},[]),V=s.useCallback(async b=>{console.log("Searching registry servers",{query:b}),_(b),M(1),U([]),x([]),await T(void 0,b)},[T]),te=s.useCallback(async()=>{_(""),M(1),U([]),x([]),await T(void 0,"")},[T]);return s.useEffect(()=>{T(void 0,m)},[]),{servers:C,allServers:c,loading:g,error:l,setError:j,searchQuery:m,searchServers:V,clearSearch:te,fetchServerByName:K,fetchServerVersions:y,fetchServerVersion:k,currentPage:D,totalPages:Z,hasNextPage:H,hasPreviousPage:D>1,changePage:A,goToNextPage:R,goToPreviousPage:W,serversPerPage:z,changeServersPerPage:re}},ur=({server:r,onClick:C})=>{var j,m,_,D;const{t:f}=le(),c=M=>M.split(" ").map(z=>z.charAt(0)).join("").toUpperCase().slice(0,2),x=()=>{if(!r.tags||r.tags.length===0)return{tagsToShow:[],hasMore:!1,moreCount:0};const M=28,z=P=>P.length+3;let O=0,L=0;const N=[...r.tags].sort((P,U)=>P.length-U.length);for(L=0;L<N.length;L++){const P=z(N[L]);if(O+P>M)break;if(O+=P,L===N.length-1)return{tagsToShow:N,hasMore:!1,moreCount:0}}L===0&&N.length>0&&(L=1);const H=N.length-L,S=3+String(H).length+f("market.moreTags").length;return O+S<=M||L<1?{tagsToShow:N.slice(0,L),hasMore:!0,moreCount:H}:{tagsToShow:N.slice(0,Math.max(1,L-1)),hasMore:!0,moreCount:H+1}},{tagsToShow:g,hasMore:i,moreCount:l}=x();return e.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-4 hover:shadow-lg hover:border-blue-400 hover:-translate-y-1 transition-all duration-300 cursor-pointer group relative overflow-hidden h-full flex flex-col",onClick:()=>C(r),children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-50/0 to-purple-50/0 group-hover:from-blue-50/30 group-hover:to-purple-50/30 dark:group-hover:from-blue-900/30 dark:group-hover:to-purple-900/30 transition-all duration-300 pointer-events-none"}),e.jsxs("div",{className:"relative z-10 flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 group-hover:text-blue-600 transition-colors duration-200 mb-1 line-clamp-1 mr-2",children:r.display_name}),e.jsxs("div",{className:"flex items-center space-x-2 mb-1",children:[e.jsx("div",{className:"w-6 h-6 bg-gradient-to-br from-blue-500 to-purple-600 rounded-full flex items-center justify-center text-white text-xs font-semibold",children:c(((j=r.author)==null?void 0:j.name)||f("market.unknown"))}),e.jsx("div",{children:e.jsx("p",{className:"text-xs font-medium text-gray-700",children:((m=r.author)==null?void 0:m.name)||f("market.unknown")})})]})]}),e.jsx("div",{className:"flex flex-col items-end space-y-2",children:r.is_official&&e.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300",children:f("market.official")})})]}),e.jsx("div",{className:"mb-2 flex-1",children:e.jsx("p",{className:"text-gray-600 text-sm leading-relaxed line-clamp-2 min-h-[36px]",children:r.description})}),e.jsx("div",{className:"mb-2",children:e.jsx("div",{className:"flex flex-wrap gap-1 min-h-[24px]",children:((_=r.categories)==null?void 0:_.length)>0?r.categories.map((M,z)=>e.jsx("span",{className:"bg-gray-100 dark:bg-gray-800 text-gray-800 text-xs px-2 py-1 rounded whitespace-nowrap",children:M},z)):e.jsx("span",{className:"text-xs text-gray-400 py-1",children:"-"})})}),e.jsx("div",{className:"mb-2",children:e.jsx("div",{className:"relative min-h-[24px] overflow-x-auto",children:((D=r.tags)==null?void 0:D.length)>0?e.jsxs("div",{className:"flex gap-1 items-center whitespace-nowrap",children:[g.map((M,z)=>e.jsxs("span",{className:"bg-green-50 text-green-700 text-xs px-2 py-1 rounded flex-shrink-0",children:["#",M]},z)),i&&e.jsxs("span",{className:"bg-gray-100 dark:bg-gray-800 text-gray-600 text-xs px-1.5 py-1 rounded flex-shrink-0",children:["+",l," ",f("market.moreTags")]})]}):e.jsx("span",{className:"text-xs text-gray-400 py-1",children:"-"})})})]})]})},xr=({server:r,onBack:C,onInstall:f,installing:c=!1,isInstalled:x=!1})=>{var A,re,K;const{t:g}=le(),[i,l]=s.useState(!1),[j,m]=s.useState(null),[_,D]=s.useState(!1),[M,z]=s.useState(null),[O,L]=s.useState([]),N=()=>x?{className:"bg-green-600 cursor-default px-4 py-2 rounded text-sm font-medium text-white",disabled:!0,text:g("market.installed")}:c?{className:"bg-gray-400 cursor-not-allowed px-4 py-2 rounded text-sm font-medium text-white",disabled:!0,text:g("market.installing")}:{className:"bg-blue-600 hover:bg-blue-700 px-4 py-2 rounded text-sm font-medium text-white btn-primary",disabled:!1,text:g("market.install")},H=()=>{l(!i),m(null),D(!1),z(null)},S=async()=>{M&&(await P(M),D(!1),z(null))},P=async y=>{try{m(null),f(r,y.config),l(!1)}catch(k){console.error("Error installing server:",k),m(g("errors.serverInstall"))}},U=()=>{x||H()},Z=()=>{if(!r.installations)return;if(r.installations.npm)return r.installations.npm;if(r.installations.uvx)return r.installations.uvx;if(r.installations.default)return r.installations.default;const y=Object.keys(r.installations);if(y.length>0)return r.installations[y[0]]},T=async y=>{try{const k=lr(y);k.length>0?(L(k),z(y),D(!0)):await P(y)}catch(k){console.error("Error processing server installation:",k),m(g("errors.serverInstall"))}},R=N(),W=Z();return e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[e.jsx("div",{className:"mb-4",children:e.jsxs("button",{onClick:C,className:"text-gray-600 hover:text-gray-900 flex items-center",children:[e.jsx("svg",{className:"h-5 w-5 mr-1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M9.707 16.707a1 1 0 01-1.414 0l-6-6a1 1 0 010-1.414l6-6a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l4.293 4.293a1 1 0 010 1.414z",clipRule:"evenodd"})}),g("market.backToList")]})}),e.jsxs("div",{className:"flex justify-between items-start mb-4",children:[e.jsx("div",{children:e.jsxs("h2",{className:"text-2xl font-bold text-gray-900 flex items-center flex-wrap",children:[r.display_name,e.jsxs("span",{className:"text-sm font-normal text-gray-500 ml-2",children:["(",r.name,")"]}),e.jsxs("span",{className:"text-sm font-normal text-gray-600 ml-4",children:[g("market.author"),": ",((A=r.author)==null?void 0:A.name)||g("market.unknown")," •"," ",g("market.license"),": ",r.license," •",e.jsx("a",{href:r.repository.url,target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:underline ml-1",children:g("market.repository")})]})]})}),e.jsxs("div",{className:"flex items-center",children:[r.is_official&&e.jsx("span",{className:"bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300 text-sm font-normal px-4 py-2 rounded mr-2 flex items-center label-primary",children:g("market.official")}),e.jsx("button",{onClick:U,disabled:R.disabled,className:R.className,children:R.text})]})]}),e.jsx("p",{className:"text-gray-700 mb-6",children:r.description}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("h3",{className:"text-lg font-semibold mb-3",children:[g("market.categories")," & ",g("market.tags")]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[(re=r.categories)==null?void 0:re.map((y,k)=>e.jsx("span",{className:"bg-gray-100 dark:bg-gray-800 text-gray-800 px-3 py-1 rounded",children:y},`cat-${k}`)),r.tags&&r.tags.map((y,k)=>e.jsxs("span",{className:"bg-gray-100 dark:bg-gray-800 text-green-700 px-2 py-1 rounded text-sm",children:["#",y]},`tag-${k}`))]})]}),r.arguments&&Object.keys(r.arguments).length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold mb-3",children:g("market.arguments")}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:g("market.argumentName")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:g("market.description")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:g("market.required")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:g("market.example")})]})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:Object.entries(r.arguments).map(([y,k],V)=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900",children:y}),e.jsx("td",{className:"px-6 py-4 text-sm text-gray-500",children:k.description}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:k.required?e.jsx("span",{className:"text-green-600",children:"✓"}):e.jsx("span",{className:"text-gray-600",children:"✗"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded",children:k.example})})]},V))})]})})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold mb-3",children:g("market.tools")}),e.jsx("div",{className:"space-y-4",children:(K=r.tools)==null?void 0:K.map((y,k)=>e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded p-4",children:[e.jsxs("h4",{className:"font-medium mb-2",children:[y.name,e.jsx("button",{type:"button",onClick:()=>{const V=document.getElementById(`schema-${k}`);V&&V.classList.toggle("hidden")},className:"text-sm text-blue-500 font-normal hover:underline focus:outline-none ml-2",children:g("market.viewSchema")})]}),e.jsx("p",{className:"text-gray-600 mb-2",children:y.description}),e.jsx("div",{className:"mt-2",children:e.jsx("pre",{id:`schema-${k}`,className:"hidden bg-gray-50 dark:bg-gray-800 p-3 rounded text-sm overflow-auto mt-2",children:JSON.stringify(y.inputSchema,null,2)})})]},k))})]}),r.examples&&r.examples.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold mb-3",children:g("market.examples")}),e.jsx("div",{className:"space-y-4",children:r.examples.map((y,k)=>e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded p-4",children:[e.jsx("h4",{className:"font-medium mb-2",children:y.title}),e.jsx("p",{className:"text-gray-600 mb-2",children:y.description}),e.jsx("pre",{className:"bg-gray-50 dark:bg-gray-800 p-3 rounded text-sm overflow-auto",children:y.prompt})]},k))})]}),e.jsx("div",{className:"mt-6 flex justify-end",children:e.jsx("button",{onClick:U,disabled:R.disabled,className:R.className,children:R.text})}),i&&e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx(Ce,{onSubmit:T,onCancel:H,modalTitle:g("market.installServer",{name:r.display_name}),formError:j,initialData:{name:r.name,status:"disconnected",config:W?{command:W.command||"",args:W.args||[],env:W.env||{}}:void 0}})}),_&&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:g("server.confirmVariables")}),e.jsx("p",{className:"text-gray-600 mb-4",children:g("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:[g("server.detectedVariables"),":"]}),e.jsx("ul",{className:"mt-1 text-sm text-yellow-700",children:O.map((y,k)=>e.jsxs("li",{className:"font-mono",children:["$",`{${y}}`]},k))})]})]})}),e.jsx("p",{className:"text-gray-600 text-sm mb-6",children:g("market.confirmVariablesMessage")}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>{D(!1),z(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:g("common.cancel")}),e.jsx("button",{onClick:S,className:"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 btn-primary",children:g("market.confirmAndInstall")})]})]})})]})},gr=({server:r,onClick:C})=>{const{t:f}=le(),c=()=>{C(r)},x=()=>{if(r.description&&r.description.length<=150)return r.description;if(r.content){const l=r.content.split(`
|
|
2
|
-
`).filter(j=>j.trim());for(const j of l)if(j.length>50&&j.length<=150)return j}return r.description?r.description.slice(0,150)+"...":f("cloud.noDescription")},g=l=>{try{const j=new Date(l),m=j.getFullYear(),_=(j.getMonth()+1).toString().padStart(2,"0"),D=j.getDate().toString().padStart(2,"0");return`${m}/${_}/${D}`}catch{return""}},i=l=>l.split(" ").map(j=>j.charAt(0)).join("").toUpperCase().slice(0,2);return e.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-4 hover:shadow-lg hover:border-blue-400 hover:-translate-y-1 transition-all duration-300 cursor-pointer group relative overflow-hidden h-full flex flex-col",onClick:c,children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-50/0 to-purple-50/0 group-hover:from-blue-50/30 group-hover:to-purple-50/30 dark:group-hover:from-blue-900/30 dark:group-hover:to-purple-900/30 transition-all duration-300 pointer-events-none"}),e.jsxs("div",{className:"relative z-10 flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 group-hover:text-blue-600 transition-colors duration-200 mb-2 line-clamp-2",children:r.title||r.name}),e.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[e.jsx("div",{className:"w-7 h-7 bg-gradient-to-br from-blue-500 to-purple-600 rounded-full flex items-center justify-center text-white text-xs font-semibold",children:i(r.author_name)}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-700",children:r.author_name}),r.updated_at&&e.jsxs("p",{className:"text-xs text-gray-500",children:[f("cloud.updated")," ",g(r.updated_at)]})]})]})]}),e.jsx("div",{className:"flex flex-col items-end space-y-2",children:e.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300",children:"MCP Server"})})]}),e.jsx("div",{className:"mb-3 flex-1",children:e.jsx("p",{className:"text-gray-600 text-sm leading-relaxed line-clamp-2",children:x()})}),r.tools&&r.tools.length>0&&e.jsx("div",{className:"mb-3",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs("svg",{className:"w-4 h-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),e.jsxs("span",{className:"text-sm text-gray-600 font-medium",children:[r.tools.length," ",r.tools.length===1?f("cloud.tool"):f("cloud.tools")]})]})}),e.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-gray-100 dark:border-gray-700 mt-auto",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-xs text-gray-500",children:[e.jsx("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z",clipRule:"evenodd"})}),e.jsx("span",{children:g(r.created_at)})]}),e.jsxs("div",{className:"flex items-center text-blue-600 text-sm font-medium group-hover:text-blue-700 transition-colors",children:[e.jsx("span",{children:f("cloud.viewDetails")}),e.jsx("svg",{className:"w-4 h-4 ml-1 transform group-hover:translate-x-1 transition-transform",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})]})]})]})},Se=()=>{const{t:r}=le(),C=Be(),f=()=>{C("/settings")},c=()=>{window.open("https://mcprouter.co","_blank","noopener,noreferrer")};return e.jsx("div",{className:"bg-amber-50 border border-amber-200 dark:bg-amber-900/20 dark:border-amber-900/50 rounded-lg p-6 mb-6",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-amber-400 dark:text-amber-500",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 flex-1",children:[e.jsx("h3",{className:"text-sm font-medium text-amber-800 dark:text-amber-400",children:r("cloud.apiKeyNotConfigured")}),e.jsx("div",{className:"mt-2 text-sm text-amber-700 dark:text-amber-300",children:e.jsx("p",{children:r("cloud.apiKeyNotConfiguredDescription")})}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsxs("button",{onClick:c,className:"inline-flex items-center px-3 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors duration-200",children:[e.jsx("svg",{className:"w-4 h-4 mr-1.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})}),r("cloud.getApiKey")]}),e.jsxs("button",{onClick:f,className:"inline-flex items-center px-3 py-2 text-sm font-medium text-amber-800 dark:text-amber-400 bg-amber-100 border border-amber-300 dark:bg-amber-900/40 dark:border-amber-700 dark:text-amber-300 rounded-md hover:bg-amber-200 dark:hover:bg-amber-900/60 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-amber-500 dark:focus:ring-amber-400 transition-colors duration-200",children:[e.jsxs("svg",{className:"w-4 h-4 mr-1.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),r("cloud.configureInSettings")]})]})]})]})})},hr=({serverName:r,onBack:C,onCallTool:f,fetchServerTools:c,onInstall:x,installing:g=!1,isInstalled:i=!1})=>{const{t:l}=le(),{mcpRouterConfig:j}=or(),[m,_]=s.useState(null),[D,M]=s.useState(!0),[z,O]=s.useState(null),[L,N]=s.useState([]),[H,S]=s.useState(!1),[P,U]=s.useState(!1),[Z,T]=s.useState(null),[R,W]=s.useState({}),[A,re]=s.useState({}),[K,y]=s.useState({}),[k,V]=s.useState(!1),[te,b]=s.useState(null),E=t=>(console.error("Checking for MCPRouter API key error:",t),t==="MCPROUTER_API_KEY_NOT_CONFIGURED"||t.toLowerCase().includes("mcprouter api key not configured")),w=()=>i?{className:"bg-green-600 cursor-default px-4 py-2 rounded text-sm font-medium text-white",disabled:!0,text:l("market.installed")}:g?{className:"bg-gray-400 cursor-not-allowed px-4 py-2 rounded text-sm font-medium text-white",disabled:!0,text:l("market.installing")}:{className:"bg-blue-600 hover:bg-blue-700 px-4 py-2 rounded text-sm font-medium text-white transition-colors",disabled:!1,text:l("market.install")},F=()=>{!i&&x&&(V(!0),b(null))},d=()=>{V(!1),b(null)},p=async t=>{try{if(!m||!x)return;b(null),x(m,t.config),V(!1)}catch(u){console.error("Error installing server:",u),b(l("errors.serverInstall"))}};s.useEffect(()=>{(async()=>{try{M(!0),O(null);const u=await J(`/cloud/servers/${r}`);u&&u.success&&u.data?(_(u.data),N(u.data.tools||[])):O(l("cloud.serverNotFound"))}catch(u){console.error("Failed to load server details:",u),O(u instanceof Error?u.message:String(u))}finally{M(!1)}})()},[r,l]),s.useEffect(()=>{(async()=>{if(m&&(!m.tools||m.tools.length===0)&&c){S(!0),U(!1);try{const u=await c(m.name);N(u)}catch(u){console.error("Failed to load tools:",u);const I=u instanceof Error?u.message:String(u);E(I)&&U(!0)}finally{S(!1)}}})()},[m==null?void 0:m.name,m==null?void 0:m.tools,c]);const h=t=>{try{const u=new Date(t),I=u.getFullYear(),B=String(u.getMonth()+1).padStart(2,"0"),ee=String(u.getDate()).padStart(2,"0"),ne=String(u.getHours()).padStart(2,"0"),ae=String(u.getMinutes()).padStart(2,"0"),oe=String(u.getSeconds()).padStart(2,"0");return`${I}-${B}-${ee} ${ne}:${ae}:${oe}`}catch{return t}},n=(t,u,I)=>{re(B=>({...B,[t]:{...B[t],[u]:I}}))},o=async t=>{if(!(!f||!m)){T(t);try{const u=A[t]||{},I=await f(m.server_key,t,u);W(B=>({...B,[t]:I}))}catch(u){console.error("Tool call failed:",u);const I=u instanceof Error?u.message:String(u);W(B=>({...B,[t]:{error:I}}))}finally{T(null)}}},X=t=>{y(u=>({...u,[t]:!u[t]}))},a=(t,u,I)=>{var ne;const B=((ne=A[t.name])==null?void 0:ne[u])||"",ee=ae=>{let oe=ae.target.value;I.type==="number"||I.type==="integer"?oe=oe===""?void 0:Number(oe):I.type==="boolean"&&(oe=ae.target.value==="true"),n(t.name,u,oe)};return I.type==="boolean"?e.jsxs("select",{value:B===!0?"true":B===!1?"false":"",onChange:ee,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",children:[e.jsx("option",{value:""}),e.jsx("option",{value:"true",children:l("common.true")}),e.jsx("option",{value:"false",children:l("common.false")})]}):I.type==="number"||I.type==="integer"?e.jsx("input",{type:"number",step:I.type==="integer"?"1":"any",value:B||"",onChange:ee,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"}):e.jsx("input",{type:"text",value:B||"",onChange:ee,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"})};return e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[e.jsx("div",{className:"mb-6",children:e.jsxs("button",{onClick:C,className:"inline-flex items-center text-gray-600 hover:text-gray-900 transition-colors group",children:[e.jsx("svg",{className:"h-5 w-5 mr-2 transform group-hover:-translate-x-1 transition-transform",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M9.707 16.707a1 1 0 01-1.414 0l-6-6a1 1 0 010-1.414l6-6a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l4.293 4.293a1 1 0 010 1.414z",clipRule:"evenodd"})}),l("cloud.backToList")]})}),D?e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm p-12",children:e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsxs("svg",{className:"animate-spin h-12 w-12 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 text-lg",children:l("app.loading")})]})}):z&&!E(z)?e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm p-6",children:e.jsx("div",{className:"bg-red-50 border border-red-200 dark:bg-red-900/20 dark:border-red-900/50 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("svg",{className:"h-5 w-5 text-red-400 dark:text-red-500 mr-3",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})}),e.jsx("p",{className:"text-red-700 dark:text-red-400",children:z})]})})}):m?e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm overflow-hidden",children:e.jsx("div",{className:"bg-gradient-to-r from-gray-100 to-gray-200 dark:from-gray-800 dark:to-gray-700 px-6 py-4",children:e.jsxs("div",{className:"flex justify-between items-end",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-800 mb-2",children:m.title||m.name}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-gray-600",children:[e.jsx("span",{className:"text-sm bg-white/60 dark:bg-gray-800/60 text-gray-700 px-3 py-1 rounded-full",children:m.name}),e.jsxs("div",{className:"flex items-center",children:[e.jsx("svg",{className:"h-4 w-4 mr-1",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z",clipRule:"evenodd"})}),l("cloud.by")," ",m.author_name]})]})]}),e.jsxs("div",{className:"text-right flex flex-col items-end gap-3",children:[e.jsxs("div",{className:"text-xs text-gray-500",children:[l("cloud.updated"),": ",h(m.updated_at)]}),x&&!E(z||"")&&!P&&e.jsx("button",{onClick:F,disabled:w().disabled,className:w().className,children:w().text})]})]})})}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm p-6",children:[e.jsxs("h2",{className:"text-xl font-semibold text-gray-900 mb-4 flex items-center",children:[e.jsx("svg",{className:"h-5 w-5 text-gray-500 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),l("cloud.description")]}),e.jsx("p",{className:"text-gray-700 leading-relaxed",children:m.description})]}),m.content&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm p-6",children:[e.jsxs("h2",{className:"text-xl font-semibold text-gray-900 mb-4 flex items-center",children:[e.jsx("svg",{className:"h-5 w-5 text-gray-500 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})}),l("cloud.details")]}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg p-4 overflow-auto",children:e.jsx("pre",{className:"text-sm text-gray-800 whitespace-pre-wrap",children:m.content})})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm p-6",children:[e.jsxs("h2",{className:"text-xl font-semibold text-gray-900 mb-4 flex items-center",children:[e.jsxs("svg",{className:"h-5 w-5 text-gray-500 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),l("cloud.tools"),L.length>0&&e.jsx("span",{className:"ml-2 bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300 text-sm font-medium px-2.5 py-0.5 rounded-full",children:L.length})]}),P&&e.jsx(Se,{}),H?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsxs("svg",{className:"animate-spin h-8 w-8 text-blue-500 mr-3",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("span",{className:"text-gray-600",children:l("cloud.loadingTools")})]}):L.length===0&&!P?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("svg",{className:"h-12 w-12 text-gray-400 mx-auto mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"})}),e.jsx("p",{className:"text-gray-600",children:l("cloud.noTools")})]}):L.length>0?e.jsx("div",{className:"space-y-4",children:L.map((t,u)=>e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg p-6 hover:border-gray-300 transition-colors",children:[e.jsxs("div",{className:"flex justify-between items-start mb-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("h3",{className:"text-lg font-medium text-gray-900 mb-2 flex items-center",children:[e.jsx("span",{className:"bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300 text-xs font-medium px-2 py-1 rounded mr-3",children:"TOOL"}),t.name]}),e.jsx("p",{className:"text-gray-600 leading-relaxed whitespace-pre-wrap",children:t.description})]}),f&&e.jsx("button",{onClick:()=>o(t.name),disabled:Z===t.name,className:"ml-4 bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center min-w-[100px] justify-center",children:Z===t.name?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"})]}),l("cloud.calling")]}):e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"h-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.828 14.828a4 4 0 01-5.656 0M9 10h6m2 8l4-4H7l4 4z"})}),l("cloud.callTool")]})})]}),t.inputSchema&&t.inputSchema.properties&&Object.keys(t.inputSchema.properties).length>0&&e.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700 pt-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700",children:l("cloud.parameters")}),e.jsxs("button",{onClick:()=>X(t.name),className:"text-sm text-blue-600 hover:text-blue-800 focus:outline-none flex items-center gap-1 transition-colors",children:[l("cloud.viewSchema"),e.jsx("svg",{className:`h-3 w-3 transition-transform duration-200 ${K[t.name]?"rotate-90":"rotate-0"}`,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"})})]})]}),K[t.name]&&e.jsx("div",{className:"mb-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg p-3 overflow-auto",children:e.jsx("pre",{className:"text-sm text-gray-800",children:JSON.stringify(t.inputSchema,null,2)})})}),e.jsx("div",{className:"space-y-4",children:Object.entries(t.inputSchema.properties).map(([I,B])=>{var ee;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700",children:[I,((ee=t.inputSchema.required)==null?void 0:ee.includes(I))&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),B.description&&e.jsx("p",{className:"text-xs text-gray-500",children:B.description}),a(t,I,B)]},I)})})]}),R[t.name]&&e.jsx("div",{className:"border-t border-gray-100 dark:border-gray-700 pt-4 mt-4",children:R[t.name].error?e.jsx(e.Fragment,{children:E(R[t.name].error)?e.jsx(Se,{}):e.jsxs(e.Fragment,{children:[e.jsxs("h4",{className:"text-sm font-medium text-red-600 mb-3 flex items-center",children:[e.jsx("svg",{className:"h-4 w-4 text-red-500 mr-2",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})}),l("cloud.error")]}),e.jsx("div",{className:"bg-red-50 border border-red-200 dark:bg-red-900/20 dark:border-red-900/50 rounded-lg p-4",children:e.jsx("pre",{className:"text-sm text-red-800 dark:text-red-300 whitespace-pre-wrap overflow-auto",children:R[t.name].error})})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("h4",{className:"text-sm font-medium text-gray-700 mb-3 flex items-center",children:[e.jsx("svg",{className:"h-4 w-4 text-green-500 mr-2",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}),l("cloud.result")]}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsx("pre",{className:"text-sm text-gray-800 whitespace-pre-wrap overflow-auto",children:JSON.stringify(R[t.name],null,2)})})]})})]},u))}):null]})]}):e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm p-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("svg",{className:"h-12 w-12 text-gray-400 mx-auto mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M9.172 16.172a4 4 0 015.656 0M9 12h6m-6-4h6m2 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 text-lg",children:l("cloud.serverNotFound")})]})}),k&&m&&e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx(Ce,{onSubmit:p,onCancel:d,modalTitle:l("cloud.installServer",{name:m.title||m.name}),formError:te,initialData:{name:m.name,status:"disconnected",config:{type:"streamable-http",url:m.server_url,headers:{Authorization:`Bearer ${j.apiKey||"<MCPROUTER_API_KEY>"}`,"HTTP-Referer":j.referer||"<YOUR_APP_URL>","X-Title":j.title||"<YOUR_APP_NAME>"}}}})})]})},fr=({serverEntry:r,onClick:C})=>{var H,S;const{t:f}=le(),{server:c,_meta:x}=r,g=()=>{C(r)},i=()=>c.description&&c.description.length<=150?c.description:c.description?c.description.slice(0,150)+"...":f("registry.noDescription"),l=P=>{if(!P)return"";try{const U=new Date(P),Z=U.getFullYear(),T=(U.getMonth()+1).toString().padStart(2,"0"),R=U.getDate().toString().padStart(2,"0");return`${Z}/${T}/${R}`}catch{return""}},m=c.icons&&c.icons.length>0?c.icons.find(U=>!U.theme||U.theme==="light")||c.icons[0]:null,_=x==null?void 0:x["io.modelcontextprotocol.registry/official"],D=_==null?void 0:_.isLatest,M=_==null?void 0:_.publishedAt,z=_==null?void 0:_.updatedAt,O=((H=c.packages)==null?void 0:H.length)||0,L=((S=c.remotes)==null?void 0:S.length)||0,N=O+L;return e.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-4 hover:shadow-lg hover:border-blue-400 hover:-translate-y-1 transition-all duration-300 cursor-pointer group relative overflow-hidden h-full flex flex-col",onClick:g,children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-50/0 to-purple-50/0 group-hover:from-blue-50/30 group-hover:to-purple-50/30 dark:group-hover:from-blue-900/30 dark:group-hover:to-purple-900/30 transition-all duration-300 pointer-events-none"}),e.jsxs("div",{className:"relative z-10 flex-1 flex flex-col",children:[e.jsx("div",{className:"flex items-start justify-between mb-3",children:e.jsxs("div",{className:"flex items-start space-x-3 flex-1",children:[m?e.jsx("img",{src:m.src,alt:c.title,className:"w-12 h-12 rounded-lg object-cover flex-shrink-0",onError:P=>{P.currentTarget.style.display="none"}}):e.jsx("div",{className:"w-12 h-12 bg-gradient-to-br from-blue-500 to-purple-600 rounded-lg flex items-center justify-center text-white text-xl font-semibold flex-shrink-0",children:"M"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 group-hover:text-blue-600 transition-colors duration-200 mb-1 line-clamp-2",children:c.name}),e.jsxs("div",{className:"flex flex-wrap gap-1 mb-1",children:[D&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800",children:f("registry.latest")}),e.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300",children:["v",c.version]})]})]})]})}),e.jsx("div",{className:"mb-3 flex-1",children:e.jsx("p",{className:"text-gray-600 text-sm leading-relaxed line-clamp-3",children:i()})}),N>0&&e.jsx("div",{className:"mb-3",children:e.jsxs("div",{className:"flex items-center space-x-4",children:[O>0&&e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx("svg",{className:"w-4 h-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",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("span",{className:"text-sm text-gray-600",children:[O," ",f(O===1?"registry.package":"registry.packages")]})]}),L>0&&e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx("svg",{className:"w-4 h-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})}),e.jsxs("span",{className:"text-sm text-gray-600",children:[L," ",f(L===1?"registry.remote":"registry.remotes")]})]})]})}),e.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-gray-100 dark:border-gray-700 mt-auto",children:[e.jsx("div",{className:"flex items-center space-x-2 text-xs text-gray-500",children:(M||z)&&e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z",clipRule:"evenodd"})}),e.jsx("span",{children:l(z||M)})]})}),e.jsxs("div",{className:"flex items-center text-blue-600 text-sm font-medium group-hover:text-blue-700 transition-colors",children:[e.jsx("span",{children:f("registry.viewDetails")}),e.jsx("svg",{className:"w-4 h-4 ml-1 transform group-hover:translate-x-1 transition-transform",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})]})]})]})},pr=({serverEntry:r,onBack:C,onInstall:f,installing:c=!1,isInstalled:x=!1,fetchVersions:g})=>{const{t:i}=le(),{server:l,_meta:j}=r,[m,_]=s.useState(l.version),[D,M]=s.useState([]),[z,O]=s.useState(!1),[L,N]=s.useState(!1),[H,S]=s.useState(null),[P,U]=s.useState(null),[Z,T]=s.useState(null),[R,W]=s.useState({packages:!0,remotes:!0,repository:!0}),A=j==null?void 0:j["io.modelcontextprotocol.registry/official"];s.useEffect(()=>{(async()=>{if(g){O(!0);try{const p=await g(l.name);M(p)}catch(p){console.error("Failed to load versions:",p)}finally{O(!1)}}})()},[l.name,g]);const K=l.icons&&l.icons.length>0?l.icons.find(p=>!p.theme||p.theme==="light")||l.icons[0]:null,y=d=>{if(!d)return"";try{return new Date(d).toLocaleDateString()}catch{return""}},k=d=>{W(p=>({...p,[d]:!p[d]}))},V=(d,p)=>{S(d),U(p),T(null),N(!0)},te=()=>{N(!1),T(null)},b=async d=>{try{if(!f||!P||!H)return;T(null);const p=d.config;f(l,p),N(!1)}catch(p){console.error("Error installing server:",p),T(i("errors.serverInstall"))}},E=()=>{if(!P||!H)return null;if(console.log("Building initial form data for:",P),H==="package"&&"identifier"in P){const d=P,p={};d.environmentVariables&&d.environmentVariables.forEach(n=>{p[n.name]=n.default||""});const h=yr(d.registryType);return{name:l.name,status:"disconnected",config:{type:"stdio",command:h,args:br(h,d),env:Object.keys(p).length>0?p:void 0}}}else if(H==="remote"&&"url"in P){const d=P,p={};d.headers&&d.headers.forEach(n=>{p[n.name]=n.default||n.value||""});const h=d.type==="sse"?"sse":"streamable-http";return{name:l.name,status:"disconnected",config:{type:h,url:d.url,headers:Object.keys(p).length>0?p:void 0}}}return null},w=(d,p)=>e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg p-4 mb-3 hover:border-blue-400 transition-colors",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-medium text-gray-900",children:d.identifier}),d.version&&e.jsxs("p",{className:"text-sm text-gray-500",children:["Version: ",d.version]}),d.runtimeHint&&e.jsx("p",{className:"text-sm text-gray-600 mt-1",children:d.runtimeHint})]}),e.jsx("button",{onClick:()=>V("package",d),disabled:x||c,className:`px-4 py-2 rounded text-sm font-medium transition-colors ${x?"bg-green-600 text-white cursor-default":c?"bg-gray-400 text-white cursor-not-allowed":"bg-blue-600 text-white hover:bg-blue-700"}`,children:i(x?"registry.installed":c?"registry.installing":"registry.install")})]}),d.registryType&&e.jsxs("div",{className:"text-sm text-gray-600 mb-2",children:[e.jsx("span",{className:"font-medium",children:"Registry:"})," ",d.registryType]}),d.transport&&e.jsxs("div",{className:"text-sm text-gray-600 mb-2",children:[e.jsx("span",{className:"font-medium",children:"Transport:"})," ",d.transport.type,d.transport.url&&e.jsxs("span",{className:"ml-2 text-gray-500",children:["(",d.transport.url,")"]})]}),d.environmentVariables&&d.environmentVariables.length>0&&e.jsxs("div",{className:"mt-3 border-t border-gray-200 dark:border-gray-700 pt-3",children:[e.jsxs("h5",{className:"text-sm font-medium text-gray-700 mb-2",children:[i("registry.environmentVariables"),":"]}),e.jsx("div",{className:"space-y-2",children:d.environmentVariables.map((h,n)=>e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"flex items-start",children:[e.jsx("span",{className:"font-mono text-gray-900 font-medium",children:h.name}),h.isRequired&&e.jsx("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-red-100 text-red-800",children:i("common.required")}),h.isSecret&&e.jsx("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-yellow-100 text-yellow-800",children:i("common.secret")})]}),h.description&&e.jsx("p",{className:"text-gray-600 mt-1",children:h.description}),h.default&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[i("common.default"),":"]})," ",e.jsx("span",{className:"font-mono",children:h.default})]})]},n))})]}),d.packageArguments&&d.packageArguments.length>0&&e.jsxs("div",{className:"mt-3 border-t border-gray-200 dark:border-gray-700 pt-3",children:[e.jsxs("h5",{className:"text-sm font-medium text-gray-700 mb-2",children:[i("registry.packageArguments"),":"]}),e.jsx("div",{className:"space-y-2",children:d.packageArguments.map((h,n)=>e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"flex items-start",children:[e.jsx("span",{className:"font-mono text-gray-900 font-medium",children:h.name}),h.isRequired&&e.jsx("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-red-100 text-red-800",children:i("common.required")}),h.isSecret&&e.jsx("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-yellow-100 text-yellow-800",children:i("common.secret")}),h.isRepeated&&e.jsx("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-purple-100 text-purple-800 dark:bg-purple-900/40 dark:text-purple-300",children:i("common.repeated")})]}),h.description&&e.jsx("p",{className:"text-gray-600 mt-1",children:h.description}),h.type&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[i("common.type"),":"]})," ",e.jsx("span",{className:"font-mono",children:h.type})]}),h.default&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[i("common.default"),":"]})," ",e.jsx("span",{className:"font-mono",children:h.default})]}),h.value&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[i("common.value"),":"]})," ",e.jsx("span",{className:"font-mono",children:h.value})]}),h.valueHint&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[i("common.valueHint"),":"]})," ",e.jsx("span",{className:"font-mono",children:h.valueHint})]}),h.choices&&h.choices.length>0&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[i("common.choices"),":"]})," ",e.jsx("span",{className:"font-mono",children:h.choices.join(", ")})]})]},n))})]})]},p),F=(d,p)=>e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg p-4 mb-3 hover:border-blue-400 transition-colors",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-medium text-gray-900",children:d.type}),e.jsx("p",{className:"text-sm text-gray-600 mt-1 break-all",children:d.url})]}),e.jsx("button",{onClick:()=>V("remote",d),disabled:x||c,className:`px-4 py-2 rounded text-sm font-medium transition-colors ${x?"bg-green-600 text-white cursor-default":c?"bg-gray-400 text-white cursor-not-allowed":"bg-blue-600 text-white hover:bg-blue-700"}`,children:i(x?"registry.installed":c?"registry.installing":"registry.install")})]}),d.headers&&d.headers.length>0&&e.jsxs("div",{className:"mt-3 border-t border-gray-200 dark:border-gray-700 pt-3",children:[e.jsxs("h5",{className:"text-sm font-medium text-gray-700 mb-2",children:[i("registry.headers"),":"]}),e.jsx("div",{className:"space-y-2",children:d.headers.map((h,n)=>e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"flex items-start",children:[e.jsx("span",{className:"font-mono text-gray-900 font-medium",children:h.name}),h.isRequired&&e.jsx("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-red-100 text-red-800",children:i("common.required")}),h.isSecret&&e.jsx("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-yellow-100 text-yellow-800",children:i("common.secret")})]}),h.description&&e.jsx("p",{className:"text-gray-600 mt-1",children:h.description}),h.value&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[i("common.value"),":"]})," ",e.jsx("span",{className:"font-mono",children:h.value})]}),h.default&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[i("common.default"),":"]})," ",e.jsx("span",{className:"font-mono",children:h.default})]})]},n))})]})]},p);return e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs("button",{onClick:C,className:"flex items-center text-blue-600 hover:text-blue-800 mb-4 transition-colors",children:[e.jsx("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),i("registry.backToList")]}),e.jsxs("div",{className:"flex items-start space-x-4",children:[K?e.jsx("img",{src:K.src,alt:l.title,className:"w-20 h-20 rounded-lg object-cover flex-shrink-0",onError:d=>{d.currentTarget.style.display="none"}}):e.jsx("div",{className:"w-20 h-20 bg-gradient-to-br from-blue-500 to-purple-600 rounded-lg flex items-center justify-center text-white text-3xl font-semibold flex-shrink-0",children:"M"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900 mb-2",children:l.name}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[(A==null?void 0:A.isLatest)&&e.jsx("span",{className:"inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-green-100 text-green-800",children:i("registry.latest")}),e.jsxs("span",{className:"inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300",children:["v",l.version]}),(A==null?void 0:A.status)&&e.jsx("span",{className:"inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-gray-100 dark:bg-gray-800 text-gray-800",children:A.status}),e.jsxs("span",{className:"flex flex-wrap items-center gap-4 text-sm text-gray-600",children:[(A==null?void 0:A.publishedAt)&&e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[i("registry.published"),":"]})," ",y(A.publishedAt)]}),(A==null?void 0:A.updatedAt)&&e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[i("registry.updated"),":"]})," ",y(A.updatedAt)]})]})]})]})]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-3",children:i("registry.description")}),e.jsx("p",{className:"text-gray-700 leading-relaxed whitespace-pre-wrap",children:l.description})]}),l.websiteUrl&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-3",children:i("registry.website")}),e.jsx("a",{href:l.websiteUrl,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:text-blue-800 hover:underline",children:l.websiteUrl})]}),l.packages&&l.packages.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsxs("button",{onClick:()=>k("packages"),className:"flex items-center justify-between w-full text-xl font-semibold text-gray-900 mb-3 hover:text-blue-600 transition-colors",children:[e.jsxs("span",{children:[i("registry.packages")," (",l.packages.length,")"]}),e.jsx("svg",{className:`w-5 h-5 transform transition-transform ${R.packages?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),R.packages&&e.jsx("div",{className:"space-y-3",children:l.packages.map(w)})]}),l.remotes&&l.remotes.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsxs("button",{onClick:()=>k("remotes"),className:"flex items-center justify-between w-full text-xl font-semibold text-gray-900 mb-3 hover:text-blue-600 transition-colors",children:[e.jsxs("span",{children:[i("registry.remotes")," (",l.remotes.length,")"]}),e.jsx("svg",{className:`w-5 h-5 transform transition-transform ${R.remotes?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),R.remotes&&e.jsx("div",{className:"space-y-3",children:l.remotes.map(F)})]}),l.repository&&e.jsxs("div",{className:"mb-6",children:[e.jsxs("button",{onClick:()=>k("repository"),className:"flex items-center justify-between w-full text-xl font-semibold text-gray-900 mb-3 hover:text-blue-600 transition-colors",children:[e.jsx("span",{children:i("registry.repository")}),e.jsx("svg",{className:`w-5 h-5 transform transition-transform ${R.repository?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),R.repository&&e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[l.repository.url&&e.jsxs("div",{className:"mb-2",children:[e.jsx("span",{className:"font-medium text-gray-700",children:"URL:"})," ",e.jsx("a",{href:l.repository.url,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:text-blue-800 hover:underline break-all",children:l.repository.url})]}),l.repository.source&&e.jsxs("div",{className:"mb-2",children:[e.jsx("span",{className:"font-medium text-gray-700",children:"Source:"})," ",l.repository.source]}),l.repository.subfolder&&e.jsxs("div",{className:"mb-2",children:[e.jsx("span",{className:"font-medium text-gray-700",children:"Subfolder:"})," ",l.repository.subfolder]}),l.repository.id&&e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-gray-700",children:"ID:"})," ",l.repository.id]})]})]}),L&&P&&H&&e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx(Ce,{onSubmit:b,onCancel:te,modalTitle:i("registry.installServer",{name:l.title||l.name}),formError:Z,initialData:E()})})]})};function yr(r){switch(r.toLowerCase()){case"pypi":case"python":return"uvx";case"npm":case"node":return"npx";case"oci":case"docker":return"docker";default:return""}}function br(r,C){const f=[C.identifier+(C.version?`@${C.version}`:"")],c=[];switch(C.packageArguments&&C.packageArguments.length>0&&C.packageArguments.forEach(x=>{if(x.isRequired||x.default||x.value){const g=`--${x.name}`,i=x.value||x.default||`\${${x.name.toUpperCase()}}`;c.push(g,i)}}),r.toLowerCase()){case"uvx":return[...f,...c];case"npx":return[...f,...c];case"docker":{const x=[];return C.environmentVariables&&C.environmentVariables.forEach(g=>{x.push("-e",`${g.name}`)}),["run","-i","--rm",...x,...f,...c]}default:return[...f,...c]}}const vr=({currentPage:r,hasNextPage:C,hasPreviousPage:f,onNextPage:c,onPreviousPage:x})=>e.jsxs("div",{className:"flex items-center justify-center space-x-2 my-6",children:[e.jsxs("button",{onClick:x,disabled:!f,className:`px-4 py-2 rounded transition-all duration-200 ${f?"bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary":"bg-gray-100 text-gray-400 cursor-not-allowed"}`,children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 inline-block mr-1",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",clipRule:"evenodd"})}),"Prev"]}),e.jsxs("span",{className:"px-4 py-2 bg-blue-500 text-white rounded btn-primary",children:["Page ",r]}),e.jsxs("button",{onClick:c,disabled:!C,className:`px-4 py-2 rounded transition-all duration-200 ${C?"bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary":"bg-gray-100 text-gray-400 cursor-not-allowed"}`,children:["Next",e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 inline-block ml-1",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"})})]})]}),Er=()=>{const{t:r}=le(),C=Be(),{serverName:f}=tr(),{showToast:c}=nr(),[x,g]=ar(),i=x.get("tab")||"cloud",{servers:l,allServers:j,categories:m,loading:_,error:D,setError:M,searchServers:z,filterByCategory:O,filterByTag:L,selectedCategory:N,selectedTag:H,installServer:S,fetchServerByName:P,isServerInstalled:U,currentPage:Z,totalPages:T,changePage:R,serversPerPage:W,changeServersPerPage:A}=cr(),{servers:re,allServers:K,loading:y,error:k,setError:V,fetchServerTools:te,callServerTool:b,currentPage:E,totalPages:w,changePage:F,serversPerPage:d,changeServersPerPage:p}=dr(),{servers:h,allServers:n,loading:o,error:X,setError:a,searchServers:t,clearSearch:u,fetchServerByName:I,fetchServerVersions:B,currentPage:ee,totalPages:ne,hasNextPage:ae,hasPreviousPage:oe,changePage:$e,goToNextPage:ze,goToPreviousPage:_e,serversPerPage:De,changeServersPerPage:Ve}=mr(),[xe,Pe]=s.useState(null),[ge,Ee]=s.useState(null),[he,Le]=s.useState(null),[fe,Re]=s.useState(""),[pe,Te]=s.useState(""),[ye,de]=s.useState(!1),[He,Fe]=s.useState(new Set),[Ue,Oe]=s.useState(new Set);s.useEffect(()=>{(async()=>{if(f)if(i==="cloud"){const $=re.find(Y=>Y.name===f);$?Ee($):C("/market?tab=cloud")}else if(i==="registry"){console.log("Loading registry server details for:",f);const $=await I(f);$?Le($):C("/market?tab=registry")}else{const $=await P(f);$?Pe($):C("/market?tab=local")}else Pe(null),Ee(null),Le(null)})()},[f,i,re,P,I,C]);const be=v=>{const $=new URLSearchParams(x);$.set("tab",v),g($),f&&C("/market?"+$.toString())},We=v=>{v.preventDefault(),i==="local"?z(fe):i==="registry"&&t(pe)},Ke=v=>{i==="local"&&O(v)},Ye=()=>{i==="local"?(Re(""),O(""),L("")):i==="registry"&&(Te(""),u())},ve=v=>{var $;if(i==="cloud")C(`/market/${v.name}?tab=cloud`);else if(i==="registry"){const Y=v;console.log("Registry server clicked:",Y);const Q=($=Y.server)==null?void 0:$.name;if(console.log("Server name extracted:",Q),Q){const se=`/market/${encodeURIComponent(Q)}?tab=registry`;console.log("Navigating to:",se),C(se)}else console.error("Server name is undefined in registry server:",Y)}else C(`/market/${v.name}?tab=local`)},je=()=>{C(`/market?tab=${i}`)},Qe=async(v,$)=>{try{de(!0),await S(v,$)&&c(r("market.installSuccess",{serverName:v.display_name}),"success")}finally{de(!1)}},Ge=async(v,$)=>{try{de(!0);const Y={name:v.name,config:$},Q=await ue("/servers",Y);if(!Q.success){const se=(Q==null?void 0:Q.message)||r("server.addError");c(se,"error");return}Fe(se=>new Set(se).add(v.name)),c(r("cloud.installSuccess",{name:v.title||v.name}),"success")}catch(Y){console.error("Error installing cloud server:",Y);const Q=Y instanceof Error?Y.message:String(Y);c(r("cloud.installError",{error:Q}),"error")}finally{de(!1)}},qe=async(v,$)=>{try{de(!0);const Y={name:v.name,config:$},Q=await ue("/servers",Y);if(!Q.success){const se=(Q==null?void 0:Q.message)||r("server.addError");c(se,"error");return}Oe(se=>new Set(se).add(v.name)),c(r("registry.installSuccess",{name:v.title||v.name}),"success")}catch(Y){console.error("Error installing registry server:",Y);const Q=Y instanceof Error?Y.message:String(Y);c(r("registry.installError",{error:Q}),"error")}finally{de(!1)}},Je=async(v,$,Y)=>{try{const Q=await b(v,$,Y);return c(r("cloud.toolCallSuccess",{toolName:$}),"success"),Q}catch(Q){const se=Q instanceof Error?Q.message:String(Q);throw Me(se)||c(r("cloud.toolCallError",{toolName:$,error:se}),"error"),Q}},Me=v=>v==="MCPROUTER_API_KEY_NOT_CONFIGURED"||v.toLowerCase().includes("mcprouter api key not configured"),Xe=v=>{i==="local"?R(v):i==="registry"?$e(v):F(v),window.scrollTo({top:0,behavior:"smooth"})},Ze=v=>{const $=parseInt(v.target.value,10);i==="local"?A($):i==="registry"?Ve($):p($)};if(xe)return e.jsx(xr,{server:xe,onBack:je,onInstall:Qe,installing:ye,isInstalled:U(xe.name)});if(ge)return e.jsx(hr,{serverName:ge.name,onBack:je,onCallTool:Je,fetchServerTools:te,onInstall:Ge,installing:ye,isInstalled:He.has(ge.name)});if(he)return e.jsx(pr,{serverEntry:he,onBack:je,onInstall:qe,installing:ye,isInstalled:Ue.has(he.server.name),fetchVersions:B});const q=i==="local",G=i==="registry",Ne=q?l:G?h:re,me=q?j:G?n:K,Ae=q?m:[],Ie=q?_:G?o:y,ke=q?D:G?X:k,er=q?M:G?a:V,we=q?N:"",rr=q?H:"",ie=q?Z:G?ee:E,sr=q?T:G?ne:w,ce=q?W:G?De:d;return e.jsxs("div",{children:[e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700",children:e.jsxs("nav",{className:"-mb-px flex space-x-3",children:[e.jsxs("button",{onClick:()=>be("cloud"),className:`py-2 px-1 border-b-2 font-medium text-lg hover:cursor-pointer transition-colors duration-200 ${!q&&!G?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"}`,children:[r("cloud.title"),e.jsxs("span",{className:"text-xs text-gray-400 font-normal ml-1",children:["(",e.jsx("a",{href:"https://mcprouter.co",target:"_blank",rel:"noopener noreferrer",className:"external-link",children:"MCPRouter"}),")"]})]}),e.jsxs("button",{onClick:()=>be("local"),className:`py-2 px-1 border-b-2 font-medium text-lg hover:cursor-pointer transition-colors duration-200 ${q?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"}`,children:[r("market.title"),e.jsxs("span",{className:"text-xs text-gray-400 font-normal ml-1",children:["(",e.jsx("a",{href:"https://mcpm.sh",target:"_blank",rel:"noopener noreferrer",className:"external-link",children:"MCPM"}),")"]})]}),e.jsxs("button",{onClick:()=>be("registry"),className:`py-2 px-1 border-b-2 font-medium text-lg hover:cursor-pointer transition-colors duration-200 ${G?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"}`,children:[r("registry.title"),e.jsxs("span",{className:"text-xs text-gray-400 font-normal ml-1",children:["(",e.jsx("a",{href:"https://registry.modelcontextprotocol.io",target:"_blank",rel:"noopener noreferrer",className:"external-link",children:r("registry.official")}),")"]})]})]})})}),ke&&e.jsx(e.Fragment,{children:!q&&Me(ke)?e.jsx(Se,{}):e.jsx("div",{className:"bg-red-100 border-l-4 border-red-500 text-red-700 dark:text-red-400 p-4 mb-6 error-box rounded-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{children:ke}),e.jsx("button",{onClick:()=>er(null),className:"text-red-700 dark:text-red-400 hover:text-red-900 transition-colors duration-200",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 01.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"})})})]})})}),(q||G)&&e.jsx("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 mb-6 page-card",children:e.jsxs("form",{onSubmit:We,className:"flex space-x-4 mb-0",children:[e.jsx("div",{className:"flex-grow",children:e.jsx("input",{type:"text",value:G?pe:fe,onChange:v=>{G?Te(v.target.value):Re(v.target.value)},placeholder:r(G?"registry.searchPlaceholder":"market.searchPlaceholder"),className:"shadow appearance-none border border-gray-200 dark:border-gray-700 rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline form-input"})}),e.jsx("button",{type:"submit",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:r(G?"registry.search":"market.search")}),(q&&(fe||we||rr)||G&&pe)&&e.jsx("button",{type:"button",onClick:Ye,className:"border border-gray-300 text-gray-700 font-medium py-2 px-4 rounded hover:bg-gray-50 dark:bg-gray-800 dark:hover:bg-gray-700 btn-secondary transition-all duration-200",children:r(G?"registry.clearFilters":"market.clearFilters")})]})}),e.jsxs("div",{className:"flex flex-col md:flex-row gap-6",children:[q&&e.jsx("div",{className:"md:w-48 flex-shrink-0",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-4 mb-6 sticky top-4 page-card",children:Ae.length>0?e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex justify-between items-center mb-3",children:[e.jsx("h3",{className:"font-medium text-gray-900",children:r("market.categories")}),we&&e.jsx("span",{className:"text-xs text-blue-600 cursor-pointer hover:underline transition-colors duration-200",onClick:()=>O(""),children:r("market.clearCategoryFilter")})]}),e.jsx("div",{className:"flex flex-col gap-2",children:Ae.map(v=>e.jsx("button",{onClick:()=>Ke(v),className:`px-3 py-2 rounded text-sm text-left transition-all duration-200 ${we===v?"bg-blue-100 text-blue-800 font-medium btn-primary":"bg-gray-100 text-gray-800 hover:bg-gray-200 btn-secondary"}`,children:v},v))})]}):Ie?e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"mb-3",children:e.jsx("h3",{className:"font-medium text-gray-900",children:r("market.categories")})}),e.jsxs("div",{className:"flex flex-col gap-2 items-center py-4 loading-container",children:[e.jsxs("svg",{className:"animate-spin h-6 w-6 text-blue-500 mb-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("p",{className:"text-sm text-gray-600",children:r("app.loading")})]})]}):e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"mb-3",children:e.jsx("h3",{className:"font-medium text-gray-900",children:r("market.categories")})}),e.jsx("p",{className:"text-sm text-gray-600 py-2",children:r("market.noCategories")})]})})}),e.jsx("div",{className:"flex-grow",children:Ie?e.jsx("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 flex items-center justify-center",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:r("app.loading")})]})}):Ne.length===0?e.jsx("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6",children:e.jsx("p",{className:"text-gray-600",children:r(q?"market.noServers":G?"registry.noServers":"cloud.noServers")})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 xl:grid-cols-3 gap-6",children:Ne.map((v,$)=>q?e.jsx(ur,{server:v,onClick:ve},$):G?e.jsx(fr,{serverEntry:v,onClick:ve},$):e.jsx(gr,{server:v,onClick:ve},$))}),e.jsxs("div",{className:"flex items-center mb-4",children:[e.jsx("div",{className:"flex-[2] text-sm text-gray-500",children:q?r("market.showing",{from:(ie-1)*ce+1,to:Math.min(ie*ce,me.length),total:me.length}):G?r("registry.showing",{from:(ie-1)*ce+1,to:(ie-1)*ce+Ne.length,total:me.length+(ae?"+":"")}):r("cloud.showing",{from:(ie-1)*ce+1,to:Math.min(ie*ce,me.length),total:me.length})}),e.jsx("div",{className:"flex-[4] flex justify-center",children:G?e.jsx(vr,{currentPage:ie,hasNextPage:ae,hasPreviousPage:oe,onNextPage:ze,onPreviousPage:_e}):e.jsx(ir,{currentPage:ie,totalPages:sr,onPageChange:Xe})}),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:[r(q?"market.perPage":G?"registry.perPage":"cloud.perPage"),":"]}),e.jsxs("select",{id:"perPage",value:ce,onChange:Ze,className:"border rounded p-1 text-sm btn-secondary outline-none",children:[e.jsx("option",{value:"6",children:"6"}),e.jsx("option",{value:"9",children:"9"}),e.jsx("option",{value:"12",children:"12"}),e.jsx("option",{value:"24",children:"24"})]})]})]})]})})]})]})};export{Er as default};
|
|
3
|
-
//# sourceMappingURL=MarketPage-haRuzjCw.js.map
|