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.
- package/README.md +1 -1
- package/dist/cli/tools/definitions/amp/definition.js +1 -1
- package/dist/cli/tools/definitions/claude/configurator.js +1 -1
- package/dist/cli/tools/definitions/claude/definition.js +5 -2
- package/dist/cli/tools/definitions/cline/definition.js +1 -1
- package/dist/cli/tools/definitions/codewhale/definition.js +1 -1
- package/dist/cli/tools/definitions/codex/definition.js +1 -1
- package/dist/cli/tools/definitions/continue/definition.js +1 -1
- package/dist/cli/tools/definitions/copilot/definition.js +1 -1
- package/dist/cli/tools/definitions/cowork/definition.js +1 -1
- package/dist/cli/tools/definitions/crush/definition.js +1 -1
- package/dist/cli/tools/definitions/deepseek-tui/definition.js +1 -1
- package/dist/cli/tools/definitions/droid/definition.js +1 -1
- package/dist/cli/tools/definitions/forge/definition.js +1 -1
- package/dist/cli/tools/definitions/grok-build/definition.js +1 -1
- package/dist/cli/tools/definitions/hermes/definition.js +1 -1
- package/dist/cli/tools/definitions/jcode/definition.js +1 -1
- package/dist/cli/tools/definitions/kilo/definition.js +1 -1
- package/dist/cli/tools/definitions/omp/definition.js +1 -1
- package/dist/cli/tools/definitions/openclaw/definition.js +1 -1
- package/dist/cli/tools/definitions/opencode/definition.js +1 -1
- package/dist/cli/tools/definitions/pi/definition.js +1 -1
- package/dist/cli/tools/definitions/qwen/definition.js +1 -1
- package/dist/cli/tools/definitions/roo/definition.js +1 -1
- package/dist/cli/tools/definitions/smelt/definition.js +1 -1
- package/dist/core/adapters/anthropic/requestAnthropicToOpenAi.js +3 -3
- package/dist/core/adapters/anthropic/requestOpenAiToAnthropic.js +2 -2
- package/dist/core/adapters/anthropic/responseConverters.js +3 -3
- package/dist/core/adapters/anthropic/streamOpenAiToAnthropic.js +29 -29
- package/dist/core/adapters/anthropic/types.js +1 -1
- package/dist/core/adapters/anthropicAdapter.js +1 -1
- package/dist/core/adapters/helpers/index.js +1 -1
- package/dist/core/adapters/helpers/streamToolCallTracker.js +1 -0
- package/dist/core/adapters/helpers/toolCallRescue.js +1 -1
- package/dist/core/adapters/helpers/toolSchemaNormalize.js +1 -1
- package/dist/core/adapters/helpers/zeroContentCheck.js +1 -1
- package/dist/core/adapters/responsesAdapter.js +2 -2
- package/dist/core/caching/promptCacheAffinity.js +3 -3
- package/dist/core/capabilities/index.js +1 -1
- package/dist/core/capabilities/patterns.js +1 -1
- package/dist/mitm/handlers/base.js +2 -2
- package/dist/providers/catalog/cerebras/metadata.js +1 -1
- package/dist/providers/catalog/coarena/metadata.js +1 -1
- package/dist/providers/catalog/groq/metadata.js +1 -1
- package/dist/providers/catalog/iteracompute/metadata.js +1 -1
- package/dist/providers/catalog/jan/metadata.js +1 -1
- package/dist/providers/catalog/kilo-gateway/metadata.js +1 -1
- package/dist/providers/catalog/lm-studio/metadata.js +1 -1
- package/dist/providers/catalog/mistral/metadata.js +1 -1
- package/dist/providers/catalog/nvidia/metadata.js +1 -1
- package/dist/providers/catalog/ollama-local/metadata.js +1 -1
- package/dist/providers/catalog/onomeo/metadata.js +1 -1
- package/dist/providers/catalog/opencode-go/responses.js +5 -5
- package/dist/providers/catalog/opencode-zen/metadata.js +1 -1
- package/dist/providers/catalog/openrouter/metadata.js +1 -1
- package/dist/providers/catalog/sail/metadata.js +1 -1
- package/dist/providers/catalog/sambanova/metadata.js +1 -1
- package/dist/providers/runtime/antigravity/executor.js +8 -8
- package/dist/providers/runtime/antigravity/metadata.js +1 -1
- package/dist/providers/runtime/antigravity/provider.js +1 -1
- package/dist/providers/runtime/antigravity/quota.js +1 -1
- package/dist/providers/runtime/antigravity/routes.js +1 -1
- package/dist/providers/runtime/antigravity/types.js +1 -1
- package/dist/providers/runtime/antigravity/weekly.js +1 -1
- package/dist/providers/runtime/cloudflare/metadata.js +1 -1
- package/dist/providers/runtime/gemini/metadata.js +1 -1
- package/dist/providers/runtime/gemini/provider.js +1 -1
- package/dist/providers/runtime/gemini-cli/provider.js +1 -1
- package/dist/providers/runtime/gemini-cli/quota.js +1 -1
- package/dist/providers/runtime/gemini-cli/routes.js +1 -1
- package/dist/providers/runtime/kiro/constants.js +1 -0
- package/dist/providers/runtime/kiro/createResponseStream.js +4 -4
- package/dist/providers/runtime/kiro/executor.js +6 -6
- package/dist/providers/runtime/kiro/index.js +1 -1
- package/dist/providers/runtime/kiro/metadata.js +1 -1
- package/dist/providers/runtime/kiro/provider.js +1 -1
- package/dist/providers/runtime/kiro/quota.js +1 -1
- package/dist/providers/runtime/ollama/metadata.js +1 -1
- package/dist/providers/runtime/opencode/metadata.js +1 -1
- package/dist/server/index.js +3 -3
- package/dist/server/middlewares/doubledV1Middleware.js +1 -0
- package/dist/server/proxy/executorHelpers.js +1 -1
- package/dist/server/proxy/pipeline.js +5 -5
- package/dist/server/proxy/responseHandlers.js +1 -1
- package/dist/server/proxy/routeSimulator.js +1 -0
- package/dist/server/proxy/singleModelExecutor.js +5 -5
- package/dist/server/proxy/streaming/sseStreamer.js +18 -18
- package/dist/server/routes/apiCliTools.js +1 -1
- package/dist/server/routes/apiModels.js +1 -1
- package/dist/storage/repositories/settingsRepo.js +2 -2
- package/dist/storage/repositories/toolMappingRepo.js +5 -4
- package/dist/web/assets/CliToolsTab-AP4tHWEj.js +171 -0
- package/dist/web/assets/ComboDetailPage-8ZPxPl5N.js +1 -0
- package/dist/web/assets/CombosTab-D0T91znw.js +1 -0
- package/dist/web/assets/{ConfirmModal-Co5OXd_g.js → ConfirmModal-gmHKbGNe.js} +1 -1
- package/dist/web/assets/{ConsoleLogTab-BTGaJpcD.js → ConsoleLogTab-Bpvxqa2f.js} +1 -1
- package/dist/web/assets/{EditAccountModal-DLyP9VNQ.js → EditAccountModal-PEltZRS8.js} +1 -1
- package/dist/web/assets/{EndpointTab-DbjjVT7s.js → EndpointTab-CYnFpxjA.js} +1 -1
- package/dist/web/assets/MitmTab-De7zsN2f.js +14 -0
- package/dist/web/assets/ModelAutocompleteInput-BH4gr6Dr.js +1 -0
- package/dist/web/assets/ModelSelectModal-B7-jAYUU.js +1 -0
- package/dist/web/assets/{ProviderDetailPage-CeOUazix.js → ProviderDetailPage-DvqxjQHh.js} +1 -1
- package/dist/web/assets/{ProvidersTab-Dd-prffr.js → ProvidersTab-DyeFqcx4.js} +1 -1
- package/dist/web/assets/{QuotaTab-zPkj0Rwo.js → QuotaTab-DrNRwUP6.js} +1 -1
- package/dist/web/assets/{SettingsTab-DUlhyz1z.js → SettingsTab-DS6HQKrg.js} +1 -1
- package/dist/web/assets/{ToolIcon-Cp4gSgFt.js → ToolIcon-BZE0Fv7L.js} +1 -1
- package/dist/web/assets/{UsageTab-Da7c7zwV.js → UsageTab-Du6U3MIb.js} +1 -1
- package/dist/web/assets/index-9wZva5_f.css +1 -0
- package/dist/web/assets/index-BvY11iVv.js +2 -0
- package/dist/web/assets/metadataRegistry-4BIaQVmV.js +1 -0
- package/dist/web/assets/{providersData-HX0E7hDv.js → providersData-C-7jZmPi.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/CliToolsTab-iJozQAQx.js +0 -168
- package/dist/web/assets/CombosTab-DdsJ2ova.js +0 -1
- package/dist/web/assets/MitmTab-DMRg64by.js +0 -14
- package/dist/web/assets/ModelAutocompleteInput-D0L1aj3-.js +0 -1
- package/dist/web/assets/index-CtfMJ11V.js +0 -2
- package/dist/web/assets/index-DXsZmXJg.css +0 -1
- package/dist/web/assets/metadataRegistry-CGDAkFU1.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as b,j as e}from"./vendor-BcOI2aZ9.js";import{u as ne,a as H,D as re,c as oe,S as ie,v as ce,b as de,s as me,K as xe,P as ue,d as pe,C as be}from"./dnd-kit-DecqzwfZ.js";import{P as Y}from"./index-BvY11iVv.js";import{M as ee,i as J,C as te,a as fe}from"./ModelAutocompleteInput-BH4gr6Dr.js";import{M as se}from"./ModelSelectModal-B7-jAYUU.js";import{S as X}from"./Select-BNRH8LIG.js";import{T as ae}from"./ToolIcon-BZE0Fv7L.js";import{P as he}from"./metadataRegistry-4BIaQVmV.js";import{C as ge}from"./ConfirmModal-gmHKbGNe.js";import"./lucide-Cc35htxl.js";const ye=/^[a-zA-Z0-9_.-]+$/,je=({id:l,model:s,index:n,onEdit:p,onRemove:g,onMoveUp:o,onMoveDown:c,isFirst:d,isLast:y,excludeValues:a})=>{const[r,i]=b.useState(!1),[v,m]=b.useState(s);b.useEffect(()=>{m(s)},[s]);const k=T=>{const _=(typeof T=="string"?T:v).trim();_&&_!==s?p(_):m(s),i(!1)},{attributes:h,listeners:L,setNodeRef:j,transform:$,transition:N,isDragging:A}=pe({id:l}),B={transform:be.Transform.toString($),transition:N,zIndex:A?50:void 0,opacity:A?.6:1};return e.jsxs("div",{ref:j,style:B,className:`group flex items-center justify-between gap-2.5 px-3 py-2 rounded-xl border bg-[#0A0D14] transition-all ${A?"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",...h,...L,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:n+1}),r?e.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-1.5",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(ee,{autoFocus:!0,value:v,onChange:T=>m(T),onEnter:T=>k(T),placeholder:"e.g. anthropic/claude-3-7-sonnet",excludeValues:a,allowCombos:!1,className:"w-full rounded border border-blue-500/60 bg-[#141B2D] px-2 py-0.5 font-mono text-xs text-white outline-none focus:border-blue-400"})}),e.jsx("button",{type:"button",onClick:k,className:"p-1 text-emerald-400 hover:text-emerald-300 cursor-pointer",title:"Save changes",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"check"})}),e.jsx("button",{type:"button",onClick:()=>{m(s),i(!1)},className:"p-1 text-slate-400 hover:text-white cursor-pointer",title:"Cancel",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"close"})})]}):e.jsxs("div",{className:"min-w-0 flex-1 cursor-text truncate rounded px-1.5 py-0.5 font-mono text-xs text-white hover:bg-white/5 flex items-center gap-2",onClick:()=>i(!0),title:"Click to edit model ID inline",children:[e.jsx("span",{className:"truncate",title:s,children:s}),e.jsx("span",{className:"material-symbols-outlined text-[13px] text-slate-500 opacity-0 group-hover:opacity-100 transition-opacity",children:"edit"})]}),!r&&e.jsx(te,{model:s,size:"xs"})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{type:"button",onClick:o,disabled:d,className:"p-1 text-slate-400 hover:text-white disabled:opacity-20 disabled:hover:text-slate-400 cursor-pointer transition-colors",title:"Move up",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"arrow_upward"})}),e.jsx("button",{type:"button",onClick:c,disabled:y,className:"p-1 text-slate-400 hover:text-white disabled:opacity-20 disabled:hover:text-slate-400 cursor-pointer transition-colors",title:"Move down",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"arrow_downward"})}),e.jsx("button",{type:"button",onClick:g,className:"p-1 text-slate-400 hover:text-rose-400 cursor-pointer transition-colors",title:"Remove model",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"close"})})]})]})},ve=({isOpen:l,onClose:s,combo:n,title:p,onSave:g})=>{const[o,c]=b.useState(""),[d,y]=b.useState("round-robin"),[a,r]=b.useState([]),[i,v]=b.useState(""),[m,k]=b.useState(""),[h,L]=b.useState(""),[j,$]=b.useState(!1),[N,A]=b.useState(!1),B=!!n,T=ne(H(ue,{activationConstraint:{distance:4}}),H(xe,{coordinateGetter:me}));b.useEffect(()=>{l&&(n?(c(n.name),y(n.strategy||"round-robin"),r(Array.isArray(n.models)?[...n.models]:[])):(c(""),y("round-robin"),r([])),v(""),k(""),L(""),A(!1))},[l,n]);const q=f=>{const x=f.trim();return x?ye.test(x)?(v(""),!0):(v("Name can only contain letters, numbers, -, _ and ."),!1):(v("Combo name is required."),!1)},_=f=>{const x=f.target.value;c(x),x.trim()?q(x):v("")},G=b.useMemo(()=>{const f=[];n!=null&&n.id&&f.push(n.id),n!=null&&n.name&&(f.push(n.name),f.push(`combo/${n.name}`));const x=o.trim();return x&&(f.push(x),f.push(`combo/${x}`)),f},[n,o]),z=f=>{const x=f.trim().toLowerCase(),t=x.startsWith("combo/")?x.slice(6):x;return G.some(u=>{const C=u.toLowerCase(),E=C.startsWith("combo/")?C.slice(6):C;return x===C||t===E})},O=(f,x)=>{const t=x.trim();if(z(t)){k("A combo cannot bundle itself (circular reference).");return}const u=[...a];u[f]=t,r(u),k("")},P=f=>{r(a.filter((x,t)=>t!==f))},I=f=>{if(f===0)return;const x=[...a],t=x[f-1];x[f-1]=x[f],x[f]=t,r(x)},W=f=>{if(f===a.length-1)return;const x=[...a],t=x[f+1];x[f+1]=x[f],x[f]=t,r(x)},U=f=>{const{active:x,over:t}=f;t&&x.id!==t.id&&r(u=>{const C=u.map((R,w)=>`${R}-${w}`),E=C.indexOf(String(x.id)),D=C.indexOf(String(t.id));return E!==-1&&D!==-1?de(u,E,D):u})},Q=(f,x)=>{const t=(typeof x=="string"?x:h).trim();if(t){if(z(t)){k("A combo cannot bundle itself (circular reference).");return}a.includes(t)||(r([...a,t]),k("")),L("")}},Z=async f=>{if(f.preventDefault(),!!q(o)){if(a.length===0){k("At least one model must be added to the combo.");return}if(a.some(z)){k("A combo cannot bundle itself (circular reference).");return}try{A(!0),await g({id:n==null?void 0:n.id,name:o.trim(),models:a,strategy:d,isActive:n?n.isActive:!0}),J(),s()}catch(x){v((x==null?void 0:x.message)||"Failed to save combo.")}finally{A(!1)}}};return e.jsxs(e.Fragment,{children:[e.jsx(Y,{isOpen:l,onClose:s,maxWidthClass:"w-full max-w-3xl",children:e.jsxs("form",{onSubmit:Z,className:"space-y-5 -m-2 sm:-m-4 p-5 sm:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between pb-4 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:B?"edit_note":"add_circle"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-bold text-white",children:p||(B?`Edit Combo: ${n==null?void 0:n.name}`:"Create Smart Model Combo")}),e.jsx("p",{className:"text-xs text-slate-400",children:"Configure an alias to rotate or fallback across multiple upstream models"})]})]}),e.jsx("button",{type:"button",onClick:s,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:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-semibold text-slate-200 mb-1.5",children:["Combo Name / Alias ",e.jsx("span",{className:"text-rose-400",children:"*"})]}),e.jsx("input",{type:"text",placeholder:"e.g. combo-fast-coding, claude-3-7-sonnet",value:o,onChange:_,className:`w-full bg-[#0A0D14] border rounded-xl px-3.5 py-2 text-xs font-mono text-white placeholder-slate-500 focus:outline-none transition-colors ${i?"border-rose-500/80 focus:border-rose-500":"border-[#1E293B] focus:border-blue-500"}`}),i?e.jsxs("p",{className:"text-[11px] text-rose-400 mt-1 flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"error"}),i]}):e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Can contain letters, numbers, dashes, underscores, and dots."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-200 mb-1.5",children:"Routing Strategy"}),e.jsx(X,{value:d,onChange:f=>y(f),options:[{value:"round-robin",label:"Round Robin — Rotate across accounts"},{value:"fallback",label:"Fallback — Sequential priority order"},{value:"fusion",label:"Fusion — Parallel query panel + judge synthesis"},{value:"lkgp",label:"LKGP — Last Known Good (maximize prompt cache warmth)"},{value:"p2c",label:"P2C — Power of Two Choices (dynamic EMA load balancing)"}],className:"w-full"}),e.jsxs("div",{className:"mt-2 p-2.5 rounded-xl bg-[#0A0D14] border border-[#1E293B] text-[11px] text-slate-400",children:[d==="round-robin"&&e.jsxs("span",{className:"text-cyan-300",children:[e.jsx("strong",{children:"Round Robin:"})," Spreads requests across member models in alternating turns to balance rate limits."]}),d==="fallback"&&e.jsxs("span",{className:"text-blue-300",children:[e.jsx("strong",{children:"Fallback:"})," Tries models sequentially; moves to backup on HTTP 429, 503, or quota errors."]}),d==="fusion"&&e.jsxs("span",{className:"text-indigo-300",children:[e.jsx("strong",{children:"Fusion:"})," Queries member models concurrently in parallel, then synthesizes the best answer with a judge."]}),d==="lkgp"&&e.jsxs("span",{className:"text-emerald-300",children:[e.jsx("strong",{children:"LKGP (Last Known Good):"})," Retains the model that succeeded on the last request to keep prompt caches warm; fails over on error."]}),d==="p2c"&&e.jsxs("span",{className:"text-amber-300",children:[e.jsx("strong",{children:"P2C (Power of Two Choices):"})," Samples 2 candidates at random and routes to the one with superior latency and error score via EMA."]})]})]}),e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("label",{className:"block text-xs font-semibold text-slate-200",children:["Member Models (",a.length,") ",e.jsx("span",{className:"text-rose-400",children:"*"})]}),e.jsxs("button",{type:"button",onClick:()=>$(!0),className:"px-3 py-1 rounded-lg bg-blue-600/10 border border-blue-500/30 text-blue-400 hover:bg-blue-600/20 text-xs font-medium flex items-center gap-1.5 transition-colors cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"add"}),"Add Model"]})]}),e.jsx("div",{className:"border border-[#1E293B] rounded-2xl bg-[#0A0D14]/50 p-2.5 space-y-2 min-h-[140px] max-h-[260px] overflow-y-auto",children:a.length===0?e.jsx("div",{className:"py-8 text-center text-slate-500 text-xs",children:"No models in this combo yet. Click “Add Model” to pick from catalog or enter a model ID below."}):e.jsx(re,{sensors:T,collisionDetection:oe,onDragEnd:U,children:e.jsx(ie,{items:a.map((f,x)=>`${f}-${x}`),strategy:ce,children:e.jsx("div",{className:"space-y-1.5",children:a.map((f,x)=>e.jsx(je,{id:`${f}-${x}`,model:f,index:x,onEdit:t=>O(x,t),onRemove:()=>P(x),onMoveUp:()=>I(x),onMoveDown:()=>W(x),isFirst:x===0,isLast:x===a.length-1,excludeValues:G},`${f}-${x}`))})})})}),m&&e.jsxs("p",{className:"text-[11px] text-rose-400 flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"error"}),m]}),e.jsxs("div",{className:"flex gap-2 pt-1 items-start",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(ee,{placeholder:"Or search/type model ID (e.g. anthropic/claude-3-7-sonnet)...",value:h,onChange:L,onEnter:f=>Q(void 0,f),excludeValues:G,allowCombos:!1,className:"w-full 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:"button",onClick:()=>Q(),disabled:!h.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 whitespace-nowrap shrink-0",children:"Add"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-4 border-t border-[#1E293B]",children:[e.jsx("button",{type:"button",onClick:s,disabled:N,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:"submit",disabled:N,className:"px-5 py-2 rounded-xl text-xs font-semibold text-white bg-blue-600 hover:bg-blue-500 shadow-md shadow-blue-600/20 disabled:opacity-50 transition-all flex items-center gap-1.5 cursor-pointer",children:N?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[15px] animate-spin",children:"progress_activity"}),"Saving..."]}):e.jsx("span",{children:B?"Update Combo":"Save Combo"})})]})]})}),j&&e.jsx(se,{isOpen:j,onClose:()=>$(!1),addedModelValues:a,initialSelectedModels:a,excludeModelIds:G,allowCombos:!1,onConfirm:f=>{r(f),f.length>0&&k("")},title:"Add Model to Combo",multiSelect:!0,closeOnSelect:!1})]})},Ne=({searchQuery:l,onSearchChange:s,onlyConnected:n,onToggleOnlyConnected:p,groupMode:g,onGroupModeChange:o,onlyMultiProvider:c=!1,onToggleOnlyMultiProvider:d,onSelectConnectedOnly:y,onDeselectAll:a,onTestAll:r,isTestingAll:i})=>{const v=[{mode:"provider",label:"Provider",icon:"dns"},{mode:"model",label:"Model",icon:"layers"},{mode:"family",label:"Family",icon:"category"},{mode:"role",label:"Role",icon:"psychology"}];return e.jsxs("div",{className:"space-y-2.5 shrink-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-[220px]",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("span",{className:"material-symbols-outlined absolute left-2.5 top-1/2 -translate-y-1/2 text-slate-500 text-[16px]",children:"search"}),e.jsx("input",{type:"text",value:l,onChange:m=>s(m.target.value),placeholder:"Search providers or models...",className:"w-full pl-8 pr-3 py-1.5 bg-[#0A0D14] border border-[#1E293B] rounded-xl text-xs text-slate-200 placeholder-slate-500 focus:outline-none focus:border-blue-500"})]}),e.jsxs("button",{type:"button",onClick:p,className:`px-2.5 py-1.5 rounded-xl border text-xs font-medium flex items-center gap-1.5 transition-colors cursor-pointer shrink-0 ${n?"bg-emerald-500/15 border-emerald-500/30 text-emerald-400":"bg-[#0A0D14] border-[#1E293B] text-slate-400 hover:text-slate-200"}`,children:[e.jsx("span",{className:"size-1.5 rounded-full bg-current"}),"Connected Only"]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0 text-xs",children:[e.jsx("button",{type:"button",onClick:y,className:"px-2.5 py-1.5 rounded-xl bg-slate-800/60 hover:bg-slate-800 text-slate-300 font-medium transition-colors cursor-pointer",children:"Select Connected"}),e.jsx("button",{type:"button",onClick:a,className:"px-2.5 py-1.5 rounded-xl bg-slate-800/60 hover:bg-slate-800 text-slate-300 font-medium transition-colors cursor-pointer",children:"Deselect All"}),e.jsxs("button",{type:"button",onClick:r,disabled:i,className:"px-2.5 py-1.5 rounded-xl bg-blue-600/10 border border-blue-500/20 text-blue-400 hover:bg-blue-600/20 font-medium flex items-center gap-1 transition-colors cursor-pointer disabled:opacity-50",children:[e.jsx("span",{className:`material-symbols-outlined text-[14px] ${i?"animate-spin":""}`,children:i?"refresh":"network_check"}),"Test All"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1 border-t border-[#1E293B]/60 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-slate-400 text-[11px] font-medium mr-1",children:"Group by:"}),e.jsx("div",{className:"inline-flex p-0.5 rounded-lg bg-[#0F1420] border border-[#1E293B]",children:v.map(m=>e.jsxs("button",{type:"button",onClick:()=>o(m.mode),className:`px-2.5 py-1 rounded-md text-[11px] font-medium flex items-center gap-1.5 transition-all cursor-pointer ${g===m.mode?"bg-blue-600 text-white shadow-sm":"text-slate-400 hover:text-slate-200"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:m.icon}),m.label]},m.mode))})]}),g==="model"&&d&&e.jsxs("button",{type:"button",onClick:d,className:`px-2 py-1 rounded-lg border text-[11px] font-medium flex items-center gap-1 transition-colors cursor-pointer ${c?"bg-purple-500/15 border-purple-500/30 text-purple-400":"bg-[#0A0D14] border-[#1E293B] text-slate-400 hover:text-slate-200"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"hub"}),"Multi-Provider Only (≥2)"]})]})]})},we=({isMultiMode:l,onToggleMultiMode:s,canMultiMode:n,comboName:p,onComboNameChange:g,namePrefix:o,onNamePrefixChange:c,strategy:d,onStrategyChange:y,activeGroupsCount:a})=>e.jsxs("div",{className:"p-3.5 rounded-xl bg-[#0A0D14] border border-[#1E293B] space-y-3 shrink-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-semibold text-slate-300",children:"Creation Mode:"}),e.jsxs("div",{className:"inline-flex p-0.5 rounded-lg bg-[#0F1420] border border-[#1E293B]",children:[e.jsx("button",{type:"button",onClick:()=>s(!1),className:`px-2.5 py-1 rounded-md text-[11px] font-medium transition-all cursor-pointer ${l?"text-slate-400 hover:text-slate-200":"bg-slate-700 text-white shadow-sm"}`,children:"Single Combo"}),e.jsxs("button",{type:"button",disabled:!n,onClick:()=>s(!0),title:n?"Generate a separate combo for each selected group":"Switch to Model, Family or Role view to enable Multi-Combos",className:`px-2.5 py-1 rounded-md text-[11px] font-medium transition-all flex items-center gap-1.5 cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed ${l?"bg-emerald-600 text-white shadow-sm":"text-slate-400 hover:text-slate-200"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"dynamic_feed"}),"Multi-Combos (1 per group)",l&&a>0&&e.jsx("span",{className:"px-1.5 py-0.2 rounded-full bg-white/20 text-[10px] font-bold",children:a})]})]})]}),l&&e.jsxs("span",{className:"text-[11px] text-emerald-400/90 font-medium flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"auto_awesome"}),a," combo",a!==1?"s":""," will be generated"]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 pt-1 border-t border-[#1E293B]/60",children:[l?e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-semibold text-slate-300 mb-1",children:"Combo Name Prefix"}),e.jsx("input",{type:"text",value:o,onChange:r=>c(r.target.value),placeholder:"e.g. free-",className:"w-full px-3 py-1.5 bg-[#0F1420] border border-[#1E293B] rounded-xl text-xs text-emerald-400 placeholder-slate-500 focus:outline-none focus:border-emerald-500 font-mono"})]}):e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[11px] font-semibold text-slate-300 mb-1",children:["Combo Identifier ",e.jsx("span",{className:"text-rose-400",children:"*"})]}),e.jsx("input",{type:"text",value:p,onChange:r=>g(r.target.value),placeholder:"e.g. free-fallback",className:"w-full px-3 py-1.5 bg-[#0F1420] border border-[#1E293B] rounded-xl text-xs text-white placeholder-slate-500 focus:outline-none focus:border-blue-500 font-mono"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[11px] font-semibold text-slate-300 mb-1",children:["Routing Strategy ",l?"(for all generated combos)":""]}),e.jsx(X,{value:d,onChange:r=>y(r),options:[{value:"fallback",label:"Fallback (try free models in order)"},{value:"round-robin",label:"Round Robin (distribute across free tiers)"},{value:"lkgp",label:"LKGP (Last Known Good Provider)"},{value:"fusion",label:"Fusion (parallel multi-model panel)"},{value:"p2c",label:"P2C (Power of Two Choices)"}],className:"w-full"})]})]})]}),Ce=({provider:l,freeTier:s,freeModels:n,selectedModelValues:p,onToggleModel:g,onToggleAllProviderModels:o,connectionStatus:c,statusLabel:d,statusDetail:y,onTestConnection:a,isTesting:r,defaultExpanded:i=!1})=>{const[v,m]=b.useState(i),k=n.filter(N=>p.has(N.comboModelValue)).length,h=n.length>0&&k===n.length,L=k>0&&k<n.length,$=(N=>{switch(N){case"local":return{label:"Local Engine",bg:"bg-purple-500/10 text-purple-400 border-purple-500/20"};case"credits":return{label:"Free Credits",bg:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20"};case"per-model":return{label:"Per-Model Limits",bg:"bg-blue-500/10 text-blue-400 border-blue-500/20"};case"requests":default:return{label:"Free Requests",bg:"bg-cyan-500/10 text-cyan-400 border-cyan-500/20"}}})(s.limitType);return e.jsxs("div",{className:"rounded-xl border border-[#1E293B] bg-[#0A0D14]/90 overflow-hidden transition-all duration-200 hover:border-slate-700",children:[e.jsxs("div",{className:"p-3.5 flex flex-wrap items-center justify-between gap-3 bg-[#0F1420]/60",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("input",{type:"checkbox",checked:h,ref:N=>{N&&(N.indeterminate=L)},onChange:N=>o(l.id,N.target.checked),title:h?"Deselect all models":"Select all free models",className:"size-4 rounded border-slate-700 bg-slate-800 text-blue-600 focus:ring-0 focus:ring-offset-0 cursor-pointer"}),e.jsx(ae,{src:l.image,name:l.name,color:l.color,iconBg:l.iconBg,size:"sm"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-semibold text-xs text-white truncate",children:l.name}),e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium border ${$.bg}`,children:$.label})]}),s.note&&e.jsx("p",{className:"text-[11px] text-slate-400 truncate max-w-md",title:s.note,children:s.note})]})]}),e.jsxs("div",{className:"flex items-center gap-2.5 shrink-0 ml-auto",children:[e.jsxs("div",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[11px] font-medium border ${c==="connected"?"bg-emerald-500/10 text-emerald-400 border-emerald-500/20":c==="not_connected"?"bg-amber-500/10 text-amber-400 border-amber-500/20":"bg-rose-500/10 text-rose-400 border-rose-500/20"}`,title:y||d,children:[e.jsx("span",{className:"size-1.5 rounded-full animate-pulse bg-current"}),e.jsx("span",{children:d}),y&&e.jsxs("span",{className:"opacity-75 font-mono text-[10px]",children:["(",y,")"]})]}),e.jsxs("button",{type:"button",onClick:()=>a(l.id),disabled:r,title:"Test upstream connection",className:"px-2 py-1 rounded-lg bg-slate-800/80 hover:bg-slate-700 text-slate-300 text-[11px] font-medium flex items-center gap-1 transition-colors cursor-pointer disabled:opacity-50",children:[e.jsx("span",{className:`material-symbols-outlined text-[13px] ${r?"animate-spin text-blue-400":""}`,children:r?"refresh":"network_check"}),e.jsx("span",{children:r?"Testing":"Test"})]}),e.jsxs("button",{type:"button",onClick:()=>m(!v),className:"px-2 py-1 rounded-lg bg-slate-800/50 hover:bg-slate-800 text-slate-300 text-[11px] font-medium flex items-center gap-1.5 transition-colors cursor-pointer",children:[e.jsxs("span",{className:"text-slate-400",children:[k,"/",n.length]}),e.jsx("span",{className:"material-symbols-outlined text-[15px] transition-transform duration-200",children:v?"expand_less":"expand_more"})]})]})]}),v&&e.jsx("div",{className:"p-3 border-t border-[#1E293B] bg-[#0A0D14]/40 space-y-1.5 animate-rt-fade-in",children:n.length===0?e.jsx("div",{className:"py-3 text-center text-xs text-slate-500 italic",children:"No free models configured or discovered yet."}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-1.5 max-h-64 overflow-y-auto pr-1",children:n.map(N=>{const A=p.has(N.comboModelValue);return e.jsxs("label",{className:`flex items-start gap-2.5 p-2 rounded-lg border text-xs cursor-pointer transition-all ${A?"bg-blue-600/10 border-blue-500/30 text-white":"bg-[#0F1420]/50 border-[#1E293B]/70 text-slate-300 hover:bg-white/5"}`,children:[e.jsx("input",{type:"checkbox",checked:A,onChange:()=>g(N.comboModelValue),className:"size-3.5 mt-0.5 rounded border-slate-700 bg-slate-800 text-blue-600 focus:ring-0 focus:ring-offset-0 cursor-pointer shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-semibold text-slate-200 truncate",children:N.name}),N.contextLength&&e.jsxs("span",{className:"text-[10px] px-1 rounded bg-slate-800 text-slate-400",children:[Math.round(N.contextLength/1e3),"k ctx"]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:"font-mono text-[10px] text-slate-500 truncate",children:N.comboModelValue}),N.limit&&e.jsxs("span",{className:"text-[10px] text-cyan-400/90 truncate",children:["• ",N.limit]})]})]})]},N.comboModelValue)})})})]})},ke=({group:l,selectedModelValues:s,onToggleModel:n,onToggleAllGroupModels:p,isMultiMode:g,comboNameValue:o,onComboNameChange:c,onTestConnection:d,testingIds:y,defaultExpanded:a=!1})=>{const[r,i]=b.useState(a),v=l.candidates.filter(j=>s.has(j.model.comboModelValue)).length,m=l.candidates.length>0&&v===l.candidates.length,k=v>0&&v<l.candidates.length,h=new Set(l.candidates.map(j=>j.provider.id)).size,L=new Set(l.candidates.filter(j=>j.connectionStatus==="connected").map(j=>j.provider.id)).size;return e.jsxs("div",{className:"rounded-xl border border-[#1E293B] bg-[#0A0D14]/90 overflow-hidden transition-all duration-200 hover:border-slate-700",children:[e.jsxs("div",{className:"p-3.5 flex flex-wrap items-center justify-between gap-3 bg-[#0F1420]/60",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("input",{type:"checkbox",checked:m,ref:j=>{j&&(j.indeterminate=k)},onChange:j=>p(l.id,j.target.checked),title:m?"Deselect all in group":"Select all in group",className:"size-4 rounded border-slate-700 bg-slate-800 text-blue-600 focus:ring-0 focus:ring-offset-0 cursor-pointer"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-semibold text-xs text-white truncate",children:l.name}),e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium border ${h>1?"bg-purple-500/10 text-purple-400 border-purple-500/20":"bg-slate-800 text-slate-400 border-slate-700"}`,children:[h," Provider",h>1?"s":""]}),L>0&&e.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:[L," Connected"]})]}),l.description&&e.jsx("p",{className:"text-[11px] text-slate-400 truncate max-w-md mt-0.5",title:l.description,children:l.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2.5 shrink-0 ml-auto",children:[g&&v>0&&c&&e.jsxs("div",{className:"flex items-center gap-1.5 bg-[#0A0D14] px-2 py-1 rounded-lg border border-[#1E293B]",children:[e.jsx("span",{className:"text-[10px] font-mono text-slate-400",children:"Combo:"}),e.jsx("input",{type:"text",value:o??l.defaultComboName,onChange:j=>c(l.id,j.target.value),placeholder:l.defaultComboName,className:"w-32 sm:w-40 bg-transparent text-[11px] font-mono text-emerald-400 focus:outline-none"})]}),e.jsxs("button",{type:"button",onClick:()=>i(!r),className:"px-2 py-1 rounded-lg bg-slate-800/50 hover:bg-slate-800 text-slate-300 text-[11px] font-medium flex items-center gap-1.5 transition-colors cursor-pointer",children:[e.jsxs("span",{className:"text-slate-400",children:[v,"/",l.candidates.length]}),e.jsx("span",{className:"material-symbols-outlined text-[15px] transition-transform duration-200",children:r?"expand_less":"expand_more"})]})]})]}),r&&e.jsx("div",{className:"p-3 border-t border-[#1E293B] bg-[#0A0D14]/40 space-y-1.5 animate-rt-fade-in",children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-1.5 max-h-64 overflow-y-auto pr-1",children:l.candidates.map(j=>{const $=s.has(j.model.comboModelValue),N=y.has(j.provider.id);return e.jsxs("div",{className:`flex items-start gap-2.5 p-2 rounded-lg border text-xs transition-all ${$?"bg-blue-600/10 border-blue-500/30 text-white":"bg-[#0F1420]/50 border-[#1E293B]/70 text-slate-300 hover:bg-white/5"}`,children:[e.jsx("input",{type:"checkbox",checked:$,onChange:()=>n(j.model.comboModelValue),className:"size-3.5 mt-0.5 rounded border-slate-700 bg-slate-800 text-blue-600 focus:ring-0 focus:ring-offset-0 cursor-pointer shrink-0"}),e.jsx("div",{className:"size-6 shrink-0 mt-0.5",children:e.jsx(ae,{src:j.provider.image,name:j.provider.name,color:j.provider.color,iconBg:j.provider.iconBg,size:"sm"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-semibold text-slate-200 truncate",children:j.provider.name}),e.jsx("span",{className:"text-slate-500 text-[10px]",children:"/"}),e.jsx("span",{className:"text-slate-300 truncate text-[11px]",children:j.model.name})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:"font-mono text-[10px] text-slate-500 truncate",children:j.model.comboModelValue}),j.latencyMs!=null&&e.jsxs("span",{className:"text-[10px] text-emerald-400 font-mono",children:[j.latencyMs,"ms"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 ml-1",children:[e.jsx("span",{className:`size-2 rounded-full ${j.connectionStatus==="connected"?"bg-emerald-400":j.connectionStatus==="not_connected"?"bg-amber-400":"bg-rose-400"}`,title:j.statusDetail||j.statusLabel}),e.jsx("button",{type:"button",onClick:()=>d(j.provider.id),disabled:N,title:"Test provider",className:"p-1 rounded hover:bg-slate-700 text-slate-400 hover:text-white transition-colors cursor-pointer disabled:opacity-50",children:e.jsx("span",{className:`material-symbols-outlined text-[13px] ${N?"animate-spin text-blue-400":""}`,children:N?"refresh":"network_check"})})]})]},j.model.comboModelValue)})})})]})},Se=({groupMode:l,filteredProviders:s,groups:n,selectedModelValues:p,onToggleModel:g,onToggleAllProviderModels:o,onToggleAllGroupModels:c,isMultiMode:d,groupComboNames:y,onGroupComboNameChange:a,onTestConnection:r,testingIds:i})=>e.jsx("div",{className:"flex-1 overflow-y-auto pr-1 space-y-2.5 min-h-[220px]",children:l==="provider"?s.length===0?e.jsx("div",{className:"py-12 text-center text-slate-500 text-xs",children:"No matching free providers found."}):s.map(v=>e.jsx(Ce,{provider:v.provider,freeTier:v.freeTier,freeModels:v.freeModels,selectedModelValues:p,onToggleModel:g,onToggleAllProviderModels:o,connectionStatus:v.connectionStatus,statusLabel:v.statusLabel,statusDetail:v.statusDetail,onTestConnection:r,isTesting:i.has(v.provider.id),defaultExpanded:v.freeModels.some(m=>p.has(m.comboModelValue))},v.provider.id)):n.length===0?e.jsx("div",{className:"py-12 text-center text-slate-500 text-xs",children:"No matching model groups found."}):n.map(v=>e.jsx(ke,{group:v,selectedModelValues:p,onToggleModel:g,onToggleAllGroupModels:c,isMultiMode:d,comboNameValue:y[v.id],onComboNameChange:a,onTestConnection:r,testingIds:i,defaultExpanded:v.candidates.some(m=>p.has(m.model.comboModelValue))},v.id))});function Me(l,s){if(!l||!s)return!1;if(l===s)return!0;const n=l.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".");return new RegExp(`^${n}$`,"i").test(s)}function Ae(l){return l?l.freeTier!=null||l.category==="freeTier"||l.category==="free"||l.isLocal===!0||l.requiresApiKey===!1||l.authType==="none"||l.noAuth===!0:!1}function Ee(l,s){const n=l.freeTier,p=l.models||[],g=(s==null?void 0:s.models)||[],o=new Map;for(const a of p)!a||!a.id||a.kind&&a.kind!=="chat"||o.set(a.id,{id:a.id,name:a.name||a.id,contextLength:a.contextLength,kind:a.kind,capabilities:a.capabilities});for(const a of g){const r=typeof a=="string"?a:a==null?void 0:a.id;if(!r)continue;const i=typeof a=="object"?a.kind:void 0;i&&i!=="chat"||o.has(r)||o.set(r,{id:r,name:typeof a=="string"?a:a.name||r,contextLength:typeof a=="object"?a.contextLength:void 0,kind:i,capabilities:typeof a=="object"?a.capabilities:void 0})}const c=[],d=new Set,y=a=>a.startsWith(`${l.id}/`)?a:`${l.id}/${a}`;if(!n){for(const[a,r]of o.entries())d.has(a)||(d.add(a),c.push({id:a,comboModelValue:y(a),name:r.name,limit:l.isLocal?"Local inference":void 0,contextLength:r.contextLength,kind:r.kind,capabilities:r.capabilities,providerId:l.id}));return c}if(Array.isArray(n.models))for(const a of n.models){if(!a||!a.id)continue;const r=a.id,i=o.get(r);i!=null&&i.kind&&i.kind!=="chat"||d.has(r)||(d.add(r),c.push({id:r,comboModelValue:y(r),name:(i==null?void 0:i.name)||r,limit:a.limit||n.note,contextLength:i==null?void 0:i.contextLength,kind:i==null?void 0:i.kind,capabilities:i==null?void 0:i.capabilities,providerId:l.id}))}if(Array.isArray(n.match)&&n.match.length>0)for(const[a,r]of o.entries()){if(d.has(a)||r.kind&&r.kind!=="chat")continue;n.match.some(v=>Me(v,a))&&(d.add(a),c.push({id:a,comboModelValue:y(a),name:r.name,limit:n.note||"Free tier",contextLength:r.contextLength,kind:r.kind,capabilities:r.capabilities,providerId:l.id}))}if(n.scope==="all"){for(const[a,r]of o.entries())if(!d.has(a)){if(r.kind&&r.kind!=="chat")continue;d.add(a),c.push({id:a,comboModelValue:y(a),name:r.name,limit:n.note,contextLength:r.contextLength,kind:r.kind,capabilities:r.capabilities,providerId:l.id})}}return c}function Be(l,s,n){if(n){if(n.success)return{status:"connected",label:"Connected",detail:n.latencyMs!=null?`${n.latencyMs}ms`:void 0};const c=n.error||n.message||"Connection failed",d=/quota|rate limit|exhausted|429/i.test(c);return{status:d?"exhausted":"error",label:d?"Quota Exhausted":"Connection Error",detail:c}}if(l.isLocal)return{status:"connected",label:"Local Engine",detail:"Runs on localhost"};if(l.noAuth||l.requiresApiKey===!1||l.authType==="none")return{status:"connected",label:"Ready (Zero Config)"};const g=((s==null?void 0:s.accounts)||[]).filter(c=>c.isActive!==!1),o=(s==null?void 0:s.accountsCount)??g.length;return o>0||g.length>0?g.length>0&&g.every(d=>(d.rateLimitHits??0)>=3)?{status:"exhausted",label:"Rate Limited",detail:"Cooldown active"}:{status:"connected",label:"Connected",detail:`${o} account${o>1?"s":""}`}:{status:"not_connected",label:"Not Connected",detail:"API key required"}}function Te(l){const[s,n]=b.useState([]),[p,g]=b.useState(new Set),[o,c]=b.useState({}),[d,y]=b.useState(!1),a=b.useCallback(async()=>{try{const m=await fetch("/api/providers");if(m.ok){const k=await m.json();Array.isArray(k)&&n(k)}}catch(m){console.error("Failed to load providers:",m)}},[]);b.useEffect(()=>{l&&a()},[l,a]);const r=b.useMemo(()=>{const m=Object.values(he).filter(h=>h.id==="combo"||h.category==="composite"?!1:Ae(h)),k=new Map(s.map(h=>[h.id,h]));return m.map(h=>{var B;const L=k.get(h.id),j=h.freeTier||{scope:"all",limitType:h.isLocal?"local":"requests",note:(B=h.notice)==null?void 0:B.text},$=Ee(h,L),N=o[h.id],A=Be(h,L,N);return{provider:h,freeTier:j,freeModels:$,connectionStatus:A.status,statusLabel:A.label,statusDetail:A.detail,testResult:N}})},[s,o]),i=async m=>{g(k=>new Set(k).add(m));try{const h=await(await fetch(`/api/providers/${encodeURIComponent(m)}/test`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({timeoutMs:7e3})})).json();c(L=>({...L,[m]:{success:!!h.success,message:h.message,latencyMs:h.latencyMs,error:h.error}}))}catch(k){c(h=>({...h,[m]:{success:!1,error:k.message||"Test failed"}}))}finally{g(k=>{const h=new Set(k);return h.delete(m),h})}};return{freeProvidersList:r,testingIds:p,isTestingAll:d,testConnection:i,testAll:async m=>{y(!0),await Promise.allSettled(m.map(k=>i(k))),y(!1)}}}function Le(l){if(!l)return"";let s=l.trim().toLowerCase();return s.includes("/")&&(s=s.split("/").pop()),s=s.replace(/:free$/,"").replace(/-free$/,"").replace(/\/free$/,"").replace(/-contributor-free(-exp)?$/,"").replace(/-vision-exp$/,"").replace(/-(versatile|instant|instruct|preview|latest|it)$/,"").replace(/-(2501|2507|1017)$/,""),s=s.replace(/\./g,"-").replace(/[\s_]+/g,"-").replace(/-+/g,"-"),s=s.replace(/^meta-llama-/,"llama-").replace(/^qwen3/,"qwen-3").replace(/^qwen2-5/,"qwen-2-5").replace(/^llama3-3/,"llama-3-3").replace(/^llama4/,"llama-4").replace(/^zai-glm-/,"glm-"),s.replace(/^-+|-+$/g,"")}function $e(l){if(!l)return"Unknown Model";const s={"llama-3-3-70b":"Llama 3.3 70B","llama-3-1-8b":"Llama 3.1 8B","llama-4-maverick-17b-128e":"Llama 4 Maverick","llama-4-scout-17b-16e":"Llama 4 Scout","qwen-3-32b":"Qwen 3 32B","qwen-2-5-coder-32b":"Qwen 2.5 Coder 32B","gpt-oss-120b":"GPT OSS 120B","gemini-3-8-flash":"Gemini 3.8 Flash","gemini-2-5-flash":"Gemini 2.5 Flash","gemini-2-5-pro":"Gemini 2.5 Pro","deepseek-r1-distill-llama-70b":"DeepSeek R1 (Llama 70B)","deepseek-r1":"DeepSeek R1","deepseek-v4-flash":"DeepSeek V4 Flash","deepseek-v4-1-flash":"DeepSeek V4.1 Flash","minimax-m2-7":"MiniMax M2.7","minimax-m3":"MiniMax M3",codestral:"Codestral","mistral-small":"Mistral Small"};return s[l]?s[l]:l.split("-").map(n=>n.length<=3?n.toUpperCase():n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function De(l){const s=l.toLowerCase();return s.includes("llama")?{id:"llama",name:"Meta Llama"}:s.includes("qwen")||s.includes("qwq")?{id:"qwen",name:"Qwen"}:s.includes("deepseek")?{id:"deepseek",name:"DeepSeek"}:s.includes("gemini")||s.includes("gemma")?{id:"gemini",name:"Google Gemini"}:s.includes("mistral")||s.includes("codestral")||s.includes("ministral")?{id:"mistral",name:"Mistral AI"}:s.includes("glm")||s.includes("zcode")?{id:"glm",name:"Zhipu GLM"}:s.includes("minimax")?{id:"minimax",name:"MiniMax"}:s.includes("gpt")||s.includes("openai")?{id:"gpt",name:"OpenAI / GPT-OSS"}:s.includes("kilo")?{id:"kilo",name:"Kilo Gateway"}:{id:"community",name:"Community / Other"}}function Fe(l,s){let n="";Array.isArray(s.capabilities)?n=s.capabilities.join(" "):s.capabilities&&typeof s.capabilities=="object"?n=Object.entries(s.capabilities).filter(([g,o])=>!!o).map(([g])=>g).join(" "):typeof s.capabilities=="string"&&(n=s.capabilities);const p=`${l} ${s.name||""} ${n}`.toLowerCase();return p.includes("coder")||p.includes("codestral")||p.includes("code")?{id:"coding",name:"Coding Specialists",description:"Models tuned specifically for programming and code completion"}:p.includes("r1")||p.includes("qwq")||p.includes("reasoning")||p.includes("thinking")?{id:"reasoning",name:"Deep Reasoning",description:"Chain-of-thought and deep reasoning models for complex problem solving"}:p.includes("flash-lite")||p.includes("instant")||p.includes("nano")||p.includes("mini")||p.includes("-8b")||p.includes("-3b")||p.includes("-1b")?{id:"fast",name:"Fast & Lightweight",description:"Ultra-fast low-latency models for autocomplete and quick tasks"}:{id:"general",name:"General & Balanced",description:"High-capacity balanced models for versatile assistant workflows"}}function Pe(l){return[...l].sort((s,n)=>{const p=c=>c==="connected"?0:c==="not_connected"?1:2,g=p(s.connectionStatus),o=p(n.connectionStatus);return g!==o?g-o:s.latencyMs!=null&&n.latencyMs!=null?s.latencyMs-n.latencyMs:s.latencyMs!=null?-1:n.latencyMs!=null?1:s.provider.name.localeCompare(n.provider.name)})}function Ie(l,s,n=new Set){const p=s instanceof Set?s:new Set(s);let g=l.trim().toLowerCase().replace(/[^a-zA-Z0-9_.-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"");g||(g="free-combo");let o=g,c=2;for(;p.has(o)||n.has(o);)o=`${g}-${c++}`;return n.add(o),o}function Re(l,s,n="free-"){var o;const p=new Map;for(const c of l)for(const d of c.freeModels){const y=Le(d.id);let a="",r="",i;if(s==="model")a=y||d.id,r=$e(y);else if(s==="family"){const m=De(y);a=m.id,r=m.name,i=`Models from the ${m.name} architecture`}else{const m=Fe(y,d);a=m.id,r=m.name,i=m.description}if(!p.has(a)){const k=`${n.replace(/[^a-zA-Z0-9_.-]/g,"")}${a}`.replace(/-+/g,"-");p.set(a,{id:a,name:r,description:i,defaultComboName:k,candidates:[]})}p.get(a).candidates.push({model:d,provider:c.provider,connectionStatus:c.connectionStatus,statusLabel:c.statusLabel,statusDetail:c.statusDetail,latencyMs:(o=c.testResult)==null?void 0:o.latencyMs})}const g=[];for(const c of p.values()){c.candidates=Pe(c.candidates);const d=new Set(c.candidates.map(y=>y.provider.id)).size;c.badge=`${d} Provider${d>1?"s":""}`,g.push(c)}return s==="model"?g.sort((c,d)=>{const y=new Set(c.candidates.map(r=>r.provider.id)).size,a=new Set(d.candidates.map(r=>r.provider.id)).size;return y!==a?a-y:c.name.localeCompare(d.name)}):g.sort((c,d)=>d.candidates.length-c.candidates.length),g}const le=/^[a-zA-Z0-9_.-]+$/;function _e(l,s,n,p,g){const o=[],c=new Set(p);for(const d of l){const y=(n[d.id]||d.defaultComboName).trim();if(!y)return{error:`Combo name for "${d.name}" cannot be empty.`};if(!le.test(y))return{error:`Invalid name "${y}". Use only letters, numbers, -, _ and .`};if(c.has(y))return{error:`Combo name "${y}" already exists. Please choose another.`};c.add(y);const a=d.candidates.filter(r=>s.has(r.model.comboModelValue)).map(r=>r.model.comboModelValue);a.length>0&&o.push({name:y,models:a,strategy:g})}return o.length===0?{error:"No valid combos to create."}:{combos:o}}const ze=({isOpen:l,onClose:s,onSave:n,onSaveBatch:p,existingComboNames:g=[]})=>{const[o,c]=b.useState("free-fallback"),[d,y]=b.useState("free-"),[a,r]=b.useState("fallback"),[i,v]=b.useState("provider"),[m,k]=b.useState(!1),[h,L]=b.useState(!1),[j,$]=b.useState(""),[N,A]=b.useState(!1),[B,T]=b.useState(new Set),[q,_]=b.useState({}),[G,z]=b.useState(!1),[O,P]=b.useState(null),{freeProvidersList:I,testingIds:W,isTestingAll:U,testConnection:Q,testAll:Z}=Te(l);b.useEffect(()=>{if(l){const w=Ie("free-fallback",g);c(w),P(null)}},[l,g]),b.useEffect(()=>{if(l&&B.size===0&&I.length>0){const w=new Set;for(const S of I)if(S.connectionStatus==="connected"&&S.freeModels.length>0)for(const M of S.freeModels.slice(0,3))w.add(M.comboModelValue);w.size>0&&T(w)}},[l,I]);const f=b.useMemo(()=>{const w=j.trim().toLowerCase();return I.filter(S=>N&&S.connectionStatus!=="connected"?!1:!w||S.provider.name.toLowerCase().includes(w)||S.provider.id.toLowerCase().includes(w)?!0:S.freeModels.some(M=>M.name.toLowerCase().includes(w)||M.id.toLowerCase().includes(w)))},[I,j,N]),x=b.useMemo(()=>{if(i==="provider")return[];let w=Re(f,i,d);return i==="model"&&h&&(w=w.filter(S=>new Set(S.candidates.map(M=>M.provider.id)).size>=2)),w},[f,i,d,h]),t=b.useMemo(()=>x.filter(w=>w.candidates.some(S=>B.has(S.model.comboModelValue))),[x,B]),u=w=>{T(S=>{const M=new Set(S);return M.has(w)?M.delete(w):M.add(w),M})},C=(w,S)=>{const M=I.find(F=>F.provider.id===w);M&&T(F=>{const V=new Set(F);for(const K of M.freeModels)S?V.add(K.comboModelValue):V.delete(K.comboModelValue);return V})},E=(w,S)=>{const M=x.find(F=>F.id===w);M&&T(F=>{const V=new Set(F);for(const K of M.candidates)S?V.add(K.model.comboModelValue):V.delete(K.model.comboModelValue);return V})},D=()=>{const w=new Set;for(const S of I)if(S.connectionStatus==="connected")for(const M of S.freeModels)w.add(M.comboModelValue);T(w)},R=async w=>{if(w.preventDefault(),B.size===0)return P("Please select at least one free model for this combo.");try{if(z(!0),P(null),!m||i==="provider"){const S=o.trim();if(!S)return P("Combo name is required.");if(!le.test(S))return P("Name can only contain letters, numbers, -, _ and .");await n({name:S,models:Array.from(B),strategy:a})}else{if(t.length===0)return P("Please select at least one model from any group.");const{error:S,combos:M}=_e(t,B,q,g,a);if(S)return P(S);if(!M||M.length===0)return P("No valid combos to create.");if(p)await p(M);else for(const F of M)await n(F)}s()}catch(S){P(S.message||"Failed to create free tier combo.")}finally{z(!1)}};return e.jsxs(Y,{isOpen:l,onClose:s,maxWidthClass:"max-w-5xl",className:"max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between pb-4 border-b border-[#1E293B] shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"size-9 rounded-xl bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 flex items-center justify-center shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"savings"})}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-base font-bold text-white flex items-center gap-2",children:["Create Free Tier Combo",e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-semibold bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:"Zero-Cost Gateway"})]}),e.jsx("p",{className:"text-xs text-slate-400",children:"Bundle verified free models across providers into high-availability fallback combos."})]})]}),e.jsx("button",{type:"button",onClick:s,className:"p-1 rounded-lg text-slate-400 hover:text-white hover:bg-slate-800 transition-colors cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),e.jsxs("form",{onSubmit:R,className:"flex-1 flex flex-col min-h-0 pt-4 space-y-4",children:[e.jsx(we,{isMultiMode:m&&i!=="provider",onToggleMultiMode:k,canMultiMode:i!=="provider",comboName:o,onComboNameChange:w=>{c(w),O&&P(null)},namePrefix:d,onNamePrefixChange:y,strategy:a,onStrategyChange:r,activeGroupsCount:t.length}),e.jsx(Ne,{searchQuery:j,onSearchChange:$,onlyConnected:N,onToggleOnlyConnected:()=>A(!N),groupMode:i,onGroupModeChange:w=>{v(w),w==="provider"&&k(!1)},onlyMultiProvider:h,onToggleOnlyMultiProvider:()=>L(!h),onSelectConnectedOnly:D,onDeselectAll:()=>T(new Set),onTestAll:()=>Z(I.map(w=>w.provider.id)),isTestingAll:U}),e.jsx(Se,{groupMode:i,filteredProviders:f,groups:x,selectedModelValues:B,onToggleModel:u,onToggleAllProviderModels:C,onToggleAllGroupModels:E,isMultiMode:m,groupComboNames:q,onGroupComboNameChange:(w,S)=>_(M=>({...M,[w]:S})),onTestConnection:Q,testingIds:W}),O&&e.jsxs("div",{className:"p-3 rounded-xl bg-rose-500/10 border border-rose-500/20 text-rose-400 text-xs flex items-center gap-2 shrink-0",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"error"}),e.jsx("span",{children:O})]}),e.jsxs("div",{className:"pt-3 border-t border-[#1E293B] flex items-center justify-between gap-3 shrink-0",children:[e.jsxs("div",{className:"text-xs text-slate-400",children:["Selected: ",e.jsx("span",{className:"font-semibold text-emerald-400",children:B.size})," free model",B.size!==1?"s":"",m&&i!=="provider"&&t.length>0&&e.jsxs("span",{className:"ml-2 text-slate-500",children:["(",t.length," combo",t.length!==1?"s":"",")"]})]}),e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("button",{type:"button",onClick:s,className:"px-4 py-2 rounded-xl bg-slate-800 hover:bg-slate-700 text-xs font-semibold text-slate-300 transition-colors cursor-pointer",children:"Cancel"}),e.jsxs("button",{type:"submit",disabled:G||B.size===0,className:"px-4 py-2 rounded-xl bg-emerald-600 hover:bg-emerald-500 disabled:opacity-50 text-xs font-semibold text-white shadow-lg shadow-emerald-600/20 flex items-center gap-1.5 transition-all cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:G?"hourglass_empty":m&&t.length>1?"dynamic_feed":"check_circle"}),e.jsx("span",{children:m&&t.length>1?`Create ${t.length} Free Combos`:"Create Free Tier Combo"})]})]})]})]})]})},qe={vision:{enabled:!1,roundRobin:!1,models:[]},audioInput:{enabled:!1,roundRobin:!1,models:[]}},He=({onSelectCombo:l})=>{const[s,n]=b.useState([]),[p,g]=b.useState(!0),[o,c]=b.useState(qe),[d,y]=b.useState(!1),[a,r]=b.useState(null),[i,v]=b.useState(""),m=b.useMemo(()=>{const t=i.trim().toLowerCase(),u=[...s].sort((C,E)=>C.name.localeCompare(E.name,void 0,{sensitivity:"base"}));return t?u.filter(C=>!!(C.name.toLowerCase().includes(t)||C.strategy.toLowerCase().includes(t)||C.models&&C.models.some(E=>E.toLowerCase().includes(t)))):u},[s,i]),[k,h]=b.useState(!1),[L,j]=b.useState(!1),[$,N]=b.useState(null),[A,B]=b.useState(null),[T,q]=b.useState(null),_=b.useCallback(async()=>{try{g(!0);const t=await fetch("/api/combos");if(t.ok){const u=await t.json();Array.isArray(u)&&n(u)}}catch(t){console.error("Failed to load combos:",t)}finally{g(!1)}},[]),G=b.useCallback(async()=>{try{const t=await fetch("/api/settings/capacity-adapter");if(t.ok){const u=await t.json();u&&typeof u=="object"&&c({vision:u.vision||{enabled:!1,roundRobin:!1,models:[]},audioInput:u.audioInput||{enabled:!1,roundRobin:!1,models:[]},pdf:u.pdf,videoInput:u.videoInput})}}catch(t){console.error("Failed to load capacity adapter settings:",t)}},[]);b.useEffect(()=>{_(),G()},[_,G]);const z=async t=>{c(t);try{y(!0),await fetch("/api/settings/capacity-adapter",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch(u){console.error("Failed to save capacity adapter settings:",u)}finally{y(!1)}},O=t=>{const u=o[t];z({...o,[t]:{...u,enabled:!u.enabled}})},P=(t,u)=>{const C=o[t];z({...o,[t]:{...C,roundRobin:u}})},I=(t,u)=>{const C=o[t];z({...o,[t]:{...C,models:C.models.filter(E=>E!==u)}})},W=t=>{if(!A)return;const u=o[A];z({...o,[A]:{...u,models:t}}),B(null)},U=async t=>{if(t.id){const u=await fetch(`/api/combos/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t.name,models:t.models,strategy:t.strategy,isActive:t.isActive})});if(!u.ok){const C=await u.json();throw new Error(C.error||"Failed to update combo")}}else{const u=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t.name,models:t.models,strategy:t.strategy})});if(!u.ok){const C=await u.json();throw new Error(C.error||"Failed to create combo")}}await _(),J(),h(!1),N(null)},Q=async t=>{try{const u=await fetch(`/api/combos/${t.id}/toggle`,{method:"POST"});if(u.ok){const C=await u.json();n(E=>E.map(D=>D.id===t.id?C:D)),J()}}catch(u){console.error("Error toggling combo status:",u)}},Z=async(t,u)=>{try{const C=await fetch(`/api/combos/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({strategy:u})});if(C.ok){const E=await C.json();n(D=>D.map(R=>R.id===t.id?E:R)),J()}}catch(C){console.error("Error updating strategy:",C)}},f=t=>{q({title:"Delete Combo",message:`Are you sure you want to delete combo "${t.name}"? This action cannot be undone.`,confirmText:"Delete Combo",variant:"danger",onConfirm:async()=>{try{(await fetch(`/api/combos/${t.id}`,{method:"DELETE"})).ok&&(n(C=>C.filter(E=>E.id!==t.id)),J())}catch(u){console.error("Error deleting combo:",u)}finally{q(null)}}})},x=(t,u)=>{navigator.clipboard.writeText(t),r(u),setTimeout(()=>r(null),2e3)};return e.jsxs("div",{className:"space-y-8 w-full pb-16 animate-rt-fade-in",children:[e.jsxs("div",{className:"w-full p-5 rounded-2xl bg-[#0F1420]/80 border border-[#1E293B] space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-blue-400 text-[20px]",children:"hub"}),e.jsx("span",{className:"font-bold text-sm text-slate-100",children:"Smart Model Combos & Routing Strategies"})]}),e.jsxs("div",{className:"flex items-center gap-2.5 shrink-0",children:[e.jsxs("button",{type:"button",onClick:()=>j(!0),className:"px-4 py-2 rounded-xl bg-emerald-600 hover:bg-emerald-500 shadow-lg shadow-emerald-600/20 text-xs font-semibold text-white flex items-center gap-1.5 transition-all cursor-pointer shrink-0",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"savings"}),"Create Free Tier Combo"]}),e.jsxs("button",{type:"button",onClick:()=>{N(null),h(!0)},className:"px-4 py-2 rounded-xl bg-blue-600 hover:bg-blue-500 shadow-lg shadow-blue-600/20 text-xs font-semibold text-white flex items-center gap-1.5 transition-all cursor-pointer shrink-0",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"add_circle"}),"Create Combo"]})]})]}),e.jsx("p",{className:"text-xs text-slate-300 leading-relaxed",children:"Group multiple models and provider accounts under a single unified alias. Mapigate automatically manages fallbacks, load balances requests, or fuses multiple outputs together."}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 xl:grid-cols-5 gap-2.5 pt-1 text-[11px]",children:[e.jsxs("div",{className:"p-3 rounded-xl bg-[#0A0D14] border border-[#1E293B] space-y-1",children:[e.jsxs("span",{className:"text-blue-400 font-bold flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"low_priority"}),"Fallback Strategy"]}),e.jsx("p",{className:"text-slate-400",children:"Tries models in order; moves to backup on 429, 503, or quota limits."})]}),e.jsxs("div",{className:"p-3 rounded-xl bg-[#0A0D14] border border-[#1E293B] space-y-1",children:[e.jsxs("span",{className:"text-cyan-400 font-bold flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"sync"}),"Round Robin Strategy"]}),e.jsx("p",{className:"text-slate-400",children:"Spreads requests sequentially across accounts to maximize throughput."})]}),e.jsxs("div",{className:"p-3 rounded-xl bg-[#0A0D14] border border-[#1E293B] space-y-1",children:[e.jsxs("span",{className:"text-indigo-400 font-bold flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"call_split"}),"Fusion Strategy"]}),e.jsx("p",{className:"text-slate-400",children:"Queries models in parallel and synthesizes the best answer with a judge."})]}),e.jsxs("div",{className:"p-3 rounded-xl bg-[#0A0D14] border border-[#1E293B] space-y-1",children:[e.jsxs("span",{className:"text-emerald-400 font-bold flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"verified"}),"LKGP Strategy"]}),e.jsx("p",{className:"text-slate-400",children:"Sticks to last known good model for prompt cache warmth; fails over on error."})]}),e.jsxs("div",{className:"p-3 rounded-xl bg-[#0A0D14] border border-[#1E293B] space-y-1",children:[e.jsxs("span",{className:"text-amber-400 font-bold flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"balance"}),"P2C Strategy"]}),e.jsx("p",{className:"text-slate-400",children:"Samples 2 random models and picks the higher-scoring via EMA latency/error rate."})]})]})]}),e.jsxs("div",{className:"w-full space-y-3.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 px-1 text-xs text-slate-400",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-blue-400 text-[18px]",children:"layers"}),e.jsxs("span",{className:"font-bold text-white text-sm",children:["Configured Combos (",i?`${m.length} of ${s.length}`:s.length,")"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"material-symbols-outlined absolute left-2.5 top-1/2 -translate-y-1/2 text-slate-500 text-[16px]",children:"search"}),e.jsx("input",{type:"text",value:i,onChange:t=>v(t.target.value),placeholder:"Filter combos by name or model...",className:"pl-8 pr-7 py-1 text-xs bg-[#0F1420] border border-[#1E293B] rounded-xl text-white placeholder-slate-500 focus:outline-none focus:border-blue-500/50 w-52 sm:w-64 transition-all"}),i&&e.jsx("button",{type:"button",onClick:()=>v(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-slate-500 hover:text-white text-xs",children:e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),e.jsx("span",{className:"text-[11px] text-slate-500 hidden sm:inline",children:"Backed by SQLite"})]})]}),p?e.jsxs("div",{className:"w-full py-16 text-center text-slate-400 flex flex-col items-center justify-center gap-3 bg-[#0F1420]/40 rounded-2xl border border-[#1E293B]",children:[e.jsx("span",{className:"material-symbols-outlined text-3xl text-blue-400 animate-spin",children:"progress_activity"}),e.jsx("span",{className:"text-xs",children:"Loading combos from database..."})]}):s.length===0?e.jsxs("div",{className:"w-full py-16 text-center text-slate-400 flex flex-col items-center justify-center gap-3 bg-[#0F1420]/40 rounded-2xl border border-[#1E293B]",children:[e.jsx("span",{className:"material-symbols-outlined text-3xl text-slate-600",children:"layers_clear"}),e.jsx("p",{className:"text-sm font-semibold text-slate-300",children:"No combos configured in SQLite database yet"}),e.jsx("p",{className:"text-xs text-slate-500 max-w-md",children:"Click “Create Combo” to build your first multi-model cluster (e.g. combo/smart-coding). Tool-specific model aliases (sonnet, default...) are configured in the CLI Tools tab."})]}):m.length===0?e.jsxs("div",{className:"w-full py-12 text-center text-slate-400 flex flex-col items-center justify-center gap-2 bg-[#0F1420]/40 rounded-2xl border border-[#1E293B]",children:[e.jsx("span",{className:"material-symbols-outlined text-3xl text-slate-600",children:"search_off"}),e.jsxs("p",{className:"text-xs font-semibold text-slate-300",children:["No combos match “",i,"”"]}),e.jsx("button",{onClick:()=>v(""),className:"text-xs text-blue-400 hover:underline cursor-pointer",children:"Clear filter"})]}):e.jsx("div",{className:"w-full space-y-2.5",children:m.map((t,u)=>{const C=fe(t.models),E=t.isActive!==!1;return e.jsxs("div",{className:`w-full flex flex-wrap items-center justify-between gap-4 py-3.5 px-5 rounded-2xl border transition-all ${E?"bg-[#0F1420]/80 border-[#1E293B] hover:border-slate-700":"bg-[#0A0D14]/50 border-[#1E293B]/50 opacity-60"}`,style:{animationDelay:`${u*30}ms`},children:[e.jsxs("div",{className:"flex items-start sm:items-center gap-3.5 min-w-0 flex-1",children:[e.jsx("div",{className:`size-9 rounded-xl flex items-center justify-center shrink-0 border ${t.strategy==="fallback"?"bg-blue-500/10 text-blue-400 border-blue-500/20":t.strategy==="round-robin"?"bg-cyan-500/10 text-cyan-400 border-cyan-500/20":t.strategy==="fusion"?"bg-indigo-500/10 text-indigo-400 border-indigo-500/20":t.strategy==="lkgp"?"bg-emerald-500/10 text-emerald-400 border-emerald-500/20":"bg-amber-500/10 text-amber-400 border-amber-500/20"}`,children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:t.strategy==="fallback"?"low_priority":t.strategy==="round-robin"?"sync":t.strategy==="fusion"?"call_split":t.strategy==="lkgp"?"verified":"balance"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>l?l(t):(N(t),h(!0)),className:"text-xs font-bold text-white font-mono hover:text-blue-400 cursor-pointer transition-colors text-left",title:"Open combo details & manage models",children:t.name}),C&&e.jsx(te,{caps:C,size:"xs"}),(()=>{const D=new Set(t.models.map(R=>R.split("/")[0].replace(/\(.*?\)/,"").trim())).size;return e.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-[#161F30] border border-[#26354D] text-[10px] text-slate-400 font-medium",children:[t.models.length," ",t.models.length===1?"model":"models",D>0&&` · ${D} ${D===1?"provider":"providers"}`]})})(),!E&&e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-slate-800 text-slate-400 text-[10px] uppercase font-bold",children:"Disabled"})]}),(()=>{const R=i.trim().toLowerCase(),w=R?t.models.filter(F=>F.toLowerCase().includes(R)):[],S=R&&w.length>0?w.slice(0,4):t.models.slice(0,4),M=t.models.length-S.length;return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-1.5",children:[S.map((F,V)=>{const K=t.models.indexOf(F);return e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-lg bg-[#0A0D14] border border-[#1E293B] text-[11px] text-slate-300 font-mono",children:[e.jsx("span",{className:"text-[10px] text-blue-400 font-bold",children:K+1}),e.jsx("span",{className:"truncate max-w-[220px] sm:max-w-none",children:F})]},V)}),M>0&&e.jsxs("button",{type:"button",onClick:F=>{F.stopPropagation(),l?l(t):(N(t),h(!0))},className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-lg bg-blue-500/10 hover:bg-blue-500/20 text-[11px] text-blue-400 font-semibold border border-blue-500/25 transition-colors cursor-pointer",title:`Click to view and manage all ${t.models.length} models`,children:[e.jsxs("span",{children:["+",M," more"]}),e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"arrow_forward"})]})]})})()]})]}),e.jsxs("div",{className:"flex items-center gap-2.5 shrink-0",children:[e.jsx(X,{value:t.strategy,onChange:D=>Z(t,D),options:[{value:"round-robin",label:"Round Robin (rotate)"},{value:"fallback",label:"Fallback (try in order)"},{value:"fusion",label:"Fusion (parallel panel)"},{value:"lkgp",label:"LKGP (Last Known Good)"},{value:"p2c",label:"P2C (Power of Two Choices)"}],className:"min-w-[180px]"}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",title:E?"Disable combo":"Enable combo",children:[e.jsx("input",{type:"checkbox",checked:E,onChange:()=>Q(t),className:"sr-only peer"}),e.jsx("div",{className:"w-9 h-5 bg-[#1E293B] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-blue-600"})]}),e.jsxs("div",{className:"flex items-center gap-1 text-slate-400 border-l border-[#1E293B] pl-2",children:[e.jsx("button",{type:"button",title:"Manage models & details",onClick:()=>{l?l(t):(N(t),h(!0))},className:"p-1.5 rounded-lg hover:bg-blue-500/10 hover:text-blue-400 transition-colors cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"tune"})}),e.jsx("button",{type:"button",title:a===t.id?"Copied to clipboard!":"Copy combo identifier",onClick:()=>x(t.name,t.id),className:`p-1.5 rounded-lg transition-colors cursor-pointer ${a===t.id?"bg-emerald-500/20 text-emerald-400":"hover:bg-white/10 hover:text-white"}`,children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:a===t.id?"check":"content_copy"})}),e.jsx("button",{type:"button",title:"Edit combo",onClick:()=>{N(t),h(!0)},className:"p-1.5 rounded-lg hover:bg-white/10 hover:text-white transition-colors cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"edit"})}),e.jsx("button",{type:"button",title:"Delete combo",onClick:()=>f(t),className:"p-1.5 rounded-lg hover:bg-rose-500/10 hover:text-rose-400 transition-colors cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"delete"})})]})]})]},t.id)})})]}),e.jsxs("div",{className:"w-full space-y-4 pt-6 border-t border-[#1E293B]",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-cyan-400 text-[20px]",children:"visibility"}),"Multimodal Capacity Adapter"]}),e.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:"When client coding tools send image or audio prompts to models lacking those modalities, Mapigate seamlessly elevates designated adapter models to priority #1."})]}),d&&e.jsxs("span",{className:"text-[11px] text-blue-400 flex items-center gap-1 font-mono",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px] animate-spin",children:"progress_activity"}),"Syncing settings..."]})]}),e.jsxs("div",{className:"w-full grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"w-full p-5 rounded-2xl bg-[#0F1420]/80 border border-[#1E293B] flex flex-col justify-between gap-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",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:"image"})}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-bold text-white flex items-center gap-2",children:["Vision Input Adapter",e.jsx("span",{className:"px-1.5 py-0.2 rounded text-[10px] bg-cyan-500/10 text-cyan-400 border border-cyan-500/20",children:"Images & Screenshots"})]}),e.jsx("p",{className:"text-[11px] text-slate-400",children:"Auto-reroutes image payloads (png, jpg, webp, base64)"})]})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:o.vision.enabled,onChange:()=>O("vision"),className:"sr-only peer"}),e.jsx("div",{className:"w-10 h-5.5 bg-[#1E293B] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4.5 after:w-4.5 after:transition-all peer-checked:bg-cyan-600"})]})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs pt-1",children:[e.jsx("span",{className:"text-slate-400",children:"Adapter Pool Strategy:"}),e.jsx(X,{value:o.vision.roundRobin?"round-robin":"fallback",onChange:t=>P("vision",t==="round-robin"),options:[{value:"fallback",label:"Fallback (try in order)"},{value:"round-robin",label:"Round Robin (rotate)"}],className:"min-w-[170px]"})]})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px]",children:[e.jsxs("span",{className:"text-slate-400 font-semibold",children:["Vision Model Pool (",o.vision.models.length,")"]}),e.jsxs("button",{type:"button",onClick:()=>B("vision"),className:"px-2.5 py-1 rounded-lg bg-cyan-600/10 border border-cyan-500/30 text-cyan-400 hover:bg-cyan-600/20 font-medium flex items-center gap-1 transition-colors cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),"Manage Models"]})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5 min-h-[38px] p-2 rounded-xl bg-[#0A0D14] border border-[#1E293B]",children:o.vision.models.length===0?e.jsx("span",{className:"text-[11px] text-slate-500 italic",children:"No models in vision pool. Click Manage Models to add."}):o.vision.models.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-lg bg-[#141B2D] border border-cyan-500/20 text-[11px] text-cyan-300 font-mono",children:[e.jsx("span",{className:"size-1.5 rounded-full bg-cyan-400"}),e.jsx("span",{children:t}),e.jsx("button",{type:"button",onClick:()=>I("vision",t),className:"text-slate-500 hover:text-rose-400 cursor-pointer ml-0.5",title:"Remove model from pool",children:e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"close"})})]},t))})]})]}),e.jsxs("div",{className:"w-full p-5 rounded-2xl bg-[#0F1420]/80 border border-[#1E293B] flex flex-col justify-between gap-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",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:"graphic_eq"})}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-bold text-white flex items-center gap-2",children:["Audio Input Adapter",e.jsx("span",{className:"px-1.5 py-0.2 rounded text-[10px] bg-purple-500/10 text-purple-400 border border-purple-500/20",children:"Speech & Voice"})]}),e.jsx("p",{className:"text-[11px] text-slate-400",children:"Auto-reroutes speech and audio inputs to audio-capable models"})]})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:o.audioInput.enabled,onChange:()=>O("audioInput"),className:"sr-only peer"}),e.jsx("div",{className:"w-10 h-5.5 bg-[#1E293B] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4.5 after:w-4.5 after:transition-all peer-checked:bg-purple-600"})]})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs pt-1",children:[e.jsx("span",{className:"text-slate-400",children:"Adapter Pool Strategy:"}),e.jsx(X,{value:o.audioInput.roundRobin?"round-robin":"fallback",onChange:t=>P("audioInput",t==="round-robin"),options:[{value:"fallback",label:"Fallback (try in order)"},{value:"round-robin",label:"Round Robin (rotate)"}],className:"min-w-[170px]"})]})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px]",children:[e.jsxs("span",{className:"text-slate-400 font-semibold",children:["Audio Model Pool (",o.audioInput.models.length,")"]}),e.jsxs("button",{type:"button",onClick:()=>B("audioInput"),className:"px-2.5 py-1 rounded-lg bg-purple-600/10 border border-purple-500/30 text-purple-400 hover:bg-purple-600/20 font-medium flex items-center gap-1 transition-colors cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),"Manage Models"]})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5 min-h-[38px] p-2 rounded-xl bg-[#0A0D14] border border-[#1E293B]",children:o.audioInput.models.length===0?e.jsx("span",{className:"text-[11px] text-slate-500 italic",children:"No models in audio pool. Click Manage Models to add."}):o.audioInput.models.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-lg bg-[#141B2D] border border-purple-500/20 text-[11px] text-purple-300 font-mono",children:[e.jsx("span",{className:"size-1.5 rounded-full bg-purple-400"}),e.jsx("span",{children:t}),e.jsx("button",{type:"button",onClick:()=>I("audioInput",t),className:"text-slate-500 hover:text-rose-400 cursor-pointer ml-0.5",title:"Remove model from pool",children:e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"close"})})]},t))})]})]})]})]}),e.jsx(ve,{isOpen:k,onClose:()=>{h(!1),N(null)},combo:$,onSave:U}),e.jsx(ze,{isOpen:L,onClose:()=>j(!1),onSave:async t=>{await U({...t,isActive:!0})},onSaveBatch:async t=>{for(const u of t){const C=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:u.name,models:u.models,strategy:u.strategy})});if(!C.ok){const E=await C.json();throw new Error(E.error||`Failed to create combo ${u.name}`)}}await fetchCombos()},existingComboNames:s.map(t=>t.name)}),A&&e.jsx(se,{isOpen:A!==null,onClose:()=>B(null),title:`Configure ${A==="vision"?"Vision":"Audio"} Adapter Model Pool`,initialSelectedModels:o[A].models,onConfirm:W,filterModality:A==="vision"?"vision":"audio",multiSelect:!0}),T&&e.jsx(ge,{isOpen:T!==null,title:T.title,message:T.message,confirmText:T.confirmText||"Confirm",variant:T.variant||"primary",onConfirm:T.onConfirm,onCancel:()=>q(null)})]})};export{He as CombosTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-BcOI2aZ9.js";import{P as m}from"./index-
|
|
1
|
+
import{j as e}from"./vendor-BcOI2aZ9.js";import{P as m}from"./index-BvY11iVv.js";const h=({isOpen:r,title:s,message:o,confirmText:a="Confirm",cancelText:n="Cancel",confirmVariant:l="primary",variant:i,onConfirm:d,onCancel:t})=>{const x=i||l,c=()=>{switch(x){case"danger":return"bg-red-600 hover:bg-red-500 text-white";case"emerald":return"bg-emerald-600 hover:bg-emerald-500 text-white";default:return"bg-blue-600 hover:bg-blue-500 text-white"}};return e.jsx(m,{isOpen:r,onClose:t,maxWidthClass:"max-w-md",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-base font-semibold text-slate-100",children:s}),e.jsx("p",{className:"text-sm text-slate-300 leading-relaxed",children:o}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-3 border-t border-[#1E293B]",children:[e.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-xs font-medium text-slate-400 hover:text-white bg-[#141B2D] border border-[#1E293B] rounded-xl transition-colors cursor-pointer",children:n}),e.jsx("button",{type:"button",onClick:d,className:`px-4 py-2 text-xs font-medium rounded-xl transition-colors cursor-pointer ${c()}`,children:a})]})]})})};export{h as C};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as c,j as e,a as fe}from"./vendor-BcOI2aZ9.js";import{S as V}from"./Select-BNRH8LIG.js";import{L as ee,i as se,t as ge,P as je,f as X,g as re,u as Ne,R as ve,l as ye,X as de,h as ie,Z as xe,k as we,W as le,C as pe,D as Ce,A as Ee,a as Te,v as ke,S as Se,e as Ae,w as Le,x as ze}from"./lucide-Cc35htxl.js";import{T as me}from"./ToolIcon-Cp4gSgFt.js";import{u as ue,D as be,d as he,a as Be,c as Re,A as Oe}from"./index-CtfMJ11V.js";const Me=[{value:"trace",label:"TRACE (Max)",icon:e.jsx("span",{className:"size-2 rounded-full bg-purple-400 shadow-[0_0_6px_#c084fc]"})},{value:"debug",label:"DEBUG",icon:e.jsx("span",{className:"size-2 rounded-full bg-sky-400 shadow-[0_0_6px_#38bdf8]"})},{value:"info",label:"INFO (Default)",icon:e.jsx("span",{className:"size-2 rounded-full bg-emerald-400 shadow-[0_0_6px_#34d399]"})},{value:"warn",label:"WARN",icon:e.jsx("span",{className:"size-2 rounded-full bg-amber-400 shadow-[0_0_6px_#facc15]"})},{value:"error",label:"ERROR",icon:e.jsx("span",{className:"size-2 rounded-full bg-red-400 shadow-[0_0_6px_#f87171]"})}],$e=[{value:"errors_only",label:"Trace: Errors Only",icon:e.jsx("span",{className:"size-2 rounded-full bg-amber-400 shadow-[0_0_6px_#facc15]"})},{value:"all",label:"Trace: All Requests",icon:e.jsx("span",{className:"size-2 rounded-full bg-emerald-400 shadow-[0_0_6px_#34d399]"})},{value:"off",label:"Trace: Disabled (Off)",icon:e.jsx("span",{className:"size-2 rounded-full bg-slate-500"})}],Ie=({connected:t,totalCount:o,filteredCount:n,viewMode:s,onViewModeChange:w,categoryTab:f,onCategoryTabChange:u,searchQuery:b,onSearchQueryChange:p,clientToolFilter:C,onClientToolFilterChange:i,providerFilter:g,onProviderFilterChange:a,statusFilter:E,onStatusFilterChange:j,levelFilter:T,onLevelFilterChange:N,gatewayLogLevel:l,onGatewayLogLevelChange:k,observabilityMode:z,onObservabilityModeChange:S,autoScroll:L,onAutoScrollToggle:_,onCopy:B,copied:U,onClear:A,availableTools:J,availableProviders:q})=>{const D=c.useMemo(()=>[{value:"all",label:"Tool: All"},...J.map(m=>({value:m,label:`Tool: ${m}`}))],[J]),P=c.useMemo(()=>[{value:"all",label:"Provider: All"},...q.map(m=>({value:m,label:`Provider: ${m}`}))],[q]),F=c.useMemo(()=>[{value:"all",label:"Status: All"},{value:"200",label:"200 OK",icon:e.jsx("span",{className:"size-1.5 rounded-full bg-emerald-400"})},{value:"429",label:"429 Rate Limit",icon:e.jsx("span",{className:"size-1.5 rounded-full bg-amber-400"})},{value:"error",label:"5xx / Errors",icon:e.jsx("span",{className:"size-1.5 rounded-full bg-red-400"})}],[]),G=c.useMemo(()=>[{value:"all",label:"Level: All"},{value:"trace",label:"Trace only",icon:e.jsx("span",{className:"size-1.5 rounded-full bg-purple-400"})},{value:"debug",label:"Debug only",icon:e.jsx("span",{className:"size-1.5 rounded-full bg-sky-400"})},{value:"info",label:"Info only",icon:e.jsx("span",{className:"size-1.5 rounded-full bg-emerald-400"})},{value:"warn",label:"Warn only",icon:e.jsx("span",{className:"size-1.5 rounded-full bg-amber-400"})},{value:"error",label:"Error only",icon:e.jsx("span",{className:"size-1.5 rounded-full bg-red-400"})}],[]),R=C!=="all"||g!=="all"||E!=="all"||T!=="all"||b.trim()!=="",H=()=>{i("all"),a("all"),j("all"),N("all"),p("")};return e.jsxs("div",{className:"space-y-2.5 shrink-0",children:[e.jsxs("div",{className:"rt-card px-4 py-2.5 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1 rounded-lg bg-[#0A0D14] border border-[#1E293B]",children:[e.jsx("span",{className:`size-2 rounded-full ${t?"bg-emerald-400 shadow-[0_0_8px_#34d399]":"bg-red-500 animate-pulse"}`}),e.jsx("span",{className:"text-xs font-semibold text-slate-300",children:t?"Live Stream":"Disconnected"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-[#0A0D14] border border-[#1E293B] text-xs font-mono text-slate-400",children:[e.jsx("span",{className:"text-slate-200 font-semibold",children:n}),n!==o&&e.jsxs("span",{className:"text-slate-500",children:["/ ",o]}),e.jsx("span",{children:"logs"})]}),e.jsxs("div",{className:"flex items-center bg-[#0A0D14] p-0.5 rounded-lg border border-[#1E293B]",children:[e.jsxs("button",{type:"button",onClick:()=>w("structured"),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-semibold transition-colors cursor-pointer ${s==="structured"?"bg-blue-600 text-white shadow-xs":"text-slate-400 hover:text-slate-200"}`,children:[e.jsx(ee,{className:"size-3.5"}),e.jsx("span",{children:"AI Transactions"})]}),e.jsxs("button",{type:"button",onClick:()=>w("raw"),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-semibold transition-colors cursor-pointer ${s==="raw"?"bg-blue-600 text-white shadow-xs":"text-slate-400 hover:text-slate-200"}`,children:[e.jsx(se,{className:"size-3.5"}),e.jsx("span",{children:"Raw Terminal"})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold text-slate-400 shrink-0",children:"Log Level:"}),e.jsx(V,{value:l,onChange:k,options:Me,size:"sm",className:"min-w-[140px]",triggerClassName:"h-8 !py-1 !px-2.5 text-xs font-semibold rounded-lg bg-[#0A0D14] border-[#1E293B] hover:border-slate-700",menuClassName:"min-w-[145px] shadow-2xl border border-[#1E293B] bg-[#0A0D14]/95 backdrop-blur-xl"})]}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx(V,{value:z,onChange:m=>S(m),options:$e,size:"sm",className:"min-w-[170px]",triggerClassName:"h-8 !py-1 !px-2.5 text-xs font-semibold rounded-lg bg-[#0A0D14] border-[#1E293B] hover:border-slate-700",menuClassName:"min-w-[180px] shadow-2xl border border-[#1E293B] bg-[#0A0D14]/95 backdrop-blur-xl"})})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("button",{type:"button",onClick:_,className:`px-2.5 py-1 rounded-lg text-xs font-semibold border flex items-center gap-1.5 transition-colors cursor-pointer ${L?"bg-blue-500/10 text-blue-400 border-blue-500/30 hover:bg-blue-500/20":"bg-slate-800/40 text-slate-400 border-slate-700/60 hover:text-slate-200"}`,title:L?"Pause auto-scrolling":"Enable auto-scrolling",children:[L?e.jsx(ge,{className:"size-3.5"}):e.jsx(je,{className:"size-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:L?"Auto-scroll ON":"Paused"})]}),e.jsxs("button",{type:"button",onClick:B,disabled:n===0,className:"px-2.5 py-1 rounded-lg text-xs font-semibold bg-[#0A0D14] border border-[#1E293B] text-slate-300 hover:text-white hover:border-slate-600 disabled:opacity-40 disabled:cursor-not-allowed flex items-center gap-1.5 transition-colors cursor-pointer",title:"Copy logs",children:[U?e.jsx(X,{className:"size-3.5 text-emerald-400"}):e.jsx(re,{className:"size-3.5"}),e.jsx("span",{children:U?"Copied!":"Copy"})]}),e.jsxs("button",{type:"button",onClick:A,disabled:o===0,className:"px-2.5 py-1 rounded-lg text-xs font-semibold bg-red-500/10 border border-red-500/20 text-red-400 hover:bg-red-500/20 hover:border-red-500/40 disabled:opacity-40 disabled:cursor-not-allowed flex items-center gap-1.5 transition-colors cursor-pointer",title:"Clear all logs",children:[e.jsx(Ne,{className:"size-3.5"}),e.jsx("span",{children:"Clear"})]})]})]}),e.jsxs("div",{className:"rt-card px-4 py-2.5 flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"flex items-center gap-1 overflow-x-auto pb-1 sm:pb-0",children:[{id:"all",label:"All Logs"},{id:"proxy",label:"AI Requests"},{id:"stream",label:"Stream & Tools"},{id:"errors",label:"Errors & Warns"},{id:"system",label:"System & MITM"}].map(m=>e.jsx("button",{type:"button",onClick:()=>u(m.id),className:`px-3 py-1.5 rounded-lg text-xs font-medium transition-all cursor-pointer whitespace-nowrap ${f===m.id?"bg-blue-600/15 text-blue-400 font-semibold border border-blue-500/30 shadow-xs":"text-slate-400 hover:text-slate-200 hover:bg-white/[0.04] border border-transparent"}`,children:m.label},m.id))}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap flex-1 justify-end min-w-[280px]",children:[e.jsx(V,{value:C,onChange:i,options:D,size:"sm",className:"min-w-[115px]",triggerClassName:`h-8 !py-1 !px-2.5 text-xs font-medium rounded-lg transition-colors ${C!=="all"?"border-blue-500/50 bg-blue-500/10 text-blue-300 font-semibold":"border-[#1E293B] bg-[#0A0D14] text-slate-300 hover:border-slate-700"}`,menuClassName:"min-w-[130px] shadow-2xl border border-[#1E293B] bg-[#0A0D14]/95 backdrop-blur-xl"}),e.jsx(V,{value:g,onChange:a,options:P,size:"sm",className:"min-w-[125px]",triggerClassName:`h-8 !py-1 !px-2.5 text-xs font-medium rounded-lg transition-colors ${g!=="all"?"border-blue-500/50 bg-blue-500/10 text-blue-300 font-semibold":"border-[#1E293B] bg-[#0A0D14] text-slate-300 hover:border-slate-700"}`,menuClassName:"min-w-[140px] shadow-2xl border border-[#1E293B] bg-[#0A0D14]/95 backdrop-blur-xl"}),e.jsx(V,{value:E,onChange:j,options:F,size:"sm",className:"min-w-[115px]",triggerClassName:`h-8 !py-1 !px-2.5 text-xs font-medium rounded-lg transition-colors ${E!=="all"?"border-blue-500/50 bg-blue-500/10 text-blue-300 font-semibold":"border-[#1E293B] bg-[#0A0D14] text-slate-300 hover:border-slate-700"}`,menuClassName:"min-w-[130px] shadow-2xl border border-[#1E293B] bg-[#0A0D14]/95 backdrop-blur-xl"}),e.jsx(V,{value:T,onChange:N,options:G,size:"sm",className:"min-w-[115px]",triggerClassName:`h-8 !py-1 !px-2.5 text-xs font-medium rounded-lg transition-colors ${T!=="all"?"border-blue-500/50 bg-blue-500/10 text-blue-300 font-semibold":"border-[#1E293B] bg-[#0A0D14] text-slate-300 hover:border-slate-700"}`,menuClassName:"right-0 left-auto min-w-[130px] shadow-2xl border border-[#1E293B] bg-[#0A0D14]/95 backdrop-blur-xl"}),R&&e.jsxs("button",{type:"button",onClick:H,className:"h-8 px-2 py-1 rounded-lg text-xs font-semibold text-slate-400 hover:text-white hover:bg-slate-800/50 border border-transparent hover:border-slate-700 flex items-center gap-1 transition-colors cursor-pointer",title:"Reset all filters to default",children:[e.jsx(ve,{className:"size-3"}),e.jsx("span",{className:"hidden xl:inline",children:"Reset"})]}),e.jsxs("div",{className:"relative w-44 sm:w-52",children:[e.jsx(ye,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 size-3.5 text-slate-500"}),e.jsx("input",{type:"text",placeholder:"Search in logs...",value:b,onChange:m=>p(m.target.value),className:"h-8 w-full bg-[#0A0D14] border border-[#1E293B] rounded-lg pl-8 pr-7 text-xs text-white placeholder-slate-500 font-mono focus:outline-hidden focus:border-blue-500 focus:ring-2 focus:ring-blue-500/20 transition-all"}),b&&e.jsx("button",{type:"button",onClick:()=>p(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-slate-400 hover:text-white cursor-pointer",children:e.jsx(de,{className:"size-3"})})]})]})]})]})};function _e(t){const o=new Date(t),n=s=>String(s).padStart(2,"0");return`${n(o.getHours())}:${n(o.getMinutes())}:${n(o.getSeconds())}`}const De=({entry:t,onClick:o,isSelected:n=!1})=>{const{gateway:s,level:w,category:f,message:u,reqTag:b,timestamp:p,error:C}=t,i=(s==null?void 0:s.statusCode)||(C==null?void 0:C.status),g=i&&i>=200&&i<300,a=i===429,E=w==="error"||i&&i>=400&&!a,j=()=>a?e.jsx("span",{className:"px-2 py-0.5 rounded text-[11px] font-bold bg-amber-500/15 text-amber-400 border border-amber-500/30",children:"429"}):E?e.jsx("span",{className:"px-2 py-0.5 rounded text-[11px] font-bold bg-red-500/15 text-red-400 border border-red-500/30",children:i||"ERR"}):g?e.jsxs("span",{className:"px-2 py-0.5 rounded text-[11px] font-bold bg-emerald-500/15 text-emerald-400 border border-emerald-500/30",children:[i," OK"]}):null,T=()=>{switch(f){case"proxy":return"bg-blue-500/10 text-blue-400 border-blue-500/30";case"router":return"bg-purple-500/10 text-purple-400 border-purple-500/30";case"rtk":return"bg-emerald-500/10 text-emerald-400 border-emerald-500/30";case"mitm":return"bg-cyan-500/10 text-cyan-400 border-cyan-500/30";case"scheduler":return"bg-slate-700/30 text-slate-400 border-slate-700/50";default:return"bg-slate-800/40 text-slate-400 border-slate-700/60"}};return e.jsxs("div",{onClick:o,className:`group px-3.5 py-2.5 rounded-xl border transition-all cursor-pointer select-text ${n?"bg-[#131B2E] border-blue-500 shadow-md ring-1 ring-blue-500/20":"bg-[#0A0E18] hover:bg-[#0E1524] border-[#1E293B] hover:border-slate-700"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap min-w-0",children:[e.jsx("span",{className:"text-[11px] font-mono text-slate-500 shrink-0",children:_e(p)}),b&&e.jsx("span",{className:"text-xs shrink-0 select-none",children:b}),e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wider border shrink-0 ${T()}`,children:f}),w==="trace"&&e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono font-bold bg-purple-500/15 text-purple-400 border border-purple-500/30",children:"TRACE"}),w==="debug"&&e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono font-bold bg-sky-500/15 text-sky-400 border border-sky-500/30",children:"DEBUG"}),j(),(s==null?void 0:s.clientTool)&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-0.5 rounded-md bg-[#05070B] border border-[#1E293B]",children:[e.jsx(me,{name:s.clientTool,size:"sm",className:"size-4"}),e.jsx("span",{className:"text-xs font-semibold text-slate-300",children:s.clientTool})]}),((s==null?void 0:s.actualModel)||(s==null?void 0:s.requestedModel))&&e.jsxs("div",{className:"flex items-center gap-1 text-xs font-mono text-slate-300 truncate",children:[s.providerId&&e.jsxs("span",{className:"text-slate-500",children:[s.providerId,"/"]}),e.jsx("span",{className:"font-medium text-blue-300",children:s.actualModel||s.requestedModel})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0 ml-auto",children:[(s==null?void 0:s.durationMs)!==void 0&&e.jsxs("div",{className:"flex items-center gap-1 px-2 py-0.5 rounded-md bg-slate-900 border border-slate-800 text-[11px] font-mono text-slate-400",children:[e.jsx(ie,{className:"size-3 text-slate-500"}),e.jsxs("span",{children:[s.durationMs,"ms"]}),s.ttftMs!==void 0&&s.ttftMs>0&&e.jsxs("span",{className:"text-slate-500",children:["· TTFT ",s.ttftMs,"ms"]})]}),(s==null?void 0:s.tokens)&&e.jsxs("div",{className:"hidden sm:flex items-center gap-1 text-[11px] font-mono",children:[e.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-400 border border-blue-500/20",children:["IN ",s.tokens.prompt.toLocaleString(),s.tokens.cached?` (↻${s.tokens.cached.toLocaleString()})`:""]}),e.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:["OUT ",s.tokens.completion.toLocaleString()]}),s.tokens.savedByRtk?e.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20 flex items-center gap-0.5",children:[e.jsx(xe,{className:"size-2.5"}),e.jsxs("span",{children:["-",s.tokens.savedByRtk.toLocaleString()]})]}):null]}),(s==null?void 0:s.cost)!==void 0&&s.cost>0&&e.jsxs("span",{className:"hidden md:inline px-1.5 py-0.5 rounded bg-slate-800 border border-slate-700 text-[11px] font-mono text-slate-300 font-semibold",children:["$",s.cost<.01?s.cost.toFixed(4):s.cost.toFixed(3)]}),e.jsx(we,{className:"size-4 text-slate-600 group-hover:text-slate-400 transition-colors"})]})]}),e.jsxs("div",{className:"mt-1.5 flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-xs font-mono text-slate-400 truncate flex-1",children:u}),(s==null?void 0:s.tools)&&s.tools.length>0&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0 overflow-hidden",children:[s.tools.slice(0,3).map((N,l)=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-mono bg-purple-500/15 text-purple-300 border border-purple-500/30",children:[e.jsx(le,{className:"size-2.5"}),e.jsx("span",{className:"truncate max-w-[120px]",children:N.name})]},l)),s.tools.length>3&&e.jsxs("span",{className:"text-[10px] text-slate-500 font-mono",children:["+",s.tools.length-3]})]})]})]})};function Pe(t){const o=t.toUpperCase();return o.includes("[ERROR]")||o.includes("ERROR:")||o.includes("EXCEPTION")||t.includes("Error:")||t.includes("ERR!")||t.toLowerCase().includes("failed")||t.includes("💥")||t.includes("❌")?"text-red-400":o.includes("[WARN]")||o.includes("WARN:")||o.includes("WARNING:")||t.includes("⚠️")?"text-amber-400":o.includes("[INFO]")||o.includes("INFO:")||t.includes("ℹ️")?"text-blue-400":o.includes("[LOG]")||t.includes("🚀")||t.includes("📡")||t.includes("▶")||t.includes("✔")||t.includes("Gateway running")||t.includes("📊")?"text-emerald-400":o.includes("[DEBUG]")||t.includes("🔍")?"text-purple-400":"text-slate-300"}const Fe=({logs:t,filterText:o,scrollRef:n})=>{const s=ue(u=>u.info),w=(s==null?void 0:s.port)||be,f=(s==null?void 0:s.host)||he;return e.jsxs("div",{className:"flex-1 flex flex-col rounded-xl border border-[#1E293B] bg-[#05070B] overflow-hidden shadow-2xl min-h-0",children:[e.jsxs("div",{className:"bg-[#0A0D14] px-4 py-2 border-b border-[#1E293B] flex items-center justify-between shrink-0 select-none",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-3 rounded-full bg-[#EF4444]/80 inline-block"}),e.jsx("span",{className:"size-3 rounded-full bg-[#F59E0B]/80 inline-block"}),e.jsx("span",{className:"size-3 rounded-full bg-[#10B981]/80 inline-block"}),e.jsx("span",{className:"ml-2 text-[11px] font-mono text-slate-400",children:"mapigate-gateway > stdout / stderr"})]}),e.jsx("div",{className:"text-[10px] font-mono text-slate-500",children:"UTF-8 · Local Gateway"})]}),e.jsx("div",{ref:n,className:"flex-1 p-4 font-mono text-xs overflow-y-auto space-y-0.5 select-text",children:t.length===0?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-slate-500 py-16 space-y-2 select-none",children:[e.jsx(se,{className:"size-8 text-slate-600"}),e.jsx("p",{className:"text-xs",children:o.trim()?`No logs match "${o}"`:"No console logs yet. Gateway logs will stream here in real time."}),e.jsxs("span",{className:"text-[10px] text-slate-600 font-mono",children:["Listening on http://",f,":",w,"/api/console-logs/stream"]})]}):t.map((u,b)=>{const p=Pe(u);return e.jsxs("div",{className:`py-0.5 px-1.5 rounded flex items-start gap-2.5 hover:bg-white/[0.03] transition-colors leading-relaxed ${p}`,children:[e.jsx("span",{className:"text-slate-600 select-none text-[10px] w-9 text-right shrink-0 pt-0.5 font-mono",children:b+1}),e.jsx("span",{className:"break-all whitespace-pre-wrap flex-1",children:u})]},b)})})]})},Ue=({tokens:t})=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold text-slate-400 uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(pe,{className:"size-3.5 text-blue-400"})," Token Economics"]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2.5",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-[#0A0E18] border border-[#1E293B]",children:[e.jsx("span",{className:"text-[11px] text-slate-400",children:"Prompt Tokens"}),e.jsx("p",{className:"text-sm font-bold font-mono text-blue-400",children:t.prompt.toLocaleString()})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-[#0A0E18] border border-[#1E293B]",children:[e.jsx("span",{className:"text-[11px] text-slate-400",children:"Cached Tokens (↻)"}),e.jsx("p",{className:"text-sm font-bold font-mono text-cyan-400",children:(t.cached||0).toLocaleString()})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-[#0A0E18] border border-[#1E293B]",children:[e.jsx("span",{className:"text-[11px] text-slate-400",children:"Output Tokens"}),e.jsx("p",{className:"text-sm font-bold font-mono text-emerald-400",children:t.completion.toLocaleString()})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-[#0A0E18] border border-[#1E293B]",children:[e.jsx("span",{className:"text-[11px] text-slate-400",children:"Tokens Saved"}),e.jsxs("p",{className:"text-sm font-bold font-mono text-amber-400 flex items-center gap-1",children:[e.jsx(xe,{className:"size-3"}),(t.savedByRtk||0).toLocaleString()]})]})]})]}),Je=({tools:t})=>!t||t.length===0?null:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold text-slate-400 uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(le,{className:"size-3.5 text-purple-400"})," Tool Calls (",t.length,")"]}),e.jsx("div",{className:"space-y-2",children:t.map((o,n)=>e.jsxs("div",{className:"p-3 rounded-lg bg-[#0A0E18] border border-[#1E293B] flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"p-1 rounded bg-purple-500/20 text-purple-300",children:e.jsx(le,{className:"size-3.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-bold text-white font-mono truncate",children:o.name}),e.jsx("p",{className:"text-[11px] text-slate-400 font-mono truncate",children:o.summary})]})]}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-semibold bg-slate-800 text-slate-300 uppercase",children:o.type})]},n))})]}),qe=({detail:t,loading:o=!1})=>{var E,j,T,N,l,k,z,S,L;const[n,s]=c.useState("client"),[w,f]=c.useState(null),u=(_,B)=>{navigator.clipboard.writeText(_),f(B),setTimeout(()=>f(null),2e3)};if(o)return e.jsxs("div",{className:"p-6 rounded-xl bg-[#0A0E18] border border-[#1E293B] flex items-center justify-center gap-3 text-slate-400",children:[e.jsx("span",{className:"size-4 border-2 border-blue-400 border-t-transparent rounded-full animate-spin"}),e.jsx("span",{className:"text-xs font-mono",children:"Loading full payload observability trace..."})]});if(!t)return e.jsxs("div",{className:"p-5 rounded-xl bg-[#0A0E18] border border-[#1E293B] space-y-2 text-center select-none",children:[e.jsx(Ce,{className:"size-6 text-slate-500 mx-auto"}),e.jsx("p",{className:"text-xs font-semibold text-slate-300",children:"No payload trace snapshot found for this request"}),e.jsxs("p",{className:"text-[11px] text-slate-500 max-w-md mx-auto",children:["Observability trace is either set to ",e.jsx("strong",{className:"text-amber-400 font-mono",children:"Errors Only"})," (which bypasses successful 200 OK payloads) or ",e.jsx("strong",{className:"text-slate-400 font-mono",children:"Off"}),". Switch to ",e.jsx("strong",{className:"text-emerald-400 font-mono",children:"Trace: All"})," in the top toolbar to record all full payloads."]})]});const b=((E=t.request)==null?void 0:E.body)||{},p=((j=t.providerRequest)==null?void 0:j.body)||{},C=((T=t.response)==null?void 0:T.body)||((N=t.providerResponse)==null?void 0:N.body)||t.errorMessage||{},i=n==="client"?b:n==="providerReq"?p:C,g=n==="client"?(l=t.request)==null?void 0:l.headers:n==="providerReq"?(k=t.providerRequest)==null?void 0:k.headers:((z=t.response)==null?void 0:z.headers)||((S=t.providerResponse)==null?void 0:S.headers),a=JSON.stringify(i,null,2);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1 bg-[#05070B] p-1 rounded-lg border border-[#1E293B]",children:[e.jsxs("button",{type:"button",onClick:()=>s("client"),className:`flex items-center gap-1.5 px-3 py-1 rounded text-xs font-semibold transition-all cursor-pointer ${n==="client"?"bg-blue-600 text-white shadow-xs":"text-slate-400 hover:text-slate-200"}`,children:[e.jsx(Ee,{className:"size-3.5"}),e.jsx("span",{children:"Client Inbound"})]}),e.jsxs("button",{type:"button",onClick:()=>s("providerReq"),className:`flex items-center gap-1.5 px-3 py-1 rounded text-xs font-semibold transition-all cursor-pointer ${n==="providerReq"?"bg-blue-600 text-white shadow-xs":"text-slate-400 hover:text-slate-200"}`,children:[e.jsx(Te,{className:"size-3.5"}),e.jsx("span",{children:"Provider Transformed"})]}),e.jsxs("button",{type:"button",onClick:()=>s("response"),className:`flex items-center gap-1.5 px-3 py-1 rounded text-xs font-semibold transition-all cursor-pointer ${n==="response"?"bg-blue-600 text-white shadow-xs":"text-slate-400 hover:text-slate-200"}`,children:[e.jsx(ke,{className:"size-3.5"}),e.jsx("span",{children:"Response & Output"})]})]}),e.jsx("button",{type:"button",onClick:()=>u(a,n),className:"px-2.5 py-1 rounded-md bg-[#0A0E18] border border-[#1E293B] text-slate-300 hover:text-white flex items-center gap-1.5 transition-colors text-xs cursor-pointer",children:w===n?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"size-3.5 text-emerald-400"}),e.jsx("span",{children:"Copied JSON"})]}):e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"size-3.5"}),e.jsx("span",{children:"Copy JSON"})]})})]}),n==="providerReq"&&((L=t.providerRequest)==null?void 0:L.url)&&e.jsxs("div",{className:"px-3 py-1.5 rounded-lg bg-[#05070B] border border-[#1E293B] text-[11px] font-mono text-slate-400 flex items-center gap-2",children:[e.jsx("span",{className:"text-slate-500 uppercase font-bold text-[10px]",children:"URL:"}),e.jsx("span",{className:"text-blue-300 truncate",children:t.providerRequest.url})]}),g&&Object.keys(g).length>0&&e.jsxs("details",{className:"rounded-lg bg-[#05070B] border border-[#1E293B] text-[11px] font-mono text-slate-400 overflow-hidden",children:[e.jsx("summary",{className:"px-3 py-1.5 cursor-pointer hover:text-slate-200 select-none flex items-center justify-between",children:e.jsxs("span",{className:"font-semibold text-slate-300",children:["Headers (",Object.keys(g).length,")"]})}),e.jsx("div",{className:"p-3 border-t border-[#1E293B] bg-black/40 max-h-36 overflow-y-auto",children:e.jsx("pre",{className:"text-[10px] text-slate-300 whitespace-pre-wrap",children:JSON.stringify(g,null,2)})})]}),e.jsx("div",{className:"rounded-xl bg-[#05070B] border border-[#1E293B] p-3 max-h-96 overflow-y-auto font-mono text-[11px] text-slate-200 leading-relaxed",children:a&&a!=="{}"?e.jsx("pre",{className:"whitespace-pre-wrap break-all select-text",children:a}):e.jsx("span",{className:"text-slate-500 italic",children:"No JSON payload body captured for this section."})})]})},Ge=({entry:t,isOpen:o,onClose:n})=>{var R,H,m,$,Y;const s=ue(v=>v.info),w=(s==null?void 0:s.port)||be,f=(s==null?void 0:s.host)||he,[u,b]=c.useState(!1),[p,C]=c.useState(!1),[i,g]=c.useState(!1),[a,E]=c.useState(null),[j,T]=c.useState(!1),{backdropProps:N}=Be(n,!o);if(c.useEffect(()=>{if(!o)return;const v=O=>{O.key==="Escape"&&n()};document.addEventListener("keydown",v);const y=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",v),document.body.style.overflow=y}},[o,n]),c.useEffect(()=>{if(!o||!t){E(null);return}const v=t.requestId||t.id;if(!v){E(null);return}let y=!0;return T(!0),fetch(`/api/usage/request-details/${encodeURIComponent(v)}`).then(O=>O.ok?O.json():null).then(O=>{y&&(E(O),T(!1))}).catch(()=>{y&&T(!1)}),()=>{y=!1}},[o,t]),!o||!t||typeof document>"u")return null;const{gateway:l,error:k,level:z,category:S,rawText:L,reqTag:_,id:B,requestId:U}=t,A=(l==null?void 0:l.statusCode)||(k==null?void 0:k.status)||(a==null?void 0:a.status),J=A===429,q=z==="error"||typeof A=="number"&&A>=400&&!J,D=typeof A=="number"&&A>=200&&A<300,P=S==="proxy"||!!l||!!a||!!t.requestId,F=(v,y)=>{navigator.clipboard.writeText(v),y==="id"?(b(!0),setTimeout(()=>b(!1),2e3)):y==="json"?(C(!0),setTimeout(()=>C(!1),2e3)):y==="curl"&&(g(!0),setTimeout(()=>g(!1),2e3))},G=()=>{var Z;const v=(l==null?void 0:l.route)||"/v1/messages",y=(l==null?void 0:l.actualModel)||(l==null?void 0:l.requestedModel)||(a==null?void 0:a.model)||"claude-3-7-sonnet",O=((Z=a==null?void 0:a.request)==null?void 0:Z.body)||{model:y,messages:[{role:"user",content:"Hello"}]},te=JSON.stringify(O,null,2).replace(/'/g,"'\\''");return`curl -X POST http://${f}:${w}${v} \\
|
|
1
|
+
import{r as c,j as e,a as fe}from"./vendor-BcOI2aZ9.js";import{S as V}from"./Select-BNRH8LIG.js";import{L as ee,i as se,t as ge,P as je,f as X,g as re,u as Ne,R as ve,l as ye,X as de,h as ie,Z as xe,k as we,W as le,C as pe,D as Ce,A as Ee,a as Te,v as ke,S as Se,e as Ae,w as Le,x as ze}from"./lucide-Cc35htxl.js";import{T as me}from"./ToolIcon-BZE0Fv7L.js";import{u as ue,D as be,d as he,a as Be,c as Re,A as Oe}from"./index-BvY11iVv.js";const Me=[{value:"trace",label:"TRACE (Max)",icon:e.jsx("span",{className:"size-2 rounded-full bg-purple-400 shadow-[0_0_6px_#c084fc]"})},{value:"debug",label:"DEBUG",icon:e.jsx("span",{className:"size-2 rounded-full bg-sky-400 shadow-[0_0_6px_#38bdf8]"})},{value:"info",label:"INFO (Default)",icon:e.jsx("span",{className:"size-2 rounded-full bg-emerald-400 shadow-[0_0_6px_#34d399]"})},{value:"warn",label:"WARN",icon:e.jsx("span",{className:"size-2 rounded-full bg-amber-400 shadow-[0_0_6px_#facc15]"})},{value:"error",label:"ERROR",icon:e.jsx("span",{className:"size-2 rounded-full bg-red-400 shadow-[0_0_6px_#f87171]"})}],$e=[{value:"errors_only",label:"Trace: Errors Only",icon:e.jsx("span",{className:"size-2 rounded-full bg-amber-400 shadow-[0_0_6px_#facc15]"})},{value:"all",label:"Trace: All Requests",icon:e.jsx("span",{className:"size-2 rounded-full bg-emerald-400 shadow-[0_0_6px_#34d399]"})},{value:"off",label:"Trace: Disabled (Off)",icon:e.jsx("span",{className:"size-2 rounded-full bg-slate-500"})}],Ie=({connected:t,totalCount:o,filteredCount:n,viewMode:s,onViewModeChange:w,categoryTab:f,onCategoryTabChange:u,searchQuery:b,onSearchQueryChange:p,clientToolFilter:C,onClientToolFilterChange:i,providerFilter:g,onProviderFilterChange:a,statusFilter:E,onStatusFilterChange:j,levelFilter:T,onLevelFilterChange:N,gatewayLogLevel:l,onGatewayLogLevelChange:k,observabilityMode:z,onObservabilityModeChange:S,autoScroll:L,onAutoScrollToggle:_,onCopy:B,copied:U,onClear:A,availableTools:J,availableProviders:q})=>{const D=c.useMemo(()=>[{value:"all",label:"Tool: All"},...J.map(m=>({value:m,label:`Tool: ${m}`}))],[J]),P=c.useMemo(()=>[{value:"all",label:"Provider: All"},...q.map(m=>({value:m,label:`Provider: ${m}`}))],[q]),F=c.useMemo(()=>[{value:"all",label:"Status: All"},{value:"200",label:"200 OK",icon:e.jsx("span",{className:"size-1.5 rounded-full bg-emerald-400"})},{value:"429",label:"429 Rate Limit",icon:e.jsx("span",{className:"size-1.5 rounded-full bg-amber-400"})},{value:"error",label:"5xx / Errors",icon:e.jsx("span",{className:"size-1.5 rounded-full bg-red-400"})}],[]),G=c.useMemo(()=>[{value:"all",label:"Level: All"},{value:"trace",label:"Trace only",icon:e.jsx("span",{className:"size-1.5 rounded-full bg-purple-400"})},{value:"debug",label:"Debug only",icon:e.jsx("span",{className:"size-1.5 rounded-full bg-sky-400"})},{value:"info",label:"Info only",icon:e.jsx("span",{className:"size-1.5 rounded-full bg-emerald-400"})},{value:"warn",label:"Warn only",icon:e.jsx("span",{className:"size-1.5 rounded-full bg-amber-400"})},{value:"error",label:"Error only",icon:e.jsx("span",{className:"size-1.5 rounded-full bg-red-400"})}],[]),R=C!=="all"||g!=="all"||E!=="all"||T!=="all"||b.trim()!=="",H=()=>{i("all"),a("all"),j("all"),N("all"),p("")};return e.jsxs("div",{className:"space-y-2.5 shrink-0",children:[e.jsxs("div",{className:"rt-card px-4 py-2.5 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1 rounded-lg bg-[#0A0D14] border border-[#1E293B]",children:[e.jsx("span",{className:`size-2 rounded-full ${t?"bg-emerald-400 shadow-[0_0_8px_#34d399]":"bg-red-500 animate-pulse"}`}),e.jsx("span",{className:"text-xs font-semibold text-slate-300",children:t?"Live Stream":"Disconnected"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-[#0A0D14] border border-[#1E293B] text-xs font-mono text-slate-400",children:[e.jsx("span",{className:"text-slate-200 font-semibold",children:n}),n!==o&&e.jsxs("span",{className:"text-slate-500",children:["/ ",o]}),e.jsx("span",{children:"logs"})]}),e.jsxs("div",{className:"flex items-center bg-[#0A0D14] p-0.5 rounded-lg border border-[#1E293B]",children:[e.jsxs("button",{type:"button",onClick:()=>w("structured"),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-semibold transition-colors cursor-pointer ${s==="structured"?"bg-blue-600 text-white shadow-xs":"text-slate-400 hover:text-slate-200"}`,children:[e.jsx(ee,{className:"size-3.5"}),e.jsx("span",{children:"AI Transactions"})]}),e.jsxs("button",{type:"button",onClick:()=>w("raw"),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-semibold transition-colors cursor-pointer ${s==="raw"?"bg-blue-600 text-white shadow-xs":"text-slate-400 hover:text-slate-200"}`,children:[e.jsx(se,{className:"size-3.5"}),e.jsx("span",{children:"Raw Terminal"})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold text-slate-400 shrink-0",children:"Log Level:"}),e.jsx(V,{value:l,onChange:k,options:Me,size:"sm",className:"min-w-[140px]",triggerClassName:"h-8 !py-1 !px-2.5 text-xs font-semibold rounded-lg bg-[#0A0D14] border-[#1E293B] hover:border-slate-700",menuClassName:"min-w-[145px] shadow-2xl border border-[#1E293B] bg-[#0A0D14]/95 backdrop-blur-xl"})]}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx(V,{value:z,onChange:m=>S(m),options:$e,size:"sm",className:"min-w-[170px]",triggerClassName:"h-8 !py-1 !px-2.5 text-xs font-semibold rounded-lg bg-[#0A0D14] border-[#1E293B] hover:border-slate-700",menuClassName:"min-w-[180px] shadow-2xl border border-[#1E293B] bg-[#0A0D14]/95 backdrop-blur-xl"})})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("button",{type:"button",onClick:_,className:`px-2.5 py-1 rounded-lg text-xs font-semibold border flex items-center gap-1.5 transition-colors cursor-pointer ${L?"bg-blue-500/10 text-blue-400 border-blue-500/30 hover:bg-blue-500/20":"bg-slate-800/40 text-slate-400 border-slate-700/60 hover:text-slate-200"}`,title:L?"Pause auto-scrolling":"Enable auto-scrolling",children:[L?e.jsx(ge,{className:"size-3.5"}):e.jsx(je,{className:"size-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:L?"Auto-scroll ON":"Paused"})]}),e.jsxs("button",{type:"button",onClick:B,disabled:n===0,className:"px-2.5 py-1 rounded-lg text-xs font-semibold bg-[#0A0D14] border border-[#1E293B] text-slate-300 hover:text-white hover:border-slate-600 disabled:opacity-40 disabled:cursor-not-allowed flex items-center gap-1.5 transition-colors cursor-pointer",title:"Copy logs",children:[U?e.jsx(X,{className:"size-3.5 text-emerald-400"}):e.jsx(re,{className:"size-3.5"}),e.jsx("span",{children:U?"Copied!":"Copy"})]}),e.jsxs("button",{type:"button",onClick:A,disabled:o===0,className:"px-2.5 py-1 rounded-lg text-xs font-semibold bg-red-500/10 border border-red-500/20 text-red-400 hover:bg-red-500/20 hover:border-red-500/40 disabled:opacity-40 disabled:cursor-not-allowed flex items-center gap-1.5 transition-colors cursor-pointer",title:"Clear all logs",children:[e.jsx(Ne,{className:"size-3.5"}),e.jsx("span",{children:"Clear"})]})]})]}),e.jsxs("div",{className:"rt-card px-4 py-2.5 flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"flex items-center gap-1 overflow-x-auto pb-1 sm:pb-0",children:[{id:"all",label:"All Logs"},{id:"proxy",label:"AI Requests"},{id:"stream",label:"Stream & Tools"},{id:"errors",label:"Errors & Warns"},{id:"system",label:"System & MITM"}].map(m=>e.jsx("button",{type:"button",onClick:()=>u(m.id),className:`px-3 py-1.5 rounded-lg text-xs font-medium transition-all cursor-pointer whitespace-nowrap ${f===m.id?"bg-blue-600/15 text-blue-400 font-semibold border border-blue-500/30 shadow-xs":"text-slate-400 hover:text-slate-200 hover:bg-white/[0.04] border border-transparent"}`,children:m.label},m.id))}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap flex-1 justify-end min-w-[280px]",children:[e.jsx(V,{value:C,onChange:i,options:D,size:"sm",className:"min-w-[115px]",triggerClassName:`h-8 !py-1 !px-2.5 text-xs font-medium rounded-lg transition-colors ${C!=="all"?"border-blue-500/50 bg-blue-500/10 text-blue-300 font-semibold":"border-[#1E293B] bg-[#0A0D14] text-slate-300 hover:border-slate-700"}`,menuClassName:"min-w-[130px] shadow-2xl border border-[#1E293B] bg-[#0A0D14]/95 backdrop-blur-xl"}),e.jsx(V,{value:g,onChange:a,options:P,size:"sm",className:"min-w-[125px]",triggerClassName:`h-8 !py-1 !px-2.5 text-xs font-medium rounded-lg transition-colors ${g!=="all"?"border-blue-500/50 bg-blue-500/10 text-blue-300 font-semibold":"border-[#1E293B] bg-[#0A0D14] text-slate-300 hover:border-slate-700"}`,menuClassName:"min-w-[140px] shadow-2xl border border-[#1E293B] bg-[#0A0D14]/95 backdrop-blur-xl"}),e.jsx(V,{value:E,onChange:j,options:F,size:"sm",className:"min-w-[115px]",triggerClassName:`h-8 !py-1 !px-2.5 text-xs font-medium rounded-lg transition-colors ${E!=="all"?"border-blue-500/50 bg-blue-500/10 text-blue-300 font-semibold":"border-[#1E293B] bg-[#0A0D14] text-slate-300 hover:border-slate-700"}`,menuClassName:"min-w-[130px] shadow-2xl border border-[#1E293B] bg-[#0A0D14]/95 backdrop-blur-xl"}),e.jsx(V,{value:T,onChange:N,options:G,size:"sm",className:"min-w-[115px]",triggerClassName:`h-8 !py-1 !px-2.5 text-xs font-medium rounded-lg transition-colors ${T!=="all"?"border-blue-500/50 bg-blue-500/10 text-blue-300 font-semibold":"border-[#1E293B] bg-[#0A0D14] text-slate-300 hover:border-slate-700"}`,menuClassName:"right-0 left-auto min-w-[130px] shadow-2xl border border-[#1E293B] bg-[#0A0D14]/95 backdrop-blur-xl"}),R&&e.jsxs("button",{type:"button",onClick:H,className:"h-8 px-2 py-1 rounded-lg text-xs font-semibold text-slate-400 hover:text-white hover:bg-slate-800/50 border border-transparent hover:border-slate-700 flex items-center gap-1 transition-colors cursor-pointer",title:"Reset all filters to default",children:[e.jsx(ve,{className:"size-3"}),e.jsx("span",{className:"hidden xl:inline",children:"Reset"})]}),e.jsxs("div",{className:"relative w-44 sm:w-52",children:[e.jsx(ye,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 size-3.5 text-slate-500"}),e.jsx("input",{type:"text",placeholder:"Search in logs...",value:b,onChange:m=>p(m.target.value),className:"h-8 w-full bg-[#0A0D14] border border-[#1E293B] rounded-lg pl-8 pr-7 text-xs text-white placeholder-slate-500 font-mono focus:outline-hidden focus:border-blue-500 focus:ring-2 focus:ring-blue-500/20 transition-all"}),b&&e.jsx("button",{type:"button",onClick:()=>p(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-slate-400 hover:text-white cursor-pointer",children:e.jsx(de,{className:"size-3"})})]})]})]})]})};function _e(t){const o=new Date(t),n=s=>String(s).padStart(2,"0");return`${n(o.getHours())}:${n(o.getMinutes())}:${n(o.getSeconds())}`}const De=({entry:t,onClick:o,isSelected:n=!1})=>{const{gateway:s,level:w,category:f,message:u,reqTag:b,timestamp:p,error:C}=t,i=(s==null?void 0:s.statusCode)||(C==null?void 0:C.status),g=i&&i>=200&&i<300,a=i===429,E=w==="error"||i&&i>=400&&!a,j=()=>a?e.jsx("span",{className:"px-2 py-0.5 rounded text-[11px] font-bold bg-amber-500/15 text-amber-400 border border-amber-500/30",children:"429"}):E?e.jsx("span",{className:"px-2 py-0.5 rounded text-[11px] font-bold bg-red-500/15 text-red-400 border border-red-500/30",children:i||"ERR"}):g?e.jsxs("span",{className:"px-2 py-0.5 rounded text-[11px] font-bold bg-emerald-500/15 text-emerald-400 border border-emerald-500/30",children:[i," OK"]}):null,T=()=>{switch(f){case"proxy":return"bg-blue-500/10 text-blue-400 border-blue-500/30";case"router":return"bg-purple-500/10 text-purple-400 border-purple-500/30";case"rtk":return"bg-emerald-500/10 text-emerald-400 border-emerald-500/30";case"mitm":return"bg-cyan-500/10 text-cyan-400 border-cyan-500/30";case"scheduler":return"bg-slate-700/30 text-slate-400 border-slate-700/50";default:return"bg-slate-800/40 text-slate-400 border-slate-700/60"}};return e.jsxs("div",{onClick:o,className:`group px-3.5 py-2.5 rounded-xl border transition-all cursor-pointer select-text ${n?"bg-[#131B2E] border-blue-500 shadow-md ring-1 ring-blue-500/20":"bg-[#0A0E18] hover:bg-[#0E1524] border-[#1E293B] hover:border-slate-700"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap min-w-0",children:[e.jsx("span",{className:"text-[11px] font-mono text-slate-500 shrink-0",children:_e(p)}),b&&e.jsx("span",{className:"text-xs shrink-0 select-none",children:b}),e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wider border shrink-0 ${T()}`,children:f}),w==="trace"&&e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono font-bold bg-purple-500/15 text-purple-400 border border-purple-500/30",children:"TRACE"}),w==="debug"&&e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono font-bold bg-sky-500/15 text-sky-400 border border-sky-500/30",children:"DEBUG"}),j(),(s==null?void 0:s.clientTool)&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-0.5 rounded-md bg-[#05070B] border border-[#1E293B]",children:[e.jsx(me,{name:s.clientTool,size:"sm",className:"size-4"}),e.jsx("span",{className:"text-xs font-semibold text-slate-300",children:s.clientTool})]}),((s==null?void 0:s.actualModel)||(s==null?void 0:s.requestedModel))&&e.jsxs("div",{className:"flex items-center gap-1 text-xs font-mono text-slate-300 truncate",children:[s.providerId&&e.jsxs("span",{className:"text-slate-500",children:[s.providerId,"/"]}),e.jsx("span",{className:"font-medium text-blue-300",children:s.actualModel||s.requestedModel})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0 ml-auto",children:[(s==null?void 0:s.durationMs)!==void 0&&e.jsxs("div",{className:"flex items-center gap-1 px-2 py-0.5 rounded-md bg-slate-900 border border-slate-800 text-[11px] font-mono text-slate-400",children:[e.jsx(ie,{className:"size-3 text-slate-500"}),e.jsxs("span",{children:[s.durationMs,"ms"]}),s.ttftMs!==void 0&&s.ttftMs>0&&e.jsxs("span",{className:"text-slate-500",children:["· TTFT ",s.ttftMs,"ms"]})]}),(s==null?void 0:s.tokens)&&e.jsxs("div",{className:"hidden sm:flex items-center gap-1 text-[11px] font-mono",children:[e.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-400 border border-blue-500/20",children:["IN ",s.tokens.prompt.toLocaleString(),s.tokens.cached?` (↻${s.tokens.cached.toLocaleString()})`:""]}),e.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:["OUT ",s.tokens.completion.toLocaleString()]}),s.tokens.savedByRtk?e.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20 flex items-center gap-0.5",children:[e.jsx(xe,{className:"size-2.5"}),e.jsxs("span",{children:["-",s.tokens.savedByRtk.toLocaleString()]})]}):null]}),(s==null?void 0:s.cost)!==void 0&&s.cost>0&&e.jsxs("span",{className:"hidden md:inline px-1.5 py-0.5 rounded bg-slate-800 border border-slate-700 text-[11px] font-mono text-slate-300 font-semibold",children:["$",s.cost<.01?s.cost.toFixed(4):s.cost.toFixed(3)]}),e.jsx(we,{className:"size-4 text-slate-600 group-hover:text-slate-400 transition-colors"})]})]}),e.jsxs("div",{className:"mt-1.5 flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-xs font-mono text-slate-400 truncate flex-1",children:u}),(s==null?void 0:s.tools)&&s.tools.length>0&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0 overflow-hidden",children:[s.tools.slice(0,3).map((N,l)=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-mono bg-purple-500/15 text-purple-300 border border-purple-500/30",children:[e.jsx(le,{className:"size-2.5"}),e.jsx("span",{className:"truncate max-w-[120px]",children:N.name})]},l)),s.tools.length>3&&e.jsxs("span",{className:"text-[10px] text-slate-500 font-mono",children:["+",s.tools.length-3]})]})]})]})};function Pe(t){const o=t.toUpperCase();return o.includes("[ERROR]")||o.includes("ERROR:")||o.includes("EXCEPTION")||t.includes("Error:")||t.includes("ERR!")||t.toLowerCase().includes("failed")||t.includes("💥")||t.includes("❌")?"text-red-400":o.includes("[WARN]")||o.includes("WARN:")||o.includes("WARNING:")||t.includes("⚠️")?"text-amber-400":o.includes("[INFO]")||o.includes("INFO:")||t.includes("ℹ️")?"text-blue-400":o.includes("[LOG]")||t.includes("🚀")||t.includes("📡")||t.includes("▶")||t.includes("✔")||t.includes("Gateway running")||t.includes("📊")?"text-emerald-400":o.includes("[DEBUG]")||t.includes("🔍")?"text-purple-400":"text-slate-300"}const Fe=({logs:t,filterText:o,scrollRef:n})=>{const s=ue(u=>u.info),w=(s==null?void 0:s.port)||be,f=(s==null?void 0:s.host)||he;return e.jsxs("div",{className:"flex-1 flex flex-col rounded-xl border border-[#1E293B] bg-[#05070B] overflow-hidden shadow-2xl min-h-0",children:[e.jsxs("div",{className:"bg-[#0A0D14] px-4 py-2 border-b border-[#1E293B] flex items-center justify-between shrink-0 select-none",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-3 rounded-full bg-[#EF4444]/80 inline-block"}),e.jsx("span",{className:"size-3 rounded-full bg-[#F59E0B]/80 inline-block"}),e.jsx("span",{className:"size-3 rounded-full bg-[#10B981]/80 inline-block"}),e.jsx("span",{className:"ml-2 text-[11px] font-mono text-slate-400",children:"mapigate-gateway > stdout / stderr"})]}),e.jsx("div",{className:"text-[10px] font-mono text-slate-500",children:"UTF-8 · Local Gateway"})]}),e.jsx("div",{ref:n,className:"flex-1 p-4 font-mono text-xs overflow-y-auto space-y-0.5 select-text",children:t.length===0?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-slate-500 py-16 space-y-2 select-none",children:[e.jsx(se,{className:"size-8 text-slate-600"}),e.jsx("p",{className:"text-xs",children:o.trim()?`No logs match "${o}"`:"No console logs yet. Gateway logs will stream here in real time."}),e.jsxs("span",{className:"text-[10px] text-slate-600 font-mono",children:["Listening on http://",f,":",w,"/api/console-logs/stream"]})]}):t.map((u,b)=>{const p=Pe(u);return e.jsxs("div",{className:`py-0.5 px-1.5 rounded flex items-start gap-2.5 hover:bg-white/[0.03] transition-colors leading-relaxed ${p}`,children:[e.jsx("span",{className:"text-slate-600 select-none text-[10px] w-9 text-right shrink-0 pt-0.5 font-mono",children:b+1}),e.jsx("span",{className:"break-all whitespace-pre-wrap flex-1",children:u})]},b)})})]})},Ue=({tokens:t})=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold text-slate-400 uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(pe,{className:"size-3.5 text-blue-400"})," Token Economics"]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2.5",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-[#0A0E18] border border-[#1E293B]",children:[e.jsx("span",{className:"text-[11px] text-slate-400",children:"Prompt Tokens"}),e.jsx("p",{className:"text-sm font-bold font-mono text-blue-400",children:t.prompt.toLocaleString()})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-[#0A0E18] border border-[#1E293B]",children:[e.jsx("span",{className:"text-[11px] text-slate-400",children:"Cached Tokens (↻)"}),e.jsx("p",{className:"text-sm font-bold font-mono text-cyan-400",children:(t.cached||0).toLocaleString()})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-[#0A0E18] border border-[#1E293B]",children:[e.jsx("span",{className:"text-[11px] text-slate-400",children:"Output Tokens"}),e.jsx("p",{className:"text-sm font-bold font-mono text-emerald-400",children:t.completion.toLocaleString()})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-[#0A0E18] border border-[#1E293B]",children:[e.jsx("span",{className:"text-[11px] text-slate-400",children:"Tokens Saved"}),e.jsxs("p",{className:"text-sm font-bold font-mono text-amber-400 flex items-center gap-1",children:[e.jsx(xe,{className:"size-3"}),(t.savedByRtk||0).toLocaleString()]})]})]})]}),Je=({tools:t})=>!t||t.length===0?null:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold text-slate-400 uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(le,{className:"size-3.5 text-purple-400"})," Tool Calls (",t.length,")"]}),e.jsx("div",{className:"space-y-2",children:t.map((o,n)=>e.jsxs("div",{className:"p-3 rounded-lg bg-[#0A0E18] border border-[#1E293B] flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"p-1 rounded bg-purple-500/20 text-purple-300",children:e.jsx(le,{className:"size-3.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-bold text-white font-mono truncate",children:o.name}),e.jsx("p",{className:"text-[11px] text-slate-400 font-mono truncate",children:o.summary})]})]}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-semibold bg-slate-800 text-slate-300 uppercase",children:o.type})]},n))})]}),qe=({detail:t,loading:o=!1})=>{var E,j,T,N,l,k,z,S,L;const[n,s]=c.useState("client"),[w,f]=c.useState(null),u=(_,B)=>{navigator.clipboard.writeText(_),f(B),setTimeout(()=>f(null),2e3)};if(o)return e.jsxs("div",{className:"p-6 rounded-xl bg-[#0A0E18] border border-[#1E293B] flex items-center justify-center gap-3 text-slate-400",children:[e.jsx("span",{className:"size-4 border-2 border-blue-400 border-t-transparent rounded-full animate-spin"}),e.jsx("span",{className:"text-xs font-mono",children:"Loading full payload observability trace..."})]});if(!t)return e.jsxs("div",{className:"p-5 rounded-xl bg-[#0A0E18] border border-[#1E293B] space-y-2 text-center select-none",children:[e.jsx(Ce,{className:"size-6 text-slate-500 mx-auto"}),e.jsx("p",{className:"text-xs font-semibold text-slate-300",children:"No payload trace snapshot found for this request"}),e.jsxs("p",{className:"text-[11px] text-slate-500 max-w-md mx-auto",children:["Observability trace is either set to ",e.jsx("strong",{className:"text-amber-400 font-mono",children:"Errors Only"})," (which bypasses successful 200 OK payloads) or ",e.jsx("strong",{className:"text-slate-400 font-mono",children:"Off"}),". Switch to ",e.jsx("strong",{className:"text-emerald-400 font-mono",children:"Trace: All"})," in the top toolbar to record all full payloads."]})]});const b=((E=t.request)==null?void 0:E.body)||{},p=((j=t.providerRequest)==null?void 0:j.body)||{},C=((T=t.response)==null?void 0:T.body)||((N=t.providerResponse)==null?void 0:N.body)||t.errorMessage||{},i=n==="client"?b:n==="providerReq"?p:C,g=n==="client"?(l=t.request)==null?void 0:l.headers:n==="providerReq"?(k=t.providerRequest)==null?void 0:k.headers:((z=t.response)==null?void 0:z.headers)||((S=t.providerResponse)==null?void 0:S.headers),a=JSON.stringify(i,null,2);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1 bg-[#05070B] p-1 rounded-lg border border-[#1E293B]",children:[e.jsxs("button",{type:"button",onClick:()=>s("client"),className:`flex items-center gap-1.5 px-3 py-1 rounded text-xs font-semibold transition-all cursor-pointer ${n==="client"?"bg-blue-600 text-white shadow-xs":"text-slate-400 hover:text-slate-200"}`,children:[e.jsx(Ee,{className:"size-3.5"}),e.jsx("span",{children:"Client Inbound"})]}),e.jsxs("button",{type:"button",onClick:()=>s("providerReq"),className:`flex items-center gap-1.5 px-3 py-1 rounded text-xs font-semibold transition-all cursor-pointer ${n==="providerReq"?"bg-blue-600 text-white shadow-xs":"text-slate-400 hover:text-slate-200"}`,children:[e.jsx(Te,{className:"size-3.5"}),e.jsx("span",{children:"Provider Transformed"})]}),e.jsxs("button",{type:"button",onClick:()=>s("response"),className:`flex items-center gap-1.5 px-3 py-1 rounded text-xs font-semibold transition-all cursor-pointer ${n==="response"?"bg-blue-600 text-white shadow-xs":"text-slate-400 hover:text-slate-200"}`,children:[e.jsx(ke,{className:"size-3.5"}),e.jsx("span",{children:"Response & Output"})]})]}),e.jsx("button",{type:"button",onClick:()=>u(a,n),className:"px-2.5 py-1 rounded-md bg-[#0A0E18] border border-[#1E293B] text-slate-300 hover:text-white flex items-center gap-1.5 transition-colors text-xs cursor-pointer",children:w===n?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"size-3.5 text-emerald-400"}),e.jsx("span",{children:"Copied JSON"})]}):e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"size-3.5"}),e.jsx("span",{children:"Copy JSON"})]})})]}),n==="providerReq"&&((L=t.providerRequest)==null?void 0:L.url)&&e.jsxs("div",{className:"px-3 py-1.5 rounded-lg bg-[#05070B] border border-[#1E293B] text-[11px] font-mono text-slate-400 flex items-center gap-2",children:[e.jsx("span",{className:"text-slate-500 uppercase font-bold text-[10px]",children:"URL:"}),e.jsx("span",{className:"text-blue-300 truncate",children:t.providerRequest.url})]}),g&&Object.keys(g).length>0&&e.jsxs("details",{className:"rounded-lg bg-[#05070B] border border-[#1E293B] text-[11px] font-mono text-slate-400 overflow-hidden",children:[e.jsx("summary",{className:"px-3 py-1.5 cursor-pointer hover:text-slate-200 select-none flex items-center justify-between",children:e.jsxs("span",{className:"font-semibold text-slate-300",children:["Headers (",Object.keys(g).length,")"]})}),e.jsx("div",{className:"p-3 border-t border-[#1E293B] bg-black/40 max-h-36 overflow-y-auto",children:e.jsx("pre",{className:"text-[10px] text-slate-300 whitespace-pre-wrap",children:JSON.stringify(g,null,2)})})]}),e.jsx("div",{className:"rounded-xl bg-[#05070B] border border-[#1E293B] p-3 max-h-96 overflow-y-auto font-mono text-[11px] text-slate-200 leading-relaxed",children:a&&a!=="{}"?e.jsx("pre",{className:"whitespace-pre-wrap break-all select-text",children:a}):e.jsx("span",{className:"text-slate-500 italic",children:"No JSON payload body captured for this section."})})]})},Ge=({entry:t,isOpen:o,onClose:n})=>{var R,H,m,$,Y;const s=ue(v=>v.info),w=(s==null?void 0:s.port)||be,f=(s==null?void 0:s.host)||he,[u,b]=c.useState(!1),[p,C]=c.useState(!1),[i,g]=c.useState(!1),[a,E]=c.useState(null),[j,T]=c.useState(!1),{backdropProps:N}=Be(n,!o);if(c.useEffect(()=>{if(!o)return;const v=O=>{O.key==="Escape"&&n()};document.addEventListener("keydown",v);const y=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",v),document.body.style.overflow=y}},[o,n]),c.useEffect(()=>{if(!o||!t){E(null);return}const v=t.requestId||t.id;if(!v){E(null);return}let y=!0;return T(!0),fetch(`/api/usage/request-details/${encodeURIComponent(v)}`).then(O=>O.ok?O.json():null).then(O=>{y&&(E(O),T(!1))}).catch(()=>{y&&T(!1)}),()=>{y=!1}},[o,t]),!o||!t||typeof document>"u")return null;const{gateway:l,error:k,level:z,category:S,rawText:L,reqTag:_,id:B,requestId:U}=t,A=(l==null?void 0:l.statusCode)||(k==null?void 0:k.status)||(a==null?void 0:a.status),J=A===429,q=z==="error"||typeof A=="number"&&A>=400&&!J,D=typeof A=="number"&&A>=200&&A<300,P=S==="proxy"||!!l||!!a||!!t.requestId,F=(v,y)=>{navigator.clipboard.writeText(v),y==="id"?(b(!0),setTimeout(()=>b(!1),2e3)):y==="json"?(C(!0),setTimeout(()=>C(!1),2e3)):y==="curl"&&(g(!0),setTimeout(()=>g(!1),2e3))},G=()=>{var Z;const v=(l==null?void 0:l.route)||"/v1/messages",y=(l==null?void 0:l.actualModel)||(l==null?void 0:l.requestedModel)||(a==null?void 0:a.model)||"claude-3-7-sonnet",O=((Z=a==null?void 0:a.request)==null?void 0:Z.body)||{model:y,messages:[{role:"user",content:"Hello"}]},te=JSON.stringify(O,null,2).replace(/'/g,"'\\''");return`curl -X POST http://${f}:${w}${v} \\
|
|
2
2
|
-H "Content-Type: application/json" \\
|
|
3
3
|
-H "Authorization: Bearer [REDACTED]" \\
|
|
4
4
|
-d '${te}'`};return fe.createPortal(e.jsx("div",{className:"fixed inset-0 z-[9999] flex justify-end bg-black/70 backdrop-blur-xs animate-rt-fade-in",...N,children:e.jsxs("div",{className:"w-full max-w-2xl sm:max-w-3xl h-full bg-[#0D121F] border-l border-[#1E293B] shadow-2xl flex flex-col text-slate-100 overflow-hidden animate-rt-slide-in-right",onClick:v=>v.stopPropagation(),children:[e.jsxs("div",{className:"p-4 sm:p-5 border-b border-[#1E293B] flex items-center justify-between bg-[#0A0E18]",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[l!=null&&l.clientTool?e.jsx(me,{name:l.clientTool,size:"md"}):e.jsx("div",{className:"p-1.5 rounded-lg bg-blue-500/10 border border-blue-500/20 text-blue-400",children:e.jsx(ee,{className:"size-4"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-bold text-sm text-white",children:P?"AI Transaction Inspector":"System Event Diagnostics"}),_&&e.jsx("span",{children:_}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-semibold uppercase bg-blue-500/10 text-blue-400 border border-blue-500/20",children:S})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("span",{className:"text-xs text-slate-400 font-mono",children:B||U||"N/A"}),e.jsx("button",{type:"button",onClick:()=>F(B||U||"","id"),className:"text-slate-500 hover:text-slate-300 transition-colors cursor-pointer",title:"Copy ID",children:u?e.jsx(X,{className:"size-3 text-emerald-400"}):e.jsx(re,{className:"size-3"})})]})]})]})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:n,className:"p-1.5 rounded-lg text-slate-400 hover:text-white hover:bg-slate-800 transition-colors cursor-pointer",children:e.jsx(de,{className:"size-5"})})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 sm:p-6 space-y-6",children:[P?e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"p-3 rounded-xl bg-[#0A0E18] border border-[#1E293B]",children:[e.jsxs("span",{className:"text-xs text-slate-400 flex items-center gap-1.5",children:[e.jsx(Se,{className:"size-3.5 text-blue-400"})," Status"]}),e.jsx("p",{className:"mt-1 text-sm font-bold",children:J?e.jsx("span",{className:"text-amber-400",children:"429 Rate Limit"}):q?e.jsx("span",{className:"text-red-400",children:A||"Error"}):D?e.jsxs("span",{className:"text-emerald-400",children:[A," OK"]}):e.jsx("span",{className:"text-slate-300",children:z.toUpperCase()})})]}),e.jsxs("div",{className:"p-3 rounded-xl bg-[#0A0E18] border border-[#1E293B]",children:[e.jsxs("span",{className:"text-xs text-slate-400 flex items-center gap-1.5",children:[e.jsx(ie,{className:"size-3.5 text-amber-400"})," Duration"]}),e.jsx("p",{className:"mt-1 text-sm font-bold text-slate-200 font-mono",children:(l==null?void 0:l.durationMs)!==void 0?`${l.durationMs}ms`:((R=a==null?void 0:a.latency)==null?void 0:R.totalMs)!==void 0?`${a.latency.totalMs}ms`:"-"}),(l==null?void 0:l.ttftMs)!==void 0&&l.ttftMs>0&&e.jsxs("span",{className:"text-[10px] text-slate-500 font-mono",children:["TTFT: ",l.ttftMs,"ms"]})]}),e.jsxs("div",{className:"p-3 rounded-xl bg-[#0A0E18] border border-[#1E293B]",children:[e.jsxs("span",{className:"text-xs text-slate-400 flex items-center gap-1.5",children:[e.jsx(pe,{className:"size-3.5 text-purple-400"})," Model"]}),e.jsx("p",{className:"mt-1 text-xs font-bold text-slate-200 font-mono truncate",title:(l==null?void 0:l.actualModel)||(l==null?void 0:l.requestedModel)||(a==null?void 0:a.model),children:(l==null?void 0:l.actualModel)||(l==null?void 0:l.requestedModel)||(a==null?void 0:a.model)||"-"}),((l==null?void 0:l.providerId)||(a==null?void 0:a.provider))&&e.jsxs("span",{className:"text-[10px] text-slate-500 font-mono",children:["via ",(l==null?void 0:l.providerId)||(a==null?void 0:a.provider)]})]}),e.jsxs("div",{className:"p-3 rounded-xl bg-[#0A0E18] border border-[#1E293B]",children:[e.jsxs("span",{className:"text-xs text-slate-400 flex items-center gap-1.5",children:[e.jsx(Ae,{className:"size-3.5 text-emerald-400"})," Cost"]}),e.jsx("p",{className:"mt-1 text-sm font-bold text-emerald-400 font-mono",children:(l==null?void 0:l.cost)!==void 0?`$${l.cost<.01?l.cost.toFixed(4):l.cost.toFixed(3)}`:(a==null?void 0:a.cost)!==void 0?`$${a.cost.toFixed(4)}`:"$0.00"})]})]}):e.jsxs("div",{className:"p-3.5 rounded-xl bg-[#0A0E18] border border-[#1E293B] flex items-center justify-between text-xs font-mono",children:[e.jsxs("span",{className:"text-slate-400",children:["Level: ",e.jsx("strong",{className:"text-white uppercase",children:z})]}),e.jsxs("span",{className:"text-slate-400",children:["Category: ",e.jsx("strong",{className:"text-blue-400 uppercase",children:S})]})]}),(l==null?void 0:l.tokens)&&e.jsx(Ue,{tokens:l.tokens}),(l==null?void 0:l.tools)&&l.tools.length>0&&e.jsx(Je,{tools:l.tools}),(t.error||(a==null?void 0:a.errorMessage))&&e.jsxs("div",{className:"p-4 rounded-xl bg-red-950/20 border border-red-500/30 space-y-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-bold text-red-400 flex items-center gap-1.5",children:[e.jsx(Le,{className:"size-4 text-red-400"})," Error Diagnostics"]}),(((H=t.error)==null?void 0:H.code)||((m=t.error)==null?void 0:m.status))&&e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono font-bold bg-red-500/20 text-red-300 border border-red-500/40",children:t.error.code||`HTTP ${t.error.status}`})]}),e.jsx("div",{className:"text-xs font-mono text-red-200 bg-black/40 p-3 rounded-lg border border-red-500/20 whitespace-pre-wrap break-all leading-relaxed",children:(($=t.error)==null?void 0:$.message)||(a==null?void 0:a.errorMessage)||"Unknown error occurred"}),((Y=t.error)==null?void 0:Y.stack)&&e.jsxs("details",{className:"text-[11px] font-mono text-slate-400",children:[e.jsx("summary",{className:"cursor-pointer hover:text-slate-200 select-none",children:"View Stack Trace"}),e.jsx("pre",{className:"mt-2 p-2.5 rounded bg-black/60 text-[10px] text-slate-400 overflow-x-auto whitespace-pre-wrap leading-relaxed border border-slate-800",children:t.error.stack})]})]}),P&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold text-slate-400 uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(ee,{className:"size-3.5 text-blue-400"})," Observability Payload Trace"]}),e.jsx(qe,{detail:a,loading:j})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold text-slate-400 uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(se,{className:"size-3.5 text-slate-400"})," Log Output"]}),e.jsx("div",{className:"p-3 rounded-lg bg-[#05070B] border border-[#1E293B] font-mono text-xs text-slate-300 whitespace-pre-wrap break-all leading-relaxed",children:L})]})]}),e.jsxs("div",{className:"p-4 border-t border-[#1E293B] bg-[#0A0E18] flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[P&&e.jsxs("button",{type:"button",onClick:()=>F(G(),"curl"),className:"px-3 py-1.5 rounded-lg text-xs font-semibold bg-[#131B2E] border border-blue-500/30 text-blue-400 hover:bg-blue-500/20 flex items-center gap-1.5 transition-colors cursor-pointer",children:[i?e.jsx(X,{className:"size-3.5 text-emerald-400"}):e.jsx(se,{className:"size-3.5"}),e.jsx("span",{children:i?"Copied cURL!":"Copy cURL"})]}),e.jsxs("button",{type:"button",onClick:()=>F(JSON.stringify(a||t,null,2),"json"),className:"px-3 py-1.5 rounded-lg text-xs font-semibold bg-[#1E293B] text-slate-300 hover:text-white flex items-center gap-1.5 transition-colors cursor-pointer",children:[p?e.jsx(X,{className:"size-3.5 text-emerald-400"}):e.jsx(ze,{className:"size-3.5"}),e.jsx("span",{children:p?"Copied JSON!":"Copy JSON"})]})]}),e.jsx("button",{type:"button",onClick:n,className:"px-4 py-1.5 rounded-lg text-xs font-semibold bg-slate-800 text-slate-300 hover:text-white transition-colors cursor-pointer",children:"Close"})]})]})}),document.body)},Ze=()=>{const[t,o]=c.useState([]),[n,s]=c.useState([]),[w,f]=c.useState(!1),[u,b]=c.useState(!0),[p,C]=c.useState("structured"),[i,g]=c.useState("all"),[a,E]=c.useState(""),[j,T]=c.useState("all"),[N,l]=c.useState("all"),[k,z]=c.useState("all"),[S,L]=c.useState("all"),[_,B]=c.useState("info"),[U,A]=c.useState("errors_only"),[J,q]=c.useState(!1),[D,P]=c.useState(null),[F,G]=c.useState(!1),R=c.useRef(null);c.useEffect(()=>{let r=null,x=!0;return(()=>{try{const d=Oe.getToken(),M=d?`/api/console-logs/stream?token=${encodeURIComponent(d)}`:"/api/console-logs/stream";r=new EventSource(M),r.onopen=()=>{x&&f(!0)},r.onmessage=Q=>{if(x)try{const h=JSON.parse(Q.data);h.type==="init"?(Array.isArray(h.logs||h.lines)&&o(h.logs||h.lines),Array.isArray(h.structured)&&s(h.structured)):h.type==="lines"?(Array.isArray(h.lines)&&o(W=>[...W,...h.lines].slice(-500)),Array.isArray(h.structured)&&s(W=>[...W,...h.structured].slice(-500))):h.type==="clear"&&(o([]),s([]))}catch{}},r.onerror=()=>{x&&f(!1)}}catch{x&&f(!1)}})(),fetch("/api/console-logs").then(d=>d.json()).then(d=>{x&&d.success&&(Array.isArray(d.logs)&&d.logs.length>0&&o(M=>M.length===0?d.logs:M),Array.isArray(d.structuredLogs)&&d.structuredLogs.length>0&&s(M=>M.length===0?d.structuredLogs:M),d.level&&B(d.level))}).catch(()=>{}),fetch("/api/console-logs/level").then(d=>d.json()).then(d=>{x&&d.success&&d.level&&B(d.level)}).catch(()=>{}),fetch("/api/console-logs/observability").then(d=>d.json()).then(d=>{x&&d.success&&d.mode&&A(d.mode)}).catch(()=>{}),()=>{x=!1,r==null||r.close()}},[]),c.useEffect(()=>{u&&R.current&&(R.current.scrollTop=R.current.scrollHeight)},[t,n,u,p]);const H=c.useMemo(()=>{var x;const r=new Set;for(const I of n)(x=I.gateway)!=null&&x.clientTool&&r.add(I.gateway.clientTool);return Array.from(r).sort()},[n]),m=c.useMemo(()=>{var x;const r=new Set;for(const I of n)(x=I.gateway)!=null&&x.providerId&&r.add(I.gateway.providerId);return Array.from(r).sort()},[n]),$=c.useMemo(()=>n.filter(r=>{var x,I,d,M,Q,h,W,ae,oe,ne,ce;if(i==="proxy"&&r.category!=="proxy"||i==="stream"&&!(r.rawText.includes("Tool invoked:")||r.rawText.includes("streaming chunks")||(x=r.gateway)!=null&&x.tools&&r.gateway.tools.length>0)||i==="errors"&&!(r.level==="error"||r.level==="warn"||(I=r.gateway)!=null&&I.statusCode&&r.gateway.statusCode>=400)||i==="system"&&r.category==="proxy"||j!=="all"&&((d=r.gateway)==null?void 0:d.clientTool)!==j||N!=="all"&&((M=r.gateway)==null?void 0:M.providerId)!==N||k==="200"&&((Q=r.gateway)==null?void 0:Q.statusCode)!==200||k==="429"&&((h=r.gateway)==null?void 0:h.statusCode)!==429||k==="error"&&!(r.level==="error"||(W=r.gateway)!=null&&W.statusCode&&r.gateway.statusCode>=400&&r.gateway.statusCode!==429)||S!=="all"&&r.level!==S||S==="all"&&(r.level==="trace"||r.level==="debug")&&!((ae=r.gateway)!=null&&ae.statusCode)&&!((oe=r.gateway)!=null&&oe.actualModel)&&!r.error)return!1;if(a.trim()){const K=a.toLowerCase();if(!(r.rawText.toLowerCase().includes(K)||r.message.toLowerCase().includes(K)||r.requestId&&r.requestId.toLowerCase().includes(K)||((ne=r.gateway)==null?void 0:ne.actualModel)&&r.gateway.actualModel.toLowerCase().includes(K)||((ce=r.gateway)==null?void 0:ce.requestedModel)&&r.gateway.requestedModel.toLowerCase().includes(K)))return!1}return!0}),[n,i,j,N,k,S,a]),Y=async r=>{B(r);try{await fetch("/api/console-logs/level",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({level:r})})}catch{}},v=async r=>{A(r);try{await fetch("/api/console-logs/observability",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:r})})}catch{}},y=c.useMemo(()=>{if(n.length>0)return $.map(x=>x.rawText);if(!a.trim())return t;const r=a.toLowerCase();return t.filter(x=>x.toLowerCase().includes(r))},[n.length,$,t,a]),O=async()=>{try{o([]),s([]),await fetch("/api/console-logs",{method:"DELETE"})}catch{}},te=async()=>{const r=p==="raw"?y.join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as ue,r as o,j as e}from"./vendor-BcOI2aZ9.js";import{P as xe}from"./index-CtfMJ11V.js";import{T as pe}from"./ToolIcon-Cp4gSgFt.js";import{S as me}from"./Select-BNRH8LIG.js";import{g as be}from"./metadataRegistry-CGDAkFU1.js";const ae={sm:{box:"size-4 rounded-[4px]",icon:"size-2.5",label:"text-xs",description:"text-[11px]",gap:"gap-2"},md:{box:"size-5 rounded-[5px]",icon:"size-3.5",label:"text-sm",description:"text-xs",gap:"gap-2.5"},lg:{box:"size-6 rounded-[6px]",icon:"size-4",label:"text-base",description:"text-sm",gap:"gap-3"}},re={primary:{active:"bg-blue-600 border-blue-500 text-white shadow-sm shadow-blue-500/25",focusRing:"peer-focus-visible:ring-blue-500/50",hoverBorder:"group-hover:border-blue-500/50 hover:border-blue-500/50"},emerald:{active:"bg-emerald-600 border-emerald-500 text-white shadow-sm shadow-emerald-500/25",focusRing:"peer-focus-visible:ring-emerald-500/50",hoverBorder:"group-hover:border-emerald-500/50 hover:border-emerald-500/50"},cyan:{active:"bg-cyan-600 border-cyan-500 text-white shadow-sm shadow-cyan-500/25",focusRing:"peer-focus-visible:ring-cyan-500/50",hoverBorder:"group-hover:border-cyan-500/50 hover:border-cyan-500/50"}},he=ue.forwardRef(({checked:B,defaultChecked:a,indeterminate:n=!1,onChange:g,size:v="md",variant:C="primary",label:u,description:x,disabled:i=!1,className:S="",checkboxClassName:b="",wrapperClassName:E="",onClick:I,...D},p)=>{const h=o.useRef(null),y=B!==void 0,[f,j]=o.useState(!!a),m=y?!!B:f;o.useEffect(()=>{h.current&&(h.current.indeterminate=!!n)},[n]);const z=c=>{h.current=c,typeof p=="function"?p(c):p&&(p.current=c)},$=c=>{i||(y||j(c.target.checked),g==null||g(c.target.checked,c))},d=ae[v]||ae.md,N=re[C]||re.primary,R=m||n,k=!!x;return e.jsxs("label",{className:`group inline-flex select-none transition-opacity ${k?"items-start":"items-center"} ${i?"cursor-not-allowed opacity-50":"cursor-pointer"} ${d.gap} ${E||S}`,onClick:I,children:[e.jsxs("div",{className:`relative inline-flex items-center justify-center shrink-0 ${k?"mt-0.5":""}`,children:[e.jsx("input",{ref:z,type:"checkbox",checked:m,disabled:i,onChange:$,"aria-checked":n?"mixed":m,className:"sr-only peer",...D}),e.jsxs("div",{className:`flex items-center justify-center border transition-all duration-150 ease-out peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2 peer-focus-visible:ring-offset-[#0A0D14] ${d.box} ${R?N.active:`bg-[#0B0F17] border-[#1E293B] text-transparent ${i?"":"group-hover:border-slate-500 hover:border-slate-500"}`} ${N.focusRing} ${i?"":"active:scale-95"} ${b}`,children:[e.jsx("svg",{className:`transition-all duration-150 ease-out ${d.icon} ${m&&!n?"scale-100 opacity-100":"scale-50 opacity-0"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),e.jsx("svg",{className:`transition-all duration-150 ease-out absolute ${d.icon} ${n?"scale-100 opacity-100":"scale-50 opacity-0"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})]})]}),(u||x)&&e.jsxs("div",{className:"flex flex-col leading-tight min-w-0 justify-center",children:[u&&e.jsx("span",{className:`font-medium text-slate-200 transition-colors ${i?"":"group-hover:text-white"} ${d.label}`,children:u}),x&&e.jsx("span",{className:`text-slate-400 mt-0.5 ${d.description}`,children:x})]})]})});he.displayName="Checkbox";const Ne=({isOpen:B,account:a,onClose:n,onSave:g})=>{const[v,C]=o.useState(""),[u,x]=o.useState(""),[i,S]=o.useState(""),[b,E]=o.useState(!1),[I,D]=o.useState(!0),[p,h]=o.useState(!1),[y,f]=o.useState(null),[j,m]=o.useState(""),[z,$]=o.useState(""),[d,N]=o.useState(""),[R,k]=o.useState("2024-10-01-preview"),[c,F]=o.useState(""),[_,q]=o.useState(""),[H,M]=o.useState("sgp"),[O,K]=o.useState("profile"),[V,G]=o.useState(""),[L,X]=o.useState("us-east-1"),[Y,Z]=o.useState(""),[J,Q]=o.useState(""),[T,P]=o.useState(""),r=((a==null?void 0:a.providerId)||"").toLowerCase(),s=be((a==null?void 0:a.providerId)||""),ne=r==="opencode"||r==="oc"||!!(s!=null&&s.noAuth)||(s==null?void 0:s.requiresApiKey)===!1||(s==null?void 0:s.authType)==="none",w=r==="ollama-local"||r.includes("ollama"),U=!!(s!=null&&s.isLocal)||r==="lm-studio"||r==="jan"||r==="local-device",ee=ne||w||U||(s==null?void 0:s.requiresApiKey)===!1,te=r==="azure"||r.includes("azure"),se=r==="cloudflare-ai"||r==="cloudflare",le=r==="bedrock"||r.includes("bedrock"),W=r==="xiaomi-tokenplan",oe=r==="alicode"||r==="alibaba",A=W?[{id:"sgp",label:"Singapore (新加坡)"},{id:"cn",label:"China (中国大陆)"},{id:"ams",label:"Amsterdam (阿姆斯特丹)"}]:(s==null?void 0:s.regions)||[];if(o.useEffect(()=>{var t;if(a){C(a.name||""),x(a.tag||((t=a.providerSpecificData)==null?void 0:t.tag)||""),S(""),E(!1),D(!!a.isActive),f(null);const l=a.providerSpecificData||{};m(l.baseUrl||(w?"http://127.0.0.1:11434":r==="lm-studio"?"http://localhost:1234/v1":r==="jan"?"http://localhost:1337/v1":"http://localhost:8000/v1")),$(l.azureEndpoint||""),N(l.deployment||"gpt-4"),k(l.apiVersion||"2024-10-01-preview"),F(l.organization||""),q(l.accountId||""),M(l.region||(A.length>0?A[0].id:"sgp")),P(l.baseUrl||"");const de=!!l.accessKeyId;K(de?"static":"profile"),G(l.profile||""),X(l.region||"us-east-1"),Z(l.accessKeyId||""),Q(l.sessionToken||"")}},[a]),!a)return null;const ie=()=>{const t=a.providerSpecificData||{};let l={};return w?l.baseUrl=j.trim()||"http://127.0.0.1:11434":U?l.baseUrl=j.trim():te?l={azureEndpoint:z.trim(),deployment:d.trim(),apiVersion:R.trim(),organization:c.trim()||void 0}:se?l={accountId:_.trim()}:le?O==="profile"?l={profile:V.trim(),region:L.trim()||"us-east-1"}:l={accessKeyId:Y.trim(),region:L.trim()||"us-east-1",sessionToken:J.trim()||void 0}:(W||A.length>0)&&(l.region=H,oe&&(T.trim()?l.baseUrl=T.trim():t.baseUrl&&delete t.baseUrl)),Object.keys(l).length>0?{...t,...l}:Object.keys(t).length>0?t:void 0},ce=async t=>{if(t.preventDefault(),!v.trim()){f("Account name is required.");return}h(!0),f(null);try{const l=ie()||{};u.trim()?l.tag=u.trim().toLowerCase():delete l.tag,await g({name:v.trim(),apiKey:i.trim()?i.trim():void 0,isActive:I,providerSpecificData:Object.keys(l).length>0?l:void 0}),n()}catch(l){f(l.message||"Failed to save account changes.")}finally{h(!1)}};return e.jsx(xe,{isOpen:B,onClose:n,maxWidthClass:"max-w-xl",children:e.jsxs("form",{onSubmit:ce,className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(pe,{src:(s==null?void 0:s.image)||`/assets/providers/${a.providerId}/icon.png`,name:(s==null?void 0:s.name)||a.providerId,color:(s==null?void 0:s.color)||"#3B82F6",iconBg:s==null?void 0:s.iconBg,size:"sm"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-slate-100 flex items-center gap-1.5",children:"Edit Account"}),e.jsxs("div",{className:"text-[11px] text-slate-400 font-mono",children:[(s==null?void 0:s.name)||a.providerId.toUpperCase()," • ",a.id]})]})]}),e.jsx("button",{type:"button",onClick:n,className:"text-slate-400 hover:text-white transition-colors cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),y&&e.jsxs("div",{className:"p-3 bg-red-500/10 border border-red-500/20 text-red-400 text-xs rounded-xl flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"error"}),e.jsx("span",{children:y})]}),e.jsxs("div",{className:"space-y-3.5 text-xs",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-slate-300 font-medium mb-1",children:["Account Name / Label ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"text",value:v,onChange:t=>C(t.target.value),placeholder:"e.g. Work Account or user@example.com",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 px-3 py-2 rounded-xl focus:outline-none focus:border-blue-500 transition-colors"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("label",{className:"text-slate-300 font-medium flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px] text-blue-400",children:"label"}),"Group Tag"]}),e.jsx("span",{className:"text-slate-500 text-[11px]",children:"Optional • For grouping in Combos"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"text",value:u,onChange:t=>x(t.target.value.toLowerCase().replace(/[^a-z0-9_-]/g,"")),placeholder:"e.g. pro, plus, free, team",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 pl-3 pr-20 py-2 rounded-xl focus:outline-none focus:border-blue-500 transition-colors font-mono"}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1 pointer-events-none",children:["pro","plus","free"].map(t=>e.jsx("button",{type:"button",tabIndex:-1,onClick:l=>{l.preventDefault(),x(t)},className:`pointer-events-auto text-[10px] px-1.5 py-0.5 rounded font-mono transition-colors ${u===t?"bg-blue-600 text-white font-semibold":"bg-[#1E293B] text-slate-400 hover:text-slate-200"}`,children:t},t))})]})]})]}),ee&&e.jsxs("div",{className:"p-2.5 bg-emerald-500/10 border border-emerald-500/20 rounded-xl text-emerald-300 text-[11px] flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-emerald-400 text-[16px]",children:"verified"}),e.jsxs("span",{children:[(s==null?void 0:s.name)||a.providerId," does not require an API key by default. You can leave the key blank."]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"block text-slate-300 font-medium",children:ee?"API Key / Auth Token (Optional)":"Update API Key / Secret Token"}),e.jsx("span",{className:"text-slate-500 text-[11px]",children:"Leave blank to keep existing key"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:b?"text":"password",value:i,onChange:t=>S(t.target.value),placeholder:"Enter new API key or token to overwrite...",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 pl-3 pr-9 py-2 rounded-xl focus:outline-none focus:border-blue-500 transition-colors font-mono"}),e.jsx("button",{type:"button",onClick:()=>E(!b),tabIndex:-1,className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-500 hover:text-slate-300 transition-colors cursor-pointer",title:b?"Hide token":"Show token",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:b?"visibility_off":"visibility"})})]})]}),(w||U)&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-300 font-medium mb-1",children:"Local Host / Base URL"}),e.jsx("input",{type:"text",value:j,onChange:t=>m(t.target.value),placeholder:w?"http://127.0.0.1:11434":"http://localhost:1234/v1",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 px-3 py-2 rounded-xl focus:outline-none focus:border-blue-500 transition-colors font-mono"})]}),te&&e.jsxs("div",{className:"space-y-2.5 p-3 bg-[#0A0D14] border border-[#1E293B] rounded-xl",children:[e.jsxs("div",{className:"text-[11px] font-semibold text-slate-300 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-blue-400 text-[14px]",children:"cloud"}),"Azure OpenAI Deployment Parameters"]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"Endpoint URL"}),e.jsx("input",{type:"text",value:z,onChange:t=>$(t.target.value),placeholder:"https://my-resource.openai.azure.com",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"Deployment Name"}),e.jsx("input",{type:"text",value:d,onChange:t=>N(t.target.value),placeholder:"gpt-4",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"API Version"}),e.jsx("input",{type:"text",value:R,onChange:t=>k(t.target.value),placeholder:"2024-10-01-preview",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"Organization (Optional)"}),e.jsx("input",{type:"text",value:c,onChange:t=>F(t.target.value),placeholder:"org-...",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]})]}),se&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-300 font-medium mb-1",children:"Cloudflare Account ID"}),e.jsx("input",{type:"text",value:_,onChange:t=>q(t.target.value),placeholder:"Cloudflare account ID (32 chars)",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 px-3 py-2 rounded-xl focus:outline-none focus:border-blue-500 transition-colors font-mono"})]}),le&&e.jsxs("div",{className:"space-y-2.5 p-3 bg-[#0A0D14] border border-[#1E293B] rounded-xl",children:[e.jsxs("div",{className:"flex bg-[#141B2D] p-1 rounded-lg border border-[#1E293B] text-xs",children:[e.jsx("button",{type:"button",onClick:()=>K("profile"),className:`flex-1 py-1 rounded-md font-medium transition-colors cursor-pointer ${O==="profile"?"bg-blue-600 text-white shadow-xs":"text-slate-400 hover:text-white"}`,children:"AWS Profile"}),e.jsx("button",{type:"button",onClick:()=>K("static"),className:`flex-1 py-1 rounded-md font-medium transition-colors cursor-pointer ${O==="static"?"bg-blue-600 text-white shadow-xs":"text-slate-400 hover:text-white"}`,children:"Static IAM Keys"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"AWS Region"}),e.jsx("input",{type:"text",value:L,onChange:t=>X(t.target.value),placeholder:"us-east-1",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]}),O==="profile"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"AWS Profile Name"}),e.jsx("input",{type:"text",value:V,onChange:t=>G(t.target.value),placeholder:"default",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"Access Key ID"}),e.jsx("input",{type:"text",value:Y,onChange:t=>Z(t.target.value),placeholder:"AKIA...",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"Session Token (Optional)"}),e.jsx("input",{type:"password",value:J,onChange:t=>Q(t.target.value),placeholder:"Optional STS token...",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]})]})]}),(W||A.length>0)&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-300 font-medium mb-1",children:"Cluster Region"}),e.jsx(me,{value:H,onChange:t=>M(t),options:A.map(t=>({value:t.id,label:t.label.includes(t.id)?t.label:`${t.label} (${t.id})`})),className:"w-full",triggerClassName:"bg-[#0A0D14] font-mono text-xs py-2"})]}),oe&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"block text-slate-400 text-xs",children:["Dedicated Workspace Endpoint URL ",e.jsx("span",{className:"text-slate-500",children:"(Optional)"})]}),e.jsx("input",{type:"text",value:T,onChange:t=>P(t.target.value),placeholder:"e.g. https://ws-xxx.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono text-xs"}),e.jsx("p",{className:"text-[11px] text-slate-400",children:"Required if your API key was created inside an Alibaba Model Studio custom workspace."})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 bg-[#141B2D] border border-[#1E293B] rounded-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-slate-200",children:"Active Status"}),e.jsx("div",{className:"text-[11px] text-slate-400",children:"Inactive accounts are excluded from routing and quota polling."})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:I,onChange:t=>D(t.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-9 h-5 bg-slate-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-blue-600"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-4 border-t border-[#1E293B]",children:[e.jsx("button",{type:"button",onClick:n,disabled:p,className:"px-4 py-2 text-xs font-medium text-slate-400 hover:text-white bg-[#141B2D] border border-[#1E293B] rounded-xl transition-colors cursor-pointer",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:p,className:"px-4 py-2 text-xs font-medium text-white bg-blue-600 hover:bg-blue-500 rounded-xl transition-colors cursor-pointer flex items-center gap-1.5 disabled:opacity-50",children:p?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[15px] animate-spin",children:"progress_activity"}),"Saving..."]}):"Save Changes"})]})]})})};export{he as C,Ne as E};
|
|
1
|
+
import{R as ue,r as o,j as e}from"./vendor-BcOI2aZ9.js";import{P as xe}from"./index-BvY11iVv.js";import{T as pe}from"./ToolIcon-BZE0Fv7L.js";import{S as me}from"./Select-BNRH8LIG.js";import{g as be}from"./metadataRegistry-4BIaQVmV.js";const ae={sm:{box:"size-4 rounded-[4px]",icon:"size-2.5",label:"text-xs",description:"text-[11px]",gap:"gap-2"},md:{box:"size-5 rounded-[5px]",icon:"size-3.5",label:"text-sm",description:"text-xs",gap:"gap-2.5"},lg:{box:"size-6 rounded-[6px]",icon:"size-4",label:"text-base",description:"text-sm",gap:"gap-3"}},re={primary:{active:"bg-blue-600 border-blue-500 text-white shadow-sm shadow-blue-500/25",focusRing:"peer-focus-visible:ring-blue-500/50",hoverBorder:"group-hover:border-blue-500/50 hover:border-blue-500/50"},emerald:{active:"bg-emerald-600 border-emerald-500 text-white shadow-sm shadow-emerald-500/25",focusRing:"peer-focus-visible:ring-emerald-500/50",hoverBorder:"group-hover:border-emerald-500/50 hover:border-emerald-500/50"},cyan:{active:"bg-cyan-600 border-cyan-500 text-white shadow-sm shadow-cyan-500/25",focusRing:"peer-focus-visible:ring-cyan-500/50",hoverBorder:"group-hover:border-cyan-500/50 hover:border-cyan-500/50"}},he=ue.forwardRef(({checked:B,defaultChecked:a,indeterminate:n=!1,onChange:g,size:v="md",variant:C="primary",label:u,description:x,disabled:i=!1,className:S="",checkboxClassName:b="",wrapperClassName:E="",onClick:I,...D},p)=>{const h=o.useRef(null),y=B!==void 0,[f,j]=o.useState(!!a),m=y?!!B:f;o.useEffect(()=>{h.current&&(h.current.indeterminate=!!n)},[n]);const z=c=>{h.current=c,typeof p=="function"?p(c):p&&(p.current=c)},$=c=>{i||(y||j(c.target.checked),g==null||g(c.target.checked,c))},d=ae[v]||ae.md,N=re[C]||re.primary,R=m||n,k=!!x;return e.jsxs("label",{className:`group inline-flex select-none transition-opacity ${k?"items-start":"items-center"} ${i?"cursor-not-allowed opacity-50":"cursor-pointer"} ${d.gap} ${E||S}`,onClick:I,children:[e.jsxs("div",{className:`relative inline-flex items-center justify-center shrink-0 ${k?"mt-0.5":""}`,children:[e.jsx("input",{ref:z,type:"checkbox",checked:m,disabled:i,onChange:$,"aria-checked":n?"mixed":m,className:"sr-only peer",...D}),e.jsxs("div",{className:`flex items-center justify-center border transition-all duration-150 ease-out peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2 peer-focus-visible:ring-offset-[#0A0D14] ${d.box} ${R?N.active:`bg-[#0B0F17] border-[#1E293B] text-transparent ${i?"":"group-hover:border-slate-500 hover:border-slate-500"}`} ${N.focusRing} ${i?"":"active:scale-95"} ${b}`,children:[e.jsx("svg",{className:`transition-all duration-150 ease-out ${d.icon} ${m&&!n?"scale-100 opacity-100":"scale-50 opacity-0"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),e.jsx("svg",{className:`transition-all duration-150 ease-out absolute ${d.icon} ${n?"scale-100 opacity-100":"scale-50 opacity-0"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})]})]}),(u||x)&&e.jsxs("div",{className:"flex flex-col leading-tight min-w-0 justify-center",children:[u&&e.jsx("span",{className:`font-medium text-slate-200 transition-colors ${i?"":"group-hover:text-white"} ${d.label}`,children:u}),x&&e.jsx("span",{className:`text-slate-400 mt-0.5 ${d.description}`,children:x})]})]})});he.displayName="Checkbox";const Ne=({isOpen:B,account:a,onClose:n,onSave:g})=>{const[v,C]=o.useState(""),[u,x]=o.useState(""),[i,S]=o.useState(""),[b,E]=o.useState(!1),[I,D]=o.useState(!0),[p,h]=o.useState(!1),[y,f]=o.useState(null),[j,m]=o.useState(""),[z,$]=o.useState(""),[d,N]=o.useState(""),[R,k]=o.useState("2024-10-01-preview"),[c,F]=o.useState(""),[_,q]=o.useState(""),[H,M]=o.useState("sgp"),[O,K]=o.useState("profile"),[V,G]=o.useState(""),[L,X]=o.useState("us-east-1"),[Y,Z]=o.useState(""),[J,Q]=o.useState(""),[T,P]=o.useState(""),r=((a==null?void 0:a.providerId)||"").toLowerCase(),s=be((a==null?void 0:a.providerId)||""),ne=r==="opencode"||r==="oc"||!!(s!=null&&s.noAuth)||(s==null?void 0:s.requiresApiKey)===!1||(s==null?void 0:s.authType)==="none",w=r==="ollama-local"||r.includes("ollama"),U=!!(s!=null&&s.isLocal)||r==="lm-studio"||r==="jan"||r==="local-device",ee=ne||w||U||(s==null?void 0:s.requiresApiKey)===!1,te=r==="azure"||r.includes("azure"),se=r==="cloudflare-ai"||r==="cloudflare",le=r==="bedrock"||r.includes("bedrock"),W=r==="xiaomi-tokenplan",oe=r==="alicode"||r==="alibaba",A=W?[{id:"sgp",label:"Singapore (新加坡)"},{id:"cn",label:"China (中国大陆)"},{id:"ams",label:"Amsterdam (阿姆斯特丹)"}]:(s==null?void 0:s.regions)||[];if(o.useEffect(()=>{var t;if(a){C(a.name||""),x(a.tag||((t=a.providerSpecificData)==null?void 0:t.tag)||""),S(""),E(!1),D(!!a.isActive),f(null);const l=a.providerSpecificData||{};m(l.baseUrl||(w?"http://127.0.0.1:11434":r==="lm-studio"?"http://localhost:1234/v1":r==="jan"?"http://localhost:1337/v1":"http://localhost:8000/v1")),$(l.azureEndpoint||""),N(l.deployment||"gpt-4"),k(l.apiVersion||"2024-10-01-preview"),F(l.organization||""),q(l.accountId||""),M(l.region||(A.length>0?A[0].id:"sgp")),P(l.baseUrl||"");const de=!!l.accessKeyId;K(de?"static":"profile"),G(l.profile||""),X(l.region||"us-east-1"),Z(l.accessKeyId||""),Q(l.sessionToken||"")}},[a]),!a)return null;const ie=()=>{const t=a.providerSpecificData||{};let l={};return w?l.baseUrl=j.trim()||"http://127.0.0.1:11434":U?l.baseUrl=j.trim():te?l={azureEndpoint:z.trim(),deployment:d.trim(),apiVersion:R.trim(),organization:c.trim()||void 0}:se?l={accountId:_.trim()}:le?O==="profile"?l={profile:V.trim(),region:L.trim()||"us-east-1"}:l={accessKeyId:Y.trim(),region:L.trim()||"us-east-1",sessionToken:J.trim()||void 0}:(W||A.length>0)&&(l.region=H,oe&&(T.trim()?l.baseUrl=T.trim():t.baseUrl&&delete t.baseUrl)),Object.keys(l).length>0?{...t,...l}:Object.keys(t).length>0?t:void 0},ce=async t=>{if(t.preventDefault(),!v.trim()){f("Account name is required.");return}h(!0),f(null);try{const l=ie()||{};u.trim()?l.tag=u.trim().toLowerCase():delete l.tag,await g({name:v.trim(),apiKey:i.trim()?i.trim():void 0,isActive:I,providerSpecificData:Object.keys(l).length>0?l:void 0}),n()}catch(l){f(l.message||"Failed to save account changes.")}finally{h(!1)}};return e.jsx(xe,{isOpen:B,onClose:n,maxWidthClass:"max-w-xl",children:e.jsxs("form",{onSubmit:ce,className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(pe,{src:(s==null?void 0:s.image)||`/assets/providers/${a.providerId}/icon.png`,name:(s==null?void 0:s.name)||a.providerId,color:(s==null?void 0:s.color)||"#3B82F6",iconBg:s==null?void 0:s.iconBg,size:"sm"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-slate-100 flex items-center gap-1.5",children:"Edit Account"}),e.jsxs("div",{className:"text-[11px] text-slate-400 font-mono",children:[(s==null?void 0:s.name)||a.providerId.toUpperCase()," • ",a.id]})]})]}),e.jsx("button",{type:"button",onClick:n,className:"text-slate-400 hover:text-white transition-colors cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),y&&e.jsxs("div",{className:"p-3 bg-red-500/10 border border-red-500/20 text-red-400 text-xs rounded-xl flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"error"}),e.jsx("span",{children:y})]}),e.jsxs("div",{className:"space-y-3.5 text-xs",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-slate-300 font-medium mb-1",children:["Account Name / Label ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"text",value:v,onChange:t=>C(t.target.value),placeholder:"e.g. Work Account or user@example.com",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 px-3 py-2 rounded-xl focus:outline-none focus:border-blue-500 transition-colors"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("label",{className:"text-slate-300 font-medium flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px] text-blue-400",children:"label"}),"Group Tag"]}),e.jsx("span",{className:"text-slate-500 text-[11px]",children:"Optional • For grouping in Combos"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"text",value:u,onChange:t=>x(t.target.value.toLowerCase().replace(/[^a-z0-9_-]/g,"")),placeholder:"e.g. pro, plus, free, team",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 pl-3 pr-20 py-2 rounded-xl focus:outline-none focus:border-blue-500 transition-colors font-mono"}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1 pointer-events-none",children:["pro","plus","free"].map(t=>e.jsx("button",{type:"button",tabIndex:-1,onClick:l=>{l.preventDefault(),x(t)},className:`pointer-events-auto text-[10px] px-1.5 py-0.5 rounded font-mono transition-colors ${u===t?"bg-blue-600 text-white font-semibold":"bg-[#1E293B] text-slate-400 hover:text-slate-200"}`,children:t},t))})]})]})]}),ee&&e.jsxs("div",{className:"p-2.5 bg-emerald-500/10 border border-emerald-500/20 rounded-xl text-emerald-300 text-[11px] flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-emerald-400 text-[16px]",children:"verified"}),e.jsxs("span",{children:[(s==null?void 0:s.name)||a.providerId," does not require an API key by default. You can leave the key blank."]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"block text-slate-300 font-medium",children:ee?"API Key / Auth Token (Optional)":"Update API Key / Secret Token"}),e.jsx("span",{className:"text-slate-500 text-[11px]",children:"Leave blank to keep existing key"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:b?"text":"password",value:i,onChange:t=>S(t.target.value),placeholder:"Enter new API key or token to overwrite...",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 pl-3 pr-9 py-2 rounded-xl focus:outline-none focus:border-blue-500 transition-colors font-mono"}),e.jsx("button",{type:"button",onClick:()=>E(!b),tabIndex:-1,className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-500 hover:text-slate-300 transition-colors cursor-pointer",title:b?"Hide token":"Show token",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:b?"visibility_off":"visibility"})})]})]}),(w||U)&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-300 font-medium mb-1",children:"Local Host / Base URL"}),e.jsx("input",{type:"text",value:j,onChange:t=>m(t.target.value),placeholder:w?"http://127.0.0.1:11434":"http://localhost:1234/v1",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 px-3 py-2 rounded-xl focus:outline-none focus:border-blue-500 transition-colors font-mono"})]}),te&&e.jsxs("div",{className:"space-y-2.5 p-3 bg-[#0A0D14] border border-[#1E293B] rounded-xl",children:[e.jsxs("div",{className:"text-[11px] font-semibold text-slate-300 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-blue-400 text-[14px]",children:"cloud"}),"Azure OpenAI Deployment Parameters"]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"Endpoint URL"}),e.jsx("input",{type:"text",value:z,onChange:t=>$(t.target.value),placeholder:"https://my-resource.openai.azure.com",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"Deployment Name"}),e.jsx("input",{type:"text",value:d,onChange:t=>N(t.target.value),placeholder:"gpt-4",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"API Version"}),e.jsx("input",{type:"text",value:R,onChange:t=>k(t.target.value),placeholder:"2024-10-01-preview",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"Organization (Optional)"}),e.jsx("input",{type:"text",value:c,onChange:t=>F(t.target.value),placeholder:"org-...",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]})]}),se&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-300 font-medium mb-1",children:"Cloudflare Account ID"}),e.jsx("input",{type:"text",value:_,onChange:t=>q(t.target.value),placeholder:"Cloudflare account ID (32 chars)",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 px-3 py-2 rounded-xl focus:outline-none focus:border-blue-500 transition-colors font-mono"})]}),le&&e.jsxs("div",{className:"space-y-2.5 p-3 bg-[#0A0D14] border border-[#1E293B] rounded-xl",children:[e.jsxs("div",{className:"flex bg-[#141B2D] p-1 rounded-lg border border-[#1E293B] text-xs",children:[e.jsx("button",{type:"button",onClick:()=>K("profile"),className:`flex-1 py-1 rounded-md font-medium transition-colors cursor-pointer ${O==="profile"?"bg-blue-600 text-white shadow-xs":"text-slate-400 hover:text-white"}`,children:"AWS Profile"}),e.jsx("button",{type:"button",onClick:()=>K("static"),className:`flex-1 py-1 rounded-md font-medium transition-colors cursor-pointer ${O==="static"?"bg-blue-600 text-white shadow-xs":"text-slate-400 hover:text-white"}`,children:"Static IAM Keys"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"AWS Region"}),e.jsx("input",{type:"text",value:L,onChange:t=>X(t.target.value),placeholder:"us-east-1",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]}),O==="profile"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"AWS Profile Name"}),e.jsx("input",{type:"text",value:V,onChange:t=>G(t.target.value),placeholder:"default",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"Access Key ID"}),e.jsx("input",{type:"text",value:Y,onChange:t=>Z(t.target.value),placeholder:"AKIA...",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-400 mb-1",children:"Session Token (Optional)"}),e.jsx("input",{type:"password",value:J,onChange:t=>Q(t.target.value),placeholder:"Optional STS token...",className:"w-full bg-[#141B2D] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono"})]})]})]}),(W||A.length>0)&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-slate-300 font-medium mb-1",children:"Cluster Region"}),e.jsx(me,{value:H,onChange:t=>M(t),options:A.map(t=>({value:t.id,label:t.label.includes(t.id)?t.label:`${t.label} (${t.id})`})),className:"w-full",triggerClassName:"bg-[#0A0D14] font-mono text-xs py-2"})]}),oe&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"block text-slate-400 text-xs",children:["Dedicated Workspace Endpoint URL ",e.jsx("span",{className:"text-slate-500",children:"(Optional)"})]}),e.jsx("input",{type:"text",value:T,onChange:t=>P(t.target.value),placeholder:"e.g. https://ws-xxx.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",className:"w-full bg-[#0A0D14] border border-[#1E293B] text-slate-100 px-3 py-1.5 rounded-lg focus:outline-none focus:border-blue-500 font-mono text-xs"}),e.jsx("p",{className:"text-[11px] text-slate-400",children:"Required if your API key was created inside an Alibaba Model Studio custom workspace."})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 bg-[#141B2D] border border-[#1E293B] rounded-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-slate-200",children:"Active Status"}),e.jsx("div",{className:"text-[11px] text-slate-400",children:"Inactive accounts are excluded from routing and quota polling."})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:I,onChange:t=>D(t.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-9 h-5 bg-slate-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-blue-600"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-4 border-t border-[#1E293B]",children:[e.jsx("button",{type:"button",onClick:n,disabled:p,className:"px-4 py-2 text-xs font-medium text-slate-400 hover:text-white bg-[#141B2D] border border-[#1E293B] rounded-xl transition-colors cursor-pointer",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:p,className:"px-4 py-2 text-xs font-medium text-white bg-blue-600 hover:bg-blue-500 rounded-xl transition-colors cursor-pointer flex items-center gap-1.5 disabled:opacity-50",children:p?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[15px] animate-spin",children:"progress_activity"}),"Saving..."]}):"Save Changes"})]})]})})};export{he as C,Ne as E};
|