mapigate 0.5.160 → 0.5.162
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli/tools/definitions/cursor/definition.js +1 -1
- package/dist/core/router/loadBalancer.js +1 -1
- package/dist/providers/composite/combo/fallbackStrategy.js +1 -1
- package/dist/providers/runtime/antigravity/executor.js +1 -1
- package/dist/providers/runtime/antigravity/metadata.js +1 -1
- package/dist/providers/runtime/antigravity/provider.js +1 -1
- package/dist/providers/runtime/antigravity/routes.js +1 -1
- package/dist/providers/runtime/antigravity/types.js +1 -1
- package/dist/providers/runtime/cursor/cursorModels.js +1 -1
- package/dist/providers/runtime/cursor/cursorSession.js +1 -1
- package/dist/providers/runtime/gemini-cli/provider.js +1 -1
- package/dist/providers/runtime/kiro/executor.js +4 -4
- package/dist/providers/runtime/kiro/metadata.js +1 -1
- package/dist/providers/runtime/kiro/provider.js +1 -1
- package/dist/providers/runtime/kiro/quota.js +1 -1
- package/dist/server/proxy/executorHelpers.js +1 -1
- package/dist/server/proxy/singleModelExecutor.js +5 -5
- package/dist/server/routes/apiCliTools.js +1 -1
- package/dist/server/routes/apiModels.js +1 -1
- package/dist/shared/utils/dnsResolver.js +1 -1
- package/dist/storage/repositories/providerRepo.js +5 -5
- package/dist/web/assets/CliToolsTab-iJozQAQx.js +168 -0
- package/dist/web/assets/{CombosTab-Cs2KWP8i.js → CombosTab-DdsJ2ova.js} +1 -1
- package/dist/web/assets/{ConfirmModal-73IbJAih.js → ConfirmModal-Co5OXd_g.js} +1 -1
- package/dist/web/assets/{ConsoleLogTab-DswA4_eC.js → ConsoleLogTab-BTGaJpcD.js} +1 -1
- package/dist/web/assets/{EditAccountModal-tMfNcAXT.js → EditAccountModal-DLyP9VNQ.js} +1 -1
- package/dist/web/assets/{EndpointTab-CweuNkGD.js → EndpointTab-DbjjVT7s.js} +1 -1
- package/dist/web/assets/{MitmTab-BBl5YAE3.js → MitmTab-DMRg64by.js} +2 -2
- package/dist/web/assets/{ModelAutocompleteInput-AZuprXC_.js → ModelAutocompleteInput-D0L1aj3-.js} +1 -1
- package/dist/web/assets/{ProviderDetailPage-CQh2gHX6.js → ProviderDetailPage-CeOUazix.js} +3 -3
- package/dist/web/assets/{ProvidersTab-CcpCZwlv.js → ProvidersTab-Dd-prffr.js} +1 -1
- package/dist/web/assets/{QuotaTab-CaoBW7ru.js → QuotaTab-zPkj0Rwo.js} +1 -1
- package/dist/web/assets/{SettingsTab-15Sy7cCT.js → SettingsTab-DUlhyz1z.js} +1 -1
- package/dist/web/assets/{UsageTab-wcmWwuXa.js → UsageTab-Da7c7zwV.js} +1 -1
- package/dist/web/assets/{index-CYeNOWj5.js → index-CtfMJ11V.js} +2 -2
- package/dist/web/assets/{index-HnsyZg0I.css → index-DXsZmXJg.css} +1 -1
- package/dist/web/assets/metadataRegistry-CGDAkFU1.js +1 -0
- package/dist/web/assets/{providersData-Bf-DlZQW.js → providersData-HX0E7hDv.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/CliToolsTab-B_lNHS7I.js +0 -168
- package/dist/web/assets/metadataRegistry-BkOuhIJ2.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as ue,r as o,j as e}from"./vendor-BcOI2aZ9.js";import{P as xe}from"./index-CYeNOWj5.js";import{T as pe}from"./ToolIcon-Cp4gSgFt.js";import{S as me}from"./Select-BNRH8LIG.js";import{g as be}from"./metadataRegistry-BkOuhIJ2.js";const ae={sm:{box:"size-4 rounded-[4px]",icon:"size-2.5",label:"text-xs",description:"text-[11px]",gap:"gap-2"},md:{box:"size-5 rounded-[5px]",icon:"size-3.5",label:"text-sm",description:"text-xs",gap:"gap-2.5"},lg:{box:"size-6 rounded-[6px]",icon:"size-4",label:"text-base",description:"text-sm",gap:"gap-3"}},re={primary:{active:"bg-blue-600 border-blue-500 text-white shadow-sm shadow-blue-500/25",focusRing:"peer-focus-visible:ring-blue-500/50",hoverBorder:"group-hover:border-blue-500/50 hover:border-blue-500/50"},emerald:{active:"bg-emerald-600 border-emerald-500 text-white shadow-sm shadow-emerald-500/25",focusRing:"peer-focus-visible:ring-emerald-500/50",hoverBorder:"group-hover:border-emerald-500/50 hover:border-emerald-500/50"},cyan:{active:"bg-cyan-600 border-cyan-500 text-white shadow-sm shadow-cyan-500/25",focusRing:"peer-focus-visible:ring-cyan-500/50",hoverBorder:"group-hover:border-cyan-500/50 hover:border-cyan-500/50"}},he=ue.forwardRef(({checked:B,defaultChecked:a,indeterminate:n=!1,onChange:g,size:v="md",variant:C="primary",label:u,description:x,disabled:i=!1,className:S="",checkboxClassName:b="",wrapperClassName:E="",onClick:I,...D},p)=>{const h=o.useRef(null),y=B!==void 0,[f,j]=o.useState(!!a),m=y?!!B:f;o.useEffect(()=>{h.current&&(h.current.indeterminate=!!n)},[n]);const z=c=>{h.current=c,typeof p=="function"?p(c):p&&(p.current=c)},$=c=>{i||(y||j(c.target.checked),g==null||g(c.target.checked,c))},d=ae[v]||ae.md,N=re[C]||re.primary,R=m||n,k=!!x;return e.jsxs("label",{className:`group inline-flex select-none transition-opacity ${k?"items-start":"items-center"} ${i?"cursor-not-allowed opacity-50":"cursor-pointer"} ${d.gap} ${E||S}`,onClick:I,children:[e.jsxs("div",{className:`relative inline-flex items-center justify-center shrink-0 ${k?"mt-0.5":""}`,children:[e.jsx("input",{ref:z,type:"checkbox",checked:m,disabled:i,onChange:$,"aria-checked":n?"mixed":m,className:"sr-only peer",...D}),e.jsxs("div",{className:`flex items-center justify-center border transition-all duration-150 ease-out peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2 peer-focus-visible:ring-offset-[#0A0D14] ${d.box} ${R?N.active:`bg-[#0B0F17] border-[#1E293B] text-transparent ${i?"":"group-hover:border-slate-500 hover:border-slate-500"}`} ${N.focusRing} ${i?"":"active:scale-95"} ${b}`,children:[e.jsx("svg",{className:`transition-all duration-150 ease-out ${d.icon} ${m&&!n?"scale-100 opacity-100":"scale-50 opacity-0"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),e.jsx("svg",{className:`transition-all duration-150 ease-out absolute ${d.icon} ${n?"scale-100 opacity-100":"scale-50 opacity-0"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})]})]}),(u||x)&&e.jsxs("div",{className:"flex flex-col leading-tight min-w-0 justify-center",children:[u&&e.jsx("span",{className:`font-medium text-slate-200 transition-colors ${i?"":"group-hover:text-white"} ${d.label}`,children:u}),x&&e.jsx("span",{className:`text-slate-400 mt-0.5 ${d.description}`,children:x})]})]})});he.displayName="Checkbox";const Ne=({isOpen:B,account:a,onClose:n,onSave:g})=>{const[v,C]=o.useState(""),[u,x]=o.useState(""),[i,S]=o.useState(""),[b,E]=o.useState(!1),[I,D]=o.useState(!0),[p,h]=o.useState(!1),[y,f]=o.useState(null),[j,m]=o.useState(""),[z,$]=o.useState(""),[d,N]=o.useState(""),[R,k]=o.useState("2024-10-01-preview"),[c,F]=o.useState(""),[_,q]=o.useState(""),[H,M]=o.useState("sgp"),[O,K]=o.useState("profile"),[V,G]=o.useState(""),[L,X]=o.useState("us-east-1"),[Y,Z]=o.useState(""),[J,Q]=o.useState(""),[T,P]=o.useState(""),r=((a==null?void 0:a.providerId)||"").toLowerCase(),s=be((a==null?void 0:a.providerId)||""),ne=r==="opencode"||r==="oc"||!!(s!=null&&s.noAuth)||(s==null?void 0:s.requiresApiKey)===!1||(s==null?void 0:s.authType)==="none",w=r==="ollama-local"||r.includes("ollama"),U=!!(s!=null&&s.isLocal)||r==="lm-studio"||r==="jan"||r==="local-device",ee=ne||w||U||(s==null?void 0:s.requiresApiKey)===!1,te=r==="azure"||r.includes("azure"),se=r==="cloudflare-ai"||r==="cloudflare",le=r==="bedrock"||r.includes("bedrock"),W=r==="xiaomi-tokenplan",oe=r==="alicode"||r==="alibaba",A=W?[{id:"sgp",label:"Singapore (新加坡)"},{id:"cn",label:"China (中国大陆)"},{id:"ams",label:"Amsterdam (阿姆斯特丹)"}]:(s==null?void 0:s.regions)||[];if(o.useEffect(()=>{var t;if(a){C(a.name||""),x(a.tag||((t=a.providerSpecificData)==null?void 0:t.tag)||""),S(""),E(!1),D(!!a.isActive),f(null);const l=a.providerSpecificData||{};m(l.baseUrl||(w?"http://127.0.0.1:11434":r==="lm-studio"?"http://localhost:1234/v1":r==="jan"?"http://localhost:1337/v1":"http://localhost:8000/v1")),$(l.azureEndpoint||""),N(l.deployment||"gpt-4"),k(l.apiVersion||"2024-10-01-preview"),F(l.organization||""),q(l.accountId||""),M(l.region||(A.length>0?A[0].id:"sgp")),P(l.baseUrl||"");const de=!!l.accessKeyId;K(de?"static":"profile"),G(l.profile||""),X(l.region||"us-east-1"),Z(l.accessKeyId||""),Q(l.sessionToken||"")}},[a]),!a)return null;const ie=()=>{const t=a.providerSpecificData||{};let l={};return w?l.baseUrl=j.trim()||"http://127.0.0.1:11434":U?l.baseUrl=j.trim():te?l={azureEndpoint:z.trim(),deployment:d.trim(),apiVersion:R.trim(),organization:c.trim()||void 0}:se?l={accountId:_.trim()}:le?O==="profile"?l={profile:V.trim(),region:L.trim()||"us-east-1"}:l={accessKeyId:Y.trim(),region:L.trim()||"us-east-1",sessionToken:J.trim()||void 0}:(W||A.length>0)&&(l.region=H,oe&&(T.trim()?l.baseUrl=T.trim():t.baseUrl&&delete t.baseUrl)),Object.keys(l).length>0?{...t,...l}:Object.keys(t).length>0?t:void 0},ce=async t=>{if(t.preventDefault(),!v.trim()){f("Account name is required.");return}h(!0),f(null);try{const l=ie()||{};u.trim()?l.tag=u.trim().toLowerCase():delete l.tag,await g({name:v.trim(),apiKey:i.trim()?i.trim():void 0,isActive:I,providerSpecificData:Object.keys(l).length>0?l:void 0}),n()}catch(l){f(l.message||"Failed to save account changes.")}finally{h(!1)}};return e.jsx(xe,{isOpen:B,onClose:n,maxWidthClass:"max-w-lg",children:e.jsxs("form",{onSubmit:ce,className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(pe,{src:(s==null?void 0:s.image)||`/assets/providers/${a.providerId}/icon.png`,name:(s==null?void 0:s.name)||a.providerId,color:(s==null?void 0:s.color)||"#3B82F6",iconBg:s==null?void 0:s.iconBg,size:"sm"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-slate-100 flex items-center gap-1.5",children:"Edit Account"}),e.jsxs("div",{className:"text-[11px] text-slate-400 font-mono",children:[(s==null?void 0:s.name)||a.providerId.toUpperCase()," • ",a.id]})]})]}),e.jsx("button",{type:"button",onClick:n,className:"text-slate-400 hover:text-white transition-colors cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),y&&e.jsxs("div",{className:"p-3 bg-red-500/10 border border-red-500/20 text-red-400 text-xs rounded-xl flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"error"}),e.jsx("span",{children:y})]}),e.jsxs("div",{className:"space-y-3.5 text-xs",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-slate-300 font-medium mb-1",children:["Account Name / Label ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"text",value:v,onChange:t=>C(t.target.value),placeholder:"e.g. Work Account or user@example.com",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 px-3 py-2 rounded-xl focus:outline-none focus:border-blue-500 transition-colors"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("label",{className:"text-slate-300 font-medium flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px] text-blue-400",children:"label"}),"Group Tag"]}),e.jsx("span",{className:"text-slate-500 text-[11px]",children:"Optional • For grouping in Combos"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"text",value:u,onChange:t=>x(t.target.value.toLowerCase().replace(/[^a-z0-9_-]/g,"")),placeholder:"e.g. pro, plus, free, team",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 pl-3 pr-20 py-2 rounded-xl focus:outline-none focus:border-blue-500 transition-colors font-mono"}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1 pointer-events-none",children:["pro","plus","free"].map(t=>e.jsx("button",{type:"button",tabIndex:-1,onClick:l=>{l.preventDefault(),x(t)},className:`pointer-events-auto text-[10px] px-1.5 py-0.5 rounded font-mono transition-colors ${u===t?"bg-blue-600 text-white font-semibold":"bg-[#1E293B] text-slate-400 hover:text-slate-200"}`,children:t},t))})]})]})]}),ee&&e.jsxs("div",{className:"p-2.5 bg-emerald-500/10 border border-emerald-500/20 rounded-xl text-emerald-300 text-[11px] flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-emerald-400 text-[16px]",children:"verified"}),e.jsxs("span",{children:[(s==null?void 0:s.name)||a.providerId," does not require an API key by default. You can leave the key blank."]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"block text-slate-300 font-medium",children:ee?"API Key / Auth Token (Optional)":"Update API Key / Secret Token"}),e.jsx("span",{className:"text-slate-500 text-[11px]",children:"Leave blank to keep existing key"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:b?"text":"password",value:i,onChange:t=>S(t.target.value),placeholder:"Enter new API key or token to overwrite...",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 pl-3 pr-9 py-2 rounded-xl focus:outline-none focus:border-blue-500 transition-colors font-mono"}),e.jsx("button",{type:"button",onClick:()=>E(!b),tabIndex:-1,className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-500 hover:text-slate-300 transition-colors cursor-pointer",title:b?"Hide token":"Show token",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:b?"visibility_off":"visibility"})})]})]}),(w||U)&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-300 font-medium mb-1",children:"Local Host / Base URL"}),e.jsx("input",{type:"text",value:j,onChange:t=>m(t.target.value),placeholder:w?"http://127.0.0.1:11434":"http://localhost:1234/v1",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 px-3 py-2 rounded-xl focus:outline-none focus:border-blue-500 transition-colors font-mono"})]}),te&&e.jsxs("div",{className:"space-y-2.5 p-3 bg-[#0A0D14] border border-[#1E293B] rounded-xl",children:[e.jsxs("div",{className:"text-[11px] font-semibold text-slate-300 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-blue-400 text-[14px]",children:"cloud"}),"Azure OpenAI Deployment Parameters"]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"Endpoint URL"}),e.jsx("input",{type:"text",value:z,onChange:t=>$(t.target.value),placeholder:"https://my-resource.openai.azure.com",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"Deployment Name"}),e.jsx("input",{type:"text",value:d,onChange:t=>N(t.target.value),placeholder:"gpt-4",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"API Version"}),e.jsx("input",{type:"text",value:R,onChange:t=>k(t.target.value),placeholder:"2024-10-01-preview",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"Organization (Optional)"}),e.jsx("input",{type:"text",value:c,onChange:t=>F(t.target.value),placeholder:"org-...",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]})]}),se&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-300 font-medium mb-1",children:"Cloudflare Account ID"}),e.jsx("input",{type:"text",value:_,onChange:t=>q(t.target.value),placeholder:"Cloudflare account ID (32 chars)",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 px-3 py-2 rounded-xl focus:outline-none focus:border-blue-500 transition-colors font-mono"})]}),le&&e.jsxs("div",{className:"space-y-2.5 p-3 bg-[#0A0D14] border border-[#1E293B] rounded-xl",children:[e.jsxs("div",{className:"flex bg-[#141B2D] p-1 rounded-lg border border-[#1E293B] text-xs",children:[e.jsx("button",{type:"button",onClick:()=>K("profile"),className:`flex-1 py-1 rounded-md font-medium transition-colors cursor-pointer ${O==="profile"?"bg-blue-600 text-white shadow-xs":"text-slate-400 hover:text-white"}`,children:"AWS Profile"}),e.jsx("button",{type:"button",onClick:()=>K("static"),className:`flex-1 py-1 rounded-md font-medium transition-colors cursor-pointer ${O==="static"?"bg-blue-600 text-white shadow-xs":"text-slate-400 hover:text-white"}`,children:"Static IAM Keys"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"AWS Region"}),e.jsx("input",{type:"text",value:L,onChange:t=>X(t.target.value),placeholder:"us-east-1",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]}),O==="profile"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"AWS Profile Name"}),e.jsx("input",{type:"text",value:V,onChange:t=>G(t.target.value),placeholder:"default",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"Access Key ID"}),e.jsx("input",{type:"text",value:Y,onChange:t=>Z(t.target.value),placeholder:"AKIA...",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"Session Token (Optional)"}),e.jsx("input",{type:"password",value:J,onChange:t=>Q(t.target.value),placeholder:"Optional STS token...",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]})]})]}),(W||A.length>0)&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-300 font-medium mb-1",children:"Cluster Region"}),e.jsx(me,{value:H,onChange:t=>M(t),options:A.map(t=>({value:t.id,label:t.label.includes(t.id)?t.label:`${t.label} (${t.id})`})),className:"w-full",triggerClassName:"bg-[#0A0D14] font-mono text-xs py-2"})]}),oe&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"block text-slate-400 text-xs",children:["Dedicated Workspace Endpoint URL ",e.jsx("span",{className:"text-slate-500",children:"(Optional)"})]}),e.jsx("input",{type:"text",value:T,onChange:t=>P(t.target.value),placeholder:"e.g. https://ws-xxx.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono text-xs"}),e.jsx("p",{className:"text-[11px] text-slate-400",children:"Required if your API key was created inside an Alibaba Model Studio custom workspace."})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 bg-[#141B2D] border border-[#1E293B] rounded-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-slate-200",children:"Active Status"}),e.jsx("div",{className:"text-[11px] text-slate-400",children:"Inactive accounts are excluded from routing and quota polling."})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:I,onChange:t=>D(t.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-9 h-5 bg-slate-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-blue-600"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-4 border-t border-[#1E293B]",children:[e.jsx("button",{type:"button",onClick:n,disabled:p,className:"px-4 py-2 text-xs font-medium text-slate-400 hover:text-white bg-[#141B2D] border border-[#1E293B] rounded-xl transition-colors cursor-pointer",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:p,className:"px-4 py-2 text-xs font-medium text-white bg-blue-600 hover:bg-blue-500 rounded-xl transition-colors cursor-pointer flex items-center gap-1.5 disabled:opacity-50",children:p?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[15px] animate-spin",children:"progress_activity"}),"Saving..."]}):"Save Changes"})]})]})})};export{he as C,Ne as E};
|
|
1
|
+
import{R as ue,r as o,j as e}from"./vendor-BcOI2aZ9.js";import{P as xe}from"./index-CtfMJ11V.js";import{T as pe}from"./ToolIcon-Cp4gSgFt.js";import{S as me}from"./Select-BNRH8LIG.js";import{g as be}from"./metadataRegistry-CGDAkFU1.js";const ae={sm:{box:"size-4 rounded-[4px]",icon:"size-2.5",label:"text-xs",description:"text-[11px]",gap:"gap-2"},md:{box:"size-5 rounded-[5px]",icon:"size-3.5",label:"text-sm",description:"text-xs",gap:"gap-2.5"},lg:{box:"size-6 rounded-[6px]",icon:"size-4",label:"text-base",description:"text-sm",gap:"gap-3"}},re={primary:{active:"bg-blue-600 border-blue-500 text-white shadow-sm shadow-blue-500/25",focusRing:"peer-focus-visible:ring-blue-500/50",hoverBorder:"group-hover:border-blue-500/50 hover:border-blue-500/50"},emerald:{active:"bg-emerald-600 border-emerald-500 text-white shadow-sm shadow-emerald-500/25",focusRing:"peer-focus-visible:ring-emerald-500/50",hoverBorder:"group-hover:border-emerald-500/50 hover:border-emerald-500/50"},cyan:{active:"bg-cyan-600 border-cyan-500 text-white shadow-sm shadow-cyan-500/25",focusRing:"peer-focus-visible:ring-cyan-500/50",hoverBorder:"group-hover:border-cyan-500/50 hover:border-cyan-500/50"}},he=ue.forwardRef(({checked:B,defaultChecked:a,indeterminate:n=!1,onChange:g,size:v="md",variant:C="primary",label:u,description:x,disabled:i=!1,className:S="",checkboxClassName:b="",wrapperClassName:E="",onClick:I,...D},p)=>{const h=o.useRef(null),y=B!==void 0,[f,j]=o.useState(!!a),m=y?!!B:f;o.useEffect(()=>{h.current&&(h.current.indeterminate=!!n)},[n]);const z=c=>{h.current=c,typeof p=="function"?p(c):p&&(p.current=c)},$=c=>{i||(y||j(c.target.checked),g==null||g(c.target.checked,c))},d=ae[v]||ae.md,N=re[C]||re.primary,R=m||n,k=!!x;return e.jsxs("label",{className:`group inline-flex select-none transition-opacity ${k?"items-start":"items-center"} ${i?"cursor-not-allowed opacity-50":"cursor-pointer"} ${d.gap} ${E||S}`,onClick:I,children:[e.jsxs("div",{className:`relative inline-flex items-center justify-center shrink-0 ${k?"mt-0.5":""}`,children:[e.jsx("input",{ref:z,type:"checkbox",checked:m,disabled:i,onChange:$,"aria-checked":n?"mixed":m,className:"sr-only peer",...D}),e.jsxs("div",{className:`flex items-center justify-center border transition-all duration-150 ease-out peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2 peer-focus-visible:ring-offset-[#0A0D14] ${d.box} ${R?N.active:`bg-[#0B0F17] border-[#1E293B] text-transparent ${i?"":"group-hover:border-slate-500 hover:border-slate-500"}`} ${N.focusRing} ${i?"":"active:scale-95"} ${b}`,children:[e.jsx("svg",{className:`transition-all duration-150 ease-out ${d.icon} ${m&&!n?"scale-100 opacity-100":"scale-50 opacity-0"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),e.jsx("svg",{className:`transition-all duration-150 ease-out absolute ${d.icon} ${n?"scale-100 opacity-100":"scale-50 opacity-0"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})]})]}),(u||x)&&e.jsxs("div",{className:"flex flex-col leading-tight min-w-0 justify-center",children:[u&&e.jsx("span",{className:`font-medium text-slate-200 transition-colors ${i?"":"group-hover:text-white"} ${d.label}`,children:u}),x&&e.jsx("span",{className:`text-slate-400 mt-0.5 ${d.description}`,children:x})]})]})});he.displayName="Checkbox";const Ne=({isOpen:B,account:a,onClose:n,onSave:g})=>{const[v,C]=o.useState(""),[u,x]=o.useState(""),[i,S]=o.useState(""),[b,E]=o.useState(!1),[I,D]=o.useState(!0),[p,h]=o.useState(!1),[y,f]=o.useState(null),[j,m]=o.useState(""),[z,$]=o.useState(""),[d,N]=o.useState(""),[R,k]=o.useState("2024-10-01-preview"),[c,F]=o.useState(""),[_,q]=o.useState(""),[H,M]=o.useState("sgp"),[O,K]=o.useState("profile"),[V,G]=o.useState(""),[L,X]=o.useState("us-east-1"),[Y,Z]=o.useState(""),[J,Q]=o.useState(""),[T,P]=o.useState(""),r=((a==null?void 0:a.providerId)||"").toLowerCase(),s=be((a==null?void 0:a.providerId)||""),ne=r==="opencode"||r==="oc"||!!(s!=null&&s.noAuth)||(s==null?void 0:s.requiresApiKey)===!1||(s==null?void 0:s.authType)==="none",w=r==="ollama-local"||r.includes("ollama"),U=!!(s!=null&&s.isLocal)||r==="lm-studio"||r==="jan"||r==="local-device",ee=ne||w||U||(s==null?void 0:s.requiresApiKey)===!1,te=r==="azure"||r.includes("azure"),se=r==="cloudflare-ai"||r==="cloudflare",le=r==="bedrock"||r.includes("bedrock"),W=r==="xiaomi-tokenplan",oe=r==="alicode"||r==="alibaba",A=W?[{id:"sgp",label:"Singapore (新加坡)"},{id:"cn",label:"China (中国大陆)"},{id:"ams",label:"Amsterdam (阿姆斯特丹)"}]:(s==null?void 0:s.regions)||[];if(o.useEffect(()=>{var t;if(a){C(a.name||""),x(a.tag||((t=a.providerSpecificData)==null?void 0:t.tag)||""),S(""),E(!1),D(!!a.isActive),f(null);const l=a.providerSpecificData||{};m(l.baseUrl||(w?"http://127.0.0.1:11434":r==="lm-studio"?"http://localhost:1234/v1":r==="jan"?"http://localhost:1337/v1":"http://localhost:8000/v1")),$(l.azureEndpoint||""),N(l.deployment||"gpt-4"),k(l.apiVersion||"2024-10-01-preview"),F(l.organization||""),q(l.accountId||""),M(l.region||(A.length>0?A[0].id:"sgp")),P(l.baseUrl||"");const de=!!l.accessKeyId;K(de?"static":"profile"),G(l.profile||""),X(l.region||"us-east-1"),Z(l.accessKeyId||""),Q(l.sessionToken||"")}},[a]),!a)return null;const ie=()=>{const t=a.providerSpecificData||{};let l={};return w?l.baseUrl=j.trim()||"http://127.0.0.1:11434":U?l.baseUrl=j.trim():te?l={azureEndpoint:z.trim(),deployment:d.trim(),apiVersion:R.trim(),organization:c.trim()||void 0}:se?l={accountId:_.trim()}:le?O==="profile"?l={profile:V.trim(),region:L.trim()||"us-east-1"}:l={accessKeyId:Y.trim(),region:L.trim()||"us-east-1",sessionToken:J.trim()||void 0}:(W||A.length>0)&&(l.region=H,oe&&(T.trim()?l.baseUrl=T.trim():t.baseUrl&&delete t.baseUrl)),Object.keys(l).length>0?{...t,...l}:Object.keys(t).length>0?t:void 0},ce=async t=>{if(t.preventDefault(),!v.trim()){f("Account name is required.");return}h(!0),f(null);try{const l=ie()||{};u.trim()?l.tag=u.trim().toLowerCase():delete l.tag,await g({name:v.trim(),apiKey:i.trim()?i.trim():void 0,isActive:I,providerSpecificData:Object.keys(l).length>0?l:void 0}),n()}catch(l){f(l.message||"Failed to save account changes.")}finally{h(!1)}};return e.jsx(xe,{isOpen:B,onClose:n,maxWidthClass:"max-w-xl",children:e.jsxs("form",{onSubmit:ce,className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(pe,{src:(s==null?void 0:s.image)||`/assets/providers/${a.providerId}/icon.png`,name:(s==null?void 0:s.name)||a.providerId,color:(s==null?void 0:s.color)||"#3B82F6",iconBg:s==null?void 0:s.iconBg,size:"sm"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-slate-100 flex items-center gap-1.5",children:"Edit Account"}),e.jsxs("div",{className:"text-[11px] text-slate-400 font-mono",children:[(s==null?void 0:s.name)||a.providerId.toUpperCase()," • ",a.id]})]})]}),e.jsx("button",{type:"button",onClick:n,className:"text-slate-400 hover:text-white transition-colors cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),y&&e.jsxs("div",{className:"p-3 bg-red-500/10 border border-red-500/20 text-red-400 text-xs rounded-xl flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"error"}),e.jsx("span",{children:y})]}),e.jsxs("div",{className:"space-y-3.5 text-xs",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-slate-300 font-medium mb-1",children:["Account Name / Label ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"text",value:v,onChange:t=>C(t.target.value),placeholder:"e.g. Work Account or user@example.com",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 px-3 py-2 rounded-xl focus:outline-none focus:border-blue-500 transition-colors"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("label",{className:"text-slate-300 font-medium flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px] text-blue-400",children:"label"}),"Group Tag"]}),e.jsx("span",{className:"text-slate-500 text-[11px]",children:"Optional • For grouping in Combos"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"text",value:u,onChange:t=>x(t.target.value.toLowerCase().replace(/[^a-z0-9_-]/g,"")),placeholder:"e.g. pro, plus, free, team",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 pl-3 pr-20 py-2 rounded-xl focus:outline-none focus:border-blue-500 transition-colors font-mono"}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1 pointer-events-none",children:["pro","plus","free"].map(t=>e.jsx("button",{type:"button",tabIndex:-1,onClick:l=>{l.preventDefault(),x(t)},className:`pointer-events-auto text-[10px] px-1.5 py-0.5 rounded font-mono transition-colors ${u===t?"bg-blue-600 text-white font-semibold":"bg-[#1E293B] text-slate-400 hover:text-slate-200"}`,children:t},t))})]})]})]}),ee&&e.jsxs("div",{className:"p-2.5 bg-emerald-500/10 border border-emerald-500/20 rounded-xl text-emerald-300 text-[11px] flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-emerald-400 text-[16px]",children:"verified"}),e.jsxs("span",{children:[(s==null?void 0:s.name)||a.providerId," does not require an API key by default. You can leave the key blank."]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"block text-slate-300 font-medium",children:ee?"API Key / Auth Token (Optional)":"Update API Key / Secret Token"}),e.jsx("span",{className:"text-slate-500 text-[11px]",children:"Leave blank to keep existing key"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:b?"text":"password",value:i,onChange:t=>S(t.target.value),placeholder:"Enter new API key or token to overwrite...",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 pl-3 pr-9 py-2 rounded-xl focus:outline-none focus:border-blue-500 transition-colors font-mono"}),e.jsx("button",{type:"button",onClick:()=>E(!b),tabIndex:-1,className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-500 hover:text-slate-300 transition-colors cursor-pointer",title:b?"Hide token":"Show token",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:b?"visibility_off":"visibility"})})]})]}),(w||U)&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-300 font-medium mb-1",children:"Local Host / Base URL"}),e.jsx("input",{type:"text",value:j,onChange:t=>m(t.target.value),placeholder:w?"http://127.0.0.1:11434":"http://localhost:1234/v1",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 px-3 py-2 rounded-xl focus:outline-none focus:border-blue-500 transition-colors font-mono"})]}),te&&e.jsxs("div",{className:"space-y-2.5 p-3 bg-[#0A0D14] border border-[#1E293B] rounded-xl",children:[e.jsxs("div",{className:"text-[11px] font-semibold text-slate-300 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-blue-400 text-[14px]",children:"cloud"}),"Azure OpenAI Deployment Parameters"]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"Endpoint URL"}),e.jsx("input",{type:"text",value:z,onChange:t=>$(t.target.value),placeholder:"https://my-resource.openai.azure.com",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"Deployment Name"}),e.jsx("input",{type:"text",value:d,onChange:t=>N(t.target.value),placeholder:"gpt-4",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"API Version"}),e.jsx("input",{type:"text",value:R,onChange:t=>k(t.target.value),placeholder:"2024-10-01-preview",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"Organization (Optional)"}),e.jsx("input",{type:"text",value:c,onChange:t=>F(t.target.value),placeholder:"org-...",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]})]}),se&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-300 font-medium mb-1",children:"Cloudflare Account ID"}),e.jsx("input",{type:"text",value:_,onChange:t=>q(t.target.value),placeholder:"Cloudflare account ID (32 chars)",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 px-3 py-2 rounded-xl focus:outline-none focus:border-blue-500 transition-colors font-mono"})]}),le&&e.jsxs("div",{className:"space-y-2.5 p-3 bg-[#0A0D14] border border-[#1E293B] rounded-xl",children:[e.jsxs("div",{className:"flex bg-[#141B2D] p-1 rounded-lg border border-[#1E293B] text-xs",children:[e.jsx("button",{type:"button",onClick:()=>K("profile"),className:`flex-1 py-1 rounded-md font-medium transition-colors cursor-pointer ${O==="profile"?"bg-blue-600 text-white shadow-xs":"text-slate-400 hover:text-white"}`,children:"AWS Profile"}),e.jsx("button",{type:"button",onClick:()=>K("static"),className:`flex-1 py-1 rounded-md font-medium transition-colors cursor-pointer ${O==="static"?"bg-blue-600 text-white shadow-xs":"text-slate-400 hover:text-white"}`,children:"Static IAM Keys"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"AWS Region"}),e.jsx("input",{type:"text",value:L,onChange:t=>X(t.target.value),placeholder:"us-east-1",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]}),O==="profile"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"AWS Profile Name"}),e.jsx("input",{type:"text",value:V,onChange:t=>G(t.target.value),placeholder:"default",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"Access Key ID"}),e.jsx("input",{type:"text",value:Y,onChange:t=>Z(t.target.value),placeholder:"AKIA...",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"Session Token (Optional)"}),e.jsx("input",{type:"password",value:J,onChange:t=>Q(t.target.value),placeholder:"Optional STS token...",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]})]})]}),(W||A.length>0)&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-300 font-medium mb-1",children:"Cluster Region"}),e.jsx(me,{value:H,onChange:t=>M(t),options:A.map(t=>({value:t.id,label:t.label.includes(t.id)?t.label:`${t.label} (${t.id})`})),className:"w-full",triggerClassName:"bg-[#0A0D14] font-mono text-xs py-2"})]}),oe&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"block text-slate-400 text-xs",children:["Dedicated Workspace Endpoint URL ",e.jsx("span",{className:"text-slate-500",children:"(Optional)"})]}),e.jsx("input",{type:"text",value:T,onChange:t=>P(t.target.value),placeholder:"e.g. https://ws-xxx.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono text-xs"}),e.jsx("p",{className:"text-[11px] text-slate-400",children:"Required if your API key was created inside an Alibaba Model Studio custom workspace."})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 bg-[#141B2D] border border-[#1E293B] rounded-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-slate-200",children:"Active Status"}),e.jsx("div",{className:"text-[11px] text-slate-400",children:"Inactive accounts are excluded from routing and quota polling."})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:I,onChange:t=>D(t.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-9 h-5 bg-slate-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-blue-600"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-4 border-t border-[#1E293B]",children:[e.jsx("button",{type:"button",onClick:n,disabled:p,className:"px-4 py-2 text-xs font-medium text-slate-400 hover:text-white bg-[#141B2D] border border-[#1E293B] rounded-xl transition-colors cursor-pointer",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:p,className:"px-4 py-2 text-xs font-medium text-white bg-blue-600 hover:bg-blue-500 rounded-xl transition-colors cursor-pointer flex items-center gap-1.5 disabled:opacity-50",children:p?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[15px] animate-spin",children:"progress_activity"}),"Saving..."]}):"Save Changes"})]})]})})};export{he as C,Ne as E};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as l,j as e}from"./vendor-BcOI2aZ9.js";import{S as Ne}from"./Select-BNRH8LIG.js";import{C as we}from"./ConfirmModal-73IbJAih.js";import{u as ee,D as m,d as te,P as ve}from"./index-CYeNOWj5.js";import"./lucide-Cc35htxl.js";const u="10.*, 172.16-31.*, 192.168.*, 169.254.*, *.local",Ce={host:te,port:m,requireApiKey:!1,proxyUrl:"",customHeaders:{},allowedHosts:u},De=({onRestartClick:K})=>{const o=ee(t=>t.info),w=ee(t=>t.fetchSystemInfo),se=!!(o!=null&&o.isRestartRequired),[r,c]=l.useState(Ce),[ae,T]=l.useState(!0),[P,H]=l.useState(!1),[L,f]=l.useState(null),[R,I]=l.useState(null),[y,g]=l.useState([]),[v,j]=l.useState([]),[le,_]=l.useState(!0),[re,ne]=l.useState(new Set),[p,U]=l.useState(null),[oe,F]=l.useState(null),[q,h]=l.useState(!1),[G,O]=l.useState(""),[$,M]=l.useState(!1),[N,b]=l.useState(null),[x,C]=l.useState(null),[J,k]=l.useState(null),[A,V]=l.useState(!1),W=l.useCallback(async()=>{try{T(!0);const[t]=await Promise.all([fetch("/api/settings/endpoint"),w()]);if(t.ok){const s=await t.json();c({host:s.host||te,port:s.port||m,requireApiKey:!!s.requireApiKey,proxyUrl:s.proxyUrl||"",customHeaders:s.customHeaders||{},allowedHosts:s.allowedHosts||u});const a=Object.entries(s.customHeaders||{}).map(([i,n],d)=>({id:`header-${d}-${Date.now()}`,key:i,value:String(n)}));g(a)}}catch(t){console.error("Failed to load endpoint settings:",t)}finally{T(!1)}},[w]),z=l.useCallback(async()=>{try{_(!0);const t=await fetch("/api/settings/endpoint/keys");if(t.ok){const s=await t.json();Array.isArray(s)&&j(s)}}catch(t){console.error("Failed to load gateway API keys:",t)}finally{_(!1)}},[]);l.useEffect(()=>{W(),z()},[W,z]);const ie=async t=>{var a,i;t&&t.preventDefault(),H(!0),f(null),I(null);const s={};for(const n of y){const d=n.key.trim();d&&(s[d]=n.value.trim())}try{const n={host:r.host,port:Number(r.port)||m,requireApiKey:r.requireApiKey,proxyUrl:((a=r.proxyUrl)==null?void 0:a.trim())||"",customHeaders:s,allowedHosts:((i=r.allowedHosts)==null?void 0:i.trim())||u},d=await fetch("/api/settings/endpoint",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!d.ok){const je=await d.json();throw new Error(je.error||"Failed to update endpoint settings")}const ye=await d.json();c(ye);const D=await w(),ge=!!(D!=null&&D.isRestartRequired);f(ge?"Configuration saved! Server restart is required to rebind the network interface.":"Settings saved successfully!"),setTimeout(()=>f(null),5e3)}catch(n){I((n==null?void 0:n.message)||"Failed to save settings")}finally{H(!1)}},ce=async t=>{t.preventDefault();try{M(!0);const s=await fetch("/api/settings/endpoint/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:G.trim()||void 0})});if(s.ok){const a=await s.json();j(i=>[a,...i]),b(a),O("")}else{const a=await s.json();alert(a.error||"Failed to create API key")}}catch(s){console.error("Error creating key:",s)}finally{M(!1)}},de=async t=>{try{const s=await fetch(`/api/settings/endpoint/keys/${t.id}/toggle`,{method:"PATCH"});if(s.ok){const a=await s.json();j(i=>i.map(n=>n.id===t.id?a:n))}}catch(s){console.error("Error toggling API key:",s)}},xe=async()=>{if(x)try{(await fetch(`/api/settings/endpoint/keys/${x.id}`,{method:"DELETE"})).ok&&j(s=>s.filter(a=>a.id!==x.id))}catch(t){console.error("Error deleting API key:",t)}finally{C(null)}},pe=t=>{ne(s=>{const a=new Set(s);return a.has(t)?a.delete(t):a.add(t),a})},S=(t,s)=>{navigator.clipboard.writeText(t),U(s),setTimeout(()=>U(null),2e3)},me=(t,s)=>{navigator.clipboard.writeText(t),F(s),setTimeout(()=>F(null),2e3)},ue=()=>{g([...y,{id:`header-${Date.now()}`,key:"",value:""}])},X=(t,s,a)=>{g(i=>i.map(n=>n.id===t?{...n,[s]:a}:n))},he=t=>{g(s=>s.filter(a=>a.id!==t))},Y=r.host==="0.0.0.0"?"127.0.0.1":r.host||"127.0.0.1",be=(o==null?void 0:o.port)||(typeof window<"u"&&window.location.port&&window.location.port!=="5173"?Number(window.location.port):m),E=r.port||be,Q=`http://${Y}:${E}/v1`,B=`http://${Y}:${E}`,fe=async()=>{V(!0),k(null);try{const s=await(await fetch("/health")).json();k(JSON.stringify(s,null,2))}catch{k(JSON.stringify({error:"Failed to connect to gateway"},null,2))}finally{V(!1)}},Z=t=>{if(t.length<=10)return"••••••••";const s=t.slice(0,6),a=t.slice(-4);return`${s}••••••••${a}`};return e.jsxs("div",{className:"space-y-8 w-full px-2 sm:px-4 pb-16 animate-rt-fade-in",children:[e.jsxs("div",{className:"w-full p-6 rounded-2xl bg-[#0F1420]/80 border border-[#1E293B] space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px] text-blue-400",children:"api"}),"Local Gateway Endpoints"]}),e.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"Universal endpoints accepting OpenAI Chat Completions and Anthropic Messages protocols"})]}),e.jsxs("div",{className:"space-y-3.5 text-xs font-mono",children:[e.jsxs("div",{className:"bg-[#0A0D14] p-4 rounded-xl border border-[#1E293B] flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-500 block text-[10px] uppercase font-sans font-semibold",children:"OpenAI-Compatible Base URL (Cursor, Cline, OpenCode, Codex)"}),e.jsx("span",{className:"text-blue-400 font-bold text-sm",children:Q})]}),e.jsxs("button",{type:"button",onClick:()=>S(Q,"openai"),className:"px-3.5 py-1.5 rounded-xl bg-[#141B2D] border border-[#1E293B] hover:border-slate-600 text-xs font-semibold text-slate-300 hover:text-white flex items-center gap-1.5 transition-all cursor-pointer self-start sm:self-center font-sans",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:p==="openai"?"check":"content_copy"}),p==="openai"?"Copied":"Copy"]})]}),e.jsxs("div",{className:"bg-[#0A0D14] p-4 rounded-xl border border-[#1E293B] flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-500 block text-[10px] uppercase font-sans font-semibold",children:"Anthropic Base URL (Claude Code CLI: ANTHROPIC_BASE_URL)"}),e.jsx("span",{className:"text-cyan-400 font-bold text-sm",children:B})]}),e.jsxs("button",{type:"button",onClick:()=>S(B,"anthropic"),className:"px-3.5 py-1.5 rounded-xl bg-[#141B2D] border border-[#1E293B] hover:border-slate-600 text-xs font-semibold text-slate-300 hover:text-white flex items-center gap-1.5 transition-all cursor-pointer self-start sm:self-center font-sans",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:p==="anthropic"?"check":"content_copy"}),p==="anthropic"?"Copied":"Copy"]})]})]}),e.jsxs("div",{className:"pt-2 border-t border-[#1E293B] space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-bold text-slate-200 block font-sans",children:"Test Gateway Connectivity:"}),e.jsxs("button",{type:"button",onClick:fe,disabled:A,className:"px-4 py-2 rounded-xl text-xs font-semibold text-white bg-blue-600 hover:bg-blue-500 shadow-md shadow-blue-600/20 disabled:opacity-50 transition-all flex items-center gap-1.5 cursor-pointer font-sans",children:[e.jsx("span",{className:`material-symbols-outlined text-[15px] ${A?"animate-spin":""}`,children:A?"sync":"play_arrow"}),"Execute Test Ping"]})]}),e.jsxs("div",{className:"bg-[#0A0D14] p-3 rounded-xl border border-[#1E293B] text-xs font-mono text-slate-300 overflow-x-auto",children:["curl ",B,"/health"]}),J&&e.jsx("pre",{className:"bg-[#080B10] p-4 rounded-xl border border-blue-500/30 text-emerald-400 text-xs font-mono overflow-x-auto animate-rt-scale-in",children:J})]})]}),e.jsxs("div",{className:"w-full p-6 rounded-2xl bg-[#0F1420]/80 border border-[#1E293B] space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px] text-cyan-400",children:"tune"}),"Gateway & Connection Configuration"]}),e.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"Configure server listening network interface, listening port, security enforcement, and global upstream proxy."})]}),L&&e.jsxs("span",{className:"px-3 py-1 rounded-lg bg-emerald-500/10 border border-emerald-500/30 text-emerald-400 text-xs font-medium flex items-center gap-1.5 animate-rt-fade-in self-start sm:self-center",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"check_circle"}),L]}),R&&e.jsxs("span",{className:"px-3 py-1 rounded-lg bg-rose-500/10 border border-rose-500/30 text-rose-400 text-xs font-medium flex items-center gap-1.5 self-start sm:self-center",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"error"}),R]})]}),se&&e.jsxs("div",{className:"p-4 rounded-xl bg-amber-500/10 border border-amber-500/30 flex flex-col sm:flex-row sm:items-center justify-between gap-3 animate-rt-fade-in",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px] text-amber-400 shrink-0",children:"restart_alt"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-amber-300",children:"Restart Required to Apply Network Configuration"}),e.jsxs("p",{className:"text-[11px] text-amber-200/70 mt-0.5",children:["Listening host is configured as ",e.jsx("span",{className:"font-mono font-semibold text-white",children:o==null?void 0:o.configuredHost}),", but the gateway socket is still bound to ",e.jsx("span",{className:"font-mono font-semibold text-white",children:o==null?void 0:o.host}),"."]})]})]}),K&&e.jsxs("button",{type:"button",onClick:K,className:"px-3.5 py-1.5 rounded-lg bg-amber-500 hover:bg-amber-400 text-slate-950 font-semibold text-xs transition-colors flex items-center gap-1.5 shrink-0 self-start sm:self-center cursor-pointer shadow-sm",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"restart_alt"}),"Restart Gateway Now"]})]}),ae?e.jsxs("div",{className:"py-12 text-center text-slate-400 flex flex-col items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-2xl text-blue-400 animate-spin",children:"progress_activity"}),e.jsx("span",{className:"text-xs",children:"Loading configuration..."})]}):e.jsxs("form",{onSubmit:ie,className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-200 mb-1.5",children:"Listening Host Interface"}),e.jsx(Ne,{value:r.host,onChange:t=>c({...r,host:t}),options:[{value:"127.0.0.1",label:"127.0.0.1 — Localhost only (Recommended, Private)"},{value:"0.0.0.0",label:"0.0.0.0 — All Interfaces (LAN / Network Access)"},{value:"localhost",label:"localhost — Standard local loopback"}],className:"w-full"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Bind to 127.0.0.1 to isolate Mapigate to this machine, or 0.0.0.0 to expose on your local network."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-200 mb-1.5",children:"Gateway Port"}),e.jsx("input",{type:"number",min:1024,max:65535,value:r.port,onChange:t=>c({...r,port:parseInt(t.target.value,10)||m}),className:"w-full bg-[#0A0D14] border border-[#1E293B] focus:border-blue-500 rounded-xl px-3.5 py-2 text-xs font-mono text-white placeholder-slate-500 focus:outline-none transition-colors"}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:["Active server listening on port ",e.jsx("span",{className:"text-blue-400 font-mono font-semibold",children:E}),". Default port is ",m,". Change requires restarting Mapigate server."]})]})]}),e.jsxs("div",{className:"p-4 rounded-xl bg-[#0A0D14] border border-[#1E293B] space-y-2.5",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("label",{className:"text-xs font-semibold text-slate-200 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-cyan-400",children:"lan"}),"Trusted LAN Host Patterns / IP Ranges"]}),e.jsx("p",{className:"text-[11px] text-slate-400",children:"Host header patterns allowed when accessing Mapigate over LAN (comma-separated)."})]}),e.jsxs("button",{type:"button",onClick:()=>c({...r,allowedHosts:u}),className:"px-2.5 py-1 rounded-lg bg-[#141B2D] border border-[#1E293B] hover:border-slate-600 text-[11px] font-medium text-slate-300 hover:text-white flex items-center gap-1 transition-all cursor-pointer self-start sm:self-center shrink-0",title:"Reset to default private network ranges",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px] text-slate-400",children:"restart_alt"}),"Reset to Default"]})]}),e.jsx("input",{type:"text",placeholder:u,value:r.allowedHosts||"",onChange:t=>c({...r,allowedHosts:t.target.value}),className:"w-full bg-[#080B10] border border-[#1E293B] focus:border-blue-500 rounded-xl px-3.5 py-2 text-xs font-mono text-white placeholder-slate-500 focus:outline-none transition-colors"}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-1 text-[10.5px] text-slate-500",children:[e.jsxs("span",{children:["Default: ",e.jsx("code",{className:"text-slate-400 font-mono",children:u})]}),e.jsx("span",{children:"Supports wildcards (e.g. 192.168.*, 10.*, *.local)"})]})]}),e.jsxs("div",{className:"p-4 rounded-xl bg-[#0A0D14] border border-[#1E293B] flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("span",{className:"text-xs font-bold text-white flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-amber-400",children:"key"}),"Require API Key Authentication"]}),e.jsxs("p",{className:"text-[11px] text-slate-400",children:["When enabled, all incoming proxy requests to ",e.jsx("code",{className:"font-mono text-slate-300",children:"/v1/*"})," must supply an Authorization header matching an active Gateway Key below."]})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer shrink-0",children:[e.jsx("input",{type:"checkbox",checked:r.requireApiKey,onChange:t=>c({...r,requireApiKey:t.target.checked}),className:"sr-only peer"}),e.jsx("div",{className:"w-10 h-5.5 bg-[#1E293B] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4.5 after:w-4.5 after:transition-all peer-checked:bg-blue-600"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-semibold text-slate-200 mb-1.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-purple-400",children:"router"}),"Global Upstream Proxy URL (Optional)"]}),e.jsx("input",{type:"text",placeholder:"e.g. http://127.0.0.1:7890 or socks5://127.0.0.1:1080",value:r.proxyUrl||"",onChange:t=>c({...r,proxyUrl:t.target.value}),className:"w-full bg-[#0A0D14] border border-[#1E293B] focus:border-blue-500 rounded-xl px-3.5 py-2 text-xs font-mono text-white placeholder-slate-500 focus:outline-none transition-colors"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Egress proxy used for routing outgoing requests to upstream AI model providers. Leave blank for direct connection."})]}),e.jsxs("div",{className:"space-y-2.5 pt-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-200",children:"Custom Outbound Headers"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Appended to all outgoing requests to upstream providers"})]}),e.jsxs("button",{type:"button",onClick:ue,className:"px-3 py-1 rounded-lg bg-blue-600/10 border border-blue-500/30 text-blue-400 hover:bg-blue-600/20 text-xs font-medium flex items-center gap-1 transition-colors cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"add"}),"Add Header"]})]}),y.length===0?e.jsx("div",{className:"p-3 text-center rounded-xl bg-[#0A0D14] border border-[#1E293B] text-slate-500 text-xs",children:"No custom headers configured. Click “Add Header” to add custom headers."}):e.jsx("div",{className:"space-y-2",children:y.map(t=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-xl bg-[#0A0D14] border border-[#1E293B]",children:[e.jsx("input",{type:"text",placeholder:"Header Name (e.g. X-Org-ID)",value:t.key,onChange:s=>X(t.id,"key",s.target.value),className:"flex-1 bg-transparent border-0 px-2 py-1 text-xs font-mono text-white placeholder-slate-600 focus:outline-none"}),e.jsx("span",{className:"text-slate-600 font-mono text-xs",children:":"}),e.jsx("input",{type:"text",placeholder:"Header Value",value:t.value,onChange:s=>X(t.id,"value",s.target.value),className:"flex-1 bg-transparent border-0 px-2 py-1 text-xs font-mono text-white placeholder-slate-600 focus:outline-none"}),e.jsx("button",{type:"button",onClick:()=>he(t.id),className:"p-1 text-slate-500 hover:text-rose-400 cursor-pointer transition-colors",title:"Remove header",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]},t.id))})]}),e.jsx("div",{className:"flex items-center justify-end pt-3 border-t border-[#1E293B]",children:e.jsx("button",{type:"submit",disabled:P,className:"px-5 py-2 rounded-xl text-xs font-semibold text-white bg-blue-600 hover:bg-blue-500 shadow-md shadow-blue-600/20 disabled:opacity-50 transition-all flex items-center gap-1.5 cursor-pointer",children:P?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[15px] animate-spin",children:"progress_activity"}),"Saving Configuration..."]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"save"}),"Save Configuration"]})})})]})]}),e.jsxs("div",{className:"w-full p-6 rounded-2xl bg-[#0F1420]/80 border border-[#1E293B] space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px] text-amber-400",children:"vpn_key"}),"Client Gateway API Keys (",v.length,")"]}),e.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"Authentication tokens used by Claude Code CLI, Cursor, and Cline to access Mapigate gateway securely."})]}),e.jsxs("button",{type:"button",onClick:()=>{b(null),h(!0)},className:"px-4 py-2 rounded-xl bg-blue-600 hover:bg-blue-500 shadow-md shadow-blue-600/20 text-xs font-semibold text-white flex items-center gap-1.5 transition-all cursor-pointer self-start sm:self-center shrink-0",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Generate New Key"]})]}),le?e.jsxs("div",{className:"py-12 text-center text-slate-400 flex flex-col items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-2xl text-blue-400 animate-spin",children:"progress_activity"}),e.jsx("span",{className:"text-xs",children:"Loading API keys..."})]}):v.length===0?e.jsxs("div",{className:"py-12 text-center text-slate-400 flex flex-col items-center justify-center gap-2.5 bg-[#0A0D14] rounded-xl border border-[#1E293B]",children:[e.jsx("span",{className:"material-symbols-outlined text-3xl text-slate-600",children:"key_off"}),e.jsx("p",{className:"text-xs font-semibold text-slate-300",children:"No Gateway API Keys Generated"}),e.jsx("p",{className:"text-[11px] text-slate-500 max-w-sm",children:"Generate a client API key to authenticate requests from external developer tools when “Require API Key” is enabled."})]}):e.jsx("div",{className:"w-full overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left text-xs text-slate-300 border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[#1E293B] text-[11px] text-slate-400 uppercase font-semibold",children:[e.jsx("th",{className:"py-3 px-3",children:"Name / Label"}),e.jsx("th",{className:"py-3 px-3",children:"API Token"}),e.jsx("th",{className:"py-3 px-3",children:"Created"}),e.jsx("th",{className:"py-3 px-3",children:"Last Used"}),e.jsx("th",{className:"py-3 px-3 text-center",children:"Status"}),e.jsx("th",{className:"py-3 px-3 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-[#1E293B]/60",children:v.map(t=>{const s=re.has(t.id),a=oe===t.id;return e.jsxs("tr",{className:"hover:bg-[#141B2D]/40 transition-colors",children:[e.jsx("td",{className:"py-3.5 px-3 font-semibold text-white",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:t.name}),t.isSystem&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-500/15 text-blue-400 border border-blue-500/30 font-medium",children:"System"})]})}),e.jsx("td",{className:"py-3.5 px-3",children:e.jsxs("div",{className:"flex items-center gap-2 font-mono text-xs",children:[e.jsx("span",{className:`px-2 py-0.5 rounded-lg border ${s?"bg-[#0A0D14] border-blue-500/30 text-blue-300 select-all":"bg-[#0A0D14] border-[#1E293B] text-slate-400 select-none"}`,children:s?t.key:Z(t.key)}),e.jsx("button",{type:"button",onClick:()=>pe(t.id),className:"p-1 text-slate-400 hover:text-white transition-colors cursor-pointer",title:s?"Hide token":"Reveal token",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:s?"visibility_off":"visibility"})}),e.jsx("button",{type:"button",onClick:()=>me(t.key,t.id),className:"p-1 text-slate-400 hover:text-white transition-colors cursor-pointer",title:"Copy API key",children:e.jsx("span",{className:`material-symbols-outlined text-[15px] ${a?"text-emerald-400":""}`,children:a?"check":"content_copy"})})]})}),e.jsx("td",{className:"py-3.5 px-3 text-slate-400 text-[11px]",children:new Date(t.createdAt).toLocaleDateString()}),e.jsx("td",{className:"py-3.5 px-3 text-slate-400 text-[11px] font-mono",children:t.lastUsedAt?new Date(t.lastUsedAt).toLocaleString():"Never"}),e.jsx("td",{className:"py-3.5 px-3 text-center",children:e.jsxs("label",{className:`relative inline-flex items-center ${t.isSystem?"cursor-not-allowed opacity-60":"cursor-pointer"}`,children:[e.jsx("input",{type:"checkbox",checked:t.isActive,disabled:t.isSystem,onChange:()=>de(t),className:"sr-only peer"}),e.jsx("div",{className:"w-8 h-4.5 bg-[#1E293B] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-3.5 after:w-3.5 after:transition-all peer-checked:bg-emerald-500"})]})}),e.jsx("td",{className:"py-3.5 px-3 text-right",children:t.isSystem?e.jsx("span",{className:"text-[11px] text-slate-500 italic pr-2",children:"Protected"}):e.jsx("button",{type:"button",onClick:()=>C(t),className:"p-1.5 text-slate-400 hover:text-rose-400 hover:bg-rose-500/10 rounded-lg transition-colors cursor-pointer",title:"Delete API key",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"delete"})})})]},t.id)})})]})})]}),q&&e.jsx(ve,{isOpen:q,onClose:()=>{h(!1),b(null)},maxWidthClass:"max-w-md",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-[#1E293B]",children:[e.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] text-amber-400",children:"vpn_key"}),"Generate Gateway API Key"]}),e.jsx("button",{type:"button",onClick:()=>{h(!1),b(null)},className:"p-1 rounded text-slate-400 hover:text-white cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),N?e.jsxs("div",{className:"space-y-4 py-2 animate-rt-scale-in",children:[e.jsxs("div",{className:"p-3 rounded-xl bg-emerald-500/10 border border-emerald-500/30 text-emerald-400 text-xs flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"check_circle"}),e.jsxs("span",{children:["API Key “",N.name,"” generated successfully!"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold text-slate-400 block",children:"Your Gateway Secret Token:"}),e.jsxs("div",{className:"flex items-center gap-2 p-2.5 rounded-xl bg-[#0A0D14] border border-[#1E293B]",children:[e.jsx("span",{className:"font-mono text-xs text-white break-all flex-1 select-all",children:N.key}),e.jsxs("button",{type:"button",onClick:()=>S(N.key,"newlyCreated"),className:"px-2.5 py-1 rounded-lg bg-blue-600 hover:bg-blue-500 text-white text-xs font-semibold flex items-center gap-1 transition-all cursor-pointer shrink-0",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:p==="newlyCreated"?"check":"content_copy"}),p==="newlyCreated"?"Copied":"Copy"]})]})]}),e.jsx("div",{className:"flex justify-end pt-2",children:e.jsx("button",{type:"button",onClick:()=>{h(!1),b(null)},className:"px-4 py-1.5 rounded-xl bg-[#141B2D] border border-[#1E293B] text-xs font-semibold text-white hover:border-slate-600 cursor-pointer",children:"Done"})})]}):e.jsxs("form",{onSubmit:ce,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-200 mb-1",children:"Key Label / Client Name"}),e.jsx("input",{type:"text",placeholder:"e.g. Claude Code CLI, Cursor MacBook, Cline",value:G,onChange:t=>O(t.target.value),className:"w-full bg-[#0A0D14] border border-[#1E293B] focus:border-blue-500 rounded-xl px-3 py-2 text-xs text-white placeholder-slate-500 focus:outline-none",autoFocus:!0}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"A friendly label to identify which coding tool is using this key."})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-3 border-t border-[#1E293B]",children:[e.jsx("button",{type:"button",onClick:()=>h(!1),className:"px-4 py-2 text-xs font-medium text-slate-400 hover:text-white bg-[#141B2D] border border-[#1E293B] rounded-xl transition-colors cursor-pointer",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:$,className:"px-4 py-2 rounded-xl text-xs font-semibold text-white bg-blue-600 hover:bg-blue-500 shadow-md shadow-blue-600/20 disabled:opacity-50 transition-all flex items-center gap-1.5 cursor-pointer",children:$?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[14px] animate-spin",children:"progress_activity"}),"Generating..."]}):"Generate Key"})]})]})]})}),x&&e.jsx(we,{isOpen:x!==null,title:"Delete Gateway API Key",message:`Are you sure you want to permanently delete API key "${x.name}" (${Z(x.key)})? Any client tool configured with this key will no longer be authorized.`,confirmText:"Delete Key",variant:"danger",onConfirm:xe,onCancel:()=>C(null)})]})};export{De as EndpointTab};
|
|
1
|
+
import{r as l,j as e}from"./vendor-BcOI2aZ9.js";import{S as Ne}from"./Select-BNRH8LIG.js";import{C as we}from"./ConfirmModal-Co5OXd_g.js";import{u as ee,D as m,d as te,P as ve}from"./index-CtfMJ11V.js";import"./lucide-Cc35htxl.js";const u="10.*, 172.16-31.*, 192.168.*, 169.254.*, *.local",Ce={host:te,port:m,requireApiKey:!1,proxyUrl:"",customHeaders:{},allowedHosts:u},De=({onRestartClick:K})=>{const o=ee(t=>t.info),w=ee(t=>t.fetchSystemInfo),se=!!(o!=null&&o.isRestartRequired),[r,c]=l.useState(Ce),[ae,T]=l.useState(!0),[P,H]=l.useState(!1),[L,f]=l.useState(null),[R,I]=l.useState(null),[y,g]=l.useState([]),[v,j]=l.useState([]),[le,_]=l.useState(!0),[re,ne]=l.useState(new Set),[p,U]=l.useState(null),[oe,F]=l.useState(null),[q,h]=l.useState(!1),[G,O]=l.useState(""),[$,M]=l.useState(!1),[N,b]=l.useState(null),[x,C]=l.useState(null),[J,k]=l.useState(null),[A,V]=l.useState(!1),W=l.useCallback(async()=>{try{T(!0);const[t]=await Promise.all([fetch("/api/settings/endpoint"),w()]);if(t.ok){const s=await t.json();c({host:s.host||te,port:s.port||m,requireApiKey:!!s.requireApiKey,proxyUrl:s.proxyUrl||"",customHeaders:s.customHeaders||{},allowedHosts:s.allowedHosts||u});const a=Object.entries(s.customHeaders||{}).map(([i,n],d)=>({id:`header-${d}-${Date.now()}`,key:i,value:String(n)}));g(a)}}catch(t){console.error("Failed to load endpoint settings:",t)}finally{T(!1)}},[w]),z=l.useCallback(async()=>{try{_(!0);const t=await fetch("/api/settings/endpoint/keys");if(t.ok){const s=await t.json();Array.isArray(s)&&j(s)}}catch(t){console.error("Failed to load gateway API keys:",t)}finally{_(!1)}},[]);l.useEffect(()=>{W(),z()},[W,z]);const ie=async t=>{var a,i;t&&t.preventDefault(),H(!0),f(null),I(null);const s={};for(const n of y){const d=n.key.trim();d&&(s[d]=n.value.trim())}try{const n={host:r.host,port:Number(r.port)||m,requireApiKey:r.requireApiKey,proxyUrl:((a=r.proxyUrl)==null?void 0:a.trim())||"",customHeaders:s,allowedHosts:((i=r.allowedHosts)==null?void 0:i.trim())||u},d=await fetch("/api/settings/endpoint",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!d.ok){const je=await d.json();throw new Error(je.error||"Failed to update endpoint settings")}const ye=await d.json();c(ye);const D=await w(),ge=!!(D!=null&&D.isRestartRequired);f(ge?"Configuration saved! Server restart is required to rebind the network interface.":"Settings saved successfully!"),setTimeout(()=>f(null),5e3)}catch(n){I((n==null?void 0:n.message)||"Failed to save settings")}finally{H(!1)}},ce=async t=>{t.preventDefault();try{M(!0);const s=await fetch("/api/settings/endpoint/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:G.trim()||void 0})});if(s.ok){const a=await s.json();j(i=>[a,...i]),b(a),O("")}else{const a=await s.json();alert(a.error||"Failed to create API key")}}catch(s){console.error("Error creating key:",s)}finally{M(!1)}},de=async t=>{try{const s=await fetch(`/api/settings/endpoint/keys/${t.id}/toggle`,{method:"PATCH"});if(s.ok){const a=await s.json();j(i=>i.map(n=>n.id===t.id?a:n))}}catch(s){console.error("Error toggling API key:",s)}},xe=async()=>{if(x)try{(await fetch(`/api/settings/endpoint/keys/${x.id}`,{method:"DELETE"})).ok&&j(s=>s.filter(a=>a.id!==x.id))}catch(t){console.error("Error deleting API key:",t)}finally{C(null)}},pe=t=>{ne(s=>{const a=new Set(s);return a.has(t)?a.delete(t):a.add(t),a})},S=(t,s)=>{navigator.clipboard.writeText(t),U(s),setTimeout(()=>U(null),2e3)},me=(t,s)=>{navigator.clipboard.writeText(t),F(s),setTimeout(()=>F(null),2e3)},ue=()=>{g([...y,{id:`header-${Date.now()}`,key:"",value:""}])},X=(t,s,a)=>{g(i=>i.map(n=>n.id===t?{...n,[s]:a}:n))},he=t=>{g(s=>s.filter(a=>a.id!==t))},Y=r.host==="0.0.0.0"?"127.0.0.1":r.host||"127.0.0.1",be=(o==null?void 0:o.port)||(typeof window<"u"&&window.location.port&&window.location.port!=="5173"?Number(window.location.port):m),E=r.port||be,Q=`http://${Y}:${E}/v1`,B=`http://${Y}:${E}`,fe=async()=>{V(!0),k(null);try{const s=await(await fetch("/health")).json();k(JSON.stringify(s,null,2))}catch{k(JSON.stringify({error:"Failed to connect to gateway"},null,2))}finally{V(!1)}},Z=t=>{if(t.length<=10)return"••••••••";const s=t.slice(0,6),a=t.slice(-4);return`${s}••••••••${a}`};return e.jsxs("div",{className:"space-y-8 w-full px-2 sm:px-4 pb-16 animate-rt-fade-in",children:[e.jsxs("div",{className:"w-full p-6 rounded-2xl bg-[#0F1420]/80 border border-[#1E293B] space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px] text-blue-400",children:"api"}),"Local Gateway Endpoints"]}),e.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"Universal endpoints accepting OpenAI Chat Completions and Anthropic Messages protocols"})]}),e.jsxs("div",{className:"space-y-3.5 text-xs font-mono",children:[e.jsxs("div",{className:"bg-[#0A0D14] p-4 rounded-xl border border-[#1E293B] flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-500 block text-[10px] uppercase font-sans font-semibold",children:"OpenAI-Compatible Base URL (Cursor, Cline, OpenCode, Codex)"}),e.jsx("span",{className:"text-blue-400 font-bold text-sm",children:Q})]}),e.jsxs("button",{type:"button",onClick:()=>S(Q,"openai"),className:"px-3.5 py-1.5 rounded-xl bg-[#141B2D] border border-[#1E293B] hover:border-slate-600 text-xs font-semibold text-slate-300 hover:text-white flex items-center gap-1.5 transition-all cursor-pointer self-start sm:self-center font-sans",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:p==="openai"?"check":"content_copy"}),p==="openai"?"Copied":"Copy"]})]}),e.jsxs("div",{className:"bg-[#0A0D14] p-4 rounded-xl border border-[#1E293B] flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-500 block text-[10px] uppercase font-sans font-semibold",children:"Anthropic Base URL (Claude Code CLI: ANTHROPIC_BASE_URL)"}),e.jsx("span",{className:"text-cyan-400 font-bold text-sm",children:B})]}),e.jsxs("button",{type:"button",onClick:()=>S(B,"anthropic"),className:"px-3.5 py-1.5 rounded-xl bg-[#141B2D] border border-[#1E293B] hover:border-slate-600 text-xs font-semibold text-slate-300 hover:text-white flex items-center gap-1.5 transition-all cursor-pointer self-start sm:self-center font-sans",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:p==="anthropic"?"check":"content_copy"}),p==="anthropic"?"Copied":"Copy"]})]})]}),e.jsxs("div",{className:"pt-2 border-t border-[#1E293B] space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-bold text-slate-200 block font-sans",children:"Test Gateway Connectivity:"}),e.jsxs("button",{type:"button",onClick:fe,disabled:A,className:"px-4 py-2 rounded-xl text-xs font-semibold text-white bg-blue-600 hover:bg-blue-500 shadow-md shadow-blue-600/20 disabled:opacity-50 transition-all flex items-center gap-1.5 cursor-pointer font-sans",children:[e.jsx("span",{className:`material-symbols-outlined text-[15px] ${A?"animate-spin":""}`,children:A?"sync":"play_arrow"}),"Execute Test Ping"]})]}),e.jsxs("div",{className:"bg-[#0A0D14] p-3 rounded-xl border border-[#1E293B] text-xs font-mono text-slate-300 overflow-x-auto",children:["curl ",B,"/health"]}),J&&e.jsx("pre",{className:"bg-[#080B10] p-4 rounded-xl border border-blue-500/30 text-emerald-400 text-xs font-mono overflow-x-auto animate-rt-scale-in",children:J})]})]}),e.jsxs("div",{className:"w-full p-6 rounded-2xl bg-[#0F1420]/80 border border-[#1E293B] space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px] text-cyan-400",children:"tune"}),"Gateway & Connection Configuration"]}),e.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"Configure server listening network interface, listening port, security enforcement, and global upstream proxy."})]}),L&&e.jsxs("span",{className:"px-3 py-1 rounded-lg bg-emerald-500/10 border border-emerald-500/30 text-emerald-400 text-xs font-medium flex items-center gap-1.5 animate-rt-fade-in self-start sm:self-center",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"check_circle"}),L]}),R&&e.jsxs("span",{className:"px-3 py-1 rounded-lg bg-rose-500/10 border border-rose-500/30 text-rose-400 text-xs font-medium flex items-center gap-1.5 self-start sm:self-center",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"error"}),R]})]}),se&&e.jsxs("div",{className:"p-4 rounded-xl bg-amber-500/10 border border-amber-500/30 flex flex-col sm:flex-row sm:items-center justify-between gap-3 animate-rt-fade-in",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px] text-amber-400 shrink-0",children:"restart_alt"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-amber-300",children:"Restart Required to Apply Network Configuration"}),e.jsxs("p",{className:"text-[11px] text-amber-200/70 mt-0.5",children:["Listening host is configured as ",e.jsx("span",{className:"font-mono font-semibold text-white",children:o==null?void 0:o.configuredHost}),", but the gateway socket is still bound to ",e.jsx("span",{className:"font-mono font-semibold text-white",children:o==null?void 0:o.host}),"."]})]})]}),K&&e.jsxs("button",{type:"button",onClick:K,className:"px-3.5 py-1.5 rounded-lg bg-amber-500 hover:bg-amber-400 text-slate-950 font-semibold text-xs transition-colors flex items-center gap-1.5 shrink-0 self-start sm:self-center cursor-pointer shadow-sm",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"restart_alt"}),"Restart Gateway Now"]})]}),ae?e.jsxs("div",{className:"py-12 text-center text-slate-400 flex flex-col items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-2xl text-blue-400 animate-spin",children:"progress_activity"}),e.jsx("span",{className:"text-xs",children:"Loading configuration..."})]}):e.jsxs("form",{onSubmit:ie,className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-200 mb-1.5",children:"Listening Host Interface"}),e.jsx(Ne,{value:r.host,onChange:t=>c({...r,host:t}),options:[{value:"127.0.0.1",label:"127.0.0.1 — Localhost only (Recommended, Private)"},{value:"0.0.0.0",label:"0.0.0.0 — All Interfaces (LAN / Network Access)"},{value:"localhost",label:"localhost — Standard local loopback"}],className:"w-full"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Bind to 127.0.0.1 to isolate Mapigate to this machine, or 0.0.0.0 to expose on your local network."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-200 mb-1.5",children:"Gateway Port"}),e.jsx("input",{type:"number",min:1024,max:65535,value:r.port,onChange:t=>c({...r,port:parseInt(t.target.value,10)||m}),className:"w-full bg-[#0A0D14] border border-[#1E293B] focus:border-blue-500 rounded-xl px-3.5 py-2 text-xs font-mono text-white placeholder-slate-500 focus:outline-none transition-colors"}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:["Active server listening on port ",e.jsx("span",{className:"text-blue-400 font-mono font-semibold",children:E}),". Default port is ",m,". Change requires restarting Mapigate server."]})]})]}),e.jsxs("div",{className:"p-4 rounded-xl bg-[#0A0D14] border border-[#1E293B] space-y-2.5",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("label",{className:"text-xs font-semibold text-slate-200 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-cyan-400",children:"lan"}),"Trusted LAN Host Patterns / IP Ranges"]}),e.jsx("p",{className:"text-[11px] text-slate-400",children:"Host header patterns allowed when accessing Mapigate over LAN (comma-separated)."})]}),e.jsxs("button",{type:"button",onClick:()=>c({...r,allowedHosts:u}),className:"px-2.5 py-1 rounded-lg bg-[#141B2D] border border-[#1E293B] hover:border-slate-600 text-[11px] font-medium text-slate-300 hover:text-white flex items-center gap-1 transition-all cursor-pointer self-start sm:self-center shrink-0",title:"Reset to default private network ranges",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px] text-slate-400",children:"restart_alt"}),"Reset to Default"]})]}),e.jsx("input",{type:"text",placeholder:u,value:r.allowedHosts||"",onChange:t=>c({...r,allowedHosts:t.target.value}),className:"w-full bg-[#080B10] border border-[#1E293B] focus:border-blue-500 rounded-xl px-3.5 py-2 text-xs font-mono text-white placeholder-slate-500 focus:outline-none transition-colors"}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-1 text-[10.5px] text-slate-500",children:[e.jsxs("span",{children:["Default: ",e.jsx("code",{className:"text-slate-400 font-mono",children:u})]}),e.jsx("span",{children:"Supports wildcards (e.g. 192.168.*, 10.*, *.local)"})]})]}),e.jsxs("div",{className:"p-4 rounded-xl bg-[#0A0D14] border border-[#1E293B] flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("span",{className:"text-xs font-bold text-white flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-amber-400",children:"key"}),"Require API Key Authentication"]}),e.jsxs("p",{className:"text-[11px] text-slate-400",children:["When enabled, all incoming proxy requests to ",e.jsx("code",{className:"font-mono text-slate-300",children:"/v1/*"})," must supply an Authorization header matching an active Gateway Key below."]})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer shrink-0",children:[e.jsx("input",{type:"checkbox",checked:r.requireApiKey,onChange:t=>c({...r,requireApiKey:t.target.checked}),className:"sr-only peer"}),e.jsx("div",{className:"w-10 h-5.5 bg-[#1E293B] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4.5 after:w-4.5 after:transition-all peer-checked:bg-blue-600"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-semibold text-slate-200 mb-1.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-purple-400",children:"router"}),"Global Upstream Proxy URL (Optional)"]}),e.jsx("input",{type:"text",placeholder:"e.g. http://127.0.0.1:7890 or socks5://127.0.0.1:1080",value:r.proxyUrl||"",onChange:t=>c({...r,proxyUrl:t.target.value}),className:"w-full bg-[#0A0D14] border border-[#1E293B] focus:border-blue-500 rounded-xl px-3.5 py-2 text-xs font-mono text-white placeholder-slate-500 focus:outline-none transition-colors"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Egress proxy used for routing outgoing requests to upstream AI model providers. Leave blank for direct connection."})]}),e.jsxs("div",{className:"space-y-2.5 pt-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-200",children:"Custom Outbound Headers"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Appended to all outgoing requests to upstream providers"})]}),e.jsxs("button",{type:"button",onClick:ue,className:"px-3 py-1 rounded-lg bg-blue-600/10 border border-blue-500/30 text-blue-400 hover:bg-blue-600/20 text-xs font-medium flex items-center gap-1 transition-colors cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"add"}),"Add Header"]})]}),y.length===0?e.jsx("div",{className:"p-3 text-center rounded-xl bg-[#0A0D14] border border-[#1E293B] text-slate-500 text-xs",children:"No custom headers configured. Click “Add Header” to add custom headers."}):e.jsx("div",{className:"space-y-2",children:y.map(t=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-xl bg-[#0A0D14] border border-[#1E293B]",children:[e.jsx("input",{type:"text",placeholder:"Header Name (e.g. X-Org-ID)",value:t.key,onChange:s=>X(t.id,"key",s.target.value),className:"flex-1 bg-transparent border-0 px-2 py-1 text-xs font-mono text-white placeholder-slate-600 focus:outline-none"}),e.jsx("span",{className:"text-slate-600 font-mono text-xs",children:":"}),e.jsx("input",{type:"text",placeholder:"Header Value",value:t.value,onChange:s=>X(t.id,"value",s.target.value),className:"flex-1 bg-transparent border-0 px-2 py-1 text-xs font-mono text-white placeholder-slate-600 focus:outline-none"}),e.jsx("button",{type:"button",onClick:()=>he(t.id),className:"p-1 text-slate-500 hover:text-rose-400 cursor-pointer transition-colors",title:"Remove header",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]},t.id))})]}),e.jsx("div",{className:"flex items-center justify-end pt-3 border-t border-[#1E293B]",children:e.jsx("button",{type:"submit",disabled:P,className:"px-5 py-2 rounded-xl text-xs font-semibold text-white bg-blue-600 hover:bg-blue-500 shadow-md shadow-blue-600/20 disabled:opacity-50 transition-all flex items-center gap-1.5 cursor-pointer",children:P?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[15px] animate-spin",children:"progress_activity"}),"Saving Configuration..."]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"save"}),"Save Configuration"]})})})]})]}),e.jsxs("div",{className:"w-full p-6 rounded-2xl bg-[#0F1420]/80 border border-[#1E293B] space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px] text-amber-400",children:"vpn_key"}),"Client Gateway API Keys (",v.length,")"]}),e.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"Authentication tokens used by Claude Code CLI, Cursor, and Cline to access Mapigate gateway securely."})]}),e.jsxs("button",{type:"button",onClick:()=>{b(null),h(!0)},className:"px-4 py-2 rounded-xl bg-blue-600 hover:bg-blue-500 shadow-md shadow-blue-600/20 text-xs font-semibold text-white flex items-center gap-1.5 transition-all cursor-pointer self-start sm:self-center shrink-0",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Generate New Key"]})]}),le?e.jsxs("div",{className:"py-12 text-center text-slate-400 flex flex-col items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-2xl text-blue-400 animate-spin",children:"progress_activity"}),e.jsx("span",{className:"text-xs",children:"Loading API keys..."})]}):v.length===0?e.jsxs("div",{className:"py-12 text-center text-slate-400 flex flex-col items-center justify-center gap-2.5 bg-[#0A0D14] rounded-xl border border-[#1E293B]",children:[e.jsx("span",{className:"material-symbols-outlined text-3xl text-slate-600",children:"key_off"}),e.jsx("p",{className:"text-xs font-semibold text-slate-300",children:"No Gateway API Keys Generated"}),e.jsx("p",{className:"text-[11px] text-slate-500 max-w-sm",children:"Generate a client API key to authenticate requests from external developer tools when “Require API Key” is enabled."})]}):e.jsx("div",{className:"w-full overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left text-xs text-slate-300 border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[#1E293B] text-[11px] text-slate-400 uppercase font-semibold",children:[e.jsx("th",{className:"py-3 px-3",children:"Name / Label"}),e.jsx("th",{className:"py-3 px-3",children:"API Token"}),e.jsx("th",{className:"py-3 px-3",children:"Created"}),e.jsx("th",{className:"py-3 px-3",children:"Last Used"}),e.jsx("th",{className:"py-3 px-3 text-center",children:"Status"}),e.jsx("th",{className:"py-3 px-3 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-[#1E293B]/60",children:v.map(t=>{const s=re.has(t.id),a=oe===t.id;return e.jsxs("tr",{className:"hover:bg-[#141B2D]/40 transition-colors",children:[e.jsx("td",{className:"py-3.5 px-3 font-semibold text-white",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:t.name}),t.isSystem&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-500/15 text-blue-400 border border-blue-500/30 font-medium",children:"System"})]})}),e.jsx("td",{className:"py-3.5 px-3",children:e.jsxs("div",{className:"flex items-center gap-2 font-mono text-xs",children:[e.jsx("span",{className:`px-2 py-0.5 rounded-lg border ${s?"bg-[#0A0D14] border-blue-500/30 text-blue-300 select-all":"bg-[#0A0D14] border-[#1E293B] text-slate-400 select-none"}`,children:s?t.key:Z(t.key)}),e.jsx("button",{type:"button",onClick:()=>pe(t.id),className:"p-1 text-slate-400 hover:text-white transition-colors cursor-pointer",title:s?"Hide token":"Reveal token",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:s?"visibility_off":"visibility"})}),e.jsx("button",{type:"button",onClick:()=>me(t.key,t.id),className:"p-1 text-slate-400 hover:text-white transition-colors cursor-pointer",title:"Copy API key",children:e.jsx("span",{className:`material-symbols-outlined text-[15px] ${a?"text-emerald-400":""}`,children:a?"check":"content_copy"})})]})}),e.jsx("td",{className:"py-3.5 px-3 text-slate-400 text-[11px]",children:new Date(t.createdAt).toLocaleDateString()}),e.jsx("td",{className:"py-3.5 px-3 text-slate-400 text-[11px] font-mono",children:t.lastUsedAt?new Date(t.lastUsedAt).toLocaleString():"Never"}),e.jsx("td",{className:"py-3.5 px-3 text-center",children:e.jsxs("label",{className:`relative inline-flex items-center ${t.isSystem?"cursor-not-allowed opacity-60":"cursor-pointer"}`,children:[e.jsx("input",{type:"checkbox",checked:t.isActive,disabled:t.isSystem,onChange:()=>de(t),className:"sr-only peer"}),e.jsx("div",{className:"w-8 h-4.5 bg-[#1E293B] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-3.5 after:w-3.5 after:transition-all peer-checked:bg-emerald-500"})]})}),e.jsx("td",{className:"py-3.5 px-3 text-right",children:t.isSystem?e.jsx("span",{className:"text-[11px] text-slate-500 italic pr-2",children:"Protected"}):e.jsx("button",{type:"button",onClick:()=>C(t),className:"p-1.5 text-slate-400 hover:text-rose-400 hover:bg-rose-500/10 rounded-lg transition-colors cursor-pointer",title:"Delete API key",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"delete"})})})]},t.id)})})]})})]}),q&&e.jsx(ve,{isOpen:q,onClose:()=>{h(!1),b(null)},maxWidthClass:"max-w-xl",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-[#1E293B]",children:[e.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] text-amber-400",children:"vpn_key"}),"Generate Gateway API Key"]}),e.jsx("button",{type:"button",onClick:()=>{h(!1),b(null)},className:"p-1 rounded text-slate-400 hover:text-white cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),N?e.jsxs("div",{className:"space-y-4 py-2 animate-rt-scale-in",children:[e.jsxs("div",{className:"p-3 rounded-xl bg-emerald-500/10 border border-emerald-500/30 text-emerald-400 text-xs flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"check_circle"}),e.jsxs("span",{children:["API Key “",N.name,"” generated successfully!"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold text-slate-400 block",children:"Your Gateway Secret Token:"}),e.jsxs("div",{className:"flex items-center gap-2 p-2.5 rounded-xl bg-[#0A0D14] border border-[#1E293B]",children:[e.jsx("span",{className:"font-mono text-xs text-white break-all flex-1 select-all",children:N.key}),e.jsxs("button",{type:"button",onClick:()=>S(N.key,"newlyCreated"),className:"px-2.5 py-1 rounded-lg bg-blue-600 hover:bg-blue-500 text-white text-xs font-semibold flex items-center gap-1 transition-all cursor-pointer shrink-0",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:p==="newlyCreated"?"check":"content_copy"}),p==="newlyCreated"?"Copied":"Copy"]})]})]}),e.jsx("div",{className:"flex justify-end pt-2",children:e.jsx("button",{type:"button",onClick:()=>{h(!1),b(null)},className:"px-4 py-1.5 rounded-xl bg-[#141B2D] border border-[#1E293B] text-xs font-semibold text-white hover:border-slate-600 cursor-pointer",children:"Done"})})]}):e.jsxs("form",{onSubmit:ce,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-200 mb-1",children:"Key Label / Client Name"}),e.jsx("input",{type:"text",placeholder:"e.g. Claude Code CLI, Cursor MacBook, Cline",value:G,onChange:t=>O(t.target.value),className:"w-full bg-[#0A0D14] border border-[#1E293B] focus:border-blue-500 rounded-xl px-3 py-2 text-xs text-white placeholder-slate-500 focus:outline-none",autoFocus:!0}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"A friendly label to identify which coding tool is using this key."})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-3 border-t border-[#1E293B]",children:[e.jsx("button",{type:"button",onClick:()=>h(!1),className:"px-4 py-2 text-xs font-medium text-slate-400 hover:text-white bg-[#141B2D] border border-[#1E293B] rounded-xl transition-colors cursor-pointer",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:$,className:"px-4 py-2 rounded-xl text-xs font-semibold text-white bg-blue-600 hover:bg-blue-500 shadow-md shadow-blue-600/20 disabled:opacity-50 transition-all flex items-center gap-1.5 cursor-pointer",children:$?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[14px] animate-spin",children:"progress_activity"}),"Generating..."]}):"Generate Key"})]})]})]})}),x&&e.jsx(we,{isOpen:x!==null,title:"Delete Gateway API Key",message:`Are you sure you want to permanently delete API key "${x.name}" (${Z(x.key)})? Any client tool configured with this key will no longer be authorized.`,confirmText:"Delete Key",variant:"danger",onConfirm:xe,onCancel:()=>C(null)})]})};export{De as EndpointTab};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as n,j as e}from"./vendor-BcOI2aZ9.js";import{u as kt,D as Ct,d as Mt,P as We,e as Tt}from"./index-
|
|
1
|
+
import{r as n,j as e}from"./vendor-BcOI2aZ9.js";import{u as kt,D as Ct,d as Mt,P as We,e as Tt}from"./index-CtfMJ11V.js";import{M as Ge}from"./ModelAutocompleteInput-D0L1aj3-.js";import{r as Je}from"./metadataRegistry-CGDAkFU1.js";import{T as Bt}from"./ToolIcon-Cp4gSgFt.js";import"./lucide-Cc35htxl.js";const Ne={},Et=({toolId:m="kiro",value:r,onChange:u,onEnter:b,placeholder:N="Select or type source model ID...",className:w="",autoFocus:x=!1,disabled:v=!1})=>{const f=(m||"kiro").toLowerCase(),[j,c]=n.useState([]),[g,y]=n.useState(!1),[S,E]=n.useState(-1),[oe,D]=n.useState("bottom"),M=n.useRef(null),I=n.useRef(null);n.useEffect(()=>{if(g&&M.current){const o=M.current.getBoundingClientRect(),p=240,T=window.innerHeight-o.bottom,O=o.top;T<p&&O>T?D("top"):D("bottom")}},[g]),n.useEffect(()=>{let o=!0;if(Ne[f]){c(Ne[f]);return}return fetch(`/api/mitm/mappings/source-models/${encodeURIComponent(f)}`).then(p=>{if(!p.ok)throw new Error("Failed to load source models");return p.json()}).then(p=>{o&&Array.isArray(p)&&(Ne[f]=p,c(p))}).catch(()=>{}),()=>{o=!1}},[f]),n.useEffect(()=>{const o=p=>{M.current&&!M.current.contains(p.target)&&y(!1)};return document.addEventListener("mousedown",o),()=>{document.removeEventListener("mousedown",o)}},[]);const h=n.useMemo(()=>{const o=(r||"").trim().toLowerCase();return o?j.filter(p=>p.id.toLowerCase().includes(o)||p.name.toLowerCase().includes(o)):j},[j,r]);n.useEffect(()=>{E(h.length>0?0:-1)},[h]),n.useEffect(()=>{if(g&&S>=0&&I.current){const o=I.current.children[S];o&&o.scrollIntoView({block:"nearest"})}},[S,g]);const W=o=>{u(o),y(!1)},le=o=>{o.key==="ArrowDown"?(o.preventDefault(),g?h.length>0&&E(p=>(p+1)%h.length):y(!0)):o.key==="ArrowUp"?(o.preventDefault(),g&&h.length>0&&E(p=>(p-1+h.length)%h.length)):o.key==="Enter"?g&&S>=0&&S<h.length?(o.preventDefault(),W(h[S].id)):b&&(o.preventDefault(),b()):o.key==="Escape"&&y(!1)};return e.jsxs("div",{ref:M,className:"relative w-full",children:[e.jsxs("div",{className:"relative flex items-center",children:[e.jsx("input",{type:"text",value:r,onChange:o=>{u(o.target.value),g||y(!0)},onFocus:()=>y(!0),onKeyDown:le,placeholder:N,disabled:v,autoFocus:x,className:w||"w-full bg-[#0A0D14] border border-[#1E293B] rounded-xl px-3 py-2 text-xs text-white font-mono focus:outline-none focus:border-blue-500 placeholder:text-slate-600"}),e.jsx("button",{type:"button",tabIndex:-1,onClick:()=>y(o=>!o),className:"absolute right-2 text-slate-500 hover:text-slate-300 p-0.5 rounded cursor-pointer",title:"Toggle model suggestions",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:g?"arrow_drop_up":"arrow_drop_down"})})]}),g&&h.length>0&&e.jsx("div",{ref:I,className:`absolute left-0 right-0 z-50 max-h-56 overflow-y-auto rounded-xl border border-[#1E293B] bg-[#0A0D14] shadow-2xl py-1 ${oe==="top"?"bottom-full mb-1":"top-full mt-1"}`,children:h.map((o,p)=>{const T=p===S,O=o.category==="native";return e.jsxs("div",{onClick:()=>W(o.id),onMouseEnter:()=>E(p),className:`px-3 py-2 flex items-center justify-between text-xs cursor-pointer transition-colors ${T?"bg-blue-600/20 text-white":"text-slate-300 hover:bg-white/5"}`,children:[e.jsxs("div",{className:"flex flex-col min-w-0 pr-2",children:[e.jsx("span",{className:"font-mono font-medium text-slate-100 truncate",children:o.id}),o.name&&o.name!==o.id&&e.jsx("span",{className:"text-[10.5px] text-slate-400 font-sans truncate",children:o.name})]}),e.jsx("div",{className:"flex-shrink-0",children:O?e.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-cyan-500/15 border border-cyan-500/30 text-[9.5px] font-mono text-cyan-300 uppercase tracking-wider font-semibold",children:[f," native"]}):e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-purple-500/15 border border-purple-500/30 text-[9.5px] font-mono text-purple-300 uppercase tracking-wider font-semibold",children:"Standard"})})]},`${o.category}-${o.id}`)})})]})},At={id:"antigravity",name:"Antigravity IDE",image:"/assets/providers/antigravity/icon.png",desc:"Intercept Google Antigravity IDE requests via MITM proxy",hosts:["daily-cloudcode-pa.googleapis.com","cloudcode-pa.googleapis.com"],urlPatterns:[":generateContent",":streamGenerateContent",":fetchAvailableModels","/v1internal:fetchAvailableModels"],defaultHost:`127.0.0.1 daily-cloudcode-pa.googleapis.com
|
|
2
2
|
127.0.0.1 cloudcode-pa.googleapis.com`,hostRewrite:{"cloudcode-pa.googleapis.com":"daily-cloudcode-pa.googleapis.com"},matchesHost:m=>{const r=(m||"").split(":")[0].trim().toLowerCase();return["cloudcode-pa.googleapis.com","daily-cloudcode-pa.googleapis.com"].some(u=>r===u||r.endsWith("."+u))},isModelListRequest:m=>(m.url||"").toLowerCase().includes("fetchavailablemodels"),modelSynonyms:{"gemini-default":"gemini-3.8-flash-medium","gemini-3.5-flash-high":"gemini-3.8-flash-high","gemini-3.5-flash-medium":"gemini-3.8-flash-medium","gemini-3.5-flash-low":"gemini-3.8-flash-low","gemini-3.5-flash-extra-low":"gemini-3.8-flash-low","gemini-3.8-flash":"gemini-3.8-flash-medium","gemini-3.8-flash-high":"gemini-3.8-flash-high","gemini-3.8-flash-medium":"gemini-3.8-flash-medium","gemini-3.8-flash-low":"gemini-3.8-flash-low","gemini-3.1-pro-high":"gemini-pro-agent","gemini-3-pro-high":"gemini-pro-agent","gemini-3-pro-low":"gemini-3.1-pro-low","claude-sonnet-5-5-max":"claude-sonnet-5-5-max","claude-sonnet-5-5-high":"claude-sonnet-5-5-high","claude-sonnet-5-5-medium":"claude-sonnet-5-5-medium","claude-sonnet-5-5-low":"claude-sonnet-5-5-low","claude-sonnet-5-5":"claude-sonnet-5-5","claude-sonnet-5.5":"claude-sonnet-5-5","claude-sonnet-5.5-max":"claude-sonnet-5-5-max","claude-sonnet-5.5-high":"claude-sonnet-5-5-high","claude-sonnet-5.5-medium":"claude-sonnet-5-5-medium","claude-sonnet-5.5-low":"claude-sonnet-5-5-low","claude-sonnet-5-5-thinking":"claude-sonnet-5-5","claude-sonnet-5.5-thinking":"claude-sonnet-5-5","claude-opus-5-5-max":"claude-opus-5-5-max","claude-opus-5-5-high":"claude-opus-5-5-high","claude-opus-5-5-medium":"claude-opus-5-5-medium","claude-opus-5-5-low":"claude-opus-5-5-low","claude-opus-5-5":"claude-opus-5-5","claude-opus-5.5":"claude-opus-5-5","claude-opus-5.5-max":"claude-opus-5-5-max","claude-opus-5.5-high":"claude-opus-5-5-high","claude-opus-5.5-medium":"claude-opus-5-5-medium","claude-opus-5.5-low":"claude-opus-5-5-low","claude-opus-5-5-thinking":"claude-opus-5-5","claude-opus-5.5-thinking":"claude-opus-5-5","claude-sonnet-4.6":"claude-sonnet-4-6","claude-opus-4.6":"claude-opus-4-6-thinking","claude-opus-4.6-thinking":"claude-opus-4-6-thinking","gemini-4-argon":"gemini-4-argon-medium","gemini-4-argon-high":"gemini-4-argon-high","gemini-4-argon-medium":"gemini-4-argon-medium","gemini-4-argon-low":"gemini-4-argon-low","gemini-4-carbon":"gemini-4-carbon-medium","gemini-4-carbon-high":"gemini-4-carbon-high","gemini-4-carbon-medium":"gemini-4-carbon-medium","gemini-4-carbon-low":"gemini-4-carbon-low","gemini-4-hydrogen":"gemini-4-hydrogen-medium","gemini-4-hydrogen-xhigh":"gemini-4-hydrogen-xhigh","gemini-4-hydrogen-high":"gemini-4-hydrogen-high","gemini-4-hydrogen-medium":"gemini-4-hydrogen-medium","gemini-4-hydrogen-low":"gemini-4-hydrogen-low","gemini-4-neon":"gemini-4-neon-medium","gemini-4-neon-xhigh":"gemini-4-neon-xhigh","gemini-4-neon-high":"gemini-4-neon-high","gemini-4-neon-medium":"gemini-4-neon-medium","gemini-4-neon-low":"gemini-4-neon-low"},modelPatterns:[{match:/flash.*extra.*low|extra.*low.*flash|flash.*low|low.*flash/i,alias:"gemini-3.8-flash-low"},{match:/flash.*medium|medium.*flash/i,alias:"gemini-3.8-flash-medium"},{match:/flash.*agent|agent.*flash|flash/i,alias:"gemini-3.8-flash-high"},{match:/pro.*low|low.*pro/i,alias:"gemini-3.1-pro-low"},{match:/gemini.*pro|pro.*gemini/i,alias:"gemini-pro-agent"},{match:/opus.*5[.-]5.*max|5[.-]5.*opus.*max/i,alias:"claude-opus-5-5-max"},{match:/opus.*5[.-]5.*high|5[.-]5.*opus.*high/i,alias:"claude-opus-5-5-high"},{match:/opus.*5[.-]5.*medium|5[.-]5.*opus.*medium/i,alias:"claude-opus-5-5-medium"},{match:/opus.*5[.-]5.*low|5[.-]5.*opus.*low/i,alias:"claude-opus-5-5-low"},{match:/sonnet.*5[.-]5.*max|5[.-]5.*sonnet.*max/i,alias:"claude-sonnet-5-5-max"},{match:/sonnet.*5[.-]5.*high|5[.-]5.*sonnet.*high/i,alias:"claude-sonnet-5-5-high"},{match:/sonnet.*5[.-]5.*medium|5[.-]5.*sonnet.*medium/i,alias:"claude-sonnet-5-5-medium"},{match:/sonnet.*5[.-]5.*low|5[.-]5.*sonnet.*low/i,alias:"claude-sonnet-5-5-low"},{match:/opus.*5[.-]5|5[.-]5.*opus/i,alias:"claude-opus-5-5"},{match:/sonnet.*5[.-]5|5[.-]5.*sonnet/i,alias:"claude-sonnet-5-5"},{match:/opus/i,alias:"claude-opus-4-6-thinking"},{match:/sonnet|claude/i,alias:"claude-sonnet-4-6"},{match:/gpt.*oss|oss/i,alias:"gpt-oss-120b-medium"},{match:/carbon.*high/i,alias:"gemini-4-carbon-high"},{match:/carbon.*low/i,alias:"gemini-4-carbon-low"},{match:/carbon/i,alias:"gemini-4-carbon-medium"},{match:/hydrogen.*xhigh/i,alias:"gemini-4-hydrogen-xhigh"},{match:/hydrogen.*high/i,alias:"gemini-4-hydrogen-high"},{match:/hydrogen.*low/i,alias:"gemini-4-hydrogen-low"},{match:/hydrogen/i,alias:"gemini-4-hydrogen-medium"},{match:/neon.*xhigh/i,alias:"gemini-4-neon-xhigh"},{match:/neon.*high/i,alias:"gemini-4-neon-high"},{match:/neon.*low/i,alias:"gemini-4-neon-low"},{match:/neon/i,alias:"gemini-4-neon-medium"},{match:/argon.*high|gemini.*4.*high/i,alias:"gemini-4-argon-high"},{match:/argon.*low|gemini.*4.*low/i,alias:"gemini-4-argon-low"},{match:/argon|gemini.*4/i,alias:"gemini-4-argon-medium"}],modelNoMap:[/^tab[_-]/i],defaultModels:["gemini-4-argon","gemini-4-argon-high","gemini-4-argon-medium","gemini-4-argon-low","gemini-4-carbon","gemini-4-carbon-high","gemini-4-carbon-medium","gemini-4-carbon-low","gemini-4-hydrogen","gemini-4-hydrogen-xhigh","gemini-4-hydrogen-high","gemini-4-hydrogen-medium","gemini-4-hydrogen-low","gemini-4-neon","gemini-4-neon-xhigh","gemini-4-neon-high","gemini-4-neon-medium","gemini-4-neon-low","gemini-3.8-flash-high","gemini-3.8-flash-medium","gemini-3.8-flash-low","gemini-3.1-pro-high","gemini-3.1-pro-low","claude-sonnet-5.5-thinking","claude-sonnet-5.5-high","claude-sonnet-5.5-medium","claude-sonnet-5.5-low","claude-opus-5.5-thinking","claude-opus-5.5-high","claude-opus-5.5-medium","claude-opus-5.5-low","claude-sonnet-4.6-thinking","claude-opus-4.6-thinking","gpt-oss-120b-medium"]},Dt={id:"copilot",name:"GitHub Copilot",image:"/assets/providers/github/icon.png",desc:"Intercept GitHub Copilot requests in VS Code via MITM proxy",hosts:["api.githubcopilot.com","copilot-proxy.githubusercontent.com","api.individual.githubcopilot.com","api.business.githubcopilot.com","api.enterprise.githubcopilot.com"],urlPatterns:["/chat/completions","/v1/messages","/responses","/models"],defaultHost:`127.0.0.1 api.githubcopilot.com
|
|
3
3
|
127.0.0.1 copilot-proxy.githubusercontent.com
|
|
4
4
|
127.0.0.1 api.individual.githubcopilot.com
|
|
@@ -11,4 +11,4 @@ import{r as n,j as e}from"./vendor-BcOI2aZ9.js";import{u as kt,D as Ct,d as Mt,P
|
|
|
11
11
|
127.0.0.1 runtime.us-east-1.kiro.dev
|
|
12
12
|
127.0.0.1 q.us-east-1.amazonaws.com
|
|
13
13
|
127.0.0.1 codewhisperer.us-east-1.amazonaws.com`,copilot:"127.0.0.1 api.individual.githubcopilot.com"}),[tt,ce]=n.useState({}),[Be,st]=n.useState({}),[at,Q]=n.useState({}),[nt,H]=n.useState({antigravity:[],kiro:[],copilot:[]}),[it,ot]=n.useState({}),[lt,Ee]=n.useState({}),[rt,de]=n.useState(null),[X,me]=n.useState(null),[ue,Z]=n.useState(""),[L,$]=n.useState(null),[pe,xe]=n.useState(""),[he,ge]=n.useState(""),[Ae,ct]=n.useState(new Set),[q,De]=n.useState(""),[F,Ie]=n.useState(""),[Pe,Re]=n.useState(!1),[Le,_e]=n.useState(!1),[Oe,Ue]=n.useState(!1),[ee,be]=n.useState(null),[te,K]=n.useState(null),[se,dt]=n.useState([]),z=n.useMemo(()=>{const t=q.trim().toLowerCase();return t?!t.includes("127.0.0.1")&&!t.includes("localhost")&&!t.includes("0.0.0.0"):!1},[q]);n.useEffect(()=>{fetch("/api/combos").then(t=>t.ok?t.json():[]).then(t=>{const s=Array.isArray(t)?t:t.combos||[];ct(new Set(s.map(i=>(i.name||"").toLowerCase())))}).catch(()=>{})},[]);const _=(t,s)=>{navigator.clipboard.writeText(s),we(t),setTimeout(()=>we(null),2e3)},A=()=>{fetch("/api/mitm/status").then(t=>t.json()).then(t=>{v(!!t.running),t.port&&j(t.port),le(!!t.certExists),p(!!t.certTrusted),t.certPath&&O(t.certPath),t.fingerprint&&Ye(t.fingerprint),t.routerBaseUrl&&N(t.routerBaseUrl),t.installCommands&&Qe(t.installCommands),t.dnsStatus&&U(s=>{var i,a,d;return{...s,antigravity:!!((i=t.dnsStatus)!=null&&i.antigravity),kiro:!!((a=t.dnsStatus)!=null&&a.kiro),copilot:!!((d=t.dnsStatus)!=null&&d.copilot)}}),t.augmentModels&&V(s=>({...s,...t.augmentModels})),Tt.getState().fetchStatus()}).catch(()=>{}),fetch("/api/mitm/router-target").then(t=>t.ok?t.json():null).then(t=>{t&&(De(t.baseUrl||""),Re(!!t.hasApiKey),t.isRemote&&t.baseUrl&&He())}).catch(()=>{})},He=()=>{fetch("/api/mitm/router-target/models").then(t=>t.ok?t.json():{models:[]}).then(t=>{const s=(t.models||[]).map(i=>({id:i.id,value:i.id,name:i.name||i.id,providerId:i.provider||"remote",providerName:i.provider||"Remote Gateway",hasConnectedAccount:!0,accountsCount:1,caps:{vision:!0,reasoning:!0,audio:!1},contextLength:128e3}));dt(s)}).catch(()=>{})},mt=async()=>{_e(!0),be(null);try{const s=await(await fetch("/api/mitm/router-target/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:q.trim(),apiKey:F.trim()||void 0})})).json();be({success:!!s.success,message:s.message||(s.success?"Connection successful":"Connection failed")}),s.success&&z&&He()}catch(t){be({success:!1,message:(t==null?void 0:t.message)||"Test request failed"})}finally{_e(!1)}},ut=async()=>{if(!x){Ue(!0),K(null);try{const s=await(await fetch("/api/mitm/router-target",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:q.trim(),apiKey:F!==""?F.trim():void 0})})).json();s.success?(K({success:!0,message:"Target configuration saved!"}),Re(!!s.hasApiKey),Ie(""),A()):K({success:!1,message:s.error||"Failed to save target"})}catch(t){K({success:!1,message:(t==null?void 0:t.message)||"Failed to save target"})}finally{Ue(!1),setTimeout(()=>K(null),3e3)}}},pt=()=>{Ve.forEach(t=>{fetch(`/api/mitm/hosts/${t.id}`).then(s=>s.json()).then(s=>{s.entries&&Y(i=>({...i,[t.id]:s.entries}))}).catch(()=>{}),fetch(`/api/mitm/mappings/${t.id}`).then(s=>s.json()).then(s=>{Array.isArray(s)&&H(i=>({...i,[t.id]:s}))}).catch(()=>{})})};n.useEffect(()=>{A(),pt()},[]);const ae=async(t=!1,s)=>{h(null);let i;if(s!==void 0)i=s;else if(y.trim()){const a=Number(y.trim());if(isNaN(a)||!Number.isInteger(a)||a<1||a>65535){h("Port must be an integer between 1 and 65535.");return}i=a}if(x&&!t){v(!1);try{const d=await(await fetch("/api/mitm/toggle-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({running:!1})})).json();v(!!d.running),d.port&&j(d.port),d.dnsStatus&&U({antigravity:!!d.dnsStatus.antigravity,kiro:!!d.dnsStatus.kiro,copilot:!!d.dnsStatus.copilot}),A()}catch(a){h((a==null?void 0:a.message)||"Failed to stop server")}return}t&&M(!0);try{const a=await fetch("/api/mitm/toggle-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({running:!0,port:i,forceKill:t})});if(a.status===409){const B=await a.json();g(B.portOwner||{port:i||443,inUse:!0}),v(!1);return}if(!a.ok){const B=await a.json().catch(()=>({}));throw new Error(B.error||`Failed to start server (${a.status})`)}const d=await a.json();v(!!d.running),d.port&&j(d.port),d.dnsStatus&&U({antigravity:!!d.dnsStatus.antigravity,kiro:!!d.dnsStatus.kiro,copilot:!!d.dnsStatus.copilot}),d.warning&&h(d.warning),g(null),A()}catch(a){h((a==null?void 0:a.message)||"Failed to start server")}finally{M(!1)}},xt=async()=>{Se(!0),k(null);try{const s=await(await fetch("/api/mitm/install-cert",{method:"POST"})).json();s.success?(k({type:"success",text:s.message||"Root CA installed successfully!"}),A()):k({type:"error",text:s.message||"Installation failed"})}catch(t){k({type:"error",text:(t==null?void 0:t.message)||"Failed to install certificate"})}finally{Se(!1)}},ht=async()=>{Ce(!0),k(null);try{const s=await(await fetch("/api/mitm/uninstall-cert",{method:"POST"})).json();s.success?(k({type:"success",text:s.message||"Root CA uninstalled successfully!"}),A()):k({type:"error",text:s.message||"Uninstallation failed"})}catch(t){k({type:"error",text:(t==null?void 0:t.message)||"Failed to uninstall certificate"})}finally{Ce(!1)}},gt=async t=>{const s=!Me[t];U(i=>({...i,[t]:s}));try{const a=await(await fetch("/api/mitm/toggle-dns",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:t,active:s})})).json();a.dnsStatus&&U(d=>({...d,antigravity:!!a.dnsStatus.antigravity,kiro:!!a.dnsStatus.kiro,copilot:!!a.dnsStatus.copilot})),a.warning&&h(a.warning),A()}catch{}},bt=async t=>{const s=!R[t];V(i=>({...i,[t]:s}));try{const a=await(await fetch("/api/mitm/augment-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:t,enabled:s})})).json();a.augmentModels&&V(d=>({...d,...a.augmentModels}))}catch{V(i=>({...i,[t]:!s}))}},ft=async t=>{const s=Te[t]||"";try{(await fetch(`/api/mitm/hosts/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:s})})).ok&&(Q(a=>({...a,[t]:"Saved hosts successfully."})),ce(a=>({...a,[t]:!1})),setTimeout(()=>{Q(a=>({...a,[t]:null}))},3e3))}catch{}},yt=async t=>{try{const i=await(await fetch(`/api/mitm/hosts/${t}/reset`,{method:"POST"})).json();i.entries&&(Y(a=>({...a,[t]:i.entries})),Q(a=>({...a,[t]:"Hosts reset to default."})),setTimeout(()=>{Q(a=>({...a,[t]:null}))},3e3))}catch{}},jt=async t=>{try{const i=await(await fetch("/api/mitm/mappings/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ide:t})})).json();Array.isArray(i.mappings)&&H(a=>({...a,[t]:i.mappings}))}catch{}},Nt=async()=>{if(!L||!pe.trim()||!he.trim())return;const t=L,s={sourceModel:pe.trim(),targetModel:he.trim()};H(i=>({...i,[t]:[...i[t]||[],s]}));try{await fetch("/api/mitm/mappings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ide:t,sourceModel:s.sourceModel,targetModel:s.targetModel})})}catch{}finally{xe(""),ge(""),$(null)}},$e=async t=>{if(!X||!ue.trim())return;let s=ue.trim();Ae.has(s.toLowerCase())&&!s.startsWith("combo/")&&(s=`combo/${s}`),H(i=>({...i,[t]:(i[t]||[]).map(a=>a.sourceModel===X?{...a,targetModel:s}:a)}));try{await fetch("/api/mitm/mappings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ide:t,sourceModel:X,targetModel:s})})}catch{}finally{me(null),de(null),Z("")}},wt=(t,s)=>{H(i=>({...i,[t]:(i[t]||[]).filter(a=>a.sourceModel!==s)})),fetch(`/api/mitm/mappings/${t}?sourceModel=${encodeURIComponent(s)}`,{method:"DELETE"}).catch(()=>{})};return e.jsxs("div",{className:"space-y-6 w-full px-2 sm:px-4 pb-16 animate-rt-fade-in",children:[e.jsxs("div",{className:"flex items-start gap-2.5 px-4 py-3 rounded-xl bg-amber-500/10 border border-amber-500/20 text-xs text-amber-300 leading-relaxed",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] text-amber-400 shrink-0",children:"warning"}),e.jsxs("p",{children:[e.jsx("strong",{children:"MITM Interceptor:"})," Intercepts HTTPS traffic of closed IDE tools (Antigravity, Kiro, GitHub Copilot) via a local Root CA to redirect requests to your chosen providers and models. DNS is controlled independently per tool."]})]}),e.jsxs("div",{className:"flex items-start gap-2.5 px-4 py-3 rounded-xl bg-blue-500/10 border border-blue-500/20 text-xs text-blue-300 leading-relaxed",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] text-blue-400 shrink-0",children:"info"}),e.jsx("p",{className:"font-mono text-[11px] sm:text-xs text-blue-200",children:"How it works: Antigravity/Kiro IDE request → DNS redirect to localhost:443 → MITM proxy intercepts → Mapigate → response to Antigravity/Kiro"})]}),e.jsxs("div",{className:"rt-card p-5 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 pb-3 border-b border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-9 rounded-xl bg-cyan-500/10 border border-cyan-500/20 text-cyan-400 flex items-center justify-center shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"alt_route"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-sm font-bold text-white",children:"MITM HTTPS Proxy Server"}),e.jsx("span",{className:`rt-badge ${x?"rt-badge--success":"rt-badge--muted"}`,children:x?`● Running (Port :${f})`:"Stopped"})]}),e.jsxs("p",{className:"text-xs text-slate-400 mt-0.5",children:["Intercepts inbound IDE requests via SNI certificate emulation on port ",f,"."]})]})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("button",{onClick:()=>ae(),className:`rt-btn text-xs py-1.5 px-3.5 ${x?"rt-btn--danger":"rt-btn--primary"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:x?"stop":"play_arrow"}),x?"Stop Server":"Start Server"]})})]}),I&&e.jsxs("div",{className:"p-3 rounded-xl bg-rose-500/10 border border-rose-500/30 text-xs text-rose-300 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-rose-400",children:"error"}),e.jsx("span",{children:I})]}),e.jsx("button",{type:"button",onClick:()=>h(null),className:"text-rose-400 hover:text-white",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"close"})})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 pt-1 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"font-semibold text-slate-300",children:"Active Gateway Endpoint:"}),e.jsx("code",{className:"text-blue-400 font-mono bg-[#0A0D14] px-3 py-1.5 rounded-lg border border-[#1E293B]",children:w})]}),e.jsx("span",{className:"text-[11px] text-slate-400 italic",children:"Enable DNS per tool below to activate redirection"})]}),e.jsx("div",{className:"pt-3 border-t border-[#1E293B]",children:e.jsxs("div",{className:"p-3.5 bg-[#0A0D14] rounded-xl border border-[#1E293B] space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] text-cyan-400",children:"hub"}),e.jsx("span",{className:"text-xs font-bold text-white",children:"Target Gateway"}),z?e.jsx("span",{className:"rt-badge rt-badge--info",children:"Remote Machine"}):e.jsx("span",{className:"rt-badge rt-badge--success",children:"Local Machine"})]}),x&&e.jsxs("span",{className:"text-[11px] text-amber-400/90 flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"lock"}),"Stop server to edit target configuration"]})]}),e.jsx("p",{className:"text-[11.5px] text-slate-400 leading-relaxed",children:"Specify where intercepted prompts are forwarded. Leave URL blank to route to this machine's local Mapigate Gateway, or enter another IP/URL to delegate requests to a remote machine."}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 pt-1",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-semibold text-slate-300 block mb-1",children:"Gateway Base URL"}),e.jsx("input",{type:"text",placeholder:`Leave blank for local (${w})`,value:q,disabled:x,onChange:t=>De(t.target.value),className:"w-full bg-[#141B2D] border border-[#1E293B] rounded-lg px-2.5 py-1.5 text-xs font-mono text-white placeholder-slate-500 focus:outline-none focus:border-blue-500 disabled:opacity-50 disabled:cursor-not-allowed"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[11px] font-semibold text-slate-300 block mb-1",children:["Gateway API Key ",Pe&&!F&&"(Configured ✓)"]}),e.jsx("input",{type:"password",disabled:x,placeholder:Pe?"•••••••••••• (Leave blank to keep)":z?"Optional (Required if Target requires key)":"Optional (Dedicated MITM key used by default)",value:F,onChange:t=>Ie(t.target.value),className:"w-full bg-[#141B2D] border border-[#1E293B] rounded-lg px-2.5 py-1.5 text-xs font-mono text-white placeholder-slate-500 focus:outline-none focus:border-blue-500 disabled:opacity-50 disabled:cursor-not-allowed"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 pt-1",children:[e.jsxs("div",{className:"text-xs",children:[ee&&e.jsxs("span",{className:`inline-flex items-center gap-1 text-[11.5px] ${ee.success?"text-emerald-400":"text-rose-400"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:ee.success?"check_circle":"cancel"}),ee.message]}),te&&e.jsxs("span",{className:`inline-flex items-center gap-1 text-[11.5px] ${te.success?"text-emerald-400":"text-rose-400"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:te.success?"check":"error"}),te.message]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",disabled:Le,onClick:mt,className:"rt-btn rt-btn--secondary text-xs py-1 px-3 flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"network_check"}),Le?"Testing...":"Test Connection"]}),e.jsxs("button",{type:"button",disabled:Oe||x,title:x?"Stop MITM server before editing target configuration":void 0,onClick:ut,className:"rt-btn rt-btn--primary text-xs py-1 px-3.5 flex items-center gap-1 disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"save"}),Oe?"Saving...":"Save Target"]})]})]})]})}),e.jsxs("div",{className:"pt-2 border-t border-[#1E293B]/60",children:[e.jsxs("button",{type:"button",onClick:()=>oe(t=>!t),className:"flex items-center gap-1.5 text-xs text-slate-400 hover:text-slate-200 transition-colors cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:E?"expand_less":"tune"}),e.jsx("span",{children:"Advanced / Custom Port Configuration"})]}),E&&e.jsxs("div",{className:"mt-3 p-3.5 bg-[#0A0D14] rounded-xl border border-[#1E293B] space-y-3",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-3 justify-between",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-slate-300 block",children:"Custom MITM Listen Port"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Default is port 443. Custom ports are for manual developer testing only."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",min:"1",max:"65535",placeholder:"443",value:y,onChange:t=>S(t.target.value),disabled:x,className:"w-24 bg-[#141B2D] border border-[#1E293B] rounded-lg px-2.5 py-1.5 text-xs font-mono text-white text-center focus:outline-none focus:border-blue-500 disabled:opacity-50"}),!x&&y&&e.jsx("button",{type:"button",onClick:()=>S(""),className:"text-xs text-slate-400 hover:text-white px-1.5 py-1 rounded",title:"Reset to default 443",children:"Reset"})]})]}),e.jsxs("div",{className:"flex items-start gap-2 p-2.5 rounded-lg bg-amber-500/10 border border-amber-500/20 text-[11.5px] text-amber-300 leading-relaxed",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-amber-400 shrink-0 mt-0.5",children:"warning"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Notice:"})," OS ",e.jsx("code",{children:"hosts"})," file redirection maps domain names to IP addresses without port numbers. AI coding tools (Antigravity, Kiro, Copilot) connect to port 443 by default. Running on custom ports will ",e.jsx("strong",{children:"not"})," intercept standard IDE traffic."]})]})]})]})]}),e.jsxs("div",{className:"rt-card p-5 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 pb-3 border-b border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-9 rounded-xl bg-purple-500/10 border border-purple-500/20 text-purple-400 flex items-center justify-center shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"verified_user"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"text-sm font-bold text-white",children:"SSL Root CA Certificate"}),o?e.jsxs("span",{className:"rt-badge rt-badge--success",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"check"})," Trusted in System"]}):e.jsxs("span",{className:"rt-badge rt-badge--warning",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"info"})," Not Yet Trusted"]}),W&&e.jsx("span",{className:"rt-badge rt-badge--info",children:"Generated"})]}),e.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:"Required for IDEs to accept MITM proxy SSL handshakes without security warnings."})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:async()=>{try{const t=await fetch("/api/mitm/cert");if(!t.ok)throw new Error(`HTTP ${t.status}`);const s=await t.blob(),i=URL.createObjectURL(s),a=document.createElement("a");a.href=i,a.download="mapigate-rootCA.crt",document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}catch(t){k({type:"error",text:(t==null?void 0:t.message)||"Failed to download Root CA certificate."})}},className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"download"}),"Download CA"]}),o?e.jsxs("button",{disabled:ke,onClick:ht,className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3.5 flex items-center gap-1.5 text-rose-400 hover:text-rose-300 border-rose-500/20",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"delete"}),ke?"Uninstalling...":"Uninstall from System"]}):e.jsxs("button",{disabled:ve,onClick:xt,className:"rt-btn rt-btn--primary text-xs py-1.5 px-3.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"add_task"}),ve?"Installing...":"Install to System Store"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 text-xs",children:[e.jsxs("div",{className:"p-3 bg-[#0A0D14] rounded-xl border border-[#1E293B] space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-400 font-medium",children:"SHA1 Fingerprint:"}),re&&e.jsxs("button",{onClick:()=>_("fp",re),className:"text-blue-400 hover:text-blue-300 font-mono text-[11px] flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"content_copy"}),P==="fp"?"Copied":"Copy"]})]}),e.jsx("code",{className:"text-purple-300 font-mono text-[11px] block break-all",children:re||"Generating upon first start..."})]}),e.jsxs("div",{className:"p-3 bg-[#0A0D14] rounded-xl border border-[#1E293B] space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-400 font-medium",children:"CA File Path:"}),T&&e.jsxs("button",{onClick:()=>_("cp",T),className:"text-blue-400 hover:text-blue-300 font-mono text-[11px] flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"content_copy"}),P==="cp"?"Copied":"Copy"]})]}),e.jsx("code",{className:"text-slate-300 font-mono text-[11px] block truncate",children:T||"~/.mapigate/mitm/rootCA.crt"})]})]}),e.jsxs("div",{className:"space-y-2 text-xs",children:[e.jsx("span",{className:"font-semibold text-slate-300 block",children:"Manual Installation Commands:"}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-2.5",children:[e.jsxs("div",{className:"p-3 rounded-xl bg-[#0A0D14] border border-[#1E293B] space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-400 font-medium",children:"Windows (PowerShell / cmd):"}),e.jsxs("button",{onClick:()=>_("winCmd",G.windows),className:"text-blue-400 hover:text-blue-300 font-mono text-[11px] flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"content_copy"}),P==="winCmd"?"Copied!":"Copy"]})]}),e.jsx("code",{className:"text-emerald-400 font-mono text-[11px] block break-all bg-[#05070B] p-2 rounded-lg border border-[#1E293B]",children:G.windows})]}),e.jsxs("div",{className:"p-3 rounded-xl bg-[#0A0D14] border border-[#1E293B] space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-400 font-medium",children:"macOS (Terminal):"}),e.jsxs("button",{onClick:()=>_("macCmd",G.mac),className:"text-blue-400 hover:text-blue-300 font-mono text-[11px] flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"content_copy"}),P==="macCmd"?"Copied!":"Copy"]})]}),e.jsx("code",{className:"text-emerald-400 font-mono text-[11px] block break-all bg-[#05070B] p-2 rounded-lg border border-[#1E293B]",children:G.mac})]})]})]}),J&&e.jsxs("div",{className:`p-2.5 rounded-xl text-xs flex items-center gap-2 ${J.type==="success"?"bg-emerald-500/10 border border-emerald-500/20 text-emerald-400":"bg-red-500/10 border border-red-500/20 text-red-400"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:J.type==="success"?"check_circle":"error"}),J.text]})]}),e.jsx("div",{className:"space-y-4",children:et.map(t=>{const s=Xe===t.id,i=!!Me[t.id],a=!!tt[t.id],d=Te[t.id]||t.defaultHost,B=it[t.id]||"source",ne=lt[t.id]||"asc",qe=Pt(nt[t.id]||[],B,ne),Fe=at[t.id],Ke=l=>{B===l?Ee(C=>({...C,[t.id]:ne==="asc"?"desc":"asc"})):(ot(C=>({...C,[t.id]:l})),Ee(C=>({...C,[t.id]:"asc"})))};return e.jsxs("div",{className:"rt-card p-5 space-y-4",children:[e.jsxs("div",{onClick:()=>Ze(s?null:t.id),className:"flex items-center justify-between cursor-pointer select-none",children:[e.jsxs("div",{className:"flex items-center gap-3.5",children:[e.jsx(Bt,{src:t.image,name:t.name,iconBg:t.iconBg,size:"md"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"text-sm font-bold text-white",children:t.name}),e.jsx("span",{className:`rt-badge ${i?"rt-badge--success":"rt-badge--muted"}`,children:i?"DNS on":"DNS off"})]}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:t.desc})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:l=>{l.stopPropagation(),gt(t.id)},className:`rt-btn text-xs py-1.5 px-3 ${i?"rt-btn--danger":"rt-btn--primary"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:i?"stop":"play_arrow"}),i?"Stop DNS":"Start DNS"]}),e.jsx("span",{className:"material-symbols-outlined text-[20px] text-slate-500",children:s?"expand_less":"expand_more"})]})]}),s&&e.jsxs("div",{className:"pt-4 border-t border-[#1E293B] space-y-5 text-xs animate-rt-fade-in",children:[e.jsxs("div",{className:"space-y-3 p-4 rounded-xl bg-[#0A0D14] border border-[#1E293B]",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs("h5",{className:"font-bold text-white flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-blue-400 text-[16px]",children:"dns"}),"Hosts File Entries (",t.name,")"]}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Domain mappings added to your system hosts file when DNS redirection is enabled."})]}),e.jsx("div",{className:"flex items-center gap-2",children:a?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{Be[t.id]!==void 0&&Y(l=>({...l,[t.id]:Be[t.id]})),ce(l=>({...l,[t.id]:!1}))},className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"close"}),"Cancel"]}),e.jsxs("button",{onClick:()=>ft(t.id),className:"rt-btn rt-btn--primary text-xs py-1.5 px-3 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"save"}),"Save Hosts"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>yt(t.id),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3 flex items-center gap-1.5",title:"Reset hosts entries to tool default",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"}),"Reset"]}),e.jsxs("button",{onClick:()=>{st(l=>({...l,[t.id]:d})),ce(l=>({...l,[t.id]:!0}))},className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"edit"}),"Edit"]})]})})]}),e.jsx("textarea",{readOnly:!a,rows:Math.max(2,d.split(`
|
|
14
|
-
`).length+1),value:d,onChange:l=>Y(C=>({...C,[t.id]:l.target.value})),className:`w-full border rounded-xl p-3 text-xs font-mono leading-relaxed transition-colors ${a?"bg-[#05070B] border-blue-500/60 text-emerald-400 cursor-text focus:outline-none focus:border-blue-500":"bg-[#07090E] border-[#1E293B] text-emerald-400/80 cursor-default focus:outline-none"}`,placeholder:"127.0.0.1 domain"}),Fe&&e.jsxs("div",{className:"text-[11px] text-emerald-400 font-mono flex items-center gap-1.5 animate-rt-scale-in",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"check_circle"}),Fe]})]}),(t.id==="kiro"||!!t.isModelListRequest)&&e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 p-4 rounded-xl bg-[#0A0D14] border border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-start sm:items-center gap-3",children:[e.jsx("div",{className:"size-8 rounded-lg bg-purple-500/10 border border-purple-500/20 text-purple-400 flex items-center justify-center shrink-0 mt-0.5 sm:mt-0",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"auto_awesome"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-bold text-white text-xs",children:"Augment Models in IDE"}),e.jsx("span",{className:`rt-badge ${R[t.id]?"rt-badge--success":"rt-badge--muted"}`,children:R[t.id]?"Enabled":"Disabled"})]}),e.jsxs("p",{className:"text-[11px] text-slate-400 mt-0.5",children:["Injects Mapigate's rich model catalog into ",t.name," so you can select from all models in the IDE regardless of your account's tier."]})]})]}),e.jsxs("button",{type:"button",onClick:()=>bt(t.id),className:`rt-btn text-xs py-1.5 px-3.5 shrink-0 flex items-center gap-1.5 cursor-pointer ${R[t.id]?"rt-btn--primary":"rt-btn--secondary"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:R[t.id]?"toggle_on":"toggle_off"}),R[t.id]?"Enabled":"Enable"]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-bold text-slate-200 block text-xs",children:["Model Redirection Mappings (",t.name,")"]}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Map requested models to your chosen Mapigate providers and upstream model IDs (slashes / supported)."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>jt(t.id),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",title:"Reset to default mappings",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"}),"Reset to Default"]}),e.jsxs("button",{onClick:()=>{$(t.id),xe(""),ge("")},className:"rt-btn rt-btn--primary text-xs py-1.5 px-3",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"add"}),"Add Mapping"]})]})]}),e.jsx("div",{className:"rounded-xl border border-[#1E293B] overflow-visible bg-[#0A0D14]",children:qe.length===0?e.jsxs("div",{className:"p-4 text-xs text-slate-500 italic text-center",children:["No model mappings configured for ",t.name,". Click 'Add Mapping' or 'Reset to Default'."]}):e.jsxs("table",{className:"w-full text-left text-xs font-mono",children:[e.jsx("thead",{className:"bg-[#0D121F] text-slate-400 font-sans text-[11px] uppercase tracking-wider border-b border-[#1E293B]",children:e.jsxs("tr",{children:[e.jsx("th",{onClick:()=>Ke("source"),className:"p-3 font-semibold cursor-pointer hover:text-white select-none transition-colors",title:"Click to sort by Source Model",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:"Source Model (IDE)"}),e.jsx("span",{className:"material-symbols-outlined text-[14px] text-blue-400",children:B==="source"?ne==="asc"?"arrow_upward":"arrow_downward":"unfold_more"})]})}),e.jsx("th",{onClick:()=>Ke("target"),className:"p-3 font-semibold cursor-pointer hover:text-white select-none transition-colors",title:"Click to sort by Target Model",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:"Target Model (Mapigate)"}),e.jsx("span",{className:"material-symbols-outlined text-[14px] text-blue-400",children:B==="target"?ne==="asc"?"arrow_upward":"arrow_downward":"unfold_more"})]})}),e.jsx("th",{className:"p-3 font-semibold text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-[#1E293B]",children:qe.map((l,C)=>{const fe=rt===t.id&&X===l.sourceModel,ye=Je(l.sourceModel),vt=!!(ye&&ye!==l.sourceModel),je=l.targetModel?Je(l.targetModel):"",ze=!!(l.targetModel&&(l.targetModel.startsWith("combo/")||Ae.has(l.targetModel.toLowerCase()))),ie=ze&&!l.targetModel.startsWith("combo/")?`combo/${l.targetModel}`:l.targetModel,St=!!(ie&&je&&je!==ie);return e.jsxs("tr",{className:`transition-colors ${fe?"bg-blue-500/10":"hover:bg-white/5"}`,children:[e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-slate-100 font-sans font-semibold text-xs leading-snug",children:ye||l.sourceModel}),vt&&e.jsx("span",{className:"text-[10.5px] font-mono text-slate-400",children:l.sourceModel})]})}),e.jsx("td",{className:"p-3 text-blue-400",children:fe?e.jsxs("div",{className:"flex items-center gap-1.5 w-full max-w-sm",children:[e.jsx("span",{className:"text-blue-400 font-mono",children:"→"}),e.jsx(Ge,{value:ue,onChange:Z,onEnter:()=>$e(t.id),placeholder:"Search model or type ID...",fetchCustomModels:z&&se.length>0?()=>Promise.resolve(se):void 0,className:"bg-[#080B11] border border-blue-500/60 focus:border-blue-400 rounded-lg px-2.5 py-1 text-xs text-white font-mono w-full focus:outline-none",autoFocus:!0})]}):l.targetModel?e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("div",{className:"inline-flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-slate-500 font-mono",children:"→"}),ze&&e.jsx("span",{className:"px-1.5 py-0.2 rounded bg-cyan-500/20 border border-cyan-500/40 text-[9.5px] font-mono text-cyan-300 font-semibold tracking-wide",children:"COMBO"}),e.jsx("span",{className:"text-emerald-300 font-sans font-semibold text-xs leading-snug",children:je||ie})]}),St&&e.jsx("span",{className:"text-[10.5px] font-mono text-slate-400 pl-4",children:ie})]}):e.jsx("span",{className:"text-slate-500 italic text-xs px-2 py-0.5 rounded bg-slate-800/60 border border-slate-700/40",children:"(unmapped)"})}),e.jsx("td",{className:"p-3 text-right space-x-2 whitespace-nowrap",children:fe?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>$e(t.id),className:"px-2.5 py-1 rounded bg-blue-600 hover:bg-blue-500 text-white font-sans text-[11px] font-medium transition-colors cursor-pointer",children:"Save"}),e.jsx("button",{onClick:()=>{me(null),de(null),Z("")},className:"px-2.5 py-1 rounded bg-[#0E1320] hover:bg-slate-700 border border-[#1E293B] text-slate-400 hover:text-white font-sans text-[11px] transition-colors cursor-pointer",children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{de(t.id),me(l.sourceModel),Z(l.targetModel)},className:"px-2.5 py-1 rounded bg-[#0E1320] hover:bg-blue-600 hover:text-white border border-[#1E293B] text-slate-300 transition-colors cursor-pointer font-sans text-[11px]",children:"Edit"}),e.jsx("button",{onClick:()=>wt(t.id,l.sourceModel),className:"p-1 text-slate-500 hover:text-red-400 transition-colors",title:"Delete mapping",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"close"})})]})})]},C)})})]})})]})]})]},t.id)})}),e.jsx(We,{isOpen:!!L,onClose:()=>$(null),maxWidthClass:"max-w-md",children:L&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-[#1E293B]",children:[e.jsxs("h4",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-blue-400 text-[18px]",children:"add_circle"}),"Add Model Mapping (",L.toUpperCase(),")"]}),e.jsx("button",{onClick:()=>$(null),className:"text-slate-400 hover:text-white p-1 rounded-lg hover:bg-white/10",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-300 mb-1",children:"Source Model ID (Sent by IDE)"}),e.jsx(Et,{toolId:L,value:pe,onChange:xe,placeholder:"Select or type model ID (e.g. auto, claude-sonnet-4.5)..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-300 mb-1",children:"Target Upstream Model ID (Mapigate Provider Model)"}),e.jsx(Ge,{value:he,onChange:ge,placeholder:"Search model or type ID...",fetchCustomModels:z&&se.length>0?()=>Promise.resolve(se):void 0}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Supports slash / formats, e.g. provider/model-name."})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-[#1E293B]",children:[e.jsx("button",{onClick:()=>$(null),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",children:"Cancel"}),e.jsx("button",{onClick:Nt,className:"rt-btn rt-btn--primary text-xs py-1.5 px-4",children:"Add Mapping"})]})]})}),e.jsx(We,{isOpen:!!c,onClose:()=>g(null),maxWidthClass:"max-w-md",children:c&&(()=>{var s;const t=!!c.isTransient||c.pid===0||!!((s=c.processName)!=null&&s.toLowerCase().includes("idle"));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`material-symbols-outlined text-[20px] ${t?"text-blue-400":c.isSystemProcess?"text-rose-400":"text-amber-400"}`,children:t?"hourglass_top":c.isSystemProcess?"gpp_bad":"warning"}),e.jsxs("h4",{className:"text-sm font-bold text-white",children:["Port ",c.port," ",t?"Socket Releasing":c.isSystemProcess?"System Conflict":"Already In Use"]})]}),e.jsx("button",{onClick:()=>g(null),className:"text-slate-400 hover:text-white p-1 rounded-lg hover:bg-white/10",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),t?e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsxs("div",{className:"p-3.5 bg-blue-500/10 border border-blue-500/30 rounded-xl space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-blue-300 font-semibold",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"hourglass_top"}),e.jsx("span",{children:"Socket Releasing (TIME_WAIT)"})]}),e.jsxs("p",{className:"text-slate-300 text-[11.5px] leading-relaxed",children:["Port ",c.port," is currently releasing from a recent restart (",e.jsx("strong",{className:"text-white",children:"TCP TIME_WAIT"}),"). The operating system will free this socket in a few seconds. Click ",e.jsx("strong",{children:"Retry"})," to start the MITM server."]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-[#1E293B]",children:[e.jsx("button",{type:"button",onClick:()=>g(null),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:()=>ae(!1,c.port),className:"rt-btn rt-btn--primary text-xs py-1.5 px-3.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"}),"Retry"]})]})]}):c.isSystemProcess?e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsxs("div",{className:"p-3.5 bg-rose-500/10 border border-rose-500/30 rounded-xl space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-rose-300 font-semibold",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"admin_panel_settings"}),e.jsx("span",{children:"Windows Kernel / System Service Conflict"})]}),e.jsxs("p",{className:"text-slate-300 text-[11.5px] leading-relaxed",children:["Port ",c.port," is occupied by"," ",e.jsx("strong",{children:c.processName||"System"})," (PID ",c.pid??4,"). This is a Windows system kernel service (e.g. ",e.jsx("code",{children:"HTTP.sys"}),", IIS, or Web Publishing Service) and cannot be killed directly."]})]}),e.jsxs("div",{className:"p-3 bg-[#0A0D14] border border-[#1E293B] rounded-xl space-y-2",children:[e.jsx("span",{className:"text-slate-400 text-[11px] font-semibold block",children:"Run these commands as Administrator to release the port:"}),e.jsxs("div",{className:"space-y-1.5 font-mono text-[11px]",children:[e.jsxs("div",{className:"flex items-center justify-between bg-[#141B2D] px-2.5 py-1.5 rounded-lg border border-[#1E293B]",children:[e.jsx("code",{className:"text-cyan-300",children:"iisreset /stop"}),e.jsx("button",{type:"button",onClick:()=>_("iisreset","iisreset /stop"),className:"text-slate-400 hover:text-white ml-2 shrink-0",title:"Copy command",children:e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:P==="iisreset"?"check":"content_copy"})})]}),e.jsxs("div",{className:"flex items-center justify-between bg-[#141B2D] px-2.5 py-1.5 rounded-lg border border-[#1E293B]",children:[e.jsx("code",{className:"text-cyan-300",children:"net stop w3svc"}),e.jsx("button",{type:"button",onClick:()=>_("w3svc","net stop w3svc"),className:"text-slate-400 hover:text-white ml-2 shrink-0",title:"Copy command",children:e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:P==="w3svc"?"check":"content_copy"})})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-[#1E293B]",children:[e.jsx("button",{type:"button",onClick:()=>g(null),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:()=>ae(!1,c.port),className:"rt-btn rt-btn--primary text-xs py-1.5 px-3.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"}),"Retry"]})]})]}):e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsxs("div",{className:"p-3.5 bg-amber-500/10 border border-amber-500/30 rounded-xl space-y-2",children:[e.jsxs("p",{className:"text-slate-300 text-[11.5px] leading-relaxed",children:["Port ",c.port," is currently used by another process:"]}),e.jsxs("div",{className:"p-2.5 bg-[#0A0D14] rounded-lg border border-[#1E293B] font-mono text-xs text-amber-200",children:[e.jsxs("div",{children:["Process: ",e.jsx("strong",{className:"text-white",children:c.processName||"Unknown"})]}),e.jsxs("div",{children:["PID: ",e.jsx("strong",{className:"text-white",children:c.pid??"Unknown"})]})]}),e.jsxs("p",{className:"text-slate-400 text-[11px]",children:["Kill this process to start MITM Proxy on port ",c.port,"?"]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-[#1E293B]",children:[e.jsx("button",{type:"button",onClick:()=>g(null),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",children:"Cancel"}),e.jsxs("button",{type:"button",disabled:D,onClick:()=>ae(!0,c.port),className:"rt-btn rt-btn--danger text-xs py-1.5 px-3.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:D?"hourglass_empty":"power_settings_new"}),D?"Terminating...":"Kill & Start"]})]})]})]})})()})]})};export{$t as MitmTab};
|
|
14
|
+
`).length+1),value:d,onChange:l=>Y(C=>({...C,[t.id]:l.target.value})),className:`w-full border rounded-xl p-3 text-xs font-mono leading-relaxed transition-colors ${a?"bg-[#05070B] border-blue-500/60 text-emerald-400 cursor-text focus:outline-none focus:border-blue-500":"bg-[#07090E] border-[#1E293B] text-emerald-400/80 cursor-default focus:outline-none"}`,placeholder:"127.0.0.1 domain"}),Fe&&e.jsxs("div",{className:"text-[11px] text-emerald-400 font-mono flex items-center gap-1.5 animate-rt-scale-in",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"check_circle"}),Fe]})]}),(t.id==="kiro"||!!t.isModelListRequest)&&e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 p-4 rounded-xl bg-[#0A0D14] border border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-start sm:items-center gap-3",children:[e.jsx("div",{className:"size-8 rounded-lg bg-purple-500/10 border border-purple-500/20 text-purple-400 flex items-center justify-center shrink-0 mt-0.5 sm:mt-0",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"auto_awesome"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-bold text-white text-xs",children:"Augment Models in IDE"}),e.jsx("span",{className:`rt-badge ${R[t.id]?"rt-badge--success":"rt-badge--muted"}`,children:R[t.id]?"Enabled":"Disabled"})]}),e.jsxs("p",{className:"text-[11px] text-slate-400 mt-0.5",children:["Injects Mapigate's rich model catalog into ",t.name," so you can select from all models in the IDE regardless of your account's tier."]})]})]}),e.jsxs("button",{type:"button",onClick:()=>bt(t.id),className:`rt-btn text-xs py-1.5 px-3.5 shrink-0 flex items-center gap-1.5 cursor-pointer ${R[t.id]?"rt-btn--primary":"rt-btn--secondary"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:R[t.id]?"toggle_on":"toggle_off"}),R[t.id]?"Enabled":"Enable"]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-bold text-slate-200 block text-xs",children:["Model Redirection Mappings (",t.name,")"]}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Map requested models to your chosen Mapigate providers and upstream model IDs (slashes / supported)."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>jt(t.id),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",title:"Reset to default mappings",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"}),"Reset to Default"]}),e.jsxs("button",{onClick:()=>{$(t.id),xe(""),ge("")},className:"rt-btn rt-btn--primary text-xs py-1.5 px-3",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"add"}),"Add Mapping"]})]})]}),e.jsx("div",{className:"rounded-xl border border-[#1E293B] overflow-visible bg-[#0A0D14]",children:qe.length===0?e.jsxs("div",{className:"p-4 text-xs text-slate-500 italic text-center",children:["No model mappings configured for ",t.name,". Click 'Add Mapping' or 'Reset to Default'."]}):e.jsxs("table",{className:"w-full text-left text-xs font-mono",children:[e.jsx("thead",{className:"bg-[#0D121F] text-slate-400 font-sans text-[11px] uppercase tracking-wider border-b border-[#1E293B]",children:e.jsxs("tr",{children:[e.jsx("th",{onClick:()=>Ke("source"),className:"p-3 font-semibold cursor-pointer hover:text-white select-none transition-colors",title:"Click to sort by Source Model",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:"Source Model (IDE)"}),e.jsx("span",{className:"material-symbols-outlined text-[14px] text-blue-400",children:B==="source"?ne==="asc"?"arrow_upward":"arrow_downward":"unfold_more"})]})}),e.jsx("th",{onClick:()=>Ke("target"),className:"p-3 font-semibold cursor-pointer hover:text-white select-none transition-colors",title:"Click to sort by Target Model",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:"Target Model (Mapigate)"}),e.jsx("span",{className:"material-symbols-outlined text-[14px] text-blue-400",children:B==="target"?ne==="asc"?"arrow_upward":"arrow_downward":"unfold_more"})]})}),e.jsx("th",{className:"p-3 font-semibold text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-[#1E293B]",children:qe.map((l,C)=>{const fe=rt===t.id&&X===l.sourceModel,ye=Je(l.sourceModel),vt=!!(ye&&ye!==l.sourceModel),je=l.targetModel?Je(l.targetModel):"",ze=!!(l.targetModel&&(l.targetModel.startsWith("combo/")||Ae.has(l.targetModel.toLowerCase()))),ie=ze&&!l.targetModel.startsWith("combo/")?`combo/${l.targetModel}`:l.targetModel,St=!!(ie&&je&&je!==ie);return e.jsxs("tr",{className:`transition-colors ${fe?"bg-blue-500/10":"hover:bg-white/5"}`,children:[e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-slate-100 font-sans font-semibold text-xs leading-snug",children:ye||l.sourceModel}),vt&&e.jsx("span",{className:"text-[10.5px] font-mono text-slate-400",children:l.sourceModel})]})}),e.jsx("td",{className:"p-3 text-blue-400",children:fe?e.jsxs("div",{className:"flex items-center gap-1.5 w-full max-w-sm",children:[e.jsx("span",{className:"text-blue-400 font-mono",children:"→"}),e.jsx(Ge,{value:ue,onChange:Z,onEnter:()=>$e(t.id),placeholder:"Search model or type ID...",fetchCustomModels:z&&se.length>0?()=>Promise.resolve(se):void 0,className:"bg-[#080B11] border border-blue-500/60 focus:border-blue-400 rounded-lg px-2.5 py-1 text-xs text-white font-mono w-full focus:outline-none",autoFocus:!0})]}):l.targetModel?e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("div",{className:"inline-flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-slate-500 font-mono",children:"→"}),ze&&e.jsx("span",{className:"px-1.5 py-0.2 rounded bg-cyan-500/20 border border-cyan-500/40 text-[9.5px] font-mono text-cyan-300 font-semibold tracking-wide",children:"COMBO"}),e.jsx("span",{className:"text-emerald-300 font-sans font-semibold text-xs leading-snug",children:je||ie})]}),St&&e.jsx("span",{className:"text-[10.5px] font-mono text-slate-400 pl-4",children:ie})]}):e.jsx("span",{className:"text-slate-500 italic text-xs px-2 py-0.5 rounded bg-slate-800/60 border border-slate-700/40",children:"(unmapped)"})}),e.jsx("td",{className:"p-3 text-right space-x-2 whitespace-nowrap",children:fe?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>$e(t.id),className:"px-2.5 py-1 rounded bg-blue-600 hover:bg-blue-500 text-white font-sans text-[11px] font-medium transition-colors cursor-pointer",children:"Save"}),e.jsx("button",{onClick:()=>{me(null),de(null),Z("")},className:"px-2.5 py-1 rounded bg-[#0E1320] hover:bg-slate-700 border border-[#1E293B] text-slate-400 hover:text-white font-sans text-[11px] transition-colors cursor-pointer",children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{de(t.id),me(l.sourceModel),Z(l.targetModel)},className:"px-2.5 py-1 rounded bg-[#0E1320] hover:bg-blue-600 hover:text-white border border-[#1E293B] text-slate-300 transition-colors cursor-pointer font-sans text-[11px]",children:"Edit"}),e.jsx("button",{onClick:()=>wt(t.id,l.sourceModel),className:"p-1 text-slate-500 hover:text-red-400 transition-colors",title:"Delete mapping",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"close"})})]})})]},C)})})]})})]})]})]},t.id)})}),e.jsx(We,{isOpen:!!L,onClose:()=>$(null),maxWidthClass:"max-w-xl",children:L&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-[#1E293B]",children:[e.jsxs("h4",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-blue-400 text-[18px]",children:"add_circle"}),"Add Model Mapping (",L.toUpperCase(),")"]}),e.jsx("button",{onClick:()=>$(null),className:"text-slate-400 hover:text-white p-1 rounded-lg hover:bg-white/10",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-300 mb-1",children:"Source Model ID (Sent by IDE)"}),e.jsx(Et,{toolId:L,value:pe,onChange:xe,placeholder:"Select or type model ID (e.g. auto, claude-sonnet-4.5)..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-300 mb-1",children:"Target Upstream Model ID (Mapigate Provider Model)"}),e.jsx(Ge,{value:he,onChange:ge,placeholder:"Search model or type ID...",fetchCustomModels:z&&se.length>0?()=>Promise.resolve(se):void 0}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Supports slash / formats, e.g. provider/model-name."})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-[#1E293B]",children:[e.jsx("button",{onClick:()=>$(null),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",children:"Cancel"}),e.jsx("button",{onClick:Nt,className:"rt-btn rt-btn--primary text-xs py-1.5 px-4",children:"Add Mapping"})]})]})}),e.jsx(We,{isOpen:!!c,onClose:()=>g(null),maxWidthClass:"max-w-xl",children:c&&(()=>{var s;const t=!!c.isTransient||c.pid===0||!!((s=c.processName)!=null&&s.toLowerCase().includes("idle"));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`material-symbols-outlined text-[20px] ${t?"text-blue-400":c.isSystemProcess?"text-rose-400":"text-amber-400"}`,children:t?"hourglass_top":c.isSystemProcess?"gpp_bad":"warning"}),e.jsxs("h4",{className:"text-sm font-bold text-white",children:["Port ",c.port," ",t?"Socket Releasing":c.isSystemProcess?"System Conflict":"Already In Use"]})]}),e.jsx("button",{onClick:()=>g(null),className:"text-slate-400 hover:text-white p-1 rounded-lg hover:bg-white/10",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),t?e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsxs("div",{className:"p-3.5 bg-blue-500/10 border border-blue-500/30 rounded-xl space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-blue-300 font-semibold",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"hourglass_top"}),e.jsx("span",{children:"Socket Releasing (TIME_WAIT)"})]}),e.jsxs("p",{className:"text-slate-300 text-[11.5px] leading-relaxed",children:["Port ",c.port," is currently releasing from a recent restart (",e.jsx("strong",{className:"text-white",children:"TCP TIME_WAIT"}),"). The operating system will free this socket in a few seconds. Click ",e.jsx("strong",{children:"Retry"})," to start the MITM server."]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-[#1E293B]",children:[e.jsx("button",{type:"button",onClick:()=>g(null),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:()=>ae(!1,c.port),className:"rt-btn rt-btn--primary text-xs py-1.5 px-3.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"}),"Retry"]})]})]}):c.isSystemProcess?e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsxs("div",{className:"p-3.5 bg-rose-500/10 border border-rose-500/30 rounded-xl space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-rose-300 font-semibold",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"admin_panel_settings"}),e.jsx("span",{children:"Windows Kernel / System Service Conflict"})]}),e.jsxs("p",{className:"text-slate-300 text-[11.5px] leading-relaxed",children:["Port ",c.port," is occupied by"," ",e.jsx("strong",{children:c.processName||"System"})," (PID ",c.pid??4,"). This is a Windows system kernel service (e.g. ",e.jsx("code",{children:"HTTP.sys"}),", IIS, or Web Publishing Service) and cannot be killed directly."]})]}),e.jsxs("div",{className:"p-3 bg-[#0A0D14] border border-[#1E293B] rounded-xl space-y-2",children:[e.jsx("span",{className:"text-slate-400 text-[11px] font-semibold block",children:"Run these commands as Administrator to release the port:"}),e.jsxs("div",{className:"space-y-1.5 font-mono text-[11px]",children:[e.jsxs("div",{className:"flex items-center justify-between bg-[#141B2D] px-2.5 py-1.5 rounded-lg border border-[#1E293B]",children:[e.jsx("code",{className:"text-cyan-300",children:"iisreset /stop"}),e.jsx("button",{type:"button",onClick:()=>_("iisreset","iisreset /stop"),className:"text-slate-400 hover:text-white ml-2 shrink-0",title:"Copy command",children:e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:P==="iisreset"?"check":"content_copy"})})]}),e.jsxs("div",{className:"flex items-center justify-between bg-[#141B2D] px-2.5 py-1.5 rounded-lg border border-[#1E293B]",children:[e.jsx("code",{className:"text-cyan-300",children:"net stop w3svc"}),e.jsx("button",{type:"button",onClick:()=>_("w3svc","net stop w3svc"),className:"text-slate-400 hover:text-white ml-2 shrink-0",title:"Copy command",children:e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:P==="w3svc"?"check":"content_copy"})})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-[#1E293B]",children:[e.jsx("button",{type:"button",onClick:()=>g(null),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:()=>ae(!1,c.port),className:"rt-btn rt-btn--primary text-xs py-1.5 px-3.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"}),"Retry"]})]})]}):e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsxs("div",{className:"p-3.5 bg-amber-500/10 border border-amber-500/30 rounded-xl space-y-2",children:[e.jsxs("p",{className:"text-slate-300 text-[11.5px] leading-relaxed",children:["Port ",c.port," is currently used by another process:"]}),e.jsxs("div",{className:"p-2.5 bg-[#0A0D14] rounded-lg border border-[#1E293B] font-mono text-xs text-amber-200",children:[e.jsxs("div",{children:["Process: ",e.jsx("strong",{className:"text-white",children:c.processName||"Unknown"})]}),e.jsxs("div",{children:["PID: ",e.jsx("strong",{className:"text-white",children:c.pid??"Unknown"})]})]}),e.jsxs("p",{className:"text-slate-400 text-[11px]",children:["Kill this process to start MITM Proxy on port ",c.port,"?"]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-[#1E293B]",children:[e.jsx("button",{type:"button",onClick:()=>g(null),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",children:"Cancel"}),e.jsxs("button",{type:"button",disabled:D,onClick:()=>ae(!0,c.port),className:"rt-btn rt-btn--danger text-xs py-1.5 px-3.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:D?"hourglass_empty":"power_settings_new"}),D?"Terminating...":"Kill & Start"]})]})]})]})})()})]})};export{$t as MitmTab};
|