@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.
Files changed (65) hide show
  1. package/dist/config/index.js +9 -9
  2. package/dist/config/index.js.map +1 -1
  3. package/dist/middlewares/userContext.js +17 -2
  4. package/dist/middlewares/userContext.js.map +1 -1
  5. package/dist/services/mcpService.js +7 -2
  6. package/dist/services/mcpService.js.map +1 -1
  7. package/dist/services/vectorSearchService.js +5 -1
  8. package/dist/services/vectorSearchService.js.map +1 -1
  9. package/frontend/dist/assets/ActivityPage-ClgKeihP.js +2 -0
  10. package/frontend/dist/assets/ActivityPage-ClgKeihP.js.map +1 -0
  11. package/frontend/dist/assets/Badge-Ck2fhRdl.js +2 -0
  12. package/frontend/dist/assets/Badge-Ck2fhRdl.js.map +1 -0
  13. package/frontend/dist/assets/ConfirmDialog-uYjffH4V.js +2 -0
  14. package/frontend/dist/assets/ConfirmDialog-uYjffH4V.js.map +1 -0
  15. package/frontend/dist/assets/Dashboard-BIXrLobn.js +2 -0
  16. package/frontend/dist/assets/Dashboard-BIXrLobn.js.map +1 -0
  17. package/frontend/dist/assets/DeleteDialog-BAfrV8EB.js +2 -0
  18. package/frontend/dist/assets/DeleteDialog-BAfrV8EB.js.map +1 -0
  19. package/frontend/dist/assets/GroupsPage-BjrvyHwu.js +33 -0
  20. package/frontend/dist/assets/GroupsPage-BjrvyHwu.js.map +1 -0
  21. package/frontend/dist/assets/LoginPage-BBHt_TfF.js +2 -0
  22. package/frontend/dist/assets/LoginPage-BBHt_TfF.js.map +1 -0
  23. package/frontend/dist/assets/LogsPage-D8Znq5NB.js +2 -0
  24. package/frontend/dist/assets/LogsPage-D8Znq5NB.js.map +1 -0
  25. package/frontend/dist/assets/MarketPage-haRuzjCw.js +3 -0
  26. package/frontend/dist/assets/MarketPage-haRuzjCw.js.map +1 -0
  27. package/frontend/dist/assets/Pagination-y-gVO8ms.js +2 -0
  28. package/frontend/dist/assets/Pagination-y-gVO8ms.js.map +1 -0
  29. package/frontend/dist/assets/PromptsPage-ByHWPyGe.js +2 -0
  30. package/frontend/dist/assets/PromptsPage-ByHWPyGe.js.map +1 -0
  31. package/frontend/dist/assets/ResourcesPage-Bodw5OY9.js +2 -0
  32. package/frontend/dist/assets/ResourcesPage-Bodw5OY9.js.map +1 -0
  33. package/frontend/dist/assets/ServersPage-CtS1I4yS.js +37 -0
  34. package/frontend/dist/assets/ServersPage-CtS1I4yS.js.map +1 -0
  35. package/frontend/dist/assets/SettingsPage-DxVigf7p.js +12 -0
  36. package/frontend/dist/assets/SettingsPage-DxVigf7p.js.map +1 -0
  37. package/frontend/dist/assets/ToggleGroup-HfxdlkGi.js +2 -0
  38. package/frontend/dist/assets/ToggleGroup-HfxdlkGi.js.map +1 -0
  39. package/frontend/dist/assets/UsersPage-Bipw33cS.js +2 -0
  40. package/frontend/dist/assets/UsersPage-Bipw33cS.js.map +1 -0
  41. package/frontend/dist/assets/framework-vendor-_OBebcuv.js +61 -0
  42. package/frontend/dist/assets/framework-vendor-_OBebcuv.js.map +1 -0
  43. package/frontend/dist/assets/i18n-vendor-MQ921plD.js +2 -0
  44. package/frontend/dist/assets/i18n-vendor-MQ921plD.js.map +1 -0
  45. package/frontend/dist/assets/icons-vendor-B67NtVuR.js +172 -0
  46. package/frontend/dist/assets/icons-vendor-B67NtVuR.js.map +1 -0
  47. package/frontend/dist/assets/index-CmnA4an8.js +5 -0
  48. package/frontend/dist/assets/index-CmnA4an8.js.map +1 -0
  49. package/frontend/dist/assets/index-DfFHVARX.css +1 -0
  50. package/frontend/dist/assets/resourceService-BfCTSBsr.js +2 -0
  51. package/frontend/dist/assets/{resourceService-CUz722Nb.js.map → resourceService-BfCTSBsr.js.map} +1 -1
  52. package/frontend/dist/assets/useGroupData-DLhbP6zd.js +2 -0
  53. package/frontend/dist/assets/useGroupData-DLhbP6zd.js.map +1 -0
  54. package/frontend/dist/assets/useServerData-QZqQTYcv.js +2 -0
  55. package/frontend/dist/assets/useServerData-QZqQTYcv.js.map +1 -0
  56. package/frontend/dist/assets/useSettingsData-D3VROqS7.js +2 -0
  57. package/frontend/dist/assets/useSettingsData-D3VROqS7.js.map +1 -0
  58. package/frontend/dist/assets/variableDetection-C3Xi21av.js +16 -0
  59. package/frontend/dist/assets/variableDetection-C3Xi21av.js.map +1 -0
  60. package/frontend/dist/index.html +5 -2
  61. package/package.json +2 -2
  62. package/frontend/dist/assets/index-CVDuCISB.js +0 -323
  63. package/frontend/dist/assets/index-CVDuCISB.js.map +0 -1
  64. package/frontend/dist/assets/index-PEyR1nSL.css +0 -1
  65. package/frontend/dist/assets/resourceService-CUz722Nb.js +0 -2
@@ -0,0 +1,12 @@
1
+ import{r as c,j as e,u as Ye}from"./framework-vendor-_OBebcuv.js";import{n as Ze,h as ke,m as We,P as I}from"./index-CmnA4an8.js";import{u as pe}from"./i18n-vendor-MQ921plD.js";import{S as A}from"./ToggleGroup-HfxdlkGi.js";import{X as Qe,j as es,C as Ae,g as Te,D as ss,h as ts,n as as}from"./icons-vendor-B67NtVuR.js";import{u as rs}from"./useSettingsData-D3VROqS7.js";import{u as ns}from"./useGroupData-DLhbP6zd.js";const we=s=>{const m=[];return s.length<8&&m.push("passwordMinLength"),/[a-zA-Z]/.test(s)||m.push("passwordRequireLetter"),/\d/.test(s)||m.push("passwordRequireNumber"),/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/.test(s)||m.push("passwordRequireSpecial"),{isValid:m.length===0,errors:m}},is=({onSuccess:s,onCancel:m})=>{const{t:o}=pe(),[h,f]=c.useState({currentPassword:"",newPassword:""}),[C,d]=c.useState(""),[a,T]=c.useState(!1),[S,w]=c.useState(null),[j,z]=c.useState(!1),[R,P]=c.useState([]),M=l=>{const{name:p,value:y}=l.target;if(p==="confirmPassword")d(y);else if(f(E=>({...E,[p]:y})),p==="newPassword"){const E=we(y);P(E.errors)}},N=async l=>{l.preventDefault(),w(null);const p=we(h.newPassword);if(!p.isValid){w(o("auth.passwordStrengthError")),P(p.errors);return}if(h.newPassword!==C){w(o("auth.passwordsNotMatch"));return}T(!0);try{const y=await Ze(h);y.success?(z(!0),s&&s()):w(y.message||o("auth.changePasswordError"))}catch{w(o("auth.changePasswordError"))}finally{T(!1)}};return e.jsxs("div",{className:"p-6 bg-white dark:bg-gray-800 rounded-lg shadow-md",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:o("auth.changePassword")}),j?e.jsx("div",{className:"bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded mb-4",children:o("auth.changePasswordSuccess")}):e.jsxs("form",{onSubmit:N,children:[S&&e.jsx("div",{className:"bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4",children:S}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-gray-700 text-sm font-bold mb-2",htmlFor:"currentPassword",children:o("auth.currentPassword")}),e.jsx("input",{type:"password",id:"currentPassword",name:"currentPassword",className:"w-full p-2 border rounded focus:outline-none focus:ring-2 focus:ring-blue-500 form-input",value:h.currentPassword,onChange:M,required:!0})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-gray-700 text-sm font-bold mb-2",htmlFor:"newPassword",children:o("auth.newPassword")}),e.jsx("input",{type:"password",id:"newPassword",name:"newPassword",className:"w-full p-2 border rounded focus:outline-none focus:ring-2 focus:ring-blue-500 form-input",value:h.newPassword,onChange:M,required:!0,minLength:8}),h.newPassword&&R.length>0&&e.jsxs("div",{className:"mt-2 text-sm text-gray-600",children:[e.jsx("p",{className:"font-semibold mb-1",children:o("auth.passwordStrengthHint")}),e.jsx("ul",{className:"list-disc list-inside space-y-1",children:R.map(l=>e.jsx("li",{className:"text-red-600",children:o(`auth.${l}`)},l))})]}),h.newPassword&&R.length===0&&e.jsxs("p",{className:"mt-2 text-sm text-green-600",children:["✓ ",o("auth.passwordStrengthHint")]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{className:"block text-gray-700 text-sm font-bold mb-2",htmlFor:"confirmPassword",children:o("auth.confirmPassword")}),e.jsx("input",{type:"password",id:"confirmPassword",name:"confirmPassword",className:"w-full p-2 border rounded focus:outline-none focus:ring-2 focus:ring-blue-500 form-input",value:C,onChange:M,required:!0,minLength:8})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[m&&e.jsx("button",{type:"button",onClick:m,disabled:a,className:"py-2 px-4 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500",children:o("common.cancel")}),e.jsx("button",{type:"submit",disabled:a,className:"py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 btn-primary",children:a?e.jsxs("span",{className:"flex items-center",children:[e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white",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"})]}),o("common.save")]}):o("common.save")})]})]})]})},$=({options:s,selected:m,onChange:o,placeholder:h="Select items...",disabled:f=!1,className:C=""})=>{const[d,a]=c.useState(!1),[T,S]=c.useState(""),w=c.useRef(null),j=c.useRef(null);c.useEffect(()=>{const l=p=>{w.current&&!w.current.contains(p.target)&&(a(!1),S(""))};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[]);const z=s.filter(l=>l.label.toLowerCase().includes(T.toLowerCase())),R=l=>{if(f)return;const p=m.includes(l)?m.filter(y=>y!==l):[...m,l];o(p)},P=(l,p)=>{p.stopPropagation(),!f&&o(m.filter(y=>y!==l))},M=()=>{f||(a(!d),d||setTimeout(()=>{var l;return(l=j.current)==null?void 0:l.focus()},0))},N=()=>m.map(l=>{var p;return((p=s.find(y=>y.value===l))==null?void 0:p.label)||l}).filter(Boolean);return e.jsxs("div",{ref:w,className:`relative ${C}`,children:[e.jsxs("div",{onClick:M,className:`
2
+ min-h-[38px] w-full px-3 py-1.5 border rounded-md shadow-sm
3
+ flex flex-wrap items-center gap-1.5 cursor-pointer
4
+ transition-all duration-200
5
+ ${f?"bg-gray-100 cursor-not-allowed":"bg-white hover:border-blue-400"}
6
+ ${d?"border-blue-500 ring-1 ring-blue-500":"border-gray-300"}
7
+ `,children:[m.length>0?e.jsx(e.Fragment,{children:N().map((l,p)=>e.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300",children:[l,!f&&e.jsx("button",{type:"button",onClick:y=>P(m[p],y),className:"ml-1 hover:bg-blue-200 rounded-full p-0.5 transition-colors",children:e.jsx(Qe,{className:"h-3 w-3"})})]},m[p]))}):e.jsx("span",{className:"text-gray-400 text-sm",children:h}),e.jsx("div",{className:"flex-1"}),e.jsx(es,{className:`h-4 w-4 text-gray-400 transition-transform duration-200 ${d?"transform rotate-180":""}`})]}),d&&!f&&e.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-white dark:bg-gray-800 border border-gray-300 rounded-md shadow-lg max-h-60 overflow-hidden",children:[e.jsx("div",{className:"p-2 border-b border-gray-200 dark:border-gray-700",children:e.jsx("input",{ref:j,type:"text",value:T,onChange:l=>S(l.target.value),placeholder:"Search...",className:"w-full px-3 py-1.5 text-sm border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500",onClick:l=>l.stopPropagation()})}),e.jsx("div",{className:"max-h-48 overflow-y-auto",children:z.length>0?z.map(l=>{const p=m.includes(l.value);return e.jsxs("div",{onClick:()=>R(l.value),className:`
8
+ px-3 py-2 cursor-pointer flex items-center justify-between
9
+ transition-colors duration-150
10
+ ${p?"bg-blue-50 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300":"hover:bg-gray-100 dark:hover:bg-gray-700"}
11
+ `,children:[e.jsx("span",{className:"text-sm",children:l.label}),p&&e.jsx(Ae,{className:"h-4 w-4 text-blue-600"})]},l.value)}):e.jsx("div",{className:"px-3 py-2 text-sm text-gray-500 text-center",children:T?"No results found":"No options available"})})]})]})};function os(s=32){const m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",o=new Uint8Array(s);return crypto.getRandomValues(o),Array.from(o).map(h=>m.charAt(h%m.length)).join("")}const L={SETTINGS_SMART_ROUTING:"settings:smart_routing",SETTINGS_ROUTE_CONFIG:"settings:route_config",SETTINGS_INSTALL_CONFIG:"settings:install_config",SETTINGS_SYSTEM_CONFIG:"settings:system_config",SETTINGS_OAUTH_SERVER:"settings:oauth_server",SETTINGS_EXPORT_CONFIG:"settings:export_config"},ds=({keyData:s,loading:m,availableServers:o,availableGroups:h,onSave:f,onDelete:C})=>{const{t:d}=pe(),{showToast:a}=ke(),[T,S]=c.useState(!1),[w,j]=c.useState(s.name),[z,R]=c.useState(s.token),[P,M]=c.useState(s.enabled),[N,l]=c.useState(s.accessType||"all"),[p,y]=c.useState(s.allowedGroups||[]),[E,i]=c.useState(s.allowedServers||[]),[U,g]=c.useState(!1),[J,X]=c.useState(!1);c.useEffect(()=>{T||(j(s.name),R(s.token),M(s.enabled),l(s.accessType||"all"),y(s.allowedGroups||[]),i(s.allowedServers||[]))},[s,T]);const r=async()=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(s.token),a(d("common.copySuccess")||"Copied to clipboard","success");else{const b=document.createElement("textarea");b.value=s.token,b.style.position="fixed",b.style.left="-9999px",document.body.appendChild(b),b.focus(),b.select();try{document.execCommand("copy"),a(d("common.copySuccess")||"Copied to clipboard","success")}catch{a(d("common.copyFailed")||"Copy failed","error")}document.body.removeChild(b)}}catch(b){console.error("Failed to copy",b),a(d("common.copyFailed")||"Copy failed","error")}},Y=async()=>{if(N==="groups"&&p.length===0){a(d("settings.selectAtLeastOneGroup")||"Please select at least one group","error");return}if(N==="servers"&&E.length===0){a(d("settings.selectAtLeastOneServer")||"Please select at least one server","error");return}if(N==="custom"&&p.length===0&&E.length===0){a(d("settings.selectAtLeastOneGroupOrServer")||"Please select at least one group or server","error");return}g(!0);try{await f(s.id,{name:w,token:z,enabled:P,accessType:N,allowedGroups:p.join(", "),allowedServers:E.join(", ")}),S(!1)}finally{g(!1)}},te=async()=>{if(window.confirm(d("settings.deleteBearerKeyConfirm")||"Delete this key?")){X(!0);try{await C(s.id)}finally{X(!1)}}},B=N==="groups",H=N==="custom",Z=b=>{if(b.accessType==="all")return d("settings.bearerKeyAccessAll")||"All Resources";if(b.accessType==="groups")return`${d("settings.bearerKeyAccessGroups")||"Groups"}: ${b.allowedGroups}`;if(b.accessType==="servers")return`${d("settings.bearerKeyAccessServers")||"Servers"}: ${b.allowedServers}`;if(b.accessType==="custom"){const K=[];return b.allowedGroups&&b.allowedGroups.length>0&&K.push(`${d("settings.bearerKeyAccessGroups")||"Groups"}: ${b.allowedGroups}`),b.allowedServers&&b.allowedServers.length>0&&K.push(`${d("settings.bearerKeyAccessServers")||"Servers"}: ${b.allowedServers}`),`${d("settings.bearerKeyAccessCustom")||"Custom"}: ${K.join("; ")}`}return""};return T?e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"p-0 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 p-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-4 mb-4",children:[e.jsxs("div",{className:"md:col-span-3",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:d("settings.bearerKeyName")||"Name"}),e.jsx("input",{type:"text",className:"block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input transition-shadow duration-200",value:w,onChange:b=>j(b.target.value),disabled:m})]}),e.jsxs("div",{className:"md:col-span-9",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:d("settings.bearerKeyToken")||"Token"}),e.jsx("input",{type:"text",className:"block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input transition-shadow duration-200",value:z,onChange:b=>R(b.target.value),disabled:m})]})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-4",children:[e.jsxs("div",{className:"w-40",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:d("settings.bearerKeyEnabled")||"Status"}),e.jsxs("div",{className:"flex items-center h-[38px] px-3 bg-white dark:bg-gray-800 border border-gray-300 rounded-md",children:[e.jsx("span",{className:`text-sm mr-3 ${P?"text-green-600 font-medium":"text-gray-500"}`,children:P?"Active":"Inactive"}),e.jsx(A,{disabled:m,checked:P,onCheckedChange:b=>M(b)})]})]}),e.jsxs("div",{className:"w-48",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:d("settings.bearerKeyAccessType")||"Access scope"}),e.jsxs("select",{className:"block w-full py-2 px-3 border border-gray-300 bg-white dark:bg-gray-800 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-select transition-shadow duration-200",value:N,onChange:b=>l(b.target.value),disabled:m,children:[e.jsx("option",{value:"all",children:d("settings.bearerKeyAccessAll")||"All Resources"}),e.jsx("option",{value:"groups",children:d("settings.bearerKeyAccessGroups")||"Specific Groups"}),e.jsx("option",{value:"servers",children:d("settings.bearerKeyAccessServers")||"Specific Servers"}),e.jsx("option",{value:"custom",children:d("settings.bearerKeyAccessCustom")||"Custom (Groups & Servers)"})]})]}),!H&&e.jsxs("div",{className:"flex-1 min-w-[200px]",children:[e.jsx("label",{className:`block text-sm font-medium mb-1 ${N==="all"?"text-gray-400":"text-gray-700"}`,children:B?d("settings.bearerKeyAllowedGroups")||"Allowed groups":d("settings.bearerKeyAllowedServers")||"Allowed servers"}),e.jsx($,{options:B?h:o,selected:B?p:E,onChange:B?y:i,placeholder:B?d("settings.selectGroups")||"Select groups...":d("settings.selectServers")||"Select servers...",disabled:m||N==="all"})]}),H&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1 min-w-[200px]",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:d("settings.bearerKeyAllowedGroups")||"Allowed groups"}),e.jsx($,{options:h,selected:p,onChange:y,placeholder:d("settings.selectGroups")||"Select groups...",disabled:m})]}),e.jsxs("div",{className:"flex-1 min-w-[200px]",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:d("settings.bearerKeyAllowedServers")||"Allowed servers"}),e.jsx($,{options:o,selected:E,onChange:i,placeholder:d("settings.selectServers")||"Select servers...",disabled:m})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>S(!1),className:"px-4 py-2 bg-white dark:bg-gray-800 border border-gray-300 text-gray-700 rounded-md text-sm font-medium hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 h-[38px]",children:d("common.cancel")||"Cancel"}),e.jsx("button",{type:"button",onClick:Y,disabled:m||U,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50 btn-primary h-[38px]",children:U?d("common.saving")||"Saving...":d("common.save")||"Save"})]})]})]})})}):e.jsxs("tr",{className:"hover:bg-gray-50 dark:bg-gray-800 dark:hover:bg-gray-700",children:[e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900",children:s.name}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 font-mono",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:s.token.length>12?`${s.token.substring(0,8)}...${s.token.substring(s.token.length-4)}`:s.token}),e.jsx("button",{onClick:r,className:"text-gray-400 hover:text-gray-600 transition-colors",title:d("common.copy")||"Copy",children:e.jsx(Te,{className:"h-3.5 w-3.5"})})]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:e.jsx("span",{className:`px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${s.enabled?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"}`,children:s.enabled?d("common.active")||"Active":d("common.inactive")||"Inactive"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:Z(s)}),e.jsxs("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:[e.jsx("button",{onClick:()=>S(!0),className:"text-blue-600 hover:text-blue-900 mr-4 inline-flex items-center",title:d("common.edit")||"Edit",children:e.jsx(ts,{className:"h-4 w-4"})}),e.jsx("button",{onClick:te,disabled:J,className:"text-red-600 hover:text-red-900 inline-flex items-center",title:d("common.delete")||"Delete",children:e.jsx(as,{className:"h-4 w-4"})})]})]})};function ls(s){const m=s.toLowerCase(),o=[["text-embedding-3-small",8191],["text-embedding-3-large",8191],["text-embedding-ada-002",8191],["gemini-embedding-001",2048],["bge-m3",8192]];for(const[h,f]of o)if(m.includes(h))return f;return m.includes("bge"),512}function Ce(s,m){const o=s.trim(),h=o?parseInt(o,10):NaN,f=o&&!isNaN(h)?h:null;return f!==(m??null)?f:void 0}function Se(s,m){const o=s.trim(),h=o?parseInt(o,10):NaN,f=o&&!isNaN(h)&&h>=0?h:null;return f!==(m??null)?f:void 0}const hs=()=>{const{t:s}=pe(),m=Ye(),{showToast:o}=ke(),{allServers:h}=We(),{groups:f}=ns(),[C,d]=c.useState({pythonIndexUrl:"",npmRegistry:"",baseUrl:"http://localhost:3000"}),[a,T]=c.useState({dbUrl:"",basePacingDelayMs:"",embeddingProvider:"openai",embeddingEncodingFormat:"auto",openaiApiBaseUrl:"",openaiApiKey:"",openaiApiEmbeddingModel:"",azureOpenaiEndpoint:"",azureOpenaiApiKey:"",azureOpenaiApiVersion:"2024-02-15-preview",azureOpenaiEmbeddingDeployment:"",azureOpenaiEmbeddingModel:"",embeddingMaxTokens:""}),[S,w]=c.useState({apiKey:"",referer:"https://www.mcphub.app",title:"MCPHub",baseUrl:"https://api.mcprouter.to/v1"}),[j,z]=c.useState({accessTokenLifetime:"3600",refreshTokenLifetime:"1209600",authorizationCodeLifetime:"300",allowedScopes:"read, write",dynamicRegistrationAllowedGrantTypes:"authorization_code, refresh_token"}),[R,P]=c.useState("-"),[M,N]=c.useState(!1),{routingConfig:l,tempRoutingConfig:p,setTempRoutingConfig:y,installConfig:E,smartRoutingConfig:i,mcpRouterConfig:U,oauthServerConfig:g,nameSeparator:J,enableSessionRebuild:X,loading:r,bearerKeys:Y,updateRoutingConfig:te,updateInstallConfig:B,updateSmartRoutingConfig:H,updateSmartRoutingConfigBatch:Z,updateMCPRouterConfig:b,updateOAuthServerConfig:K,updateNameSeparator:Ee,updateSessionRebuild:Oe,exportMCPSettings:Pe,createBearerKey:ze,updateBearerKey:Re,deleteBearerKey:Me,refreshBearerKeys:W}=rs();c.useEffect(()=>{E&&d(E)},[E]),c.useEffect(()=>{i&&T({dbUrl:i.dbUrl||"",basePacingDelayMs:i.basePacingDelayMs!=null?String(i.basePacingDelayMs):"",embeddingProvider:i.embeddingProvider==="azure_openai"?"azure_openai":"openai",embeddingEncodingFormat:i.embeddingEncodingFormat==="base64"?"base64":i.embeddingEncodingFormat==="float"?"float":"auto",openaiApiBaseUrl:i.openaiApiBaseUrl||"",openaiApiKey:i.openaiApiKey||"",openaiApiEmbeddingModel:i.openaiApiEmbeddingModel||"",azureOpenaiEndpoint:i.azureOpenaiEndpoint||"",azureOpenaiApiKey:i.azureOpenaiApiKey||"",azureOpenaiApiVersion:i.azureOpenaiApiVersion||"2024-02-15-preview",azureOpenaiEmbeddingDeployment:i.azureOpenaiEmbeddingDeployment||"",azureOpenaiEmbeddingModel:i.azureOpenaiEmbeddingModel||"",embeddingMaxTokens:i.embeddingMaxTokens!=null?String(i.embeddingMaxTokens):""})},[i]),c.useEffect(()=>{U&&w({apiKey:U.apiKey||"",referer:U.referer||"https://www.mcphub.app",title:U.title||"MCPHub",baseUrl:U.baseUrl||"https://api.mcprouter.to/v1"})},[U]),c.useEffect(()=>{var t,n;g&&z({accessTokenLifetime:g.accessTokenLifetime!==void 0?String(g.accessTokenLifetime):"",refreshTokenLifetime:g.refreshTokenLifetime!==void 0?String(g.refreshTokenLifetime):"",authorizationCodeLifetime:g.authorizationCodeLifetime!==void 0?String(g.authorizationCodeLifetime):"",allowedScopes:g.allowedScopes&&g.allowedScopes.length>0?g.allowedScopes.join(", "):"",dynamicRegistrationAllowedGrantTypes:(n=(t=g.dynamicRegistration)==null?void 0:t.allowedGrantTypes)!=null&&n.length?g.dynamicRegistration.allowedGrantTypes.join(", "):""})},[g]),c.useEffect(()=>{P(J)},[J]),c.useEffect(()=>{W()},[]);const[v,Ke]=c.useState({routingConfig:!1,installConfig:!1,smartRoutingConfig:!1,oauthServerConfig:!1,mcpRouterConfig:!1,nameSeparator:!1,password:!1,exportConfig:!1,bearerKeys:!1}),D=t=>{Ke(n=>({...n,[t]:!n[t]}))},F=async(t,n)=>{await te(t,n)},ge=(t,n)=>{y(x=>({...x,[t]:n}))},ae=(t,n)=>{d({...C,[t]:n})},re=async t=>{await B(t,C[t])},O=(t,n)=>{T({...a,[t]:n})},be=(t,n)=>{w({...S,[t]:n})},xe=async t=>{await b(t,S[t])},ne=(t,n)=>{z(x=>({...x,[t]:n}))},he=(t,n)=>{z(x=>({...x,[t]:n}))},ie=async t=>{const n=j[t];if(!n||n.trim()===""){o(s("settings.invalidNumberInput")||"Please enter a valid number","error");return}const x=Number(n);if(Number.isNaN(x)||x<0){o(s("settings.invalidNumberInput")||"Please enter a valid number","error");return}await K(t,x)},Ge=async()=>{const t=j.allowedScopes.split(",").map(n=>n.trim()).filter(n=>n.length>0);await K("allowedScopes",t)},Ue=async()=>{const t=j.dynamicRegistrationAllowedGrantTypes.split(",").map(n=>n.trim()).filter(n=>n.length>0);await K("dynamicRegistration",{...g.dynamicRegistration,allowedGrantTypes:t})},oe=async(t,n)=>{await K(t,n)},ye=async t=>{await K("dynamicRegistration",{...g.dynamicRegistration,...t})},De=async()=>{await Ee(R)},Ie=async t=>{if(t){const n=a.dbUrl||i.dbUrl,x=[];if(n||x.push(s("settings.dbUrl")||"Database URL"),a.embeddingProvider==="azure_openai"){const ce=a.azureOpenaiEndpoint||i.azureOpenaiEndpoint,me=a.azureOpenaiApiKey||i.azureOpenaiApiKey,ue=a.azureOpenaiApiVersion||i.azureOpenaiApiVersion,Xe=a.azureOpenaiEmbeddingDeployment||i.azureOpenaiEmbeddingDeployment;(!ce||!me||!ue||!Xe)&&x.push(s("settings.azureOpenaiEndpoint")||"Azure OpenAI Endpoint",s("settings.azureOpenaiApiKey")||"Azure OpenAI API Key",s("settings.azureOpenaiApiVersion")||"Azure OpenAI API Version",s("settings.azureOpenaiEmbeddingDeployment")||"Azure Embedding Deployment")}else{const ce=(typeof a.openaiApiKey=="string"?a.openaiApiKey:i.openaiApiKey||"").trim(),me=(typeof a.openaiApiBaseUrl=="string"?a.openaiApiBaseUrl:i.openaiApiBaseUrl||"").trim(),ue=(typeof a.openaiApiEmbeddingModel=="string"?a.openaiApiEmbeddingModel:i.openaiApiEmbeddingModel||"").trim();ce||x.push(s("settings.openaiApiKey")||"OpenAI API Key"),me||x.push(s("settings.openaiApiBaseUrl")||"OpenAI API Base URL"),ue||x.push(s("settings.openaiApiEmbeddingModel")||"OpenAI Embedding Model")}if(x.length>0){o(s("settings.smartRoutingValidationError",{fields:x.join(", ")}));return}const k={enabled:t};a.dbUrl!==i.dbUrl&&(k.dbUrl=a.dbUrl);const je=Se(a.basePacingDelayMs,i.basePacingDelayMs);je!==void 0&&(k.basePacingDelayMs=je),a.embeddingProvider!==i.embeddingProvider&&(k.embeddingProvider=a.embeddingProvider),a.embeddingEncodingFormat!==i.embeddingEncodingFormat&&(k.embeddingEncodingFormat=a.embeddingEncodingFormat),a.openaiApiBaseUrl!==i.openaiApiBaseUrl&&(k.openaiApiBaseUrl=a.openaiApiBaseUrl),a.openaiApiKey!==i.openaiApiKey&&(k.openaiApiKey=a.openaiApiKey),a.openaiApiEmbeddingModel!==i.openaiApiEmbeddingModel&&(k.openaiApiEmbeddingModel=a.openaiApiEmbeddingModel),a.azureOpenaiEndpoint!==i.azureOpenaiEndpoint&&(k.azureOpenaiEndpoint=a.azureOpenaiEndpoint),a.azureOpenaiApiKey!==i.azureOpenaiApiKey&&(k.azureOpenaiApiKey=a.azureOpenaiApiKey),a.azureOpenaiApiVersion!==i.azureOpenaiApiVersion&&(k.azureOpenaiApiVersion=a.azureOpenaiApiVersion),a.azureOpenaiEmbeddingDeployment!==i.azureOpenaiEmbeddingDeployment&&(k.azureOpenaiEmbeddingDeployment=a.azureOpenaiEmbeddingDeployment),a.azureOpenaiEmbeddingModel!==i.azureOpenaiEmbeddingModel&&(k.azureOpenaiEmbeddingModel=a.azureOpenaiEmbeddingModel);const Ne=Ce(a.embeddingMaxTokens,i.embeddingMaxTokens);Ne!==void 0&&(k.embeddingMaxTokens=Ne),await Z(k)}else await H("enabled",t)},Le=async()=>{const t={};a.dbUrl!==i.dbUrl&&(t.dbUrl=a.dbUrl);const n=Se(a.basePacingDelayMs,i.basePacingDelayMs);n!==void 0&&(t.basePacingDelayMs=n),a.embeddingProvider!==i.embeddingProvider&&(t.embeddingProvider=a.embeddingProvider),a.embeddingEncodingFormat!==i.embeddingEncodingFormat&&(t.embeddingEncodingFormat=a.embeddingEncodingFormat),a.openaiApiBaseUrl!==i.openaiApiBaseUrl&&(t.openaiApiBaseUrl=a.openaiApiBaseUrl),a.openaiApiKey!==i.openaiApiKey&&(t.openaiApiKey=a.openaiApiKey),a.openaiApiEmbeddingModel!==i.openaiApiEmbeddingModel&&(t.openaiApiEmbeddingModel=a.openaiApiEmbeddingModel),a.azureOpenaiEndpoint!==i.azureOpenaiEndpoint&&(t.azureOpenaiEndpoint=a.azureOpenaiEndpoint),a.azureOpenaiApiKey!==i.azureOpenaiApiKey&&(t.azureOpenaiApiKey=a.azureOpenaiApiKey),a.azureOpenaiApiVersion!==i.azureOpenaiApiVersion&&(t.azureOpenaiApiVersion=a.azureOpenaiApiVersion),a.azureOpenaiEmbeddingDeployment!==i.azureOpenaiEmbeddingDeployment&&(t.azureOpenaiEmbeddingDeployment=a.azureOpenaiEmbeddingDeployment),a.azureOpenaiEmbeddingModel!==i.azureOpenaiEmbeddingModel&&(t.azureOpenaiEmbeddingModel=a.azureOpenaiEmbeddingModel);const x=Ce(a.embeddingMaxTokens,i.embeddingMaxTokens);x!==void 0&&(t.embeddingMaxTokens=x),Object.keys(t).length>0?await Z(t):o(s("settings.noChanges")||"No changes to save","info")},Be=()=>{setTimeout(()=>{m("/")},2e3)},[fe,Q]=c.useState(!1),[G,Fe]=c.useState(""),[u,_]=c.useState({name:"",token:"",enabled:!0,accessType:"all",allowedGroups:"",allowedServers:""}),[V,ee]=c.useState([]),[q,se]=c.useState([]),de=h.map(t=>({value:t.name,label:t.name})),le=f.map(t=>({value:t.name,label:t.name}));c.useEffect(()=>{u.accessType!=="groups"&&u.accessType!=="custom"&&ee([]),u.accessType!=="servers"&&u.accessType!=="custom"&&se([])},[u.accessType]);const _e=async()=>{try{const t=await Pe();console.log("Fetched MCP settings:",t);const n=JSON.stringify(t.data,null,2);Fe(n)}catch(t){console.error("Error fetching MCP settings:",t),o(s("settings.exportError")||"Failed to fetch settings","error")}};c.useEffect(()=>{v.exportConfig&&!G&&_e()},[v.exportConfig]);const Ve=async()=>{if(G)try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(G),Q(!0),o(s("common.copySuccess")||"Copied to clipboard","success"),setTimeout(()=>Q(!1),2e3);else{const t=document.createElement("textarea");t.value=G,t.style.position="fixed",t.style.left="-9999px",document.body.appendChild(t),t.focus(),t.select();try{document.execCommand("copy"),Q(!0),o(s("common.copySuccess")||"Copied to clipboard","success"),setTimeout(()=>Q(!1),2e3)}catch(n){o(s("common.copyFailed")||"Copy failed","error"),console.error("Copy to clipboard failed:",n)}document.body.removeChild(t)}}catch(t){console.error("Error copying configuration:",t),o(s("common.copyFailed")||"Copy failed","error")}},qe=()=>{if(!G)return;const t=new Blob([G],{type:"application/json"}),n=URL.createObjectURL(t),x=document.createElement("a");x.href=n,x.download="mcp_settings.json",document.body.appendChild(x),x.click(),document.body.removeChild(x),URL.revokeObjectURL(n),o(s("settings.exportSuccess")||"Settings exported successfully","success")},ve=t=>{const n=t.split(",").map(x=>x.trim()).filter(x=>x.length>0);return n.length>0?n:void 0},$e=async()=>{if(!u.name||!u.token){o(s("settings.bearerKeyRequired")||"Name and token are required","error");return}if(u.accessType==="groups"&&V.length===0){o(s("settings.selectAtLeastOneGroup")||"Please select at least one group","error");return}if(u.accessType==="servers"&&q.length===0){o(s("settings.selectAtLeastOneServer")||"Please select at least one server","error");return}if(u.accessType==="custom"&&V.length===0&&q.length===0){o(s("settings.selectAtLeastOneGroupOrServer")||"Please select at least one group or server","error");return}await ze({name:u.name,token:u.token,enabled:u.enabled,accessType:u.accessType,allowedGroups:(u.accessType==="groups"||u.accessType==="custom")&&V.length>0?V:void 0,allowedServers:(u.accessType==="servers"||u.accessType==="custom")&&q.length>0?q:void 0}),_({name:"",token:"",enabled:!0,accessType:"all",allowedGroups:"",allowedServers:""}),ee([]),se([]),await W()},He=async(t,n)=>{await Re(t,{name:n.name,token:n.token,enabled:n.enabled,accessType:n.accessType,allowedGroups:ve(n.allowedGroups),allowedServers:ve(n.allowedServers)}),await W()},Je=async t=>{await Me(t),await W()};return e.jsxs("div",{className:"container mx-auto",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-8",children:s("pages.settings.title")}),e.jsx(I,{permissions:L.SETTINGS_ROUTE_CONFIG,children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg mb-6 page-card dashboard-card",children:[e.jsxs("div",{className:"flex justify-between items-center cursor-pointer transition-colors duration-200 hover:text-blue-600 py-4 px-6",onClick:()=>D("bearerKeys"),children:[e.jsx("h2",{className:"font-semibold text-gray-800",children:s("settings.bearerKeysSectionTitle")||"Bearer authentication keys"}),e.jsx("span",{className:"text-gray-500 transition-transform duration-200",children:v.bearerKeys?"▼":"►"})]}),v.bearerKeys&&e.jsxs("div",{className:"space-y-4 pb-4 px-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.enableBearerAuth")||"Enable Bearer Authentication"}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.enableBearerAuthDescription")||"Require bearer token authentication for MCP requests"})]}),e.jsx(A,{disabled:r,checked:l.enableBearerAuth,onCheckedChange:t=>F("enableBearerAuth",t)})]}),e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.bearerAuthHeaderName")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.bearerAuthHeaderNameDescription")})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"text",value:p.bearerAuthHeaderName,onChange:t=>ge("bearerAuthHeaderName",t.target.value),placeholder:s("settings.bearerAuthHeaderNamePlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input",disabled:r}),e.jsx("button",{onClick:()=>F("bearerAuthHeaderName",p.bearerAuthHeaderName),disabled:r,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50 btn-primary",children:s("common.save")})]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("p",{className:"text-sm text-gray-600",children:s("settings.bearerKeysSectionDescription")||"Manage multiple bearer authentication keys with different access scopes."}),!M&&e.jsxs("button",{type:"button",onClick:()=>N(!0),className:"flex items-center text-blue-600 hover:text-blue-800 font-medium transition-colors duration-200",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 mr-1",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"})}),s("settings.addBearerKey")||"Add bearer key"]})]}),Y.length===0?e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.noBearerKeys")||"No bearer keys configured yet."}):e.jsx("div",{className:"mt-2 overflow-x-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700 border border-gray-200 dark:border-gray-700 rounded-lg",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:s("settings.bearerKeyName")||"Name"}),e.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:s("settings.bearerKeyToken")||"Token"}),e.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:s("settings.bearerKeyEnabled")||"Status"}),e.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:s("settings.bearerKeyAccessType")||"Access Scope"}),e.jsx("th",{scope:"col",className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:s("common.actions")||"Actions"})]})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:Y.map(t=>e.jsx(ds,{keyData:t,loading:r,availableServers:de,availableGroups:le,onSave:He,onDelete:Je},t.id))})]})}),M&&e.jsx("div",{className:"mt-6 border-t border-gray-200 dark:border-gray-700 pt-6",children:e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-lg p-5 border border-gray-200 dark:border-gray-700",children:[e.jsxs("h3",{className:"font-medium text-gray-900 mb-4 flex items-center gap-2",children:[e.jsx("span",{className:"bg-blue-100 text-blue-600 p-1 rounded",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",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"})})}),s("settings.addBearerKey")||"Add bearer key"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-4 mb-4",children:[e.jsxs("div",{className:"md:col-span-3",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("settings.bearerKeyName")||"Name"}),e.jsx("input",{type:"text",className:"block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input transition-shadow duration-200",placeholder:"e.g. My API Key",value:u.name,onChange:t=>_(n=>({...n,name:t.target.value})),disabled:r})]}),e.jsxs("div",{className:"md:col-span-9",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("settings.bearerKeyToken")||"Token"}),e.jsxs("div",{className:"flex rounded-md shadow-sm",children:[e.jsx("input",{type:"text",className:"flex-1 block w-full py-2 px-3 border border-gray-300 rounded-l-md rounded-r-none border-r-0 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input transition-shadow duration-200",placeholder:"sk-...",value:u.token,onChange:t=>_(n=>({...n,token:t.target.value})),disabled:r}),e.jsx("button",{type:"button",onClick:()=>_(t=>({...t,token:os()})),disabled:r,className:"relative -ml-[5px] inline-flex items-center px-4 py-2 border border-gray-300 bg-gray-100 dark:bg-gray-800 text-gray-700 text-sm font-medium rounded-r-md rounded-l-none hover:bg-gray-200 focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500 transition-colors duration-200 z-10",children:s("settings.generate")||"Generate"})]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-4 mb-2",children:[e.jsxs("div",{className:"w-40",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("settings.bearerKeyEnabled")||"Status"}),e.jsxs("div",{className:"flex items-center h-[38px] px-3 bg-white dark:bg-gray-800 border border-gray-300 rounded-md",children:[e.jsx("span",{className:`text-sm mr-3 ${u.enabled?"text-green-600 font-medium":"text-gray-500"}`,children:u.enabled?"Active":"Inactive"}),e.jsx(A,{disabled:r,checked:u.enabled,onCheckedChange:t=>_(n=>({...n,enabled:t}))})]})]}),e.jsxs("div",{className:"w-48",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("settings.bearerKeyAccessType")||"Access scope"}),e.jsxs("select",{className:"block w-full py-2 px-3 border border-gray-300 bg-white dark:bg-gray-800 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-select transition-shadow duration-200",value:u.accessType,onChange:t=>_(n=>({...n,accessType:t.target.value})),disabled:r,children:[e.jsx("option",{value:"all",children:s("settings.bearerKeyAccessAll")||"All Resources"}),e.jsx("option",{value:"groups",children:s("settings.bearerKeyAccessGroups")||"Specific Groups"}),e.jsx("option",{value:"servers",children:s("settings.bearerKeyAccessServers")||"Specific Servers"}),e.jsx("option",{value:"custom",children:s("settings.bearerKeyAccessCustom")||"Custom (Groups & Servers)"})]})]}),u.accessType!=="custom"&&e.jsxs("div",{className:"flex-1 min-w-[200px]",children:[e.jsx("label",{className:`block text-sm font-medium mb-1 ${u.accessType==="all"?"text-gray-400":"text-gray-700"}`,children:u.accessType==="groups"?s("settings.bearerKeyAllowedGroups")||"Allowed groups":s("settings.bearerKeyAllowedServers")||"Allowed servers"}),e.jsx($,{options:u.accessType==="groups"?le:de,selected:u.accessType==="groups"?V:q,onChange:u.accessType==="groups"?ee:se,placeholder:u.accessType==="groups"?s("settings.selectGroups")||"Select groups...":s("settings.selectServers")||"Select servers...",disabled:r||u.accessType==="all"})]}),u.accessType==="custom"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1 min-w-[200px]",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("settings.bearerKeyAllowedGroups")||"Allowed groups"}),e.jsx($,{options:le,selected:V,onChange:ee,placeholder:s("settings.selectGroups")||"Select groups...",disabled:r})]}),e.jsxs("div",{className:"flex-1 min-w-[200px]",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("settings.bearerKeyAllowedServers")||"Allowed servers"}),e.jsx($,{options:de,selected:q,onChange:se,placeholder:s("settings.selectServers")||"Select servers...",disabled:r})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>N(!1),className:"px-4 py-2 bg-white dark:bg-gray-800 border border-gray-300 text-gray-700 rounded-md text-sm font-medium hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 h-[38px]",children:s("common.cancel")||"Cancel"}),e.jsx("button",{type:"button",onClick:$e,disabled:r,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50 btn-primary h-[38px]",children:s("settings.addBearerKeyButton")||"Create Key"})]})]})]})})]})]})}),e.jsx(I,{permissions:L.SETTINGS_SMART_ROUTING,children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg mb-6 page-card dashboard-card",children:[e.jsxs("div",{className:"flex justify-between items-center cursor-pointer transition-colors duration-200 hover:text-blue-600 py-4 px-6",onClick:()=>D("smartRoutingConfig"),children:[e.jsx("h2",{className:"font-semibold text-gray-800",children:s("pages.settings.smartRouting")}),e.jsx("span",{className:"text-gray-500 transition-transform duration-200",children:v.smartRoutingConfig?"▼":"►"})]}),v.smartRoutingConfig&&e.jsxs("div",{className:"space-y-4 pb-4 px-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.enableSmartRouting")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.enableSmartRoutingDescription")})]}),e.jsx(A,{disabled:r,checked:i.enabled,onCheckedChange:t=>Ie(t)})]}),e.jsx("div",{className:"p-3 bg-blue-300 border border-blue-200 rounded-md",children:e.jsx("p",{className:"text-sm text-blue-800",children:s("settings.smartRoutingRequiredFields")})}),i.dbUrl!=="${DB_URL}"&&e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsx("div",{className:"mb-2",children:e.jsxs("h3",{className:"font-medium text-gray-700",children:[e.jsx("span",{className:"text-red-500 px-1",children:"*"}),s("settings.dbUrl")]})}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsx("input",{type:"text",value:a.dbUrl,onChange:t=>O("dbUrl",t.target.value),placeholder:s("settings.dbUrlPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm border-gray-300 form-input",disabled:r})})]}),e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsx("div",{className:"mb-2",children:e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.embeddingProvider")||"Embedding Provider"})}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("select",{className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 bg-white dark:bg-gray-800 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-select",value:a.embeddingProvider,onChange:t=>O("embeddingProvider",t.target.value),disabled:r,children:[e.jsx("option",{value:"openai",children:"OpenAI (or compatible)"}),e.jsx("option",{value:"azure_openai",children:"Azure OpenAI"})]})})]}),a.embeddingProvider==="openai"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsx("div",{className:"mb-2",children:e.jsxs("h3",{className:"font-medium text-gray-700",children:[e.jsx("span",{className:"text-red-500 px-1",children:"*"}),s("settings.openaiApiKey")]})}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsx("input",{type:"password",value:a.openaiApiKey,onChange:t=>O("openaiApiKey",t.target.value),placeholder:s("settings.openaiApiKeyPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm border-gray-300",disabled:r})})]}),e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsx("div",{className:"mb-2",children:e.jsxs("h3",{className:"font-medium text-gray-700",children:[e.jsx("span",{className:"text-red-500 px-1",children:"*"}),s("settings.openaiApiBaseUrl")]})}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsx("input",{type:"text",value:a.openaiApiBaseUrl,onChange:t=>O("openaiApiBaseUrl",t.target.value),placeholder:s("settings.openaiApiBaseUrlPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input",disabled:r,required:!0})})]}),e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsx("div",{className:"mb-2",children:e.jsxs("h3",{className:"font-medium text-gray-700",children:[e.jsx("span",{className:"text-red-500 px-1",children:"*"}),s("settings.openaiApiEmbeddingModel")]})}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsx("input",{type:"text",value:a.openaiApiEmbeddingModel,onChange:t=>O("openaiApiEmbeddingModel",t.target.value),placeholder:s("settings.openaiApiEmbeddingModelPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input",disabled:r,required:!0})})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsx("div",{className:"mb-2",children:e.jsxs("h3",{className:"font-medium text-gray-700",children:[e.jsx("span",{className:"text-red-500 px-1",children:"*"}),s("settings.azureOpenaiEndpoint")||"Azure OpenAI Endpoint"]})}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsx("input",{type:"text",value:a.azureOpenaiEndpoint,onChange:t=>O("azureOpenaiEndpoint",t.target.value),placeholder:s("settings.azureOpenaiEndpointPlaceholder")||"https://YOUR_RESOURCE_NAME.openai.azure.com",className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input",disabled:r})})]}),e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsx("div",{className:"mb-2",children:e.jsxs("h3",{className:"font-medium text-gray-700",children:[e.jsx("span",{className:"text-red-500 px-1",children:"*"}),s("settings.azureOpenaiApiKey")||"Azure OpenAI API Key"]})}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsx("input",{type:"password",value:a.azureOpenaiApiKey,onChange:t=>O("azureOpenaiApiKey",t.target.value),placeholder:s("settings.azureOpenaiApiKeyPlaceholder")||"***",className:"flex-1 mt-1 block w-full py-2 px-3 border rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm border-gray-300",disabled:r})})]}),e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsx("div",{className:"mb-2",children:e.jsxs("h3",{className:"font-medium text-gray-700",children:[e.jsx("span",{className:"text-red-500 px-1",children:"*"}),s("settings.azureOpenaiApiVersion")||"Azure OpenAI API Version"]})}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsx("input",{type:"text",value:a.azureOpenaiApiVersion,onChange:t=>O("azureOpenaiApiVersion",t.target.value),placeholder:s("settings.azureOpenaiApiVersionPlaceholder")||"2024-02-15-preview",className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input",disabled:r})})]}),e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsx("div",{className:"mb-2",children:e.jsxs("h3",{className:"font-medium text-gray-700",children:[e.jsx("span",{className:"text-red-500 px-1",children:"*"}),s("settings.azureOpenaiEmbeddingDeployment")||"Azure Embedding Deployment"]})}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsx("input",{type:"text",value:a.azureOpenaiEmbeddingDeployment,onChange:t=>O("azureOpenaiEmbeddingDeployment",t.target.value),placeholder:s("settings.azureOpenaiEmbeddingDeploymentPlaceholder")||"your-embedding-deployment-name",className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input",disabled:r})})]}),e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{className:"mb-2",children:[e.jsxs("h3",{className:"font-medium text-gray-700",children:[e.jsx("span",{className:"text-red-500 px-1",children:"*"}),s("settings.azureOpenaiEmbeddingModel")||"Azure Embedding Model Name"]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:s("settings.azureOpenaiEmbeddingModelDescription")||"The actual OpenAI model name deployed in Azure (e.g. text-embedding-3-small). Used for accurate token counting."})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsx("input",{type:"text",value:a.azureOpenaiEmbeddingModel,onChange:t=>O("azureOpenaiEmbeddingModel",t.target.value),placeholder:s("settings.azureOpenaiEmbeddingModelPlaceholder")||"text-embedding-3-small",className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input",disabled:r,required:!0})})]})]}),e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.basePacingDelayMs")}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:s("settings.basePacingDelayMsDescription")})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsx("input",{type:"number",min:"0",step:"1000",value:a.basePacingDelayMs,onChange:t=>O("basePacingDelayMs",t.target.value),placeholder:s("settings.basePacingDelayMsPlaceholder")||"Empty = default 0 ms",className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input",disabled:r})}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:(()=>{const t=a.basePacingDelayMs.trim();return t?s(t==="0"?"settings.basePacingDelayMsZero":"settings.basePacingDelayMsOverride"):s("settings.basePacingDelayMsAuto",{value:0})})()})]}),e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.embeddingEncodingFormat")}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:s("settings.embeddingEncodingFormatDescription")})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("select",{value:a.embeddingEncodingFormat,onChange:t=>O("embeddingEncodingFormat",t.target.value),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-select",disabled:r,children:[e.jsx("option",{value:"auto",children:s("settings.embeddingEncodingFormatAuto")||"Auto"}),e.jsx("option",{value:"base64",children:"Base64"}),e.jsx("option",{value:"float",children:"Float"})]})})]}),e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.embeddingMaxTokens")}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:s("settings.embeddingMaxTokensDescription")})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsx("input",{type:"number",min:"1",value:a.embeddingMaxTokens,onChange:t=>O("embeddingMaxTokens",t.target.value),placeholder:s("settings.embeddingMaxTokensPlaceholder")||"Empty = auto by model",className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input",disabled:r})}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:(()=>{const t=(a.embeddingProvider==="azure_openai"?a.azureOpenaiEmbeddingModel||i.azureOpenaiEmbeddingModel:a.openaiApiEmbeddingModel||i.openaiApiEmbeddingModel)||"text-embedding-3-small";return a.embeddingMaxTokens.trim()?s("settings.embeddingMaxTokensOverride"):s("settings.embeddingMaxTokensAuto",{limit:ls(t),model:t})})()})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.progressiveDisclosure")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.progressiveDisclosureDescription")})]}),e.jsx(A,{disabled:r||!i.enabled,checked:i.progressiveDisclosure,onCheckedChange:t=>H("progressiveDisclosure",t)})]}),e.jsx("div",{className:"flex justify-end pt-2",children:e.jsx("button",{onClick:Le,disabled:r,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50 btn-primary",children:s("common.save")})})]})]})}),e.jsx(I,{permissions:L.SETTINGS_OAUTH_SERVER,children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg mb-6 dashboard-card",children:[e.jsxs("div",{className:"flex justify-between items-center cursor-pointer transition-colors duration-200 hover:text-blue-600 py-4 px-6",onClick:()=>D("oauthServerConfig"),children:[e.jsx("h2",{className:"font-semibold text-gray-800",children:s("pages.settings.oauthServer")}),e.jsx("span",{className:"text-gray-500",children:v.oauthServerConfig?"▼":"►"})]}),v.oauthServerConfig&&e.jsxs("div",{className:"space-y-4 pb-4 px-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.enableOauthServer")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.enableOauthServerDescription")})]}),e.jsx(A,{disabled:r,checked:g.enabled,onCheckedChange:t=>oe("enabled",t)})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.requireClientSecret")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.requireClientSecretDescription")})]}),e.jsx(A,{disabled:r||!g.enabled,checked:g.requireClientSecret,onCheckedChange:t=>oe("requireClientSecret",t)})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.requireState")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.requireStateDescription")})]}),e.jsx(A,{disabled:r||!g.enabled,checked:g.requireState,onCheckedChange:t=>oe("requireState",t)})]}),e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.accessTokenLifetime")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.accessTokenLifetimeDescription")})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"number",value:j.accessTokenLifetime,onChange:t=>ne("accessTokenLifetime",t.target.value),placeholder:s("settings.accessTokenLifetimePlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input",disabled:r}),e.jsx("button",{onClick:()=>ie("accessTokenLifetime"),disabled:r,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50 btn-primary",children:s("common.save")})]})]}),e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.refreshTokenLifetime")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.refreshTokenLifetimeDescription")})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"number",value:j.refreshTokenLifetime,onChange:t=>ne("refreshTokenLifetime",t.target.value),placeholder:s("settings.refreshTokenLifetimePlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input",disabled:r}),e.jsx("button",{onClick:()=>ie("refreshTokenLifetime"),disabled:r,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50 btn-primary",children:s("common.save")})]})]}),e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.authorizationCodeLifetime")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.authorizationCodeLifetimeDescription")})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"number",value:j.authorizationCodeLifetime,onChange:t=>ne("authorizationCodeLifetime",t.target.value),placeholder:s("settings.authorizationCodeLifetimePlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input",disabled:r}),e.jsx("button",{onClick:()=>ie("authorizationCodeLifetime"),disabled:r,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50 btn-primary",children:s("common.save")})]})]}),e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.allowedScopes")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.allowedScopesDescription")})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"text",value:j.allowedScopes,onChange:t=>he("allowedScopes",t.target.value),placeholder:s("settings.allowedScopesPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input",disabled:r}),e.jsx("button",{onClick:Ge,disabled:r,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50 btn-primary",children:s("common.save")})]})]}),e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.enableDynamicRegistration")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.dynamicRegistrationDescription")})]}),e.jsx(A,{disabled:r||!g.enabled,checked:g.dynamicRegistration.enabled,onCheckedChange:t=>ye({enabled:t})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.dynamicRegistrationAllowedGrantTypes")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.dynamicRegistrationAllowedGrantTypesDescription")})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"text",value:j.dynamicRegistrationAllowedGrantTypes,onChange:t=>he("dynamicRegistrationAllowedGrantTypes",t.target.value),placeholder:s("settings.dynamicRegistrationAllowedGrantTypesPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input",disabled:r||!g.enabled||!g.dynamicRegistration.enabled}),e.jsx("button",{onClick:Ue,disabled:r||!g.enabled||!g.dynamicRegistration.enabled,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50 btn-primary",children:s("common.save")})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.dynamicRegistrationAuth")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.dynamicRegistrationAuthDescription")})]}),e.jsx(A,{disabled:r||!g.enabled||!g.dynamicRegistration.enabled,checked:g.dynamicRegistration.requiresAuthentication,onCheckedChange:t=>ye({requiresAuthentication:t})})]})]})]})]})}),e.jsx(I,{permissions:L.SETTINGS_INSTALL_CONFIG,children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg mb-6 page-card dashboard-card",children:[e.jsxs("div",{className:"flex justify-between items-center cursor-pointer transition-colors duration-200 hover:text-blue-600 py-4 px-6",onClick:()=>D("mcpRouterConfig"),children:[e.jsx("h2",{className:"font-semibold text-gray-800",children:s("settings.mcpRouterConfig")}),e.jsx("span",{className:"text-gray-500 transition-transform duration-200",children:v.mcpRouterConfig?"▼":"►"})]}),v.mcpRouterConfig&&e.jsxs("div",{className:"space-y-4 pb-4 px-6",children:[e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.mcpRouterApiKey")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.mcpRouterApiKeyDescription")})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"password",value:S.apiKey,onChange:t=>be("apiKey",t.target.value),placeholder:s("settings.mcpRouterApiKeyPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm border-gray-300 form-input",disabled:r}),e.jsx("button",{onClick:()=>xe("apiKey"),disabled:r,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50 btn-primary",children:s("common.save")})]})]}),e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.mcpRouterBaseUrl")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.mcpRouterBaseUrlDescription")})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"text",value:S.baseUrl,onChange:t=>be("baseUrl",t.target.value),placeholder:s("settings.mcpRouterBaseUrlPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input",disabled:r}),e.jsx("button",{onClick:()=>xe("baseUrl"),disabled:r,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50 btn-primary",children:s("common.save")})]})]})]})]})}),e.jsx(I,{permissions:L.SETTINGS_SYSTEM_CONFIG,children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg mb-6 dashboard-card",children:[e.jsxs("div",{className:"flex justify-between items-center cursor-pointer transition-colors duration-200 hover:text-blue-600 py-4 px-6",onClick:()=>D("nameSeparator"),children:[e.jsx("h2",{className:"font-semibold text-gray-800",children:s("settings.systemSettings")}),e.jsx("span",{className:"text-gray-500",children:v.nameSeparator?"▼":"►"})]}),v.nameSeparator&&e.jsxs("div",{className:"space-y-4 pb-4 px-6",children:[e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.nameSeparatorLabel")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.nameSeparatorDescription")})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"text",value:R,onChange:t=>P(t.target.value),placeholder:"-",className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input",disabled:r,maxLength:5}),e.jsx("button",{onClick:De,disabled:r,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50 btn-primary",children:s("common.save")})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.enableSessionRebuild")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.enableSessionRebuildDescription")})]}),e.jsx(A,{disabled:r,checked:X,onCheckedChange:t=>Oe(t)})]})]})]})}),e.jsx(I,{permissions:L.SETTINGS_ROUTE_CONFIG,children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg mb-6 dashboard-card",children:[e.jsxs("div",{className:"flex justify-between items-center cursor-pointer transition-colors duration-200 hover:text-blue-600 py-4 px-6",onClick:()=>D("routingConfig"),children:[e.jsx("h2",{className:"font-semibold text-gray-800",children:s("pages.settings.routeConfig")}),e.jsx("span",{className:"text-gray-500",children:v.routingConfig?"▼":"►"})]}),v.routingConfig&&e.jsxs("div",{className:"space-y-4 pb-4 px-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.enableGlobalRoute")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.enableGlobalRouteDescription")})]}),e.jsx(A,{disabled:r,checked:l.enableGlobalRoute,onCheckedChange:t=>F("enableGlobalRoute",t)})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.enableGroupNameRoute")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.enableGroupNameRouteDescription")})]}),e.jsx(A,{disabled:r,checked:l.enableGroupNameRoute,onCheckedChange:t=>F("enableGroupNameRoute",t)})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.skipAuth")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.skipAuthDescription")})]}),e.jsx(A,{disabled:r,checked:l.skipAuth,onCheckedChange:t=>F("skipAuth",t)})]}),e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.jsonBodyLimit")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.jsonBodyLimitDescription")})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"text",value:p.jsonBodyLimit,onChange:t=>ge("jsonBodyLimit",t.target.value),placeholder:s("settings.jsonBodyLimitPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input",disabled:r}),e.jsx("button",{onClick:()=>F("jsonBodyLimit",p.jsonBodyLimit),disabled:r,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50 btn-primary",children:s("common.save")})]})]})]})]})}),e.jsx(I,{permissions:L.SETTINGS_INSTALL_CONFIG,children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg mb-6 dashboard-card",children:[e.jsxs("div",{className:"flex justify-between items-center cursor-pointer transition-colors duration-200 hover:text-blue-600 py-4 px-6",onClick:()=>D("installConfig"),children:[e.jsx("h2",{className:"font-semibold text-gray-800",children:s("settings.installConfig")}),e.jsx("span",{className:"text-gray-500",children:v.installConfig?"▼":"►"})]}),v.installConfig&&e.jsxs("div",{className:"space-y-4 pb-4 px-6",children:[e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.baseUrl")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.baseUrlDescription")})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"text",value:C.baseUrl,onChange:t=>ae("baseUrl",t.target.value),placeholder:s("settings.baseUrlPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input",disabled:r}),e.jsx("button",{onClick:()=>re("baseUrl"),disabled:r,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50 btn-primary",children:s("common.save")})]})]}),e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.pythonIndexUrl")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.pythonIndexUrlDescription")})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"text",value:C.pythonIndexUrl,onChange:t=>ae("pythonIndexUrl",t.target.value),placeholder:s("settings.pythonIndexUrlPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input",disabled:r}),e.jsx("button",{onClick:()=>re("pythonIndexUrl"),disabled:r,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50 btn-primary",children:s("common.save")})]})]}),e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.npmRegistry")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.npmRegistryDescription")})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"text",value:C.npmRegistry,onChange:t=>ae("npmRegistry",t.target.value),placeholder:s("settings.npmRegistryPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input",disabled:r}),e.jsx("button",{onClick:()=>re("npmRegistry"),disabled:r,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50 btn-primary",children:s("common.save")})]})]})]})]})}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg mb-6 dashboard-card","data-section":"password",children:[e.jsxs("div",{className:"flex justify-between items-center cursor-pointer transition-colors duration-200 hover:text-blue-600 py-4 px-6",onClick:()=>D("password"),role:"button",children:[e.jsx("h2",{className:"font-semibold text-gray-800",children:s("auth.changePassword")}),e.jsx("span",{className:"text-gray-500",children:v.password?"▼":"►"})]}),v.password&&e.jsx("div",{className:"max-w-lg pb-4 px-6",children:e.jsx(is,{onSuccess:Be})})]}),e.jsx(I,{permissions:L.SETTINGS_EXPORT_CONFIG,children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg mb-6 dashboard-card",children:[e.jsxs("div",{className:"flex justify-between items-center cursor-pointer transition-colors duration-200 hover:text-blue-600 py-4 px-6",onClick:()=>D("exportConfig"),children:[e.jsx("h2",{className:"font-semibold text-gray-800",children:s("settings.exportMcpSettings")}),e.jsx("span",{className:"text-gray-500",children:v.exportConfig?"▼":"►"})]}),v.exportConfig&&e.jsx("div",{className:"space-y-4 pb-4 px-6",children:e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"font-medium text-gray-700",children:s("settings.mcpSettingsJson")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("settings.mcpSettingsJsonDescription")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:Ve,disabled:!G,className:"flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50 btn-primary",children:[fe?e.jsx(Ae,{size:16}):e.jsx(Te,{size:16}),s(fe?"common.copied":"settings.copyToClipboard")]}),e.jsxs("button",{onClick:qe,disabled:!G,className:"flex items-center gap-2 px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-md text-sm font-medium disabled:opacity-50 btn-primary",children:[e.jsx(ss,{size:16}),s("settings.downloadJson")]})]}),G&&e.jsx("div",{className:"mt-3",children:e.jsx("pre",{className:"bg-gray-900 text-gray-100 p-4 rounded-md overflow-x-auto text-xs max-h-96",children:G})})]})]})})]})})]})};export{hs as default};
12
+ //# sourceMappingURL=SettingsPage-DxVigf7p.js.map