mapigate 0.5.170 → 0.5.174
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/adapters/responsesAdapter.js +2 -2
- package/dist/providers/catalog/perplexity/index.js +1 -1
- package/dist/providers/catalog/perplexity/provider.js +1 -1
- package/dist/providers/core/base/customExecutionHelper.js +21 -1
- package/dist/providers/core/base/responsesExecution.js +37 -0
- package/dist/providers/core/base/responsesPayloadBuilder.js +5 -0
- package/dist/providers/runtime/antigravity/weekly.js +1 -1
- package/dist/providers/runtime/codex/index.js +1 -1
- package/dist/providers/runtime/codex/provider.js +1 -1
- package/dist/providers/runtime/codex/responses.js +1 -0
- package/dist/providers/runtime/codex/responsesPayload.js +1 -0
- package/dist/providers/runtime/grok-cli/grokWeb.js +5 -0
- package/dist/providers/runtime/grok-cli/provider.js +1 -1
- package/dist/providers/runtime/ollama/nativeChat.js +3 -0
- package/dist/providers/runtime/ollama/provider.js +1 -1
- package/dist/providers/runtime/opencode/provider.js +1 -1
- package/dist/web/assets/CallbackPage-B-htyyMG.js +1 -0
- package/dist/web/assets/{CliToolsTab-AP4tHWEj.js → CliToolsTab-Q0vXiulu.js} +24 -24
- package/dist/web/assets/ComboDetailPage-hWEuQaOZ.js +1 -0
- package/dist/web/assets/CombosTab-nBWliTLU.js +1 -0
- package/dist/web/assets/{ConfirmModal-gmHKbGNe.js → ConfirmModal-CsfteGXH.js} +1 -1
- package/dist/web/assets/ConsoleLogTab-CW8OK2qW.js +6 -0
- package/dist/web/assets/EditAccountModal-CAxJfsFe.js +1 -0
- package/dist/web/assets/EndpointTab-BSOhVZQl.js +1 -0
- package/dist/web/assets/MitmTab-BjTPAKno.js +6 -0
- package/dist/web/assets/ModelSelectModal-BP5Ha7Az.js +1 -0
- package/dist/web/assets/PortalDrawer-Bv31mboq.js +1 -0
- package/dist/web/assets/ProviderDetailPage-CeYToos_.js +6 -0
- package/dist/web/assets/{ProvidersTab-DyeFqcx4.js → ProvidersTab-C4ZpyulK.js} +1 -1
- package/dist/web/assets/QuotaTab-Dh1eTSJx.js +1 -0
- package/dist/web/assets/SettingsTab-D0Bo21nq.js +1 -0
- package/dist/web/assets/{TokenSaverTab-B3Fbu_yc.js → TokenSaverTab-BYqUuEE1.js} +1 -1
- package/dist/web/assets/UsageTab-C5qvXO61.js +1 -0
- package/dist/web/assets/clipboard-CLQF8jeK.js +1 -0
- package/dist/web/assets/index-_goGZDSK.css +1 -0
- package/dist/web/assets/index-vFoRSZw0.js +10 -0
- package/dist/web/index.html +2 -2
- package/package.json +2 -2
- package/dist/web/assets/CallbackPage-sTRnWJ-d.js +0 -1
- package/dist/web/assets/ComboDetailPage-8ZPxPl5N.js +0 -1
- package/dist/web/assets/CombosTab-D0T91znw.js +0 -1
- package/dist/web/assets/ConsoleLogTab-Bpvxqa2f.js +0 -6
- package/dist/web/assets/EditAccountModal-PEltZRS8.js +0 -1
- package/dist/web/assets/EndpointTab-CYnFpxjA.js +0 -1
- package/dist/web/assets/MitmTab-De7zsN2f.js +0 -14
- package/dist/web/assets/ModelSelectModal-B7-jAYUU.js +0 -1
- package/dist/web/assets/ProviderDetailPage-DvqxjQHh.js +0 -6
- package/dist/web/assets/QuotaTab-DrNRwUP6.js +0 -1
- package/dist/web/assets/SettingsTab-DS6HQKrg.js +0 -1
- package/dist/web/assets/UsageTab-Du6U3MIb.js +0 -1
- package/dist/web/assets/index-9wZva5_f.css +0 -1
- package/dist/web/assets/index-BvY11iVv.js +0 -2
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import{r as n,j as e}from"./vendor-BcOI2aZ9.js";import{u as Bt,D as Et,d as At,P as Xe,e as Dt}from"./index-BvY11iVv.js";import{M as Ze}from"./ModelAutocompleteInput-BH4gr6Dr.js";import{r as ue}from"./metadataRegistry-4BIaQVmV.js";import{T as It}from"./ToolIcon-BZE0Fv7L.js";import"./lucide-Cc35htxl.js";const Se={},Pt=({toolId:m="kiro",value:r,onChange:u,onEnter:b,placeholder:w="Select or type source model ID...",className:v="",autoFocus:x=!1,disabled:C=!1})=>{const f=(m||"kiro").toLowerCase(),[N,c]=n.useState([]),[g,j]=n.useState(!1),[S,D]=n.useState(-1),[pe,P]=n.useState("bottom"),M=n.useRef(null),R=n.useRef(null);n.useEffect(()=>{if(g&&M.current){const l=M.current.getBoundingClientRect(),p=240,T=window.innerHeight-l.bottom,O=l.top;T<p&&O>T?P("top"):P("bottom")}},[g]),n.useEffect(()=>{let l=!0;if(Se[f]){c(Se[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=>{l&&Array.isArray(p)&&(Se[f]=p,c(p))}).catch(()=>{}),()=>{l=!1}},[f]),n.useEffect(()=>{const l=p=>{M.current&&!M.current.contains(p.target)&&j(!1)};return document.addEventListener("mousedown",l),()=>{document.removeEventListener("mousedown",l)}},[]);const h=n.useMemo(()=>{const l=(r||"").trim().toLowerCase();return l?N.filter(p=>p.id.toLowerCase().includes(l)||p.name.toLowerCase().includes(l)):N},[N,r]);n.useEffect(()=>{D(h.length>0?0:-1)},[h]),n.useEffect(()=>{if(g&&S>=0&&R.current){const l=R.current.children[S];l&&l.scrollIntoView({block:"nearest"})}},[S,g]);const Q=l=>{u(l),j(!1)},xe=l=>{l.key==="ArrowDown"?(l.preventDefault(),g?h.length>0&&D(p=>(p+1)%h.length):j(!0)):l.key==="ArrowUp"?(l.preventDefault(),g&&h.length>0&&D(p=>(p-1+h.length)%h.length)):l.key==="Enter"?g&&S>=0&&S<h.length?(l.preventDefault(),Q(h[S].id)):b&&(l.preventDefault(),b()):l.key==="Escape"&&j(!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:l=>{u(l.target.value),g||j(!0)},onFocus:()=>j(!0),onKeyDown:xe,placeholder:w,disabled:C,autoFocus:x,className:v||"w-full bg-[#0A0D14] border border-[#1E293B] rounded-xl px-3 py-2 text-xs text-white font-mono focus:outline-none focus:border-blue-500 placeholder:text-slate-600"}),e.jsx("button",{type:"button",tabIndex:-1,onClick:()=>j(l=>!l),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:R,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 ${pe==="top"?"bottom-full mb-1":"top-full mt-1"}`,children:h.map((l,p)=>{const T=p===S,O=l.category==="native";return e.jsxs("div",{onClick:()=>Q(l.id),onMouseEnter:()=>D(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:l.id}),l.name&&l.name!==l.id&&e.jsx("span",{className:"text-[10.5px] text-slate-400 font-sans truncate",children:l.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"})})]},`${l.category}-${l.id}`)})})]})},Rt={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"]},Lt={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"]},_t={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 v;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=(v=m.headers)==null?void 0:v["x-amz-target"],w=Array.isArray(b)?b[0]:String(b||"");return w.includes("ListAvailableModels")||w.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"]},et=[Rt,Lt,_t];function Ot(m,r="source",u="asc"){return[...m].sort((b,w)=>{if(r==="target"){const f=b.targetModel||"",N=w.targetModel||"";if(!f&&N)return 1;if(f&&!N)return-1;const c=f.localeCompare(N,void 0,{numeric:!0,sensitivity:"base"});if(c!==0)return u==="asc"?c:-c}const v=b.sourceModel.toLowerCase()==="auto",x=w.sourceModel.toLowerCase()==="auto";if(v&&!x)return u==="asc"?-1:1;if(!v&&x)return u==="asc"?1:-1;const C=b.sourceModel.localeCompare(w.sourceModel,void 0,{numeric:!0,sensitivity:"base"});return u==="asc"?C:-C})}const zt=()=>{const m=Bt(t=>t.info),r=(m==null?void 0:m.port)||Et,u=(m==null?void 0:m.host)||At,[b,w]=n.useState(""),v=b||`http://${u}:${r}`,[x,C]=n.useState(!0),[f,N]=n.useState(443),[c,g]=n.useState(null),[j,S]=n.useState(""),[D,pe]=n.useState(!1),[P,M]=n.useState(!1),[R,h]=n.useState(null),[Q,xe]=n.useState(!0),[l,p]=n.useState(!1),[T,O]=n.useState(""),[he,tt]=n.useState(""),[X,st]=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"}),[B,ke]=n.useState(null),[Me,Te]=n.useState(!1),[Be,Ee]=n.useState(!1),[Z,k]=n.useState(null),[Ae,$]=n.useState({antigravity:!1,kiro:!1,copilot:!1}),[L,ee]=n.useState({antigravity:!1,kiro:!1,copilot:!1}),[at,nt]=n.useState(null),ot=n.useMemo(()=>[...et].sort((t,s)=>t.name.localeCompare(s.name)),[]),[De,te]=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"}),[it,ge]=n.useState({}),[Ie,lt]=n.useState({}),[rt,se]=n.useState({}),[ct,U]=n.useState({antigravity:[],kiro:[],copilot:[]}),[dt,mt]=n.useState({}),[ut,Pe]=n.useState({}),[H,Re]=n.useState({}),[pt,ae]=n.useState(null),[ne,oe]=n.useState(null),[be,q]=n.useState(""),[_,F]=n.useState(null),[fe,ye]=n.useState(""),[je,Ne]=n.useState(""),[Le,xt]=n.useState(new Set),[K,_e]=n.useState(""),[z,Oe]=n.useState(""),[$e,Ue]=n.useState(!1),[He,qe]=n.useState(!1),[Fe,Ke]=n.useState(!1),[ie,we]=n.useState(null),[le,W]=n.useState(null),[re,ht]=n.useState([]),G=n.useMemo(()=>{const t=K.trim().toLowerCase();return t?!t.includes("127.0.0.1")&&!t.includes("localhost")&&!t.includes("0.0.0.0"):!1},[K]);n.useEffect(()=>{fetch("/api/combos").then(t=>t.ok?t.json():[]).then(t=>{const s=Array.isArray(t)?t:t.combos||[];xt(new Set(s.map(o=>(o.name||"").toLowerCase())))}).catch(()=>{})},[]);const E=(t,s)=>{navigator.clipboard.writeText(s),ke(t),setTimeout(()=>ke(null),2e3)},I=()=>{fetch("/api/mitm/status").then(t=>t.json()).then(t=>{C(!!t.running),t.port&&N(t.port),xe(!!t.certExists),p(!!t.certTrusted),t.certPath&&O(t.certPath),t.fingerprint&&tt(t.fingerprint),t.routerBaseUrl&&w(t.routerBaseUrl),t.installCommands&&st(t.installCommands),t.dnsStatus&&$(s=>{var o,a,d;return{...s,antigravity:!!((o=t.dnsStatus)!=null&&o.antigravity),kiro:!!((a=t.dnsStatus)!=null&&a.kiro),copilot:!!((d=t.dnsStatus)!=null&&d.copilot)}}),t.augmentModels&&ee(s=>({...s,...t.augmentModels})),Dt.getState().fetchStatus()}).catch(()=>{}),fetch("/api/mitm/router-target").then(t=>t.ok?t.json():null).then(t=>{t&&(_e(t.baseUrl||""),Ue(!!t.hasApiKey),t.isRemote&&t.baseUrl&&ze())}).catch(()=>{})},ze=()=>{fetch("/api/mitm/router-target/models").then(t=>t.ok?t.json():{models:[]}).then(t=>{const s=(t.models||[]).map(o=>({id:o.id,value:o.id,name:o.name||o.id,providerId:o.provider||"remote",providerName:o.provider||"Remote Gateway",hasConnectedAccount:!0,accountsCount:1,caps:{vision:!0,reasoning:!0,audio:!1},contextLength:128e3}));ht(s)}).catch(()=>{})},gt=async()=>{qe(!0),we(null);try{const s=await(await fetch("/api/mitm/router-target/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:K.trim(),apiKey:z.trim()||void 0})})).json();we({success:!!s.success,message:s.message||(s.success?"Connection successful":"Connection failed")}),s.success&&G&&ze()}catch(t){we({success:!1,message:(t==null?void 0:t.message)||"Test request failed"})}finally{qe(!1)}},bt=async()=>{if(!x){Ke(!0),W(null);try{const s=await(await fetch("/api/mitm/router-target",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:K.trim(),apiKey:z!==""?z.trim():void 0})})).json();s.success?(W({success:!0,message:"Target configuration saved!"}),Ue(!!s.hasApiKey),Oe(""),I()):W({success:!1,message:s.error||"Failed to save target"})}catch(t){W({success:!1,message:(t==null?void 0:t.message)||"Failed to save target"})}finally{Ke(!1),setTimeout(()=>W(null),3e3)}}},ft=()=>{et.forEach(t=>{fetch(`/api/mitm/hosts/${t.id}`).then(s=>s.json()).then(s=>{s.entries&&te(o=>({...o,[t.id]:s.entries}))}).catch(()=>{}),fetch(`/api/mitm/mappings/${t.id}`).then(s=>s.json()).then(s=>{Array.isArray(s)&&U(o=>({...o,[t.id]:s}))}).catch(()=>{})})};n.useEffect(()=>{I(),ft()},[]);const ce=async(t=!1,s)=>{h(null);let o;if(s!==void 0)o=s;else if(j.trim()){const a=Number(j.trim());if(isNaN(a)||!Number.isInteger(a)||a<1||a>65535){h("Port must be an integer between 1 and 65535.");return}o=a}if(x&&!t){C(!1);try{const d=await(await fetch("/api/mitm/toggle-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({running:!1})})).json();C(!!d.running),d.port&&N(d.port),d.dnsStatus&&$({antigravity:!!d.dnsStatus.antigravity,kiro:!!d.dnsStatus.kiro,copilot:!!d.dnsStatus.copilot}),I()}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:o,forceKill:t})});if(a.status===409){const A=await a.json();g(A.portOwner||{port:o||443,inUse:!0}),C(!1);return}if(!a.ok){const A=await a.json().catch(()=>({}));throw new Error(A.error||`Failed to start server (${a.status})`)}const d=await a.json();C(!!d.running),d.port&&N(d.port),d.dnsStatus&&$({antigravity:!!d.dnsStatus.antigravity,kiro:!!d.dnsStatus.kiro,copilot:!!d.dnsStatus.copilot}),d.warning&&h(d.warning),g(null),I()}catch(a){h((a==null?void 0:a.message)||"Failed to start server")}finally{M(!1)}},yt=async()=>{Te(!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!"}),I()):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{Te(!1)}},jt=async()=>{Ee(!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!"}),I()):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{Ee(!1)}},Nt=async t=>{const s=!Ae[t];$(o=>({...o,[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&&$(d=>({...d,antigravity:!!a.dnsStatus.antigravity,kiro:!!a.dnsStatus.kiro,copilot:!!a.dnsStatus.copilot})),a.warning&&h(a.warning),I()}catch{}},wt=async t=>{const s=!L[t];ee(o=>({...o,[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&&ee(d=>({...d,...a.augmentModels}))}catch{ee(o=>({...o,[t]:!s}))}},vt=async t=>{const s=De[t]||"";try{(await fetch(`/api/mitm/hosts/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:s})})).ok&&(se(a=>({...a,[t]:"Saved hosts successfully."})),ge(a=>({...a,[t]:!1})),setTimeout(()=>{se(a=>({...a,[t]:null}))},3e3))}catch{}},Ct=async t=>{try{const o=await(await fetch(`/api/mitm/hosts/${t}/reset`,{method:"POST"})).json();o.entries&&(te(a=>({...a,[t]:o.entries})),se(a=>({...a,[t]:"Hosts reset to default."})),setTimeout(()=>{se(a=>({...a,[t]:null}))},3e3))}catch{}},St=async t=>{try{const o=await(await fetch("/api/mitm/mappings/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ide:t})})).json();Array.isArray(o.mappings)&&U(a=>({...a,[t]:o.mappings}))}catch{}},kt=async()=>{if(!_||!fe.trim()||!je.trim())return;const t=_,s={sourceModel:fe.trim(),targetModel:je.trim()};U(o=>({...o,[t]:[...o[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{ye(""),Ne(""),F(null)}},We=async t=>{if(!ne||!be.trim())return;let s=be.trim();Le.has(s.toLowerCase())&&!s.startsWith("combo/")&&(s=`combo/${s}`),U(o=>({...o,[t]:(o[t]||[]).map(a=>a.sourceModel===ne?{...a,targetModel:s}:a)}));try{await fetch("/api/mitm/mappings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ide:t,sourceModel:ne,targetModel:s})})}catch{}finally{oe(null),ae(null),q("")}},Mt=(t,s)=>{U(o=>({...o,[t]:(o[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:()=>ce(),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"]})})]}),R&&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:R})]}),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:v})]}),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"}),G?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 (${v})`,value:K,disabled:x,onChange:t=>_e(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 ",$e&&!z&&"(Configured ✓)"]}),e.jsx("input",{type:"password",disabled:x,placeholder:$e?"•••••••••••• (Leave blank to keep)":G?"Optional (Required if Target requires key)":"Optional (Dedicated MITM key used by default)",value:z,onChange:t=>Oe(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:[ie&&e.jsxs("span",{className:`inline-flex items-center gap-1 text-[11.5px] ${ie.success?"text-emerald-400":"text-rose-400"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:ie.success?"check_circle":"cancel"}),ie.message]}),le&&e.jsxs("span",{className:`inline-flex items-center gap-1 text-[11.5px] ${le.success?"text-emerald-400":"text-rose-400"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:le.success?"check":"error"}),le.message]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",disabled:He,onClick:gt,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"}),He?"Testing...":"Test Connection"]}),e.jsxs("button",{type:"button",disabled:Fe||x,title:x?"Stop MITM server before editing target configuration":void 0,onClick:bt,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"}),Fe?"Saving...":"Save Target"]})]})]})]})}),e.jsxs("div",{className:"pt-2 border-t border-[#1E293B]/60",children:[e.jsxs("button",{type:"button",onClick:()=>pe(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:D?"expand_less":"tune"}),e.jsx("span",{children:"Advanced / Custom Port Configuration"})]}),D&&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:j,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&&j&&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"}),l?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"]}),Q&&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(),o=URL.createObjectURL(s),a=document.createElement("a");a.href=o,a.download="mapigate-rootCA.crt",document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(o)}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"]}),l?e.jsxs("button",{disabled:Be,onClick:jt,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"}),Be?"Uninstalling...":"Uninstall from System"]}):e.jsxs("button",{disabled:Me,onClick:yt,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"}),Me?"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:"}),he&&e.jsxs("button",{onClick:()=>E("fp",he),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"}),B==="fp"?"Copied":"Copy"]})]}),e.jsx("code",{className:"text-purple-300 font-mono text-[11px] block break-all",children:he||"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:()=>E("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"}),B==="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:()=>E("winCmd",X.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"}),B==="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:X.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:()=>E("macCmd",X.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"}),B==="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:X.mac})]})]})]}),Z&&e.jsxs("div",{className:`p-2.5 rounded-xl text-xs flex items-center gap-2 ${Z.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:Z.type==="success"?"check_circle":"error"}),Z.text]})]}),e.jsx("div",{className:"space-y-4",children:ot.map(t=>{const s=at===t.id,o=!!Ae[t.id],a=!!it[t.id],d=De[t.id]||t.defaultHost,A=dt[t.id]||"source",de=ut[t.id]||"asc",Ge=Ot(ct[t.id]||[],A,de),J=(H[t.id]||"").trim().toLowerCase(),Je=J?Ge.filter(i=>{const y=i.sourceModel.toLowerCase(),V=(i.targetModel||"").toLowerCase(),Y=(ue(i.sourceModel)||"").toLowerCase(),ve=(ue(i.targetModel)||"").toLowerCase();return y.includes(J)||V.includes(J)||Y.includes(J)||ve.includes(J)}):Ge,Ve=rt[t.id],Ye=i=>{A===i?Pe(y=>({...y,[t.id]:de==="asc"?"desc":"asc"})):(mt(y=>({...y,[t.id]:i})),Pe(y=>({...y,[t.id]:"asc"})))};return e.jsxs("div",{className:"rt-card p-5 space-y-4",children:[e.jsxs("div",{onClick:()=>nt(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(It,{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 ${o?"rt-badge--success":"rt-badge--muted"}`,children:o?"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:i=>{i.stopPropagation(),Nt(t.id)},className:`rt-btn text-xs py-1.5 px-3 ${o?"rt-btn--danger":"rt-btn--primary"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:o?"stop":"play_arrow"}),o?"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:()=>{Ie[t.id]!==void 0&&te(i=>({...i,[t.id]:Ie[t.id]})),ge(i=>({...i,[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:()=>vt(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:()=>Ct(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:()=>{lt(i=>({...i,[t.id]:d})),ge(i=>({...i,[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:i=>te(y=>({...y,[t.id]:i.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"}),Ve&&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"}),Ve]})]}),(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 ${L[t.id]?"rt-badge--success":"rt-badge--muted"}`,children:L[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:()=>wt(t.id),className:`rt-btn text-xs py-1.5 px-3.5 shrink-0 flex items-center gap-1.5 cursor-pointer ${L[t.id]?"rt-btn--primary":"rt-btn--secondary"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:L[t.id]?"toggle_on":"toggle_off"}),L[t.id]?"Enabled":"Enable"]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 rounded-2xl bg-[#0F1420]/80 border border-[#1E293B] flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs("div",{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-[20px]",children:"alt_route"}),"Model Redirection Mappings (",t.name,")"]}),e.jsx("p",{className:"text-xs 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",{type:"button",onClick:()=>St(t.id),className:"px-3 py-1.5 text-xs font-medium rounded-xl bg-slate-800/80 hover:bg-slate-700/80 border border-[#1E293B] hover:border-slate-600 text-slate-200 flex items-center gap-1.5 transition-all cursor-pointer",title:"Reset to default mappings",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px] text-slate-400",children:"restart_alt"}),"Reset to Default"]}),e.jsxs("button",{type:"button",onClick:()=>{F(t.id),ye(""),Ne("")},className:"px-3.5 py-1.5 text-xs font-semibold rounded-xl bg-blue-600 hover:bg-blue-500 shadow-md shadow-blue-600/30 text-white flex items-center gap-1.5 transition-all cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"add_circle"}),"Add Mapping"]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-slate-500 text-[18px]",children:"search"}),e.jsx("input",{type:"text",value:H[t.id]||"",onChange:i=>Re(y=>({...y,[t.id]:i.target.value})),placeholder:"Search model alias or destination...",className:"w-full bg-[#0F1420]/80 border border-[#1E293B] focus:border-blue-500 rounded-xl pl-9 pr-4 py-2 text-xs text-slate-200 focus:outline-none"})]}),(H[t.id]||"")&&e.jsx("button",{type:"button",onClick:()=>Re(i=>({...i,[t.id]:""})),className:"text-xs text-slate-400 hover:text-white cursor-pointer",children:"Clear"})]}),e.jsx("div",{className:"rounded-2xl border border-[#1E293B] overflow-hidden bg-[#0F1420]/80",children:Je.length===0?e.jsxs("div",{className:"py-14 text-center text-xs text-slate-400 space-y-2",children:[e.jsx("span",{className:"material-symbols-outlined text-3xl text-slate-600 block",children:"alt_route"}),e.jsx("p",{className:"font-semibold text-slate-300",children:H[t.id]?`No mappings match "${H[t.id]}"`:`No model mappings configured for ${t.name}`}),e.jsxs("p",{className:"text-slate-500 max-w-md mx-auto text-[11.5px] leading-relaxed",children:["Click ",e.jsx("strong",{className:"text-blue-400",children:"“+ Add Mapping”"})," to add a custom mapping or"," ",e.jsx("strong",{className:"text-slate-300",children:"“Reset to Default”"})," to restore defaults."]})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left border-collapse text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[#1E293B] bg-[#0A0D14] text-slate-400 font-semibold",children:[e.jsx("th",{onClick:()=>Ye("source"),className:"p-3 pl-4 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:A==="source"?de==="asc"?"arrow_upward":"arrow_downward":"unfold_more"})]})}),e.jsx("th",{onClick:()=>Ye("target"),className:"p-3 cursor-pointer hover:text-white select-none transition-colors",title:"Click to sort by Target Destination",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:"Target Destination (Model or Combo)"}),e.jsx("span",{className:"material-symbols-outlined text-[14px] text-blue-400",children:A==="target"?de==="asc"?"arrow_upward":"arrow_downward":"unfold_more"})]})}),e.jsx("th",{className:"p-3 pr-4 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-[#1E293B]",children:Je.map((i,y)=>{const V=pt===t.id&&ne===i.sourceModel,Y=ue(i.sourceModel),ve=!!(Y&&Y!==i.sourceModel),Ce=i.targetModel?ue(i.targetModel):"",Qe=!!(i.targetModel&&(i.targetModel.startsWith("combo/")||Le.has(i.targetModel.toLowerCase()))),me=Qe&&!i.targetModel.startsWith("combo/")?`combo/${i.targetModel}`:i.targetModel,Tt=!!(me&&Ce&&Ce!==me);return e.jsxs("tr",{className:`transition-colors ${V?"bg-blue-500/10":"hover:bg-white/5"}`,children:[e.jsx("td",{className:"p-3 pl-4 font-mono text-slate-200",children:e.jsx("div",{className:"flex items-center gap-2",children:ve?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-slate-100 font-sans font-semibold text-xs leading-snug",children:Y}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"px-2 py-0.5 rounded-lg bg-slate-800/80 border border-slate-700/60 font-mono text-[11px] text-slate-400",children:i.sourceModel}),e.jsx("button",{type:"button",onClick:()=>E(`src-${t.id}-${i.sourceModel}`,i.sourceModel),className:"text-slate-500 hover:text-slate-300 p-0.5 cursor-pointer",title:"Copy source model ID",children:e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:B===`src-${t.id}-${i.sourceModel}`?"done":"content_copy"})})]})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-slate-800/80 border border-slate-700/60 text-slate-100 font-medium",children:i.sourceModel}),e.jsx("button",{type:"button",onClick:()=>E(`src-${t.id}-${i.sourceModel}`,i.sourceModel),className:"text-slate-500 hover:text-slate-300 p-0.5 cursor-pointer",title:"Copy source model ID",children:e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:B===`src-${t.id}-${i.sourceModel}`?"done":"content_copy"})})]})})}),e.jsx("td",{className:"p-3",children:V?e.jsxs("div",{className:"flex items-center gap-2 w-full max-w-md",children:[e.jsx("span",{className:"text-blue-400 font-mono",children:"→"}),e.jsx(Ze,{value:be,onChange:q,onEnter:()=>We(t.id),placeholder:"Search model or combo...",fetchCustomModels:G&&re.length>0?()=>Promise.resolve(re):void 0,className:"bg-[#080B11] border border-blue-500/60 focus:border-blue-400 rounded-xl px-3 py-1.5 text-xs text-white font-mono w-full focus:outline-none",autoFocus:!0})]}):i.targetModel?e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-slate-500 font-mono",children:"→"}),Qe&&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-mono font-medium text-xs",children:Ce||me})]}),Tt&&e.jsx("span",{className:"text-[10.5px] font-mono text-slate-400 pl-4",children:me})]}):e.jsxs("button",{type:"button",onClick:()=>{ae(t.id),oe(i.sourceModel),q("")},className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg border border-dashed border-amber-500/40 bg-amber-500/10 text-amber-300 hover:border-amber-400 hover:text-amber-200 text-xs font-medium transition-colors cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"add"}),"Click to select target model or combo"]})}),e.jsx("td",{className:"p-3 pr-4 text-right space-x-2 whitespace-nowrap",children:V?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>We(t.id),className:"px-2.5 py-1 rounded-lg bg-blue-600 hover:bg-blue-500 text-white font-sans text-xs font-semibold transition-colors cursor-pointer",children:"Save"}),e.jsx("button",{type:"button",onClick:()=>{oe(null),ae(null),q("")},className:"px-2.5 py-1 rounded-lg bg-slate-800 hover:bg-slate-700 text-slate-300 font-sans text-xs transition-colors cursor-pointer",children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>{ae(t.id),oe(i.sourceModel),q(i.targetModel||"")},className:"p-1 rounded-lg text-slate-400 hover:text-blue-400 hover:bg-blue-500/10 transition-colors cursor-pointer",title:"Edit target model",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"edit"})}),e.jsx("button",{type:"button",onClick:()=>Mt(t.id,i.sourceModel),className:"p-1 rounded-lg text-slate-400 hover:text-red-400 hover:bg-red-500/10 transition-colors cursor-pointer",title:"Delete mapping",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"delete"})})]})})]},y)})})]})})})]})]})]},t.id)})}),e.jsx(Xe,{isOpen:!!_,onClose:()=>F(null),maxWidthClass:"max-w-xl",children:_&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-[#1E293B]",children:[e.jsxs("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 (",_.toUpperCase(),")"]}),e.jsx("button",{onClick:()=>F(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(Pt,{toolId:_,value:fe,onChange:ye,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(Ze,{value:je,onChange:Ne,placeholder:"Search model or type ID...",fetchCustomModels:G&&re.length>0?()=>Promise.resolve(re):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:()=>F(null),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",children:"Cancel"}),e.jsx("button",{onClick:kt,className:"rt-btn rt-btn--primary text-xs py-1.5 px-4",children:"Add Mapping"})]})]})}),e.jsx(Xe,{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:()=>ce(!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:()=>E("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:B==="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:()=>E("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:B==="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:()=>ce(!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:P,onClick:()=>ce(!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:P?"hourglass_empty":"power_settings_new"}),P?"Terminating...":"Kill & Start"]})]})]})]})})()})]})};export{zt as MitmTab};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as l,j as e,R as ce}from"./vendor-BcOI2aZ9.js";import{u as Te,a as ge,b as Le,D as _e,c as ze,S as Oe,v as We,s as Ge,K as Ke,P as Fe,d as Qe,C as Ve}from"./dnd-kit-DecqzwfZ.js";import{P as Ye}from"./index-BvY11iVv.js";import{o as Ue,g as H,m as qe,a as ve,C as xe,b as Ze}from"./ModelAutocompleteInput-BH4gr6Dr.js";import{T as He}from"./ToolIcon-BZE0Fv7L.js";import{S as Je}from"./Select-BNRH8LIG.js";import{P as de}from"./metadataRegistry-4BIaQVmV.js";const Xe={},X=[],_=50;function et(n){return!n||n<=0?null:n>=1e6?`${(n/1e6).toFixed(n%1e6===0?0:1)}M ctx`:n>=1e3?`${Math.round(n/1e3)}K ctx`:`${n} ctx`}function J(n,x,h,v,y,C,A,j="llm",p=!1){const M=`${h} ${n} ${x} ${y} ${v}`.toLowerCase(),g=M.replace(/[-_./]/g," ");return{id:n,value:x,name:h,providerId:v,providerName:y,caps:C,contextLength:A,kind:j,isCustom:p,searchTarget:M,normalizedSearchTarget:g}}const ye=ce.memo(({id:n,index:x,onRemove:h,onMoveUp:v,onMoveDown:y,isFirst:C,isLast:A})=>{const{attributes:j,listeners:p,setNodeRef:M,transform:g,transition:z,isDragging:E}=Qe({id:n}),F={transform:Ve.Transform.toString(g),transition:z,zIndex:E?50:void 0,opacity:E?.6:1};return e.jsxs("div",{ref:M,style:F,className:`flex items-center justify-between gap-2 px-3 py-2 rounded-xl border bg-[#0A0D14] transition-all ${E?"border-blue-500 shadow-lg shadow-blue-500/10 bg-blue-950/40":"border-[#1E293B] hover:border-slate-700"}`,children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0 flex-1",children:[e.jsx("button",{type:"button",...j,...p,className:"cursor-grab active:cursor-grabbing text-slate-500 hover:text-slate-300 p-0.5 rounded touch-none shrink-0",title:"Drag to reorder priority",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"drag_indicator"})}),e.jsx("span",{className:"size-5 rounded-md bg-[#141B2D] border border-[#1E293B] text-[10px] font-mono text-blue-400 font-bold flex items-center justify-center shrink-0",children:x+1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"font-mono text-xs text-white truncate block",title:n,children:n}),e.jsx(xe,{model:n,size:"xs",className:"mt-1"})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{type:"button",onClick:v,disabled:C,className:"p-1 text-slate-400 hover:text-white disabled:opacity-20 disabled:hover:text-slate-400 cursor-pointer",title:"Move up",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"arrow_upward"})}),e.jsx("button",{type:"button",onClick:y,disabled:A,className:"p-1 text-slate-400 hover:text-white disabled:opacity-20 disabled:hover:text-slate-400 cursor-pointer",title:"Move down",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"arrow_downward"})}),e.jsx("button",{type:"button",onClick:h,className:"p-1 text-slate-400 hover:text-rose-400 cursor-pointer",title:"Remove",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"close"})})]})]})});ye.displayName="SortableModelItem";const je=ce.memo(({item:n,isSelected:x,onToggle:h})=>{const v=et(n.contextLength);return e.jsxs("div",{onClick:()=>h(n),className:`flex items-center justify-between p-2.5 rounded-xl border transition-colors cursor-pointer ${x?"bg-blue-600/10 border-blue-500/40 text-white":"bg-[#0A0D14] border-[#1E293B] hover:border-slate-700 text-slate-300"}`,children:[e.jsxs("div",{className:"min-w-0 pr-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-semibold text-white truncate",children:n.name}),v&&e.jsx("span",{className:"text-[9.5px] font-mono px-1 py-0.2 rounded bg-slate-800 text-slate-400 border border-slate-700/60 leading-tight",children:v})]}),e.jsx("div",{className:"font-mono text-[11px] text-slate-400 truncate mt-0.5",children:n.value}),e.jsx("div",{className:"mt-1",children:e.jsx(xe,{caps:n.caps,size:"xs"})})]}),e.jsx("button",{type:"button",onClick:y=>{y.stopPropagation(),h(n)},className:`size-7 rounded-lg flex items-center justify-center shrink-0 border transition-colors ${x?"bg-blue-600 border-blue-500 text-white":"bg-[#141B2D] border-[#1E293B] text-slate-400 hover:text-white hover:border-slate-600"}`,children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:x?"check":"add"})})]})});je.displayName="ModelOptionRow";const Ne=ce.memo(({group:n,isExpanded:x,visibleModelCount:h,selectedSet:v,selectedModel:y,onToggleGroup:C,onToggleModel:A,onShowMore:j,onShowAll:p})=>{const M=x?n.models.slice(0,h):X;return e.jsxs("div",{className:"rounded-xl border border-[#1E293B] bg-[#0A0D14]/70 overflow-hidden transition-colors",children:[e.jsxs("div",{onClick:()=>C(n.providerId),className:`flex items-center justify-between p-2.5 cursor-pointer select-none transition-colors ${x?"bg-[#141B2D]/80 hover:bg-[#141B2D] border-b border-[#1E293B]":"hover:bg-white/[0.03]"}`,children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx(He,{src:n.image,name:n.providerName,color:n.color,iconBg:n.iconBg,size:"sm"}),e.jsxs("div",{className:"min-w-0 flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-bold text-white truncate",children:n.providerName}),e.jsxs("span",{className:"text-[10px] font-mono px-1.5 py-0.2 rounded bg-slate-800/80 text-slate-400 border border-slate-700/60 shrink-0",children:[n.models.length," model",n.models.length>1?"s":""]}),n.selectedCount>0&&e.jsxs("span",{className:"text-[10px] font-mono px-1.5 py-0.2 rounded bg-blue-500/20 text-blue-300 border border-blue-500/40 font-semibold shrink-0",children:[n.selectedCount," selected"]})]})]}),e.jsx("span",{className:`material-symbols-outlined text-[18px] text-slate-400 transition-transform duration-200 shrink-0 ${x?"rotate-180 text-blue-400":""}`,children:"expand_more"})]}),x&&e.jsxs("div",{className:"p-2 space-y-1.5 bg-[#080B12]/60",children:[M.map(g=>{const z=v.has(g.value)||y===g.value;return e.jsx(je,{item:g,isSelected:z,onToggle:A},g.value)}),n.models.length>h&&e.jsxs("div",{className:"pt-2 pb-1 text-center flex items-center justify-center gap-2",children:[e.jsxs("button",{type:"button",onClick:g=>{g.stopPropagation(),j()},className:"px-3 py-1.5 rounded-lg bg-blue-600/10 border border-blue-500/30 text-blue-400 hover:bg-blue-600/20 text-xs font-medium cursor-pointer transition-colors",children:["Show 50 more (",n.models.length-h," remaining)"]}),n.models.length-h>50&&e.jsxs("button",{type:"button",onClick:g=>{g.stopPropagation(),p()},className:"px-3 py-1.5 rounded-lg bg-[#141B2D] border border-[#1E293B] text-slate-400 hover:text-white text-xs font-medium cursor-pointer transition-colors",children:["Show all (",n.models.length,")"]})]})]})]})});Ne.displayName="ProviderAccordionItem";const it=({isOpen:n,onClose:x,title:h="Select & Reorder Models",initialSelectedModels:v=X,onConfirm:y,multiSelect:C=!0,filterModality:A=null,onSelect:j,onDeselect:p,selectedModel:M,activeProviders:g=X,modelAliases:z=Xe,kindFilter:E=null,capFilter:F=null,addedModelValues:me,closeOnSelect:U=!1,excludeModelIds:ue=X,allowCombos:P=!0})=>{const[N,b]=l.useState([]),[ee,te]=l.useState(""),$=l.useDeferredValue(ee),[f,se]=l.useState("all"),[w,Q]=l.useState(F||A||"all"),[re,oe]=l.useState(""),[O,pe]=l.useState([]),[q,Ce]=l.useState([]),[k,ne]=l.useState(!0),[he,W]=l.useState(null),[we,R]=l.useState(_),be=l.useRef(null),ke=Te(ge(Fe,{activationConstraint:{distance:4}}),ge(Ke,{coordinateGetter:Ge}));l.useEffect(()=>{if(n){b([...me||v||[]]),te(""),se("all"),Q(F||A||"all"),oe(""),W(null),R(_);const s=setTimeout(()=>{var o;(o=be.current)==null||o.focus()},50);return()=>clearTimeout(s)}},[n,v,me,A,F]),l.useEffect(()=>{if(!n)return;let t=!1;return fetch("/api/combos").then(s=>s.ok?s.json():[]).then(s=>{if(!t){const o=Array.isArray(s)?s:s.combos||[];pe(o)}}).catch(()=>{t||pe([])}),()=>{t=!0}},[n]),l.useEffect(()=>{if(!n)return;let t=!1;const s=(r=!1)=>{Ze().then(a=>{if(!t&&(Ce(a),r)){const d=a.some(i=>i.hasConnectedAccount);ne(P===!1?!1:d)}}).catch(()=>{})};s(!0);const o=Ue(()=>{t||s(!1)});return()=>{t=!0,o()}},[n,P]);const B=l.useMemo(()=>{const t=new Set;for(const s of q)s.hasConnectedAccount&&t.add(s.providerId);return t},[q]),G=l.useMemo(()=>B.size>0,[B]),I=l.useMemo(()=>new Set(N),[N]),K=l.useMemo(()=>{var r,a,d,m;const t=[],s=new Set,o=new Set;for(const i of q){if(i.isCombo||s.has(i.value))continue;s.add(i.value),o.add(i.providerId);const c=H(i.providerId,i.id);t.push(J(i.id,i.value,i.name||i.id,i.providerId,i.providerName||i.providerId,{...c,vision:!!((r=i.caps)!=null&&r.vision||c.vision),reasoning:!!((a=i.caps)!=null&&a.reasoning||c.reasoning),audioInput:!!((d=i.caps)!=null&&d.audio||c.audioInput),audioOutput:!!((m=i.caps)!=null&&m.audio||c.audioOutput)},i.contextLength||c.contextWindow,"llm",!1))}for(const[i,c]of Object.entries(de)){if(!c||!c.models)continue;const D=c.alias||c.id||i;if(!(o.has(i)||o.has(D)||c.aliases&&c.aliases.some(u=>o.has(u))))for(const u of c.models){const L=u.id.startsWith(`${D}/`)||u.id.startsWith(`${i}/`)||c.uiAlias&&u.id.startsWith(`${c.uiAlias}/`)?u.id:`${D}/${u.id}`;if(s.has(L))continue;s.add(L);const ie=H(i,u.id);t.push(J(u.id,L,u.name||u.id,i,c.name||i,ie,u.contextLength,u.kind||"llm",!1))}}for(const[i,c]of Object.entries(z))if(!s.has(c)){s.add(c);const D=c.indexOf("/"),Y=D===-1?"custom":c.slice(0,D),u=D===-1?c:c.slice(D+1),L=de[Y],ie=H(Y,u);t.push(J(u,c,i,Y,(L==null?void 0:L.name)||Y,ie,void 0,"llm",!0))}return t},[q,z]),T=l.useMemo(()=>new Set((ue||[]).map(t=>t.toLowerCase())),[ue]),ae=l.useMemo(()=>$.toLowerCase().trim().split(/\s+/).filter(Boolean),[$]),fe=l.useMemo(()=>{const t=new Map,s=P!==!1&&O.length>0;for(const a of K)k&&G&&!B.has(a.providerId)||t.has(a.providerId)||t.set(a.providerId,a.providerName);const o=new Intl.Collator(void 0,{sensitivity:"base"}),r=Array.from(t.entries()).map(([a,d])=>({id:a,name:d})).sort((a,d)=>o.compare(a.name,d.name));return s?[{id:"combo",name:"Combos"},...r]:r},[K,k,G,B,P,O]),V=l.useMemo(()=>{if(P===!1)return[];if(w!=="all"||E)return[];const t=$.trim().toLowerCase(),o=[...O.filter(r=>!T.has(r.id.toLowerCase())&&!T.has(r.name.toLowerCase())&&!T.has(`combo/${r.name}`.toLowerCase()))].sort((r,a)=>r.name.localeCompare(a.name,void 0,{sensitivity:"base"}));return t?o.filter(r=>{const a=`${r.name} ${r.id} ${r.strategy||""} ${r.models.join(" ")}`;return qe(a,t)}):o},[O,$,w,E,P,T]),Z=l.useMemo(()=>f==="combo"?[]:K.filter(t=>!(t.providerId==="combo"&&T.has(t.id.toLowerCase())||T.has(t.value.toLowerCase())||k&&G&&!B.has(t.providerId)||E&&t.kind&&t.kind!==E||f!=="all"&&t.providerId!==f||w==="vision"&&!t.caps.vision||w==="pdf"&&!t.caps.pdf||w==="audio"&&!t.caps.audioInput&&!t.caps.audio||w==="thinking"&&!t.caps.reasoning&&!t.caps.thinking&&!t.caps.thinkingFormat||ae.length>0&&!ae.every(o=>t.searchTarget.includes(o)||t.normalizedSearchTarget.includes(o)))),[K,f,w,E,ae,k,G,B,T]),S=l.useMemo(()=>{const t=new Map;for(const r of Z){const a=r.providerId;let d=t.get(a);if(!d){const m=de[a];d={providerId:a,providerName:r.providerName||(m==null?void 0:m.name)||a,color:m==null?void 0:m.color,iconBg:m==null?void 0:m.iconBg,image:m==null?void 0:m.image,models:[],selectedCount:0},t.set(a,d)}d.models.push(r),(I.has(r.value)||M===r.value)&&d.selectedCount++}const s=new Intl.Collator(void 0,{sensitivity:"base"});return Array.from(t.values()).map(r=>({...r,models:[...r.models].sort((a,d)=>s.compare(a.name||a.id,d.name||d.id))})).sort((r,a)=>{if(r.selectedCount>0&&a.selectedCount===0)return-1;if(a.selectedCount>0&&r.selectedCount===0)return 1;const d=B.has(r.providerId)?1:0,m=B.has(a.providerId)?1:0;return d!==m?m-d:s.compare(r.providerName,a.providerName)})},[Z,I,M,B]);l.useEffect(()=>{$.trim()?(W(t=>{var s;return t&&S.some(o=>o.providerId===t)?t:((s=S[0])==null?void 0:s.providerId)||null}),R(_)):f!=="all"&&(W(f),R(_))},[$,f,S]),l.useEffect(()=>{n&&!$.trim()&&f==="all"&&S.length>0&&(W(t=>{var o;if(t&&S.some(r=>r.providerId===t))return t;const s=S.find(r=>r.selectedCount>0);return s?s.providerId:((o=S[0])==null?void 0:o.providerId)||null}),R(_))},[n,S,$,f]);const Se=l.useCallback(t=>{W(s=>s===t?null:t),R(_)},[]),Me=l.useCallback(()=>{W(null)},[]),Be=l.useCallback(()=>{R(t=>t+_)},[]),Ie=l.useCallback(t=>{const s=t.value;I.has(s)?(p&&p(t),b(r=>r.filter(a=>a!==s))):(j&&j(t),b(C?r=>[...r,s]:[s])),U&&x()},[I,p,j,C,U,x]),le=l.useCallback(t=>{const s=t.name,o=I.has(s),r=ve(t.models),a=J(t.name,t.name,t.name,"combo","Combos",r||H(null,t.name),void 0,"combo",!1);o?(p&&p(a),b(d=>d.filter(m=>m!==s))):(j&&j(a),b(C?d=>[...d,s]:[s])),U&&x()},[I,p,j,C,U,x]),Ae=l.useCallback(t=>{b(o=>o.filter(r=>r!==t));const s=K.find(o=>o.value===t);s&&p&&p(s)},[K,p]),Ee=l.useCallback(t=>{t!==0&&b(s=>{const o=[...s],r=o[t-1];return o[t-1]=o[t],o[t]=r,o})},[]),$e=l.useCallback(t=>{b(s=>{if(t===s.length-1)return s;const o=[...s],r=o[t+1];return o[t+1]=o[t],o[t]=r,o})},[]),De=l.useCallback(t=>{const{active:s,over:o}=t;o&&s.id!==o.id&&b(r=>{const a=r.indexOf(String(s.id)),d=r.indexOf(String(o.id));return a!==-1&&d!==-1?Le(r,a,d):r})},[]),Pe=t=>{t.preventDefault();const s=re.trim();s&&(I.has(s)||b(C?o=>[...o,s]:[s]),oe(""))},Re=()=>{y&&y(N),x()};return e.jsx(Ye,{isOpen:n,onClose:x,maxWidthClass:"w-full max-w-[72rem]",children:e.jsxs("div",{className:"flex flex-col h-[85vh] max-h-[780px] -m-2 sm:-m-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 sm:p-5 border-b border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-9 rounded-xl bg-blue-500/10 border border-blue-500/20 text-blue-400 flex items-center justify-center shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"tune"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm sm:text-base font-bold text-white",children:h}),e.jsx("p",{className:"text-xs text-slate-400",children:"Pick models and drag & drop in the right panel to set priority order"})]})]}),e.jsx("button",{type:"button",onClick:x,className:"p-1.5 rounded-lg text-slate-400 hover:text-white hover:bg-white/10 cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 flex-1 min-h-0 overflow-hidden divide-y lg:divide-y-0 lg:divide-x divide-[#1E293B]",children:[e.jsxs("div",{className:"lg:col-span-7 flex flex-col min-h-0 p-4 space-y-3.5 overflow-hidden",children:[e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-[18px] text-slate-500",children:"search"}),e.jsx("input",{ref:be,type:"text",placeholder:"Search models by name, provider, or ID...",value:ee,onChange:t=>te(t.target.value),className:"w-full bg-[#0A0D14] border border-[#1E293B] rounded-xl pl-9 pr-8 py-2 text-xs text-white placeholder-slate-500 focus:outline-none focus:border-blue-500 font-mono"}),ee&&e.jsx("button",{type:"button",onClick:()=>te(""),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-500 hover:text-white cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Je,{value:f,onChange:se,options:[{value:"all",label:`All Providers (${fe.length})`},...fe.map(t=>({value:t.id,label:t.name}))],className:"shrink-0 min-w-[150px]"}),P!==!1&&O.length>0&&e.jsxs("button",{type:"button",onClick:()=>se(f==="combo"?"all":"combo"),className:`px-2.5 py-1 rounded-lg text-[11px] font-medium border transition-colors cursor-pointer flex items-center gap-1.5 ${f==="combo"?"bg-cyan-500/20 text-cyan-300 border-cyan-500/40":"bg-[#0A0D14] text-slate-400 border-[#1E293B] hover:text-cyan-300"}`,title:"Filter by Smart Combos",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"layers"}),"Combos",e.jsx("span",{className:"text-[9.5px] px-1 rounded bg-cyan-500/30 text-cyan-300 font-mono",children:O.length})]}),e.jsxs("button",{type:"button",onClick:()=>ne(!k),className:`px-2.5 py-1 rounded-lg text-[11px] font-medium border transition-colors cursor-pointer flex items-center gap-1.5 ${k?"bg-emerald-500/20 text-emerald-300 border-emerald-500/40":"bg-[#0A0D14] text-slate-400 border-[#1E293B] hover:text-white"}`,title:k?"Showing only models from connected accounts. Click to show all models.":"Showing all catalog models. Click to filter by connected accounts.",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:k?"check_circle":"tune"}),"Connected Only",G&&e.jsx("span",{className:"text-[9.5px] px-1 rounded bg-emerald-500/30 text-emerald-300 font-mono",children:B.size})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>Q("all"),className:`px-2 py-1 rounded-lg text-[11px] font-medium border transition-colors cursor-pointer ${w==="all"?"bg-blue-600 text-white border-blue-500":"bg-[#0A0D14] text-slate-400 border-[#1E293B] hover:text-white"}`,children:"All"}),e.jsxs("button",{type:"button",onClick:()=>Q("vision"),className:`px-2 py-1 rounded-lg text-[11px] font-medium border transition-colors cursor-pointer flex items-center gap-1 ${w==="vision"?"bg-cyan-500/20 text-cyan-300 border-cyan-500/40":"bg-[#0A0D14] text-slate-400 border-[#1E293B] hover:text-cyan-300"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"visibility"}),"Vision"]}),e.jsxs("button",{type:"button",onClick:()=>Q("audio"),className:`px-2 py-1 rounded-lg text-[11px] font-medium border transition-colors cursor-pointer flex items-center gap-1 ${w==="audio"?"bg-purple-500/20 text-purple-300 border-purple-500/40":"bg-[#0A0D14] text-slate-400 border-[#1E293B] hover:text-purple-300"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"graphic_eq"}),"Audio"]}),e.jsxs("button",{type:"button",onClick:()=>Q("thinking"),className:`px-2 py-1 rounded-lg text-[11px] font-medium border transition-colors cursor-pointer flex items-center gap-1 ${w==="thinking"?"bg-emerald-500/20 text-emerald-300 border-emerald-500/40":"bg-[#0A0D14] text-slate-400 border-[#1E293B] hover:text-emerald-300"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"psychology"}),"Reasoning"]})]})]}),f!=="combo"&&V.length>0&&e.jsxs("div",{className:"p-2.5 rounded-xl border border-cyan-500/20 bg-cyan-950/20 space-y-1.5 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-cyan-400 font-semibold",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"layers"}),e.jsxs("span",{children:["Smart Combos (",V.length,")"]})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:V.map(t=>{const s=I.has(t.name);return e.jsxs("button",{type:"button",onClick:()=>le(t),className:`inline-flex items-center gap-1 px-2 py-1 rounded-lg text-xs font-mono font-medium border transition-colors cursor-pointer ${s?"bg-cyan-600 text-white border-cyan-500":"bg-[#0A0D14] text-slate-300 border-[#1E293B] hover:border-cyan-500/40 hover:text-white"}`,children:[s&&e.jsx("span",{className:"material-symbols-outlined text-[12px] text-cyan-200",children:"check"}),e.jsx("span",{children:t.name}),e.jsxs("span",{className:"text-[10px] opacity-60",children:["(",t.models.length,")"]})]},t.id)})})]}),f==="combo"?e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto pr-1",children:V.length===0?e.jsxs("div",{className:"py-10 text-center text-slate-500 text-xs space-y-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[26px] text-slate-600 block mx-auto",children:"layers_clear"}),e.jsx("p",{className:"max-w-xs mx-auto",children:"No combos found matching your search or filters."})]}):e.jsx("div",{className:"space-y-2",children:V.map(t=>{const s=I.has(t.name),o=ve(t.models);return e.jsxs("div",{onClick:()=>le(t),className:`flex items-center justify-between p-3 rounded-xl border transition-colors cursor-pointer ${s?"bg-cyan-950/30 border-cyan-500/50 text-white":"bg-[#0A0D14]/70 border-[#1E293B] hover:border-slate-700 text-slate-300"}`,children:[e.jsxs("div",{className:"min-w-0 pr-2 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.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"}),e.jsx("span",{className:"text-xs font-semibold text-white truncate",children:t.name}),t.strategy&&e.jsx("span",{className:`px-1.5 py-0.2 rounded font-sans text-[9px] font-medium border ${t.strategy==="round-robin"?"bg-cyan-950/40 text-cyan-300 border-cyan-500/30":t.strategy==="fusion"?"bg-purple-950/40 text-purple-300 border-purple-500/30":t.strategy==="lkgp"?"bg-emerald-950/40 text-emerald-300 border-emerald-500/30":t.strategy==="p2c"?"bg-indigo-950/40 text-indigo-300 border-indigo-500/30":"bg-amber-950/40 text-amber-300 border-amber-500/30"}`,children:t.strategy==="round-robin"?"Round Robin":t.strategy==="fusion"?"Fusion":t.strategy==="lkgp"?"LKGP":t.strategy==="p2c"?"P2C":"Fallback"})]}),e.jsxs("div",{className:"font-mono text-[11px] text-slate-400 truncate",children:[e.jsxs("span",{className:"text-cyan-400 font-semibold",children:[t.models.length," model",t.models.length>1?"s":"",":"]})," ",e.jsx("span",{className:"text-slate-300",children:t.models.join(", ")})]}),o&&e.jsx("div",{className:"pt-0.5",children:e.jsx(xe,{caps:o,size:"xs"})})]}),e.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),le(t)},className:`size-7 rounded-lg flex items-center justify-center shrink-0 border transition-colors ${s?"bg-cyan-600 border-cyan-500 text-white":"bg-[#141B2D] border-[#1E293B] text-slate-400 hover:text-white hover:border-slate-600"}`,children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:s?"check":"add"})})]},t.id)})})}):Z.length===0?e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto pr-1",children:e.jsxs("div",{className:"py-10 text-center text-slate-500 text-xs space-y-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[26px] text-slate-600 block mx-auto",children:"search_off"}),e.jsx("p",{className:"max-w-xs mx-auto",children:k&&!G?"No accounts connected yet. All models are currently hidden by 'Connected Only'.":k?"No models found from connected accounts matching your search/filters.":"No models matched your filter. Try clearing filters or enter a custom model below."}),k&&e.jsx("button",{type:"button",onClick:()=>ne(!1),className:"px-3 py-1 rounded-lg bg-blue-600/10 border border-blue-500/30 text-blue-400 hover:bg-blue-600/20 text-xs font-medium cursor-pointer transition-colors",children:"Show All Registry Models"})]})}):e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400 px-1 shrink-0",children:[e.jsxs("span",{className:"font-medium text-slate-300",children:[S.length," provider",S.length>1?"s":""," •"," ",Z.length," models"]}),e.jsx("div",{className:"flex items-center gap-2",children:he&&e.jsx("button",{type:"button",onClick:Me,className:"text-[11px] text-slate-400 hover:text-slate-300 font-medium cursor-pointer hover:underline",children:"Collapse"})})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto space-y-2 pr-1",children:S.map(t=>{const s=he===t.providerId;return e.jsx(Ne,{group:t,isExpanded:s,visibleModelCount:we,selectedSet:I,selectedModel:M,onToggleGroup:Se,onToggleModel:Ie,onShowMore:Be,onShowAll:()=>R(t.models.length)},t.providerId)})})]}),e.jsxs("form",{onSubmit:Pe,className:"flex gap-2 pt-1 border-t border-[#1E293B]",children:[e.jsx("input",{type:"text",placeholder:"Or enter custom model ID (e.g. provider/model)...",value:re,onChange:t=>oe(t.target.value),className:"flex-1 bg-[#0A0D14] border border-[#1E293B] rounded-xl px-3 py-1.5 text-xs text-white font-mono placeholder-slate-500 focus:outline-none focus:border-blue-500"}),e.jsx("button",{type:"submit",disabled:!re.trim(),className:"px-3 py-1.5 rounded-xl bg-[#141B2D] border border-[#1E293B] hover:border-blue-500/50 hover:bg-blue-600/10 text-xs text-slate-300 hover:text-white disabled:opacity-40 cursor-pointer",children:"Add Custom"})]})]}),e.jsxs("div",{className:"lg:col-span-5 flex flex-col min-h-0 p-4 space-y-3 bg-[#0A0D14]/40",children:[e.jsxs("div",{className:"flex items-center justify-between pb-2 border-b border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-blue-400 text-[18px]",children:"format_list_numbered"}),e.jsxs("span",{className:"text-xs font-bold text-white",children:["Selected Models (",N.length,")"]})]}),N.length>0&&e.jsx("button",{type:"button",onClick:()=>b([]),className:"text-[11px] text-slate-500 hover:text-rose-400 transition-colors cursor-pointer",children:"Clear all"})]}),e.jsx("p",{className:"text-[11px] text-slate-400 leading-normal",children:"Order determines execution priority (1 = primary, 2+ = backup fallbacks). Drag handles to reorder."}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto space-y-2 pr-1",children:N.length===0?e.jsx("div",{className:"py-16 text-center text-slate-500 text-xs border border-dashed border-[#1E293B] rounded-2xl p-4",children:"No models selected yet. Click any model on the left to add it to this priority list."}):e.jsx(_e,{sensors:ke,collisionDetection:ze,onDragEnd:De,children:e.jsx(Oe,{items:N,strategy:We,children:e.jsx("div",{className:"space-y-1.5",children:N.map((t,s)=>e.jsx(ye,{id:t,index:s,onRemove:()=>Ae(t),onMoveUp:()=>Ee(s),onMoveDown:()=>$e(s),isFirst:s===0,isLast:s===N.length-1},t))})})})})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 sm:p-5 border-t border-[#1E293B] bg-[#0A0D14]/60",children:[e.jsx("div",{className:"text-xs text-slate-400",children:N.length===0?e.jsx("span",{children:"No models selected"}):e.jsxs("span",{children:[e.jsx("strong",{className:"text-white font-mono",children:N.length})," model",N.length>1?"s":""," in priority order"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:x,className:"px-4 py-2 rounded-xl text-xs font-medium text-slate-400 hover:text-white bg-[#141B2D] border border-[#1E293B] hover:border-slate-700 transition-colors cursor-pointer",children:"Cancel"}),e.jsx("button",{type:"button",onClick:Re,className:"px-5 py-2 rounded-xl text-xs font-semibold text-white bg-blue-600 hover:bg-blue-500 shadow-md shadow-blue-600/20 transition-all cursor-pointer",children:y?"Confirm Selection":"Done"})]})]})]})})};export{it as M};
|