manifest
Version:
Self-hosted Manifest LLM router with embedded server, SQLite database, and dashboard
1 lines • 93.5 kB
JavaScript
import{a as B,i as n,g as i,h as A,s as Z,S as g,m as H,z as ue,F as _e,t as r,d as re,j as ve,I as ft,o as ut,e as pt,l as _t,P as bt,k as pe,p as xe,n as $t,u as yt,D as kt,T as wt,M as Ct}from"./vendor-C-Y5oNOq.js";import{S as Fe,c as we,p as he,b as Pe,r as be,i as Se,P as Q,v as We,d as qe,e as xt,f as Pt,h as gt,s as St}from"./routing-utils-CHapjwyd.js";import{q as Ne,B as Ke,e as vt,c as Ce,t as G,d as ht,l as Tt,b as Le}from"./index-C4Qw7vZo.js";import{d as Mt,u as At,c as Dt,b as ye,e as Lt,f as It,h as Te,s as Ee,i as Bt,j as Rt,r as Ut,k as Et,o as Ot,l as Ft,m as Nt,n as Kt,g as zt,p as jt}from"./routing-CLLAl6kl.js";import{C as Me}from"./CopyButton-BWMVlK2w.js";import{g as Vt}from"./provider-api-key-urls-1G6okUJ7.js";import{a as ze}from"./AuthBadge-Dj2KkXRW.js";import"./auth-CU91cd7V.js";function Ht(e){return vt("/oauth/openai/authorize",{agentName:e})}function Wt(e,a){return Ne(`${Ke}/oauth/openai/callback`,{method:"POST",body:JSON.stringify({code:e,state:a}),headers:{"Content-Type":"application/json"}})}function je(e){return Ne(`${Ke}/oauth/openai/revoke?agentName=${encodeURIComponent(e)}`,{method:"POST"})}function qt(e,a="global"){return Ne(`${Ke}/oauth/minimax/start?agentName=${encodeURIComponent(e)}®ion=${encodeURIComponent(a)}`,{method:"POST"})}function Zt(e){return vt("/oauth/minimax/poll",{flowId:e})}var Gt=r('<div class=provider-modal__tabs-wrapper><div class=panel__tabs role=tablist><button role=tab class=panel__tab><svg class=provider-modal__tab-icon width=14 height=14 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2.5 stroke-linecap=round stroke-linejoin=round aria-hidden=true style=color:#1cc4bf><path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"></path><circle cx=12 cy=7 r=4></circle></svg>Subscription</button><button role=tab class=panel__tab><svg class=provider-modal__tab-icon width=14 height=14 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2.5 stroke-linecap=round stroke-linejoin=round aria-hidden=true style=color:#e59d55><path d="m21 2-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0 3 3L22 7l-3-3m-3.5 3.5L19 4"></path></svg>API Keys'),Jt=r('<div class=routing-modal__search-wrap><svg class=routing-modal__search-icon width=15 height=15 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round aria-hidden=true><circle cx=11 cy=11 r=8></circle><path d="m21 21-4.3-4.3"></path></svg><input class=routing-modal__search type=text placeholder="Search models or providers..."aria-label="Search models or providers"autofocus>'),Yt=r("<svg><rect x=3 y=3 width=18 height=18 rx=3 stroke-width=2 fill=currentColor></svg>",!1,!0,!1),Xt=r('<svg><path d="m9 12 2 2 4-4"stroke=hsl(var(--card))></svg>',!1,!0,!1),Qt=r('<div class=routing-modal__filter-bar><button type=button class=routing-modal__filter-pill><svg class=routing-modal__filter-check width=14 height=14 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2.5 stroke-linecap=round stroke-linejoin=round aria-hidden=true></svg>Free models only'),en=r("<div class=routing-modal__empty>"),tn=r('<div class=modal-overlay><div class=modal-card role=dialog aria-modal=true aria-labelledby=model-picker-title style=max-width:600px;padding:0;display:flex;flex-direction:column;max-height:80vh><div class=routing-modal__header><div><div class=routing-modal__title id=model-picker-title>Select a model</div><div class=routing-modal__subtitle> tier</div></div><button class=modal__close aria-label=Close><svg width=16 height=16 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round aria-hidden=true><path d="M18 6 6 18"></path><path d="m6 6 12 12"></path></svg></button></div><div class=routing-modal__list>'),nn=r("<svg><rect x=3 y=3 width=18 height=18 rx=3 stroke-width=2></svg>",!1,!0,!1),rn=r("<div class=routing-modal__group><div class=routing-modal__group-header><span class=routing-modal__group-icon></span><span class=routing-modal__group-name>"),ln=r("<span class=provider-card__logo-letter style=width:16px;height:16px;font-size:9px;border-radius:50%>"),an=r("<span class=routing-modal__recommended> (recommended)"),on=r("<button class=routing-modal__model><span class=routing-modal__model-label>"),sn=r("<span class=routing-modal__role-tag>"),dn=r('<span class="routing-modal__model-id routing-modal__model-id--subscription">Included in subscription'),cn=r("<span class=routing-modal__model-id> in · <!> out per 1M");function un(e,a){const f=a.get(e);if(f)return f;const b=e.indexOf("/");if(b!==-1){const u=e.substring(b+1),m=a.get(u);return m||u}return e}const _n=e=>e.input_price_per_token!=null&&e.output_price_per_token!=null&&Number(e.input_price_per_token)===0&&Number(e.output_price_per_token)===0,Ze=e=>{const a=()=>(e.connectedProviders??[]).some(t=>t.is_active&&t.auth_type==="subscription"),f=()=>(e.connectedProviders??[]).some(t=>t.is_active&&t.auth_type==="api_key"),b=()=>a()&&f(),[u,m]=B(a()?"subscription":"api_key"),[y,S]=B(""),[p,T]=B(!1),_=()=>{const t=new Map;for(const o of Q)for(const c of o.models)t.set(c.value,c.label);return t},l=()=>{const t=new Map;for(const o of e.customProviders??[])t.set(`custom:${o.id}`,o.name);return t},s=t=>{const o=new Set;for(const c of e.connectedProviders??[])if(c.is_active&&c.auth_type===t){o.add(c.provider.toLowerCase());const $=be(c.provider);$&&o.add($)}return o},v=()=>{const t=y().toLowerCase().trim(),o=_(),c=l(),$=u(),D=(e.connectedProviders??[]).length>0,P=new Map,I=$==="api_key"&&p(),q=D?s($):void 0;for(const k of e.models){if(b()&&k.auth_type&&k.auth_type!==$||I&&!_n(k))continue;const M=be(k.provider),C=Se(k.model_name),U=M==="ollama"?"ollama":C&&Q.find(N=>N.id===C)?C:M??C;if(!U||q&&!q.has(U))continue;if(!P.has(U)){const N=U.startsWith("custom:"),E=Q.find(F=>F.id===U),V=N?k.provider_display_name??c.get(U)??k.provider:E?.name??k.provider;P.set(U,{provId:U,name:V,models:[]})}const j=k.display_name||un(k.model_name,o);P.get(U).models.push({value:k.model_name,label:j,pricing:k})}const z=[];for(const k of P.values())if(k.models.sort((M,C)=>M.value==="openrouter/free"?-1:C.value==="openrouter/free"?1:M.label.localeCompare(C.label)),t){const C=k.name.toLowerCase().includes(t)?k.models:k.models.filter(U=>U.label.toLowerCase().includes(t)||U.value.toLowerCase().includes(t));C.length>0&&z.push({...k,models:C})}else k.models.length>0&&z.push(k);return z.sort((k,M)=>k.name.localeCompare(M.name)),z},h=t=>e.tiers.find(c=>c.tier===e.tierId)?.auto_assigned_model===t,w=t=>{const o=e.tiers.find(P=>P.tier===e.tierId);if(!o)return null;if((o.override_model??o.auto_assigned_model)===t)return"Primary";const D=(o.fallback_models??[]).indexOf(t);return D!==-1?`Fallback ${D+1}`:null},x=()=>v().reduce((t,o)=>t+o.models.length,0),R=()=>y()?e.models.length:x(),d=()=>u()==="subscription";return(()=>{var t=tn(),o=t.firstChild,c=o.firstChild,$=c.firstChild,D=$.firstChild,P=D.nextSibling,I=P.firstChild,q=$.nextSibling,z=c.nextSibling;return t.$$keydown=k=>{k.key==="Escape"&&e.onClose()},t.$$click=k=>{k.target===k.currentTarget&&e.onClose()},n(P,()=>Fe.find(k=>k.id===e.tierId)?.label,I),q.$$click=()=>e.onClose(),n(o,i(g,{get when(){return b()},get children(){var k=Gt(),M=k.firstChild,C=M.firstChild,U=C.nextSibling;return C.$$click=()=>{m("subscription"),T(!1)},U.$$click=()=>m("api_key"),A(j=>{var N=u()==="subscription",E=u()==="subscription",V=u()==="api_key",F=u()==="api_key";return N!==j.e&&Z(C,"aria-selected",j.e=N),E!==j.t&&C.classList.toggle("panel__tab--active",j.t=E),V!==j.a&&Z(U,"aria-selected",j.a=V),F!==j.o&&U.classList.toggle("panel__tab--active",j.o=F),j},{e:void 0,t:void 0,a:void 0,o:void 0}),k}}),z),n(o,i(g,{get when(){return R()>5},get children(){var k=Jt(),M=k.firstChild,C=M.nextSibling;return C.$$input=U=>S(U.currentTarget.value),A(()=>C.value=y()),k}}),z),n(o,i(g,{get when(){return!d()},get children(){var k=Qt(),M=k.firstChild,C=M.firstChild;return M.$$click=()=>T(!p()),n(C,i(g,{get when(){return p()},get fallback(){return nn()},get children(){return[Yt(),Xt()]}})),A(()=>M.classList.toggle("routing-modal__filter-pill--active",!!p())),k}}),z),n(z,i(_e,{get each(){return v()},children:k=>(()=>{var M=rn(),C=M.firstChild,U=C.firstChild,j=U.nextSibling;return n(U,(()=>{var N=H(()=>!!k.provId.startsWith("custom:"));return()=>N()?(()=>{const E=(e.customProviders??[]).find(V=>`custom:${V.id}`===k.provId);return we(k.name,16,E?.base_url)??(()=>{var V=ln();return n(V,()=>k.name.charAt(0).toUpperCase()),A(F=>ue(V,"background",Ce(k.name))),V})()})():he(k.provId,16)})()),n(j,()=>k.name),n(M,i(_e,{get each(){return k.models},children:N=>(()=>{var E=on(),V=E.firstChild;return E.$$click=()=>e.onSelect(e.tierId,N.value,k.provId,u()),n(V,()=>N.label,null),n(V,i(g,{get when(){return h(N.value)},get children(){return an()}}),null),n(V,i(g,{get when(){return w(N.value)},children:F=>(()=>{var W=sn();return n(W,F),W})()}),null),n(E,i(g,{get when(){return!d()},get fallback(){return dn()},get children(){return i(g,{get when(){return N.pricing},children:F=>(()=>{var W=cn(),L=W.firstChild,O=L.nextSibling;return O.nextSibling,n(W,()=>Pe(F().input_price_per_token),L),n(W,()=>Pe(F().output_price_per_token),O),W})()})}}),null),E})()}),null),M})()}),null),n(z,i(g,{get when(){return v().length===0},get children(){var k=en();return n(k,(()=>{var M=H(()=>!!y().trim());return()=>M()?"No models match your search.":H(()=>!!p())()?"No free models available from your connected providers.":d()?"No subscription providers connected. Connect a provider to see models.":"No API key providers connected. Connect a provider to see models."})()),k}}),null),t})()};re(["click","keydown","input"]);var gn=r('<div class=provider-detail__key-row><input id=cp-api-key class="provider-detail__input provider-detail__input--disabled"type=text disabled aria-label="Current API key (masked)"><button type=button class="btn btn--outline btn--sm">Change'),vn=r('<input id=cp-api-key class="provider-detail__input provider-detail__input--masked"type=text autocomplete=off placeholder=sk-...>'),hn=r('<button type=button class="btn btn--outline btn--sm provider-detail__disconnect">Delete provider'),mn=r('<div class=modal-overlay><div class=modal-card role=dialog aria-modal=true aria-labelledby=delete-provider-modal-title style=max-width:400px><div style=display:flex;justify-content:space-between;align-items:center;margin-bottom:var(--gap-lg)><h3 id=delete-provider-modal-title style=margin:0;font-size:var(--font-size-lg)>Delete provider</h3><button aria-label=Close style=background:none;border:none;cursor:pointer;color:hsl(var(--muted-foreground));padding:4px><svg width=16 height=16 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round aria-hidden=true><path d="M18 6 6 18"></path><path d="m6 6 12 12"></path></svg></button></div><p style=font-size:var(--font-size-sm);color:hsl(var(--muted-foreground));margin-bottom:var(--gap-lg)>Remove <strong style=color:hsl(var(--foreground))></strong>? This will delete all its models and any routing assignments using them. This action cannot be undone.</p><div style=display:flex;gap:var(--gap-sm);justify-content:flex-end><button class="btn btn--outline btn--sm">Cancel</button><button class="btn btn--danger btn--sm">'),fn=r('<div class=provider-detail><button class=provider-detail__back aria-label="Back to providers"><svg width=16 height=16 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round aria-hidden=true><path d="m15 18-6-6 6-6"></path></svg></button><div class=routing-modal__header style=border:none;padding:0;margin-bottom:20px><div><div class=routing-modal__title></div><div class=routing-modal__subtitle>Connect any OpenAI-compatible endpoint</div></div></div><form><div class=provider-detail__field><label class=provider-detail__label for=cp-name>Provider name</label><input id=cp-name class=provider-detail__input type=text placeholder="e.g. Groq, vLLM, Azure"></div><div class=provider-detail__field><label class=provider-detail__label for=cp-base-url>Base URL</label><input id=cp-base-url class=provider-detail__input type=url placeholder=https://api.example.com/v1></div><div class=provider-detail__field><label class=provider-detail__label for=cp-api-key>API Key <span style=color:hsl(var(--muted-foreground));font-weight:400>(optional for local providers)</span></label></div><div class=provider-detail__field><label class=provider-detail__label>Models</label><div class=custom-provider-models><button type=button class="btn btn--outline btn--sm"style=margin-top:4px;align-self:flex-start>+ Add model</button></div></div><div style=display:flex;align-items:center;justify-content:space-between;margin-top:16px><button type=submit class="btn btn--primary btn--sm provider-detail__action">'),pn=r('<div class=custom-provider-model-row><input class="provider-detail__input custom-provider-model-row__name"type=text placeholder="Model name"><input class="provider-detail__input custom-provider-model-row__price"type=text inputmode=decimal placeholder="$/M in"><input class="provider-detail__input custom-provider-model-row__price"type=text inputmode=decimal placeholder="$/M out"><button type=button class=custom-provider-model-row__remove title=Remove><svg width=14 height=14 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round aria-hidden=true><path d="M18 6 6 18"></path><path d="m6 6 12 12">'),bn=r("<div class=provider-detail__error role=alert>"),$n=r("<div>"),Ge=r("<span class=spinner>");const Je=()=>({model_name:"",input_price:"",output_price:""}),yn=e=>e.map(a=>({model_name:a.model_name,input_price:a.input_price_per_million_tokens!=null?String(a.input_price_per_million_tokens):"",output_price:a.output_price_per_million_tokens!=null?String(a.output_price_per_million_tokens):""})),kn=e=>{const a=()=>!!e.initialData,f=()=>e.prefill?.models?.length?e.prefill.models.map(C=>({model_name:C.model_name,input_price:C.input_price??"",output_price:C.output_price??""})):[Je()],[b,u]=B(e.initialData?.name??e.prefill?.name??""),[m,y]=B(e.initialData?.base_url??e.prefill?.baseUrl??""),[S,p]=B(e.prefill?.apiKey??""),[T,_]=B(!1),[l,s]=B(e.initialData?yn(e.initialData.models):f()),[v,h]=B(!1),[w,x]=B(null),[R,d]=B(!1),t=(C,U,j)=>{s(N=>N.map((E,V)=>V===C?{...E,[U]:j}:E))},o=()=>s(C=>[...C,Je()]),c=C=>{s(U=>U.length<=1?U:U.filter((j,N)=>N!==C))},$=()=>l().filter(C=>C.model_name.trim()),D=()=>b().trim()&&m().trim()&&$().length>0&&!v(),P=C=>Number(C.replace(",",".")),I=()=>$().map(C=>({model_name:C.model_name.trim(),...C.input_price!==""?{input_price_per_million_tokens:P(C.input_price)}:{},...C.output_price!==""?{output_price_per_million_tokens:P(C.output_price)}:{}})),q=async()=>{x(null),h(!0);try{await Dt(e.agentName,{name:b().trim(),base_url:m().trim(),apiKey:S().trim()||void 0,models:I()}),G.success(`${b().trim()} connected`),e.onCreated()}catch(C){x(C instanceof Error?C.message:"Failed to create provider")}finally{h(!1)}},z=async()=>{x(null);const C={name:b().trim(),base_url:m().trim(),models:I()};T()&&(C.apiKey=S().trim()||void 0),h(!0);try{await At(e.agentName,e.initialData.id,C),G.success(`${b().trim()} updated`),e.onCreated()}catch(U){x(U instanceof Error?U.message:"Failed to update provider")}finally{h(!1)}},k=async()=>{h(!0);try{await Mt(e.agentName,e.initialData.id),G.success(`${e.initialData.name} removed`),e.onDeleted?.()}catch{}finally{h(!1),d(!1)}},M=()=>{a()?z():q()};return(()=>{var C=fn(),U=C.firstChild,j=U.nextSibling,N=j.firstChild,E=N.firstChild,V=j.nextSibling,F=V.firstChild,W=F.firstChild,L=W.nextSibling,O=F.nextSibling,ee=O.firstChild,te=ee.nextSibling,ae=O.nextSibling;ae.firstChild;var X=ae.nextSibling,ce=X.firstChild,ge=ce.nextSibling,J=ge.firstChild,de=X.nextSibling,me=de.firstChild;return ve(U,"click",e.onBack,!0),n(E,()=>a()?"Edit custom provider":"Add custom provider"),V.addEventListener("submit",K=>{K.preventDefault(),D()&&M()}),L.$$input=K=>{u(K.currentTarget.value),x(null)},te.$$input=K=>{y(K.currentTarget.value),x(null)},n(ae,i(g,{get when(){return H(()=>!!a())()&&!T()},get children(){var K=gn(),Y=K.firstChild,oe=Y.nextSibling;return oe.$$click=()=>{_(!0),p("")},A(()=>Y.value=e.initialData?.has_api_key?"••••••••••••":"No key set"),K}}),null),n(ae,i(g,{get when(){return!a()||T()},get children(){var K=vn();return K.$$input=Y=>p(Y.currentTarget.value),A(()=>K.value=S()),K}}),null),n(ge,i(ft,{get each(){return l()},children:(K,Y)=>(()=>{var oe=pn(),ne=oe.firstChild,ie=ne.nextSibling,le=ie.nextSibling,ke=le.nextSibling;return ne.$$input=fe=>t(Y,"model_name",fe.currentTarget.value),Z(ne,"aria-label",`Model ${Y+1} name`),ie.$$input=fe=>t(Y,"input_price",fe.currentTarget.value),Z(ie,"aria-label",`Model ${Y+1} input price per million tokens`),le.$$input=fe=>t(Y,"output_price",fe.currentTarget.value),Z(le,"aria-label",`Model ${Y+1} output price per million tokens`),ke.$$click=()=>c(Y),Z(ke,"aria-label",`Remove model ${Y+1}`),A(()=>ke.disabled=l().length<=1),A(()=>ne.value=K().model_name),A(()=>ie.value=K().input_price),A(()=>le.value=K().output_price),oe})()}),J),J.$$click=o,n(V,(()=>{var K=H(()=>!!w());return()=>K()&&(()=>{var Y=bn();return n(Y,w),Y})()})(),de),n(de,i(g,{get when(){return a()},get fallback(){return $n()},get children(){var K=hn();return K.$$click=()=>d(!0),A(()=>K.disabled=v()),K}}),me),n(me,(()=>{var K=H(()=>!!v());return()=>K()?Ge():a()?"Save changes":"Connect"})()),n(C,i(g,{get when(){return R()},get children(){var K=mn(),Y=K.firstChild,oe=Y.firstChild,ne=oe.firstChild,ie=ne.nextSibling,le=oe.nextSibling,ke=le.firstChild,fe=ke.nextSibling,mt=le.nextSibling,Ae=mt.firstChild,De=Ae.nextSibling;return K.$$keydown=se=>{se.key==="Escape"&&d(!1)},K.$$click=se=>{se.target===se.currentTarget&&d(!1)},ie.$$click=()=>d(!1),n(fe,()=>e.initialData?.name),Ae.$$click=()=>d(!1),De.$$click=k,n(De,(()=>{var se=H(()=>!!v());return()=>se()?Ge():"Delete"})()),A(se=>{var Ve=v(),He=v();return Ve!==se.e&&(Ae.disabled=se.e=Ve),He!==se.t&&(De.disabled=se.t=He),se},{e:void 0,t:void 0}),K}}),null),A(K=>{var Y=!l().at(-1)?.model_name.trim(),oe=!D();return Y!==K.e&&(J.disabled=K.e=Y),oe!==K.t&&(me.disabled=K.t=oe),K},{e:void 0,t:void 0}),A(()=>L.value=b()),A(()=>te.value=m()),C})()};re(["click","input","keydown"]);var wn=r('<p class=provider-detail__hint style="color:var(--success-color, #22c55e)">Connected via GitHub device login.'),Cn=r('<button class="btn btn--outline provider-detail__action provider-detail__disconnect">'),xn=r("<p class=provider-detail__hint>Requires an active GitHub Copilot subscription. This will open a GitHub device login."),Pn=r("<div class=provider-detail__error>"),Sn=r('<button class="btn btn--primary provider-detail__action">Sign in with GitHub'),Tn=r('<div class=provider-detail__field style="text-align:center;padding:24px 0"><span class=spinner>'),Mn=r('<svg width=16 height=16 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round aria-hidden=true><polyline points="20 6 9 17 4 12">'),An=r('<div class=copilot-device-login__code-box><p class=provider-detail__hint style=margin-bottom:12px>Copy the code, then open GitHub to enter it:</p><div class=copilot-device-login__code-row><div class=copilot-device-login__code aria-label="Device code"></div><button class=copilot-device-login__copy-btn></button></div><a class="btn btn--primary copilot-device-login__open-btn"target=_blank rel="noopener noreferrer">Open GitHub</a><p class=copilot-device-login__waiting><span class=spinner style=width:14px;height:14px;margin-right:8px></span>Waiting for authorization...'),Dn=r('<p class=provider-detail__hint style="color:var(--success-color, #22c55e)">GitHub Copilot connected successfully.'),Ln=r('<div class=provider-detail><button class=provider-detail__back aria-label="Back to providers"><svg width=16 height=16 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round aria-hidden=true><path d="m15 18-6-6 6-6"></path></svg></button><div class=routing-modal__header style=border:none;padding:0;margin-bottom:15px><div><div class=routing-modal__title>Connect providers</div></div></div><div class=provider-detail__header><span class=provider-detail__icon></span><div class=provider-detail__title-group><div class=provider-detail__name>GitHub Copilot'),In=r("<span class=spinner>"),Bn=r('<svg width=16 height=16 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round aria-hidden=true><rect x=9 y=9 width=13 height=13 rx=2 ry=2></rect><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1">');function Rn(e,a){navigator.clipboard.writeText(e).then(()=>{a(!0),setTimeout(()=>a(!1),2e3)}).catch(()=>{})}const Un=5,En=5,On=e=>{const[a,f]=B("idle"),[b,u]=B(""),[m,y]=B(""),[S,p]=B(""),[T,_]=B(!1),[l,s]=B(!1);let v,h=!1;ut(()=>{h=!0,v&&clearTimeout(v)});const w=async()=>{f("loading"),p(""),h=!1;try{const t=await Lt(e.agentName);u(t.user_code),y(t.verification_uri),f("awaiting"),x(t.device_code,Math.max(t.interval,5))}catch{p("Failed to start GitHub login. Please try again."),f("error")}},x=(t,o,c=0)=>{h||(v=setTimeout(async()=>{if(!h)try{const $=await It(e.agentName,t);if(h)return;const D=R($.status,o);D>0&&x(t,D,0)}catch{if(h)return;const $=c+1;$>=En?(p("Connection lost. Please try again."),f("error")):x(t,o,$)}},o*1e3))},R=(t,o)=>t==="complete"?(f("success"),G.success("GitHub Copilot connected"),e.onConnected(),0):t==="expired"?(p("Device code expired. Please try again."),f("error"),0):t==="denied"?(p("Authorization was denied."),f("error"),0):t==="slow_down"?o+Un:o,d=async()=>{_(!0);try{const t=await ye(e.agentName,"copilot","subscription");if(t?.notifications?.length)for(const o of t.notifications)G.error(o);e.onDisconnected()}catch{}finally{_(!1)}};return(()=>{var t=Ln(),o=t.firstChild,c=o.nextSibling,$=c.nextSibling,D=$.firstChild;return ve(o,"click",e.onBack,!0),n(D,()=>he("copilot",28)),n(t,i(g,{get when(){return H(()=>!!e.connected)()&&a()!=="success"},get children(){return[wn(),(()=>{var P=Cn();return P.$$click=d,n(P,i(g,{get when(){return!T()},get fallback(){return In()},children:"Disconnect"})),A(()=>P.disabled=T()),P})()]}}),null),n(t,i(g,{get when(){return H(()=>!e.connected)()&&(a()==="idle"||a()==="error")},get children(){return[xn(),i(g,{get when(){return S()},get children(){var P=Pn();return n(P,S),P}}),(()=>{var P=Sn();return P.$$click=w,P})()]}}),null),n(t,i(g,{get when(){return a()==="loading"},get children(){return Tn()}}),null),n(t,i(g,{get when(){return a()==="awaiting"},get children(){var P=An(),I=P.firstChild,q=I.nextSibling,z=q.firstChild,k=z.nextSibling,M=q.nextSibling;return n(z,b),k.$$click=()=>Rn(b(),s),n(k,i(g,{get when(){return l()},get fallback(){return Bn()},get children(){return Mn()}})),A(C=>{var U=l()?"Copied":"Copy device code",j=l()?"Copied":"Copy",N=m();return U!==C.e&&Z(k,"aria-label",C.e=U),j!==C.t&&Z(k,"title",C.t=j),N!==C.a&&Z(M,"href",C.a=N),C},{e:void 0,t:void 0,a:void 0}),P}}),null),n(t,i(g,{get when(){return a()==="success"},get children(){return Dn()}}),null),t})()};re(["click"]);var Ye=r("<div class=provider-detail__error>"),Xe=r('<p class=provider-detail__key-help><a class=provider-detail__key-help-link target=_blank rel="noopener noreferrer">Get <!> API key'),Fn=r('<div class=provider-detail__field><label class=provider-detail__label></label><input class="provider-detail__input provider-detail__input--masked"type=text autocomplete=off>'),Nn=r('<button class="btn btn--primary provider-detail__action">'),Kn=r('<svg width=16 height=16 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round aria-hidden=true><path d="M3 6h18"></path><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"></path><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2">'),zn=r('<div class=provider-detail__key-row><input class="provider-detail__input provider-detail__input--disabled"type=text disabled><button class="btn btn--outline btn--sm">Change</button><button class=provider-detail__disconnect-icon aria-label="Disconnect provider"title=Disconnect>'),jn=r('<input class="provider-detail__input provider-detail__input--masked"type=text autocomplete=off>'),Vn=r('<button class="btn btn--primary provider-detail__action"style=margin-top:12px>Save'),Hn=r("<div class=provider-detail__field><label class=provider-detail__label>"),Qe=r("<span class=spinner>");const Wn=e=>{const a=()=>e.provDef.subscriptionAuthMode==="popup_oauth"||!!e.provDef.subscriptionOAuth,f=()=>e.provId==="openai"&&a()&&e.selectedAuthType()==="subscription",b=()=>e.isSubMode()?"Setup Token":"API Key",u=()=>e.isSubMode()?e.provDef.subscriptionKeyPlaceholder??"Paste token":e.provDef.keyPlaceholder,m=()=>e.isSubMode()?`${e.provDef.name} setup token`:`${e.provDef.name} API key`,y=()=>e.isSubMode()?`New ${e.provDef.name} setup token`:`New ${e.provDef.name} API key`,S=Vt(e.provId),p=async()=>{const s=e.isSubMode()?We(e.provDef,e.keyInput()):qe(e.provDef,e.keyInput());if(!s.valid){e.setValidationError(s.error);return}e.setBusy(!0);try{await Te(e.agentName,{provider:e.provId,apiKey:e.keyInput().replace(/\s/g,""),authType:e.selectedAuthType()}),G.success(`${e.provDef.name} connected`),e.onBack(),e.onUpdate()}catch{}finally{e.setBusy(!1)}},T=async()=>{const s=e.isSubMode()?We(e.provDef,e.keyInput()):qe(e.provDef,e.keyInput());if(!s.valid){e.setValidationError(s.error);return}e.setBusy(!0);try{await Te(e.agentName,{provider:e.provId,apiKey:e.keyInput().replace(/\s/g,""),authType:e.selectedAuthType()});const v=e.isSubMode()?"token":"key";G.success(`${e.provDef.name} ${v} updated`),e.onBack(),e.onUpdate()}catch{}finally{e.setBusy(!1)}},_=async()=>{e.setBusy(!0);try{f()&&await je(e.agentName).catch(()=>{});const s=await ye(e.agentName,e.provId,e.selectedAuthType());if(s?.notifications?.length)for(const v of s.notifications)G.error(v);e.onBack(),e.onUpdate()}catch{}finally{e.setBusy(!1)}};let l;return pt(()=>{l&&!e.connected()&&l.focus()}),[i(g,{get when(){return!e.connected()},get children(){return[(()=>{var s=Fn(),v=s.firstChild,h=v.nextSibling;n(v,b),h.$$keydown=x=>{x.key==="Enter"&&p()},h.$$input=x=>{e.setKeyInput(x.currentTarget.value),e.setValidationError(null)};var w=l;return typeof w=="function"?_t(w,h):l=h,n(s,i(g,{get when(){return e.validationError()},get children(){var x=Ye();return n(x,()=>e.validationError()),x}}),null),n(s,i(g,{get when(){return S&&!e.isSubMode()},get children(){var x=Xe(),R=x.firstChild,d=R.firstChild,t=d.nextSibling;return t.nextSibling,Z(R,"href",S),n(R,()=>e.provDef.name,t),x}}),null),A(x=>{var R=!!e.validationError(),d=u(),t=m();return R!==x.e&&h.classList.toggle("provider-detail__input--error",x.e=R),d!==x.t&&Z(h,"placeholder",x.t=d),t!==x.a&&Z(h,"aria-label",x.a=t),x},{e:void 0,t:void 0,a:void 0}),A(()=>h.value=e.keyInput()),s})(),(()=>{var s=Nn();return s.$$click=p,n(s,i(g,{get when(){return!e.busy()},get fallback(){return Qe()},children:"Connect"})),A(()=>s.disabled=e.busy()||!e.keyInput().trim()),s})()]}}),i(g,{get when(){return e.connected()},get children(){var s=Hn(),v=s.firstChild;return n(v,b),n(s,i(g,{get when(){return!e.editing()},get children(){var h=zn(),w=h.firstChild,x=w.nextSibling,R=x.nextSibling;return x.$$click=()=>{e.setEditing(!0),e.setKeyInput(""),e.setValidationError(null)},R.$$click=_,n(R,i(g,{get when(){return!e.busy()},get fallback(){return Qe()},get children(){return Kn()}})),A(d=>{var t=e.isSubMode()?"Current setup token (masked)":"Current API key (masked)",o=e.busy();return t!==d.e&&Z(w,"aria-label",d.e=t),o!==d.t&&(R.disabled=d.t=o),d},{e:void 0,t:void 0}),A(()=>w.value=e.getKeyPrefixDisplay(e.selectedAuthType())),h}}),null),n(s,i(g,{get when(){return e.editing()},get children(){return[(()=>{var h=jn();return h.$$keydown=w=>{w.key==="Enter"&&T()},h.$$input=w=>{e.setKeyInput(w.currentTarget.value),e.setValidationError(null)},A(w=>{var x=!!e.validationError(),R=u(),d=y();return x!==w.e&&h.classList.toggle("provider-detail__input--error",w.e=x),R!==w.t&&Z(h,"placeholder",w.t=R),d!==w.a&&Z(h,"aria-label",w.a=d),w},{e:void 0,t:void 0,a:void 0}),A(()=>h.value=e.keyInput()),h})(),i(g,{get when(){return e.validationError()},get children(){var h=Ye();return n(h,()=>e.validationError()),h}}),i(g,{get when(){return S&&!e.isSubMode()},get children(){var h=Xe(),w=h.firstChild,x=w.firstChild,R=x.nextSibling;return R.nextSibling,Z(w,"href",S),n(w,()=>e.provDef.name,R),h}}),(()=>{var h=Vn();return h.$$click=T,A(()=>h.disabled=e.busy()||!e.keyInput().trim()),h})()]}}),null),s}})]};re(["input","keydown","click"]);function qn(e,a){let f=!1,b=null,u;const m=()=>{window.removeEventListener("message",_);try{b?.close()}catch{}clearTimeout(u)},y=l=>{if(!f){f=!0,clearInterval(T),m();try{e.close()}catch{}l&&a.onSuccess()}},S=l=>!!l&&typeof l=="object"&&"type"in l,p=l=>{S(l)&&(l.type==="manifest-oauth-success"?y(!0):l.type==="manifest-oauth-error"&&y(!1))};let T;try{b=new BroadcastChannel("manifest-oauth"),b.onmessage=l=>p(l.data)}catch{}const _=l=>p(l.data);window.addEventListener("message",_),T=setInterval(()=>{try{const l=e.location?.href;if(l?.includes("/oauth/openai/done")){const s=new URL(l).searchParams.get("ok")==="1";y(s)}}catch{}e.closed&&!f&&(clearInterval(T),u=setTimeout(()=>{f||y(!1)},3e4))},300)}var Zn=r(`<p class=provider-detail__hint>A login window has opened. After you sign in, the popup will show a "can't be reached" page. This is expected.`),Gn=r("<p class=provider-detail__hint style=margin-top:8px>Copy the full URL from the <span style=color:#000000;font-weight:500>popup's address bar</span> and paste it below:"),Jn=r('<video src=/images/oauth-callback-example.mp4 autoplay loop muted playsinline style="width:100%;border-radius:var(--radius);border:1px solid hsl(var(--border));margin-top:12px">'),Yn=r("<div class=provider-detail__error>"),Xn=r('<div class=provider-detail__field style=margin-top:12px><input class=provider-detail__input type=text autocomplete=off placeholder="http://localhost:1455/auth/callback?code=..."><button class="btn btn--primary btn--sm provider-detail__action"style=margin-top:8px>'),Qn=r("<div class=provider-detail__field><span class=provider-detail__no-key>Connected via "),er=r('<button class="btn btn--outline provider-detail__action provider-detail__disconnect">'),tr=r("<p class=provider-detail__hint>Log in with your <!> account to connect your subscription."),nr=r('<button class="btn btn--primary provider-detail__action">'),Ie=r("<span class=spinner>");const rr=e=>{const[a,f]=B(!1),[b,u]=B(""),[m,y]=B(null),S=async()=>{e.setBusy(!0),u(""),y(null);try{const{url:_}=await Ht(e.agentName),l=window.open(_,"manifest-oauth","width=500,height=700");if(!l){G.error("Popup was blocked by your browser. Allow popups for this site, then try again."),e.setBusy(!1);return}f(!0),e.setBusy(!1),qn(l,{onSuccess:()=>{G.success(`${e.provDef.name} subscription connected`),e.onUpdate(),e.onClose()},onFailure:()=>{}})}catch{e.setBusy(!1)}},p=async()=>{const _=b().trim();if(_)try{const l=new URL(_),s=l.searchParams.get("code"),v=l.searchParams.get("state");if(!s||!v){y("URL is missing the authorization code. Make sure you copied the full URL.");return}e.setBusy(!0),y(null),await Wt(s,v),G.success(`${e.provDef.name} subscription connected`),e.onUpdate(),e.onClose()}catch{y("Failed to exchange token. The URL may have expired — try logging in again.")}finally{e.setBusy(!1)}},T=async()=>{e.setBusy(!0);try{await je(e.agentName).catch(()=>{});const _=await ye(e.agentName,e.provId,e.selectedAuthType());if(_?.notifications?.length)for(const l of _.notifications)G.error(l);e.onBack(),e.onUpdate()}catch{}finally{e.setBusy(!1)}};return[i(g,{get when(){return!e.connected()},get children(){return i(g,{get when(){return a()},get fallback(){return[(()=>{var _=tr(),l=_.firstChild,s=l.nextSibling;return s.nextSibling,n(_,()=>e.provDef.name,s),_})(),(()=>{var _=nr();return _.$$click=S,n(_,i(g,{get when(){return!e.busy()},get fallback(){return Ie()},get children(){return["Log in with ",H(()=>e.provDef.name)]}})),A(()=>_.disabled=e.busy()),_})()]},get children(){return[Zn(),Gn(),Jn(),(()=>{var _=Xn(),l=_.firstChild,s=l.nextSibling;return l.$$keydown=v=>{v.key==="Enter"&&p()},l.$$input=v=>{u(v.currentTarget.value),y(null)},n(_,i(g,{get when(){return m()},get children(){var v=Yn();return n(v,m),v}}),s),s.$$click=p,n(s,i(g,{get when(){return!e.busy()},get fallback(){return Ie()},children:"Connect"})),A(v=>{var h=!!m(),w=e.busy()||!b().trim();return h!==v.e&&l.classList.toggle("provider-detail__input--error",v.e=h),w!==v.t&&(s.disabled=v.t=w),v},{e:void 0,t:void 0}),A(()=>l.value=b()),_})()]}})}}),i(g,{get when(){return e.connected()},get children(){return[(()=>{var _=Qn(),l=_.firstChild;return l.firstChild,n(l,()=>e.provDef.subscriptionLabel??"subscription",null),_})(),(()=>{var _=er();return _.$$click=T,n(_,i(g,{get when(){return!e.busy()},get fallback(){return Ie()},children:"Disconnect"})),A(()=>_.disabled=e.busy()),_})()]}})]};re(["input","keydown","click"]);var ir=r("<div class=provider-detail__field><span class=provider-detail__no-key>Connected via "),lr=r('<button class="btn btn--outline provider-detail__action provider-detail__disconnect">'),ar=r("<p class=provider-detail__hint>Choose your MiniMax region, then open the authorization page in your browser to sign in and approve access."),or=r("<div class=provider-detail__field style=margin-top:12px><label class=provider-detail__label for=minimax-region>Region</label><select id=minimax-region class=provider-detail__input><option value=global>Global (api.minimax.io)</option><option value=cn>China Mainland (api.minimaxi.com)"),sr=r('<button class="btn btn--primary provider-detail__action"style=margin-top:12px>'),et=r("<span class=spinner>"),dr=r("<p class=provider-detail__hint>Your browser should open to the MiniMax authorization page. If MiniMax asks for a one-time code, enter the code shown below."),cr=r('<div class=provider-detail__field style=margin-top:12px><label class=provider-detail__label>Verification Code</label><div class=provider-detail__key-row><input class="provider-detail__input provider-detail__input--disabled"type=text readonly>'),ur=r('<div class=provider-detail__field style=margin-top:12px><label class=provider-detail__label>Verification Link</label><div class=provider-detail__key-row><input class="provider-detail__input provider-detail__input--disabled"type=text readonly>'),_r=r('<div class=provider-detail__field style=margin-top:12px><button class="btn btn--outline btn--sm">Open verification page</button><button class="btn btn--ghost btn--sm"style=margin-left:8px>Start over'),gr=r("<p class=provider-detail__hint style=margin-top:12px>"),vr=r("<div class=provider-detail__error style=margin-top:12px>");const tt=2e3,hr=e=>{const[a,f]=B(null),[b,u]=B(null),[m,y]=B(null),[S,p]=B("global");let T,_=!1,l=0;const s=()=>{T!==void 0&&(window.clearTimeout(T),T=void 0)},v=(d,t=l)=>{s(),!(_||t!==l)&&(T=window.setTimeout(()=>{_||t!==l||x(t)},d))},h=()=>{const d=a();d&&window.open(d.verificationUri,"_blank","noopener,noreferrer")},w=async()=>{e.setBusy(!0);try{const d=await ye(e.agentName,e.provId,e.selectedAuthType());if(d?.notifications?.length)for(const t of d.notifications)G.error(t);e.onBack(),e.onUpdate()}catch{}finally{e.setBusy(!1)}},x=async(d=l)=>{if(_||d!==l)return;const t=a();if(t){if(Date.now()>=t.expiresAt){y("This verification code expired. Start again to generate a new one."),u(null),s();return}try{const o=await Zt(t.flowId);if(_||d!==l)return;const c=a();if(!c||c.flowId!==t.flowId)return;if(o.status==="success"){s(),G.success(`${e.provDef.name} subscription connected`),e.onUpdate(),e.onClose();return}if(o.status==="error"){s(),y(o.message??"MiniMax login failed. Start again to retry."),u(null);return}y(null),u(o.message??"Waiting for approval…"),v(o.pollIntervalMs??c.pollIntervalMs??tt,d)}catch{if(_||d!==l||a()?.flowId!==t.flowId)return;s(),y("Failed to check approval status. Start again to retry."),u(null)}}},R=async()=>{e.setBusy(!0);const d=++l;s(),y(null),u(null);try{const t=await qt(e.agentName,S());if(_||d!==l)return;f(t),window.open(t.verificationUri,"_blank","noopener,noreferrer"),v(t.pollIntervalMs??tt,d)}catch{if(_||d!==l)return;f(null)}finally{if(_||d!==l)return;e.setBusy(!1)}};return ut(()=>{_=!0,l+=1,s()}),[i(g,{get when(){return!e.connected()},get children(){return i(g,{get when(){return a()},get fallback(){return[ar(),(()=>{var d=or(),t=d.firstChild,o=t.nextSibling;return o.addEventListener("change",c=>p(c.currentTarget.value)),A(()=>o.disabled=e.busy()),A(()=>o.value=S()),d})(),(()=>{var d=sr();return d.$$click=R,n(d,i(g,{get when(){return!e.busy()},get fallback(){return et()},get children(){return["Connect with ",H(()=>e.provDef.name)]}})),A(()=>d.disabled=e.busy()),d})()]},children:d=>[dr(),(()=>{var t=cr(),o=t.firstChild,c=o.nextSibling,$=c.firstChild;return n(c,i(Me,{get text(){return d().userCode}}),null),A(()=>Z($,"aria-label",`${e.provDef.name} verification code`)),A(()=>$.value=d().userCode),t})(),(()=>{var t=ur(),o=t.firstChild,c=o.nextSibling,$=c.firstChild;return n(c,i(Me,{get text(){return d().verificationUri}}),null),A(()=>Z($,"aria-label",`${e.provDef.name} verification link`)),A(()=>$.value=d().verificationUri),t})(),(()=>{var t=_r(),o=t.firstChild,c=o.nextSibling;return o.$$click=h,c.$$click=R,A(()=>c.disabled=e.busy()),t})(),i(g,{get when(){return b()},get children(){var t=gr();return n(t,b),t}}),i(g,{get when(){return m()},get children(){var t=vr();return n(t,m),t}})]})}}),i(g,{get when(){return e.connected()},get children(){return[(()=>{var d=ir(),t=d.firstChild;return t.firstChild,n(t,()=>e.provDef.subscriptionLabel??"subscription",null),d})(),(()=>{var d=lr();return d.$$click=w,n(d,i(g,{get when(){return!e.busy()},get fallback(){return et()},children:"Disconnect"})),A(()=>d.disabled=e.busy()),d})()]}})]};re(["click"]);var mr=r("<p class=provider-detail__hint>"),fr=r('<div class=modal-terminal><div class=modal-terminal__header><div class=modal-terminal__dots><span class="modal-terminal__dot modal-terminal__dot--red"></span><span class="modal-terminal__dot modal-terminal__dot--yellow"></span><span class="modal-terminal__dot modal-terminal__dot--green"></span></div><div class=modal-terminal__tabs><span class="modal-terminal__tab modal-terminal__tab--active">Terminal</span></div></div><div class=modal-terminal__body><div><span class=modal-terminal__prompt>$</span><span class=modal-terminal__code>'),pr=r("<p class=provider-detail__hint style=margin-top:16px>A browser window will open for you to log in. Once authenticated, the connection will be detected automatically."),nt=r('<button class="btn btn--outline provider-detail__action provider-detail__disconnect">'),br=r('<button class="btn btn--primary provider-detail__action">Done'),$r=r("<div class=provider-detail__field><span class=provider-detail__no-key>No API key required for local models"),yr=r('<button class="btn btn--primary provider-detail__action">'),kr=r('<div class=provider-detail><button class=provider-detail__back aria-label="Back to providers"><svg width=16 height=16 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round aria-hidden=true><path d="m15 18-6-6 6-6"></path></svg></button><div class=routing-modal__header style=border:none;padding:0;margin-bottom:15px><div><div class=routing-modal__title>Connect providers</div></div></div><div class=provider-detail__header><span class=provider-detail__icon></span><div class=provider-detail__title-group><div class=provider-detail__name>'),wr=r("<span class=provider-card__logo-letter style=width:32px;height:32px;font-size:13px>"),Be=r("<span class=spinner>"),Cr=r(`<div class=anthropic-credits__tooltip><p>Anthropic offers extra API credits to eligible Pro, Max, and Team plan subscribers. Click the link to check your eligibility and available credits.</p><p>If you're not eligible, the page may not be accessible. <a href=https://support.claude.com/en/articles/14246053-extra-usage-credit-for-pro-max-and-team-plans target=_blank rel="noopener noreferrer">Learn more about eligibility`),xr=r('<div class=anthropic-credits><a href=https://claude.ai/settings/usage target=_blank rel="noopener noreferrer"class=anthropic-credits__btn><svg class=anthropic-credits__btn-icon xmlns=http://www.w3.org/2000/svg width=14 height=14 fill=currentColor viewBox="0 0 24 24"aria-hidden=true><path d=m19,7h-.21c.13-.41.21-.9.21-1.5,0-1.93-1.57-3.5-3.5-3.5-1.62,0-2.7,1.48-3.4,3.09-.69-1.51-1.83-3.09-3.6-3.09-1.93,0-3.5,1.57-3.5,3.5,0,.6.08,1.09.21,1.5h-.21c-1.65,0-3,1.35-3,3,0,1.3.84,2.4,2,2.82v6.18c0,1.65,1.35,3,3,3h10c1.65,0,3-1.35,3-3v-6.18c1.16-.41,2-1.51,2-2.82,0-1.65-1.35-3-3-3Zm-3.5-3c.83,0,1.5.67,1.5,1.5,0,1.5-.63,1.5-1,1.5h-2.48c.51-1.58,1.25-3,1.98-3Zm-8.5,1.5c0-.83.67-1.5,1.5-1.5.89,0,1.71,1.53,2.2,3h-2.7c-.37,0-1,0-1-1.5Zm-2,3.5h6v2h-6c-.55,0-1-.45-1-1s.45-1,1-1Zm2,11c-.55,0-1-.45-1-1v-6h5v7h-4Zm10,0h-4v-7h5v6c0,.55-.45,1-1,1Zm2-9h-6v-1.92s.01-.06.02-.08h5.98c.55,0,1,.45,1,1s-.45,1-1,1Z></path></svg>Claim your credits on Claude</a><div class=anthropic-credits__info-wrapper><svg class=anthropic-credits__info-icon width=16 height=16 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round aria-hidden=true><circle cx=12 cy=12 r=10></circle><path d="M12 16v-4"></path><path d="M12 8h.01">');const Pr=e=>{const a=Q.find(d=>d.id===e.provId),f=d=>e.providers.find(t=>t.provider===e.provId&&t.auth_type===d),b=()=>{const d=f("api_key");return!!d&&d.is_active&&d.has_api_key},u=()=>{const d=f("subscription");return!!d&&d.is_active},m=()=>{const d=f("subscription");return!!d&&d.is_active&&d.has_api_key},y=()=>{const d=f("api_key");return!!d&&d.is_active&&!!a.noKeyRequired},S=d=>{const t=f(d);return t?.key_prefix?`${t.key_prefix}${"•".repeat(8)}`:"••••••••••••"},p=()=>e.selectedAuthType()==="subscription",T=()=>a.subscriptionAuthMode??(a.subscriptionOAuth?"popup_oauth":void 0)??(a.subscriptionKeyPlaceholder?"token":void 0),_=()=>p()&&T()==="popup_oauth",l=()=>p()&&T()==="device_code",s=()=>e.provId==="openai"&&_(),v=()=>p()&&!!a.subscriptionCommand&&!a.subscriptionKeyPlaceholder&&!T(),h=()=>p()?v()?u():T()==="token"?m():u():b()||y(),w=a.noKeyRequired,x=async()=>{e.setBusy(!0);try{await Te(e.agentName,{provider:e.provId,authType:e.selectedAuthType()}),G.success(`${a.name} connected`),e.onBack(),e.onUpdate()}catch{}finally{e.setBusy(!1)}},R=async()=>{e.setBusy(!0);try{s()&&await je(e.agentName).catch(()=>{});const d=await ye(e.agentName,e.provId,e.selectedAuthType());if(d?.notifications?.length)for(const t of d.notifications)G.error(t);e.onBack(),e.onUpdate()}catch{}finally{e.setBusy(!1)}};return(()=>{var d=kr(),t=d.firstChild,o=t.nextSibling,c=o.nextSibling,$=c.firstChild,D=$.nextSibling,P=D.firstChild;return ve(t,"click",e.onBack,!0),n($,()=>he(e.provId,28)??(()=>{var I=wr();return n(I,()=>a.initial),A(q=>ue(I,"background",a.color)),I})()),n(P,()=>a.name),n(c,i(g,{get when(){return e.provId==="anthropic"},get children(){return i(Sr,{})}}),null),n(d,i(g,{get when(){return H(()=>!!p())()&&a.subscriptionCommand},get children(){return[(()=>{var I=mr();return n(I,()=>v()?"Run the command below to log in via your browser.":"Run the command below, then paste the token."),I})(),(()=>{var I=fr(),q=I.firstChild,z=q.nextSibling,k=z.firstChild,M=k.firstChild,C=M.nextSibling;return n(z,i(Me,{get text(){return a.subscriptionCommand}}),k),n(C,()=>a.subscriptionCommand),I})()]}}),null),n(d,i(g,{get when(){return v()},get children(){return[pr(),i(g,{get when(){return h()},get children(){var I=nt();return I.$$click=R,n(I,i(g,{get when(){return!e.busy()},get fallback(){return Be()},children:"Disconnect"})),A(()=>I.disabled=e.busy()),I}}),i(g,{get when(){return!h()},get children(){var I=br();return ve(I,"click",e.onBack,!0),I}})]}}),null),n(d,i(g,{get when(){return _()},get children(){return i(rr,{provDef:a,get provId(){return e.provId},get agentName(){return e.agentName},connected:h,get selectedAuthType(){return e.selectedAuthType},get busy(){return e.busy},get setBusy(){return e.setBusy},get onBack(){return e.onBack},get onUpdate(){return e.onUpdate},get onClose(){return e.onClose}})}}),null),n(d,i(g,{get when(){return l()},get children(){return i(hr,{provDef:a,get provId(){return e.provId},get agentName(){return e.agentName},connected:h,get selectedAuthType(){return e.selectedAuthType},get busy(){return e.busy},get setBusy(){return e.setBusy},get onBack(){return e.onBack},get onUpdate(){return e.onUpdate},get onClose(){return e.onClose}})}}),null),n(d,i(g,{when:w,get children(){return[$r(),i(g,{get when(){return!h()},get children(){var I=yr();return I.$$click=x,n(I,i(g,{get when(){return!e.busy()},get fallback(){return Be()},children:"Connect"})),A(()=>I.disabled=e.busy()),I}}),i(g,{get when(){return h()},get children(){var I=nt();return I.$$click=R,n(I,i(g,{get when(){return!e.busy()},get fallback(){return Be()},children:"Disconnect"})),A(()=>I.disabled=e.busy()),I}})]}}),null),n(d,i(g,{get when(){return H(()=>!w&&!v()&&!_())()&&!l()},get children(){return i(Wn,{provDef:a,get provId(){return e.provId},get agentName(){return e.agentName},isSubMode:p,connected:h,get selectedAuthType(){return e.selectedAuthType},get busy(){return e.busy},get setBusy(){return e.setBusy},get keyInput(){return e.keyInput},get setKeyInput(){return e.setKeyInput},get editing(){return e.editing},get setEditing(){return e.setEditing},get validationError(){return e.validationError},get setValidationError(){return e.setValidationError},getKeyPrefixDisplay:S,get onBack(){return e.onBack},get onUpdate(){return e.onUpdate}})}}),null),d})()},Sr=()=>{const[e,a]=B(!1),[f,b]=B({top:0,left:0});let u;const m=()=>{u=setTimeout(()=>a(!1),150)},y=()=>{u&&(clearTimeout(u),u=void 0)},S=p=>{y();const _=p.currentTarget.getBoundingClientRect(),l=280;let s=_.left+_.width/2-l/2;s+l>window.innerWidth-8&&(s=window.innerWidth-l-8),s<8&&(s=8),b({top:_.bottom+4,left:s}),a(!0)};return(()=>{var p=xr(),T=p.firstChild,_=T.nextSibling;return _.firstChild,_.addEventListener("mouseleave",m),_.addEventListener("mouseenter",S),n(_,i(g,{get when(){return e()},get children(){return i(bt,{get children(){var l=Cr();return l.addEventListener("mouseleave",m),l.addEventListener("mouseenter",y),A(s=>{var v=`${f().top}px`,h=`${f().left}px`;return v!==s.e&&ue(l,"top",s.e=v),h!==s.t&&ue(l,"left",s.t=h),s},{e:void 0,t:void 0}),l}})}}),null),p})()};re(["click"]);var Tr=r("<div class=provider-modal__tab-hint>Connect providers using your own API keys (BYOK)."),Mr=r('<div class=provider-modal__list><div class=provider-modal__add-custom><button class=provider-modal__add-custom-chip><svg width=16 height=16 viewBox="0 0 24 24"fill=currentColor aria-hidden=true><path d="M8.46 11h7.08a1.755 1.755 0 0 0 1.43-2.77l-3.54-4.96c-.66-.92-2.19-.92-2.85 0L7.04 8.23A1.755 1.755 0 0 0 8.47 11ZM12 4.72 15.06 9H8.95l3.06-4.28ZM17.5 13c-2.48 0-4.5 2.02-4.5 4.5s2.02 4.5 4.5 4.5 4.5-2.02 4.5-4.5-2.02-4.5-4.5-4.5m0 7a2.5 2.5 0 0 1 0-5 2.5 2.5 0 0 1 0 5M3.75 22h5.5c.96 0 1.75-.79 1.75-1.75v-5.5c0-.96-.79-1.75-1.75-1.75h-5.5C2.79 13 2 13.79 2 14.75v5.5c0 .96.79 1.75 1.75 1.75M4 15h5v5H4z"></path></svg>Add custom provider'),Ar=r('<button class=provider-toggle><span class=provider-toggle__icon></span><span class=provider-toggle__info><span class=provider-toggle__name><span class=provider-toggle__tag>Custom</span></span></span><span class="provider-toggle__switch provider-toggle__switch--on"><span class=provider-toggle__switch-thumb>'),rt=r("<span class=provider-card__logo-letter>"),Dr=r("<span class=provider-toggle__local-only>Only available on Manifest Local"),Lr=r("<span class=provider-toggle__switch><span class=provider-toggle__switch-thumb>"),Ir=r("<button class=provider-toggle><span class=provider-toggle__icon></span><span class=provider-toggle__info><span class=provider-toggle__name>");const Br=e=>{const a=()=>{const f=e.apiKeyProviders.map(u=>({kind:"standard",prov:u})),b=(e.customProviders??[]).map(u=>({kind:"custom",cp:u}));return[...f,...b].sort((u,m)=>{const y=u.kind==="standard"?u.prov.name:u.cp.name,S=m.kind==="standard"?m.prov.name:m.cp.name;return y.localeCompare(S)})};return[Tr(),(()=>{var f=Mr(),b=f.firstChild,u=b.firstChild;return n(f,i(_e,{get each(){return a()},children:m=>{if(m.kind==="custom"){const T=m.cp;return(()=>{var _=Ar(),l=_.firstChild,s=l.nextSibling,v=s.firstChild,h=v.firstChild;return _.$$click=()=>e.onEditCustom(T),n(l,()=>we(T.name,20,T.base_url)??(()=>{var w=rt();return n(w,()=>T.name.charAt(0).toUpperCase()),A(x=>ue(w,"background",Ce(T.name))),w})()),n(v,()=>T.name,h),_})()}const y=m.prov,S=()=>e.isConnected(y.id)||e.isNoKeyConnected(y.id),p=()=>!!y.localOnly&&!ht();return(()=>{var T=Ir(),_=T.firstChild,l=_.nextSibling,s=l.firstChild;return T.$$click=()=>!p()&&e.onOpenDetail(y.id,"api_key"),n(_,()=>he(y.id,20)??(()=>{var v=rt();return n(v,()=>y.initial),A(h=>ue(v,"background",y.color)),v})()),n(s,()=>y.name),n(l,i(g,{get when(){return p()},get children(){return Dr()}}),null),n(T,i(g,{get when(){return!p()},get children(){var v=Lr();return A(()=>v.classList.toggle("provider-toggle__switch--on",!!S())),v}}),null),A(()=>T.disabled=p()),T})()}}),b),ve(u,"click",e.onOpenCustomForm,!0),f})()]};re(["click"]);var Rr=r("<div class=provider-modal__tab-hint>Use your existing subscription instead of an API key. Connect via OpenClaw or paste a setup-token."),Ur=r("<div class=provider-modal__disclaimer><span class=provider-modal__disclaimer-label>Notice</span><span>Using OAuth from certain providers with AI agents may lead to account restrictions or bans. Use at your own risk."),Er=r('<div class=provider-modal__list><div class=provider-modal__add-custom><a class=provider-modal__add-custom-chip href=https://github.com/mnfst/manifest/discussions/973 target=_blank rel="noopener noreferrer"><svg width=16 height=16 viewBox="0 0 24 24"fill=currentColor aria-hidden=true><path d=m9,13h2v2c0,.55.45,1,1,1s1-.45,1-1v-2h2c.55,