mapigate 0.5.130 → 0.5.136

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +1 -1
  2. package/dist/core/adapters/anthropic/requestAnthropicToOpenAi.js +59 -11
  3. package/dist/core/adapters/anthropicAdapter.js +2 -2
  4. package/dist/providers/catalog/commandcode/converter.js +215 -0
  5. package/dist/providers/catalog/commandcode/executor.js +305 -0
  6. package/dist/providers/catalog/commandcode/headers.js +76 -0
  7. package/dist/providers/catalog/commandcode/metadata.js +4 -1
  8. package/dist/providers/catalog/commandcode/ndjson.js +161 -0
  9. package/dist/providers/catalog/commandcode/provider.js +18 -35
  10. package/dist/providers/catalog/commandcode/routes.js +75 -0
  11. package/dist/providers/catalog/opencode-go/metadata.js +4 -2
  12. package/dist/providers/catalog/opencode-go/models.js +1 -0
  13. package/dist/providers/catalog/opencode-go/provider.js +114 -0
  14. package/dist/providers/catalog/opencode-go/quota.js +106 -0
  15. package/dist/providers/catalog/opencode-go/responses.js +301 -0
  16. package/dist/providers/catalog/opencode-go/responsesPayload.js +228 -0
  17. package/dist/providers/catalog/sensenova/metadata.js +35 -0
  18. package/dist/providers/core/base/baseProvider.js +3 -0
  19. package/dist/providers/core/base/openAiProvider.js +3 -1
  20. package/dist/providers/generated/routesRegistry.generated.js +2 -0
  21. package/dist/providers/runtime/antigravity/schema.js +19 -1
  22. package/dist/providers/runtime/codebuddy/provider.js +21 -6
  23. package/dist/providers/runtime/kiro/converter.js +2 -1
  24. package/dist/providers/runtime/kiro/executor.js +15 -9
  25. package/dist/providers/runtime/kiro/metadata.js +3 -3
  26. package/dist/providers/runtime/kiro/models.js +11 -0
  27. package/dist/providers/runtime/kiro/provider.js +12 -8
  28. package/dist/providers/runtime/kiro/quota.js +4 -4
  29. package/dist/providers/runtime/opencode/tools.js +38 -16
  30. package/dist/server/proxy/proxyDispatcher.js +136 -17
  31. package/dist/server/proxy/singleModelExecutor.js +14 -2
  32. package/dist/server/routes/apiModels.js +15 -6
  33. package/dist/shared/utils/dnsResolver.js +69 -27
  34. package/dist/web/assets/{CliToolsTab-Ck8EuOcF.js → CliToolsTab-CkzwuwaC.js} +1 -1
  35. package/dist/web/assets/CombosTab-C5RzRwwr.js +1 -0
  36. package/dist/web/assets/{ConfirmModal-1KqBoeRh.js → ConfirmModal-DGvcf0gB.js} +1 -1
  37. package/dist/web/assets/{ConsoleLogTab-DC2FAcl1.js → ConsoleLogTab-84Ens8T5.js} +1 -1
  38. package/dist/web/assets/{EditAccountModal-1EbG3eyM.js → EditAccountModal-D-_omvev.js} +1 -1
  39. package/dist/web/assets/{EndpointTab-C-gwVRmb.js → EndpointTab-7nBfEdYE.js} +1 -1
  40. package/dist/web/assets/{MitmTab-C2kTKbAV.js → MitmTab-CqS6mXHZ.js} +1 -1
  41. package/dist/web/assets/{ModelAutocompleteInput-K8-vMnIb.js → ModelAutocompleteInput-B9syrV1O.js} +1 -1
  42. package/dist/web/assets/ProviderDetailPage-DGZceQ2d.js +6 -0
  43. package/dist/web/assets/{ProvidersTab-w9OOjPmA.js → ProvidersTab-CiYbqRou.js} +1 -1
  44. package/dist/web/assets/{QuotaTab-C43xP8JP.js → QuotaTab-DFr0DWAU.js} +1 -1
  45. package/dist/web/assets/{SettingsTab-BMs0BtId.js → SettingsTab-4c0ksNJa.js} +1 -1
  46. package/dist/web/assets/{UsageTab-C5MbpcRp.js → UsageTab-BQcPmvtQ.js} +1 -1
  47. package/dist/web/assets/{index-DVeDwPjn.js → index-C4NTQZ40.js} +2 -2
  48. package/dist/web/assets/{index-BisuNW2y.css → index-HnsyZg0I.css} +1 -1
  49. package/dist/web/assets/metadataRegistry-B91sal4r.js +1 -0
  50. package/dist/web/assets/providersData-DkVCRBsJ.js +1 -0
  51. package/dist/web/index.html +2 -2
  52. package/package.json +1 -1
  53. package/dist/web/assets/CombosTab-CLPru5aK.js +0 -1
  54. package/dist/web/assets/ProviderDetailPage-BSqwg2fW.js +0 -6
  55. package/dist/web/assets/metadataRegistry-BMKXREeE.js +0 -1
  56. package/dist/web/assets/providersData-D7kilpPx.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-DVeDwPjn.js";import{T as pe}from"./ToolIcon-Cp4gSgFt.js";import{S as me}from"./Select-BNRH8LIG.js";import{g as be}from"./metadataRegistry-BMKXREeE.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-C4NTQZ40.js";import{T as pe}from"./ToolIcon-Cp4gSgFt.js";import{S as me}from"./Select-BNRH8LIG.js";import{g as be}from"./metadataRegistry-B91sal4r.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 +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-1KqBoeRh.js";import{u as ee,D as m,d as te,P as ve}from"./index-DVeDwPjn.js";import"./lucide-Cc35htxl.js";const u="10.*, 172.16-31.*, 192.168.*, 169.254.*, *.local",ke={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(ke),[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,k]=l.useState(null),[J,C]=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{k(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),C(null);try{const s=await(await fetch("/health")).json();C(JSON.stringify(s,null,2))}catch{C(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:t.name}),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 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.isActive,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:e.jsx("button",{type:"button",onClick:()=>k(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:()=>k(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-DGvcf0gB.js";import{u as ee,D as m,d as te,P as ve}from"./index-C4NTQZ40.js";import"./lucide-Cc35htxl.js";const u="10.*, 172.16-31.*, 192.168.*, 169.254.*, *.local",ke={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(ke),[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,k]=l.useState(null),[J,C]=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{k(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),C(null);try{const s=await(await fetch("/health")).json();C(JSON.stringify(s,null,2))}catch{C(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:t.name}),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 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.isActive,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:e.jsx("button",{type:"button",onClick:()=>k(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:()=>k(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 Ge,e as Tt}from"./index-DVeDwPjn.js";import{M as We}from"./ModelAutocompleteInput-K8-vMnIb.js";import{r as Je}from"./metadataRegistry-BMKXREeE.js";import{T as Bt}from"./ToolIcon-Cp4gSgFt.js";import"./lucide-Cc35htxl.js";const Ne={},Et=({toolId:r="kiro",value:u,onChange:g,onEnter:b,placeholder:N="Select or type source model ID...",className:v="",autoFocus:p=!1,disabled:w=!1})=>{const f=(r||"kiro").toLowerCase(),[j,c]=n.useState([]),[h,y]=n.useState(!1),[S,E]=n.useState(-1),[ie,D]=n.useState("bottom"),C=n.useRef(null),I=n.useRef(null);n.useEffect(()=>{if(h&&C.current){const i=C.current.getBoundingClientRect(),m=240,M=window.innerHeight-i.bottom,O=i.top;M<m&&O>M?D("top"):D("bottom")}},[h]),n.useEffect(()=>{let i=!0;if(Ne[f]){c(Ne[f]);return}return fetch(`/api/mitm/mappings/source-models/${encodeURIComponent(f)}`).then(m=>{if(!m.ok)throw new Error("Failed to load source models");return m.json()}).then(m=>{i&&Array.isArray(m)&&(Ne[f]=m,c(m))}).catch(()=>{}),()=>{i=!1}},[f]),n.useEffect(()=>{const i=m=>{C.current&&!C.current.contains(m.target)&&y(!1)};return document.addEventListener("mousedown",i),()=>{document.removeEventListener("mousedown",i)}},[]);const x=n.useMemo(()=>{const i=(u||"").trim().toLowerCase();return i?j.filter(m=>m.id.toLowerCase().includes(i)||m.name.toLowerCase().includes(i)):j},[j,u]);n.useEffect(()=>{E(x.length>0?0:-1)},[x]),n.useEffect(()=>{if(h&&S>=0&&I.current){const i=I.current.children[S];i&&i.scrollIntoView({block:"nearest"})}},[S,h]);const z=i=>{g(i),y(!1)},oe=i=>{i.key==="ArrowDown"?(i.preventDefault(),h?x.length>0&&E(m=>(m+1)%x.length):y(!0)):i.key==="ArrowUp"?(i.preventDefault(),h&&x.length>0&&E(m=>(m-1+x.length)%x.length)):i.key==="Enter"?h&&S>=0&&S<x.length?(i.preventDefault(),z(x[S].id)):b&&(i.preventDefault(),b()):i.key==="Escape"&&y(!1)};return e.jsxs("div",{ref:C,className:"relative w-full",children:[e.jsxs("div",{className:"relative flex items-center",children:[e.jsx("input",{type:"text",value:u,onChange:i=>{g(i.target.value),h||y(!0)},onFocus:()=>y(!0),onKeyDown:oe,placeholder:N,disabled:w,autoFocus:p,className:v||"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(i=>!i),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:h?"arrow_drop_up":"arrow_drop_down"})})]}),h&&x.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 ${ie==="top"?"bottom-full mb-1":"top-full mt-1"}`,children:x.map((i,m)=>{const M=m===S,O=i.category==="native";return e.jsxs("div",{onClick:()=>z(i.id),onMouseEnter:()=>E(m),className:`px-3 py-2 flex items-center justify-between text-xs cursor-pointer transition-colors ${M?"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:i.id}),i.name&&i.name!==i.id&&e.jsx("span",{className:"text-[10.5px] text-slate-400 font-sans truncate",children:i.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"})})]},`${i.category}-${i.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
1
+ import{r as n,j as e}from"./vendor-BcOI2aZ9.js";import{u as kt,D as Ct,d as Mt,P as Ge,e as Tt}from"./index-C4NTQZ40.js";import{M as We}from"./ModelAutocompleteInput-B9syrV1O.js";import{r as Je}from"./metadataRegistry-B91sal4r.js";import{T as Bt}from"./ToolIcon-Cp4gSgFt.js";import"./lucide-Cc35htxl.js";const Ne={},Et=({toolId:r="kiro",value:u,onChange:g,onEnter:b,placeholder:N="Select or type source model ID...",className:v="",autoFocus:p=!1,disabled:w=!1})=>{const f=(r||"kiro").toLowerCase(),[j,c]=n.useState([]),[h,y]=n.useState(!1),[S,E]=n.useState(-1),[ie,D]=n.useState("bottom"),C=n.useRef(null),I=n.useRef(null);n.useEffect(()=>{if(h&&C.current){const i=C.current.getBoundingClientRect(),m=240,M=window.innerHeight-i.bottom,O=i.top;M<m&&O>M?D("top"):D("bottom")}},[h]),n.useEffect(()=>{let i=!0;if(Ne[f]){c(Ne[f]);return}return fetch(`/api/mitm/mappings/source-models/${encodeURIComponent(f)}`).then(m=>{if(!m.ok)throw new Error("Failed to load source models");return m.json()}).then(m=>{i&&Array.isArray(m)&&(Ne[f]=m,c(m))}).catch(()=>{}),()=>{i=!1}},[f]),n.useEffect(()=>{const i=m=>{C.current&&!C.current.contains(m.target)&&y(!1)};return document.addEventListener("mousedown",i),()=>{document.removeEventListener("mousedown",i)}},[]);const x=n.useMemo(()=>{const i=(u||"").trim().toLowerCase();return i?j.filter(m=>m.id.toLowerCase().includes(i)||m.name.toLowerCase().includes(i)):j},[j,u]);n.useEffect(()=>{E(x.length>0?0:-1)},[x]),n.useEffect(()=>{if(h&&S>=0&&I.current){const i=I.current.children[S];i&&i.scrollIntoView({block:"nearest"})}},[S,h]);const z=i=>{g(i),y(!1)},oe=i=>{i.key==="ArrowDown"?(i.preventDefault(),h?x.length>0&&E(m=>(m+1)%x.length):y(!0)):i.key==="ArrowUp"?(i.preventDefault(),h&&x.length>0&&E(m=>(m-1+x.length)%x.length)):i.key==="Enter"?h&&S>=0&&S<x.length?(i.preventDefault(),z(x[S].id)):b&&(i.preventDefault(),b()):i.key==="Escape"&&y(!1)};return e.jsxs("div",{ref:C,className:"relative w-full",children:[e.jsxs("div",{className:"relative flex items-center",children:[e.jsx("input",{type:"text",value:u,onChange:i=>{g(i.target.value),h||y(!0)},onFocus:()=>y(!0),onKeyDown:oe,placeholder:N,disabled:w,autoFocus:p,className:v||"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(i=>!i),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:h?"arrow_drop_up":"arrow_drop_down"})})]}),h&&x.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 ${ie==="top"?"bottom-full mb-1":"top-full mt-1"}`,children:x.map((i,m)=>{const M=m===S,O=i.category==="native";return e.jsxs("div",{onClick:()=>z(i.id),onMouseEnter:()=>E(m),className:`px-3 py-2 flex items-center justify-between text-xs cursor-pointer transition-colors ${M?"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:i.id}),i.name&&i.name!==i.id&&e.jsx("span",{className:"text-[10.5px] text-slate-400 font-sans truncate",children:i.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"})})]},`${i.category}-${i.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:r=>r.includes("cloudcode-pa.googleapis.com"),isModelListRequest:r=>(r.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.7-flash-high":"gemini-3.7-flash-high","gemini-3.7-flash-medium":"gemini-3.7-flash-medium","gemini-3.7-flash-low":"gemini-3.7-flash-low","gemini-3.6-flash-high":"gemini-3.6-flash-high","gemini-3.6-flash-medium":"gemini-3.6-flash-medium","gemini-3.6-flash-low":"gemini-3.6-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-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-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-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-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"},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.*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.*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:/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-3.8-flash-high","gemini-3.8-flash-medium","gemini-3.8-flash-low","gemini-3.7-flash-high","gemini-3.7-flash-medium","gemini-3.7-flash-low","gemini-3.6-flash-high","gemini-3.6-flash-medium","gemini-3.6-flash-low","gemini-3.1-pro-high","gemini-3.1-pro-low","gemini-3.1-pro-high-legacy","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
@@ -1 +1 @@
1
- import{j as a,r as x}from"./vendor-BcOI2aZ9.js";import{g as X,a as Z}from"./metadataRegistry-BMKXREeE.js";const v={vision:!1,pdf:!1,audioInput:!1,videoInput:!1,imageOutput:!1,audioOutput:!1,search:!1,tools:!0,reasoning:!1,thinkingFormat:null,thinkingCanDisable:!0,thinkingRange:null,thinkingEffortSupported:!1,contextWindow:2e5,maxOutput:64e3},C="[-_/:.]",ee=new RegExp([`(^|${C})(image|img)(${C}|$)`,"stable-image","gen[0-9]_image","nanobanana","imagine","t2v","i2v","flux","dall","sdxl","diffusion","embed","rerank","guard","moderation","tts","stt","whisper","voice","speech","audio"].join("|"),"i"),te=new RegExp([`(^|${C})(vision|vl|vlm|multimodal|omni|visual)(${C}|$)`,`[0-9]\\.[0-9]+v(${C}|$)`,`(^|${C})glm-[0-9]+v(${C}|$)`,"(^|[-_/:.])(llava|pixtral|internvl|cogvlm|minicpm-v|moondream|idefics|fuyu)"].join("|"),"i"),V={nvidia:{"minimaxai/minimax-m2.7":{reasoning:!0,thinkingFormat:"openai",thinkingCanDisable:!1,contextWindow:2e5,maxOutput:131072},"minimaxai/minimax-m3":{vision:!0,reasoning:!0,thinkingFormat:"openai",thinkingCanDisable:!1,contextWindow:512e3,maxOutput:131072},"deepseek-ai/deepseek-v4-pro":{reasoning:!0,thinkingFormat:"openai",contextWindow:1e6,maxOutput:65536}},"opencode-go":{"glm-5.3-flash":{vision:!0,videoInput:!0,pdf:!0,reasoning:!0,thinkingFormat:"openai",thinkingCanDisable:!1,contextWindow:1e6,maxOutput:131072}}},S={"claude-fable-5-1":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",thinkingCanDisable:!1,contextWindow:1e6,maxOutput:128e3},"claude-opus-5.5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingCanDisable:!1,forcedToolChoice:!1},"claude-opus-5-5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingCanDisable:!1,forcedToolChoice:!1},"claude-opus-5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-sonnet-5.5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingOffType:"between_tools",forcedToolChoice:!1},"claude-sonnet-5-5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingOffType:"between_tools",forcedToolChoice:!1},"claude-haiku-5.5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-haiku-5-5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-sonnet-5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-opus-4.8":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-opus-4-8":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-opus-4.6":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-opus-4-6":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-sonnet-4.6":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-sonnet-4-6":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-3-7-sonnet":{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:64e3},"claude-3.7-sonnet":{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:64e3},"claude-3-5-sonnet":{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192},"claude-3.5-sonnet":{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192},"claude-3-5-haiku":{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192},"claude-3.5-haiku":{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192},"claude-3-opus":{vision:!0,contextWindow:2e5,maxOutput:4096},"claude-3-haiku":{vision:!0,contextWindow:2e5,maxOutput:4096},"glm-5.3-flash":{vision:!0,videoInput:!0,pdf:!0,reasoning:!0,thinkingFormat:"zai",thinkingCanDisable:!1,contextWindow:1e6,maxOutput:131072},"glm-4.6v":{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"zai",contextWindow:128e3,maxOutput:32768},"glm-4.5v":{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"zai",contextWindow:64e3,maxOutput:16384},"glm-5.2":{reasoning:!0,thinkingFormat:"zai",thinkingCanDisable:!1,contextWindow:1e6,maxOutput:131072},"deepseek-chat":{vision:!1,reasoning:!0,thinkingFormat:"deepseek",contextWindow:128e3,maxOutput:64e3},"deepseek-reasoner":{vision:!1,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:128e3,maxOutput:64e3},"deepseek-r1":{vision:!1,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:128e3,maxOutput:64e3},"deepseek-v4.1-flash":{vision:!0,reasoning:!0,thinkingFormat:"deepseek",contextWindow:1e6,maxOutput:384e3},"deepseek-v4-1-flash":{vision:!0,reasoning:!0,thinkingFormat:"deepseek",contextWindow:1e6,maxOutput:384e3},"deepseek-v4-flash-vision-exp":{vision:!0,reasoning:!0,thinkingFormat:"deepseek",contextWindow:1e6,maxOutput:384e3},"deepseek-flash":{vision:!0,reasoning:!0,thinkingFormat:"deepseek",contextWindow:128e3,maxOutput:64e3},"kimi-k3":{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:131072},"kimi-for-coding":{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:262144,maxOutput:65536},"kimi-k2.7-code":{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:262144,maxOutput:65536},"gpt-image-1":{imageOutput:!0,tools:!1}};function y(i){if(!i)return!1;const n=String(i).toLowerCase();return ee.test(n)?!1:te.test(n)}function H(i,n){return!i||!n?!1:new RegExp("^"+i.split("*").map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*")+"$","i").test(n)}const ne=[{pattern:"*claude*opus-5.5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingCanDisable:!1,forcedToolChoice:!1}},{pattern:"*claude*opus-5-5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingCanDisable:!1,forcedToolChoice:!1}},{pattern:"*claude*sonnet-5.5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingOffType:"between_tools",forcedToolChoice:!1}},{pattern:"*claude*sonnet-5-5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingOffType:"between_tools",forcedToolChoice:!1}},{pattern:"*claude*haiku-5.5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*haiku-5-5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*opus-5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*sonnet-5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*opus-4.8*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*opus-4-8*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*opus-4.7*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*opus-4-7*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*opus-4.6*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*opus-4-6*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*sonnet-4.7*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*sonnet-4-7*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*sonnet-4.6*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*sonnet-4-6*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*haiku-6*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*haiku-5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*haiku-4*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*3.7*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:64e3}},{pattern:"*claude*3-7*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:64e3}},{pattern:"*claude*3.5*sonnet*",caps:{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192}},{pattern:"*claude*3-5*sonnet*",caps:{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192}},{pattern:"*claude*3.5*haiku*",caps:{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192}},{pattern:"*claude*3-5*haiku*",caps:{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192}},{pattern:"*claude*3*opus*",caps:{vision:!0,contextWindow:2e5,maxOutput:4096}},{pattern:"*claude*3*sonnet*",caps:{vision:!0,contextWindow:2e5,maxOutput:4096}},{pattern:"*claude*3*haiku*",caps:{vision:!0,contextWindow:2e5,maxOutput:4096}},{pattern:"*claude-3*",caps:{vision:!0,contextWindow:2e5,maxOutput:4096}},{pattern:"*claude*haiku*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:8192}},{pattern:"*claude*opus*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:64e3}},{pattern:"*claude*sonnet*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:64e3}},{pattern:"*claude*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:64e3}},{pattern:"*gemini*image*",caps:{vision:!0,imageOutput:!0,contextWindow:1048576}},{pattern:"*gemini-4*",caps:{vision:!0,audioInput:!0,videoInput:!0,reasoning:!0,search:!0,thinkingFormat:"gemini-level",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:65536}},{pattern:"*gemini-3.8*",caps:{vision:!0,audioInput:!0,videoInput:!0,reasoning:!0,search:!0,thinkingFormat:"gemini-level",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:65536}},{pattern:"*gemini-3.7*",caps:{vision:!0,audioInput:!0,videoInput:!0,reasoning:!0,search:!0,thinkingFormat:"gemini-level",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:65536}},{pattern:"*gemini-2.5*",caps:{vision:!0,audioInput:!0,videoInput:!0,reasoning:!0,search:!0,thinkingFormat:"gemini-budget",thinkingRange:{min:0,max:24576},contextWindow:1048576,maxOutput:65536}},{pattern:"*gemini-2*",caps:{vision:!0,audioInput:!0,videoInput:!0,search:!0,contextWindow:1048576,maxOutput:65536}},{pattern:"*gemini*",caps:{vision:!0,search:!0,contextWindow:1048576}},{pattern:"*gemma*",caps:{vision:!0,contextWindow:128e3}},{pattern:"*gpt-6.1-terra*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:5e5,maxOutput:128e3}},{pattern:"*gpt-6.1-sol*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:272e3,maxOutput:128e3}},{pattern:"*gpt-6*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:105e4,maxOutput:128e3}},{pattern:"*gpt-5*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:4e5,maxOutput:128e3}},{pattern:"*gpt-4o*",caps:{vision:!0,search:!0,contextWindow:128e3,maxOutput:16384}},{pattern:"*gpt-4.1*",caps:{vision:!0,contextWindow:1e6,maxOutput:32768}},{pattern:"*gpt-4-turbo*",caps:{vision:!0,contextWindow:128e3}},{pattern:"*gpt-4*",caps:{contextWindow:128e3}},{pattern:"*gpt-3.5*",caps:{contextWindow:16385,maxOutput:4096}},{pattern:"*o1-mini*",caps:{reasoning:!0,thinkingFormat:"openai",contextWindow:128e3}},{pattern:"*o1*",caps:{vision:!0,reasoning:!0,thinkingFormat:"openai",contextWindow:2e5,maxOutput:1e5}},{pattern:"*o3*",caps:{vision:!0,reasoning:!0,thinkingFormat:"openai",contextWindow:2e5,maxOutput:1e5}},{pattern:"*o4*",caps:{vision:!0,reasoning:!0,thinkingFormat:"openai",contextWindow:2e5,maxOutput:1e5}},{pattern:"*grok*image*",caps:{imageOutput:!0}},{pattern:"*grok-code*",caps:{reasoning:!0,thinkingFormat:"openai",contextWindow:256e3}},{pattern:"*grok-4.7*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:5e5,maxOutput:5e5}},{pattern:"*grok-4.6*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:5e5,maxOutput:5e5}},{pattern:"*grok-4.5*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:5e5,maxOutput:64e3}},{pattern:"*grok-4*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:256e3}},{pattern:"*grok*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:128e3}},{pattern:"*deepseek*v4.1*flash*free*",caps:{vision:!0,reasoning:!0,thinkingFormat:"deepseek",contextWindow:33e4,maxOutput:128e3}},{pattern:"*deepseek-v4.*",caps:{vision:!0,reasoning:!0,thinkingFormat:"deepseek",thinkingEffortSupported:!0,contextWindow:1e6,maxOutput:128e3}},{pattern:"*deepseek-v4*",caps:{reasoning:!0,thinkingFormat:"deepseek",thinkingEffortSupported:!0,contextWindow:1e6,maxOutput:384e3}},{pattern:"*reasoner*",caps:{vision:!1,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:128e3}},{pattern:"*deepseek-r*",caps:{vision:!1,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:128e3}},{pattern:"*deepseek-chat*",caps:{vision:!1,reasoning:!0,thinkingFormat:"deepseek",contextWindow:128e3}},{pattern:"*deepseek*",caps:{reasoning:!0,thinkingFormat:"deepseek",contextWindow:128e3}},{pattern:"*qwen*vl*",caps:{vision:!0,reasoning:!0,thinkingFormat:"qwen",contextWindow:262144}},{pattern:"*qwen*omni*",caps:{vision:!0,audioInput:!0,videoInput:!0,reasoning:!0,thinkingFormat:"qwen",contextWindow:262144,maxOutput:65536}},{pattern:"*qwen*coder*",caps:{reasoning:!0,thinkingFormat:"qwen",contextWindow:1e6}},{pattern:"*qwen*max*",caps:{vision:!0,reasoning:!0,thinkingFormat:"qwen",contextWindow:1e6,maxOutput:65536}},{pattern:"*qwen3.5*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"qwen",contextWindow:1e6,maxOutput:65536}},{pattern:"*qwen3.6*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"qwen",contextWindow:1e6,maxOutput:65536}},{pattern:"*qwen3.7*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"qwen",contextWindow:1e6,maxOutput:65536}},{pattern:"*qwen*plus*",caps:{vision:!0,reasoning:!0,thinkingFormat:"qwen",contextWindow:1e6,maxOutput:65536}},{pattern:"*qwq*",caps:{reasoning:!0,thinkingFormat:"qwen",thinkingCanDisable:!1,contextWindow:131072}},{pattern:"*qwen*",caps:{reasoning:!0,thinkingFormat:"qwen",contextWindow:262144}},{pattern:"*kimi*k3.1*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:131072}},{pattern:"*kimi*k3*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:131072}},{pattern:"*k3.1*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:131072}},{pattern:"*k3*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:131072}},{pattern:"*kimi*coding*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:262144,maxOutput:65536}},{pattern:"*kimi*k2*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:262144,maxOutput:65536}},{pattern:"*kimi*",caps:{vision:!0,reasoning:!0,thinkingFormat:"kimi",contextWindow:262144}},{pattern:"*mimo*v2.6*",caps:{vision:!0,audioInput:!0,videoInput:!0,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:131072}},{pattern:"*mimo*v2.5*",caps:{vision:!0,audioInput:!0,videoInput:!0,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:131072}},{pattern:"*mimo*omni*",caps:{vision:!0,audioInput:!0,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:262144,maxOutput:131072}},{pattern:"*mimo*",caps:{vision:!0,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:262144,maxOutput:131072}},{pattern:"*llama-4*",caps:{vision:!0,contextWindow:1e6}},{pattern:"*llama*",caps:{contextWindow:128e3}},{pattern:"*mistral-large*",caps:{vision:!0,contextWindow:256e3}},{pattern:"*codestral*",caps:{contextWindow:256e3}},{pattern:"*mistral*",caps:{contextWindow:128e3}}];function K(i){if(i){if(Array.isArray(i)){const n={};for(const u of i)typeof u=="string"&&(n[u]=!0);return n}return i}}function G(i,n){if(!n)return{...v};const u=n.includes("/")?n.split("/").pop():n,s=!i&&n.includes("/")?n.split("/")[0]:i;if(s){const t=X(s);if(t!=null&&t.models){const c=t.models.find(o=>o.id===n||o.id===u||o.upstreamModelId&&(o.upstreamModelId===n||o.upstreamModelId===u));if(c!=null&&c.capabilities){const o=K(c.capabilities);if(o){const m={...v,...o};return!m.vision&&y(n)&&(m.vision=!0),m}}}}else for(const t of Z()){if(!t.models)continue;const c=t.models.find(o=>o.id===n||o.id===u||o.upstreamModelId&&(o.upstreamModelId===n||o.upstreamModelId===u));if(c!=null&&c.capabilities){const o=K(c.capabilities);if(o){const m={...v,...o};return!m.vision&&y(n)&&(m.vision=!0),m}}}if(s&&V[s]){const t=V[s];if(t[n])return{...v,...t[n]};if(t[u])return{...v,...t[u]}}if(S[u]){const t={...v,...S[u]};return!t.vision&&y(n)&&(t.vision=!0),t}if(S[n]){const t={...v,...S[n]};return!t.vision&&y(n)&&(t.vision=!0),t}for(const{pattern:t,caps:c}of ne)if(H(t,u)||H(t,n)){const o={...v,...c};return!o.vision&&y(n)&&(o.vision=!0),o}const g={...v};return!g.vision&&y(n)&&(g.vision=!0),g}function ue(i,n,u=0){if(!i||i.length===0||u>6)return null;const s=i.map(t=>{!t.includes("/")&&(n!=null&&n[t]);const c=t.indexOf("/"),o=c===-1?null:t.slice(0,c),m=c===-1?t:t.slice(c+1);return G(o,m)}),g=s[0];return{vision:s.some(t=>t.vision),pdf:s.some(t=>t.pdf),audioInput:s.some(t=>t.audioInput),videoInput:s.some(t=>t.videoInput),imageOutput:s.some(t=>t.imageOutput),audioOutput:s.some(t=>t.audioOutput),search:s.some(t=>t.search),tools:s.every(t=>t.tools),reasoning:g.reasoning,thinkingFormat:g.thinkingFormat,thinkingCanDisable:g.thinkingCanDisable,thinkingRange:g.thinkingRange,thinkingEffortSupported:g.thinkingEffortSupported,contextWindow:Math.min(...s.map(t=>t.contextWindow)),maxOutput:Math.max(...s.map(t=>t.maxOutput))}}const $={vision:{key:"vision",label:"Vision",icon:"visibility",desc:"Supports image inputs (png, jpg, webp, base64)",colorClass:"text-cyan-400",bgClass:"bg-cyan-500/10",borderClass:"border-cyan-500/20"},pdf:{key:"pdf",label:"PDF",icon:"picture_as_pdf",desc:"Supports PDF and document parsing",colorClass:"text-orange-400",bgClass:"bg-orange-500/10",borderClass:"border-orange-500/20"},audio:{key:"audio",label:"Audio",icon:"graphic_eq",desc:"Supports raw voice and audio speech input",colorClass:"text-purple-400",bgClass:"bg-purple-500/10",borderClass:"border-purple-500/20"},thinking:{key:"thinking",label:"Thinking",icon:"psychology",desc:"Supports reasoning and thinking trace",colorClass:"text-emerald-400",bgClass:"bg-emerald-500/10",borderClass:"border-emerald-500/20"}};function ie(i){if(!i)return null;const n=i.indexOf("/"),u=n===-1?null:i.slice(0,n),s=n===-1?i:i.slice(n+1);return G(u,s)}const ae=({caps:i,model:n,className:u="",showLabels:s=!1,size:g="sm"})=>{const t=i||(n?ie(n):null);if(!t)return null;const c=!!t.vision,o=!!t.pdf,m=!!(t.audioInput||t.audio),N=!!(t.reasoning||t.thinking||t.thinkingFormat&&t.thinkingFormat!==null),h=[];if(c&&h.push($.vision),o&&h.push($.pdf),m&&h.push($.audio),N&&h.push($.thinking),h.length===0)return null;const w={xs:"text-[12px]",sm:"text-[14px]",md:"text-[16px]"},A={xs:"text-[9.5px]",sm:"text-[10.5px]",md:"text-xs"};return a.jsx("div",{className:`inline-flex items-center gap-1.5 flex-wrap ${u}`,children:h.map(d=>a.jsxs("span",{title:`${d.label}: ${d.desc}`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md border font-medium transition-all ${d.colorClass} ${d.bgClass} ${d.borderClass} ${A[g]}`,children:[a.jsx("span",{className:`material-symbols-outlined leading-none ${w[g]}`,children:d.icon}),s&&a.jsx("span",{children:d.label})]},d.key))})};let j=null,E=null;const B=new Set;function oe(i){return B.add(i),()=>{B.delete(i)}}function ce(){j=null,E=null;for(const i of B)try{i()}catch(n){console.error("Error in model cache invalidation listener:",n)}}function U(){return E?Promise.resolve(E):(j||(j=fetch("/api/models/available").then(i=>{if(!i.ok)throw new Error("Failed to load models");return i.json()}).then(i=>(E=i,i)).catch(i=>{throw j=null,i})),j)}const pe=({value:i,onChange:n,onEnter:u,placeholder:s="Search model (e.g. openai/gpt-4o)...",className:g="",autoFocus:t=!1,connectedOnly:c=!0,disabled:o=!1,excludeValues:m,allowCombos:N=!0,fetchCustomModels:h})=>{const[w,A]=x.useState([]),[d,f]=x.useState(!1),[b,k]=x.useState(-1),[W,T]=x.useState(c),[Y,R]=x.useState("bottom"),I=x.useRef(null),q=x.useRef(null);x.useEffect(()=>{if(d&&I.current){const e=I.current.getBoundingClientRect(),p=280,l=window.innerHeight-e.bottom,F=e.top;l<p&&F>l?R("top"):R("bottom")}},[d]),x.useEffect(()=>{let e=!0;const p=()=>{(h?h():U()).then(r=>{e&&A(r)}).catch(()=>{})};p();const l=oe(()=>{e&&p()});return()=>{e=!1,l()}},[h]),x.useEffect(()=>{T(c)},[c]),x.useEffect(()=>{const e=p=>{I.current&&!I.current.contains(p.target)&&f(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]);const L=x.useMemo(()=>w.some(e=>e.hasConnectedAccount),[w]),O=x.useMemo(()=>{const e=(i||"").trim().toLowerCase(),p=new Set((m||[]).map(r=>r.toLowerCase()));let l=w;if(N===!1&&(l=l.filter(r=>!r.isCombo)),p.size>0&&(l=l.filter(r=>!p.has(r.value.toLowerCase())&&!p.has(r.id.toLowerCase()))),W&&L&&(l=l.filter(r=>r.hasConnectedAccount)),!e)return l.slice(0,50);const F=l.filter(r=>!!(r.value.toLowerCase().includes(e)||r.id.toLowerCase().includes(e)||r.name.toLowerCase().includes(e)||r.providerName.toLowerCase().includes(e)||r.providerId.toLowerCase().includes(e)||r.isCombo&&(r.strategy&&r.strategy.toLowerCase().includes(e)||r.models&&r.models.some(M=>M.toLowerCase().includes(e)))));return F.sort((r,D)=>{const M=r.value.toLowerCase(),P=D.value.toLowerCase(),_=r.id.toLowerCase(),z=D.id.toLowerCase();return M===e||_===e?-1:P===e||z===e?1:M.startsWith(e)||_.startsWith(e)?-1:P.startsWith(e)||z.startsWith(e)?1:r.isCombo&&!D.isCombo?-1:!r.isCombo&&D.isCombo?1:0}),F.slice(0,50)},[w,i,W,L,m,N]);x.useEffect(()=>{if(b>=0&&q.current){const e=q.current.children[b];e&&e.scrollIntoView({block:"nearest"})}},[b]);const J=e=>{if(!o)if(e.key==="ArrowDown")e.preventDefault(),d?k(p=>p<O.length-1?p+1:0):f(!0);else if(e.key==="ArrowUp")e.preventDefault(),d?k(p=>p>0?p-1:O.length-1):f(!0);else if(e.key==="Enter")if(d&&b>=0&&O[b]){e.preventDefault();const p=O[b];n(p.value),f(!1),k(-1),u&&u()}else f(!1),u&&(e.preventDefault(),u());else e.key==="Escape"&&(e.preventDefault(),f(!1),k(-1))},Q=e=>{n(e),f(!1),k(-1)};return a.jsxs("div",{ref:I,className:"relative w-full",children:[a.jsx("input",{type:"text",value:i,onChange:e=>{n(e.target.value),d||f(!0),k(-1)},onFocus:()=>{(w.length===0||!E)&&U().then(e=>A(e)).catch(()=>{}),f(!0)},onKeyDown:J,placeholder:s,disabled:o,autoFocus:t,className:g||"w-full bg-[#0A0D14] border border-[#1E293B] rounded-xl pl-3 pr-8 py-2 text-xs text-white font-mono focus:outline-none focus:border-blue-500"}),i&&!o&&a.jsx("button",{type:"button",onClick:()=>{n(""),k(-1)},className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-500 hover:text-white transition-colors cursor-pointer flex items-center justify-center",title:"Clear input",children:a.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"close"})}),d&&a.jsxs("div",{className:`absolute left-0 right-0 ${Y==="top"?"bottom-full mb-1.5":"top-full mt-1.5"} z-50 rounded-xl bg-[#0A0D14] border border-[#1E293B] shadow-2xl overflow-hidden animate-rt-scale-in min-w-[280px]`,children:[a.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-[#1E293B] bg-[#05070B] text-[11px]",children:[a.jsxs("span",{className:"text-slate-400 font-mono text-[10.5px]",children:[O.length," models ",i.trim()?"found":"available"]}),a.jsxs("button",{type:"button",onMouseDown:e=>{e.preventDefault(),T(!W)},className:`px-2 py-0.5 rounded-md font-sans text-[10.5px] font-medium flex items-center gap-1 transition-all cursor-pointer ${W?"bg-emerald-500/15 border border-emerald-500/30 text-emerald-400":"bg-slate-800 border border-slate-700 text-slate-400 hover:text-slate-200"}`,title:W?"Showing only models from connected accounts. Click to show all catalog models.":"Showing all catalog models. Click to filter by connected accounts.",children:[a.jsx("span",{className:"material-symbols-outlined text-[12px]",children:W?"check":"filter_alt"}),"Connected only"]})]}),a.jsx("div",{ref:q,className:"max-h-56 overflow-y-auto divide-y divide-[#1E293B]/40",children:O.length===0?a.jsxs("div",{className:"p-3 text-center text-xs text-slate-500 space-y-1",children:[a.jsx("p",{children:"No matching models in catalog."}),a.jsx("p",{className:"text-[10.5px] text-slate-400",children:"Custom IDs are supported. Press Enter or click outside to use your custom model ID."}),W&&!L&&a.jsx("button",{type:"button",onMouseDown:e=>{e.preventDefault(),T(!1)},className:"mt-1 text-[11px] text-blue-400 hover:underline",children:"View all registry models"})]}):O.map((e,p)=>{const l=p===b,F=e.value===i;return a.jsxs("div",{onMouseDown:r=>{r.preventDefault(),Q(e.value)},onMouseEnter:()=>k(p),className:`px-3 py-2 cursor-pointer transition-colors flex items-center justify-between gap-2.5 ${l?"bg-blue-600/20 text-white":F?"bg-[#141B2D] text-slate-100":"hover:bg-white/5 text-slate-300"}`,children:[a.jsxs("div",{className:"min-w-0 flex-1 space-y-0.5",children:[a.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.isCombo?a.jsx("span",{className:"px-1.5 py-0.2 rounded bg-cyan-500/20 border border-cyan-500/40 font-mono text-[9.5px] text-cyan-300 font-semibold tracking-wide",children:"COMBO"}):a.jsx("span",{className:"px-1.5 py-0.2 rounded bg-slate-800/80 border border-slate-700/60 font-mono text-[9.5px] text-slate-300",children:e.providerName||e.providerId}),a.jsx("span",{className:"font-medium text-xs text-slate-100 truncate",children:e.name}),e.isCombo&&e.strategy&&a.jsx("span",{className:`px-1.5 py-0.2 rounded font-sans text-[9px] font-medium border ${e.strategy==="round-robin"?"bg-cyan-950/40 text-cyan-300 border-cyan-500/30":e.strategy==="fusion"?"bg-purple-950/40 text-purple-300 border-purple-500/30":"bg-amber-950/40 text-amber-300 border-amber-500/30"}`,children:e.strategy==="round-robin"?"Round Robin":e.strategy==="fusion"?"Fusion":"Fallback"}),e.hasConnectedAccount&&a.jsx("span",{className:"size-1.5 rounded-full bg-emerald-400 shrink-0",title:`Connected account active (${e.accountsCount})`})]}),e.isCombo&&e.models&&e.models.length>0?a.jsxs("div",{className:"font-mono text-[10.5px] text-slate-400 truncate",children:[a.jsxs("span",{className:"text-cyan-400 font-semibold",children:[e.models.length," model",e.models.length>1?"s":"",":"]})," ",a.jsxs("span",{className:"text-slate-300",children:[e.models.slice(0,3).join(", "),e.models.length>3?` +${e.models.length-3} more`:""]})]}):a.jsx("div",{className:"font-mono text-[10.5px] text-slate-400 truncate",children:e.value})]}),a.jsx("div",{className:"shrink-0 flex items-center gap-1.5",children:a.jsx(ae,{caps:e.caps,size:"xs",showLabels:!1})})]},e.value)})})]})]})};export{ae as C,pe as M,ue as a,U as b,G as g,ce as i,oe as o};
1
+ import{j as a,r as x}from"./vendor-BcOI2aZ9.js";import{g as X,a as Z}from"./metadataRegistry-B91sal4r.js";const v={vision:!1,pdf:!1,audioInput:!1,videoInput:!1,imageOutput:!1,audioOutput:!1,search:!1,tools:!0,reasoning:!1,thinkingFormat:null,thinkingCanDisable:!0,thinkingRange:null,thinkingEffortSupported:!1,contextWindow:2e5,maxOutput:64e3},C="[-_/:.]",ee=new RegExp([`(^|${C})(image|img)(${C}|$)`,"stable-image","gen[0-9]_image","nanobanana","imagine","t2v","i2v","flux","dall","sdxl","diffusion","embed","rerank","guard","moderation","tts","stt","whisper","voice","speech","audio"].join("|"),"i"),te=new RegExp([`(^|${C})(vision|vl|vlm|multimodal|omni|visual)(${C}|$)`,`[0-9]\\.[0-9]+v(${C}|$)`,`(^|${C})glm-[0-9]+v(${C}|$)`,"(^|[-_/:.])(llava|pixtral|internvl|cogvlm|minicpm-v|moondream|idefics|fuyu)"].join("|"),"i"),V={nvidia:{"minimaxai/minimax-m2.7":{reasoning:!0,thinkingFormat:"openai",thinkingCanDisable:!1,contextWindow:2e5,maxOutput:131072},"minimaxai/minimax-m3":{vision:!0,reasoning:!0,thinkingFormat:"openai",thinkingCanDisable:!1,contextWindow:512e3,maxOutput:131072},"deepseek-ai/deepseek-v4-pro":{reasoning:!0,thinkingFormat:"openai",contextWindow:1e6,maxOutput:65536}},"opencode-go":{"glm-5.3-flash":{vision:!0,videoInput:!0,pdf:!0,reasoning:!0,thinkingFormat:"openai",thinkingCanDisable:!1,contextWindow:1e6,maxOutput:131072}}},S={"claude-fable-5-1":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",thinkingCanDisable:!1,contextWindow:1e6,maxOutput:128e3},"claude-opus-5.5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingCanDisable:!1,forcedToolChoice:!1},"claude-opus-5-5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingCanDisable:!1,forcedToolChoice:!1},"claude-opus-5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-sonnet-5.5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingOffType:"between_tools",forcedToolChoice:!1},"claude-sonnet-5-5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingOffType:"between_tools",forcedToolChoice:!1},"claude-haiku-5.5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-haiku-5-5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-sonnet-5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-opus-4.8":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-opus-4-8":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-opus-4.6":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-opus-4-6":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-sonnet-4.6":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-sonnet-4-6":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-3-7-sonnet":{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:64e3},"claude-3.7-sonnet":{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:64e3},"claude-3-5-sonnet":{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192},"claude-3.5-sonnet":{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192},"claude-3-5-haiku":{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192},"claude-3.5-haiku":{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192},"claude-3-opus":{vision:!0,contextWindow:2e5,maxOutput:4096},"claude-3-haiku":{vision:!0,contextWindow:2e5,maxOutput:4096},"glm-5.3-flash":{vision:!0,videoInput:!0,pdf:!0,reasoning:!0,thinkingFormat:"zai",thinkingCanDisable:!1,contextWindow:1e6,maxOutput:131072},"glm-4.6v":{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"zai",contextWindow:128e3,maxOutput:32768},"glm-4.5v":{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"zai",contextWindow:64e3,maxOutput:16384},"glm-5.2":{reasoning:!0,thinkingFormat:"zai",thinkingCanDisable:!1,contextWindow:1e6,maxOutput:131072},"deepseek-chat":{vision:!1,reasoning:!0,thinkingFormat:"deepseek",contextWindow:128e3,maxOutput:64e3},"deepseek-reasoner":{vision:!1,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:128e3,maxOutput:64e3},"deepseek-r1":{vision:!1,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:128e3,maxOutput:64e3},"deepseek-v4.1-flash":{vision:!0,reasoning:!0,thinkingFormat:"deepseek",contextWindow:1e6,maxOutput:384e3},"deepseek-v4-1-flash":{vision:!0,reasoning:!0,thinkingFormat:"deepseek",contextWindow:1e6,maxOutput:384e3},"deepseek-v4-flash-vision-exp":{vision:!0,reasoning:!0,thinkingFormat:"deepseek",contextWindow:1e6,maxOutput:384e3},"deepseek-flash":{vision:!0,reasoning:!0,thinkingFormat:"deepseek",contextWindow:128e3,maxOutput:64e3},"kimi-k3":{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:131072},"kimi-for-coding":{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:262144,maxOutput:65536},"kimi-k2.7-code":{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:262144,maxOutput:65536},"gpt-image-1":{imageOutput:!0,tools:!1}};function y(i){if(!i)return!1;const n=String(i).toLowerCase();return ee.test(n)?!1:te.test(n)}function H(i,n){return!i||!n?!1:new RegExp("^"+i.split("*").map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*")+"$","i").test(n)}const ne=[{pattern:"*claude*opus-5.5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingCanDisable:!1,forcedToolChoice:!1}},{pattern:"*claude*opus-5-5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingCanDisable:!1,forcedToolChoice:!1}},{pattern:"*claude*sonnet-5.5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingOffType:"between_tools",forcedToolChoice:!1}},{pattern:"*claude*sonnet-5-5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingOffType:"between_tools",forcedToolChoice:!1}},{pattern:"*claude*haiku-5.5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*haiku-5-5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*opus-5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*sonnet-5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*opus-4.8*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*opus-4-8*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*opus-4.7*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*opus-4-7*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*opus-4.6*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*opus-4-6*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*sonnet-4.7*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*sonnet-4-7*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*sonnet-4.6*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*sonnet-4-6*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*haiku-6*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*haiku-5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*haiku-4*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*3.7*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:64e3}},{pattern:"*claude*3-7*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:64e3}},{pattern:"*claude*3.5*sonnet*",caps:{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192}},{pattern:"*claude*3-5*sonnet*",caps:{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192}},{pattern:"*claude*3.5*haiku*",caps:{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192}},{pattern:"*claude*3-5*haiku*",caps:{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192}},{pattern:"*claude*3*opus*",caps:{vision:!0,contextWindow:2e5,maxOutput:4096}},{pattern:"*claude*3*sonnet*",caps:{vision:!0,contextWindow:2e5,maxOutput:4096}},{pattern:"*claude*3*haiku*",caps:{vision:!0,contextWindow:2e5,maxOutput:4096}},{pattern:"*claude-3*",caps:{vision:!0,contextWindow:2e5,maxOutput:4096}},{pattern:"*claude*haiku*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:8192}},{pattern:"*claude*opus*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:64e3}},{pattern:"*claude*sonnet*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:64e3}},{pattern:"*claude*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:64e3}},{pattern:"*gemini*image*",caps:{vision:!0,imageOutput:!0,contextWindow:1048576}},{pattern:"*gemini-4*",caps:{vision:!0,audioInput:!0,videoInput:!0,reasoning:!0,search:!0,thinkingFormat:"gemini-level",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:65536}},{pattern:"*gemini-3.8*",caps:{vision:!0,audioInput:!0,videoInput:!0,reasoning:!0,search:!0,thinkingFormat:"gemini-level",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:65536}},{pattern:"*gemini-3.7*",caps:{vision:!0,audioInput:!0,videoInput:!0,reasoning:!0,search:!0,thinkingFormat:"gemini-level",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:65536}},{pattern:"*gemini-2.5*",caps:{vision:!0,audioInput:!0,videoInput:!0,reasoning:!0,search:!0,thinkingFormat:"gemini-budget",thinkingRange:{min:0,max:24576},contextWindow:1048576,maxOutput:65536}},{pattern:"*gemini-2*",caps:{vision:!0,audioInput:!0,videoInput:!0,search:!0,contextWindow:1048576,maxOutput:65536}},{pattern:"*gemini*",caps:{vision:!0,search:!0,contextWindow:1048576}},{pattern:"*gemma*",caps:{vision:!0,contextWindow:128e3}},{pattern:"*gpt-6.1-terra*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:5e5,maxOutput:128e3}},{pattern:"*gpt-6.1-sol*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:272e3,maxOutput:128e3}},{pattern:"*gpt-6*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:105e4,maxOutput:128e3}},{pattern:"*gpt-5*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:4e5,maxOutput:128e3}},{pattern:"*gpt-4o*",caps:{vision:!0,search:!0,contextWindow:128e3,maxOutput:16384}},{pattern:"*gpt-4.1*",caps:{vision:!0,contextWindow:1e6,maxOutput:32768}},{pattern:"*gpt-4-turbo*",caps:{vision:!0,contextWindow:128e3}},{pattern:"*gpt-4*",caps:{contextWindow:128e3}},{pattern:"*gpt-3.5*",caps:{contextWindow:16385,maxOutput:4096}},{pattern:"*o1-mini*",caps:{reasoning:!0,thinkingFormat:"openai",contextWindow:128e3}},{pattern:"*o1*",caps:{vision:!0,reasoning:!0,thinkingFormat:"openai",contextWindow:2e5,maxOutput:1e5}},{pattern:"*o3*",caps:{vision:!0,reasoning:!0,thinkingFormat:"openai",contextWindow:2e5,maxOutput:1e5}},{pattern:"*o4*",caps:{vision:!0,reasoning:!0,thinkingFormat:"openai",contextWindow:2e5,maxOutput:1e5}},{pattern:"*grok*image*",caps:{imageOutput:!0}},{pattern:"*grok-code*",caps:{reasoning:!0,thinkingFormat:"openai",contextWindow:256e3}},{pattern:"*grok-4.7*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:5e5,maxOutput:5e5}},{pattern:"*grok-4.6*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:5e5,maxOutput:5e5}},{pattern:"*grok-4.5*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:5e5,maxOutput:64e3}},{pattern:"*grok-4*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:256e3}},{pattern:"*grok*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:128e3}},{pattern:"*deepseek*v4.1*flash*free*",caps:{vision:!0,reasoning:!0,thinkingFormat:"deepseek",contextWindow:33e4,maxOutput:128e3}},{pattern:"*deepseek-v4.*",caps:{vision:!0,reasoning:!0,thinkingFormat:"deepseek",thinkingEffortSupported:!0,contextWindow:1e6,maxOutput:128e3}},{pattern:"*deepseek-v4*",caps:{reasoning:!0,thinkingFormat:"deepseek",thinkingEffortSupported:!0,contextWindow:1e6,maxOutput:384e3}},{pattern:"*reasoner*",caps:{vision:!1,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:128e3}},{pattern:"*deepseek-r*",caps:{vision:!1,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:128e3}},{pattern:"*deepseek-chat*",caps:{vision:!1,reasoning:!0,thinkingFormat:"deepseek",contextWindow:128e3}},{pattern:"*deepseek*",caps:{reasoning:!0,thinkingFormat:"deepseek",contextWindow:128e3}},{pattern:"*qwen*vl*",caps:{vision:!0,reasoning:!0,thinkingFormat:"qwen",contextWindow:262144}},{pattern:"*qwen*omni*",caps:{vision:!0,audioInput:!0,videoInput:!0,reasoning:!0,thinkingFormat:"qwen",contextWindow:262144,maxOutput:65536}},{pattern:"*qwen*coder*",caps:{reasoning:!0,thinkingFormat:"qwen",contextWindow:1e6}},{pattern:"*qwen*max*",caps:{vision:!0,reasoning:!0,thinkingFormat:"qwen",contextWindow:1e6,maxOutput:65536}},{pattern:"*qwen3.5*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"qwen",contextWindow:1e6,maxOutput:65536}},{pattern:"*qwen3.6*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"qwen",contextWindow:1e6,maxOutput:65536}},{pattern:"*qwen3.7*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"qwen",contextWindow:1e6,maxOutput:65536}},{pattern:"*qwen*plus*",caps:{vision:!0,reasoning:!0,thinkingFormat:"qwen",contextWindow:1e6,maxOutput:65536}},{pattern:"*qwq*",caps:{reasoning:!0,thinkingFormat:"qwen",thinkingCanDisable:!1,contextWindow:131072}},{pattern:"*qwen*",caps:{reasoning:!0,thinkingFormat:"qwen",contextWindow:262144}},{pattern:"*kimi*k3.1*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:131072}},{pattern:"*kimi*k3*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:131072}},{pattern:"*k3.1*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:131072}},{pattern:"*k3*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:131072}},{pattern:"*kimi*coding*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:262144,maxOutput:65536}},{pattern:"*kimi*k2*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:262144,maxOutput:65536}},{pattern:"*kimi*",caps:{vision:!0,reasoning:!0,thinkingFormat:"kimi",contextWindow:262144}},{pattern:"*mimo*v2.6*",caps:{vision:!0,audioInput:!0,videoInput:!0,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:131072}},{pattern:"*mimo*v2.5*",caps:{vision:!0,audioInput:!0,videoInput:!0,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:131072}},{pattern:"*mimo*omni*",caps:{vision:!0,audioInput:!0,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:262144,maxOutput:131072}},{pattern:"*mimo*",caps:{vision:!0,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:262144,maxOutput:131072}},{pattern:"*llama-4*",caps:{vision:!0,contextWindow:1e6}},{pattern:"*llama*",caps:{contextWindow:128e3}},{pattern:"*mistral-large*",caps:{vision:!0,contextWindow:256e3}},{pattern:"*codestral*",caps:{contextWindow:256e3}},{pattern:"*mistral*",caps:{contextWindow:128e3}}];function K(i){if(i){if(Array.isArray(i)){const n={};for(const u of i)typeof u=="string"&&(n[u]=!0);return n}return i}}function G(i,n){if(!n)return{...v};const u=n.includes("/")?n.split("/").pop():n,s=!i&&n.includes("/")?n.split("/")[0]:i;if(s){const t=X(s);if(t!=null&&t.models){const c=t.models.find(o=>o.id===n||o.id===u||o.upstreamModelId&&(o.upstreamModelId===n||o.upstreamModelId===u));if(c!=null&&c.capabilities){const o=K(c.capabilities);if(o){const m={...v,...o};return!m.vision&&y(n)&&(m.vision=!0),m}}}}else for(const t of Z()){if(!t.models)continue;const c=t.models.find(o=>o.id===n||o.id===u||o.upstreamModelId&&(o.upstreamModelId===n||o.upstreamModelId===u));if(c!=null&&c.capabilities){const o=K(c.capabilities);if(o){const m={...v,...o};return!m.vision&&y(n)&&(m.vision=!0),m}}}if(s&&V[s]){const t=V[s];if(t[n])return{...v,...t[n]};if(t[u])return{...v,...t[u]}}if(S[u]){const t={...v,...S[u]};return!t.vision&&y(n)&&(t.vision=!0),t}if(S[n]){const t={...v,...S[n]};return!t.vision&&y(n)&&(t.vision=!0),t}for(const{pattern:t,caps:c}of ne)if(H(t,u)||H(t,n)){const o={...v,...c};return!o.vision&&y(n)&&(o.vision=!0),o}const g={...v};return!g.vision&&y(n)&&(g.vision=!0),g}function ue(i,n,u=0){if(!i||i.length===0||u>6)return null;const s=i.map(t=>{!t.includes("/")&&(n!=null&&n[t]);const c=t.indexOf("/"),o=c===-1?null:t.slice(0,c),m=c===-1?t:t.slice(c+1);return G(o,m)}),g=s[0];return{vision:s.some(t=>t.vision),pdf:s.some(t=>t.pdf),audioInput:s.some(t=>t.audioInput),videoInput:s.some(t=>t.videoInput),imageOutput:s.some(t=>t.imageOutput),audioOutput:s.some(t=>t.audioOutput),search:s.some(t=>t.search),tools:s.every(t=>t.tools),reasoning:g.reasoning,thinkingFormat:g.thinkingFormat,thinkingCanDisable:g.thinkingCanDisable,thinkingRange:g.thinkingRange,thinkingEffortSupported:g.thinkingEffortSupported,contextWindow:Math.min(...s.map(t=>t.contextWindow)),maxOutput:Math.max(...s.map(t=>t.maxOutput))}}const $={vision:{key:"vision",label:"Vision",icon:"visibility",desc:"Supports image inputs (png, jpg, webp, base64)",colorClass:"text-cyan-400",bgClass:"bg-cyan-500/10",borderClass:"border-cyan-500/20"},pdf:{key:"pdf",label:"PDF",icon:"picture_as_pdf",desc:"Supports PDF and document parsing",colorClass:"text-orange-400",bgClass:"bg-orange-500/10",borderClass:"border-orange-500/20"},audio:{key:"audio",label:"Audio",icon:"graphic_eq",desc:"Supports raw voice and audio speech input",colorClass:"text-purple-400",bgClass:"bg-purple-500/10",borderClass:"border-purple-500/20"},thinking:{key:"thinking",label:"Thinking",icon:"psychology",desc:"Supports reasoning and thinking trace",colorClass:"text-emerald-400",bgClass:"bg-emerald-500/10",borderClass:"border-emerald-500/20"}};function ie(i){if(!i)return null;const n=i.indexOf("/"),u=n===-1?null:i.slice(0,n),s=n===-1?i:i.slice(n+1);return G(u,s)}const ae=({caps:i,model:n,className:u="",showLabels:s=!1,size:g="sm"})=>{const t=i||(n?ie(n):null);if(!t)return null;const c=!!t.vision,o=!!t.pdf,m=!!(t.audioInput||t.audio),N=!!(t.reasoning||t.thinking||t.thinkingFormat&&t.thinkingFormat!==null),h=[];if(c&&h.push($.vision),o&&h.push($.pdf),m&&h.push($.audio),N&&h.push($.thinking),h.length===0)return null;const w={xs:"text-[12px]",sm:"text-[14px]",md:"text-[16px]"},A={xs:"text-[9.5px]",sm:"text-[10.5px]",md:"text-xs"};return a.jsx("div",{className:`inline-flex items-center gap-1.5 flex-wrap ${u}`,children:h.map(d=>a.jsxs("span",{title:`${d.label}: ${d.desc}`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md border font-medium transition-all ${d.colorClass} ${d.bgClass} ${d.borderClass} ${A[g]}`,children:[a.jsx("span",{className:`material-symbols-outlined leading-none ${w[g]}`,children:d.icon}),s&&a.jsx("span",{children:d.label})]},d.key))})};let j=null,E=null;const B=new Set;function oe(i){return B.add(i),()=>{B.delete(i)}}function ce(){j=null,E=null;for(const i of B)try{i()}catch(n){console.error("Error in model cache invalidation listener:",n)}}function U(){return E?Promise.resolve(E):(j||(j=fetch("/api/models/available").then(i=>{if(!i.ok)throw new Error("Failed to load models");return i.json()}).then(i=>(E=i,i)).catch(i=>{throw j=null,i})),j)}const pe=({value:i,onChange:n,onEnter:u,placeholder:s="Search model (e.g. openai/gpt-4o)...",className:g="",autoFocus:t=!1,connectedOnly:c=!0,disabled:o=!1,excludeValues:m,allowCombos:N=!0,fetchCustomModels:h})=>{const[w,A]=x.useState([]),[d,f]=x.useState(!1),[b,k]=x.useState(-1),[W,T]=x.useState(c),[Y,R]=x.useState("bottom"),I=x.useRef(null),q=x.useRef(null);x.useEffect(()=>{if(d&&I.current){const e=I.current.getBoundingClientRect(),p=280,l=window.innerHeight-e.bottom,F=e.top;l<p&&F>l?R("top"):R("bottom")}},[d]),x.useEffect(()=>{let e=!0;const p=()=>{(h?h():U()).then(r=>{e&&A(r)}).catch(()=>{})};p();const l=oe(()=>{e&&p()});return()=>{e=!1,l()}},[h]),x.useEffect(()=>{T(c)},[c]),x.useEffect(()=>{const e=p=>{I.current&&!I.current.contains(p.target)&&f(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]);const L=x.useMemo(()=>w.some(e=>e.hasConnectedAccount),[w]),O=x.useMemo(()=>{const e=(i||"").trim().toLowerCase(),p=new Set((m||[]).map(r=>r.toLowerCase()));let l=w;if(N===!1&&(l=l.filter(r=>!r.isCombo)),p.size>0&&(l=l.filter(r=>!p.has(r.value.toLowerCase())&&!p.has(r.id.toLowerCase()))),W&&L&&(l=l.filter(r=>r.hasConnectedAccount)),!e)return l.slice(0,50);const F=l.filter(r=>!!(r.value.toLowerCase().includes(e)||r.id.toLowerCase().includes(e)||r.name.toLowerCase().includes(e)||r.providerName.toLowerCase().includes(e)||r.providerId.toLowerCase().includes(e)||r.isCombo&&(r.strategy&&r.strategy.toLowerCase().includes(e)||r.models&&r.models.some(M=>M.toLowerCase().includes(e)))));return F.sort((r,D)=>{const M=r.value.toLowerCase(),P=D.value.toLowerCase(),_=r.id.toLowerCase(),z=D.id.toLowerCase();return M===e||_===e?-1:P===e||z===e?1:M.startsWith(e)||_.startsWith(e)?-1:P.startsWith(e)||z.startsWith(e)?1:r.isCombo&&!D.isCombo?-1:!r.isCombo&&D.isCombo?1:0}),F.slice(0,50)},[w,i,W,L,m,N]);x.useEffect(()=>{if(b>=0&&q.current){const e=q.current.children[b];e&&e.scrollIntoView({block:"nearest"})}},[b]);const J=e=>{if(!o)if(e.key==="ArrowDown")e.preventDefault(),d?k(p=>p<O.length-1?p+1:0):f(!0);else if(e.key==="ArrowUp")e.preventDefault(),d?k(p=>p>0?p-1:O.length-1):f(!0);else if(e.key==="Enter")if(d&&b>=0&&O[b]){e.preventDefault();const p=O[b];n(p.value),f(!1),k(-1),u&&u()}else f(!1),u&&(e.preventDefault(),u());else e.key==="Escape"&&(e.preventDefault(),f(!1),k(-1))},Q=e=>{n(e),f(!1),k(-1)};return a.jsxs("div",{ref:I,className:"relative w-full",children:[a.jsx("input",{type:"text",value:i,onChange:e=>{n(e.target.value),d||f(!0),k(-1)},onFocus:()=>{(w.length===0||!E)&&U().then(e=>A(e)).catch(()=>{}),f(!0)},onKeyDown:J,placeholder:s,disabled:o,autoFocus:t,className:g||"w-full bg-[#0A0D14] border border-[#1E293B] rounded-xl pl-3 pr-8 py-2 text-xs text-white font-mono focus:outline-none focus:border-blue-500"}),i&&!o&&a.jsx("button",{type:"button",onClick:()=>{n(""),k(-1)},className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-500 hover:text-white transition-colors cursor-pointer flex items-center justify-center",title:"Clear input",children:a.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"close"})}),d&&a.jsxs("div",{className:`absolute left-0 right-0 ${Y==="top"?"bottom-full mb-1.5":"top-full mt-1.5"} z-50 rounded-xl bg-[#0A0D14] border border-[#1E293B] shadow-2xl overflow-hidden animate-rt-scale-in min-w-[280px]`,children:[a.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-[#1E293B] bg-[#05070B] text-[11px]",children:[a.jsxs("span",{className:"text-slate-400 font-mono text-[10.5px]",children:[O.length," models ",i.trim()?"found":"available"]}),a.jsxs("button",{type:"button",onMouseDown:e=>{e.preventDefault(),T(!W)},className:`px-2 py-0.5 rounded-md font-sans text-[10.5px] font-medium flex items-center gap-1 transition-all cursor-pointer ${W?"bg-emerald-500/15 border border-emerald-500/30 text-emerald-400":"bg-slate-800 border border-slate-700 text-slate-400 hover:text-slate-200"}`,title:W?"Showing only models from connected accounts. Click to show all catalog models.":"Showing all catalog models. Click to filter by connected accounts.",children:[a.jsx("span",{className:"material-symbols-outlined text-[12px]",children:W?"check":"filter_alt"}),"Connected only"]})]}),a.jsx("div",{ref:q,className:"max-h-56 overflow-y-auto divide-y divide-[#1E293B]/40",children:O.length===0?a.jsxs("div",{className:"p-3 text-center text-xs text-slate-500 space-y-1",children:[a.jsx("p",{children:"No matching models in catalog."}),a.jsx("p",{className:"text-[10.5px] text-slate-400",children:"Custom IDs are supported. Press Enter or click outside to use your custom model ID."}),W&&!L&&a.jsx("button",{type:"button",onMouseDown:e=>{e.preventDefault(),T(!1)},className:"mt-1 text-[11px] text-blue-400 hover:underline",children:"View all registry models"})]}):O.map((e,p)=>{const l=p===b,F=e.value===i;return a.jsxs("div",{onMouseDown:r=>{r.preventDefault(),Q(e.value)},onMouseEnter:()=>k(p),className:`px-3 py-2 cursor-pointer transition-colors flex items-center justify-between gap-2.5 ${l?"bg-blue-600/20 text-white":F?"bg-[#141B2D] text-slate-100":"hover:bg-white/5 text-slate-300"}`,children:[a.jsxs("div",{className:"min-w-0 flex-1 space-y-0.5",children:[a.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.isCombo?a.jsx("span",{className:"px-1.5 py-0.2 rounded bg-cyan-500/20 border border-cyan-500/40 font-mono text-[9.5px] text-cyan-300 font-semibold tracking-wide",children:"COMBO"}):a.jsx("span",{className:"px-1.5 py-0.2 rounded bg-slate-800/80 border border-slate-700/60 font-mono text-[9.5px] text-slate-300",children:e.providerName||e.providerId}),a.jsx("span",{className:"font-medium text-xs text-slate-100 truncate",children:e.name}),e.isCombo&&e.strategy&&a.jsx("span",{className:`px-1.5 py-0.2 rounded font-sans text-[9px] font-medium border ${e.strategy==="round-robin"?"bg-cyan-950/40 text-cyan-300 border-cyan-500/30":e.strategy==="fusion"?"bg-purple-950/40 text-purple-300 border-purple-500/30":"bg-amber-950/40 text-amber-300 border-amber-500/30"}`,children:e.strategy==="round-robin"?"Round Robin":e.strategy==="fusion"?"Fusion":"Fallback"}),e.hasConnectedAccount&&a.jsx("span",{className:"size-1.5 rounded-full bg-emerald-400 shrink-0",title:`Connected account active (${e.accountsCount})`})]}),e.isCombo&&e.models&&e.models.length>0?a.jsxs("div",{className:"font-mono text-[10.5px] text-slate-400 truncate",children:[a.jsxs("span",{className:"text-cyan-400 font-semibold",children:[e.models.length," model",e.models.length>1?"s":"",":"]})," ",a.jsxs("span",{className:"text-slate-300",children:[e.models.slice(0,3).join(", "),e.models.length>3?` +${e.models.length-3} more`:""]})]}):a.jsx("div",{className:"font-mono text-[10.5px] text-slate-400 truncate",children:e.value})]}),a.jsx("div",{className:"shrink-0 flex items-center gap-1.5",children:a.jsx(ae,{caps:e.caps,size:"xs",showLabels:!1})})]},e.value)})})]})]})};export{ae as C,pe as M,ue as a,U as b,G as g,ce as i,oe as o};