mapigate 0.5.162 → 0.5.170

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 (120) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/tools/definitions/amp/definition.js +1 -1
  3. package/dist/cli/tools/definitions/claude/configurator.js +1 -1
  4. package/dist/cli/tools/definitions/claude/definition.js +5 -2
  5. package/dist/cli/tools/definitions/cline/definition.js +1 -1
  6. package/dist/cli/tools/definitions/codewhale/definition.js +1 -1
  7. package/dist/cli/tools/definitions/codex/definition.js +1 -1
  8. package/dist/cli/tools/definitions/continue/definition.js +1 -1
  9. package/dist/cli/tools/definitions/copilot/definition.js +1 -1
  10. package/dist/cli/tools/definitions/cowork/definition.js +1 -1
  11. package/dist/cli/tools/definitions/crush/definition.js +1 -1
  12. package/dist/cli/tools/definitions/deepseek-tui/definition.js +1 -1
  13. package/dist/cli/tools/definitions/droid/definition.js +1 -1
  14. package/dist/cli/tools/definitions/forge/definition.js +1 -1
  15. package/dist/cli/tools/definitions/grok-build/definition.js +1 -1
  16. package/dist/cli/tools/definitions/hermes/definition.js +1 -1
  17. package/dist/cli/tools/definitions/jcode/definition.js +1 -1
  18. package/dist/cli/tools/definitions/kilo/definition.js +1 -1
  19. package/dist/cli/tools/definitions/omp/definition.js +1 -1
  20. package/dist/cli/tools/definitions/openclaw/definition.js +1 -1
  21. package/dist/cli/tools/definitions/opencode/definition.js +1 -1
  22. package/dist/cli/tools/definitions/pi/definition.js +1 -1
  23. package/dist/cli/tools/definitions/qwen/definition.js +1 -1
  24. package/dist/cli/tools/definitions/roo/definition.js +1 -1
  25. package/dist/cli/tools/definitions/smelt/definition.js +1 -1
  26. package/dist/core/adapters/anthropic/requestAnthropicToOpenAi.js +3 -3
  27. package/dist/core/adapters/anthropic/requestOpenAiToAnthropic.js +2 -2
  28. package/dist/core/adapters/anthropic/responseConverters.js +3 -3
  29. package/dist/core/adapters/anthropic/streamOpenAiToAnthropic.js +29 -29
  30. package/dist/core/adapters/anthropic/types.js +1 -1
  31. package/dist/core/adapters/anthropicAdapter.js +1 -1
  32. package/dist/core/adapters/helpers/index.js +1 -1
  33. package/dist/core/adapters/helpers/streamToolCallTracker.js +1 -0
  34. package/dist/core/adapters/helpers/toolCallRescue.js +1 -1
  35. package/dist/core/adapters/helpers/toolSchemaNormalize.js +1 -1
  36. package/dist/core/adapters/helpers/zeroContentCheck.js +1 -1
  37. package/dist/core/adapters/responsesAdapter.js +2 -2
  38. package/dist/core/caching/promptCacheAffinity.js +3 -3
  39. package/dist/core/capabilities/index.js +1 -1
  40. package/dist/core/capabilities/patterns.js +1 -1
  41. package/dist/mitm/handlers/base.js +2 -2
  42. package/dist/providers/catalog/cerebras/metadata.js +1 -1
  43. package/dist/providers/catalog/coarena/metadata.js +1 -1
  44. package/dist/providers/catalog/groq/metadata.js +1 -1
  45. package/dist/providers/catalog/iteracompute/metadata.js +1 -1
  46. package/dist/providers/catalog/jan/metadata.js +1 -1
  47. package/dist/providers/catalog/kilo-gateway/metadata.js +1 -1
  48. package/dist/providers/catalog/lm-studio/metadata.js +1 -1
  49. package/dist/providers/catalog/mistral/metadata.js +1 -1
  50. package/dist/providers/catalog/nvidia/metadata.js +1 -1
  51. package/dist/providers/catalog/ollama-local/metadata.js +1 -1
  52. package/dist/providers/catalog/onomeo/metadata.js +1 -1
  53. package/dist/providers/catalog/opencode-go/responses.js +5 -5
  54. package/dist/providers/catalog/opencode-zen/metadata.js +1 -1
  55. package/dist/providers/catalog/openrouter/metadata.js +1 -1
  56. package/dist/providers/catalog/sail/metadata.js +1 -1
  57. package/dist/providers/catalog/sambanova/metadata.js +1 -1
  58. package/dist/providers/runtime/antigravity/executor.js +8 -8
  59. package/dist/providers/runtime/antigravity/metadata.js +1 -1
  60. package/dist/providers/runtime/antigravity/provider.js +1 -1
  61. package/dist/providers/runtime/antigravity/quota.js +1 -1
  62. package/dist/providers/runtime/antigravity/routes.js +1 -1
  63. package/dist/providers/runtime/antigravity/types.js +1 -1
  64. package/dist/providers/runtime/antigravity/weekly.js +1 -1
  65. package/dist/providers/runtime/cloudflare/metadata.js +1 -1
  66. package/dist/providers/runtime/gemini/metadata.js +1 -1
  67. package/dist/providers/runtime/gemini/provider.js +1 -1
  68. package/dist/providers/runtime/gemini-cli/provider.js +1 -1
  69. package/dist/providers/runtime/gemini-cli/quota.js +1 -1
  70. package/dist/providers/runtime/gemini-cli/routes.js +1 -1
  71. package/dist/providers/runtime/kiro/constants.js +1 -0
  72. package/dist/providers/runtime/kiro/createResponseStream.js +4 -4
  73. package/dist/providers/runtime/kiro/executor.js +6 -6
  74. package/dist/providers/runtime/kiro/index.js +1 -1
  75. package/dist/providers/runtime/kiro/metadata.js +1 -1
  76. package/dist/providers/runtime/kiro/provider.js +1 -1
  77. package/dist/providers/runtime/kiro/quota.js +1 -1
  78. package/dist/providers/runtime/ollama/metadata.js +1 -1
  79. package/dist/providers/runtime/opencode/metadata.js +1 -1
  80. package/dist/server/index.js +3 -3
  81. package/dist/server/middlewares/doubledV1Middleware.js +1 -0
  82. package/dist/server/proxy/executorHelpers.js +1 -1
  83. package/dist/server/proxy/pipeline.js +5 -5
  84. package/dist/server/proxy/responseHandlers.js +1 -1
  85. package/dist/server/proxy/routeSimulator.js +1 -0
  86. package/dist/server/proxy/singleModelExecutor.js +5 -5
  87. package/dist/server/proxy/streaming/sseStreamer.js +18 -18
  88. package/dist/server/routes/apiCliTools.js +1 -1
  89. package/dist/server/routes/apiModels.js +1 -1
  90. package/dist/storage/repositories/settingsRepo.js +2 -2
  91. package/dist/storage/repositories/toolMappingRepo.js +5 -4
  92. package/dist/web/assets/CliToolsTab-AP4tHWEj.js +171 -0
  93. package/dist/web/assets/ComboDetailPage-8ZPxPl5N.js +1 -0
  94. package/dist/web/assets/CombosTab-D0T91znw.js +1 -0
  95. package/dist/web/assets/{ConfirmModal-Co5OXd_g.js → ConfirmModal-gmHKbGNe.js} +1 -1
  96. package/dist/web/assets/{ConsoleLogTab-BTGaJpcD.js → ConsoleLogTab-Bpvxqa2f.js} +1 -1
  97. package/dist/web/assets/{EditAccountModal-DLyP9VNQ.js → EditAccountModal-PEltZRS8.js} +1 -1
  98. package/dist/web/assets/{EndpointTab-DbjjVT7s.js → EndpointTab-CYnFpxjA.js} +1 -1
  99. package/dist/web/assets/MitmTab-De7zsN2f.js +14 -0
  100. package/dist/web/assets/ModelAutocompleteInput-BH4gr6Dr.js +1 -0
  101. package/dist/web/assets/ModelSelectModal-B7-jAYUU.js +1 -0
  102. package/dist/web/assets/{ProviderDetailPage-CeOUazix.js → ProviderDetailPage-DvqxjQHh.js} +1 -1
  103. package/dist/web/assets/{ProvidersTab-Dd-prffr.js → ProvidersTab-DyeFqcx4.js} +1 -1
  104. package/dist/web/assets/{QuotaTab-zPkj0Rwo.js → QuotaTab-DrNRwUP6.js} +1 -1
  105. package/dist/web/assets/{SettingsTab-DUlhyz1z.js → SettingsTab-DS6HQKrg.js} +1 -1
  106. package/dist/web/assets/{ToolIcon-Cp4gSgFt.js → ToolIcon-BZE0Fv7L.js} +1 -1
  107. package/dist/web/assets/{UsageTab-Da7c7zwV.js → UsageTab-Du6U3MIb.js} +1 -1
  108. package/dist/web/assets/index-9wZva5_f.css +1 -0
  109. package/dist/web/assets/index-BvY11iVv.js +2 -0
  110. package/dist/web/assets/metadataRegistry-4BIaQVmV.js +1 -0
  111. package/dist/web/assets/{providersData-HX0E7hDv.js → providersData-C-7jZmPi.js} +1 -1
  112. package/dist/web/index.html +2 -2
  113. package/package.json +1 -1
  114. package/dist/web/assets/CliToolsTab-iJozQAQx.js +0 -168
  115. package/dist/web/assets/CombosTab-DdsJ2ova.js +0 -1
  116. package/dist/web/assets/MitmTab-DMRg64by.js +0 -14
  117. package/dist/web/assets/ModelAutocompleteInput-D0L1aj3-.js +0 -1
  118. package/dist/web/assets/index-CtfMJ11V.js +0 -2
  119. package/dist/web/assets/index-DXsZmXJg.css +0 -1
  120. package/dist/web/assets/metadataRegistry-CGDAkFU1.js +0 -1
@@ -1,14 +0,0 @@
1
- import{r as n,j as e}from"./vendor-BcOI2aZ9.js";import{u as kt,D as Ct,d as Mt,P as We,e as Tt}from"./index-CtfMJ11V.js";import{M as Ge}from"./ModelAutocompleteInput-D0L1aj3-.js";import{r as Je}from"./metadataRegistry-CGDAkFU1.js";import{T as Bt}from"./ToolIcon-Cp4gSgFt.js";import"./lucide-Cc35htxl.js";const Ne={},Et=({toolId:m="kiro",value:r,onChange:u,onEnter:b,placeholder:N="Select or type source model ID...",className:w="",autoFocus:x=!1,disabled:v=!1})=>{const f=(m||"kiro").toLowerCase(),[j,c]=n.useState([]),[g,y]=n.useState(!1),[S,E]=n.useState(-1),[oe,D]=n.useState("bottom"),M=n.useRef(null),I=n.useRef(null);n.useEffect(()=>{if(g&&M.current){const o=M.current.getBoundingClientRect(),p=240,T=window.innerHeight-o.bottom,O=o.top;T<p&&O>T?D("top"):D("bottom")}},[g]),n.useEffect(()=>{let o=!0;if(Ne[f]){c(Ne[f]);return}return fetch(`/api/mitm/mappings/source-models/${encodeURIComponent(f)}`).then(p=>{if(!p.ok)throw new Error("Failed to load source models");return p.json()}).then(p=>{o&&Array.isArray(p)&&(Ne[f]=p,c(p))}).catch(()=>{}),()=>{o=!1}},[f]),n.useEffect(()=>{const o=p=>{M.current&&!M.current.contains(p.target)&&y(!1)};return document.addEventListener("mousedown",o),()=>{document.removeEventListener("mousedown",o)}},[]);const h=n.useMemo(()=>{const o=(r||"").trim().toLowerCase();return o?j.filter(p=>p.id.toLowerCase().includes(o)||p.name.toLowerCase().includes(o)):j},[j,r]);n.useEffect(()=>{E(h.length>0?0:-1)},[h]),n.useEffect(()=>{if(g&&S>=0&&I.current){const o=I.current.children[S];o&&o.scrollIntoView({block:"nearest"})}},[S,g]);const W=o=>{u(o),y(!1)},le=o=>{o.key==="ArrowDown"?(o.preventDefault(),g?h.length>0&&E(p=>(p+1)%h.length):y(!0)):o.key==="ArrowUp"?(o.preventDefault(),g&&h.length>0&&E(p=>(p-1+h.length)%h.length)):o.key==="Enter"?g&&S>=0&&S<h.length?(o.preventDefault(),W(h[S].id)):b&&(o.preventDefault(),b()):o.key==="Escape"&&y(!1)};return e.jsxs("div",{ref:M,className:"relative w-full",children:[e.jsxs("div",{className:"relative flex items-center",children:[e.jsx("input",{type:"text",value:r,onChange:o=>{u(o.target.value),g||y(!0)},onFocus:()=>y(!0),onKeyDown:le,placeholder:N,disabled:v,autoFocus:x,className:w||"w-full bg-[#0A0D14] border border-[#1E293B] rounded-xl px-3 py-2 text-xs text-white font-mono focus:outline-none focus:border-blue-500 placeholder:text-slate-600"}),e.jsx("button",{type:"button",tabIndex:-1,onClick:()=>y(o=>!o),className:"absolute right-2 text-slate-500 hover:text-slate-300 p-0.5 rounded cursor-pointer",title:"Toggle model suggestions",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:g?"arrow_drop_up":"arrow_drop_down"})})]}),g&&h.length>0&&e.jsx("div",{ref:I,className:`absolute left-0 right-0 z-50 max-h-56 overflow-y-auto rounded-xl border border-[#1E293B] bg-[#0A0D14] shadow-2xl py-1 ${oe==="top"?"bottom-full mb-1":"top-full mt-1"}`,children:h.map((o,p)=>{const T=p===S,O=o.category==="native";return e.jsxs("div",{onClick:()=>W(o.id),onMouseEnter:()=>E(p),className:`px-3 py-2 flex items-center justify-between text-xs cursor-pointer transition-colors ${T?"bg-blue-600/20 text-white":"text-slate-300 hover:bg-white/5"}`,children:[e.jsxs("div",{className:"flex flex-col min-w-0 pr-2",children:[e.jsx("span",{className:"font-mono font-medium text-slate-100 truncate",children:o.id}),o.name&&o.name!==o.id&&e.jsx("span",{className:"text-[10.5px] text-slate-400 font-sans truncate",children:o.name})]}),e.jsx("div",{className:"flex-shrink-0",children:O?e.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-cyan-500/15 border border-cyan-500/30 text-[9.5px] font-mono text-cyan-300 uppercase tracking-wider font-semibold",children:[f," native"]}):e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-purple-500/15 border border-purple-500/30 text-[9.5px] font-mono text-purple-300 uppercase tracking-wider font-semibold",children:"Standard"})})]},`${o.category}-${o.id}`)})})]})},At={id:"antigravity",name:"Antigravity IDE",image:"/assets/providers/antigravity/icon.png",desc:"Intercept Google Antigravity IDE requests via MITM proxy",hosts:["daily-cloudcode-pa.googleapis.com","cloudcode-pa.googleapis.com"],urlPatterns:[":generateContent",":streamGenerateContent",":fetchAvailableModels","/v1internal:fetchAvailableModels"],defaultHost:`127.0.0.1 daily-cloudcode-pa.googleapis.com
2
- 127.0.0.1 cloudcode-pa.googleapis.com`,hostRewrite:{"cloudcode-pa.googleapis.com":"daily-cloudcode-pa.googleapis.com"},matchesHost:m=>{const r=(m||"").split(":")[0].trim().toLowerCase();return["cloudcode-pa.googleapis.com","daily-cloudcode-pa.googleapis.com"].some(u=>r===u||r.endsWith("."+u))},isModelListRequest:m=>(m.url||"").toLowerCase().includes("fetchavailablemodels"),modelSynonyms:{"gemini-default":"gemini-3.8-flash-medium","gemini-3.5-flash-high":"gemini-3.8-flash-high","gemini-3.5-flash-medium":"gemini-3.8-flash-medium","gemini-3.5-flash-low":"gemini-3.8-flash-low","gemini-3.5-flash-extra-low":"gemini-3.8-flash-low","gemini-3.8-flash":"gemini-3.8-flash-medium","gemini-3.8-flash-high":"gemini-3.8-flash-high","gemini-3.8-flash-medium":"gemini-3.8-flash-medium","gemini-3.8-flash-low":"gemini-3.8-flash-low","gemini-3.1-pro-high":"gemini-pro-agent","gemini-3-pro-high":"gemini-pro-agent","gemini-3-pro-low":"gemini-3.1-pro-low","claude-sonnet-5-5-max":"claude-sonnet-5-5-max","claude-sonnet-5-5-high":"claude-sonnet-5-5-high","claude-sonnet-5-5-medium":"claude-sonnet-5-5-medium","claude-sonnet-5-5-low":"claude-sonnet-5-5-low","claude-sonnet-5-5":"claude-sonnet-5-5","claude-sonnet-5.5":"claude-sonnet-5-5","claude-sonnet-5.5-max":"claude-sonnet-5-5-max","claude-sonnet-5.5-high":"claude-sonnet-5-5-high","claude-sonnet-5.5-medium":"claude-sonnet-5-5-medium","claude-sonnet-5.5-low":"claude-sonnet-5-5-low","claude-sonnet-5-5-thinking":"claude-sonnet-5-5","claude-sonnet-5.5-thinking":"claude-sonnet-5-5","claude-opus-5-5-max":"claude-opus-5-5-max","claude-opus-5-5-high":"claude-opus-5-5-high","claude-opus-5-5-medium":"claude-opus-5-5-medium","claude-opus-5-5-low":"claude-opus-5-5-low","claude-opus-5-5":"claude-opus-5-5","claude-opus-5.5":"claude-opus-5-5","claude-opus-5.5-max":"claude-opus-5-5-max","claude-opus-5.5-high":"claude-opus-5-5-high","claude-opus-5.5-medium":"claude-opus-5-5-medium","claude-opus-5.5-low":"claude-opus-5-5-low","claude-opus-5-5-thinking":"claude-opus-5-5","claude-opus-5.5-thinking":"claude-opus-5-5","claude-sonnet-4.6":"claude-sonnet-4-6","claude-opus-4.6":"claude-opus-4-6-thinking","claude-opus-4.6-thinking":"claude-opus-4-6-thinking","gemini-4-argon":"gemini-4-argon-medium","gemini-4-argon-high":"gemini-4-argon-high","gemini-4-argon-medium":"gemini-4-argon-medium","gemini-4-argon-low":"gemini-4-argon-low","gemini-4-carbon":"gemini-4-carbon-medium","gemini-4-carbon-high":"gemini-4-carbon-high","gemini-4-carbon-medium":"gemini-4-carbon-medium","gemini-4-carbon-low":"gemini-4-carbon-low","gemini-4-hydrogen":"gemini-4-hydrogen-medium","gemini-4-hydrogen-xhigh":"gemini-4-hydrogen-xhigh","gemini-4-hydrogen-high":"gemini-4-hydrogen-high","gemini-4-hydrogen-medium":"gemini-4-hydrogen-medium","gemini-4-hydrogen-low":"gemini-4-hydrogen-low","gemini-4-neon":"gemini-4-neon-medium","gemini-4-neon-xhigh":"gemini-4-neon-xhigh","gemini-4-neon-high":"gemini-4-neon-high","gemini-4-neon-medium":"gemini-4-neon-medium","gemini-4-neon-low":"gemini-4-neon-low"},modelPatterns:[{match:/flash.*extra.*low|extra.*low.*flash|flash.*low|low.*flash/i,alias:"gemini-3.8-flash-low"},{match:/flash.*medium|medium.*flash/i,alias:"gemini-3.8-flash-medium"},{match:/flash.*agent|agent.*flash|flash/i,alias:"gemini-3.8-flash-high"},{match:/pro.*low|low.*pro/i,alias:"gemini-3.1-pro-low"},{match:/gemini.*pro|pro.*gemini/i,alias:"gemini-pro-agent"},{match:/opus.*5[.-]5.*max|5[.-]5.*opus.*max/i,alias:"claude-opus-5-5-max"},{match:/opus.*5[.-]5.*high|5[.-]5.*opus.*high/i,alias:"claude-opus-5-5-high"},{match:/opus.*5[.-]5.*medium|5[.-]5.*opus.*medium/i,alias:"claude-opus-5-5-medium"},{match:/opus.*5[.-]5.*low|5[.-]5.*opus.*low/i,alias:"claude-opus-5-5-low"},{match:/sonnet.*5[.-]5.*max|5[.-]5.*sonnet.*max/i,alias:"claude-sonnet-5-5-max"},{match:/sonnet.*5[.-]5.*high|5[.-]5.*sonnet.*high/i,alias:"claude-sonnet-5-5-high"},{match:/sonnet.*5[.-]5.*medium|5[.-]5.*sonnet.*medium/i,alias:"claude-sonnet-5-5-medium"},{match:/sonnet.*5[.-]5.*low|5[.-]5.*sonnet.*low/i,alias:"claude-sonnet-5-5-low"},{match:/opus.*5[.-]5|5[.-]5.*opus/i,alias:"claude-opus-5-5"},{match:/sonnet.*5[.-]5|5[.-]5.*sonnet/i,alias:"claude-sonnet-5-5"},{match:/opus/i,alias:"claude-opus-4-6-thinking"},{match:/sonnet|claude/i,alias:"claude-sonnet-4-6"},{match:/gpt.*oss|oss/i,alias:"gpt-oss-120b-medium"},{match:/carbon.*high/i,alias:"gemini-4-carbon-high"},{match:/carbon.*low/i,alias:"gemini-4-carbon-low"},{match:/carbon/i,alias:"gemini-4-carbon-medium"},{match:/hydrogen.*xhigh/i,alias:"gemini-4-hydrogen-xhigh"},{match:/hydrogen.*high/i,alias:"gemini-4-hydrogen-high"},{match:/hydrogen.*low/i,alias:"gemini-4-hydrogen-low"},{match:/hydrogen/i,alias:"gemini-4-hydrogen-medium"},{match:/neon.*xhigh/i,alias:"gemini-4-neon-xhigh"},{match:/neon.*high/i,alias:"gemini-4-neon-high"},{match:/neon.*low/i,alias:"gemini-4-neon-low"},{match:/neon/i,alias:"gemini-4-neon-medium"},{match:/argon.*high|gemini.*4.*high/i,alias:"gemini-4-argon-high"},{match:/argon.*low|gemini.*4.*low/i,alias:"gemini-4-argon-low"},{match:/argon|gemini.*4/i,alias:"gemini-4-argon-medium"}],modelNoMap:[/^tab[_-]/i],defaultModels:["gemini-4-argon","gemini-4-argon-high","gemini-4-argon-medium","gemini-4-argon-low","gemini-4-carbon","gemini-4-carbon-high","gemini-4-carbon-medium","gemini-4-carbon-low","gemini-4-hydrogen","gemini-4-hydrogen-xhigh","gemini-4-hydrogen-high","gemini-4-hydrogen-medium","gemini-4-hydrogen-low","gemini-4-neon","gemini-4-neon-xhigh","gemini-4-neon-high","gemini-4-neon-medium","gemini-4-neon-low","gemini-3.8-flash-high","gemini-3.8-flash-medium","gemini-3.8-flash-low","gemini-3.1-pro-high","gemini-3.1-pro-low","claude-sonnet-5.5-thinking","claude-sonnet-5.5-high","claude-sonnet-5.5-medium","claude-sonnet-5.5-low","claude-opus-5.5-thinking","claude-opus-5.5-high","claude-opus-5.5-medium","claude-opus-5.5-low","claude-sonnet-4.6-thinking","claude-opus-4.6-thinking","gpt-oss-120b-medium"]},Dt={id:"copilot",name:"GitHub Copilot",image:"/assets/providers/github/icon.png",desc:"Intercept GitHub Copilot requests in VS Code via MITM proxy",hosts:["api.githubcopilot.com","copilot-proxy.githubusercontent.com","api.individual.githubcopilot.com","api.business.githubcopilot.com","api.enterprise.githubcopilot.com"],urlPatterns:["/chat/completions","/v1/messages","/responses","/models"],defaultHost:`127.0.0.1 api.githubcopilot.com
3
- 127.0.0.1 copilot-proxy.githubusercontent.com
4
- 127.0.0.1 api.individual.githubcopilot.com
5
- 127.0.0.1 api.business.githubcopilot.com
6
- 127.0.0.1 api.enterprise.githubcopilot.com`,matchesHost:m=>{const r=(m||"").split(":")[0].trim().toLowerCase();return["githubcopilot.com","copilot-proxy.githubusercontent.com"].some(u=>r===u||r.endsWith("."+u))},isModelListRequest:m=>{const r=(m.url||"").toLowerCase().split("?")[0];return r==="/models"||r==="/v1/models"||r.endsWith("/models")},defaultModels:["auto","claude-haiku-4.5","claude-haiku-5.5","claude-sonnet-4","claude-sonnet-4.6","claude-sonnet-5","claude-sonnet-5.5","claude-opus-4.8","claude-opus-5","claude-opus-5.5","claude-fable-5","claude-fable-5.1","claude-fable-5.2","copilot-search-a","copilot-search-b","gpt-3.5-turbo","gpt-4","gpt-4.1","gpt-4o","gpt-4o-mini","gpt-5-mini","gpt-5.2","gpt-5.2-codex","gpt-5.3-codex","gpt-5.4","gpt-5.4-nano","gpt-5.6-terra","gpt-5.6-luna","gpt-5.6-sol","gpt-6-astra","gpt-6-luna","gpt-6-sol","gpt-6.1-terra","gpt-6.1-sol","mai-code-1.1-flash","mai-code-2-flash","mai-code-2","gemini-3.7-flash","gemini-3.8-flash","gemini-4-argon","grok-4.5","grok-4.6","grok-4.7","kimi-k3"]},It={id:"kiro",name:"Kiro IDE",image:"/assets/providers/kiro/icon.png",desc:"Intercept Amazon Kiro IDE requests via MITM proxy",iconBg:"#9046ff",hosts:["management.us-east-1.kiro.dev","runtime.us-east-1.kiro.dev","q.us-east-1.amazonaws.com","codewhisperer.us-east-1.amazonaws.com"],urlPatterns:["/generateAssistantResponse","/responses","/List-Available-Models","/list-available-models","/ListAvailableModels","/listavailablemodels"],defaultHost:`127.0.0.1 management.us-east-1.kiro.dev
7
- 127.0.0.1 runtime.us-east-1.kiro.dev
8
- 127.0.0.1 q.us-east-1.amazonaws.com
9
- 127.0.0.1 codewhisperer.us-east-1.amazonaws.com`,matchesHost:m=>{const r=(m||"").split(":")[0].trim().toLowerCase();return["kiro.dev","q.us-east-1.amazonaws.com","codewhisperer.us-east-1.amazonaws.com"].some(u=>r===u||r.endsWith("."+u))},isChatRequest:m=>{var b;const r=(b=m.headers)==null?void 0:b["x-amz-target"],u=Array.isArray(r)?r[0]:String(r||"");return u.includes("GenerateAssistantResponse")||u.includes("CreateResponse")},isModelListRequest:m=>{var w;const r=(m.url||"").toLowerCase(),u=r.replace(/[-_]/g,"");if(u.includes("listavailablemodels")||u.includes("listmodels")||r.includes("list-available-models")||r.includes("listavailablemodels"))return!0;const b=(w=m.headers)==null?void 0:w["x-amz-target"],N=Array.isArray(b)?b[0]:String(b||"");return N.includes("ListAvailableModels")||N.includes("ListModels")},modelSynonyms:{"auto (kiro agent)":"auto","auto-(kiro-agent)":"auto","kiro-auto":"auto","claude-sonnet-4-5":"claude-sonnet-4.5","claude-haiku-4-5":"claude-haiku-4.5","claude-sonnet-5-5":"claude-sonnet-5.5","deepseek-3-2":"deepseek-3.2","minimax-m2-5":"minimax-m2.5","minimax-m2-1":"minimax-m2.1",glm5:"glm-5","qwen-3-coder-next":"qwen3-coder-next","qwen3-coder":"qwen3-coder-next"},modelPatterns:[{match:/auto.*kiro|kiro.*auto/i,alias:"auto"},{match:/claude.*sonnet.*4[.-]5/i,alias:"claude-sonnet-4.5"},{match:/claude.*haiku.*4[.-]5/i,alias:"claude-haiku-4.5"},{match:/claude.*sonnet.*4/i,alias:"claude-sonnet-4"},{match:/claude.*sonnet.*5[.-]5/i,alias:"claude-sonnet-5.5"},{match:/claude.*sonnet.*5/i,alias:"claude-sonnet-5"},{match:/deepseek.*3[.-]2/i,alias:"deepseek-3.2"},{match:/minimax.*2[.-]5/i,alias:"minimax-m2.5"},{match:/minimax.*2[.-]1/i,alias:"minimax-m2.1"},{match:/glm.*5/i,alias:"glm-5"},{match:/sol/i,alias:"gpt-5.6-sol"},{match:/terra/i,alias:"gpt-5.6-terra"},{match:/luna/i,alias:"gpt-5.6-luna"},{match:/qwen.*3.*coder/i,alias:"qwen3-coder-next"}],defaultModels:["auto","claude-opus-5.5","claude-opus-5","claude-opus-4.8","claude-opus-4.7","claude-opus-4.6","claude-opus-4.5","claude-sonnet-5.5","claude-sonnet-5","claude-sonnet-4.6","claude-sonnet-4.5","claude-sonnet-4","claude-haiku-5.5","claude-haiku-4.5","deepseek-3.2","minimax-m2.5","minimax-m2.1","kimi-k3","glm-5","simple-task","permission-classifier","gpt-5.6-sol","gpt-5.6-terra","gpt-5.6-luna","qwen3-coder-next"]},Ve=[At,Dt,It];function Pt(m,r="source",u="asc"){return[...m].sort((b,N)=>{if(r==="target"){const f=b.targetModel||"",j=N.targetModel||"";if(!f&&j)return 1;if(f&&!j)return-1;const c=f.localeCompare(j,void 0,{numeric:!0,sensitivity:"base"});if(c!==0)return u==="asc"?c:-c}const w=b.sourceModel.toLowerCase()==="auto",x=N.sourceModel.toLowerCase()==="auto";if(w&&!x)return u==="asc"?-1:1;if(!w&&x)return u==="asc"?1:-1;const v=b.sourceModel.localeCompare(N.sourceModel,void 0,{numeric:!0,sensitivity:"base"});return u==="asc"?v:-v})}const $t=()=>{const m=kt(t=>t.info),r=(m==null?void 0:m.port)||Ct,u=(m==null?void 0:m.host)||Mt,[b,N]=n.useState(""),w=b||`http://${u}:${r}`,[x,v]=n.useState(!0),[f,j]=n.useState(443),[c,g]=n.useState(null),[y,S]=n.useState(""),[E,oe]=n.useState(!1),[D,M]=n.useState(!1),[I,h]=n.useState(null),[W,le]=n.useState(!0),[o,p]=n.useState(!1),[T,O]=n.useState(""),[re,Ye]=n.useState(""),[G,Qe]=n.useState({windows:'certutil -addstore -user "Root" "%USERPROFILE%\\.mapigate\\mitm\\rootCA.crt"',mac:"sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/.mapigate/mitm/rootCA.crt",linux:"sudo cp ~/.mapigate/mitm/rootCA.crt /usr/local/share/ca-certificates/mapigate-rootCA.crt && sudo update-ca-certificates"}),[P,we]=n.useState(null),[ve,Se]=n.useState(!1),[ke,Ce]=n.useState(!1),[J,k]=n.useState(null),[Me,U]=n.useState({antigravity:!1,kiro:!1,copilot:!1}),[R,V]=n.useState({antigravity:!1,kiro:!1,copilot:!1}),[Xe,Ze]=n.useState(null),et=n.useMemo(()=>[...Ve].sort((t,s)=>t.name.localeCompare(s.name)),[]),[Te,Y]=n.useState({antigravity:`127.0.0.1 daily-cloudcode-pa.googleapis.com
10
- 127.0.0.1 cloudcode-pa.googleapis.com`,kiro:`127.0.0.1 management.us-east-1.kiro.dev
11
- 127.0.0.1 runtime.us-east-1.kiro.dev
12
- 127.0.0.1 q.us-east-1.amazonaws.com
13
- 127.0.0.1 codewhisperer.us-east-1.amazonaws.com`,copilot:"127.0.0.1 api.individual.githubcopilot.com"}),[tt,ce]=n.useState({}),[Be,st]=n.useState({}),[at,Q]=n.useState({}),[nt,H]=n.useState({antigravity:[],kiro:[],copilot:[]}),[it,ot]=n.useState({}),[lt,Ee]=n.useState({}),[rt,de]=n.useState(null),[X,me]=n.useState(null),[ue,Z]=n.useState(""),[L,$]=n.useState(null),[pe,xe]=n.useState(""),[he,ge]=n.useState(""),[Ae,ct]=n.useState(new Set),[q,De]=n.useState(""),[F,Ie]=n.useState(""),[Pe,Re]=n.useState(!1),[Le,_e]=n.useState(!1),[Oe,Ue]=n.useState(!1),[ee,be]=n.useState(null),[te,K]=n.useState(null),[se,dt]=n.useState([]),z=n.useMemo(()=>{const t=q.trim().toLowerCase();return t?!t.includes("127.0.0.1")&&!t.includes("localhost")&&!t.includes("0.0.0.0"):!1},[q]);n.useEffect(()=>{fetch("/api/combos").then(t=>t.ok?t.json():[]).then(t=>{const s=Array.isArray(t)?t:t.combos||[];ct(new Set(s.map(i=>(i.name||"").toLowerCase())))}).catch(()=>{})},[]);const _=(t,s)=>{navigator.clipboard.writeText(s),we(t),setTimeout(()=>we(null),2e3)},A=()=>{fetch("/api/mitm/status").then(t=>t.json()).then(t=>{v(!!t.running),t.port&&j(t.port),le(!!t.certExists),p(!!t.certTrusted),t.certPath&&O(t.certPath),t.fingerprint&&Ye(t.fingerprint),t.routerBaseUrl&&N(t.routerBaseUrl),t.installCommands&&Qe(t.installCommands),t.dnsStatus&&U(s=>{var i,a,d;return{...s,antigravity:!!((i=t.dnsStatus)!=null&&i.antigravity),kiro:!!((a=t.dnsStatus)!=null&&a.kiro),copilot:!!((d=t.dnsStatus)!=null&&d.copilot)}}),t.augmentModels&&V(s=>({...s,...t.augmentModels})),Tt.getState().fetchStatus()}).catch(()=>{}),fetch("/api/mitm/router-target").then(t=>t.ok?t.json():null).then(t=>{t&&(De(t.baseUrl||""),Re(!!t.hasApiKey),t.isRemote&&t.baseUrl&&He())}).catch(()=>{})},He=()=>{fetch("/api/mitm/router-target/models").then(t=>t.ok?t.json():{models:[]}).then(t=>{const s=(t.models||[]).map(i=>({id:i.id,value:i.id,name:i.name||i.id,providerId:i.provider||"remote",providerName:i.provider||"Remote Gateway",hasConnectedAccount:!0,accountsCount:1,caps:{vision:!0,reasoning:!0,audio:!1},contextLength:128e3}));dt(s)}).catch(()=>{})},mt=async()=>{_e(!0),be(null);try{const s=await(await fetch("/api/mitm/router-target/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:q.trim(),apiKey:F.trim()||void 0})})).json();be({success:!!s.success,message:s.message||(s.success?"Connection successful":"Connection failed")}),s.success&&z&&He()}catch(t){be({success:!1,message:(t==null?void 0:t.message)||"Test request failed"})}finally{_e(!1)}},ut=async()=>{if(!x){Ue(!0),K(null);try{const s=await(await fetch("/api/mitm/router-target",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:q.trim(),apiKey:F!==""?F.trim():void 0})})).json();s.success?(K({success:!0,message:"Target configuration saved!"}),Re(!!s.hasApiKey),Ie(""),A()):K({success:!1,message:s.error||"Failed to save target"})}catch(t){K({success:!1,message:(t==null?void 0:t.message)||"Failed to save target"})}finally{Ue(!1),setTimeout(()=>K(null),3e3)}}},pt=()=>{Ve.forEach(t=>{fetch(`/api/mitm/hosts/${t.id}`).then(s=>s.json()).then(s=>{s.entries&&Y(i=>({...i,[t.id]:s.entries}))}).catch(()=>{}),fetch(`/api/mitm/mappings/${t.id}`).then(s=>s.json()).then(s=>{Array.isArray(s)&&H(i=>({...i,[t.id]:s}))}).catch(()=>{})})};n.useEffect(()=>{A(),pt()},[]);const ae=async(t=!1,s)=>{h(null);let i;if(s!==void 0)i=s;else if(y.trim()){const a=Number(y.trim());if(isNaN(a)||!Number.isInteger(a)||a<1||a>65535){h("Port must be an integer between 1 and 65535.");return}i=a}if(x&&!t){v(!1);try{const d=await(await fetch("/api/mitm/toggle-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({running:!1})})).json();v(!!d.running),d.port&&j(d.port),d.dnsStatus&&U({antigravity:!!d.dnsStatus.antigravity,kiro:!!d.dnsStatus.kiro,copilot:!!d.dnsStatus.copilot}),A()}catch(a){h((a==null?void 0:a.message)||"Failed to stop server")}return}t&&M(!0);try{const a=await fetch("/api/mitm/toggle-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({running:!0,port:i,forceKill:t})});if(a.status===409){const B=await a.json();g(B.portOwner||{port:i||443,inUse:!0}),v(!1);return}if(!a.ok){const B=await a.json().catch(()=>({}));throw new Error(B.error||`Failed to start server (${a.status})`)}const d=await a.json();v(!!d.running),d.port&&j(d.port),d.dnsStatus&&U({antigravity:!!d.dnsStatus.antigravity,kiro:!!d.dnsStatus.kiro,copilot:!!d.dnsStatus.copilot}),d.warning&&h(d.warning),g(null),A()}catch(a){h((a==null?void 0:a.message)||"Failed to start server")}finally{M(!1)}},xt=async()=>{Se(!0),k(null);try{const s=await(await fetch("/api/mitm/install-cert",{method:"POST"})).json();s.success?(k({type:"success",text:s.message||"Root CA installed successfully!"}),A()):k({type:"error",text:s.message||"Installation failed"})}catch(t){k({type:"error",text:(t==null?void 0:t.message)||"Failed to install certificate"})}finally{Se(!1)}},ht=async()=>{Ce(!0),k(null);try{const s=await(await fetch("/api/mitm/uninstall-cert",{method:"POST"})).json();s.success?(k({type:"success",text:s.message||"Root CA uninstalled successfully!"}),A()):k({type:"error",text:s.message||"Uninstallation failed"})}catch(t){k({type:"error",text:(t==null?void 0:t.message)||"Failed to uninstall certificate"})}finally{Ce(!1)}},gt=async t=>{const s=!Me[t];U(i=>({...i,[t]:s}));try{const a=await(await fetch("/api/mitm/toggle-dns",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:t,active:s})})).json();a.dnsStatus&&U(d=>({...d,antigravity:!!a.dnsStatus.antigravity,kiro:!!a.dnsStatus.kiro,copilot:!!a.dnsStatus.copilot})),a.warning&&h(a.warning),A()}catch{}},bt=async t=>{const s=!R[t];V(i=>({...i,[t]:s}));try{const a=await(await fetch("/api/mitm/augment-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:t,enabled:s})})).json();a.augmentModels&&V(d=>({...d,...a.augmentModels}))}catch{V(i=>({...i,[t]:!s}))}},ft=async t=>{const s=Te[t]||"";try{(await fetch(`/api/mitm/hosts/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:s})})).ok&&(Q(a=>({...a,[t]:"Saved hosts successfully."})),ce(a=>({...a,[t]:!1})),setTimeout(()=>{Q(a=>({...a,[t]:null}))},3e3))}catch{}},yt=async t=>{try{const i=await(await fetch(`/api/mitm/hosts/${t}/reset`,{method:"POST"})).json();i.entries&&(Y(a=>({...a,[t]:i.entries})),Q(a=>({...a,[t]:"Hosts reset to default."})),setTimeout(()=>{Q(a=>({...a,[t]:null}))},3e3))}catch{}},jt=async t=>{try{const i=await(await fetch("/api/mitm/mappings/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ide:t})})).json();Array.isArray(i.mappings)&&H(a=>({...a,[t]:i.mappings}))}catch{}},Nt=async()=>{if(!L||!pe.trim()||!he.trim())return;const t=L,s={sourceModel:pe.trim(),targetModel:he.trim()};H(i=>({...i,[t]:[...i[t]||[],s]}));try{await fetch("/api/mitm/mappings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ide:t,sourceModel:s.sourceModel,targetModel:s.targetModel})})}catch{}finally{xe(""),ge(""),$(null)}},$e=async t=>{if(!X||!ue.trim())return;let s=ue.trim();Ae.has(s.toLowerCase())&&!s.startsWith("combo/")&&(s=`combo/${s}`),H(i=>({...i,[t]:(i[t]||[]).map(a=>a.sourceModel===X?{...a,targetModel:s}:a)}));try{await fetch("/api/mitm/mappings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ide:t,sourceModel:X,targetModel:s})})}catch{}finally{me(null),de(null),Z("")}},wt=(t,s)=>{H(i=>({...i,[t]:(i[t]||[]).filter(a=>a.sourceModel!==s)})),fetch(`/api/mitm/mappings/${t}?sourceModel=${encodeURIComponent(s)}`,{method:"DELETE"}).catch(()=>{})};return e.jsxs("div",{className:"space-y-6 w-full px-2 sm:px-4 pb-16 animate-rt-fade-in",children:[e.jsxs("div",{className:"flex items-start gap-2.5 px-4 py-3 rounded-xl bg-amber-500/10 border border-amber-500/20 text-xs text-amber-300 leading-relaxed",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] text-amber-400 shrink-0",children:"warning"}),e.jsxs("p",{children:[e.jsx("strong",{children:"MITM Interceptor:"})," Intercepts HTTPS traffic of closed IDE tools (Antigravity, Kiro, GitHub Copilot) via a local Root CA to redirect requests to your chosen providers and models. DNS is controlled independently per tool."]})]}),e.jsxs("div",{className:"flex items-start gap-2.5 px-4 py-3 rounded-xl bg-blue-500/10 border border-blue-500/20 text-xs text-blue-300 leading-relaxed",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] text-blue-400 shrink-0",children:"info"}),e.jsx("p",{className:"font-mono text-[11px] sm:text-xs text-blue-200",children:"How it works: Antigravity/Kiro IDE request → DNS redirect to localhost:443 → MITM proxy intercepts → Mapigate → response to Antigravity/Kiro"})]}),e.jsxs("div",{className:"rt-card p-5 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 pb-3 border-b border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-9 rounded-xl bg-cyan-500/10 border border-cyan-500/20 text-cyan-400 flex items-center justify-center shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"alt_route"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-sm font-bold text-white",children:"MITM HTTPS Proxy Server"}),e.jsx("span",{className:`rt-badge ${x?"rt-badge--success":"rt-badge--muted"}`,children:x?`● Running (Port :${f})`:"Stopped"})]}),e.jsxs("p",{className:"text-xs text-slate-400 mt-0.5",children:["Intercepts inbound IDE requests via SNI certificate emulation on port ",f,"."]})]})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("button",{onClick:()=>ae(),className:`rt-btn text-xs py-1.5 px-3.5 ${x?"rt-btn--danger":"rt-btn--primary"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:x?"stop":"play_arrow"}),x?"Stop Server":"Start Server"]})})]}),I&&e.jsxs("div",{className:"p-3 rounded-xl bg-rose-500/10 border border-rose-500/30 text-xs text-rose-300 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-rose-400",children:"error"}),e.jsx("span",{children:I})]}),e.jsx("button",{type:"button",onClick:()=>h(null),className:"text-rose-400 hover:text-white",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"close"})})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 pt-1 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"font-semibold text-slate-300",children:"Active Gateway Endpoint:"}),e.jsx("code",{className:"text-blue-400 font-mono bg-[#0A0D14] px-3 py-1.5 rounded-lg border border-[#1E293B]",children:w})]}),e.jsx("span",{className:"text-[11px] text-slate-400 italic",children:"Enable DNS per tool below to activate redirection"})]}),e.jsx("div",{className:"pt-3 border-t border-[#1E293B]",children:e.jsxs("div",{className:"p-3.5 bg-[#0A0D14] rounded-xl border border-[#1E293B] space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] text-cyan-400",children:"hub"}),e.jsx("span",{className:"text-xs font-bold text-white",children:"Target Gateway"}),z?e.jsx("span",{className:"rt-badge rt-badge--info",children:"Remote Machine"}):e.jsx("span",{className:"rt-badge rt-badge--success",children:"Local Machine"})]}),x&&e.jsxs("span",{className:"text-[11px] text-amber-400/90 flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"lock"}),"Stop server to edit target configuration"]})]}),e.jsx("p",{className:"text-[11.5px] text-slate-400 leading-relaxed",children:"Specify where intercepted prompts are forwarded. Leave URL blank to route to this machine's local Mapigate Gateway, or enter another IP/URL to delegate requests to a remote machine."}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 pt-1",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-semibold text-slate-300 block mb-1",children:"Gateway Base URL"}),e.jsx("input",{type:"text",placeholder:`Leave blank for local (${w})`,value:q,disabled:x,onChange:t=>De(t.target.value),className:"w-full bg-[#141B2D] border border-[#1E293B] rounded-lg px-2.5 py-1.5 text-xs font-mono text-white placeholder-slate-500 focus:outline-none focus:border-blue-500 disabled:opacity-50 disabled:cursor-not-allowed"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[11px] font-semibold text-slate-300 block mb-1",children:["Gateway API Key ",Pe&&!F&&"(Configured ✓)"]}),e.jsx("input",{type:"password",disabled:x,placeholder:Pe?"•••••••••••• (Leave blank to keep)":z?"Optional (Required if Target requires key)":"Optional (Dedicated MITM key used by default)",value:F,onChange:t=>Ie(t.target.value),className:"w-full bg-[#141B2D] border border-[#1E293B] rounded-lg px-2.5 py-1.5 text-xs font-mono text-white placeholder-slate-500 focus:outline-none focus:border-blue-500 disabled:opacity-50 disabled:cursor-not-allowed"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 pt-1",children:[e.jsxs("div",{className:"text-xs",children:[ee&&e.jsxs("span",{className:`inline-flex items-center gap-1 text-[11.5px] ${ee.success?"text-emerald-400":"text-rose-400"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:ee.success?"check_circle":"cancel"}),ee.message]}),te&&e.jsxs("span",{className:`inline-flex items-center gap-1 text-[11.5px] ${te.success?"text-emerald-400":"text-rose-400"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:te.success?"check":"error"}),te.message]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",disabled:Le,onClick:mt,className:"rt-btn rt-btn--secondary text-xs py-1 px-3 flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"network_check"}),Le?"Testing...":"Test Connection"]}),e.jsxs("button",{type:"button",disabled:Oe||x,title:x?"Stop MITM server before editing target configuration":void 0,onClick:ut,className:"rt-btn rt-btn--primary text-xs py-1 px-3.5 flex items-center gap-1 disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"save"}),Oe?"Saving...":"Save Target"]})]})]})]})}),e.jsxs("div",{className:"pt-2 border-t border-[#1E293B]/60",children:[e.jsxs("button",{type:"button",onClick:()=>oe(t=>!t),className:"flex items-center gap-1.5 text-xs text-slate-400 hover:text-slate-200 transition-colors cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:E?"expand_less":"tune"}),e.jsx("span",{children:"Advanced / Custom Port Configuration"})]}),E&&e.jsxs("div",{className:"mt-3 p-3.5 bg-[#0A0D14] rounded-xl border border-[#1E293B] space-y-3",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-3 justify-between",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-slate-300 block",children:"Custom MITM Listen Port"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Default is port 443. Custom ports are for manual developer testing only."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",min:"1",max:"65535",placeholder:"443",value:y,onChange:t=>S(t.target.value),disabled:x,className:"w-24 bg-[#141B2D] border border-[#1E293B] rounded-lg px-2.5 py-1.5 text-xs font-mono text-white text-center focus:outline-none focus:border-blue-500 disabled:opacity-50"}),!x&&y&&e.jsx("button",{type:"button",onClick:()=>S(""),className:"text-xs text-slate-400 hover:text-white px-1.5 py-1 rounded",title:"Reset to default 443",children:"Reset"})]})]}),e.jsxs("div",{className:"flex items-start gap-2 p-2.5 rounded-lg bg-amber-500/10 border border-amber-500/20 text-[11.5px] text-amber-300 leading-relaxed",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-amber-400 shrink-0 mt-0.5",children:"warning"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Notice:"})," OS ",e.jsx("code",{children:"hosts"})," file redirection maps domain names to IP addresses without port numbers. AI coding tools (Antigravity, Kiro, Copilot) connect to port 443 by default. Running on custom ports will ",e.jsx("strong",{children:"not"})," intercept standard IDE traffic."]})]})]})]})]}),e.jsxs("div",{className:"rt-card p-5 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 pb-3 border-b border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-9 rounded-xl bg-purple-500/10 border border-purple-500/20 text-purple-400 flex items-center justify-center shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"verified_user"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"text-sm font-bold text-white",children:"SSL Root CA Certificate"}),o?e.jsxs("span",{className:"rt-badge rt-badge--success",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"check"})," Trusted in System"]}):e.jsxs("span",{className:"rt-badge rt-badge--warning",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"info"})," Not Yet Trusted"]}),W&&e.jsx("span",{className:"rt-badge rt-badge--info",children:"Generated"})]}),e.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:"Required for IDEs to accept MITM proxy SSL handshakes without security warnings."})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:async()=>{try{const t=await fetch("/api/mitm/cert");if(!t.ok)throw new Error(`HTTP ${t.status}`);const s=await t.blob(),i=URL.createObjectURL(s),a=document.createElement("a");a.href=i,a.download="mapigate-rootCA.crt",document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}catch(t){k({type:"error",text:(t==null?void 0:t.message)||"Failed to download Root CA certificate."})}},className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"download"}),"Download CA"]}),o?e.jsxs("button",{disabled:ke,onClick:ht,className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3.5 flex items-center gap-1.5 text-rose-400 hover:text-rose-300 border-rose-500/20",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"delete"}),ke?"Uninstalling...":"Uninstall from System"]}):e.jsxs("button",{disabled:ve,onClick:xt,className:"rt-btn rt-btn--primary text-xs py-1.5 px-3.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"add_task"}),ve?"Installing...":"Install to System Store"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 text-xs",children:[e.jsxs("div",{className:"p-3 bg-[#0A0D14] rounded-xl border border-[#1E293B] space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-400 font-medium",children:"SHA1 Fingerprint:"}),re&&e.jsxs("button",{onClick:()=>_("fp",re),className:"text-blue-400 hover:text-blue-300 font-mono text-[11px] flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"content_copy"}),P==="fp"?"Copied":"Copy"]})]}),e.jsx("code",{className:"text-purple-300 font-mono text-[11px] block break-all",children:re||"Generating upon first start..."})]}),e.jsxs("div",{className:"p-3 bg-[#0A0D14] rounded-xl border border-[#1E293B] space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-400 font-medium",children:"CA File Path:"}),T&&e.jsxs("button",{onClick:()=>_("cp",T),className:"text-blue-400 hover:text-blue-300 font-mono text-[11px] flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"content_copy"}),P==="cp"?"Copied":"Copy"]})]}),e.jsx("code",{className:"text-slate-300 font-mono text-[11px] block truncate",children:T||"~/.mapigate/mitm/rootCA.crt"})]})]}),e.jsxs("div",{className:"space-y-2 text-xs",children:[e.jsx("span",{className:"font-semibold text-slate-300 block",children:"Manual Installation Commands:"}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-2.5",children:[e.jsxs("div",{className:"p-3 rounded-xl bg-[#0A0D14] border border-[#1E293B] space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-400 font-medium",children:"Windows (PowerShell / cmd):"}),e.jsxs("button",{onClick:()=>_("winCmd",G.windows),className:"text-blue-400 hover:text-blue-300 font-mono text-[11px] flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"content_copy"}),P==="winCmd"?"Copied!":"Copy"]})]}),e.jsx("code",{className:"text-emerald-400 font-mono text-[11px] block break-all bg-[#05070B] p-2 rounded-lg border border-[#1E293B]",children:G.windows})]}),e.jsxs("div",{className:"p-3 rounded-xl bg-[#0A0D14] border border-[#1E293B] space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-400 font-medium",children:"macOS (Terminal):"}),e.jsxs("button",{onClick:()=>_("macCmd",G.mac),className:"text-blue-400 hover:text-blue-300 font-mono text-[11px] flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"content_copy"}),P==="macCmd"?"Copied!":"Copy"]})]}),e.jsx("code",{className:"text-emerald-400 font-mono text-[11px] block break-all bg-[#05070B] p-2 rounded-lg border border-[#1E293B]",children:G.mac})]})]})]}),J&&e.jsxs("div",{className:`p-2.5 rounded-xl text-xs flex items-center gap-2 ${J.type==="success"?"bg-emerald-500/10 border border-emerald-500/20 text-emerald-400":"bg-red-500/10 border border-red-500/20 text-red-400"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:J.type==="success"?"check_circle":"error"}),J.text]})]}),e.jsx("div",{className:"space-y-4",children:et.map(t=>{const s=Xe===t.id,i=!!Me[t.id],a=!!tt[t.id],d=Te[t.id]||t.defaultHost,B=it[t.id]||"source",ne=lt[t.id]||"asc",qe=Pt(nt[t.id]||[],B,ne),Fe=at[t.id],Ke=l=>{B===l?Ee(C=>({...C,[t.id]:ne==="asc"?"desc":"asc"})):(ot(C=>({...C,[t.id]:l})),Ee(C=>({...C,[t.id]:"asc"})))};return e.jsxs("div",{className:"rt-card p-5 space-y-4",children:[e.jsxs("div",{onClick:()=>Ze(s?null:t.id),className:"flex items-center justify-between cursor-pointer select-none",children:[e.jsxs("div",{className:"flex items-center gap-3.5",children:[e.jsx(Bt,{src:t.image,name:t.name,iconBg:t.iconBg,size:"md"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"text-sm font-bold text-white",children:t.name}),e.jsx("span",{className:`rt-badge ${i?"rt-badge--success":"rt-badge--muted"}`,children:i?"DNS on":"DNS off"})]}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:t.desc})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:l=>{l.stopPropagation(),gt(t.id)},className:`rt-btn text-xs py-1.5 px-3 ${i?"rt-btn--danger":"rt-btn--primary"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:i?"stop":"play_arrow"}),i?"Stop DNS":"Start DNS"]}),e.jsx("span",{className:"material-symbols-outlined text-[20px] text-slate-500",children:s?"expand_less":"expand_more"})]})]}),s&&e.jsxs("div",{className:"pt-4 border-t border-[#1E293B] space-y-5 text-xs animate-rt-fade-in",children:[e.jsxs("div",{className:"space-y-3 p-4 rounded-xl bg-[#0A0D14] border border-[#1E293B]",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs("h5",{className:"font-bold text-white flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-blue-400 text-[16px]",children:"dns"}),"Hosts File Entries (",t.name,")"]}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Domain mappings added to your system hosts file when DNS redirection is enabled."})]}),e.jsx("div",{className:"flex items-center gap-2",children:a?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{Be[t.id]!==void 0&&Y(l=>({...l,[t.id]:Be[t.id]})),ce(l=>({...l,[t.id]:!1}))},className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"close"}),"Cancel"]}),e.jsxs("button",{onClick:()=>ft(t.id),className:"rt-btn rt-btn--primary text-xs py-1.5 px-3 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"save"}),"Save Hosts"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>yt(t.id),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3 flex items-center gap-1.5",title:"Reset hosts entries to tool default",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"}),"Reset"]}),e.jsxs("button",{onClick:()=>{st(l=>({...l,[t.id]:d})),ce(l=>({...l,[t.id]:!0}))},className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"edit"}),"Edit"]})]})})]}),e.jsx("textarea",{readOnly:!a,rows:Math.max(2,d.split(`
14
- `).length+1),value:d,onChange:l=>Y(C=>({...C,[t.id]:l.target.value})),className:`w-full border rounded-xl p-3 text-xs font-mono leading-relaxed transition-colors ${a?"bg-[#05070B] border-blue-500/60 text-emerald-400 cursor-text focus:outline-none focus:border-blue-500":"bg-[#07090E] border-[#1E293B] text-emerald-400/80 cursor-default focus:outline-none"}`,placeholder:"127.0.0.1 domain"}),Fe&&e.jsxs("div",{className:"text-[11px] text-emerald-400 font-mono flex items-center gap-1.5 animate-rt-scale-in",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"check_circle"}),Fe]})]}),(t.id==="kiro"||!!t.isModelListRequest)&&e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 p-4 rounded-xl bg-[#0A0D14] border border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-start sm:items-center gap-3",children:[e.jsx("div",{className:"size-8 rounded-lg bg-purple-500/10 border border-purple-500/20 text-purple-400 flex items-center justify-center shrink-0 mt-0.5 sm:mt-0",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"auto_awesome"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-bold text-white text-xs",children:"Augment Models in IDE"}),e.jsx("span",{className:`rt-badge ${R[t.id]?"rt-badge--success":"rt-badge--muted"}`,children:R[t.id]?"Enabled":"Disabled"})]}),e.jsxs("p",{className:"text-[11px] text-slate-400 mt-0.5",children:["Injects Mapigate's rich model catalog into ",t.name," so you can select from all models in the IDE regardless of your account's tier."]})]})]}),e.jsxs("button",{type:"button",onClick:()=>bt(t.id),className:`rt-btn text-xs py-1.5 px-3.5 shrink-0 flex items-center gap-1.5 cursor-pointer ${R[t.id]?"rt-btn--primary":"rt-btn--secondary"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:R[t.id]?"toggle_on":"toggle_off"}),R[t.id]?"Enabled":"Enable"]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-bold text-slate-200 block text-xs",children:["Model Redirection Mappings (",t.name,")"]}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Map requested models to your chosen Mapigate providers and upstream model IDs (slashes / supported)."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>jt(t.id),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",title:"Reset to default mappings",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"}),"Reset to Default"]}),e.jsxs("button",{onClick:()=>{$(t.id),xe(""),ge("")},className:"rt-btn rt-btn--primary text-xs py-1.5 px-3",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"add"}),"Add Mapping"]})]})]}),e.jsx("div",{className:"rounded-xl border border-[#1E293B] overflow-visible bg-[#0A0D14]",children:qe.length===0?e.jsxs("div",{className:"p-4 text-xs text-slate-500 italic text-center",children:["No model mappings configured for ",t.name,". Click 'Add Mapping' or 'Reset to Default'."]}):e.jsxs("table",{className:"w-full text-left text-xs font-mono",children:[e.jsx("thead",{className:"bg-[#0D121F] text-slate-400 font-sans text-[11px] uppercase tracking-wider border-b border-[#1E293B]",children:e.jsxs("tr",{children:[e.jsx("th",{onClick:()=>Ke("source"),className:"p-3 font-semibold cursor-pointer hover:text-white select-none transition-colors",title:"Click to sort by Source Model",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:"Source Model (IDE)"}),e.jsx("span",{className:"material-symbols-outlined text-[14px] text-blue-400",children:B==="source"?ne==="asc"?"arrow_upward":"arrow_downward":"unfold_more"})]})}),e.jsx("th",{onClick:()=>Ke("target"),className:"p-3 font-semibold cursor-pointer hover:text-white select-none transition-colors",title:"Click to sort by Target Model",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:"Target Model (Mapigate)"}),e.jsx("span",{className:"material-symbols-outlined text-[14px] text-blue-400",children:B==="target"?ne==="asc"?"arrow_upward":"arrow_downward":"unfold_more"})]})}),e.jsx("th",{className:"p-3 font-semibold text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-[#1E293B]",children:qe.map((l,C)=>{const fe=rt===t.id&&X===l.sourceModel,ye=Je(l.sourceModel),vt=!!(ye&&ye!==l.sourceModel),je=l.targetModel?Je(l.targetModel):"",ze=!!(l.targetModel&&(l.targetModel.startsWith("combo/")||Ae.has(l.targetModel.toLowerCase()))),ie=ze&&!l.targetModel.startsWith("combo/")?`combo/${l.targetModel}`:l.targetModel,St=!!(ie&&je&&je!==ie);return e.jsxs("tr",{className:`transition-colors ${fe?"bg-blue-500/10":"hover:bg-white/5"}`,children:[e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-slate-100 font-sans font-semibold text-xs leading-snug",children:ye||l.sourceModel}),vt&&e.jsx("span",{className:"text-[10.5px] font-mono text-slate-400",children:l.sourceModel})]})}),e.jsx("td",{className:"p-3 text-blue-400",children:fe?e.jsxs("div",{className:"flex items-center gap-1.5 w-full max-w-sm",children:[e.jsx("span",{className:"text-blue-400 font-mono",children:"→"}),e.jsx(Ge,{value:ue,onChange:Z,onEnter:()=>$e(t.id),placeholder:"Search model or type ID...",fetchCustomModels:z&&se.length>0?()=>Promise.resolve(se):void 0,className:"bg-[#080B11] border border-blue-500/60 focus:border-blue-400 rounded-lg px-2.5 py-1 text-xs text-white font-mono w-full focus:outline-none",autoFocus:!0})]}):l.targetModel?e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("div",{className:"inline-flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-slate-500 font-mono",children:"→"}),ze&&e.jsx("span",{className:"px-1.5 py-0.2 rounded bg-cyan-500/20 border border-cyan-500/40 text-[9.5px] font-mono text-cyan-300 font-semibold tracking-wide",children:"COMBO"}),e.jsx("span",{className:"text-emerald-300 font-sans font-semibold text-xs leading-snug",children:je||ie})]}),St&&e.jsx("span",{className:"text-[10.5px] font-mono text-slate-400 pl-4",children:ie})]}):e.jsx("span",{className:"text-slate-500 italic text-xs px-2 py-0.5 rounded bg-slate-800/60 border border-slate-700/40",children:"(unmapped)"})}),e.jsx("td",{className:"p-3 text-right space-x-2 whitespace-nowrap",children:fe?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>$e(t.id),className:"px-2.5 py-1 rounded bg-blue-600 hover:bg-blue-500 text-white font-sans text-[11px] font-medium transition-colors cursor-pointer",children:"Save"}),e.jsx("button",{onClick:()=>{me(null),de(null),Z("")},className:"px-2.5 py-1 rounded bg-[#0E1320] hover:bg-slate-700 border border-[#1E293B] text-slate-400 hover:text-white font-sans text-[11px] transition-colors cursor-pointer",children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{de(t.id),me(l.sourceModel),Z(l.targetModel)},className:"px-2.5 py-1 rounded bg-[#0E1320] hover:bg-blue-600 hover:text-white border border-[#1E293B] text-slate-300 transition-colors cursor-pointer font-sans text-[11px]",children:"Edit"}),e.jsx("button",{onClick:()=>wt(t.id,l.sourceModel),className:"p-1 text-slate-500 hover:text-red-400 transition-colors",title:"Delete mapping",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"close"})})]})})]},C)})})]})})]})]})]},t.id)})}),e.jsx(We,{isOpen:!!L,onClose:()=>$(null),maxWidthClass:"max-w-xl",children:L&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-[#1E293B]",children:[e.jsxs("h4",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-blue-400 text-[18px]",children:"add_circle"}),"Add Model Mapping (",L.toUpperCase(),")"]}),e.jsx("button",{onClick:()=>$(null),className:"text-slate-400 hover:text-white p-1 rounded-lg hover:bg-white/10",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-300 mb-1",children:"Source Model ID (Sent by IDE)"}),e.jsx(Et,{toolId:L,value:pe,onChange:xe,placeholder:"Select or type model ID (e.g. auto, claude-sonnet-4.5)..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-300 mb-1",children:"Target Upstream Model ID (Mapigate Provider Model)"}),e.jsx(Ge,{value:he,onChange:ge,placeholder:"Search model or type ID...",fetchCustomModels:z&&se.length>0?()=>Promise.resolve(se):void 0}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Supports slash / formats, e.g. provider/model-name."})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-[#1E293B]",children:[e.jsx("button",{onClick:()=>$(null),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",children:"Cancel"}),e.jsx("button",{onClick:Nt,className:"rt-btn rt-btn--primary text-xs py-1.5 px-4",children:"Add Mapping"})]})]})}),e.jsx(We,{isOpen:!!c,onClose:()=>g(null),maxWidthClass:"max-w-xl",children:c&&(()=>{var s;const t=!!c.isTransient||c.pid===0||!!((s=c.processName)!=null&&s.toLowerCase().includes("idle"));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`material-symbols-outlined text-[20px] ${t?"text-blue-400":c.isSystemProcess?"text-rose-400":"text-amber-400"}`,children:t?"hourglass_top":c.isSystemProcess?"gpp_bad":"warning"}),e.jsxs("h4",{className:"text-sm font-bold text-white",children:["Port ",c.port," ",t?"Socket Releasing":c.isSystemProcess?"System Conflict":"Already In Use"]})]}),e.jsx("button",{onClick:()=>g(null),className:"text-slate-400 hover:text-white p-1 rounded-lg hover:bg-white/10",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),t?e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsxs("div",{className:"p-3.5 bg-blue-500/10 border border-blue-500/30 rounded-xl space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-blue-300 font-semibold",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"hourglass_top"}),e.jsx("span",{children:"Socket Releasing (TIME_WAIT)"})]}),e.jsxs("p",{className:"text-slate-300 text-[11.5px] leading-relaxed",children:["Port ",c.port," is currently releasing from a recent restart (",e.jsx("strong",{className:"text-white",children:"TCP TIME_WAIT"}),"). The operating system will free this socket in a few seconds. Click ",e.jsx("strong",{children:"Retry"})," to start the MITM server."]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-[#1E293B]",children:[e.jsx("button",{type:"button",onClick:()=>g(null),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:()=>ae(!1,c.port),className:"rt-btn rt-btn--primary text-xs py-1.5 px-3.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"}),"Retry"]})]})]}):c.isSystemProcess?e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsxs("div",{className:"p-3.5 bg-rose-500/10 border border-rose-500/30 rounded-xl space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-rose-300 font-semibold",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"admin_panel_settings"}),e.jsx("span",{children:"Windows Kernel / System Service Conflict"})]}),e.jsxs("p",{className:"text-slate-300 text-[11.5px] leading-relaxed",children:["Port ",c.port," is occupied by"," ",e.jsx("strong",{children:c.processName||"System"})," (PID ",c.pid??4,"). This is a Windows system kernel service (e.g. ",e.jsx("code",{children:"HTTP.sys"}),", IIS, or Web Publishing Service) and cannot be killed directly."]})]}),e.jsxs("div",{className:"p-3 bg-[#0A0D14] border border-[#1E293B] rounded-xl space-y-2",children:[e.jsx("span",{className:"text-slate-400 text-[11px] font-semibold block",children:"Run these commands as Administrator to release the port:"}),e.jsxs("div",{className:"space-y-1.5 font-mono text-[11px]",children:[e.jsxs("div",{className:"flex items-center justify-between bg-[#141B2D] px-2.5 py-1.5 rounded-lg border border-[#1E293B]",children:[e.jsx("code",{className:"text-cyan-300",children:"iisreset /stop"}),e.jsx("button",{type:"button",onClick:()=>_("iisreset","iisreset /stop"),className:"text-slate-400 hover:text-white ml-2 shrink-0",title:"Copy command",children:e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:P==="iisreset"?"check":"content_copy"})})]}),e.jsxs("div",{className:"flex items-center justify-between bg-[#141B2D] px-2.5 py-1.5 rounded-lg border border-[#1E293B]",children:[e.jsx("code",{className:"text-cyan-300",children:"net stop w3svc"}),e.jsx("button",{type:"button",onClick:()=>_("w3svc","net stop w3svc"),className:"text-slate-400 hover:text-white ml-2 shrink-0",title:"Copy command",children:e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:P==="w3svc"?"check":"content_copy"})})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-[#1E293B]",children:[e.jsx("button",{type:"button",onClick:()=>g(null),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:()=>ae(!1,c.port),className:"rt-btn rt-btn--primary text-xs py-1.5 px-3.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"}),"Retry"]})]})]}):e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsxs("div",{className:"p-3.5 bg-amber-500/10 border border-amber-500/30 rounded-xl space-y-2",children:[e.jsxs("p",{className:"text-slate-300 text-[11.5px] leading-relaxed",children:["Port ",c.port," is currently used by another process:"]}),e.jsxs("div",{className:"p-2.5 bg-[#0A0D14] rounded-lg border border-[#1E293B] font-mono text-xs text-amber-200",children:[e.jsxs("div",{children:["Process: ",e.jsx("strong",{className:"text-white",children:c.processName||"Unknown"})]}),e.jsxs("div",{children:["PID: ",e.jsx("strong",{className:"text-white",children:c.pid??"Unknown"})]})]}),e.jsxs("p",{className:"text-slate-400 text-[11px]",children:["Kill this process to start MITM Proxy on port ",c.port,"?"]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-[#1E293B]",children:[e.jsx("button",{type:"button",onClick:()=>g(null),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",children:"Cancel"}),e.jsxs("button",{type:"button",disabled:D,onClick:()=>ae(!0,c.port),className:"rt-btn rt-btn--danger text-xs py-1.5 px-3.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:D?"hourglass_empty":"power_settings_new"}),D?"Terminating...":"Kill & Start"]})]})]})]})})()})]})};export{$t as MitmTab};
@@ -1 +0,0 @@
1
- import{j as o,r as f}from"./vendor-BcOI2aZ9.js";import{n as E,g as Z,a as ee}from"./metadataRegistry-CGDAkFU1.js";const k={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},y="[-_/:.]",te=new RegExp([`(^|${y})(image|img)(${y}|$)`,"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"),ne=new RegExp([`(^|${y})(vision|vl|vlm|multimodal|omni|visual)(${y}|$)`,`[0-9]\\.[0-9]+v(${y}|$)`,`(^|${y})glm-[0-9]+v(${y}|$)`,"(^|[-_/:.])(llava|pixtral|internvl|cogvlm|minicpm-v|moondream|idefics|fuyu)"].join("|"),"i"),H={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}}},A={"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 D(n){if(!n)return!1;const t=String(n).toLowerCase();return te.test(t)?!1:ne.test(t)}function K(n,t){return!n||!t?!1:new RegExp("^"+n.split("*").map(c=>c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*")+"$","i").test(t)}const ie=[{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 U(n){if(n){if(Array.isArray(n)){const t={};for(const u of n)typeof u=="string"&&(t[u]=!0);return t}return n}}function Q(n,t){if(!t)return{...k};const u=t.includes("/")?t.split("/").pop():t,c=!n&&t.includes("/")?t.split("/")[0]:n,d=c?c.replace(/\[.*?\]$/,""):null,i=E(u);if(d){const r=Z(d);if(r!=null&&r.models){const l=r.models.find(a=>a.id===t||a.id===u||a.upstreamModelId&&(a.upstreamModelId===t||a.upstreamModelId===u)||E(a.id)===i||a.upstreamModelId&&E(a.upstreamModelId)===i);if(l!=null&&l.capabilities){const a=U(l.capabilities);if(a){const g={...k,...a};return!g.vision&&D(t)&&(g.vision=!0),g}}}}else for(const r of ee()){if(!r.models)continue;const l=r.models.find(a=>a.id===t||a.id===u||a.upstreamModelId&&(a.upstreamModelId===t||a.upstreamModelId===u)||E(a.id)===i||a.upstreamModelId&&E(a.upstreamModelId)===i);if(l!=null&&l.capabilities){const a=U(l.capabilities);if(a){const g={...k,...a};return!g.vision&&D(t)&&(g.vision=!0),g}}}if(d&&H[d]){const r=H[d];if(r[t])return{...k,...r[t]};if(r[u])return{...k,...r[u]}}if(A[u]){const r={...k,...A[u]};return!r.vision&&D(t)&&(r.vision=!0),r}if(A[t]){const r={...k,...A[t]};return!r.vision&&D(t)&&(r.vision=!0),r}for(const{pattern:r,caps:l}of ie)if(K(r,u)||K(r,t)){const a={...k,...l};return!a.vision&&D(t)&&(a.vision=!0),a}const m={...k};return!m.vision&&D(t)&&(m.vision=!0),m}function pe(n,t,u=0){if(!n||n.length===0||u>6)return null;const c=n.map(i=>{!i.includes("/")&&(t!=null&&t[i]);const m=i.indexOf("/"),r=m===-1?null:i.slice(0,m),l=m===-1?i:i.slice(m+1);return Q(r,l)}),d=c[0];return{vision:c.some(i=>i.vision),pdf:c.some(i=>i.pdf),audioInput:c.some(i=>i.audioInput),videoInput:c.some(i=>i.videoInput),imageOutput:c.some(i=>i.imageOutput),audioOutput:c.some(i=>i.audioOutput),search:c.some(i=>i.search),tools:c.every(i=>i.tools),reasoning:d.reasoning,thinkingFormat:d.thinkingFormat,thinkingCanDisable:d.thinkingCanDisable,thinkingRange:d.thinkingRange,thinkingEffortSupported:d.thinkingEffortSupported,contextWindow:Math.min(...c.map(i=>i.contextWindow)),maxOutput:Math.max(...c.map(i=>i.maxOutput))}}const S={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 ae(n){if(!n)return null;const t=n.indexOf("/"),u=t===-1?null:n.slice(0,t),c=t===-1?n:n.slice(t+1);return Q(u,c)}const oe=({caps:n,model:t,className:u="",showLabels:c=!1,size:d="sm"})=>{const i=n||(t?ae(t):null);if(!i)return null;const m=!!i.vision,r=!!i.pdf,l=!!(i.audioInput||i.audio),a=!!(i.reasoning||i.thinking||i.thinkingFormat&&i.thinkingFormat!==null),g=[];if(m&&g.push(S.vision),r&&g.push(S.pdf),l&&g.push(S.audio),a&&g.push(S.thinking),g.length===0)return null;const W={xs:"text-[12px]",sm:"text-[14px]",md:"text-[16px]"},$={xs:"text-[9.5px]",sm:"text-[10.5px]",md:"text-xs"};return o.jsx("div",{className:`inline-flex items-center gap-1.5 flex-wrap ${u}`,children:g.map(x=>o.jsxs("span",{title:`${x.label}: ${x.desc}`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md border font-medium transition-all ${x.colorClass} ${x.bgClass} ${x.borderClass} ${$[d]}`,children:[o.jsx("span",{className:`material-symbols-outlined leading-none ${W[d]}`,children:x.icon}),c&&o.jsx("span",{children:x.label})]},x.key))})};function re(n,t){if(!t.trim())return!0;const u=t.toLowerCase().trim(),c=n.toLowerCase();if(c.includes(u))return!0;const d=u.split(/\s+/).filter(Boolean);if(d.length===0)return!0;const i=c.replace(/[-_./]/g," ");return d.every(m=>c.includes(m)||i.includes(m))}let N=null,M=null;const P=new Set;function se(n){return P.add(n),()=>{P.delete(n)}}function de(){N=null,M=null;for(const n of P)try{n()}catch(t){console.error("Error in model cache invalidation listener:",t)}}function G(){return M?Promise.resolve(M):(N||(N=fetch("/api/models/available").then(n=>{if(!n.ok)throw new Error("Failed to load models");return n.json()}).then(n=>(M=n,n)).catch(n=>{throw N=null,n})),N)}const le=({value:n,onChange:t,onEnter:u,placeholder:c="Search model (e.g. openai/gpt-4o)...",className:d="",autoFocus:i=!1,connectedOnly:m=!0,disabled:r=!1,excludeValues:l,allowCombos:a=!0,fetchCustomModels:g})=>{const[W,$]=f.useState([]),[x,v]=f.useState(!1),[O,w]=f.useState(-1),[F,T]=f.useState(m),[Y,R]=f.useState("bottom"),j=f.useRef(null),q=f.useRef(null);f.useEffect(()=>{if(x&&j.current){const e=j.current.getBoundingClientRect(),p=280,h=window.innerHeight-e.bottom,I=e.top;h<p&&I>h?R("top"):R("bottom")}},[x]),f.useEffect(()=>{let e=!0;const p=()=>{(g?g():G()).then(s=>{e&&$(s)}).catch(()=>{})};p();const h=se(()=>{e&&p()});return()=>{e=!1,h()}},[g]),f.useEffect(()=>{T(m)},[m]),f.useEffect(()=>{const e=p=>{j.current&&!j.current.contains(p.target)&&v(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]);const B=f.useMemo(()=>W.some(e=>e.hasConnectedAccount),[W]),C=f.useMemo(()=>{const e=(n||"").trim().toLowerCase(),p=new Set((l||[]).map(s=>s.toLowerCase()));let h=W;if(a===!1&&(h=h.filter(s=>!s.isCombo)),p.size>0&&(h=h.filter(s=>!p.has(s.value.toLowerCase())&&!(s.isCombo&&p.has(s.id.toLowerCase())))),F&&B&&(h=h.filter(s=>s.hasConnectedAccount)),!e)return h.slice(0,50);const I=h.filter(s=>{let b=`${s.name} ${s.id} ${s.value} ${s.providerName} ${s.providerId}`;return s.isCombo&&(s.strategy&&(b+=` ${s.strategy}`),s.models&&(b+=` ${s.models.join(" ")}`)),re(b,e)});return I.sort((s,b)=>{const _=s.value.toLowerCase(),L=b.value.toLowerCase(),z=s.id.toLowerCase(),V=b.id.toLowerCase();return _===e||z===e?-1:L===e||V===e?1:_.startsWith(e)||z.startsWith(e)?-1:L.startsWith(e)||V.startsWith(e)?1:s.isCombo&&!b.isCombo?-1:!s.isCombo&&b.isCombo?1:0}),I.slice(0,50)},[W,n,F,B,l,a]);f.useEffect(()=>{if(O>=0&&q.current){const e=q.current.children[O];e&&e.scrollIntoView({block:"nearest"})}},[O]);const J=e=>{if(!r)if(e.key==="ArrowDown")e.preventDefault(),x?w(p=>p<C.length-1?p+1:0):v(!0);else if(e.key==="ArrowUp")e.preventDefault(),x?w(p=>p>0?p-1:C.length-1):v(!0);else if(e.key==="Enter")if(x&&O>=0&&C[O]){e.preventDefault();const p=C[O];t(p.value),v(!1),w(-1),u&&u(p.value)}else v(!1),u&&(e.preventDefault(),u(n));else e.key==="Escape"&&(e.preventDefault(),v(!1),w(-1))},X=e=>{t(e),v(!1),w(-1)};return o.jsxs("div",{ref:j,className:"relative w-full",children:[o.jsx("input",{type:"text",value:n,onChange:e=>{t(e.target.value),x||v(!0),w(-1)},onFocus:()=>{(W.length===0||!M)&&G().then(e=>$(e)).catch(()=>{}),v(!0)},onKeyDown:J,placeholder:c,disabled:r,autoFocus:i,className:d||"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"}),n&&!r&&o.jsx("button",{type:"button",onClick:()=>{t(""),w(-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:o.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"close"})}),x&&o.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:[o.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-[#1E293B] bg-[#05070B] text-[11px]",children:[o.jsxs("span",{className:"text-slate-400 font-mono text-[10.5px]",children:[C.length," models ",n.trim()?"found":"available"]}),o.jsxs("button",{type:"button",onMouseDown:e=>{e.preventDefault(),T(!F)},className:`px-2 py-0.5 rounded-md font-sans text-[10.5px] font-medium flex items-center gap-1 transition-all cursor-pointer ${F?"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:F?"Showing only models from connected accounts. Click to show all catalog models.":"Showing all catalog models. Click to filter by connected accounts.",children:[o.jsx("span",{className:"material-symbols-outlined text-[12px]",children:F?"check":"filter_alt"}),"Connected only"]})]}),o.jsx("div",{ref:q,className:"max-h-56 overflow-y-auto divide-y divide-[#1E293B]/40",children:C.length===0?o.jsxs("div",{className:"p-3 text-center text-xs text-slate-500 space-y-1",children:[o.jsx("p",{children:"No matching models in catalog."}),o.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."}),F&&!B&&o.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"})]}):C.map((e,p)=>{const h=p===O,I=e.value===n;return o.jsxs("div",{onMouseDown:s=>{s.preventDefault(),X(e.value)},onMouseEnter:()=>w(p),className:`px-3 py-2 cursor-pointer transition-colors flex items-center justify-between gap-2.5 ${h?"bg-blue-600/20 text-white":I?"bg-[#141B2D] text-slate-100":"hover:bg-white/5 text-slate-300"}`,children:[o.jsxs("div",{className:"min-w-0 flex-1 space-y-0.5",children:[o.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.isCombo?o.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"}):o.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}),o.jsx("span",{className:"font-medium text-xs text-slate-100 truncate",children:e.name}),e.isCombo&&e.strategy&&o.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&&o.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?o.jsxs("div",{className:"font-mono text-[10.5px] text-slate-400 truncate",children:[o.jsxs("span",{className:"text-cyan-400 font-semibold",children:[e.models.length," model",e.models.length>1?"s":"",":"]})," ",o.jsxs("span",{className:"text-slate-300",children:[e.models.slice(0,3).join(", "),e.models.length>3?` +${e.models.length-3} more`:""]})]}):o.jsx("div",{className:"font-mono text-[10.5px] text-slate-400 truncate",children:e.value})]}),o.jsx("div",{className:"shrink-0 flex items-center gap-1.5",children:o.jsx(oe,{caps:e.caps,size:"xs",showLabels:!1})})]},e.value)})})]})]})};export{oe as C,le as M,pe as a,G as b,Q as g,de as i,re as m,se as o};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ProvidersTab-Dd-prffr.js","assets/vendor-BcOI2aZ9.js","assets/ConfirmModal-Co5OXd_g.js","assets/ModelAutocompleteInput-D0L1aj3-.js","assets/metadataRegistry-CGDAkFU1.js","assets/ToolIcon-Cp4gSgFt.js","assets/providersData-HX0E7hDv.js","assets/lucide-Cc35htxl.js","assets/ProviderDetailPage-CeOUazix.js","assets/Select-BNRH8LIG.js","assets/EditAccountModal-DLyP9VNQ.js","assets/CombosTab-DdsJ2ova.js","assets/dnd-kit-DecqzwfZ.js","assets/UsageTab-Da7c7zwV.js","assets/recharts-X4_nm3od.js","assets/QuotaTab-zPkj0Rwo.js","assets/CliToolsTab-iJozQAQx.js","assets/MitmTab-DMRg64by.js","assets/EndpointTab-DbjjVT7s.js","assets/TokenSaverTab-B3Fbu_yc.js","assets/ConsoleLogTab-BTGaJpcD.js","assets/SettingsTab-DUlhyz1z.js","assets/CallbackPage-sTRnWJ-d.js"])))=>i.map(i=>d[i]);
2
- import{d as A,j as e,r as m,a as J,e as Y,R as X}from"./vendor-BcOI2aZ9.js";import{G as H}from"./lucide-Cc35htxl.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))t(n);new MutationObserver(n=>{for(const o of n)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&t(l)}).observe(document,{childList:!0,subtree:!0});function s(n){const o={};return n.integrity&&(o.integrity=n.integrity),n.referrerPolicy&&(o.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?o.credentials="include":n.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function t(n){if(n.ep)return;n.ep=!0;const o=s(n);fetch(n.href,o)}})();const Z="modulepreload",ee=function(a){return"/"+a},z={},y=function(r,s,t){let n=Promise.resolve();if(s&&s.length>0){let l=function(i){return Promise.all(i.map(c=>Promise.resolve(c).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const x=document.querySelector("meta[property=csp-nonce]"),d=(x==null?void 0:x.nonce)||(x==null?void 0:x.getAttribute("nonce"));n=l(s.map(i=>{if(i=ee(i),i in z)return;z[i]=!0;const c=i.endsWith(".css"),p=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${i}"]${p}`))return;const h=document.createElement("link");if(h.rel=c?"stylesheet":Z,c||(h.as="script"),h.crossOrigin="",h.href=i,d&&h.setAttribute("nonce",d),document.head.appendChild(h),c)return new Promise((u,b)=>{h.addEventListener("load",u),h.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${i}`)))})}))}function o(l){const x=new Event("vite:preloadError",{cancelable:!0});if(x.payload=l,window.dispatchEvent(x),!x.defaultPrevented)throw l}return n.then(l=>{for(const x of l||[])x.status==="rejected"&&o(x.reason);return r().catch(o)})},T=20128,R="127.0.0.1",te=`http://${R}:${T}`,Se=`${te}/v1`,_=A(a=>({info:null,loading:!1,fetchSystemInfo:async()=>{try{a({loading:!0});const r=await fetch("/api/settings/system-info");if(r.ok){const s=await r.json(),t=typeof window<"u"&&window.location.port?Number(window.location.port):void 0,n=s.port||(t&&t!==5173?t:T),o=s.host||(typeof window<"u"&&window.location.hostname?window.location.hostname:R),l={dataDir:s.dataDir||"",dbPath:s.dbPath||"",isDevelopmentMode:!!s.isDevelopmentMode,appName:s.appName||"Mapigate",version:s.version||"",port:n,host:o,configuredHost:s.configuredHost||o,configuredPort:s.configuredPort||n,isRestartRequired:!!s.isRestartRequired};return a({info:l,loading:!1}),(async()=>{try{const x=await fetch("/api/settings/version");if(x.ok){const d=await x.json();a(i=>i.info?{...i,info:{...i.info,latestVersion:d.latestVersion,hasUpdate:!!d.hasUpdate}}:i)}}catch{}})(),l}}catch{}return a({loading:!1}),null},checkForUpdate:async()=>{try{const r=await fetch("/api/settings/version?force=true");if(r.ok){const s=await r.json();a(t=>t.info?{...t,info:{...t.info,latestVersion:s.latestVersion,hasUpdate:!!s.hasUpdate}}:t)}}catch{}}})),se=({currentTab:a,onSelectTab:r,onUpgradeClick:s})=>{const t=_(d=>d.info),n=t==null?void 0:t.version,o=(t==null?void 0:t.port)||(typeof window<"u"&&window.location.port&&window.location.port!=="5173"?Number(window.location.port):T),l=(t==null?void 0:t.host)||(typeof window<"u"&&window.location.hostname?window.location.hostname:R),x=[{id:"endpoint",label:"Endpoint & Key",icon:"api"},{id:"providers",label:"Providers",icon:"dns"},{id:"combos",label:"Combo & Vision Adapter",icon:"layers"},{id:"usage",label:"Usage & Analytics",icon:"bar_chart"},{id:"quota",label:"Quota Tracker",icon:"data_usage"},{id:"tokensaver",label:"Token Saver",icon:"savings"},{id:"clitools",label:"Tools & Mappings",icon:"widgets"},{id:"mitm",label:"MITM Proxy",icon:"alt_route"}];return e.jsxs("aside",{className:"rt-sidebar",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"rt-sidebar__brand pt-5 pr-4 flex items-center gap-3",children:[e.jsx("div",{className:"rt-sidebar__brand-icon shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"graph_5"})}),e.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("h1",{className:"text-sm font-bold tracking-tight text-white leading-none truncate",children:"Mapigate"}),n&&(t!=null&&t.hasUpdate&&t.latestVersion?e.jsxs("button",{type:"button",onClick:()=>s==null?void 0:s(),className:"group relative inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded-md bg-amber-500/15 text-amber-300 border border-amber-500/35 font-mono font-semibold shrink-0 select-none leading-none hover:bg-amber-500/25 transition-all cursor-pointer",title:`New version v${t.latestVersion} available! Click to upgrade`,children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-amber-500"})]}),e.jsxs("span",{children:["v",n]}),e.jsx("span",{className:"text-[9px] text-amber-400 group-hover:translate-y-[-0.5px] transition-transform",children:"↑"})]}):e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded-md bg-blue-500/15 text-blue-300 border border-blue-500/30 font-mono font-semibold shrink-0 shadow-xs select-none leading-none",title:`Mapigate Version v${n}`,children:["v",n]}))]}),e.jsx("span",{className:"text-[11px] text-slate-400 leading-normal mt-1 truncate",children:"AI Model API Gateway"})]})]}),e.jsx("nav",{className:"px-3 pt-3 space-y-1",children:x.map(d=>{const i=a===d.id;return e.jsxs("button",{onClick:()=>r(d.id),className:`rt-sidebar__nav-item ${i?"rt-sidebar__nav-item--active":""}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:d.icon}),e.jsx("span",{children:d.label})]},d.id)})}),e.jsx("div",{className:"px-5 pt-6 pb-2",children:e.jsx("span",{className:"text-[10px] font-bold text-slate-500 tracking-wider uppercase",children:"SYSTEM PREFERENCES"})}),e.jsxs("nav",{className:"px-3 space-y-1",children:[e.jsxs("button",{onClick:()=>r("consolelog"),className:`rt-sidebar__nav-item ${a==="consolelog"?"rt-sidebar__nav-item--active":""}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"terminal"}),e.jsx("span",{children:"Console Log"})]}),e.jsxs("button",{onClick:()=>r("settings"),className:`rt-sidebar__nav-item ${a==="settings"?"rt-sidebar__nav-item--active":""}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"tune"}),e.jsx("span",{children:"Settings"})]})]})]}),e.jsxs("div",{className:"p-4 border-t border-[#1E293B] space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400 bg-[#111827] px-3.5 py-2.5 rounded-xl border border-[#1E293B] shadow-inner",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"rt-beacon size-2 bg-emerald-400"}),e.jsxs("span",{className:"font-semibold text-slate-200",children:["Port ",o]})]}),e.jsx("span",{className:"text-[10px] text-blue-300 font-mono bg-blue-500/10 px-1.5 py-0.5 rounded border border-blue-500/20",children:l})]}),e.jsxs("a",{href:"https://github.com/joutvhu/mapigate",target:"_blank",rel:"noreferrer",title:"Mapigate on GitHub (joutvhu/mapigate)",className:"flex items-center justify-center gap-2 w-full py-1.5 px-3 rounded-xl bg-[#111827]/60 hover:bg-white/5 border border-[#1E293B]/60 hover:border-[#1E293B] text-[11px] font-medium text-slate-400 hover:text-white transition-all cursor-pointer",children:[e.jsx(H,{className:"size-3.5 text-slate-400"}),e.jsx("span",{children:"GitHub · joutvhu/mapigate"})]})]})]})},E="mapigate_auth_token";let $=!1;const P=new Set;function ae(a){return P.add(a),()=>{P.delete(a)}}function q(){for(const a of P)try{a()}catch{}}class w{static getToken(){if(typeof window>"u")return null;try{return localStorage.getItem(E)}catch{return null}}static setToken(r){if(!(typeof window>"u"))try{localStorage.setItem(E,r)}catch{}}static removeToken(){if(!(typeof window>"u"))try{localStorage.removeItem(E)}catch{}}static async checkStatus(){try{const r=this.getToken(),s={};r&&(s.Authorization=`Bearer ${r}`);const t=await fetch("/api/auth/status",{headers:s});if(!t.ok)return{enabled:!1,authenticated:!0};const n=await t.json();return{enabled:!!n.enabled,authenticated:!!n.authenticated}}catch{return{enabled:!1,authenticated:!0}}}static async login(r){try{const s=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:r})}),t=await s.json();return s.ok&&t.success?(t.token&&this.setToken(t.token),{success:!0,token:t.token}):{success:!1,error:t.error||"Invalid master password"}}catch(s){return{success:!1,error:s.message||"Failed to authenticate"}}}static async logout(){try{await fetch("/api/auth/logout",{method:"POST"})}catch{}this.removeToken(),q()}static async setup(r){try{const s=await fetch("/api/auth/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:r})}),t=await s.json();return s.ok&&t.success?(t.token&&this.setToken(t.token),{success:!0,token:t.token}):{success:!1,error:t.error||"Failed to setup master password"}}catch(s){return{success:!1,error:s.message||"Failed to setup master password"}}}static async changePassword(r,s){try{const t=await fetch("/api/auth/change-password",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:r,newPassword:s})}),n=await t.json();return t.ok&&n.success?(n.token&&this.setToken(n.token),{success:!0,token:n.token}):{success:!1,error:n.error||"Failed to change master password"}}catch(t){return{success:!1,error:t.message||"Failed to change master password"}}}static async removePassword(r){try{const s=await fetch("/api/auth/remove-password",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:r})}),t=await s.json();return s.ok&&t.success?(this.removeToken(),{success:!0}):{success:!1,error:t.error||"Failed to remove master password"}}catch(s){return{success:!1,error:s.message||"Failed to remove master password"}}}}function re(){if(typeof window>"u"||$)return;$=!0;const a=window.fetch.bind(window);window.fetch=async(r,s)=>{let t="";typeof r=="string"?t=r:r instanceof URL?t=r.toString():r&&typeof r.url=="string"&&(t=r.url);let n=!1;try{const i=new URL(t,window.location.origin);n=i.origin===window.location.origin&&(i.pathname==="/api"||i.pathname.startsWith("/api/"))}catch{n=t.startsWith("/api/")}const o=t.includes("/api/auth/status")||t.includes("/api/auth/login");let l=s;const x=w.getToken();if(n&&x){const i=new Headers((s==null?void 0:s.headers)||(r instanceof Request?r.headers:void 0));i.has("Authorization")||i.set("Authorization",`Bearer ${x}`),l={...s,headers:i}}const d=await a(r,l);if(n&&!o&&d.status===401)try{const c=await d.clone().json();c&&c.code==="AUTH_REQUIRED"&&q()}catch{}return d}}re();const j=A((a,r)=>({isChecking:!0,isPasswordSet:!1,isAuthenticated:!0,isLocked:!1,checkAuth:async()=>{a({isChecking:!0});try{const s=await w.checkStatus();if(!s.enabled){a({isChecking:!1,isPasswordSet:!1,isAuthenticated:!0,isLocked:!1});return}a({isChecking:!1,isPasswordSet:!0,isAuthenticated:s.authenticated,isLocked:!s.authenticated})}catch{a({isChecking:!1,isPasswordSet:!1,isAuthenticated:!0,isLocked:!1})}},login:async s=>{const t=await w.login(s);return t.success?(a({isAuthenticated:!0,isLocked:!1}),{success:!0}):{success:!1,error:t.error}},logout:async()=>{await w.logout();const s=r().isPasswordSet;a({isAuthenticated:!s,isLocked:s})},lock:()=>{w.removeToken(),a({isPasswordSet:!0,isAuthenticated:!1,isLocked:!0})},unlock:s=>{w.setToken(s),a({isAuthenticated:!0,isLocked:!1})}}));typeof window<"u"&&(ae(()=>{j.getState().lock()}),window.addEventListener("storage",a=>{(a.key===E||a.key===null)&&(w.getToken()?j.setState({isAuthenticated:!0,isLocked:!1}):j.getState().isPasswordSet&&j.setState({isAuthenticated:!1,isLocked:!0}))}));const F=A(a=>({status:null,loading:!1,fetchStatus:async()=>{try{a({loading:!0});const r=await fetch("/api/mitm/status");if(r.ok){const s=await r.json(),t=s.dnsStatus||{},n=Object.entries(t).filter(([l,x])=>!!x).map(([l])=>l),o={running:!!s.running,port:Number(s.port)||443,certExists:!!s.certExists,certTrusted:!!s.certTrusted,dnsStatus:t,orphanedDns:!!s.orphanedDns,activeDnsCount:n.length,activeDnsTools:n};return a({status:o,loading:!1}),o}}catch{}return a({loading:!1}),null}})),ne={antigravity:"Antigravity",kiro:"Kiro",copilot:"GitHub Copilot",cursor:"Cursor"};function V(a){return!a||a.length===0?"":a.map(r=>ne[r]||r.charAt(0).toUpperCase()+r.slice(1)).join(", ")}const G={endpoint:{title:"Endpoint & Key",subtitle:"Manage your local AI gateway endpoint and master keys",icon:"api"},providers:{title:"Providers",subtitle:"Manage your AI provider connections and encrypted API credentials",icon:"dns"},combos:{title:"Combos & Adapter",subtitle:"Group models under smart fallback and load-balancing combos",icon:"layers"},usage:{title:"Usage & Analytics",subtitle:"Real-time token metrics, savings analysis, and interactive routing topology",icon:"bar_chart"},quota:{title:"Quota Tracker",subtitle:"Track rate limits and multi-account sliding quota reset times",icon:"data_usage"},tokensaver:{title:"Token Saver",subtitle:"Lossless context optimization saving 20-40% input tokens",icon:"savings"},clitools:{title:"Tools & Mappings",subtitle:"One-click connection setups and universal model rewrite rules for AI assistants, IDEs & tools",icon:"widgets"},mitm:{title:"MITM Proxy",subtitle:"Intercept CLI & IDE tool traffic (Antigravity, Kiro, Copilot) via local Root CA",icon:"alt_route"},consolelog:{title:"Console Log",subtitle:"Live gateway server stdout, request streaming events, and system logs",icon:"terminal"},settings:{title:"Settings",subtitle:"Local SQLite database, hardware encryption vault, and system preferences",icon:"tune"}},oe=({currentTab:a,searchQuery:r,onSearchChange:s,detailProvider:t,onBackToProviders:n,onRestartClick:o,onSelectTab:l})=>{const x=G[a]||G.providers,d=j(v=>v.isPasswordSet),i=j(v=>v.lock),c=_(v=>v.info),p=_(v=>v.fetchSystemInfo);c==null||c.version;const h=F(v=>v.status),u=F(v=>v.fetchStatus);m.useEffect(()=>{u(),p();const v=setInterval(()=>{document.hidden||(u(),p())},1e4),U=()=>{u(),p()};return window.addEventListener("focus",U),()=>{clearInterval(v),window.removeEventListener("focus",U)}},[u,p]);const b=!!(h!=null&&h.running),g=(h==null?void 0:h.port)||443,f=(h==null?void 0:h.activeDnsCount)||0,M=(h==null?void 0:h.activeDnsTools)||[],W=!!(h!=null&&h.orphanedDns),S=(c==null?void 0:c.host)||"127.0.0.1",L=(c==null?void 0:c.configuredHost)||S,D=!!(c!=null&&c.isRestartRequired),C=S==="0.0.0.0";let I=C?`Network: LAN Active (0.0.0.0:${(c==null?void 0:c.port)||T}) • Accessible from local network • Click to configure Endpoint`:`Network: Local Only (127.0.0.1:${(c==null?void 0:c.port)||T}) • Isolated to this machine • Click to configure Endpoint`,B=C?"bg-emerald-500/10 text-emerald-400 border-emerald-500/20 hover:bg-emerald-500/20":"bg-blue-500/10 text-blue-400 border-blue-500/20 hover:bg-blue-500/20",O=C?"wifi":"shield";D&&(I=`⚠️ Restart Required: Configured for ${L==="0.0.0.0"?"LAN Active":"Local Only"} (${L}), but running on ${S}. Click Restart button to apply.`,B="bg-amber-500/15 text-amber-300 border-amber-500/30 hover:bg-amber-500/25 animate-pulse",O="restart_alt");let N="MITM Proxy: Stopped • Click to open settings",k="text-slate-500 hover:text-slate-300";return W?(N=`⚠️ MITM Warning: Server stopped but ${f} DNS redirect(s) still active (${V(M)})! Tools cannot connect. Click to fix.`,k="text-amber-400 hover:text-amber-300 animate-pulse"):b?f>0?(N=`MITM Proxy: Active on port ${g} • ${f} tool DNS active (${V(M)}) • Click to manage`,k="text-emerald-400 hover:text-emerald-300"):(N=`MITM Proxy: Running on port ${g} (Idle, 0 tool DNS active) • Click to configure`,k="text-blue-400 hover:text-blue-300"):(N="MITM Proxy: Stopped • Click to open settings",k="text-slate-500 hover:text-slate-300"),e.jsxs("header",{className:"rt-header",children:[e.jsxs("div",{className:"flex items-center gap-3.5 min-w-0",children:[e.jsx("div",{className:"rt-header__icon-box",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:x.icon})}),e.jsxs("div",{className:"flex flex-col min-w-0",children:[a==="providers"&&t?e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("button",{type:"button",onClick:n,className:"text-sm font-bold text-slate-400 hover:text-white flex items-center gap-1 cursor-pointer transition-colors",title:"Back to Providers",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"arrow_back"}),"Providers"]}),e.jsx("span",{className:"text-slate-600 text-xs",children:"/"}),e.jsx("h2",{className:"text-sm font-bold text-white tracking-tight leading-tight",children:t.name})]}):e.jsx("h2",{className:"text-sm font-bold text-white tracking-tight leading-tight",children:x.title}),e.jsx("p",{className:"text-[11px] text-slate-400 truncate leading-tight mt-0.5",children:a==="providers"&&t?`Configure credentials, upstream headers, and fallback strategy for ${t.name}`:x.subtitle})]})]}),e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsxs("div",{className:"relative w-64 h-8",children:[e.jsx("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-[15px] text-slate-500 pointer-events-none",children:"search"}),e.jsx("input",{type:"text",placeholder:"Search providers & models...",value:r,onChange:v=>s(v.target.value),className:"w-full h-8 bg-[#111827] border border-[#1E293B] rounded-lg pl-9 pr-8 text-xs text-white placeholder-slate-500 focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500/30 transition-all"}),r&&e.jsx("button",{type:"button",onClick:()=>s(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-slate-500 hover:text-white transition-colors cursor-pointer flex items-center justify-center w-5 h-5 rounded hover:bg-white/5",title:"Clear search",children:e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>{D&&o?o():l==null||l("endpoint")},title:I,className:`w-8 h-8 rounded-lg border text-xs font-medium transition-all cursor-pointer shadow-xs inline-flex items-center justify-center ${B}`,children:e.jsx("span",{className:"material-symbols-outlined text-[17px]",children:O})}),e.jsx("button",{type:"button",onClick:()=>l==null?void 0:l("mitm"),title:N,className:`w-8 h-8 rounded-lg border border-[#1E293B] bg-[#111827] hover:bg-white/5 ${k} transition-colors cursor-pointer inline-flex items-center justify-center shadow-xs`,children:e.jsx("span",{className:"material-symbols-outlined text-[17px]",children:"alt_route"})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 border-l border-[#1E293B] pl-2.5",children:[o&&e.jsx("button",{type:"button",onClick:o,title:"Restart Mapigate Gateway (Hot Reload)",className:"w-8 h-8 rounded-lg border border-[#1E293B] bg-[#111827] hover:bg-white/5 hover:text-blue-400 text-slate-400 transition-colors cursor-pointer inline-flex items-center justify-center shadow-xs",children:e.jsx("span",{className:"material-symbols-outlined text-[17px]",children:"restart_alt"})}),d&&e.jsx("button",{type:"button",onClick:i,title:"Lock Dashboard (Master Password Protected)",className:"w-8 h-8 rounded-lg bg-amber-500/10 hover:bg-amber-500/20 text-amber-400 border border-amber-500/20 hover:border-amber-500/30 transition-all cursor-pointer inline-flex items-center justify-center shadow-xs",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"lock"})})]}),e.jsx("div",{className:"flex items-center border-l border-[#1E293B] pl-2.5",children:e.jsx("a",{href:"https://github.com/joutvhu/mapigate",target:"_blank",rel:"noreferrer",title:"Mapigate on GitHub (joutvhu/mapigate)",className:"hidden sm:inline-flex items-center justify-center w-8 h-8 rounded-lg bg-[#111827] hover:bg-white/5 text-slate-400 hover:text-white border border-[#1E293B] transition-all cursor-pointer shadow-xs",children:e.jsx(H,{className:"size-4"})})})]})]})},le=()=>{const[a,r]=m.useState(""),[s,t]=m.useState(!1),[n,o]=m.useState(!1),[l,x]=m.useState(null),d=m.useRef(null),i=j(p=>p.login);m.useEffect(()=>{var p;(p=d.current)==null||p.focus()},[]);const c=async p=>{var u;if(p.preventDefault(),!a.trim()||n)return;o(!0),x(null);const h=await i(a);h.success||(x(h.error||"Incorrect master password"),o(!1),(u=d.current)==null||u.select())};return e.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-[#07090E] p-4 animate-rt-fade-in select-none",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute -top-[25%] left-1/2 -translate-x-1/2 w-[650px] h-[450px] bg-gradient-to-b from-blue-600/15 via-indigo-600/10 to-transparent blur-[140px] rounded-full"}),e.jsx("div",{className:"absolute -bottom-[20%] left-1/2 -translate-x-1/2 w-[500px] h-[300px] bg-blue-500/5 blur-[120px] rounded-full"})]}),e.jsxs("div",{className:"w-full max-w-sm relative z-10 space-y-6",children:[e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3",children:[e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute -inset-1 bg-gradient-to-r from-blue-500 to-indigo-500 rounded-2xl blur-md opacity-40 group-hover:opacity-75 transition-opacity"}),e.jsx("div",{className:"relative size-12 rounded-2xl bg-gradient-to-br from-blue-500 to-indigo-600 text-white flex items-center justify-center shadow-lg shadow-blue-500/30 border border-blue-400/30",children:e.jsx("span",{className:"material-symbols-outlined text-[24px]",children:"graph_5"})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx("h1",{className:"text-xl font-bold tracking-tight text-white font-sans",children:"Mapigate"}),e.jsx("span",{className:"text-[10px] uppercase font-semibold px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400 border border-blue-500/30 font-mono",children:"AI"})]}),e.jsx("p",{className:"text-xs text-slate-400 mt-1 font-medium",children:"Ultra-lightweight Local AI Gateway"})]})]}),e.jsxs("div",{className:"bg-[#0D111A]/90 backdrop-blur-xl border border-slate-800/80 shadow-2xl shadow-black/60 rounded-2xl p-6 sm:p-7 text-center space-y-5 border-t-blue-500/50",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-slate-800/60",children:[e.jsxs("div",{className:"flex items-center gap-2 text-left",children:[e.jsx("div",{className:"size-8 rounded-lg bg-blue-500/10 border border-blue-500/20 text-blue-400 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"lock"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xs font-semibold text-white tracking-tight",children:"Dashboard Locked"}),e.jsx("p",{className:"text-[11px] text-slate-400",children:"Authentication required"})]})]}),e.jsx("span",{className:"text-[10px] font-mono px-2 py-0.5 rounded-full bg-slate-800/80 text-slate-300 border border-slate-700/50",children:"v1.0"})]}),e.jsxs("form",{onSubmit:c,className:"space-y-4",children:[e.jsxs("div",{className:"relative text-left",children:[e.jsx("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-[18px] text-slate-500",children:"key"}),e.jsx("input",{ref:d,type:s?"text":"password",placeholder:"Enter master password...",value:a,onChange:p=>{r(p.target.value),l&&x(null)},disabled:n,className:"w-full bg-[#07090E] border border-slate-800 rounded-xl pl-9 pr-10 py-2.5 text-xs text-white placeholder-slate-500 focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/20 transition-all font-mono"}),e.jsx("button",{type:"button",onClick:()=>t(!s),tabIndex:-1,className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-500 hover:text-slate-300 transition-colors cursor-pointer","aria-label":s?"Hide password":"Show password",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:s?"visibility_off":"visibility"})})]}),l&&e.jsxs("div",{className:"p-2.5 rounded-lg bg-rose-500/10 border border-rose-500/30 text-xs text-rose-300 flex items-center gap-2 text-left animate-rt-scale-in",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] shrink-0 text-rose-400",children:"error"}),e.jsx("span",{className:"truncate",children:l})]}),e.jsx("button",{type:"submit",disabled:n||!a.trim(),className:"w-full rt-btn rt-btn--primary text-xs py-2.5 px-4 flex items-center justify-center gap-2 cursor-pointer font-semibold shadow-lg shadow-blue-500/20 disabled:opacity-50 disabled:cursor-not-allowed transition-all",children:n?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] animate-spin",children:"progress_activity"}),"Verifying..."]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"lock_open"}),"Unlock Dashboard"]})})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-slate-500 text-[11px]",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px] text-blue-400",children:"verified_user"}),e.jsx("span",{children:"100% Local-First · Coding assistants proxy unaffected"})]})]})]})};function ie(a){let r={...a},s=!1,t=!1,n=0;const o=u=>{r={...u}},l=()=>{var b;if(r.disabled)return;const u=Date.now();u-n<250||(n=u,(b=r.onClose)==null||b.call(r))};return{updateOptions:o,handleMouseDown:u=>{r.disabled||(u.target===u.currentTarget&&(u.button===0||u.button===void 0)?s=!0:s=!1)},handleMouseUp:u=>{if(r.disabled){s=!1;return}s&&u.target===u.currentTarget&&(u.button===0||u.button===void 0)&&l(),s=!1},handleTouchStart:u=>{r.disabled||(u.target===u.currentTarget?t=!0:t=!1)},handleTouchEnd:u=>{if(r.disabled){t=!1;return}t&&u.target===u.currentTarget&&l(),t=!1},handleClick:u=>{r.disabled||u.detail===0&&u.target===u.currentTarget&&l()},reset:()=>{s=!1,t=!1},get isMouseDown(){return s},get isTouchStart(){return t}}}function ce(a,r=!1){const s=m.useRef(null);s.current?s.current.updateOptions({onClose:a,disabled:r}):s.current=ie({onClose:a,disabled:r}),m.useEffect(()=>{if(typeof window>"u")return;const n=()=>{var l;(l=s.current)==null||l.reset()},o=()=>{var l;(l=s.current)==null||l.reset()};return window.addEventListener("mouseup",n),window.addEventListener("touchend",o),()=>{window.removeEventListener("mouseup",n),window.removeEventListener("touchend",o)}},[]);const t=s.current;return{handleBackdropMouseDown:t.handleMouseDown,handleBackdropMouseUp:t.handleMouseUp,handleBackdropTouchStart:t.handleTouchStart,handleBackdropTouchEnd:t.handleTouchEnd,handleBackdropClick:t.handleClick,backdropProps:{onMouseDown:t.handleMouseDown,onMouseUp:t.handleMouseUp,onTouchStart:t.handleTouchStart,onTouchEnd:t.handleTouchEnd,onClick:t.handleClick}}}const K=({isOpen:a,onClose:r,children:s,maxWidthClass:t="max-w-xl",className:n="",overflowHidden:o=!1})=>{const{backdropProps:l}=ce(r);if(m.useEffect(()=>{if(!a)return;const d=c=>{c.key==="Escape"&&r()};document.addEventListener("keydown",d);const i=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",d),document.body.style.overflow=i}},[a,r]),!a||typeof document>"u")return null;const x=o?"overflow-hidden":n.includes("overflow-")?"":"overflow-visible";return J.createPortal(e.jsx("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-[9999] flex items-center justify-center p-4 bg-black/75 backdrop-blur-xs animate-rt-fade-in",...l,children:e.jsx("div",{className:`w-full ${t} bg-[#0F1420] border border-[#1E293B] rounded-2xl shadow-2xl p-6 animate-rt-scale-in text-slate-100 ${x} ${n}`,onClick:d=>d.stopPropagation(),children:s})}),document.body)},de=({isOpen:a,onClose:r})=>{const[s,t]=m.useState("confirm"),[n,o]=m.useState(null),[l,x]=m.useState(0),d=m.useRef(null),i=m.useRef(null);m.useEffect(()=>(a?(t("confirm"),o(null),x(0)):(d.current&&clearInterval(d.current),i.current&&clearInterval(i.current)),()=>{d.current&&clearInterval(d.current),i.current&&clearInterval(i.current)}),[a]);const c=()=>{const h=Date.now();let u=0;i.current=setInterval(()=>{x(Math.floor((Date.now()-h)/1e3))},500),setTimeout(()=>{d.current=setInterval(async()=>{u+=1;try{const b=await fetch("/health",{cache:"no-store",headers:{Accept:"application/json"}});if(b.ok){const g=await b.json().catch(()=>null);(g==null?void 0:g.status)==="ok"&&(d.current&&clearInterval(d.current),i.current&&clearInterval(i.current),t("success"),setTimeout(()=>{window.location.reload()},600))}}catch{}u>=50&&(d.current&&clearInterval(d.current),i.current&&clearInterval(i.current),t("timeout"))},500)},600)},p=async()=>{t("restarting"),o(null);try{const h=await fetch("/api/server/restart",{method:"POST",headers:{"Content-Type":"application/json"}});if(!h.ok){const u=await h.json().catch(()=>({}));o(u.error||"Failed to initiate server restart."),t("confirm");return}}catch{}c()};return e.jsx(K,{isOpen:a,onClose:()=>{(s==="confirm"||s==="timeout")&&r()},maxWidthClass:"max-w-md",children:e.jsxs("div",{className:"space-y-4",children:[s==="confirm"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-10 rounded-xl bg-blue-500/15 border border-blue-500/30 text-blue-400 flex items-center justify-center shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[24px]",children:"restart_alt"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-white",children:"Restart Mapigate Gateway?"}),e.jsx("p",{className:"text-xs text-slate-400",children:"Gracefully reload server and apply new version"})]})]}),e.jsxs("div",{className:"p-3.5 rounded-xl bg-[#0A0D14] border border-[#1E293B] text-xs text-slate-300 space-y-2 leading-relaxed",children:[e.jsx("p",{children:"Hot restarting the gateway reloads all provider modules, registries, and configuration. MITM proxy and tool DNS entries remain active across restart."}),e.jsxs("p",{className:"text-slate-400 text-[11px]",children:["If you recently installed an update (e.g. via ",e.jsx("code",{className:"text-blue-400",children:"npm install -g mapigate"})," or ",e.jsx("code",{className:"text-blue-400",children:"npm run local:publish"}),"), the new code will take effect immediately without needing to open a terminal or turn off DNS."]})]}),n&&e.jsx("div",{className:"p-3 rounded-lg bg-rose-500/10 border border-rose-500/30 text-xs text-rose-300",children:n}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-2",children:[e.jsx("button",{type:"button",onClick:r,className:"rt-btn rt-btn--secondary text-xs py-2 px-4 cursor-pointer",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:p,className:"rt-btn rt-btn--primary text-xs py-2 px-4 flex items-center gap-1.5 cursor-pointer font-semibold",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"restart_alt"}),"Restart Gateway"]})]})]}),s==="restarting"&&e.jsxs("div",{className:"py-6 px-2 text-center space-y-4",children:[e.jsxs("div",{className:"relative size-14 mx-auto flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-blue-500/20 border-t-blue-500 animate-spin"}),e.jsx("span",{className:"material-symbols-outlined text-[28px] text-blue-400",children:"restart_alt"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h4",{className:"text-sm font-bold text-white",children:"Restarting Mapigate Gateway..."}),e.jsxs("p",{className:"text-xs text-slate-400",children:["Re-spawning daemon and binding port (",l,"s)"]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Please wait. This page will refresh automatically once the new server responds."})]}),s==="success"&&e.jsxs("div",{className:"py-6 px-2 text-center space-y-4",children:[e.jsx("div",{className:"size-14 mx-auto rounded-full bg-emerald-500/15 border border-emerald-500/30 text-emerald-400 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-[32px]",children:"check_circle"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h4",{className:"text-sm font-bold text-white",children:"Restart Succeeded!"}),e.jsx("p",{className:"text-xs text-emerald-400 font-medium",children:"Gateway is back online. Refreshing dashboard..."})]})]}),s==="timeout"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-10 rounded-xl bg-amber-500/15 border border-amber-500/30 text-amber-400 flex items-center justify-center shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[24px]",children:"schedule"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-white",children:"Restart Taking Longer Than Expected"}),e.jsx("p",{className:"text-xs text-slate-400",children:"The gateway server has not responded yet."})]})]}),e.jsxs("div",{className:"p-3.5 rounded-xl bg-[#0A0D14] border border-[#1E293B] text-xs text-slate-300 space-y-2",children:[e.jsx("p",{children:"If the server failed to restart automatically, you can start it manually in your terminal:"}),e.jsx("div",{className:"bg-[#111827] p-2.5 rounded-lg border border-[#1E293B] font-mono text-[11px] text-blue-400",children:"mpg start"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-2",children:[e.jsx("button",{type:"button",onClick:r,className:"rt-btn rt-btn--secondary text-xs py-2 px-4 cursor-pointer",children:"Close"}),e.jsxs("button",{type:"button",onClick:()=>window.location.reload(),className:"rt-btn rt-btn--primary text-xs py-2 px-4 flex items-center gap-1.5 cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"refresh"}),"Refresh Page"]})]})]})]})})},ue=({isOpen:a,onClose:r,currentVersion:s,latestVersion:t})=>{const[n,o]=m.useState("confirm"),[l,x]=m.useState(null),[d,i]=m.useState(0),c=m.useRef(null),p=m.useRef(null);m.useEffect(()=>(a?(o("confirm"),x(null),i(0)):(c.current&&clearInterval(c.current),p.current&&clearInterval(p.current)),()=>{c.current&&clearInterval(c.current),p.current&&clearInterval(p.current)}),[a]);const h=()=>{let b=0;setTimeout(()=>{c.current=setInterval(async()=>{b+=1;try{const g=await fetch("/health",{cache:"no-store",headers:{Accept:"application/json"}});if(g.ok){const f=await g.json().catch(()=>null);(f==null?void 0:f.status)==="ok"&&(c.current&&clearInterval(c.current),p.current&&clearInterval(p.current),o("success"),setTimeout(()=>{window.location.reload()},800))}}catch{}b>=60&&(c.current&&clearInterval(c.current),p.current&&clearInterval(p.current),o("timeout"))},500)},800)},u=async()=>{o("upgrading"),x(null),i(0);const b=Date.now();p.current=setInterval(()=>{i(Math.floor((Date.now()-b)/1e3))},500);try{const g=await fetch("/api/server/upgrade",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:!1})}),f=await g.json().catch(()=>({}));if(!g.ok||!f.success){p.current&&clearInterval(p.current),x(f.error||"Failed to upgrade Mapigate."),o("error");return}o("restarting"),h()}catch(g){p.current&&clearInterval(p.current),x((g==null?void 0:g.message)||"Network error while requesting upgrade."),o("error")}};return e.jsx(K,{isOpen:a,onClose:()=>{(n==="confirm"||n==="error"||n==="timeout")&&r()},maxWidthClass:"max-w-md",children:e.jsxs("div",{className:"space-y-4",children:[n==="confirm"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-10 rounded-xl bg-amber-500/15 border border-amber-500/30 text-amber-400 flex items-center justify-center shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[24px]",children:"upgrade"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-white",children:"Upgrade Mapigate Gateway"}),e.jsx("p",{className:"text-xs text-slate-400",children:"Install the latest release from npm and reload"})]})]}),e.jsxs("div",{className:"p-3.5 rounded-xl bg-[#0A0D14] border border-[#1E293B] space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-slate-400",children:"Current Version:"}),e.jsxs("span",{className:"font-mono font-semibold text-slate-300",children:["v",s||"0.0.0"]})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-slate-400",children:"Target Version:"}),e.jsxs("span",{className:"font-mono font-semibold text-amber-400",children:["v",t||"latest"]})]}),e.jsxs("div",{className:"pt-2 border-t border-[#1E293B] text-[11px] text-slate-400 leading-relaxed",children:["Mapigate will run ",e.jsxs("code",{className:"text-amber-400 font-mono",children:["npm install -g mapigate@",t||"latest"]})," and hot-reload the gateway. All database settings, API keys, and active combos will be preserved."]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs("a",{href:"https://www.npmjs.com/package/mapigate",target:"_blank",rel:"noreferrer",className:"text-[11px] text-blue-400 hover:text-blue-300 hover:underline inline-flex items-center gap-1",children:[e.jsx("span",{children:"View on npm"}),e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"open_in_new"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:r,className:"rt-btn rt-btn--secondary text-xs py-2 px-3.5 cursor-pointer",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:u,className:"rt-btn rt-btn--primary text-xs py-2 px-4 flex items-center gap-1.5 cursor-pointer font-semibold bg-amber-600 hover:bg-amber-500 text-white border-amber-500/40",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"upgrade"}),"Upgrade to v",t]})]})]})]}),n==="upgrading"&&e.jsxs("div",{className:"py-6 px-2 text-center space-y-4",children:[e.jsxs("div",{className:"relative size-14 mx-auto flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-amber-500/20 border-t-amber-500 animate-spin"}),e.jsx("span",{className:"material-symbols-outlined text-[28px] text-amber-400",children:"download"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h4",{className:"text-sm font-bold text-white",children:"Upgrading Mapigate..."}),e.jsxs("p",{className:"text-xs text-slate-400 font-mono",children:["npm install -g mapigate@",t||"latest"," (",d,"s)"]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Downloading and installing update. Please do not close this window."})]}),n==="restarting"&&e.jsxs("div",{className:"py-6 px-2 text-center space-y-4",children:[e.jsxs("div",{className:"relative size-14 mx-auto flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-blue-500/20 border-t-blue-500 animate-spin"}),e.jsx("span",{className:"material-symbols-outlined text-[28px] text-blue-400",children:"restart_alt"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h4",{className:"text-sm font-bold text-white",children:"Restarting Gateway..."}),e.jsxs("p",{className:"text-xs text-slate-400",children:["Re-spawning daemon with v",t," (",d,"s)"]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Gateway is reloading. This dashboard will refresh automatically once online."})]}),n==="success"&&e.jsxs("div",{className:"py-6 px-2 text-center space-y-4",children:[e.jsx("div",{className:"size-14 mx-auto rounded-full bg-emerald-500/15 border border-emerald-500/30 text-emerald-400 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-[32px]",children:"check_circle"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h4",{className:"text-sm font-bold text-white",children:"Upgrade Succeeded!"}),e.jsxs("p",{className:"text-xs text-emerald-400 font-medium",children:["Mapigate v",t," is live. Refreshing dashboard..."]})]})]}),n==="error"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-10 rounded-xl bg-rose-500/15 border border-rose-500/30 text-rose-400 flex items-center justify-center shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[24px]",children:"error"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-white",children:"Upgrade Failed"}),e.jsx("p",{className:"text-xs text-slate-400",children:"An error occurred while updating"})]})]}),l&&e.jsx("div",{className:"p-3 rounded-lg bg-rose-500/10 border border-rose-500/30 text-xs text-rose-300 font-mono break-words leading-relaxed max-h-36 overflow-y-auto",children:l}),e.jsxs("div",{className:"p-3 rounded-xl bg-[#0A0D14] border border-[#1E293B] text-[11px] text-slate-400 space-y-1.5 leading-relaxed",children:[e.jsx("p",{className:"font-semibold text-slate-300",children:"You can upgrade manually from your terminal:"}),e.jsxs("div",{className:"p-2 rounded bg-black/50 font-mono text-slate-200 text-[10px] space-y-1 select-all",children:[e.jsx("div",{children:"npm install -g mapigate@latest"}),e.jsx("div",{children:"mpg restart"})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx("button",{type:"button",onClick:r,className:"rt-btn rt-btn--secondary text-xs py-2 px-4 cursor-pointer",children:"Close"}),e.jsxs("button",{type:"button",onClick:u,className:"rt-btn rt-btn--primary text-xs py-2 px-4 flex items-center gap-1 cursor-pointer font-semibold",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"refresh"}),"Retry"]})]})]}),n==="timeout"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-10 rounded-xl bg-amber-500/15 border border-amber-500/30 text-amber-400 flex items-center justify-center shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[24px]",children:"schedule"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-white",children:"Server Still Starting"}),e.jsx("p",{className:"text-xs text-slate-400",children:"The gateway has not responded yet"})]})]}),e.jsxs("div",{className:"p-3.5 rounded-xl bg-[#0A0D14] border border-[#1E293B] text-xs text-slate-300 space-y-2 leading-relaxed",children:[e.jsx("p",{children:"The upgrade may have completed, but the server is taking longer than expected to bind to port."}),e.jsxs("p",{className:"text-slate-400 text-[11px]",children:["You can try refreshing the page or checking ",e.jsx("code",{className:"text-blue-400",children:"mpg status"})," in your terminal."]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx("button",{type:"button",onClick:r,className:"rt-btn rt-btn--secondary text-xs py-2 px-4 cursor-pointer",children:"Close"}),e.jsxs("button",{type:"button",onClick:()=>window.location.reload(),className:"rt-btn rt-btn--primary text-xs py-2 px-4 flex items-center gap-1.5 cursor-pointer font-semibold",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"refresh"}),"Refresh Page"]})]})]})]})})},xe=m.lazy(()=>y(()=>import("./ProvidersTab-Dd-prffr.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])).then(a=>({default:a.ProvidersTab}))),me=m.lazy(()=>y(()=>import("./ProviderDetailPage-CeOUazix.js"),__vite__mapDeps([8,1,6,4,9,5,3,10,2,7])).then(a=>({default:a.ProviderDetailPage}))),pe=m.lazy(()=>y(()=>import("./CombosTab-DdsJ2ova.js"),__vite__mapDeps([11,1,12,3,4,5,9,2,7])).then(a=>({default:a.CombosTab}))),he=m.lazy(()=>y(()=>import("./UsageTab-Da7c7zwV.js"),__vite__mapDeps([13,1,7,5,4,14,9])).then(a=>({default:a.UsageTab}))),fe=m.lazy(()=>y(()=>import("./QuotaTab-zPkj0Rwo.js"),__vite__mapDeps([15,1,4,5,9,10,2,7])).then(a=>({default:a.QuotaTab}))),be=m.lazy(()=>y(()=>import("./CliToolsTab-iJozQAQx.js"),__vite__mapDeps([16,1,6,4,5,3,7])).then(a=>({default:a.CliToolsTab}))),ge=m.lazy(()=>y(()=>import("./MitmTab-DMRg64by.js"),__vite__mapDeps([17,1,3,4,5,7])).then(a=>({default:a.MitmTab}))),ve=m.lazy(()=>y(()=>import("./EndpointTab-DbjjVT7s.js"),__vite__mapDeps([18,1,9,2,7])).then(a=>({default:a.EndpointTab}))),ye=m.lazy(()=>y(()=>import("./TokenSaverTab-B3Fbu_yc.js"),__vite__mapDeps([19,1])).then(a=>({default:a.TokenSaverTab}))),je=m.lazy(()=>y(()=>import("./ConsoleLogTab-BTGaJpcD.js"),__vite__mapDeps([20,1,9,7,5])).then(a=>({default:a.ConsoleLogTab}))),we=m.lazy(()=>y(()=>import("./SettingsTab-DUlhyz1z.js"),__vite__mapDeps([21,1,7])).then(a=>({default:a.SettingsTab}))),Ne=m.lazy(()=>y(()=>import("./CallbackPage-sTRnWJ-d.js"),__vite__mapDeps([22,1])));function Q(){return e.jsx("div",{className:"flex items-center justify-center py-24 text-slate-500",children:e.jsx("div",{className:"size-6 rounded-full border-2 border-blue-500/20 border-t-blue-500 animate-spin"})})}function ke(){const a=typeof window<"u"?new URLSearchParams(window.location.search):null,r=!!(a&&(a.has("user_id")&&(a.has("access_token")||a.has("accessToken")||a.has("token"))||a.has("userId")&&(a.has("access_token")||a.has("accessToken")||a.has("token"))));return typeof window<"u"&&(window.location.pathname==="/callback"||window.location.pathname==="/auth/callback"||window.location.pathname==="/authorize"||window.location.pathname.startsWith("/callback")||r)?e.jsx(m.Suspense,{fallback:e.jsx(Q,{}),children:e.jsx(Ne,{})}):e.jsx(Te,{})}function Te(){const a=j(f=>f.isChecking),r=j(f=>f.isLocked),s=j(f=>f.checkAuth),t=_(f=>f.fetchSystemInfo);m.useEffect(()=>{s(),t()},[s,t]);const[n,o]=m.useState("providers"),[l,x]=m.useState(""),[d,i]=m.useState(null),[c,p]=m.useState(!1),[h,u]=m.useState(!1),b=_(f=>f.info),g=f=>{o(f),i(null)};return a?e.jsx("div",{className:"fixed inset-0 flex items-center justify-center bg-[#0A0D14] text-slate-400",children:e.jsx("div",{className:"size-8 rounded-full border-2 border-blue-500/20 border-t-blue-500 animate-spin"})}):r?e.jsx(le,{}):e.jsxs("div",{className:"rt-app",children:[e.jsx(se,{currentTab:n,onSelectTab:g,onUpgradeClick:()=>u(!0)}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 h-full overflow-hidden",children:[e.jsx(oe,{currentTab:n,searchQuery:l,onSearchChange:x,detailProvider:d,onBackToProviders:()=>i(null),onRestartClick:()=>p(!0),onSelectTab:g}),e.jsx("main",{className:"flex-1 overflow-y-auto px-4 sm:px-6 py-6 w-full",children:e.jsxs(m.Suspense,{fallback:e.jsx(Q,{}),children:[n==="endpoint"&&e.jsx(ve,{onRestartClick:()=>p(!0)}),n==="providers"&&(d?e.jsx(me,{provider:d,onBack:()=>i(null)}):e.jsx(xe,{searchQuery:l,onSelectProvider:f=>i(f)})),n==="combos"&&e.jsx(pe,{}),n==="usage"&&e.jsx(he,{}),n==="quota"&&e.jsx(fe,{searchQuery:l}),n==="tokensaver"&&e.jsx(ye,{}),n==="clitools"&&e.jsx(be,{}),n==="mitm"&&e.jsx(ge,{}),n==="consolelog"&&e.jsx(je,{}),n==="settings"&&e.jsx(we,{onRestartClick:()=>p(!0),onUpgradeClick:()=>u(!0)})]})})]}),e.jsx(de,{isOpen:c,onClose:()=>p(!1)}),e.jsx(ue,{isOpen:h,onClose:()=>u(!1),currentVersion:b==null?void 0:b.version,latestVersion:b==null?void 0:b.latestVersion})]})}Y.createRoot(document.getElementById("root")).render(e.jsx(X.StrictMode,{children:e.jsx(ke,{})}));export{w as A,T as D,K as P,de as R,ce as a,Se as b,te as c,R as d,F as e,j as f,_ as u};