import{A as p,b as n,i as se,a as de,g as le,c as pe,d as ce,O as ue,e as ve,C as me,f as fe,L as ge,V as he,M as be,h as Ie,G as xe,X as ye,j as _e,k as Ae,B as ke,l as Pe,Q as we,Z as $e,m as Se,n as Re,o as Me,p as Oe,q as Ee,S as Ce,T as Le,H as Te,r as De,s as Ne,t as Ve,u as qe}from"./app-wpJSg6bV.js";import{buildProviderAuthSummary as Fe,calloutClassForProviderAuthActionTone as Ge,buildOrderedProviderProfiles as Ue}from"./config-D5fCHJGy.js";import"./index-BScPU8W0.js";function ze(e){return e==="api-key"?"api":e==="token"?"token":e==="manual"?"manual":"interactive"}function s(e){return{id:e.id,label:e.label,routeIds:[...new Set([...e.methods.map(r=>r.route),...e.routeAliases??[]])],authMethods:e.methods.map(r=>({kind:ze(r.kind),providerId:r.configProviderId??r.route,statusProviderId:r.statusRoute,methodId:r.id,label:r.label,buttonLabel:r.buttonLabel,reason:r.hint,setupRequirement:r.setupRequirement})),modelProviderIds:e.modelProviderIds,modelRefs:e.models.recommended}}const Be=[s(ue),s(ve),s(me),s(fe),s(ge),s(he),s(be),s(Ie),s(xe),s(ye),s(_e),s(Ae),s(ke),s(Pe),s(we),s($e),s(Se),s(Re),s(Me),s(Oe),s(Ee),s(Ce),s(Le),s(Te),s(De),s(Ne),s(Ve),s(qe)],He={anthropic:"Anthropic API key",byteplus:"BytePlus API key",chutes:"Chutes API key",gemini:"Google Gemini API key",google:"Google Gemini API key",huggingface:"Hugging Face token","kimi-code":"Kimi Code API key","kimi-coding":"Kimi Code API key",litellm:"LiteLLM API key",minimax:"MiniMax API key","minimax-cn":"MiniMax CN API key","minimax-lightning":"MiniMax Highspeed API key",mistral:"Mistral API key",moonshot:"Moonshot API key","moonshot-cn":"Moonshot CN API key",opencode:"OpenCode Zen API key","opencode-zen":"OpenCode Zen API key",openai:"OpenAI API key",openrouter:"OpenRouter API key",qianfan:"Qianfan API key",qwen:"Qwen DashScope API key","qwen-coding-plan":"Qwen Coding Plan API key",synthetic:"Synthetic API key",together:"Together AI API key",venice:"Venice API key","vercel-ai-gateway":"Vercel AI API key",volcengine:"Volcano Engine API key",xai:"xAI API key",xiaomi:"Xiaomi API key",zai:"Z.AI API key","zai-cn":"Z.AI CN API key","zai-coding-cn":"Z.AI Coding CN API key","zai-coding-global":"Z.AI Coding Global API key"},je={anthropic:"Sign in",chutes:"Sign in","copilot-proxy":"Proxy sign in","github-copilot":"GitHub sign in","google-gemini-cli":"Sign in","minimax-portal":"Sign in","openai-codex":"Sign in",xai:"xAI sign-in"},Ke={"cloudflare-ai-gateway":"Cloudflare AI uses the Configure form for Account ID, Gateway ID, and Anthropic API key.","copilot-proxy":"Copilot Proxy uses a local sign-in/proxy flow, not API-key setup.","github-copilot":"GitHub Copilot uses GitHub device login, not API-key setup.","google-gemini-cli":"Google Gemini CLI uses OAuth. Use the Google provider row for Gemini API keys.","minimax-portal":"MiniMax Portal uses OAuth. Use the MiniMax provider row for API keys.","openai-codex":"OpenAI sign-in uses ChatGPT OAuth. Use the OpenAI provider row for OpenAI API keys.",ollama:"Ollama needs native endpoint/model fields, not generic API-key setup.",lmstudio:"LM Studio needs endpoint/model fields, not generic API-key setup.",vllm:"vLLM needs endpoint/model fields, not API-key setup."},Ze={gemini:"Use the Google Gemini CLI row for OAuth, or save a Gemini API key here.",google:"Use the Google Gemini CLI row for OAuth, or save a Gemini API key here.",minimax:"Use the MiniMax Portal row for OAuth, or save a MiniMax API key here.",openai:"Use OpenAI sign-in for ChatGPT OAuth, or save an OpenAI API key here."};function ee(e,r){return e?.providers.find(i=>i.provider===r)??null}function q(e,r){return e?.providers.find(i=>i.provider===r)??null}function Qe(e){return e==="ready"||e==="ok"||e==="configured"||e==="expiring"||e==="static"?"chip ok":e==="missing"||e==="unauthenticated"||e==="unconfigured"?"chip warn":e==="error"?"chip danger":"chip"}function S(e){return e==="ready"||e==="ok"||e==="configured"||e==="expiring"||e==="static"}function F(e){return e?S(e.status)||e.profiles.some(r=>S(r.status)):!1}function Ye(e,r){return(r.modelProviderIds??r.routeIds).map(o=>ee(e,o)).filter(o=>!!o)}function X(e){return e==="ok"?"chip ok":e==="fail"?"chip danger":"chip"}function J(e,r,i){return e==="ok"?r:e==="fail"?i:"unknown"}function We(e){const r=e.find(i=>i.health)?.health;return r?n`
    <div class="providers-health" role="note">
      <span class=${X(r.reachable)}>
        reachable ${J(r.reachable,"ok","failed")}
      </span>
      <span class=${X(r.auth)}>
        auth ${J(r.auth,"ok","failed")}
      </span>
      <span class=${r.modelsDiscovered>0?"chip ok":"chip"}>
        ${r.modelsDiscovered} discovered
      </span>
      <span class=${r.privateNetworkApproved?"chip ok":"chip warn"}>
        private network ${r.privateNetworkApproved?"approved":"blocked"}
      </span>
      ${r.detail?n`<span class="providers-health__detail">${r.detail}</span>`:p}
    </div>
  `:p}function Xe(e){const r=new Set(e.providerIds),i=e.modelCatalog.filter(u=>r.has(u.provider));if(i.length===0)return p;const o=u=>i.filter(O=>O.metadata&&u(O.metadata)).length,l=o(u=>u.features.includes("vision")),c=o(u=>u.features.includes("tools")),v=o(u=>u.features.includes("reasoning")),f=o(u=>u.streaming),R=o(u=>u.privateNetwork),M=o(u=>u.capabilityConfidence==="unknown");return n`
    <div class="providers-health providers-capabilities" role="note">
      <span class="chip ok">text ${i.length}</span>
      <span class=${l>0?"chip ok":"chip"}>vision ${l}</span>
      <span class=${c>0?"chip ok":"chip"}>tools ${c}</span>
      <span class=${v>0?"chip ok":"chip"}>reasoning ${v}</span>
      <span class=${f>0?"chip ok":"chip"}>streaming ${f}</span>
      <span class=${R>0?"chip warn":"chip"}>local/private ${R}</span>
      ${M>0?n`<span class="chip">unknown ${M}</span>`:p}
    </div>
  `}function I(e,r){const i=e.get(r);return typeof i=="string"?i.trim():""}function Je(e,r){return e.get(r)==="on"}async function er(e){const r=e?.trim();!r||typeof navigator>"u"||await navigator.clipboard?.writeText(r).catch(()=>{})}function rr(e){const r=e?.trim();if(!r)return"browser sign-in";try{return new URL(r).host||"browser sign-in"}catch{return"browser sign-in"}}function ir(e){const r=e?.trim();if(!r)return"Open sign-in link";try{const i=new URL(r),o=i.pathname&&i.pathname!=="/"?i.pathname:"";return`${i.host}${o}`}catch{return"Open sign-in link"}}function tr(e,r,i){const o=r.trim();!o||e.has(o)||!ce(o)||e.set(o,{value:o,label:i?.trim()||o})}function or(e){const r=new Map;for(const i of e.modelCatalog){const o=de(i);tr(r,o.value,o.label)}return Array.from(r.values()).toSorted((i,o)=>i.label.localeCompare(o.label))}function ar(e){const r=e.trim();return r?`${r}:default`:""}function nr(e){const r=e.runtimeProvider?.profiles??[],i=e.preferOauth?r.find(c=>c.type==="oauth")??null:null;if(i?.profileId)return i.profileId;const o=e.preferOauth?e.orderedProfiles.find(c=>c.mode==="oauth")??null:null;if(o?.id)return o.id;const l=r.find(c=>S(c.status));return l?.profileId?l.profileId:e.orderedProfiles[0]?.id??r[0]?.profileId??ar(e.providerId)}function sr(e){const r=e.runtimeProvider?.profiles??[];return r.find(o=>S(o.status))?.profileId??r[0]?.profileId??null}function dr(e,r){return e?.profiles.find(i=>i.type===r&&S(i.status))??null}function lr(e){return e?.authModes.some(r=>r==="api-key"||r==="api_key")??!1}function pr(e){return e?.authModes.some(r=>r==="oauth"||r==="device-code"||r==="device_code")??!1}function cr(e,r){const i=e.trim(),o=Ke[i];if(o)return{supported:!1,label:"API key",buttonLabel:"Save API",reason:o};const l=He[i];return l||lr(r)?{supported:!0,label:l??`${$(i)} API key`,buttonLabel:"Save API"}:{supported:!1,label:"API key",buttonLabel:"Save API",reason:"No API-key setup is available for this provider in the UI."}}function ur(e,r,i){const o=e.trim(),l=Ze[o];if(l)return{supported:!1,label:"Sign-in",buttonLabel:"Sign in",reason:l};const c=je[o],v=i.some(f=>f.mode==="oauth");return c||pr(r)||v?{supported:!0,label:c??`${$(o)} sign-in`,buttonLabel:"Sign in"}:{supported:!1,label:"Sign-in",buttonLabel:"Sign in",reason:"No OAuth/device/setup-token flow is available for this provider in the UI."}}function $(e){const r=le(e)??pe(e);return r?r.label:{anthropic:"Anthropic",chutes:"Chutes",gemini:"Google Gemini",google:"Google","google-gemini-cli":"Google Gemini CLI","github-copilot":"GitHub Copilot",minimax:"MiniMax","minimax-portal":"MiniMax Portal","openai-codex":"OpenAI sign-in",openai:"OpenAI",openrouter:"OpenRouter",lmstudio:"LM Studio",ollama:"Ollama","qwen-coding-plan":"Qwen Coding Plan",qwen:"Qwen",vllm:"Custom/vLLM",xai:"xAI"}[e]??e.split(/[-_]/g).filter(Boolean).map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" ")}function U(e){return e.kind==="token"||e.methodId==="token"||e.methodId==="setup-token"?"Token":e.kind==="api"?"API key":e.kind==="interactive"?"Sign in":e.label??$(e.providerId)}function vr(e,r){const i=[e.label,e.reason,e.setupRequirement,r?.reason,r?.label&&r.label!==U(e)?r.label:void 0].map(l=>l?.trim()).filter(l=>!!l),o=[...new Set(i)];return o.length>0?o.join(" · "):`${$(e.providerId)} ${U(e)}`}function G(e,r,i){return n`
    <span
      class="providers-method-help"
      role="img"
      tabindex="0"
      data-provider-method-help=${e.methodId??r}
      data-provider-method-help-text=${i}
      aria-label=${i}
      data-tooltip=${i}
    >
      <svg viewBox="0 0 24 24" aria-hidden="true">
        <circle cx="12" cy="12" r="10" />
        <path d="M9.09 9a3 3 0 1 1 5.82 1c0 2-3 2-3 4" />
        <path d="M12 17h.01" />
      </svg>
    </span>
  `}function re(e){return(e??"").split(/\r?\n/g).map(r=>r.trim()).filter(r=>r&&!r.toLowerCase().startsWith("summary:")).join(`
`)}function mr(e){return!e||e.actionKind!=="interactive"?e?.title??"":e.tone==="success"?"Sign in complete":e.tone==="danger"?"Sign in failed":e.tone==="warn"?"Sign in cancelled":e.prompt?"Continue sign in":"Sign in in progress"}function fr(e){return e?e.actionKind!=="interactive"?e.message.trim():e.tone==="success"?"Sign in completed.":e.tone==="danger"?"Sign in did not complete.":e.tone==="warn"?"Sign in was cancelled.":"Sign in is in progress.":""}function gr(e){if(!e)return"";const r=re(e.detail);return e.actionKind==="interactive"&&e.tone!=="danger"?"":r}function hr(e){return re(e).split(/\r?\n/g).map(i=>i.trim()).filter(Boolean)[0]??"Continue sign-in."}function br(e,r){const i=`${r}/`;return e.filter(o=>o.value===r||o.value.startsWith(i))}function Ir(e,r){const i=new Set,o=[];for(const l of r)for(const c of br(e,l))i.has(c.value)||(i.add(c.value),o.push(c));return o}function xr(e,r){const i=r.trim();return e.some(o=>i===o||i.startsWith(`${o}/`))}function yr(e){const r=e.indexOf("/");if(r<=0)return{value:e,label:e};const i=e.slice(0,r),o=e.slice(r+1);return{value:e,label:`${o} · ${i}`}}function _r(e){const r=e.providerCard.modelProviderIds??e.providerCard.routeIds,i=new Map(e.options.map(v=>[v.value,v])),o=new Set,l=[],c=v=>{const f=v.trim();!f||o.has(f)||!xr(r,f)||(o.add(f),l.push(i.get(f)??yr(f)))};for(const v of e.providerCard.modelRefs)c(v);if(l.length===0&&e.providerCard.modelRefs.length===0)for(const v of Ir(e.options,r))o.has(v.value)||(o.add(v.value),l.push(v));return l}function wr(e){const r=Fe(e.formValue??e.originalValue??{}),i=Be,o=or({config:e.formValue??e.originalValue??{},modelCatalog:e.modelCatalog}),l=mr(e.authAction),c=fr(e.authAction),v=gr(e.authAction),f=hr(e.authAction?.prompt?.message),R=!!c&&c!==f,M=a=>{a.preventDefault();const m=a.currentTarget,d=new FormData(m),h=I(d,"provider"),x=I(d,"secret");if(!h||!x){m.reportValidity();return}e.onStoreProviderApiKey({provider:h,secret:x}),m.reset()},u=a=>{a.preventDefault();const m=a.currentTarget,d=new FormData(m),h=I(d,"provider"),x=I(d,"secret"),E=I(d,"baseUrl"),k=I(d,"modelId"),y=I(d,"compatibility"),P=y==="anthropic"||y==="openai"||y==="unknown"?y:void 0,C=I(d,"customProviderId"),L=I(d,"alias"),t=I(d,"accountId"),g=I(d,"gatewayId");if(!h){m.reportValidity();return}e.onStoreManualProvider({provider:h,...x?{secret:x}:{},...E?{baseUrl:E}:{},...k?{modelId:k}:{},...P?{compatibility:P}:{},...C?{customProviderId:C}:{},...L?{alias:L}:{},...t?{accountId:t}:{},...g?{gatewayId:g}:{},...Je(d,"allowPrivateNetwork")?{allowPrivateNetwork:!0}:{}})},O=a=>{typeof window<"u"&&!window.confirm(`Clear the stored credential for "${a}"?`)||e.onClearProfileCredential(a)},z=a=>a.routeIds.some(m=>{const d=q(e.authStatus,m);return d?F(d):!1}),B=[...i].toSorted((a,m)=>{const d=z(a),h=z(m);return d!==h?d?-1:1:i.indexOf(a)-i.indexOf(m)});return n`
    <style>
      .providers-shell {
        display: grid;
        gap: 16px;
      }

      .providers-hero {
        display: grid;
        gap: 14px;
      }

      .providers-hero__actions,
      .providers-card__actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
      }

      .providers-grid {
        display: grid;
        gap: 12px;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
      }

      .providers-list {
        display: grid;
        gap: 8px;
      }

      .providers-local-quick {
        display: grid;
        gap: 8px;
        grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
      }

      .providers-local-quick__card {
        background: var(--panel);
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        display: grid;
        gap: 7px;
        padding: 11px;
      }

      .providers-local-quick__name {
        color: var(--text-strong);
        font-size: 13px;
        font-weight: 850;
      }

      .providers-local-quick__detail {
        color: var(--muted);
        font-size: 12px;
        line-height: 1.45;
      }

      .providers-provider {
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        background: var(--panel);
        overflow: visible;
      }

      .providers-provider[open] {
        border-color: color-mix(in srgb, var(--accent) 38%, var(--border));
      }

      .providers-provider__summary {
        align-items: center;
        cursor: pointer;
        display: grid;
        gap: 12px;
        grid-template-columns: minmax(0, 1fr) auto;
        list-style: none;
        padding: 14px 16px;
      }

      .providers-provider__summary::-webkit-details-marker {
        display: none;
      }

      .providers-provider__main {
        align-items: center;
        display: flex;
        gap: 10px;
        min-width: 0;
      }

      .providers-provider__dot {
        border-radius: 999px;
        background: var(--muted);
        flex: 0 0 auto;
        height: 9px;
        width: 9px;
      }

      .providers-provider__dot.ok {
        background: var(--success);
      }

      .providers-provider__dot.warn {
        background: var(--warning);
      }

      .providers-provider__name {
        color: var(--text-strong);
        font-size: 15px;
        font-weight: 850;
      }

      .providers-provider__name-row {
        align-items: baseline;
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
      }

      .providers-provider__model-count {
        color: var(--muted);
        font-size: 12px;
        font-weight: 700;
        line-height: 1.2;
      }

      .providers-provider__id,
      .providers-provider__meta {
        color: var(--muted);
        font-size: 12px;
        line-height: 1.45;
      }

      .providers-provider__status {
        align-items: center;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: flex-end;
      }

      .providers-provider__chips {
        align-items: center;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: flex-end;
      }

      .providers-provider__body {
        border-top: 1px solid var(--border);
        display: grid;
        gap: 14px;
        padding: 14px 16px 16px;
      }

      .providers-health {
        align-items: center;
        display: flex;
        flex-wrap: wrap;
        gap: 7px;
      }

      .providers-health__detail {
        color: var(--muted);
        font-size: 12px;
        line-height: 1.4;
        overflow-wrap: anywhere;
      }

      .providers-provider__setup {
        display: grid;
        gap: 12px;
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
      }

      .providers-catalog-gap {
        border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--border));
        border-radius: var(--radius-md);
        background: color-mix(in srgb, var(--accent) 7%, transparent);
        display: grid;
        gap: 4px;
        padding: 10px 12px;
      }

      .providers-catalog-gap.is-warn {
        border-color: color-mix(in srgb, var(--warning) 42%, var(--border));
        background: color-mix(in srgb, var(--warning) 8%, transparent);
      }

      .providers-catalog-gap__title {
        color: var(--text-strong);
        font-size: 13px;
        font-weight: 850;
      }

      .providers-catalog-gap__detail {
        color: var(--muted);
        font-size: 12px;
        line-height: 1.45;
      }

      .providers-card {
        display: grid;
        gap: 12px;
        min-width: 0;
        padding: 16px;
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        background: var(--panel);
      }

      .providers-card__head {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 10px;
      }

      .providers-card__title {
        color: var(--text-strong);
        font-size: 18px;
        font-weight: 800;
        min-width: 0;
        overflow-wrap: anywhere;
      }

      .providers-card__meta {
        color: var(--muted);
        font-size: 12px;
        line-height: 1.45;
      }

      .providers-empty {
        color: var(--muted);
        font-size: 13px;
      }

      .providers-setup-grid {
        display: grid;
        gap: 12px;
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
      }

      .providers-setup-card {
        display: grid;
        gap: 10px;
        align-content: start;
        grid-template-rows: auto 1fr auto;
        min-width: 0;
        overflow: visible;
        padding: 12px;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--panel);
      }

      .providers-setup-card.is-disabled {
        background: color-mix(in srgb, var(--panel) 72%, var(--muted) 8%);
      }

      .providers-setup-card__title {
        color: var(--text-strong);
        font-weight: 800;
      }

      .providers-setup-card__title-row {
        align-items: center;
        display: flex;
        gap: 8px;
        justify-content: flex-start;
        min-width: 0;
      }

      .providers-setup-card__title-row .providers-setup-card__title {
        min-width: 0;
        order: 1;
        overflow-wrap: anywhere;
      }

      .providers-method-status {
        background: color-mix(in srgb, var(--muted) 36%, transparent);
        border: 1px solid color-mix(in srgb, var(--muted) 46%, transparent);
        border-radius: 999px;
        flex: 0 0 auto;
        height: 8px;
        order: 0;
        width: 8px;
      }

      .providers-method-status.ok {
        background: var(--success);
        border-color: var(--success);
      }

      .providers-method-help {
        align-items: center;
        background: transparent;
        border: 1px solid var(--border);
        border-radius: 999px;
        color: var(--muted);
        cursor: help;
        display: inline-flex;
        flex: 0 0 auto;
        height: 24px;
        justify-content: center;
        order: 2;
        padding: 0;
        position: relative;
        width: 24px;
      }

      .providers-method-help:hover,
      .providers-method-help:focus-visible {
        background: var(--secondary);
        border-color: var(--accent-muted);
        color: var(--text-strong);
        outline: none;
      }

      .providers-method-help svg {
        fill: none;
        height: 14px;
        stroke: currentColor;
        stroke-linecap: round;
        stroke-linejoin: round;
        stroke-width: 2;
        width: 14px;
      }

      .providers-method-help::after {
        background: var(--panel);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        bottom: calc(100% + 8px);
        box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
        color: var(--text);
        content: attr(data-tooltip);
        display: none;
        font-size: 12px;
        font-weight: 600;
        inline-size: min(280px, calc(100vw - 32px));
        left: 50%;
        line-height: 1.45;
        padding: 10px 12px;
        pointer-events: none;
        position: absolute;
        transform: translateX(-50%);
        white-space: normal;
        z-index: 20;
      }

      .providers-method-help:hover::after,
      .providers-method-help:focus-visible::after {
        display: block;
      }

      .providers-setup-card__sub {
        color: var(--muted);
        font-size: 12px;
        line-height: 1.45;
      }

      .providers-form-grid {
        display: grid;
        gap: 8px;
      }

      .providers-field {
        display: grid;
        gap: 7px;
        color: var(--muted);
        font-size: 12px;
        font-weight: 680;
      }

      .providers-field input,
      .providers-field select {
        background: var(--secondary);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        box-sizing: border-box;
        color: var(--text-strong);
        height: 38px;
        font-weight: 500;
        max-width: 100%;
        max-inline-size: 100%;
        min-height: 40px;
        min-width: 0;
        inline-size: 100%;
        overflow: hidden;
        padding: 9px 11px;
        text-overflow: ellipsis;
        width: 100%;
      }

      .providers-checkbox {
        align-items: center;
        color: var(--muted);
        display: flex;
        font-size: 12px;
        font-weight: 700;
        gap: 8px;
      }

      .providers-checkbox input {
        height: auto;
        min-height: 0;
      }

      .providers-field--bare {
        gap: 0;
      }

      .providers-setup-card .btn {
        align-self: end;
        min-height: 38px;
      }

      .providers-setup-card--model .providers-field {
        align-self: end;
        min-width: 0;
      }

      .providers-setup-card--model {
        overflow: hidden;
      }

      .providers-setup-card--agent-models .btn {
        align-items: center;
        color: #05150c;
        display: inline-flex;
        gap: 6px;
        font-weight: 850;
      }

      .providers-setup-card--agent-models .btn svg {
        color: #05150c;
        height: 16px;
        stroke: #05150c;
        stroke-width: 3;
        width: 16px;
      }

      .providers-model-tags {
        align-items: center;
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        margin-top: 6px;
      }

      .providers-model-tag {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 999px;
        color: var(--text);
        display: inline-flex;
        font-size: 12px;
        font-weight: 750;
        max-width: min(100%, 340px);
        overflow: hidden;
        padding: 5px 8px;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .providers-inline-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
      }

      .providers-auth-dialog {
        background: var(--panel);
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        box-shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
        color: var(--text);
        max-width: min(560px, calc(100vw - 28px));
        padding: 0;
        width: 560px;
      }

      .providers-auth-dialog::backdrop {
        background: rgba(0, 0, 0, 0.58);
      }

      .providers-auth-dialog__body {
        display: grid;
        gap: 10px;
        padding: 16px;
      }

      .providers-auth-dialog__head {
        align-items: center;
        display: flex;
        gap: 10px;
        justify-content: space-between;
      }

      .providers-auth-dialog__title {
        color: var(--text-strong);
        font-size: 16px;
        font-weight: 850;
      }

      .providers-auth-link {
        align-items: center;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: color-mix(in srgb, var(--panel) 88%, var(--surface) 12%);
        display: grid;
        gap: 8px;
        grid-template-columns: minmax(0, 1fr) auto;
        padding: 10px;
      }

      .providers-auth-link__summary {
        display: grid;
        gap: 2px;
        min-width: 0;
      }

      .providers-auth-link__label {
        color: var(--text-strong);
        font-size: 13px;
        font-weight: 780;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      a.providers-auth-link__label:hover {
        color: var(--accent);
      }

      .providers-auth-link__host {
        color: var(--muted);
        font-size: 12px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .providers-auth-link__actions {
        display: flex;
        gap: 6px;
      }

      .providers-auth-prompt {
        border-top: 1px solid var(--border);
        display: grid;
        gap: 10px;
        margin-top: 4px;
        padding-top: 12px;
      }

      .providers-auth-prompt__message {
        color: var(--muted);
        font-size: 12px;
        line-height: 1.45;
      }

      .providers-auth-prompt input,
      .providers-auth-prompt select {
        background: var(--secondary);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        color: var(--text-strong);
        height: 40px;
        padding: 9px 11px;
        width: 100%;
      }

      .providers-auth-prompt__actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: flex-end;
      }

      .providers-icon-btn {
        align-items: center;
        display: inline-flex;
        height: 32px;
        justify-content: center;
        padding: 0;
        width: 32px;
      }

      .providers-icon-btn svg {
        height: 16px;
        width: 16px;
      }
    </style>

    <section class="providers-shell">
      ${e.error||e.authAction?n`
              <section class="card providers-hero">
                ${e.error?n`<div class="callout warn">${e.error}</div>`:p}
        ${e.authAction?n`
                <dialog
                  class="providers-auth-dialog"
                  open
                  @cancel=${a=>{a.preventDefault(),e.onAuthActionDismiss()}}
                >
                  <form class="providers-auth-dialog__body" method="dialog">
                    <div class="providers-auth-dialog__head">
                      <div class="providers-auth-dialog__title">${l}</div>
                      <button
                        type="button"
                        class="btn btn--sm btn--ghost"
                        @click=${()=>e.onAuthActionDismiss()}
                      >
                        Close
                      </button>
                    </div>
                    ${R?n`
                            <div class=${Ge(e.authAction.tone)}>
                              ${c}
                            </div>
                          `:p}
                    ${v?n`
                          <div class="providers-setup-card__sub" style="margin-top: 6px;">
                            ${v}
                          </div>
                        `:p}
                  ${e.authAction.hasUrl&&e.authAction.url?n`
                          <div class="providers-auth-link">
                            <div class="providers-auth-link__summary" title=${e.authAction.url}>
                              <a
                                class="providers-auth-link__label"
                                href=${e.authAction.url}
                                target="_blank"
                                rel="noreferrer"
                                aria-label="Open sign-in link"
                              >
                                ${ir(e.authAction.url)}
                              </a>
                              <div class="providers-auth-link__host">
                                ${rr(e.authAction.url)} · full URL hidden
                              </div>
                            </div>
                            <div class="providers-auth-link__actions">
                              <button
                                type="button"
                                class="btn btn--sm providers-icon-btn"
                                title="Copy sign-in link"
                                aria-label="Copy sign-in link"
                                @click=${()=>{er(e.authAction?.url)}}
                              >
                                ${se.copy}
                              </button>
                            </div>
                          </div>
                        `:p}
                  ${e.authAction.prompt?n`
                          <div
                            class="providers-auth-prompt"
                            data-auth-prompt=${e.authAction.prompt.stepId}
                          >
                            <div class="providers-auth-prompt__message">
                              ${f}
                            </div>
                            ${e.authAction.prompt.type==="note"||e.authAction.prompt.type==="action"?n`
                                    <div class="providers-auth-prompt__actions">
                                      <button
                                        type="button"
                                        class="btn"
                                        @click=${()=>e.onAuthPromptCancel()}
                                      >
                                        Cancel
                                      </button>
                                      <button
                                        type="button"
                                        class="btn primary"
                                        @click=${()=>e.onAuthPromptSubmit(null)}
                                      >
                                        Continue
                                      </button>
                                    </div>
                                  `:e.authAction.prompt.type==="confirm"?n`
                                      <div class="providers-auth-prompt__actions">
                                        <button
                                        type="button"
                                        class="btn"
                                        @click=${()=>e.onAuthPromptSubmit(!1)}
                                      >
                                        No
                                      </button>
                                      <button
                                        type="button"
                                        class="btn primary"
                                        @click=${()=>e.onAuthPromptSubmit(!0)}
                                      >
                                        Yes
                                      </button>
                                    </div>
                                  `:e.authAction.prompt.type==="select"?n`
                                      <select
                                        aria-label="Provider sign-in selection"
                                        @change=${a=>{const m=a.currentTarget;e.onAuthPromptSubmit(m.value)}}
                                      >
                                        <option value="">Choose...</option>
                                        ${(e.authAction.prompt.options??[]).map(a=>n`
                                            <option
                                              value=${String(a.value)}
                                              ?selected=${a.value===e.authAction?.prompt?.initialValue}
                                            >
                                              ${a.label}
                                            </option>
                                          `)}
                                      </select>
                                    `:n`
                                      <input
                                        type="text"
                                        autocomplete="off"
                                        aria-label="Provider sign-in response"
                                        placeholder=${e.authAction.prompt.placeholder??""}
                                        .value=${typeof e.authAction.prompt.initialValue=="string"?e.authAction.prompt.initialValue:""}
                                        @keydown=${a=>{if(a.key!=="Enter")return;a.preventDefault();const m=a.currentTarget;e.onAuthPromptSubmit(m.value)}}
                                      />
                                      <div class="providers-auth-prompt__actions">
                                        <button
                                          type="button"
                                          class="btn"
                                          @click=${()=>e.onAuthPromptCancel()}
                                        >
                                          Cancel
                                        </button>
                                        <button
                                          type="button"
                                          class="btn primary"
                                          @click=${a=>{const d=a.currentTarget.closest(".providers-auth-prompt")?.querySelector("input");e.onAuthPromptSubmit(d?.value??"")}}
                                        >
                                          Continue
                                        </button>
                                      </div>
                                    `}
                          </div>
                        `:p}
                  </form>
                </dialog>
              `:p}
              </section>
            `:p}

      ${e.surface==="agent"?p:n`
              <section class="providers-local-quick" aria-label="Local model quick setup">
                <div class="providers-local-quick__card">
                  <div class="providers-local-quick__name">Ollama</div>
                  <div class="providers-local-quick__detail">
                    Native Ollama on localhost or tailnet. Use this for
                    <code>ollama pull</code> models and native <code>/api/chat</code>.
                  </div>
                </div>
                <div class="providers-local-quick__card">
                  <div class="providers-local-quick__name">LM Studio</div>
                  <div class="providers-local-quick__detail">
                    Best for LM Studio's local server on <code>localhost:1234</code>. Token is optional unless
                    your server requires it.
                  </div>
                </div>
                <div class="providers-local-quick__card">
                  <div class="providers-local-quick__name">Custom/vLLM-compatible</div>
                  <div class="providers-local-quick__detail">
                    Use for vLLM, SGLang, TGI, LocalAI, FastChat, or other OpenAI-compatible endpoints.
                  </div>
                </div>
              </section>
            `}

      <section class="providers-list" aria-label="Provider status">
        ${B.length===0?n`
                <section class="card providers-card">
                  <div class="providers-card__title">No providers loaded</div>
                  <div class="providers-card__meta">
                    Refresh provider status. Use Advanced Config only for raw provider fields such
                    as custom base URLs, headers, model catalogs, and private-network options.
                  </div>
                  <div class="providers-card__actions">
                    <button class="btn" @click=${()=>e.onRefresh()}>Refresh</button>
                    <button class="btn" @click=${()=>e.onOpenConfigSection("models")}>
                      Advanced Config
                    </button>
                  </div>
                </section>
              `:B.map(a=>{const d=a.routeIds.map(t=>q(e.authStatus,t)).filter(t=>!!t),h=d.some(t=>F(t)),x=d.find(t=>F(t))?.status??d[0]?.status??null,E=_r({options:o,providerCard:a}),k=Ye(e.modelCatalogStatus,a),y=a.modelRefs.length||E.length,P=d.map(t=>sr({runtimeProvider:t})).find(t=>!!t)??null,C=`${y} ${y===1?"model":"models"}`,L=e.providerSetupExtra?.({id:a.id,label:a.label,routeIds:[...a.routeIds],modelProviderIds:[...a.modelProviderIds??a.routeIds],modelCount:y,ready:h})??p;return n`
                  <details
                    class="providers-provider"
                    data-provider-card=${a.id}
                    data-provider-card-order=${`provider-card:${a.id}`}
                  >
                    <summary class="providers-provider__summary">
                      <div class="providers-provider__main">
                        <span
                          class="providers-provider__dot ${h?"ok":x?"warn":""}"
                          aria-hidden="true"
                        ></span>
                        <div>
                          <div class="providers-provider__name-row">
                            <span class="providers-provider__name">${a.label}</span>
                            <span class="providers-provider__model-count">${C}</span>
                          </div>
                        </div>
                      </div>
                      <div class="providers-provider__status">
                        <div class="providers-provider__chips">
                          ${h?p:n`<span class=${Qe(x)}>Sign in</span>`}
                          ${p}
                          ${k.some(t=>t.health)?n`<span class=${k.some(t=>t.probeStatus==="ok")?"chip ok":"chip warn"}>health</span>`:p}
                        </div>
                        ${P?n`
                                <button
                                  type="button"
                                  class="btn btn--sm"
                                  ?disabled=${e.authActionBusyProfileId===P}
                                  @click=${t=>{t.preventDefault(),t.stopPropagation(),O(P)}}
                                >
                                  × Clear
                                </button>
                              `:p}
                      </div>
                    </summary>
                    <div class="providers-provider__body">
                      ${We(k)}
                      ${Xe({providerIds:a.modelProviderIds??a.routeIds,modelCatalog:e.modelCatalog})}
                      ${p}
                      <div class="providers-provider__setup">
                        ${a.authMethods.map(t=>{const g=t.providerId,T=t.statusProviderId??g,H=r.providers.find(A=>A.id===T),j=ee(e.modelCatalogStatus,T),K=q(e.authStatus,T),Z=H?Ue(H):[];if(t.kind==="manual"){if(t.methodId==="vllm"||t.methodId==="ollama"||t.methodId==="lmstudio"){const A=t.methodId==="ollama",w=t.methodId==="lmstudio",Y=A?"ollama":w?"lmstudio":"vllm",W=A?"http://127.0.0.1:11434":w?"http://127.0.0.1:1234/v1":"http://127.0.0.1:8000/v1",ae=A?"llama3.3:latest":w?"qwen/qwen3.5-9b":"meta-llama/Meta-Llama-3-8B-Instruct or sglang-served-model",ne=A?"Optional API key; blank uses local marker":w?"Optional LM Studio API token":"API key, local placeholder, or vllm-local";return n`
                                <form
                                  class="providers-setup-card"
                                  data-provider-method-id=${t.methodId??""}
                                  @submit=${u}
                                >
                                  <div>
                                    <div class="providers-setup-card__title">
                                      ${t.label??$(Y)}
                                    </div>
                                    <div class="providers-setup-card__sub">
                                      ${A?"Native Ollama. Do not add /v1.":w?"LM Studio local server. Discovery reads /api/v1/models.":"OpenAI-compatible local servers: vLLM, SGLang, TGI, LocalAI, FastChat."}
                                    </div>
                                  </div>
                                  <input type="hidden" name="provider" value=${Y} />
                                  <label class="providers-field">
                                    Base URL
                                    <input
                                      name="baseUrl"
                                      type="url"
                                      required
                                      placeholder=${W}
                                      value=${W}
                                    />
                                  </label>
                                  <label class="providers-field">
                                    Model ID
                                    <input
                                      name="modelId"
                                      type="text"
                                      required
                                      placeholder=${ae}
                                    />
                                  </label>
                                  <label class="providers-field providers-field--bare">
                                    <input
                                      name="secret"
                                      type="password"
                                      ?required=${!A&&!w}
                                      placeholder=${ne}
                                      autocomplete="off"
                                    />
                                  </label>
                                  <button
                                    type="submit"
                                    class="btn primary"
                                    ?disabled=${e.loading||!e.connected}
                                  >
                                    Configure
                                  </button>
                                </form>
                              `}return t.methodId==="cloudflare-ai-gateway-api-key"?n`
                                <form
                                  class="providers-setup-card"
                                  data-provider-method-id=${t.methodId??""}
                                  @submit=${u}
                                >
                                  <div>
                                    <div class="providers-setup-card__title">
                                      Cloudflare AI
                                    </div>
                                  </div>
                                  <input
                                    type="hidden"
                                    name="provider"
                                    value="cloudflare-ai-gateway"
                                  />
                                  <label class="providers-field">
                                    Account ID
                                    <input name="accountId" type="text" required autocomplete="off" />
                                  </label>
                                  <label class="providers-field">
                                    Gateway ID
                                    <input name="gatewayId" type="text" required autocomplete="off" />
                                  </label>
                                  <label class="providers-field providers-field--bare">
                                    <input
                                      name="secret"
                                      type="password"
                                      required
                                      placeholder="Anthropic API key"
                                      autocomplete="off"
                                    />
                                  </label>
                                  <button
                                    type="submit"
                                    class="btn primary"
                                    ?disabled=${e.loading||!e.connected}
                                  >
                                    Configure
                                  </button>
                                </form>
                              `:n`
                              <form
                                class="providers-setup-card"
                                data-provider-method-id=${t.methodId??""}
                                @submit=${u}
                              >
                                <div>
                                  <div class="providers-setup-card__title">
                                    ${t.label??$(g)}
                                  </div>
                                </div>
                                <input type="hidden" name="provider" value="custom" />
                                <label class="providers-field">
                                  Base URL
                                  <input
                                    name="baseUrl"
                                    type="url"
                                    required
                                    placeholder="https://models.example.com/v1"
                                  />
                                </label>
                                <label class="providers-field">
                                  API format
                                  <select name="compatibility" required>
                                    <option value="openai">OpenAI-compatible</option>
                                    <option value="anthropic">Anthropic-compatible</option>
                                    <option value="unknown">Detect automatically</option>
                                  </select>
                                </label>
                                <label class="providers-field">
                                  Model ID
                                  <input
                                    name="modelId"
                                    type="text"
                                    required
                                    placeholder="provider/model-or-deployment"
                                  />
                                </label>
                                <label class="providers-field">
                                  Endpoint ID
                                  <input
                                    name="customProviderId"
                                    type="text"
                                    placeholder="optional stable id"
                                    autocomplete="off"
                                  />
                                </label>
                                <label class="providers-field">
                                  Alias
                                  <input
                                    name="alias"
                                    type="text"
                                    placeholder="optional model shortcut"
                                    autocomplete="off"
                                  />
                                </label>
                                <label class="providers-field providers-field--bare">
                                  <input
                                    name="secret"
                                    type="password"
                                    placeholder="API key if required"
                                    autocomplete="off"
                                  />
                                </label>
                                <label class="providers-checkbox">
                                  <input name="allowPrivateNetwork" type="checkbox" />
                                  Allow local/private endpoint
                                </label>
                                <button
                                  type="submit"
                                  class="btn primary"
                                  ?disabled=${e.loading||!e.connected}
                                >
                                  Save provider
                                </button>
                              </form>
                            `}const Q=t.kind==="api"?cr(g,j):ur(g,j,Z),_=t.label?{...Q,label:t.label,...t.buttonLabel?{buttonLabel:t.buttonLabel}:{}}:Q,D=U(t),N=vr(t,_),V=t.kind==="token"||t.methodId==="token"||t.methodId==="setup-token",ie=t.kind==="api"?"api_key":V?"token":"oauth",te=dr(K,ie),b=_.supported&&!!te;if(!_.supported)return n`
                              <div class="providers-setup-card is-disabled">
                                <div>
                                  <div class="providers-setup-card__title-row">
                                    <span
                                      class="providers-method-status ${b?"ok":""}"
                                      title=${b?"Credential ready":"Credential not saved"}
                                      aria-label=${b?"Credential ready":"Credential not saved"}
                                    ></span>
                                    <div class="providers-setup-card__title">${D}</div>
                                    ${G(t,g,N)}
                                  </div>
                                  ${t.setupRequirement?n`
                                          <div class="providers-setup-card__sub">
                                            ${t.setupRequirement}
                                          </div>
                                        `:p}
                                  ${_.reason?n`<div class="providers-setup-card__sub">${_.reason}</div>`:p}
                                </div>
                              </div>
                            `;if(t.kind==="api")return n`
                              <form
                                class="providers-setup-card"
                                data-provider-api-key-form="true"
                                data-provider-method-id=${t.methodId??""}
                                @submit=${M}
                              >
                                <div>
                                  <div class="providers-setup-card__title-row">
                                    <span
                                      class="providers-method-status ${b?"ok":""}"
                                      title=${b?"Credential ready":"Credential not saved"}
                                      aria-label=${b?"Credential ready":"Credential not saved"}
                                    ></span>
                                    <div class="providers-setup-card__title">${D}</div>
                                    ${G(t,g,N)}
                                  </div>
                                  ${t.setupRequirement?n`
                                          <div class="providers-setup-card__sub">
                                            ${t.setupRequirement}
                                          </div>
                                        `:p}
                                </div>
                                <input type="hidden" name="provider" .value=${g} />
                                <label class="providers-field providers-field--bare">
                                  <input
                                    name="secret"
                                    type="password"
                                    required
                                    placeholder="Paste API key"
                                    aria-label=${_.label}
                                    autocomplete="off"
                                  />
                                </label>
                                <button
                                  type="submit"
                                  class="btn primary"
                                  ?disabled=${e.loading||!e.connected}
                                >
                                  ${b?"Update API":_.buttonLabel}
                                </button>
                              </form>
                            `;const oe=nr({providerId:g,runtimeProvider:K,orderedProfiles:Z,preferOauth:!V});return n`
                            <div class="providers-setup-card">
                              <div>
                                <div class="providers-setup-card__title-row">
                                  <span
                                    class="providers-method-status ${b?"ok":""}"
                                    title=${b?"Credential ready":"Credential not saved"}
                                    aria-label=${b?"Credential ready":"Credential not saved"}
                                  ></span>
                                  <div class="providers-setup-card__title">${D}</div>
                                  ${G(t,g,N)}
                                </div>
                                ${t.setupRequirement?n`
                                        <div class="providers-setup-card__sub">
                                          ${t.setupRequirement}
                                        </div>
                                      `:p}
                              </div>
                              <button
                                type="button"
                                class="btn"
                                data-provider-sign-in-button=${g}
                                data-provider-method-id=${t.methodId??""}
                                ?disabled=${e.loading||!e.connected}
                                @click=${()=>e.onRunProviderSignIn({provider:g,profileId:oe,...t.methodId?{methodId:t.methodId}:{}})}
                              >
                                ${b?V?"Update token":"Sign in again":_.buttonLabel}
                              </button>
                            </div>
                          `})}
                        ${L}

                      </div>
                    </div>
                  </details>
                `})}
      </section>
    </section>
  `}export{wr as renderProviders};
//# sourceMappingURL=providers-0YmtCPD-.js.map
