myapikey 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myapikey",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "type": "module",
5
5
  "description": "Personal LLM API gateway & proxy — one address + one API key for all your models. Forwards OpenAI & Anthropic calls to your backends with failover and a circuit breaker. Pure passthrough, no format translation. Self-hosted (CLI + web UI).",
6
6
  "keywords": [
@@ -105,6 +105,8 @@ export interface ProviderModelStat {
105
105
  success: number;
106
106
  /** Fresh (non-cached) prompt tokens summed across this cell's rows. */
107
107
  inputTokens: number;
108
+ /** Completion tokens summed across this cell's rows. */
109
+ outputTokens: number;
108
110
  cacheRead: number;
109
111
  cacheCreation: number;
110
112
  cacheHitRate: number;
@@ -489,6 +491,7 @@ export class Store {
489
491
  calls: a.calls,
490
492
  success: a.success,
491
493
  inputTokens: a.sumInput,
494
+ outputTokens: a.sumOutput,
492
495
  cacheRead: a.sumCacheRead,
493
496
  cacheCreation: a.sumCacheCreation,
494
497
  cacheHitRate: hitRate(a.sumCacheRead, a.sumInput, a.sumCacheCreation),
@@ -279,7 +279,7 @@ var xu=e=>{throw TypeError(e)};var Xm=(e,t,n)=>t.has(e)||xu("Cannot "+n);var Oo=
279
279
  *
280
280
  * This source code is licensed under the ISC license.
281
281
  * See the LICENSE file in the root directory of this source tree.
282
- */const El=De("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),Xa=Q({__name:"Dialog",props:{open:{type:Boolean},defaultOpen:{type:Boolean},modal:{type:Boolean},unmountOnHide:{type:Boolean}},emits:["update:open"],setup(e,{emit:t}){const o=Mt(e,t);return(r,l)=>(_(),N(a($1),Tt($t(a(o))),{default:g(()=>[ie(r.$slots,"default")]),_:3},16))}}),Ja=Q({__name:"DialogContent",props:{forceMount:{type:Boolean},disableOutsidePointerEvents:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},emits:["escapeKeyDown","pointerDownOutside","focusOutside","interactOutside","openAutoFocus","closeAutoFocus"],setup(e,{emit:t}){const n=e,s=t,o=Y(()=>{const{class:l,...i}=n;return i}),r=Mt(o,s);return(l,i)=>(_(),N(a(f0),null,{default:g(()=>[h(a(u0),{class:"fixed inset-0 z-50 bg-black/80"}),h(a(s0),Te(a(r),{class:a(Xe)("fixed left-[50%] top-[50%] z-50 grid max-h-[90vh] w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 overflow-y-auto border bg-background p-6 shadow-lg sm:rounded-lg",n.class)}),{default:g(()=>[ie(l.$slots,"default"),h(a(M1),{class:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background"},{default:g(()=>[h(a(vu),{class:"h-4 w-4"}),i[0]||(i[0]=x("span",{class:"sr-only"},"Close",-1))]),_:1})]),_:3},16,["class"])]),_:3}))}}),Qa=Q({__name:"DialogTitle",props:{asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(_(),N(a(m0),{class:ke(a(Xe)("text-lg font-semibold leading-none tracking-tight",t.class))},{default:g(()=>[ie(n.$slots,"default")]),_:3},8,["class"]))}}),Za=Q({__name:"DialogDescription",props:{asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(_(),N(a(r0),{class:ke(a(Xe)("text-sm text-muted-foreground",t.class))},{default:g(()=>[ie(n.$slots,"default")]),_:3},8,["class"]))}}),Kn=Q({__name:"Checkbox",props:bs({class:{type:[Boolean,null,String,Object,Array]},id:{}},{modelValue:{type:Boolean},modelModifiers:{}}),emits:["update:modelValue"],setup(e){const t=e,n=br(e,"modelValue");return(s,o)=>(_(),N(a(qw),{modelValue:n.value,"onUpdate:modelValue":o[0]||(o[0]=r=>n.value=r),id:t.id,class:ke(a(Xe)("peer h-4 w-4 shrink-0 cursor-pointer rounded-[4px] border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t.class))},{default:g(()=>[h(a(Vw),{class:"flex h-full w-full items-center justify-center text-current"},{default:g(()=>[h(a(Pn),{class:"h-3.5 w-3.5"})]),_:1})]),_:1},8,["modelValue","id","class"]))}}),_i=Q({__name:"Separator",props:{class:{type:[Boolean,null,String,Object,Array]},orientation:{}},setup(e){const t=e;return(n,s)=>(_(),N(a(Ek),{orientation:t.orientation??"horizontal",class:ke(a(Xe)("shrink-0 bg-border",t.orientation==="vertical"?"h-full w-px":"h-px w-full",t.class))},null,8,["orientation","class"]))}}),oC={class:"flex gap-3 pr-8"},rC={key:0,class:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-destructive/15 text-destructive"},aC={class:"min-w-0 flex-1 space-y-1.5"},lC={class:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end"},gu=Q({__name:"ConfirmDialog",props:bs({title:{},description:{},confirmText:{default:""},cancelText:{default:""},variant:{default:"default"},loading:{type:Boolean,default:!1}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:bs(["confirm"],["update:open"]),setup(e,{emit:t}){const{t:n}=Wt(),s=br(e,"open"),o=t;return(r,l)=>(_(),N(a(Xa),{open:s.value,"onUpdate:open":l[2]||(l[2]=i=>s.value=i)},{default:g(()=>[h(a(Ja),{class:"max-w-sm"},{default:g(()=>[x("div",oC,[e.variant==="destructive"?(_(),K("span",rC,[h(a(nC),{class:"h-4 w-4"})])):me("",!0),x("div",aC,[h(a(Qa),{class:"text-base leading-tight"},{default:g(()=>[z(S(e.title),1)]),_:1}),e.description?(_(),N(a(Za),{key:0},{default:g(()=>[z(S(e.description),1)]),_:1})):me("",!0)])]),x("div",lC,[h(a(Ie),{variant:"outline",disabled:e.loading,onClick:l[0]||(l[0]=i=>s.value=!1)},{default:g(()=>[z(S(e.cancelText||a(n)("common.cancel")),1)]),_:1},8,["disabled"]),h(a(Ie),{variant:e.variant,disabled:e.loading,onClick:l[1]||(l[1]=i=>o("confirm"))},{default:g(()=>[e.loading?(_(),N(a(St),{key:0,class:"h-4 w-4 animate-spin"})):me("",!0),z(" "+S(e.confirmText||a(n)("common.confirm")),1)]),_:1},8,["variant","disabled"])])]),_:1})]),_:1},8,["open"]))}}),iC={class:"flex items-center gap-2 pr-8"},uC={class:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-primary/15 text-primary"},cC={class:"min-w-0"},dC={key:0,class:"py-4 text-center text-sm text-muted-foreground"},fC={key:1,class:"py-4 text-center text-sm text-destructive"},pC={class:"space-y-1"},mC={key:0,class:"space-y-1.5 rounded-md border bg-muted/30 p-3 text-xs leading-relaxed text-muted-foreground"},hC={key:3,class:"space-y-3 rounded-lg border bg-muted/30 p-4"},vC={class:"space-y-1.5"},gC={class:"text-xs font-medium text-muted-foreground"},yC={class:"space-y-1.5"},bC={class:"text-xs font-medium text-muted-foreground"},_C={class:"space-y-3 rounded-md border bg-background/50 p-3"},wC={class:"space-y-2"},xC={class:"flex items-center gap-2.5"},kC={class:"flex items-center gap-2.5 pl-7"},CC={class:"flex items-center gap-2.5"},SC={class:"text-xs text-muted-foreground"},AC={key:0,class:"space-y-1.5"},EC={class:"text-xs font-medium text-muted-foreground"},OC={class:"text-xs text-muted-foreground"},TC={key:1,class:"space-y-1.5"},PC={class:"text-xs font-medium text-muted-foreground"},$C={class:"text-xs text-muted-foreground"},IC={class:"space-y-1.5"},MC={class:"text-xs font-medium text-muted-foreground"},RC={key:2,class:"text-sm text-destructive"},LC={class:"flex justify-end gap-2"},DC={key:4,class:"space-y-2"},NC={key:0,class:"flex items-center gap-3"},FC={class:"min-w-0 flex-1"},qC={class:"flex items-center gap-2"},BC={class:"truncate font-medium"},VC={key:0,class:"mt-0.5 truncate font-mono text-xs text-muted-foreground"},UC={key:1,class:"mt-0.5 truncate font-mono text-xs text-muted-foreground"},HC={key:1,class:"space-y-3"},jC={class:"space-y-1.5"},WC={class:"text-xs font-medium text-muted-foreground"},KC={class:"space-y-1.5"},zC={class:"text-xs font-medium text-muted-foreground"},GC={class:"space-y-3 rounded-md border bg-background/50 p-3"},YC={class:"space-y-2"},XC={class:"flex items-center gap-2.5"},JC={class:"flex items-center gap-2.5 pl-7"},QC={class:"flex items-center gap-2.5"},ZC={key:0,class:"space-y-1.5"},eS={class:"text-xs font-medium text-muted-foreground"},tS={class:"text-xs text-muted-foreground"},nS={key:1,class:"space-y-1.5"},sS={class:"text-xs font-medium text-muted-foreground"},oS={class:"text-xs text-muted-foreground"},rS={class:"space-y-1.5"},aS={class:"flex items-center justify-between"},lS={class:"text-xs font-medium text-muted-foreground"},iS={key:0,class:"text-xs text-muted-foreground"},uS={class:"space-y-1.5"},cS={class:"text-xs font-medium text-muted-foreground"},dS={class:"text-xs text-muted-foreground"},fS={class:"flex justify-end gap-2"},pS=Q({__name:"SourcesDialog",props:{open:{type:Boolean,default:!1},openModifiers:{}},emits:bs(["changed"],["update:open"]),setup(e,{emit:t}){const{t:n}=Wt(),s=br(e,"open"),o=t,r=L([]),l=L(!1),i=L(""),u=L(""),c=L(""),d=L(""),f=L(""),p=L(!0),m=L(!1),b=L(!1),C=L(!1),E=L(""),y=L(!1),k=L(!1),I=L(null),v=L(""),$=L(""),T=L(""),A=L(""),R=L(""),V=L(!0),J=L(!1),fe=L(!1),X=L(!1),ce=L({}),be=L(null),Z=L(!1),ue=L(!1);async function de(){l.value=!0,i.value="";try{const ge=await He("GET","/admin/providers");r.value=ge.providers}catch(ge){i.value=ge.message}finally{l.value=!1}}Fe(s,ge=>{ge&&de()});function se(ge,w){const M=ge==="new"?p:V,W=ge==="new"?m:J;if(w==="openai"){if(M.value&&!W.value)return;M.value=!M.value}else{if(W.value&&!M.value)return;W.value=!W.value}}function re(ge){const w=[];return(ge==="new"?p:V).value&&w.push("openai"),(ge==="new"?m:J).value&&w.push("anthropic"),w}async function q(){if(C.value)return;E.value="";const ge=re("new");if(!u.value||!f.value){E.value=n("sources.errRequired");return}if(!ge.length){E.value=n("sources.errFormat");return}if(p.value&&!c.value||m.value&&!d.value){E.value=n("sources.errBaseUrl");return}C.value=!0;try{const w=await He("POST","/admin/providers",{name:u.value,baseUrlOpenai:c.value,baseUrlAnthropic:d.value,apiKey:f.value,formats:ge,supportsResponses:p.value&&b.value});r.value=[...r.value,w.provider],u.value=f.value="",c.value=d.value="",b.value=!1,y.value=!1,Me(n("sources.added"),"success"),o("changed")}catch(w){Me(w.message,"error")}finally{C.value=!1}}function pe(ge){I.value=ge.id,v.value=ge.name,$.value=ge.baseUrlOpenai,T.value=ge.baseUrlAnthropic,A.value="",R.value=ge.rpm?String(ge.rpm):"",V.value=ge.formats.includes("openai"),J.value=ge.formats.includes("anthropic"),fe.value=!!ge.supportsResponses}function ee(){I.value=null}async function Ze(ge){if(X.value)return;const w=re("edit");if(!v.value){Me(n("sources.errRequired"),"error");return}if(!w.length){Me(n("sources.errFormat"),"error");return}if(V.value&&!$.value||J.value&&!T.value){Me(n("sources.errBaseUrl"),"error");return}X.value=!0;try{const M={name:v.value,baseUrlOpenai:$.value,baseUrlAnthropic:T.value,formats:w,supportsResponses:V.value&&fe.value,rpm:Number(R.value)||0};A.value&&(M.apiKey=A.value);const W=await He("PUT",`/admin/providers/${ge.id}`,M);r.value=r.value.map(le=>le.id===ge.id?W.provider:le),I.value=null,Me(n("sources.updated"),"success"),o("changed")}catch(M){Me(M.message,"error")}finally{X.value=!1}}async function Ve(ge){ce.value[ge.id]=!0;try{const w=await He("POST",`/admin/providers/${ge.id}/discover`);r.value=r.value.map(M=>M.id===ge.id?{...M,discoveredModels:w.models}:M),Me(n("sources.refreshDone",{name:ge.name}),w.models.length?"success":"default"),o("changed")}catch(w){Me(w.message,"error")}finally{ce.value[ge.id]=!1}}function $e(ge){be.value=ge,Z.value=!0}async function Be(){const ge=be.value;if(!(!ge||ue.value)){ue.value=!0;try{await He("DELETE",`/admin/providers/${ge.id}`),r.value=r.value.filter(w=>w.id!==ge.id),Me(n("sources.removed",{name:ge.name}),"success"),o("changed"),Z.value=!1}catch(w){Me(w.message,"error")}finally{ue.value=!1}}}function Ue(ge){var w;return((w=ge.discoveredModels)==null?void 0:w.length)??0}function rt(ge){return Ue(ge)>0?"found":ge.discoveredAt?"empty":"never"}function Re(ge){const w=rt(ge);return w==="found"?n("sources.discoveredCount",{n:Ue(ge)}):n(w==="empty"?"sources.noModelsFound":"sources.notScanned")}function ut(ge){const w=rt(ge);return w==="empty"?n("sources.noModelsHint"):w==="never"?n("sources.notScannedHint"):""}return(ge,w)=>(_(),K(Ce,null,[h(a(Xa),{open:s.value,"onUpdate:open":w[18]||(w[18]=M=>s.value=M)},{default:g(()=>[h(a(Ja),{class:"max-w-xl"},{default:g(()=>[x("div",iC,[x("span",uC,[h(a(yi),{class:"h-4 w-4"})]),x("div",cC,[h(a(Qa),{class:"text-base"},{default:g(()=>[z(S(a(n)("sources.manage")),1)]),_:1}),h(a(Za),null,{default:g(()=>[z(S(a(n)("sources.subtitle")),1)]),_:1})])]),l.value?(_(),K("p",dC,S(a(n)("common.loading")),1)):i.value?(_(),K("p",fC,S(i.value),1)):me("",!0),x("div",pC,[x("button",{type:"button",class:"inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground",onClick:w[0]||(w[0]=M=>k.value=!k.value)},[h(a(Om),{class:"h-3.5 w-3.5"}),z(" "+S(a(n)("sources.baseHelpToggle"))+" ",1),h(a(Ya),{class:ke(["h-3.5 w-3.5 transition-transform",{"rotate-180":k.value}])},null,8,["class"])]),k.value?(_(),K("div",mC,[x("p",null,S(a(n)("sources.baseHelpSplit")),1),x("p",null,[w[20]||(w[20]=x("span",{class:"font-medium text-foreground"},"openai",-1)),z(" — "+S(a(n)("sources.baseHelpOpenai")),1)]),x("p",null,[w[21]||(w[21]=x("span",{class:"font-medium text-foreground"},"anthropic",-1)),z(" — "+S(a(n)("sources.baseHelpAnthropic")),1)])])):me("",!0)]),!y.value&&r.value.length?(_(),N(a(Ie),{key:2,variant:"outline",class:"w-full justify-center",onClick:w[1]||(w[1]=M=>y.value=!0)},{default:g(()=>[h(a(ts),{class:"h-4 w-4"}),z(S(a(n)("sources.add")),1)]),_:1})):(_(),K("div",hC,[x("div",vC,[x("label",gC,S(a(n)("sources.nameLabel")),1),h(a(vt),{modelValue:u.value,"onUpdate:modelValue":w[2]||(w[2]=M=>u.value=M),placeholder:a(n)("sources.namePh"),autocomplete:"off","aria-label":"name"},null,8,["modelValue","placeholder"])]),x("div",yC,[x("label",bC,S(a(n)("sources.formats")),1),x("div",_C,[x("div",wC,[x("div",xC,[h(a(Kn),{"model-value":p.value,disabled:p.value&&!m.value,"aria-label":"openai","onUpdate:modelValue":w[3]||(w[3]=M=>se("new","openai"))},null,8,["model-value","disabled"]),w[22]||(w[22]=x("span",{class:"text-sm font-medium leading-none"},"openai",-1)),w[23]||(w[23]=x("span",{class:"text-xs text-muted-foreground"},"/chat/completions",-1))]),x("div",kC,[h(a(Kn),{modelValue:b.value,"onUpdate:modelValue":w[4]||(w[4]=M=>b.value=M),disabled:!p.value,"aria-label":a(n)("sources.responses")},null,8,["modelValue","disabled","aria-label"]),x("span",{class:ke(["text-sm leading-none",p.value?"":"text-muted-foreground"])},S(a(n)("sources.responses")),3),w[24]||(w[24]=x("span",{class:"text-xs text-muted-foreground"},"/responses",-1))])]),h(a(_i)),x("div",CC,[h(a(Kn),{"model-value":m.value,disabled:m.value&&!p.value,"aria-label":"anthropic","onUpdate:modelValue":w[5]||(w[5]=M=>se("new","anthropic"))},null,8,["model-value","disabled"]),w[25]||(w[25]=x("span",{class:"text-sm font-medium leading-none"},"anthropic",-1)),w[26]||(w[26]=x("span",{class:"text-xs text-muted-foreground"},"/messages",-1))])]),x("p",SC,S(a(n)("sources.addHint")),1)]),p.value?(_(),K("div",AC,[x("label",EC,S(a(n)("sources.urlLabelOpenai")),1),h(a(vt),{modelValue:c.value,"onUpdate:modelValue":w[6]||(w[6]=M=>c.value=M),placeholder:a(n)("sources.urlPhOpenai"),autocomplete:"off","aria-label":"openai base url"},null,8,["modelValue","placeholder"]),x("p",OC,S(a(n)("sources.urlHintOpenai")),1)])):me("",!0),m.value?(_(),K("div",TC,[x("label",PC,S(a(n)("sources.urlLabelAnthropic")),1),h(a(vt),{modelValue:d.value,"onUpdate:modelValue":w[7]||(w[7]=M=>d.value=M),placeholder:a(n)("sources.urlPhAnthropic"),autocomplete:"off","aria-label":"anthropic base url"},null,8,["modelValue","placeholder"]),x("p",$C,S(a(n)("sources.urlHintAnthropic")),1)])):me("",!0),x("div",IC,[x("label",MC,S(a(n)("sources.keyLabel")),1),h(a(vt),{modelValue:f.value,"onUpdate:modelValue":w[8]||(w[8]=M=>f.value=M),type:"password",placeholder:a(n)("sources.keyPh"),autocomplete:"new-password","aria-label":"api key"},null,8,["modelValue","placeholder"])]),E.value?(_(),K("p",RC,S(E.value),1)):me("",!0),x("div",LC,[r.value.length?(_(),N(a(Ie),{key:0,variant:"ghost",size:"sm",onClick:w[9]||(w[9]=M=>y.value=!1)},{default:g(()=>[z(S(a(n)("sources.cancel")),1)]),_:1})):me("",!0),h(a(Ie),{size:"sm",disabled:C.value,onClick:q},{default:g(()=>[C.value?(_(),N(a(St),{key:0,class:"h-4 w-4 animate-spin"})):(_(),N(a(ts),{key:1,class:"h-4 w-4"})),z(S(a(n)("sources.addBtn")),1)]),_:1},8,["disabled"])])])),r.value.length?(_(),K("div",DC,[(_(!0),K(Ce,null,st(r.value,M=>(_(),K("div",{key:M.id,class:"rounded-lg border p-3"},[I.value!==M.id?(_(),K("div",NC,[x("div",FC,[x("div",qC,[x("span",BC,S(M.name),1),(_(!0),K(Ce,null,st(M.formats,W=>(_(),N(a(_t),{key:W,variant:"secondary"},{default:g(()=>[z(S(W),1)]),_:2},1024))),128)),M.rpm?(_(),N(a(_t),{key:0,variant:"outline",title:a(n)("sources.rpmBadgeHint")},{default:g(()=>[z(S(a(n)("sources.rpmBadge",{n:M.rpm})),1)]),_:2},1032,["title"])):me("",!0),h(a(_t),{variant:"muted",title:ut(M)},{default:g(()=>[z(S(Re(M)),1)]),_:2},1032,["title"])]),M.formats.includes("openai")?(_(),K("div",VC,[w[27]||(w[27]=x("span",{class:"opacity-60"},"openai ·",-1)),z(" "+S(M.baseUrlOpenai),1)])):me("",!0),M.formats.includes("anthropic")?(_(),K("div",UC,[w[28]||(w[28]=x("span",{class:"opacity-60"},"anthropic ·",-1)),z(" "+S(M.baseUrlAnthropic),1)])):me("",!0)]),h(a(fi),null,{default:g(()=>[h(a(pi),null,{default:g(()=>[h(a(Ie),{variant:"ghost",size:"icon",class:"h-8 w-8","aria-label":a(n)("sources.moreActions")},{default:g(()=>[h(a(gi),{class:"h-4 w-4"})]),_:1},8,["aria-label"])]),_:1}),h(a(mi),{align:"end"},{default:g(()=>[h(a(Wn),{disabled:ce.value[M.id],onSelect:W=>Ve(M)},{default:g(()=>[ce.value[M.id]?(_(),N(a(St),{key:0,class:"animate-spin"})):(_(),N(a(mr),{key:1})),z(" "+S(a(n)("sources.refreshModels")),1)]),_:2},1032,["disabled","onSelect"]),h(a(Wn),{onSelect:W=>pe(M)},{default:g(()=>[h(a(Tm)),z(" "+S(a(n)("sources.editLabel")),1)]),_:1},8,["onSelect"]),h(a(hi)),h(a(Wn),{class:"text-destructive focus:bg-destructive/10 focus:text-destructive",onSelect:W=>$e(M)},{default:g(()=>[h(a(bi)),z(" "+S(a(n)("sources.deleteLabel")),1)]),_:1},8,["onSelect"])]),_:2},1024)]),_:2},1024)])):(_(),K("div",HC,[x("div",jC,[x("label",WC,S(a(n)("sources.nameLabel")),1),h(a(vt),{modelValue:v.value,"onUpdate:modelValue":w[10]||(w[10]=W=>v.value=W),placeholder:a(n)("sources.namePh"),autocomplete:"off","aria-label":"name"},null,8,["modelValue","placeholder"])]),x("div",KC,[x("label",zC,S(a(n)("sources.formats")),1),x("div",GC,[x("div",YC,[x("div",XC,[h(a(Kn),{"model-value":V.value,disabled:V.value&&!J.value,"aria-label":"openai","onUpdate:modelValue":w[11]||(w[11]=W=>se("edit","openai"))},null,8,["model-value","disabled"]),w[29]||(w[29]=x("span",{class:"text-sm font-medium leading-none"},"openai",-1)),w[30]||(w[30]=x("span",{class:"text-xs text-muted-foreground"},"/chat/completions",-1))]),x("div",JC,[h(a(Kn),{modelValue:fe.value,"onUpdate:modelValue":w[12]||(w[12]=W=>fe.value=W),disabled:!V.value,"aria-label":a(n)("sources.responses")},null,8,["modelValue","disabled","aria-label"]),x("span",{class:ke(["text-sm leading-none",V.value?"":"text-muted-foreground"])},S(a(n)("sources.responses")),3),w[31]||(w[31]=x("span",{class:"text-xs text-muted-foreground"},"/responses",-1))])]),h(a(_i)),x("div",QC,[h(a(Kn),{"model-value":J.value,disabled:J.value&&!V.value,"aria-label":"anthropic","onUpdate:modelValue":w[13]||(w[13]=W=>se("edit","anthropic"))},null,8,["model-value","disabled"]),w[32]||(w[32]=x("span",{class:"text-sm font-medium leading-none"},"anthropic",-1)),w[33]||(w[33]=x("span",{class:"text-xs text-muted-foreground"},"/messages",-1))])])]),V.value?(_(),K("div",ZC,[x("label",eS,S(a(n)("sources.urlLabelOpenai")),1),h(a(vt),{modelValue:$.value,"onUpdate:modelValue":w[14]||(w[14]=W=>$.value=W),placeholder:a(n)("sources.urlPhOpenai"),autocomplete:"off","aria-label":"openai base url"},null,8,["modelValue","placeholder"]),x("p",tS,S(a(n)("sources.urlHintOpenai")),1)])):me("",!0),J.value?(_(),K("div",nS,[x("label",sS,S(a(n)("sources.urlLabelAnthropic")),1),h(a(vt),{modelValue:T.value,"onUpdate:modelValue":w[15]||(w[15]=W=>T.value=W),placeholder:a(n)("sources.urlPhAnthropic"),autocomplete:"off","aria-label":"anthropic base url"},null,8,["modelValue","placeholder"]),x("p",oS,S(a(n)("sources.urlHintAnthropic")),1)])):me("",!0),x("div",rS,[x("div",aS,[x("label",lS,S(a(n)("sources.keyLabel")),1),M.apiKey?(_(),K("span",iS,S(a(n)("sources.currentKeyLabel"))+": "+S(M.apiKey),1)):me("",!0)]),h(a(vt),{modelValue:A.value,"onUpdate:modelValue":w[16]||(w[16]=W=>A.value=W),type:"password",placeholder:a(n)("sources.keyPhEdit"),autocomplete:"new-password","aria-label":"api key"},null,8,["modelValue","placeholder"])]),x("div",uS,[x("label",cS,S(a(n)("sources.rpmLabel")),1),h(a(vt),{modelValue:R.value,"onUpdate:modelValue":w[17]||(w[17]=W=>R.value=W),type:"number",min:"0",inputmode:"numeric",placeholder:a(n)("sources.rpmPh"),"aria-label":"rpm"},null,8,["modelValue","placeholder"]),x("p",dS,S(a(n)("sources.rpmHint")),1)]),x("div",fS,[h(a(Ie),{variant:"ghost",size:"sm",onClick:ee},{default:g(()=>[z(S(a(n)("sources.cancel")),1)]),_:1}),h(a(Ie),{size:"sm",disabled:X.value,onClick:W=>Ze(M)},{default:g(()=>[X.value?(_(),N(a(St),{key:0,class:"h-4 w-4 animate-spin"})):me("",!0),z(S(a(n)("sources.saveBtn")),1)]),_:1},8,["disabled","onClick"])])]))]))),128))])):me("",!0)]),_:1})]),_:1},8,["open"]),h(gu,{open:Z.value,"onUpdate:open":w[19]||(w[19]=M=>Z.value=M),variant:"destructive",title:a(n)("sources.remove"),description:be.value?a(n)("sources.confirmRemove",{name:be.value.name}):"","confirm-text":a(n)("sources.remove"),loading:ue.value,onConfirm:Be},null,8,["open","title","description","confirm-text","loading"])],64))}}),zo=Q({__name:"Select",props:{open:{type:Boolean},defaultOpen:{type:Boolean},defaultValue:{},modelValue:{},nullableValue:{},by:{type:[String,Function]},dir:{},multiple:{type:Boolean},autocomplete:{},disabled:{type:Boolean},name:{},required:{type:Boolean}},emits:["update:modelValue","update:open"],setup(e,{emit:t}){const o=Mt(e,t);return(r,l)=>(_(),N(a(jx),Tt($t(a(o))),{default:g(()=>[ie(r.$slots,"default")]),_:3},16))}}),Go=Q({__name:"SelectTrigger",props:{disabled:{type:Boolean},reference:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e,n=Y(()=>{const{class:s,...o}=t;return o});return(s,o)=>(_(),N(a(bk),Te(n.value,{class:a(Xe)("flex h-9 w-full items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t.class)}),{default:g(()=>[ie(s.$slots,"default"),h(a(ik),{"as-child":""},{default:g(()=>[h(a(Ya),{class:"h-4 w-4 opacity-50"})]),_:1})]),_:3},16,["class"]))}}),Yo=Q({__name:"SelectValue",props:{placeholder:{},asChild:{type:Boolean},as:{}},setup(e){const t=e;return(n,s)=>(_(),N(a(wk),Tt($t(t)),{default:g(()=>[ie(n.$slots,"default")]),_:3},16))}}),Xo=Q({__name:"SelectContent",props:{forceMount:{type:Boolean},position:{default:"popper"},bodyLock:{type:Boolean},memoDependencies:{},side:{},sideOffset:{},sideFlip:{type:Boolean},align:{},alignOffset:{},alignFlip:{type:Boolean},avoidCollisions:{type:Boolean},collisionBoundary:{},collisionPadding:{},arrowPadding:{},hideShiftedArrow:{type:Boolean},sticky:{},hideWhenDetached:{type:Boolean},positionStrategy:{},updatePositionStrategy:{},disableUpdateOnLayoutShift:{type:Boolean},prioritizePosition:{type:Boolean},reference:{},dir:{},asChild:{type:Boolean},as:{},disableOutsidePointerEvents:{type:Boolean},class:{type:[Boolean,null,String,Object,Array]}},emits:["closeAutoFocus","escapeKeyDown","pointerDownOutside"],setup(e,{emit:t}){const n=e,s=t,o=Y(()=>{const{class:l,...i}=n;return i}),r=Mt(o,s);return(l,i)=>(_(),N(a(gk),null,{default:g(()=>[h(a(ak),Te(a(r),{class:a(Xe)("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",n.position==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:translate-x-1 data-[side=right]:-translate-x-1 data-[side=top]:-translate-y-1",n.class)}),{default:g(()=>[h(a(kk),{class:ke(a(Xe)("p-1",n.position==="popper"&&"w-full min-w-[var(--reka-select-trigger-width)]"))},{default:g(()=>[ie(l.$slots,"default")]),_:3},8,["class"])]),_:3},16,["class"])]),_:3}))}}),mS={class:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center"},fn=Q({__name:"SelectItem",props:{value:{},disabled:{type:Boolean},textValue:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e,n=Y(()=>{const{class:s,...o}=t;return o});return(s,o)=>(_(),N(a(dk),Te(n.value,{class:a(Xe)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t.class)}),{default:g(()=>[x("span",mS,[h(a(pk),null,{default:g(()=>[h(a(Pn),{class:"h-4 w-4"})]),_:1})]),h(a(hk),null,{default:g(()=>[ie(s.$slots,"default")]),_:3})]),_:3},16,["class"]))}}),hS={class:"flex items-center gap-2 pr-8"},vS={class:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-primary/15 text-primary"},gS={class:"min-w-0"},yS={class:"space-y-3"},bS={class:"space-y-1.5"},_S={class:"text-xs font-medium text-muted-foreground"},wS={class:"text-xs text-muted-foreground"},xS={class:"font-medium text-foreground"},kS={key:0,class:"space-y-3 rounded-lg border bg-muted/30 p-4"},CS={class:"text-xs text-muted-foreground"},SS={key:0,class:"space-y-1.5"},AS={class:"text-xs font-medium text-muted-foreground"},ES={class:"space-y-1.5"},OS={class:"text-xs font-medium text-muted-foreground"},TS={class:"space-y-2 rounded-md border bg-background/50 p-3"},PS={class:"space-y-2"},$S={class:"flex items-center gap-2.5"},IS={class:"flex items-center gap-2.5 pl-7"},MS={class:"flex items-center gap-2.5"},RS={key:1,class:"space-y-1.5"},LS={class:"text-xs font-medium text-muted-foreground"},DS={class:"text-xs text-muted-foreground"},NS={key:2,class:"space-y-1.5"},FS={class:"text-xs font-medium text-muted-foreground"},qS={class:"text-xs text-muted-foreground"},BS={key:3,class:"space-y-1.5"},VS={class:"text-xs font-medium text-muted-foreground"},US={key:4,class:"text-sm text-destructive"},HS={key:1,class:"space-y-1.5"},jS={class:"flex items-center justify-between gap-2"},WS={class:"text-xs font-medium text-muted-foreground"},KS={key:0,class:"text-xs text-muted-foreground"},zS={key:0,class:"text-xs text-muted-foreground"},GS={key:0,class:"text-xs text-muted-foreground"},YS={key:1,class:"flex max-h-40 flex-wrap gap-1 overflow-y-auto rounded-md border bg-background/50 p-2"},XS=["aria-pressed","onClick"],JS={class:"space-y-1.5"},QS={class:"text-xs font-medium text-muted-foreground"},ZS=["placeholder"],eA={key:0,class:"text-xs text-muted-foreground"},tA={class:"flex justify-end gap-2"},Ol="__new__",yd="__none__",nA=Q({__name:"AddModelsDialog",props:bs({providers:{}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:bs(["changed"],["update:open"]),setup(e,{emit:t}){const{t:n}=Wt(),s=e,o=br(e,"open"),r=t,l=L(""),i=L(""),u=L(!1),c=L(""),d=L(""),f=L(""),p=L(""),m=L(!0),b=L(!1),C=L(!1),E=L(""),y=L(new Set),k=L([]),I=L("");Fe(o,se=>{se&&(l.value=s.providers.length?s.providers[0].id:Ol,i.value="",y.value=new Set,k.value=[],I.value="",c.value=p.value="",d.value=f.value="",m.value=!0,b.value=!1,C.value=!1,E.value="")}),Fe(l,()=>{y.value=new Set,I.value=""});const v=Y(()=>l.value===Ol),$=Y(()=>l.value===yd);function T(se){const re=[...se.formats];return se.supportsResponses&&!re.includes("responses")&&re.push("responses"),re}const A=Y(()=>{if(v.value||$.value)return T({formats:V(),supportsResponses:m.value&&C.value});const se=s.providers.find(re=>re.id===l.value);return se?T(se):[]});function R(se){if(se==="openai"){if(m.value&&!b.value)return;m.value=!m.value}else{if(b.value&&!m.value)return;b.value=!b.value}}function V(){const se=[];return m.value&&se.push("openai"),b.value&&se.push("anthropic"),se}function J(){return!c.value.trim()||!p.value?n("sources.errRequired"):V().length?m.value&&!d.value.trim()||b.value&&!f.value.trim()?n("sources.errBaseUrl"):"":n("sources.errFormat")}const fe=Y(()=>{const se=new Set,re=[];for(const q of i.value.split(/[\s,;]+/)){const pe=q.trim();pe&&!se.has(pe)&&(se.add(pe),re.push(pe))}return re}),X=Y(()=>{const se=new Set,re=[];for(const q of[...fe.value,...y.value])se.has(q)||(se.add(q),re.push(q));return re}),ce=Y(()=>{if($.value)return[];const se=s.providers.find(re=>re.id===l.value);return se?se.discoveredModels??[]:k.value}),be=Y(()=>{const se=I.value.trim().toLowerCase();return se?ce.value.filter(re=>re.toLowerCase().includes(se)):ce.value});function Z(se){const re=new Set(y.value);re.has(se)?re.delete(se):re.add(se),y.value=re}const ue=Y(()=>!!l.value&&X.value.length>0&&A.value.length>0&&!u.value);async function de(){if(ue.value){if(v.value){const se=J();if(se){E.value=se;return}}u.value=!0;try{let se=l.value,re=[],q=!1;if(v.value){const $e=await He("POST","/admin/providers",{name:c.value.trim(),baseUrlOpenai:d.value,baseUrlAnthropic:f.value,apiKey:p.value,formats:V(),supportsResponses:m.value&&C.value});se=$e.provider.id,l.value=se,k.value=$e.discovered??$e.provider.discoveredModels??[],re=T($e.provider),q=!0,Me(n("sources.added"),"success")}else if($.value)re=T({formats:V(),supportsResponses:m.value&&C.value});else{const $e=s.providers.find(Be=>Be.id===se);re=$e?T($e):[]}const pe=[];for(const $e of X.value)for(const Be of re)pe.push({name:$e,slot:Be});const ee=await Promise.allSettled(pe.map($e=>He("POST","/admin/models",{name:$e.name,format:$e.slot,providers:$.value?[]:[se]}))),Ze=new Set;let Ve=0;ee.forEach(($e,Be)=>{$e.status==="fulfilled"?Ze.add(pe[Be].name):Ve++}),Ze.size&&Me(n("models.addedToast",{n:Ze.size}),"success"),Ve&&Me(n("models.addModelsFailed",{n:Ve}),"error"),(q||Ze.size)&&r("changed"),Ze.size&&(o.value=!1)}finally{u.value=!1}}}return(se,re)=>(_(),N(a(Xa),{open:o.value,"onUpdate:open":re[11]||(re[11]=q=>o.value=q)},{default:g(()=>[h(a(Ja),{class:ke(v.value?"max-w-lg":"max-w-md")},{default:g(()=>[x("div",hS,[x("span",vS,[h(a(ts),{class:"h-4 w-4"})]),x("div",gS,[h(a(Qa),{class:"text-base"},{default:g(()=>[z(S(a(n)("models.addModels")),1)]),_:1}),h(a(Za),null,{default:g(()=>[z(S(a(n)("models.addModelsDesc")),1)]),_:1})])]),x("div",yS,[x("div",bS,[x("label",_S,S(a(n)("models.providerLabel")),1),h(a(zo),{modelValue:l.value,"onUpdate:modelValue":re[0]||(re[0]=q=>l.value=q)},{default:g(()=>[h(a(Go),null,{default:g(()=>[h(a(Yo),{placeholder:a(n)("models.providerPh")},null,8,["placeholder"])]),_:1}),h(a(Xo),null,{default:g(()=>[h(a(fn),{value:Ol},{default:g(()=>[z(S(a(n)("models.newSourceOpt")),1)]),_:1}),h(a(fn),{value:yd},{default:g(()=>[z(S(a(n)("models.noneSourceOpt")),1)]),_:1}),(_(!0),K(Ce,null,st(e.providers,q=>(_(),N(a(fn),{key:q.id,value:q.id},{default:g(()=>[z(S(q.name),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"]),x("p",wS,[z(S(a(n)("models.addModelsSlotsHint"))+" ",1),x("span",xS,S(A.value.join(" / ")||"—"),1)])]),v.value||$.value?(_(),K("div",kS,[x("p",CS,S(v.value?a(n)("models.addModelsNewHint"):a(n)("models.addModelsNoneHint")),1),v.value?(_(),K("div",SS,[x("label",AS,S(a(n)("sources.nameLabel")),1),h(a(vt),{modelValue:c.value,"onUpdate:modelValue":re[1]||(re[1]=q=>c.value=q),placeholder:a(n)("sources.namePh"),autocomplete:"off","aria-label":"name"},null,8,["modelValue","placeholder"])])):me("",!0),x("div",ES,[x("label",OS,S(a(n)("sources.formats")),1),x("div",TS,[x("div",PS,[x("div",$S,[h(a(Kn),{"model-value":m.value,disabled:m.value&&!b.value,"aria-label":"openai","onUpdate:modelValue":re[2]||(re[2]=q=>R("openai"))},null,8,["model-value","disabled"]),re[12]||(re[12]=x("span",{class:"text-sm font-medium leading-none"},"openai",-1)),re[13]||(re[13]=x("span",{class:"text-xs text-muted-foreground"},"/chat/completions",-1))]),x("div",IS,[h(a(Kn),{modelValue:C.value,"onUpdate:modelValue":re[3]||(re[3]=q=>C.value=q),disabled:!m.value,"aria-label":a(n)("sources.responses")},null,8,["modelValue","disabled","aria-label"]),x("span",{class:ke(["text-sm leading-none",m.value?"":"text-muted-foreground"])},S(a(n)("sources.responses")),3),re[14]||(re[14]=x("span",{class:"text-xs text-muted-foreground"},"/responses",-1))])]),h(a(_i)),x("div",MS,[h(a(Kn),{"model-value":b.value,disabled:b.value&&!m.value,"aria-label":"anthropic","onUpdate:modelValue":re[4]||(re[4]=q=>R("anthropic"))},null,8,["model-value","disabled"]),re[15]||(re[15]=x("span",{class:"text-sm font-medium leading-none"},"anthropic",-1)),re[16]||(re[16]=x("span",{class:"text-xs text-muted-foreground"},"/messages",-1))])])]),v.value&&m.value?(_(),K("div",RS,[x("label",LS,S(a(n)("sources.urlLabelOpenai")),1),h(a(vt),{modelValue:d.value,"onUpdate:modelValue":re[5]||(re[5]=q=>d.value=q),placeholder:a(n)("sources.urlPhOpenai"),autocomplete:"off","aria-label":"openai base url"},null,8,["modelValue","placeholder"]),x("p",DS,S(a(n)("sources.urlHintOpenai")),1)])):me("",!0),v.value&&b.value?(_(),K("div",NS,[x("label",FS,S(a(n)("sources.urlLabelAnthropic")),1),h(a(vt),{modelValue:f.value,"onUpdate:modelValue":re[6]||(re[6]=q=>f.value=q),placeholder:a(n)("sources.urlPhAnthropic"),autocomplete:"off","aria-label":"anthropic base url"},null,8,["modelValue","placeholder"]),x("p",qS,S(a(n)("sources.urlHintAnthropic")),1)])):me("",!0),v.value?(_(),K("div",BS,[x("label",VS,S(a(n)("sources.keyLabel")),1),h(a(vt),{modelValue:p.value,"onUpdate:modelValue":re[7]||(re[7]=q=>p.value=q),type:"password",placeholder:a(n)("sources.keyPh"),autocomplete:"new-password","aria-label":"api key"},null,8,["modelValue","placeholder"])])):me("",!0),v.value&&E.value?(_(),K("p",US,S(E.value),1)):me("",!0)])):me("",!0),!v.value&&!$.value?(_(),K("div",HS,[x("div",jS,[x("label",WS,S(a(n)("models.addModelsDiscoveredLabel")),1),ce.value.length?(_(),K("span",KS,S(a(n)("models.addModelsDiscoveredHint")),1)):me("",!0)]),ce.value.length?(_(),K(Ce,{key:1},[h(a(vt),{modelValue:I.value,"onUpdate:modelValue":re[8]||(re[8]=q=>I.value=q),placeholder:a(n)("models.searchPh"),autocomplete:"off"},null,8,["modelValue","placeholder"]),be.value.length?(_(),K("div",YS,[(_(!0),K(Ce,null,st(be.value,q=>(_(),K("button",{key:q,type:"button","aria-pressed":y.value.has(q),class:ke(["inline-flex items-center rounded-md border px-2 py-0.5 font-mono text-xs transition-colors",y.value.has(q)?"border-transparent bg-primary text-primary-foreground shadow-sm":"border-input text-muted-foreground hover:bg-accent hover:text-accent-foreground"]),onClick:pe=>Z(q)},S(q),11,XS))),128))])):(_(),K("p",GS,S(a(n)("models.addModelsDiscoveredNoMatch")),1))],64)):(_(),K("p",zS,S(a(n)("models.addModelsDiscoveredEmpty")),1))])):me("",!0),x("div",JS,[x("label",QS,S(a(n)("models.namesLabel")),1),yo(x("textarea",{"onUpdate:modelValue":re[9]||(re[9]=q=>i.value=q),placeholder:a(n)("models.addModelsNamesPh"),rows:"6",spellcheck:"false",class:"flex w-full resize-y rounded-md border border-input bg-transparent px-3 py-2 font-mono text-sm shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50"},null,8,ZS),[[Og,i.value]]),X.value.length?(_(),K("p",eA,S(a(n)("models.addModelsCount",{n:X.value.length})),1)):me("",!0)]),x("div",tA,[h(a(Ie),{variant:"outline",disabled:u.value,onClick:re[10]||(re[10]=q=>o.value=!1)},{default:g(()=>[z(S(a(n)("common.cancel")),1)]),_:1},8,["disabled"]),h(a(Ie),{disabled:!ue.value,onClick:de},{default:g(()=>[u.value?(_(),N(a(St),{key:0,class:"h-4 w-4 animate-spin"})):(_(),N(a(ts),{key:1,class:"h-4 w-4"})),z(" "+S(a(n)("models.addModelsBtn")),1)]),_:1},8,["disabled"])])])]),_:1},8,["class"])]),_:1},8,["open"]))}}),sA={key:0,class:"absolute z-50 mt-1 max-h-56 w-full overflow-auto rounded-md border bg-popover p-1 text-sm shadow-md"},oA=["onMousedown"],rA={key:1,class:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"},aA={class:"flex-1 truncate"},lA={key:0,class:"px-2 py-1 text-xs text-muted-foreground"},iA=Q({__name:"Combobox",props:{modelValue:{},options:{},placeholder:{},limit:{default:300}},emits:["update:modelValue"],setup(e,{emit:t}){const n=e,s=t,o=L(null),r=L(!1),l=Y(()=>{const p=n.modelValue.trim().toLowerCase();return p?n.options.filter(m=>m.toLowerCase().includes(p)):n.options}),i=Y(()=>l.value.slice(0,n.limit)),u=Y(()=>l.value.length-i.value.length);function c(p){s("update:modelValue",String(p)),r.value=!0}function d(p){s("update:modelValue",p),r.value=!1}function f(p){var b;const m=p.relatedTarget;m&&((b=o.value)!=null&&b.contains(m))||(r.value=!1)}return(p,m)=>(_(),K("div",{ref_key:"rootRef",ref:o,class:"relative",onFocusin:m[0]||(m[0]=b=>r.value=!0),onFocusout:f},[h(a(vt),{"model-value":e.modelValue,placeholder:e.placeholder,autocomplete:"off",spellcheck:"false","onUpdate:modelValue":c},null,8,["model-value","placeholder"]),r.value&&i.value.length?(_(),K("ul",sA,[(_(!0),K(Ce,null,st(i.value,b=>(_(),K("li",{key:b},[x("button",{type:"button",class:ke(["flex w-full items-center gap-2 rounded px-2 py-1.5 text-left font-mono hover:bg-accent hover:text-accent-foreground",b===e.modelValue?"text-primary":""]),onMousedown:Gt(C=>d(b),["prevent"])},[b===e.modelValue?(_(),N(a(Pn),{key:0,class:"h-3.5 w-3.5 shrink-0"})):(_(),K("span",rA)),x("span",aA,S(b),1)],42,oA)]))),128)),u.value>0?(_(),K("li",lA," +"+S(u.value)+" more — refine your search ",1)):me("",!0)])):me("",!0)],544))}}),uA={class:"flex items-center gap-2 pr-8"},cA={class:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-primary/15 text-primary"},dA={class:"min-w-0"},fA={class:"space-y-3"},pA={key:0,class:"rounded-md bg-muted/40 px-3 py-6 text-center text-sm text-muted-foreground"},mA={class:"space-y-1.5"},hA={class:"text-xs font-medium text-muted-foreground"},vA={key:0,class:"text-xs text-muted-foreground"},gA={class:"font-medium text-foreground"},yA={key:1,class:"text-xs text-amber-600 dark:text-amber-500"},bA={class:"space-y-1.5"},_A={class:"text-xs font-medium text-muted-foreground"},wA={class:"text-xs text-muted-foreground"},xA={class:"flex justify-end gap-2"},kA=Q({__name:"AddSourceDialog",props:bs({modelName:{},providers:{},enabledFormats:{},chainByFormat:{}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:bs(["added"],["update:open"]),setup(e,{emit:t}){const{t:n}=Wt(),s=e,o=br(e,"open"),r=t,l=encodeURIComponent,i=L(""),u=L(""),c=L(!1);function d(v,$){return $==="responses"?!!v.supportsResponses:v.formats.includes($)}function f(v){const $=s.providers.find(T=>T.id===v);return $?s.enabledFormats.filter(T=>d($,T)):[]}function p(v){return s.enabledFormats.filter($=>(s.chainByFormat[$]??[]).includes(v))}const m=Y(()=>s.providers.filter(v=>s.enabledFormats.some($=>d(v,$))).sort((v,$)=>v.name.localeCompare($.name))),b=Y(()=>{var v;return((v=s.providers.find($=>$.id===i.value))==null?void 0:v.discoveredModels)??[]}),C={openai:"models.fmtOpenaiShort",anthropic:"models.fmtAnthropicShort",responses:"models.fmtResponsesShort"},E=Y(()=>i.value?f(i.value).map(v=>n(C[v]??v)):[]),y=Y(()=>!!i.value&&p(i.value).length>0),k=Y(()=>!!i.value&&!c.value);Fe(o,v=>{var $;v&&(i.value=(($=m.value[0])==null?void 0:$.id)??"",u.value="")});async function I(){if(!k.value)return;const v=i.value;if(!v)return;const $=f(v),T=u.value.trim();c.value=!0;try{(await Promise.allSettled($.map(V=>He("POST",`/admin/models/${l(s.modelName)}/providers`,{format:V,providerId:v,model:T||void 0})))).filter(V=>V.status==="rejected").length?Me(n("models.addSourcePartial"),"error"):Me(n("models.sourceAdded"),"success"),r("added"),o.value=!1}catch(A){Me(A.message,"error")}finally{c.value=!1}}return(v,$)=>(_(),N(a(Xa),{open:o.value,"onUpdate:open":$[3]||($[3]=T=>o.value=T)},{default:g(()=>[h(a(Ja),{class:"max-w-md"},{default:g(()=>[x("div",uA,[x("span",cA,[h(a(ts),{class:"h-4 w-4"})]),x("div",dA,[h(a(Qa),{class:"text-base"},{default:g(()=>[z(S(a(n)("models.addSourceTitle")),1)]),_:1}),h(a(Za),null,{default:g(()=>[z(S(a(n)("models.addSourceDesc")),1)]),_:1})])]),x("div",fA,[m.value.length?(_(),K(Ce,{key:1},[x("div",mA,[x("label",hA,S(a(n)("models.providerLabel")),1),h(a(zo),{modelValue:i.value,"onUpdate:modelValue":$[0]||($[0]=T=>i.value=T)},{default:g(()=>[h(a(Go),null,{default:g(()=>[h(a(Yo),{placeholder:a(n)("models.providerPh")},null,8,["placeholder"])]),_:1}),h(a(Xo),null,{default:g(()=>[(_(!0),K(Ce,null,st(m.value,T=>(_(),N(a(fn),{key:T.id,value:T.id},{default:g(()=>[z(S(T.name),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"]),E.value.length?(_(),K("p",vA,[z(S(a(n)("models.addSourceTargetsHint"))+" ",1),x("span",gA,S(E.value.join(" / ")),1)])):me("",!0),y.value?(_(),K("p",yA,S(a(n)("models.addSourceDupHint")),1)):me("",!0)]),x("div",bA,[x("label",_A,S(a(n)("models.upstreamLabel")),1),h(iA,{modelValue:u.value,"onUpdate:modelValue":$[1]||($[1]=T=>u.value=T),options:b.value,placeholder:a(n)("models.upstreamPh")},null,8,["modelValue","options","placeholder"]),x("p",wA,S(a(n)("models.upstreamHint")),1)])],64)):(_(),K("div",pA,S(a(n)("models.addSourceNone")),1)),x("div",xA,[h(a(Ie),{variant:"outline",disabled:c.value,onClick:$[2]||($[2]=T=>o.value=!1)},{default:g(()=>[z(S(a(n)("common.cancel")),1)]),_:1},8,["disabled"]),h(a(Ie),{disabled:!k.value||!m.value.length,onClick:I},{default:g(()=>[c.value?(_(),N(a(St),{key:0,class:"h-4 w-4 animate-spin"})):(_(),N(a(ts),{key:1,class:"h-4 w-4"})),z(" "+S(a(n)("models.addToChain")),1)]),_:1},8,["disabled"])])])]),_:1})]),_:1},8,["open"]))}}),CA={class:"space-y-4"},SA={class:"flex h-11 w-11 items-center justify-center rounded-xl bg-primary/15 text-primary"},AA={class:"space-y-1"},EA={class:"font-medium"},OA={class:"max-w-sm text-sm text-muted-foreground"},TA={class:"flex flex-wrap items-center gap-2"},PA={class:"relative min-w-[180px] flex-1"},$A={class:"text-xs text-muted-foreground"},IA={key:0,class:"py-6 text-center text-sm text-muted-foreground"},MA={key:1,class:"py-6 text-center text-sm text-destructive"},RA={key:0,class:"relative overflow-hidden rounded-lg border border-border/60 bg-card"},LA={class:"flex items-center gap-2.5 border-b border-border/60 bg-muted/30 px-3 py-2"},DA={class:"text-sm font-semibold"},NA={class:"ml-auto inline-flex items-center rounded-md bg-primary/15 px-1.5 py-0.5 text-xs font-medium tabular-nums text-primary"},FA={class:"divide-y divide-border"},qA={class:"flex items-center gap-3"},BA=["aria-expanded","aria-label","onClick","onKeydown"],VA={class:"flex min-w-0 flex-1 flex-col items-start"},UA={class:"flex w-full items-center gap-1.5"},HA={class:"truncate font-mono text-sm font-medium"},jA=["title","aria-label","onClick"],WA={class:"w-full truncate text-xs text-muted-foreground"},KA={class:"flex shrink-0 items-center gap-1.5"},zA=["disabled","title","aria-label","onClick"],GA={key:0,class:"mt-2 space-y-3 rounded-md border bg-muted/30 p-2"},YA={class:"flex items-center gap-2 px-1"},XA={class:"text-xs font-semibold"},JA={class:"font-mono text-[11px] text-muted-foreground"},QA={key:0,class:"flex items-start gap-2 rounded bg-muted px-2 py-1.5 text-xs text-muted-foreground"},ZA={class:"shrink-0 font-medium"},eE={key:1,class:"px-1 py-1 text-xs text-muted-foreground"},tE={class:"w-4 shrink-0 text-right text-xs text-muted-foreground"},nE={class:"flex items-center gap-1.5 text-sm"},sE={key:2,class:"flex items-center gap-1"},oE=["value","placeholder","aria-label","title","onKeyup","onBlur"],rE=["title","onClick"],aE={key:7,class:"flex items-center gap-1"},lE=["value","placeholder","aria-label","title","onInput","onKeyup","onBlur"],iE=["title","onClick"],uE={class:"ml-auto flex items-center gap-0.5 opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100"},cE={key:0,class:"flex justify-center pt-1"},dE={class:"relative overflow-hidden rounded-lg border border-border/60 bg-card"},fE={class:"flex items-center gap-2.5 border-b border-border/60 bg-muted/30 px-3 py-2"},pE={class:"text-sm font-semibold"},mE={class:"ml-auto inline-flex items-center rounded-md bg-muted px-1.5 py-0.5 text-xs font-medium tabular-nums text-muted-foreground"},hE={key:0},vE={key:0,class:"py-3 text-center text-xs text-muted-foreground"},gE={key:1,class:"divide-y divide-border"},yE=["aria-expanded","aria-label","onClick"],bE={class:"text-sm font-medium"},_E={class:"inline-flex items-center rounded-md bg-muted px-1.5 py-0.5 text-xs font-medium tabular-nums text-muted-foreground"},wE={key:0,class:"divide-y divide-border/50 bg-muted/10"},xE={class:"flex min-w-0 items-center gap-1.5"},kE={class:"truncate font-mono text-sm"},CE=["title","aria-label","onClick"],SE={class:"flex shrink-0 items-center gap-1.5"},AE=["disabled","title","aria-label","onClick"],EE=8,OE=Q({__name:"Models",setup(e){const{t}=Wt(),n=["openai","anthropic","responses"],s=L([]),o=L([]),r=L(""),l=L(!1),i=L(""),u=L(!0),c=L(new Set),d=L(!1),f=L(!1),p=L(!1),m=L(!1),b=L({}),C=L({}),E=L({}),y=L({}),k=L({}),I=L({}),v=L({}),$=L({}),T=L(""),A=L(null),R=L(!1),V={mounted:B=>B.focus()},J=L(null),fe=L(!1),X=encodeURIComponent;async function ce(){l.value=!0,r.value="";try{const[B,F]=await Promise.all([He("GET","/admin/models"),He("GET","/admin/providers")]);s.value=B.models,o.value=F.providers}catch(B){r.value=B.message}finally{l.value=!1}}const be=Y(()=>new Map(o.value.map(B=>[B.id,B]))),Z=Y(()=>{const B=new Map;for(const F of o.value)for(const te of F.discoveredModels??[]){const D=B.get(te);D?D.push(F.id):B.set(te,[F.id])}return B}),ue=Y(()=>{const B=new Set;for(const te of o.value)for(const D of te.discoveredModels??[])B.add(D);for(const te of s.value)B.add(te.name);const F=te=>({enabled:(te==null?void 0:te.enabled)??!1,chain:((te==null?void 0:te.providers)??[]).map(D=>({id:D.id,name:D.name,model:D.model}))});return[...B].map(te=>{const D=s.value.find(Se=>Se.name===te),_e=(Z.value.get(te)??[]).map(Se=>be.value.get(Se)).filter(Se=>!!Se).map(Se=>({id:Se.id,name:Se.name,formats:Se.formats,supportsResponses:Se.supportsResponses}));return{name:te,openai:F(D==null?void 0:D.openai),anthropic:F(D==null?void 0:D.anthropic),responses:F(D==null?void 0:D.responses),offering:_e}})});function de(B){return n.filter(F=>B[F].enabled)}function se(B){return n.filter(F=>B.offering.some(te=>oe(te,F)))}function re(B){return se(B).filter(F=>!B[F].enabled)}function q(B,F){return B[F].enabled?"enabled":se(B).includes(F)?"enableable":"unsupported"}function pe(B,F){return B.offering.filter(te=>oe(te,F)).map(te=>te.id)}const ee=Y(()=>{const B=i.value.trim().toLowerCase();return ue.value.filter(F=>!B||F.name.toLowerCase().includes(B))}),Ze=Y(()=>ee.value.filter(B=>B.openai.enabled||B.anthropic.enabled||B.responses.enabled)),Ve=Y(()=>ee.value.filter(B=>!(B.openai.enabled||B.anthropic.enabled||B.responses.enabled)&&se(B).length>0)),$e=["embed","whisper","tts","dall-e","dall_e","image","moderation","audio","transcribe","rerank","realtime","sora"];function Be(B){const F=B.toLowerCase();return $e.some(te=>F.includes(te))}const Ue=L(!0),rt=Y(()=>Ve.value.filter(B=>Be(B.name)).length),Re=Y(()=>Ue.value?Ve.value.filter(B=>!Be(B.name)):Ve.value),ut=Y(()=>{const B=[];for(const F of o.value){const te=Re.value.filter(D=>D.offering.some(_e=>_e.id===F.id)).sort((D,_e)=>D.name.localeCompare(_e.name));te.length&&B.push({source:F,rows:te})}return B}),ge=L({});function w(B,F){return i.value.trim()?!0:B in ge.value?ge.value[B]:F<=EE}function M(B,F){i.value.trim()||(ge.value={...ge.value,[B]:!w(B,F)})}function W(B){const F=de(B);return o.value.filter(te=>F.some(D=>oe(te,D)))}function le(B){const F={};for(const te of n)F[te]=B[te].chain.map(D=>D.id);return F}function oe(B,F){return F==="responses"?!!B.supportsResponses:B.formats.includes(F)}const ne={openai:{key:"models.fmtOpenai",chip:"models.fmtOpenaiShort",endpoint:"/chat/completions"},anthropic:{key:"models.fmtAnthropic",chip:"models.fmtAnthropicShort",endpoint:"/messages"},responses:{key:"models.fmtResponses",chip:"models.fmtResponsesShort",endpoint:"/responses"}};function O(B){return c.value.has(B)}function P(B){const F=new Set(c.value);F.has(B)?F.delete(B):F.add(B),c.value=F}async function U(B){const F=await Yi(B);Me(t(F?"connect.copied":"connect.copyFailed"),F?"success":"error")}function j(B,F){B.target===B.currentTarget&&(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),P(F))}function he(B){return B.length?B.map(F=>F.name).join(" → "):t("models.noSourcesShort")}function ae(B){return de(B).map(F=>`${t(ne[F].chip)}: ${he(B[F].chain)}`).join(" · ")}function H(B,F){const te=B[F].chain;if(!te.length)return!1;const D=_e=>{var Se;return((Se=be.value.get(_e))==null?void 0:Se.discoveredModels)??[]};return!te.some(_e=>D(_e.id).includes(_e.model??B.name))&&te.some(_e=>D(_e.id).length>0)}function G(B){return de(B).some(F=>H(B,F))}function ve(B){let F=!1,te=null,D=null;for(const _e of de(B)){const Se=`${B.name}:${_e}`;y.value[Se]&&(F=!0);const at=v.value[Se];at!=null&&at.ok&&!te?te=at:at&&!at.ok&&!D&&(D=at)}return F?{state:"testing"}:te?{state:"ok",provider:te.provider}:D?{state:"fail",status:D.status,error:D.error}:null}function Ee(B,F){const te=q(B,F);return te==="enabled"?`border-transparent ${tn[F].solid} text-white shadow-sm`:te==="enableable"?"border-dashed border-input text-muted-foreground hover:bg-accent hover:text-accent-foreground":"border-transparent text-muted-foreground/40"}function Le(B,F){const te=q(B,F);return te==="enabled"?`${t(ne[F].key)} · ${t("models.chipOn")}`:te==="enableable"?`${t(ne[F].key)} · ${t("models.chipOff")}`:`${t(ne[F].key)} · ${t("models.chipNa")}`}async function Je(B,F){B[F].enabled?await Zt(B,F):await We(B,F)}async function We(B,F){const te=`${B.name}:${F}`;C.value[te]=!0;const D=B.offering.filter(at=>oe(at,F)),_e=D.map(at=>({id:at.id,name:at.name})),Se=s.value.find(at=>at.name===B.name);if(Se){Se[F].enabled=!0;for(const at of _e)Se[F].providers.find(Is=>Is.id===at.id)||Se[F].providers.push(at)}else s.value.push({name:B.name,openai:{enabled:F==="openai",providers:F==="openai"?_e:[]},anthropic:{enabled:F==="anthropic",providers:F==="anthropic"?_e:[]},responses:{enabled:F==="responses",providers:F==="responses"?_e:[]}});try{await He("POST","/admin/models",{name:B.name,format:F,providers:D.map(at=>at.id)}),Me(t("models.enabledToast",{name:`${B.name} [${F}]`}),"success")}catch(at){await ce(),Me(at.message,"error")}finally{C.value[te]=!1}}async function Kt(){if(f.value)return;f.value=!0;const B=[];for(const D of Re.value)for(const _e of re(D))B.push({name:D.name,fmt:_e,providers:pe(D,_e)});for(const D of B)C.value[`${D.name}:${D.fmt}`]=!0;const F=await Promise.allSettled(B.map(D=>He("POST","/admin/models",{name:D.name,format:D.fmt,providers:D.providers})));for(const D of B)C.value[`${D.name}:${D.fmt}`]=!1;if(await ce(),f.value=!1,!B.length)return;const te=F.filter(D=>D.status==="rejected").length;te?te===B.length?Me(t("models.enableAllFailed"),"error"):Me(t("models.enableAllPartial",{failed:te}),"error"):Me(t("models.enableAllDone"),"success")}async function Zt(B,F){const te=s.value.find(D=>D.name===B.name);te&&(te[F].enabled=!1);try{await He("POST",`/admin/models/${X(B.name)}/disable`,{format:F}),Me(t("models.disabledToast",{name:`${B.name} [${F}]`}),"success")}catch(D){await ce(),Me(D.message,"error")}}function Ps(B){J.value=B,fe.value=!0}async function Sr(B,F){const te=`${B.name}:${F}`;if(!y.value[te]){y.value[te]=!0;try{const D=await He("POST",`/admin/models/${X(B.name)}/test?format=${F}`);v.value[te]=D.result}catch(D){v.value[te]={ok:!1,status:0,format:F,error:D.message}}finally{y.value[te]=!1}}}async function qt(B){const F=de(B);F.length&&await Promise.all(F.map(te=>Sr(B,te)))}async function rn(B,F,te){const D=`${B.name}:${F}:${te}`;if(!k.value[D]){k.value[D]=!0;try{const _e=await He("POST",`/admin/models/${X(B.name)}/providers/test?format=${F}&index=${te}`);I.value[D]=_e.result}catch(_e){I.value[D]={ok:!1,status:0,format:F,error:_e.message}}finally{k.value[D]=!1}}}async function Ar(){const B=J.value;if(B){b.value[B.name]=!0;try{await He("DELETE",`/admin/models/${X(B.name)}`),s.value=s.value.filter(F=>F.name!==B.name),Me(t("models.removedToast",{name:B.name}),"success"),fe.value=!1}catch(F){Me(F.message,"error")}finally{b.value[B.name]=!1}}}async function Ao(B,F,te){const D=s.value.find(Se=>Se.name===B.name);if(!D)return;const _e=D[te].providers.slice();D[te].providers=F.map(Se=>_e[Se]);try{await He("PUT",`/admin/models/${X(B.name)}/priority`,{format:te,order:F})}catch(Se){D[te].providers=_e,Me(Se.message,"error")}}function Lm(B,F,te){if(F===0)return;const D=B[te].chain.map((_e,Se)=>Se);[D[F-1],D[F]]=[D[F],D[F-1]],Ao(B,D,te)}function Dm(B,F,te){if(F>=B[te].chain.length-1)return;const D=B[te].chain.map((_e,Se)=>Se);[D[F+1],D[F]]=[D[F],D[F+1]],Ao(B,D,te)}function Nm(B){A.value=B,R.value=!0}function Qs(B,F,te){return`${B.name}:${F}:${te}`}function Fm(B,F,te){return T.value===Qs(B,F,te)}function yu(B,F,te,D){const _e=Qs(B,F,D);$.value[_e]=te.model??"",T.value=_e}function qm(B,F,te){return $.value[Qs(B,F,te)]??""}function Bm(B,F,te,D){$.value[Qs(B,F,te)]=D}async function Vm(B,F,te,D){const _e=Qs(B,F,D);T.value="";const Se=($.value[_e]??"").trim(),at=(te.model??"").trim();if(Se===at)return;const Is=s.value.find(Zs=>Zs.name===B.name);Is&&(Is[F].providers[D].model=Se||void 0),$.value[_e]=Se;try{await He("PUT",`/admin/models/${X(B.name)}/map`,{format:F,index:D,model:Se}),Me(t("models.mapSaved"),"success")}catch(Zs){await ce(),Me(Zs.message,"error")}}function Um(B,F,te,D,_e){$.value[Qs(B,F,D)]=te.model??"",_e.blur()}const el=L(""),Eo=L("");function $s(B){var F;return((F=be.value.get(B))==null?void 0:F.rpm)??0}function Hm(B){return el.value===B.id}function bu(B){el.value=B.id,Eo.value=$s(B.id)?String($s(B.id)):""}function jm(B){Eo.value=B}async function Wm(B,F){const te=be.value.get(B);te&&await He("PUT",`/admin/providers/${B}`,{name:te.name,baseUrlOpenai:te.baseUrlOpenai,baseUrlAnthropic:te.baseUrlAnthropic,formats:te.formats,supportsResponses:te.supportsResponses??!1,rpm:F})}async function Km(B){const F=B.id;el.value="";const te=Number(Eo.value),D=Number.isFinite(te)&&te>0?Math.floor(te):0;if(D!==$s(F))try{await Wm(F,D),o.value=o.value.map(_e=>_e.id===F?{..._e,rpm:D}:_e),Me(D?t("sources.rpmSaved",{n:D}):t("sources.rpmCleared"),D?"success":"default")}catch(_e){Me(_e.message,"error")}}function zm(B,F){Eo.value=$s(B.id)?String($s(B.id)):"",F.blur()}async function Gm(B,F,te){const D=`${B.name}:${F}:${te}`;if(E.value[D])return;E.value[D]=!0;const _e=s.value.find(Se=>Se.name===B.name);_e&&_e[F].providers.splice(te,1);try{await He("DELETE",`/admin/models/${X(B.name)}/providers?format=${F}&index=${te}`),Me(t("models.sourceRemoved"),"success")}catch(Se){await ce(),Me(Se.message,"error")}finally{E.value[D]=!1}}async function Ym(){if(d.value||!o.value.length)return;d.value=!0;const B=o.value,F=await Promise.allSettled(B.map(D=>He("POST",`/admin/providers/${D.id}/discover`)));await ce();const te=F.map((D,_e)=>D.status==="rejected"?B[_e].name:null).filter(D=>!!D);te.length?te.length===B.length?Me(t("sources.refreshAllFailed"),"error"):Me(t("sources.refreshAllPartial",{failed:te.join("、")}),"error"):Me(t("sources.refreshAllDone"),"success"),d.value=!1}return pt(ce),(B,F)=>{var te;return _(),K("div",CA,[!l.value&&!o.value.length?(_(),N(a(mn),{key:0},{default:g(()=>[h(a(hn),{class:"flex flex-col items-center gap-3 py-12 text-center"},{default:g(()=>[x("span",SA,[h(a(yi),{class:"h-5 w-5"})]),x("div",AA,[x("div",EA,S(a(t)("models.empty")),1),x("p",OA,S(a(t)("models.emptyHint")),1)]),h(a(Ie),{onClick:F[0]||(F[0]=D=>p.value=!0)},{default:g(()=>[h(a(ts),{class:"h-4 w-4"}),z(S(a(t)("models.addSource")),1)]),_:1})]),_:1})]),_:1})):(_(),N(a(mn),{key:1},{default:g(()=>[h(a(Mn),null,{default:g(()=>[h(a(Rn),{class:"flex items-center gap-2 text-base"},{default:g(()=>[h(a(Am),{class:"h-4 w-4 text-primary"}),z(" "+S(a(t)("models.title")),1)]),_:1}),h(a(ys),null,{default:g(()=>[z(S(a(t)("models.desc")),1)]),_:1})]),_:1}),h(a(hn),{class:"space-y-4"},{default:g(()=>[x("div",TA,[x("div",PA,[h(a($m),{class:"absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),h(a(vt),{modelValue:i.value,"onUpdate:modelValue":F[1]||(F[1]=D=>i.value=D),placeholder:a(t)("models.searchPh"),class:"pl-8"},null,8,["modelValue","placeholder"])]),h(a(Ie),{size:"sm",onClick:F[2]||(F[2]=D=>m.value=!0)},{default:g(()=>[h(a(ts),{class:"h-4 w-4"}),z(S(a(t)("models.addModels")),1)]),_:1}),h(a(Ie),{variant:"outline",size:"sm",onClick:F[3]||(F[3]=D=>p.value=!0)},{default:g(()=>[h(a(yi),{class:"h-4 w-4"}),z(S(a(t)("models.manageSources")),1)]),_:1})]),x("p",$A,S(a(t)("models.chipLegend")),1),l.value?(_(),K("p",IA,S(a(t)("common.loading")),1)):r.value?(_(),K("p",MA,S(r.value),1)):(_(),K(Ce,{key:2},[Ze.value.length?(_(),K("section",RA,[F[16]||(F[16]=x("div",{class:"pointer-events-none absolute inset-y-0 left-0 w-1 bg-primary","aria-hidden":"true"},null,-1)),x("div",LA,[F[13]||(F[13]=x("span",{class:"h-2 w-2 shrink-0 rounded-full bg-primary"},null,-1)),x("span",DA,S(a(t)("models.enabledSection")),1),x("span",NA,S(Ze.value.length),1)]),x("div",FA,[(_(!0),K(Ce,null,st(Ze.value,D=>{var _e,Se,at,Is,Zs;return _(),K("div",{key:D.name,class:"px-3 py-2.5"},[x("div",qA,[x("div",{role:"button",tabindex:"0",class:"flex min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-md text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background","aria-expanded":O(D.name),"aria-label":O(D.name)?a(t)("models.collapseAria"):a(t)("models.expandAria"),onClick:Oe=>P(D.name),onKeydown:Oe=>j(Oe,D.name)},[h(a(vi),{class:ke(["h-4 w-4 shrink-0 text-muted-foreground transition-transform",{"rotate-90":O(D.name)}])},null,8,["class"]),x("span",VA,[x("span",UA,[x("span",HA,S(D.name),1),x("button",{type:"button",title:a(t)("connect.copy"),"aria-label":a(t)("connect.copy"),class:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground/50 transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:Gt(Oe=>U(D.name),["stop"])},[h(a(Jn),{class:"h-3 w-3"})],8,jA),((_e=ve(D))==null?void 0:_e.state)==="testing"?(_(),N(a(_t),{key:0,variant:"muted",class:"gap-1"},{default:g(()=>[h(a(St),{class:"h-3 w-3 animate-spin"}),z(S(a(t)("models.probeTesting")),1)]),_:1})):((Se=ve(D))==null?void 0:Se.state)==="ok"?(_(),N(a(_t),{key:1,variant:"success",title:a(t)("models.probeOkHint",{name:((at=ve(D))==null?void 0:at.provider)??""})},{default:g(()=>[z(S(a(t)("models.probeOk")),1)]),_:1},8,["title"])):((Is=ve(D))==null?void 0:Is.state)==="fail"?(_(),N(a(_t),{key:2,variant:"destructive",title:((Zs=ve(D))==null?void 0:Zs.error)||a(t)("models.probeFailHint")},{default:g(()=>{var Oe;return[z(S(a(t)("models.probeFail"))+" · "+S(((Oe=ve(D))==null?void 0:Oe.status)||"?"),1)]}),_:2},1032,["title"])):G(D)?(_(),N(a(_t),{key:3,variant:"secondary",title:a(t)("models.delistedHint")},{default:g(()=>[z(S(a(t)("models.delisted")),1)]),_:1},8,["title"])):me("",!0)]),x("span",WA,S(ae(D)),1)])],40,BA),x("div",KA,[(_(),K(Ce,null,st(n,Oe=>x("button",{key:Oe,type:"button",disabled:q(D,Oe)==="unsupported"||C.value[`${D.name}:${Oe}`],title:Le(D,Oe),"aria-label":Le(D,Oe),class:ke(["inline-flex items-center gap-1 rounded-md border px-2 py-0.5 text-xs font-medium transition-colors disabled:cursor-not-allowed",Ee(D,Oe)]),onClick:ht=>Je(D,Oe)},[C.value[`${D.name}:${Oe}`]?(_(),N(a(St),{key:0,class:"h-3 w-3 animate-spin"})):(_(),K("span",{key:1,class:ke(["rounded-full",q(D,Oe)==="enabled"?"h-1.5 w-1.5 bg-current":q(D,Oe)==="enableable"?"h-1.5 w-1.5 border border-current":"h-1.5 w-1.5"])},null,2)),z(" "+S(a(t)(ne[Oe].chip)),1)],10,zA)),64))]),h(a(fi),null,{default:g(()=>[h(a(pi),null,{default:g(()=>[h(a(Ie),{variant:"ghost",size:"icon",class:"h-8 w-8 shrink-0 text-muted-foreground","aria-label":a(t)("models.moreActions")},{default:g(()=>[h(a(gi),{class:"h-4 w-4"})]),_:1},8,["aria-label"])]),_:1}),h(a(mi),{align:"end"},{default:g(()=>{var Oe;return[h(a(Wn),{disabled:((Oe=ve(D))==null?void 0:Oe.state)==="testing"||!de(D).length,onSelect:ht=>qt(D)},{default:g(()=>{var ht;return[((ht=ve(D))==null?void 0:ht.state)==="testing"?(_(),N(a(St),{key:0,class:"animate-spin"})):(_(),N(a(El),{key:1})),z(" "+S(a(t)("models.testModel")),1)]}),_:2},1032,["disabled","onSelect"]),h(a(hi)),h(a(Wn),{class:"text-destructive focus:bg-destructive/10 focus:text-destructive",onSelect:ht=>Ps(D)},{default:g(()=>[h(a(bi)),z(" "+S(a(t)("models.removeModel")),1)]),_:1},8,["onSelect"])]}),_:2},1024)]),_:2},1024)]),O(D.name)?(_(),K("div",GA,[(_(!0),K(Ce,null,st(de(D),Oe=>(_(),K("div",{key:Oe,class:"space-y-1"},[x("div",YA,[x("span",{class:ke(["h-2 w-2 rounded-full",a(tn)[Oe].solid])},null,2),x("span",XA,S(a(t)(ne[Oe].key)),1),x("span",JA,S(ne[Oe].endpoint),1)]),H(D,Oe)?(_(),K("div",QA,[x("span",ZA,S(a(t)("models.delisted")),1),x("span",null,S(a(t)("models.delistedHint")),1)])):me("",!0),D[Oe].chain.length?me("",!0):(_(),K("div",eE,S(a(t)("models.noSources")),1)),(_(!0),K(Ce,null,st(D[Oe].chain,(ht,mt)=>{var _u,wu;return _(),K("div",{key:mt,class:"group flex items-center gap-2 rounded px-1 py-1 hover:bg-muted/40"},[x("span",tE,S(mt+1)+".",1),x("span",nE,[x("span",{class:ke(["h-1.5 w-1.5 rounded-full",a(ei)(ht.id).solid])},null,2),z(" "+S(ht.name),1)]),mt===0?(_(),N(a(_t),{key:0,variant:"default"},{default:g(()=>[z(S(a(t)("models.primary")),1)]),_:1})):(_(),N(a(_t),{key:1,variant:"muted"},{default:g(()=>[z(S(a(t)("models.fallback")),1)]),_:1})),Hm(ht)?(_(),K("span",sE,[h(a(Ko),{class:"h-3 w-3 text-muted-foreground"}),yo(x("input",{type:"number",min:"0",inputmode:"numeric",value:Eo.value,placeholder:a(t)("sources.rpmPh"),"aria-label":a(t)("sources.rpmLabel"),title:a(t)("sources.rpmHint"),class:"h-6 w-16 rounded-md border border-input bg-background px-2 font-mono text-xs shadow-sm transition-colors placeholder:font-sans placeholder:text-muted-foreground/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",onInput:F[4]||(F[4]=ct=>jm(ct.target.value)),onKeyup:[F[5]||(F[5]=Vs(ct=>ct.target.blur(),["enter"])),Vs(ct=>zm(ht,ct.target),["esc"])],onBlur:ct=>Km(ht)},null,40,oE),[[V]])])):$s(ht.id)>0?(_(),K("button",{key:3,type:"button",title:a(t)("sources.rpmBadgeHint"),class:"inline-flex items-center gap-1 rounded-full border border-input bg-background px-2 py-0.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:ct=>bu(ht)},[h(a(Ko),{class:"h-3 w-3"}),z(" "+S(a(t)("sources.rpmBadge",{n:$s(ht.id)})),1)],8,rE)):me("",!0),k.value[`${D.name}:${Oe}:${mt}`]?(_(),N(a(_t),{key:4,variant:"muted",class:"gap-1"},{default:g(()=>[h(a(St),{class:"h-3 w-3 animate-spin"}),z(S(a(t)("models.probeTesting")),1)]),_:1})):(_u=I.value[`${D.name}:${Oe}:${mt}`])!=null&&_u.ok?(_(),N(a(_t),{key:5,variant:"success",title:a(t)("models.probeOkHint",{name:ht.name})},{default:g(()=>[z(S(a(t)("models.probeOk")),1)]),_:1},8,["title"])):I.value[`${D.name}:${Oe}:${mt}`]?(_(),N(a(_t),{key:6,variant:"destructive",title:((wu=I.value[`${D.name}:${Oe}:${mt}`])==null?void 0:wu.error)||a(t)("models.probeFailHint")},{default:g(()=>{var ct;return[z(S(a(t)("models.probeFail"))+" · "+S(((ct=I.value[`${D.name}:${Oe}:${mt}`])==null?void 0:ct.status)||"?"),1)]}),_:2},1032,["title"])):me("",!0),Fm(D,Oe,mt)?(_(),K("div",aE,[F[14]||(F[14]=x("span",{class:"text-xs text-muted-foreground"},"→",-1)),yo(x("input",{type:"text",value:qm(D,Oe,mt),placeholder:a(t)("models.upstreamPh"),"aria-label":a(t)("models.upstreamLabel"),title:a(t)("models.upstreamHint"),spellcheck:"false",class:"h-6 w-40 rounded-md border border-input bg-background px-2 font-mono text-xs shadow-sm transition-colors placeholder:font-sans placeholder:text-muted-foreground/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",onInput:ct=>Bm(D,Oe,mt,ct.target.value),onKeyup:[F[6]||(F[6]=Vs(ct=>ct.target.blur(),["enter"])),Vs(ct=>Um(D,Oe,ht,mt,ct.target),["esc"])],onBlur:ct=>Vm(D,Oe,ht,mt)},null,40,lE),[[V]])])):ht.model?(_(),K("button",{key:8,type:"button",title:a(t)("models.upstreamHint"),class:"inline-flex items-center gap-1 rounded border border-transparent px-1.5 py-0.5 font-mono text-xs text-muted-foreground transition-colors hover:border-border hover:bg-background hover:text-foreground",onClick:ct=>yu(D,Oe,ht,mt)},[F[15]||(F[15]=x("span",null,"→",-1)),z(S(ht.model),1)],8,iE)):me("",!0),x("div",uE,[h(a(Ie),{variant:"ghost",size:"icon",class:"h-7 w-7",disabled:mt===0,"aria-label":a(t)("models.moveUpAria"),onClick:ct=>Lm(D,mt,Oe)},{default:g(()=>[h(a(Xk),{class:"h-4 w-4"})]),_:1},8,["disabled","aria-label","onClick"]),h(a(Ie),{variant:"ghost",size:"icon",class:"h-7 w-7",disabled:mt===D[Oe].chain.length-1,"aria-label":a(t)("models.moveDownAria"),onClick:ct=>Dm(D,mt,Oe)},{default:g(()=>[h(a(Yk),{class:"h-4 w-4"})]),_:1},8,["disabled","aria-label","onClick"]),h(a(fi),null,{default:g(()=>[h(a(pi),null,{default:g(()=>[h(a(Ie),{variant:"ghost",size:"icon",class:"h-7 w-7 text-muted-foreground","aria-label":a(t)("models.moreActions")},{default:g(()=>[h(a(gi),{class:"h-4 w-4"})]),_:1},8,["aria-label"])]),_:1}),h(a(mi),{align:"end"},{default:g(()=>[h(a(Wn),{disabled:k.value[`${D.name}:${Oe}:${mt}`],onSelect:ct=>rn(D,Oe,mt)},{default:g(()=>[k.value[`${D.name}:${Oe}:${mt}`]?(_(),N(a(St),{key:0,class:"animate-spin"})):(_(),N(a(El),{key:1})),z(" "+S(a(t)("models.testSource")),1)]),_:2},1032,["disabled","onSelect"]),h(a(Wn),{onSelect:ct=>yu(D,Oe,ht,mt)},{default:g(()=>[h(a(Tm),{class:"h-4 w-4"}),z(" "+S(a(t)("models.editUpstream")),1)]),_:1},8,["onSelect"]),h(a(Wn),{onSelect:ct=>bu(ht)},{default:g(()=>[h(a(Ko),{class:"h-4 w-4"}),z(" "+S(a(t)("sources.rpmLabel")),1)]),_:1},8,["onSelect"]),h(a(hi)),h(a(Wn),{class:"text-destructive focus:bg-destructive/10 focus:text-destructive",onSelect:ct=>Gm(D,Oe,mt)},{default:g(()=>[h(a(bi),{class:"h-4 w-4"}),z(" "+S(a(t)("models.removeSource")),1)]),_:1},8,["onSelect"])]),_:2},1024)]),_:2},1024)])])}),128))]))),128)),W(D).length?(_(),K("div",cE,[h(a(Ie),{variant:"outline",size:"sm",class:"h-7 gap-1 border-dashed text-muted-foreground",onClick:Oe=>Nm(D)},{default:g(()=>[h(a(ts),{class:"h-3.5 w-3.5"}),z(" "+S(a(t)("models.addSourceToChain")),1)]),_:1},8,["onClick"])])):me("",!0)])):me("",!0)])}),128))])])):me("",!0),x("section",dE,[F[18]||(F[18]=x("div",{class:"pointer-events-none absolute inset-y-0 left-0 w-1 bg-muted-foreground/40","aria-hidden":"true"},null,-1)),x("div",fE,[x("button",{type:"button",class:"flex min-w-0 flex-1 items-center gap-2.5 rounded px-1 py-0.5 text-left hover:bg-muted/50",onClick:F[7]||(F[7]=D=>u.value=!u.value)},[h(a(Ya),{class:ke(["h-4 w-4 shrink-0 text-muted-foreground transition-transform",{"-rotate-90":!u.value}])},null,8,["class"]),F[17]||(F[17]=x("span",{class:"h-2 w-2 shrink-0 rounded-full bg-muted-foreground/40"},null,-1)),x("span",pE,S(a(t)("models.availableSection")),1),x("span",mE,S(Re.value.length),1)]),rt.value>0?(_(),N(a(Ie),{key:0,variant:"ghost",size:"sm",class:ke(["h-7 gap-1.5 px-2.5",Ue.value?"bg-accent text-accent-foreground":"text-muted-foreground"]),title:Ue.value?a(t)("models.filterChatHint",{n:rt.value}):a(t)("models.filterAllHint"),onClick:F[8]||(F[8]=D=>Ue.value=!Ue.value)},{default:g(()=>[h(a(Em),{class:"h-3.5 w-3.5"}),z(" "+S(Ue.value?a(t)("models.filterChatOnly"):a(t)("models.filterInclude")),1)]),_:1},8,["class","title"])):me("",!0),h(a(Ie),{variant:"ghost",size:"sm",class:"h-7 gap-1.5 px-2.5",disabled:d.value,title:a(t)("sources.refreshAll"),onClick:Ym},{default:g(()=>[d.value?(_(),N(a(St),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(_(),N(a(mr),{key:1,class:"h-3.5 w-3.5"})),z(" "+S(a(t)("sources.refreshAll")),1)]),_:1},8,["disabled","title"]),Re.value.length?(_(),N(a(Ie),{key:1,size:"sm",variant:"secondary",class:"h-7 gap-1.5 px-2.5",disabled:f.value,onClick:Kt},{default:g(()=>[f.value?(_(),N(a(St),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(_(),N(a(El),{key:1,class:"h-3.5 w-3.5"})),z(" "+S(a(t)("models.enableAll")),1)]),_:1},8,["disabled"])):me("",!0)]),u.value?(_(),K("div",hE,[Re.value.length?(_(),K("div",gE,[(_(!0),K(Ce,null,st(ut.value,D=>(_(),K("div",{key:D.source.id},[x("button",{type:"button",class:"flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-muted/40","aria-expanded":w(D.source.id,D.rows.length),"aria-label":D.source.name,onClick:_e=>M(D.source.id,D.rows.length)},[h(a(vi),{class:ke(["h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform",{"rotate-90":w(D.source.id,D.rows.length)}])},null,8,["class"]),x("span",{class:ke(["h-1.5 w-1.5 shrink-0 rounded-full",a(ei)(D.source.id).solid])},null,2),x("span",bE,S(D.source.name),1),x("span",_E,S(D.rows.length),1)],8,yE),w(D.source.id,D.rows.length)?(_(),K("div",wE,[(_(!0),K(Ce,null,st(D.rows,_e=>(_(),K("div",{key:_e.name,class:"flex items-center justify-between gap-2 px-3 py-2 pl-9"},[x("div",xE,[x("span",kE,S(_e.name),1),x("button",{type:"button",title:a(t)("connect.copy"),"aria-label":a(t)("connect.copy"),class:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground/50 transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:Se=>U(_e.name)},[h(a(Jn),{class:"h-3 w-3"})],8,CE)]),x("div",SE,[(_(),K(Ce,null,st(n,Se=>x("button",{key:Se,type:"button",disabled:q(_e,Se)==="unsupported"||C.value[`${_e.name}:${Se}`],title:Le(_e,Se),"aria-label":Le(_e,Se),class:ke(["inline-flex items-center gap-1 rounded-md border px-2 py-0.5 text-xs font-medium transition-colors disabled:cursor-not-allowed",Ee(_e,Se)]),onClick:at=>Je(_e,Se)},[C.value[`${_e.name}:${Se}`]?(_(),N(a(St),{key:0,class:"h-3 w-3 animate-spin"})):(_(),K("span",{key:1,class:ke(["rounded-full",q(_e,Se)==="enabled"?"h-1.5 w-1.5 bg-current":q(_e,Se)==="enableable"?"h-1.5 w-1.5 border border-current":"h-1.5 w-1.5"])},null,2)),z(" "+S(a(t)(ne[Se].chip)),1)],10,AE)),64))])]))),128))])):me("",!0)]))),128))])):(_(),K("p",vE,S(Ue.value&&Ve.value.length?a(t)("models.availableAllFiltered",{n:rt.value}):a(t)("models.availableDesc")),1))])):me("",!0)])],64))]),_:1})]),_:1})),h(pS,{open:p.value,"onUpdate:open":F[9]||(F[9]=D=>p.value=D),onChanged:ce},null,8,["open"]),h(nA,{open:m.value,"onUpdate:open":F[10]||(F[10]=D=>m.value=D),providers:o.value,onChanged:ce},null,8,["open","providers"]),h(kA,{open:R.value,"onUpdate:open":F[11]||(F[11]=D=>R.value=D),"model-name":((te=A.value)==null?void 0:te.name)??"",providers:o.value,"enabled-formats":A.value?de(A.value):[],"chain-by-format":A.value?le(A.value):{},onAdded:ce},null,8,["open","model-name","providers","enabled-formats","chain-by-format"]),h(gu,{open:fe.value,"onUpdate:open":F[12]||(F[12]=D=>fe.value=D),variant:"destructive",title:a(t)("models.removeModel"),description:J.value?a(t)("models.confirmRemove",{name:J.value.name}):"","confirm-text":a(t)("models.removeModel"),loading:J.value?!!b.value[J.value.name]:!1,onConfirm:Ar},null,8,["open","title","description","confirm-text","loading"])])}}}),TE={class:"relative w-full overflow-auto"},Im=Q({__name:"Table",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(_(),K("div",TE,[x("table",{class:ke(a(Xe)("w-full caption-bottom text-sm",t.class))},[ie(n.$slots,"default")],2)]))}}),Mm=Q({__name:"TableHeader",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(_(),K("thead",{class:ke(a(Xe)("[&_tr]:border-b",t.class))},[ie(n.$slots,"default")],2))}}),Rm=Q({__name:"TableBody",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(_(),K("tbody",{class:ke(a(Xe)("[&_tr:last-child]:border-0",t.class))},[ie(n.$slots,"default")],2))}}),uo=Q({__name:"TableRow",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(_(),K("tr",{class:ke(a(Xe)("border-b transition-colors hover:bg-muted/40 data-[state=selected]:bg-muted",t.class))},[ie(n.$slots,"default")],2))}}),zt=Q({__name:"TableHead",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(_(),K("th",{class:ke(a(Xe)("h-10 px-3 text-left align-middle text-xs font-medium uppercase tracking-wide text-muted-foreground [&:has([role=checkbox])]:pr-0",t.class))},[ie(n.$slots,"default")],2))}}),Lt=Q({__name:"TableCell",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(_(),K("td",{class:ke(a(Xe)("p-3 align-middle [&:has([role=checkbox])]:pr-0",t.class))},[ie(n.$slots,"default")],2))}}),PE=Q({__name:"Popover",props:{defaultOpen:{type:Boolean},open:{type:Boolean},modal:{type:Boolean}},emits:["update:open"],setup(e,{emit:t}){const o=Mt(e,t);return(r,l)=>(_(),N(a(mx),Tt($t(a(o))),{default:g(()=>[ie(r.$slots,"default")]),_:3},16))}}),$E=Q({__name:"PopoverTrigger",props:{asChild:{type:Boolean},as:{}},setup(e){const t=e;return(n,s)=>(_(),N(a(Sx),Tt($t(t)),{default:g(()=>[ie(n.$slots,"default")]),_:3},16))}}),IE=Q({__name:"PopoverContent",props:{forceMount:{type:Boolean},memoDependencies:{},side:{},sideOffset:{default:4},sideFlip:{type:Boolean},align:{},alignOffset:{},alignFlip:{type:Boolean},avoidCollisions:{type:Boolean},collisionBoundary:{},collisionPadding:{},arrowPadding:{},hideShiftedArrow:{type:Boolean},sticky:{},hideWhenDetached:{type:Boolean},positionStrategy:{},updatePositionStrategy:{},disableUpdateOnLayoutShift:{type:Boolean},prioritizePosition:{type:Boolean},reference:{},dir:{},asChild:{type:Boolean},as:{},disableOutsidePointerEvents:{type:Boolean},class:{type:[Boolean,null,String,Object,Array]}},emits:["escapeKeyDown","pointerDownOutside","focusOutside","interactOutside","openAutoFocus","closeAutoFocus"],setup(e,{emit:t}){const n=e,s=t,o=Y(()=>{const{class:l,...i}=n;return i}),r=Mt(o,s);return(l,i)=>(_(),N(a(kx),null,{default:g(()=>[h(a(wx),Te(a(r),{class:a(Xe)("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2",n.class)}),{default:g(()=>[ie(l.$slots,"default")]),_:3},16,["class"])]),_:3}))}}),ME={class:"flex items-center justify-between gap-2"},RE={class:"flex gap-1"},LE={class:"sr-only"},DE={class:"flex flex-wrap items-center gap-2"},NE={class:"relative flex-1 sm:max-w-sm"},FE={key:0,class:"inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[10px] font-medium text-primary-foreground"},qE={class:"space-y-2.5"},BE={class:"flex items-center justify-between"},VE={class:"text-xs font-medium"},UE={class:"space-y-2"},HE={class:"grid grid-cols-[3.5rem_1fr] items-center gap-2"},jE={class:"text-xs text-muted-foreground"},WE={class:"grid grid-cols-[3.5rem_1fr] items-center gap-2"},KE={class:"text-xs text-muted-foreground"},zE={class:"grid grid-cols-[3.5rem_1fr] items-center gap-2"},GE={class:"text-xs text-muted-foreground"},YE={key:0,class:"flex flex-wrap items-center gap-1.5"},XE={class:"text-muted-foreground"},JE={class:"font-medium"},QE=["aria-label","onClick"],ZE={class:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground"},eO={key:1,class:"space-y-2 rounded-lg border border-amber-500/30 bg-amber-500/5 p-3"},tO={class:"flex items-center gap-1.5 text-xs font-medium text-amber-700 dark:text-amber-400"},nO={class:"space-y-1.5"},sO={class:"font-medium"},oO={class:"break-all text-muted-foreground"},rO={key:2,class:"space-y-2 rounded-lg border border-orange-500/30 bg-orange-500/5 p-3"},aO={class:"flex items-center gap-1.5 text-xs font-medium text-orange-700 dark:text-orange-400"},lO={class:"space-y-1.5"},iO={class:"font-medium"},uO={class:"text-muted-foreground"},cO={key:3,class:"py-6 text-center text-sm text-muted-foreground"},dO={key:4,class:"py-6 text-center text-sm text-muted-foreground"},fO={key:5,class:"overflow-x-auto"},pO={class:"flex flex-wrap items-center gap-x-2 gap-y-1 text-xs"},mO={class:"font-mono text-muted-foreground"},hO={class:"font-medium"},vO={class:"text-muted-foreground"},gO={class:"text-muted-foreground"},yO={class:"break-all text-muted-foreground"},bO={key:0,class:"text-muted-foreground/60"},_O={class:"inline-flex items-center gap-1.5"},wO={class:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 px-2 py-2 text-xs sm:grid-cols-[auto_1fr_auto_1fr]"},xO={class:"text-muted-foreground"},kO={class:"font-mono"},CO={class:"text-muted-foreground"},SO={class:"font-mono"},AO={class:"text-muted-foreground"},EO={class:"text-muted-foreground"},OO={class:"break-all font-mono"},TO={class:"text-muted-foreground"},PO={class:"font-mono"},$O={class:"text-foreground/80"},IO={class:"text-foreground/80"},MO={class:"text-amber-600 dark:text-amber-400"},RO={class:"text-muted-foreground"},LO={class:"break-all font-mono"},bd="myapikey.logs.filters",DO=Q({__name:"Logs",setup(e){const{t}=Wt(),n=L([]),s=L(!0),o=L(!1),r=L([]),l=L([]),i=L("all"),u=L("all"),c=L("all"),d=L(""),f=L(new Set),p=L(!1);try{const q=JSON.parse(localStorage.getItem(bd)||"null");q&&(typeof q.model=="string"&&(i.value=q.model),typeof q.provider=="string"&&(u.value=q.provider),(q.status==="success"||q.status==="error")&&(c.value=q.status),typeof q.query=="string"&&(d.value=q.query))}catch{}Fe([i,u,c,d],()=>{try{localStorage.setItem(bd,JSON.stringify({model:i.value,provider:u.value,status:c.value,query:d.value}))}catch{}});let m;async function b(){o.value=!0;try{const[q,pe]=await Promise.all([He("GET","/admin/logs").catch(()=>null),He("GET","/admin/circuit").catch(()=>null)]);q&&(n.value=q.logs),pe&&(r.value=pe.providers.filter(ee=>ee.state==="cooling"),l.value=pe.providers.filter(ee=>ee.rpm>0&&ee.rpmUsed>=ee.rpm&&ee.state!=="cooling"))}finally{o.value=!1}}async function C(q){await He("POST",`/admin/circuit/${q}/reset`).catch(()=>{}),await b()}function E(){y(),m=window.setInterval(b,4e3)}function y(){m&&(clearInterval(m),m=void 0)}function k(){s.value=!s.value,s.value?(b(),E()):y()}function I(q){return q>=200&&q<300?"success":q>=400?"destructive":"muted"}function v(q){var pe;return((pe=tn[q])==null?void 0:pe.badge)??""}function $(q){return q<1e3?`${q}ms`:`${(q/1e3).toFixed(1)}s`}function T(q){return q?q<1e3?String(q):q<1e6?(q/1e3).toFixed(q<1e4?1:0).replace(/\.0$/,"")+"k":(q/1e6).toFixed(1)+"M":"0"}function A(q){if(q<=0)return"0";const pe=Math.round(q*1e3)/10;return Number.isInteger(pe)?String(pe):pe.toFixed(1)}function R(q){return new Date(q).toLocaleTimeString()}function V(q){return new Date(q).toLocaleString()}function J(q){return`${q.ts}-${q.model}-${q.provider}-${q.status}-${q.kind??"call"}`}function fe(q){return f.value.has(J(q))}function X(q){const pe=new Set(f.value),ee=J(q);pe.has(ee)?pe.delete(ee):pe.add(ee),f.value=pe}const ce=Y(()=>[...new Set(n.value.map(q=>q.model))].sort()),be=Y(()=>[...new Set(n.value.map(q=>q.provider))].sort()),Z=Y(()=>{const q=d.value.trim().toLowerCase();return n.value.filter(pe=>{var ee;return!(i.value!=="all"&&pe.model!==i.value||u.value!=="all"&&pe.provider!==u.value||c.value==="success"&&!(pe.status>=200&&pe.status<300)||c.value==="error"&&pe.status<400||q&&!(pe.model.toLowerCase().includes(q)||(ee=pe.upstreamModel)!=null&&ee.toLowerCase().includes(q)||pe.provider.toLowerCase().includes(q)))})}),ue=Y(()=>{const q=Z.value.filter(Ve=>Ve.kind!=="cooldown"),pe=q.length,ee=q.filter(Ve=>Ve.status>=400).length,Ze=pe?Math.round(q.reduce((Ve,$e)=>Ve+$e.ms,0)/pe):0;return{total:pe,fail:ee,avgMs:Ze,errorRateStr:A(pe?ee/pe:0)}}),de=Y(()=>(i.value!=="all"?1:0)+(u.value!=="all"?1:0)+(c.value!=="all"?1:0)),se=Y(()=>{const q=[];return i.value!=="all"&&q.push({key:"model",label:t("logs.filter.model"),value:i.value,clear:()=>i.value="all"}),u.value!=="all"&&q.push({key:"provider",label:t("logs.filter.provider"),value:u.value,clear:()=>u.value="all"}),c.value!=="all"&&q.push({key:"status",label:t("logs.filter.status"),value:c.value==="success"?t("logs.filter.success"):t("logs.filter.error"),clear:()=>c.value="all"}),q});function re(){i.value="all",u.value="all",c.value="all"}return pt(()=>{b(),E()}),bn(y),(q,pe)=>(_(),N(a(mn),null,{default:g(()=>[h(a(Mn),null,{default:g(()=>[x("div",ME,[h(a(Rn),{class:"flex items-center gap-2 text-base"},{default:g(()=>[h(a(Cm),{class:"h-4 w-4 text-primary"}),z(" "+S(a(t)("logs.title"))+" ",1),s.value?(_(),N(a(_t),{key:0,variant:"success",class:"gap-1.5"},{default:g(()=>[pe[5]||(pe[5]=x("span",{class:"relative flex h-1.5 w-1.5"},[x("span",{class:"absolute inline-flex h-full w-full animate-ping rounded-full bg-current opacity-75"}),x("span",{class:"relative inline-flex h-1.5 w-1.5 rounded-full bg-current"})],-1)),z(" "+S(a(t)("logs.live")),1)]),_:1})):me("",!0)]),_:1}),x("div",RE,[h(a(Ie),{variant:"outline",size:"sm",disabled:o.value,onClick:b},{default:g(()=>[o.value?(_(),N(a(St),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(_(),N(a(mr),{key:1,class:"h-3.5 w-3.5"})),x("span",LE,S(a(t)("logs.refresh")),1)]),_:1},8,["disabled"]),h(a(Ie),{variant:"outline",size:"sm","aria-pressed":s.value,onClick:k},{default:g(()=>[s.value?(_(),N(a(Jk),{key:0,class:"h-3.5 w-3.5"})):(_(),N(a(Qk),{key:1,class:"h-3.5 w-3.5"})),z(" "+S(s.value?a(t)("logs.pause"):a(t)("logs.resume")),1)]),_:1},8,["aria-pressed"])])]),h(a(ys),null,{default:g(()=>[z(S(a(t)("logs.desc")),1)]),_:1})]),_:1}),h(a(hn),{class:"space-y-3"},{default:g(()=>[x("div",DE,[x("div",NE,[h(a($m),{class:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),h(a(vt),{modelValue:d.value,"onUpdate:modelValue":pe[0]||(pe[0]=ee=>d.value=ee),placeholder:a(t)("logs.searchPh"),class:"h-8 pl-8"},null,8,["modelValue","placeholder"])]),h(a(PE),{open:p.value,"onUpdate:open":pe[4]||(pe[4]=ee=>p.value=ee)},{default:g(()=>[h(a($E),{"as-child":""},{default:g(()=>[h(a(Ie),{variant:"outline",size:"sm",class:"h-8 gap-1.5"},{default:g(()=>[h(a(Em),{class:"h-3.5 w-3.5"}),z(" "+S(a(t)("logs.filter.title"))+" ",1),de.value?(_(),K("span",FE,S(de.value),1)):me("",!0)]),_:1})]),_:1}),h(a(IE),{align:"start",class:"w-72 p-3"},{default:g(()=>[x("div",qE,[x("div",BE,[x("span",VE,S(a(t)("logs.filter.title")),1),de.value?(_(),K("button",{key:0,type:"button",class:"text-xs text-primary hover:underline",onClick:re},S(a(t)("logs.filter.clear")),1)):me("",!0)]),x("div",UE,[x("div",HE,[x("span",jE,S(a(t)("logs.filter.model")),1),h(a(zo),{modelValue:i.value,"onUpdate:modelValue":pe[1]||(pe[1]=ee=>i.value=ee)},{default:g(()=>[h(a(Go),{class:"h-8 w-full"},{default:g(()=>[h(a(Yo),{placeholder:a(t)("logs.filter.model")},null,8,["placeholder"])]),_:1}),h(a(Xo),null,{default:g(()=>[h(a(fn),{value:"all"},{default:g(()=>[z(S(a(t)("logs.filter.all")),1)]),_:1}),(_(!0),K(Ce,null,st(ce.value,ee=>(_(),N(a(fn),{key:ee,value:ee},{default:g(()=>[z(S(ee),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"])]),x("div",WE,[x("span",KE,S(a(t)("logs.filter.provider")),1),h(a(zo),{modelValue:u.value,"onUpdate:modelValue":pe[2]||(pe[2]=ee=>u.value=ee)},{default:g(()=>[h(a(Go),{class:"h-8 w-full"},{default:g(()=>[h(a(Yo),{placeholder:a(t)("logs.filter.provider")},null,8,["placeholder"])]),_:1}),h(a(Xo),null,{default:g(()=>[h(a(fn),{value:"all"},{default:g(()=>[z(S(a(t)("logs.filter.all")),1)]),_:1}),(_(!0),K(Ce,null,st(be.value,ee=>(_(),N(a(fn),{key:ee,value:ee},{default:g(()=>[z(S(ee),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"])]),x("div",zE,[x("span",GE,S(a(t)("logs.filter.status")),1),h(a(zo),{modelValue:c.value,"onUpdate:modelValue":pe[3]||(pe[3]=ee=>c.value=ee)},{default:g(()=>[h(a(Go),{class:"h-8 w-full"},{default:g(()=>[h(a(Yo),{placeholder:a(t)("logs.filter.status")},null,8,["placeholder"])]),_:1}),h(a(Xo),null,{default:g(()=>[h(a(fn),{value:"all"},{default:g(()=>[z(S(a(t)("logs.filter.all")),1)]),_:1}),h(a(fn),{value:"success"},{default:g(()=>[z(S(a(t)("logs.filter.success")),1)]),_:1}),h(a(fn),{value:"error"},{default:g(()=>[z(S(a(t)("logs.filter.error")),1)]),_:1})]),_:1})]),_:1},8,["modelValue"])])])])]),_:1})]),_:1},8,["open"])]),se.value.length?(_(),K("div",YE,[(_(!0),K(Ce,null,st(se.value,ee=>(_(),K("span",{key:ee.key,class:"inline-flex items-center gap-1 rounded-full border border-input bg-muted/40 py-0.5 pl-2.5 pr-1 text-xs"},[x("span",XE,S(ee.label)+":",1),x("span",JE,S(ee.value),1),x("button",{type:"button",class:"rounded-full p-0.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground","aria-label":a(t)("logs.filter.remove",{label:ee.label}),onClick:ee.clear},[h(a(vu),{class:"h-3 w-3"})],8,QE)]))),128)),x("button",{type:"button",class:"text-xs text-muted-foreground hover:text-foreground",onClick:re},S(a(t)("logs.filter.clear")),1)])):me("",!0),x("div",ZE,[x("span",null,S(a(t)("logs.summary.window",{n:ue.value.total})),1),x("span",{class:ke({"text-destructive":ue.value.fail>0})},S(a(t)("logs.summary.errorRate",{pct:ue.value.errorRateStr})),3),x("span",null,S(a(t)("logs.summary.avgLatency",{ms:$(ue.value.avgMs)})),1)]),r.value.length?(_(),K("div",eO,[x("div",tO,[h(a(Al),{class:"h-4 w-4"}),z(" "+S(a(t)("logs.circuit.stripTitle")),1)]),x("ul",nO,[(_(!0),K(Ce,null,st(r.value,ee=>(_(),K("li",{key:ee.id,class:"flex flex-wrap items-center gap-x-2 gap-y-1 text-xs"},[x("span",sO,S(ee.name),1),h(a(_t),{variant:"warning",class:"gap-1 whitespace-nowrap"},{default:g(()=>[h(a(Al),{class:"h-3 w-3"}),z(" "+S(a(t)("logs.circuit.remaining",{s:ee.secondsLeft})),1)]),_:2},1024),x("span",oO,S(ee.lastReason||a(t)("logs.circuit.reasonUnknown")),1),h(a(Ie),{variant:"outline",size:"sm",class:"ml-auto h-6 gap-1",onClick:Ze=>C(ee.id)},{default:g(()=>[h(a(mr),{class:"h-3 w-3"}),z(" "+S(a(t)("logs.circuit.reset")),1)]),_:1},8,["onClick"])]))),128))])])):me("",!0),l.value.length?(_(),K("div",rO,[x("div",aO,[h(a(Ko),{class:"h-4 w-4"}),z(" "+S(a(t)("logs.pacing.stripTitle")),1)]),x("ul",lO,[(_(!0),K(Ce,null,st(l.value,ee=>(_(),K("li",{key:ee.id,class:"flex flex-wrap items-center gap-x-2 gap-y-1 text-xs"},[x("span",iO,S(ee.name),1),h(a(_t),{variant:"outline",class:"gap-1 whitespace-nowrap"},{default:g(()=>[h(a(Ko),{class:"h-3 w-3"}),z(" "+S(a(t)("logs.pacing.at",{used:ee.rpmUsed,cap:ee.rpm})),1)]),_:2},1024),x("span",uO,S(a(t)("logs.pacing.reason")),1)]))),128))])])):me("",!0),n.value.length?Z.value.length?(_(),K("div",fO,[h(a(Im),null,{default:g(()=>[h(a(Mm),null,{default:g(()=>[h(a(uo),null,{default:g(()=>[h(a(zt),{class:"w-8"}),h(a(zt),null,{default:g(()=>[z(S(a(t)("logs.col.time")),1)]),_:1}),h(a(zt),null,{default:g(()=>[z(S(a(t)("logs.col.model")),1)]),_:1}),h(a(zt),null,{default:g(()=>[z(S(a(t)("logs.col.provider")),1)]),_:1}),h(a(zt),null,{default:g(()=>[z(S(a(t)("logs.col.format")),1)]),_:1}),h(a(zt),{class:"text-right"},{default:g(()=>[z(S(a(t)("logs.col.latency")),1)]),_:1}),h(a(zt),{class:"text-right"},{default:g(()=>[z(S(a(t)("logs.col.status")),1)]),_:1})]),_:1})]),_:1}),h(a(Rm),null,{default:g(()=>[(_(!0),K(Ce,null,st(Z.value,ee=>(_(),K(Ce,{key:J(ee)},[ee.kind==="cooldown"?(_(),N(a(uo),{key:0,class:"bg-amber-500/5 hover:bg-amber-500/10"},{default:g(()=>[h(a(Lt),{colspan:"7",class:"py-2"},{default:g(()=>[x("div",pO,[x("span",mO,S(R(ee.ts)),1),h(a(_t),{variant:"warning",class:"gap-1 whitespace-nowrap"},{default:g(()=>[h(a(Al),{class:"h-3 w-3"}),z(" "+S(a(t)("logs.circuit.badge")),1)]),_:1}),x("span",hO,S(ee.provider),1),x("span",vO,S(a(t)("logs.circuit.failures",{n:ee.fails})),1),x("span",gO,S(a(t)("logs.circuit.cooldown",{s:Math.round((ee.cooldownMs??0)/1e3)})),1),x("span",yO,S(ee.error||a(t)("logs.circuit.reasonUnknown")),1)])]),_:2},1024)]),_:2},1024)):(_(),K(Ce,{key:1},[h(a(uo),{class:"cursor-pointer hover:bg-muted/50",onClick:Ze=>X(ee)},{default:g(()=>[h(a(Lt),{class:"w-8 text-muted-foreground"},{default:g(()=>[(_(),N(yr(fe(ee)?a(Ya):a(vi)),{class:"h-3.5 w-3.5"}))]),_:2},1024),h(a(Lt),{class:"font-mono text-xs text-muted-foreground",title:V(ee.ts)},{default:g(()=>[z(S(R(ee.ts)),1)]),_:2},1032,["title"]),h(a(Lt),{class:"font-mono text-xs"},{default:g(()=>[z(S(ee.model),1),ee.upstreamModel?(_(),K("span",bO," → "+S(ee.upstreamModel),1)):me("",!0)]),_:2},1024),h(a(Lt),{class:"text-sm"},{default:g(()=>[z(S(ee.provider),1)]),_:2},1024),h(a(Lt),null,{default:g(()=>[x("span",_O,[h(a(_t),{variant:"outline",class:ke(v(ee.format))},{default:g(()=>[z(S(ee.format),1)]),_:2},1032,["class"]),ee.stream?(_(),N(a(_t),{key:0,variant:"muted",class:"text-[10px]"},{default:g(()=>[z(S(a(t)("logs.stream")),1)]),_:1})):me("",!0)])]),_:2},1024),h(a(Lt),{class:"text-right font-mono text-xs text-muted-foreground"},{default:g(()=>[z(S($(ee.ms)),1)]),_:2},1024),h(a(Lt),{class:"text-right"},{default:g(()=>[h(a(_t),{variant:I(ee.status),class:"font-mono"},{default:g(()=>[z(S(ee.status),1)]),_:2},1032,["variant"])]),_:2},1024)]),_:2},1032,["onClick"]),fe(ee)?(_(),N(a(uo),{key:0,class:"hover:bg-transparent"},{default:g(()=>[h(a(Lt),{colspan:"7",class:"bg-muted/30"},{default:g(()=>[x("dl",wO,[x("dt",xO,S(a(t)("logs.detail.time")),1),x("dd",kO,S(V(ee.ts)),1),x("dt",CO,S(a(t)("logs.detail.latency")),1),x("dd",SO,S($(ee.ms)),1),x("dt",AO,S(a(t)("logs.detail.stream")),1),x("dd",null,S(ee.stream?a(t)("logs.detail.streamYes"):a(t)("logs.detail.streamNo")),1),ee.upstreamModel?(_(),K(Ce,{key:0},[x("dt",EO,S(a(t)("logs.detail.upstreamModel")),1),x("dd",OO,S(ee.upstreamModel),1)],64)):me("",!0),ee.usage?(_(),K(Ce,{key:1},[x("dt",TO,S(a(t)("logs.detail.tokens")),1),x("dd",PO,[x("span",$O,"↑ "+S(T(ee.usage.input)),1),pe[7]||(pe[7]=x("span",{class:"text-muted-foreground/50"}," · ",-1)),x("span",IO,"↓ "+S(T(ee.usage.output)),1),ee.usage.estimated?(_(),N(a(_t),{key:0,variant:"muted",class:"ml-1.5 text-[10px]"},{default:g(()=>[z("≈ "+S(a(t)("logs.detail.estimated")),1)]),_:1})):me("",!0),(ee.usage.cacheRead||0)+(ee.usage.cacheCreation||0)?(_(),K(Ce,{key:1},[pe[6]||(pe[6]=x("span",{class:"text-muted-foreground/50"}," · ",-1)),x("span",MO,"⚡ "+S(a(t)("logs.detail.cache"))+" "+S(T((ee.usage.cacheRead||0)+(ee.usage.cacheCreation||0))),1)],64)):me("",!0)])],64)):me("",!0),x("dt",RO,S(a(t)("logs.detail.error")),1),x("dd",LO,S(ee.error||a(t)("logs.detail.errorNone")),1)])]),_:2},1024)]),_:2},1024)):me("",!0)],64))],64))),128))]),_:1})]),_:1})])):(_(),K("p",dO,S(a(t)("logs.noMatch")),1)):(_(),K("p",cO,S(a(t)("logs.empty")),1))]),_:1})]),_:1}))}}),NO={key:0,class:"py-4 text-center text-xs text-muted-foreground"},FO={class:"flex items-center gap-1.5"},qO={class:"truncate font-mono text-xs"},BO={class:"flex items-center gap-2"},VO={class:"h-1.5 w-full max-w-[120px] overflow-hidden rounded-full bg-muted"},UO={class:"font-mono text-xs tabular-nums"},HO={key:0},jO={class:"text-foreground/80"},WO={class:"text-foreground/80"},KO={key:1,class:"text-muted-foreground/40"},zO={key:0,class:"inline-flex flex-col items-end leading-tight"},GO={class:"text-amber-600 dark:text-amber-400"},YO={class:"text-[10px] text-muted-foreground/60"},XO={key:1,class:"text-muted-foreground/40"},Br=Q({__name:"StatsBreakdown",props:{title:{},buckets:{},max:{},kind:{}},setup(e){const{t}=Wt();function n(d){return d<1e3?`${d}ms`:`${(d/1e3).toFixed(1)}s`}function s(d){return d?d<1e3?String(d):d<1e6?(d/1e3).toFixed(d<1e4?1:0).replace(/\.0$/,"")+"k":(d/1e6).toFixed(1)+"M":"0"}function o(d){if(!d)return"0%";const f=Math.round(d*1e3)/10;return(f%1===0?f.toFixed(0):f.toFixed(1))+"%"}const r=e,l=()=>r.buckets.some(d=>d.inputTokens||d.outputTokens),i=()=>r.buckets.some(d=>d.cacheRead||d.cacheCreation);function u(d,f){return f?Math.round(d/f*100):0}function c(d){var f;return(f=tn[d])==null?void 0:f.solid}return(d,f)=>(_(),N(a(mn),null,{default:g(()=>[h(a(Mn),{class:"pb-2"},{default:g(()=>[h(a(Rn),{class:"text-sm"},{default:g(()=>[z(S(e.title),1)]),_:1})]),_:1}),h(a(hn),null,{default:g(()=>[e.buckets.length?(_(),N(a(Im),{key:1},{default:g(()=>[h(a(Mm),null,{default:g(()=>[h(a(uo),null,{default:g(()=>[h(a(zt),null,{default:g(()=>[z(S(a(t)("stats.col.name")),1)]),_:1}),h(a(zt),{class:"w-1/3"},{default:g(()=>[z(S(a(t)("stats.col.calls")),1)]),_:1}),h(a(zt),{class:"text-right"},{default:g(()=>[z(S(a(t)("stats.col.success")),1)]),_:1}),h(a(zt),{class:"text-right"},{default:g(()=>[z(S(a(t)("stats.col.error")),1)]),_:1}),h(a(zt),{class:"text-right"},{default:g(()=>[z(S(a(t)("stats.col.avgLatency")),1)]),_:1}),l()?(_(),N(a(zt),{key:0,class:"text-right"},{default:g(()=>[z(S(a(t)("stats.col.tokens")),1)]),_:1})):me("",!0),i()?(_(),N(a(zt),{key:1,class:"text-right"},{default:g(()=>[z(S(a(t)("stats.col.cacheHit")),1)]),_:1})):me("",!0)]),_:1})]),_:1}),h(a(Rm),null,{default:g(()=>[(_(!0),K(Ce,null,st(e.buckets,p=>(_(),N(a(uo),{key:p.key},{default:g(()=>[h(a(Lt),{class:"py-1.5"},{default:g(()=>[x("div",FO,[e.kind==="format"&&c(p.key)?(_(),K("span",{key:0,class:ke(["h-2 w-2 shrink-0 rounded-full",c(p.key)])},null,2)):e.kind==="provider"&&p.id?(_(),K("span",{key:1,class:ke(["h-2 w-2 shrink-0 rounded-full",a(ei)(p.id).solid])},null,2)):me("",!0),x("span",qO,S(p.key),1)])]),_:2},1024),h(a(Lt),{class:"py-1.5"},{default:g(()=>[x("div",BO,[x("div",VO,[x("div",{class:"h-full rounded-full bg-primary/50",style:vn({width:u(p.calls,e.max)+"%"})},null,4)]),x("span",UO,S(p.calls),1)])]),_:2},1024),h(a(Lt),{class:"py-1.5 text-right font-mono text-xs text-emerald-600 dark:text-emerald-400"},{default:g(()=>[z(S(p.success),1)]),_:2},1024),h(a(Lt),{class:ke(["py-1.5 text-right font-mono text-xs",p.error?"text-destructive":"text-muted-foreground"])},{default:g(()=>[z(S(p.error),1)]),_:2},1032,["class"]),h(a(Lt),{class:"py-1.5 text-right font-mono text-xs text-muted-foreground"},{default:g(()=>[z(S(n(p.avgMs)),1)]),_:2},1024),l()?(_(),N(a(Lt),{key:0,class:"py-1.5 text-right font-mono text-xs tabular-nums"},{default:g(()=>[p.inputTokens||p.outputTokens?(_(),K("span",HO,[x("span",jO,S(s(p.inputTokens)),1),f[0]||(f[0]=x("span",{class:"text-muted-foreground/50"}," / ",-1)),x("span",WO,S(s(p.outputTokens)),1)])):(_(),K("span",KO,"—"))]),_:2},1024)):me("",!0),i()?(_(),N(a(Lt),{key:1,class:"py-1.5 text-right font-mono text-xs tabular-nums"},{default:g(()=>[p.cacheRead||p.cacheCreation?(_(),K("span",zO,[x("span",GO,S(o(p.cacheHitRate)),1),x("span",YO,"↑"+S(s(p.cacheRead)),1)])):(_(),K("span",XO,"—"))]),_:2},1024)):me("",!0)]),_:2},1024))),128))]),_:1})]),_:1})):(_(),K("p",NO,S(a(t)("stats.empty")),1))]),_:1})]),_:1}))}}),JO={class:"flex flex-wrap items-center justify-between gap-2"},QO={class:"flex items-center gap-2"},ZO={class:"inline-flex rounded-md border bg-muted/30 p-0.5"},eT=["onClick"],tT={class:"sr-only"},nT={key:0,class:"flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground"},sT={key:1,class:"py-10 text-center text-sm text-muted-foreground"},oT={class:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-6"},rT={class:"rounded-lg border bg-muted/20 p-3"},aT={class:"text-xs text-muted-foreground"},lT={class:"mt-1 font-mono text-xl tabular-nums"},iT={class:"rounded-lg border bg-muted/20 p-3"},uT={class:"text-xs text-muted-foreground"},cT={class:"mt-1 font-mono text-xl tabular-nums text-emerald-600 dark:text-emerald-400"},dT={class:"rounded-lg border bg-muted/20 p-3"},fT={class:"text-xs text-muted-foreground"},pT={class:"mt-1 font-mono text-xl tabular-nums text-destructive"},mT={class:"rounded-lg border bg-muted/20 p-3"},hT={class:"text-xs text-muted-foreground"},vT={class:"mt-1 font-mono text-xl tabular-nums"},gT={class:"rounded-lg border bg-muted/20 p-3"},yT={class:"text-xs text-muted-foreground"},bT={class:"mt-1 font-mono text-xl tabular-nums"},_T={class:"rounded-lg border bg-muted/20 p-3"},wT={class:"text-xs text-muted-foreground"},xT={class:"mt-1 font-mono text-xl tabular-nums"},kT={key:0,class:"grid grid-cols-3 gap-2"},CT={class:"rounded-lg border bg-muted/20 p-3"},ST={class:"text-xs text-muted-foreground"},AT={class:"mt-1 font-mono text-lg tabular-nums"},ET={class:"rounded-lg border bg-muted/20 p-3"},OT={class:"text-xs text-muted-foreground"},TT={class:"mt-1 font-mono text-lg tabular-nums"},PT={class:"rounded-lg border bg-muted/20 p-3"},$T={class:"text-xs text-muted-foreground"},IT={class:"mt-1 font-mono text-lg tabular-nums"},MT={class:"mb-2 flex items-center justify-between gap-2"},RT={class:"text-sm font-medium"},LT={key:0,class:"text-[11px] text-muted-foreground"},DT={class:"font-mono tabular-nums text-foreground"},NT={class:"rounded-lg border p-3"},FT={class:"relative pt-9"},qT={class:"flex h-40 gap-px"},BT={class:"pointer-events-none absolute bottom-full left-1/2 z-20 mb-1 hidden -translate-x-1/2 whitespace-nowrap rounded-md border bg-background px-2 py-1 text-center text-xs shadow-md group-hover:block"},VT={class:"font-medium"},UT={class:"font-mono tabular-nums"},HT={class:"text-[10px]"},jT={class:"text-emerald-600 dark:text-emerald-400"},WT={class:"text-destructive"},KT={class:"mt-1.5 flex justify-between text-[10px] text-muted-foreground"},zT={class:"grid gap-4 lg:grid-cols-2"},GT={class:"lg:col-span-2"},YT={key:1,class:"space-y-3"},XT={class:"text-sm font-medium"},JT={class:"grid gap-4 lg:grid-cols-2"},_d=160,QT=Q({__name:"Stats",setup(e){const{t}=Wt(),n=[{v:"24h",key:"h24"},{v:"7d",key:"d7"},{v:"30d",key:"d30"},{v:"90d",key:"d90"},{v:"all",key:"all"}],s=L(localStorage.getItem("myapikey.stats.range")||"7d");n.some(I=>I.v===s.value)||(s.value="7d"),Fe(s,I=>{try{localStorage.setItem("myapikey.stats.range",I)}catch{}});const o=L(null),r=L(!1);async function l(){r.value=!0;try{o.value=await He("GET",`/admin/stats?range=${s.value}`)}catch{o.value=null}finally{r.value=!1}}Fe(s,l),pt(l);function i(I){return I<1e3?`${I}ms`:`${(I/1e3).toFixed(1)}s`}function u(I){if(!I)return"0%";const v=Math.round(I*1e3)/10;return(v%1===0?v.toFixed(0):v.toFixed(1))+"%"}function c(I){const[v,$,T]=I.split("-").map(Number);return new Date(v,$-1,T).toLocaleDateString(void 0,{month:"short",day:"numeric"})}const d=Y(()=>{var I;return((I=o.value)==null?void 0:I.byDay.reduce((v,$)=>Math.max(v,$.calls),0))??0});function f(I){const v=d.value||1,$=I.calls/v*_d,T=I.error/v*_d;return{success:Math.max(0,Math.round($-T)),error:Math.round(T)}}function p(I){return I.reduce((v,$)=>Math.max(v,$.calls),0)||1}const m=Y(()=>!!o.value&&o.value.totals.calls>0),b=Y(()=>{var I,v;return(((I=o.value)==null?void 0:I.totals.cacheRead)??0)+(((v=o.value)==null?void 0:v.totals.cacheCreation)??0)}),C=Y(()=>!!o.value&&!!(o.value.totals.inputTokens||o.value.totals.outputTokens||b.value)),E=Y(()=>{var $;const I=((($=o.value)==null?void 0:$.byProviderModel)??[]).filter(T=>T.cacheRead||T.cacheCreation),v=new Map;for(const T of I){const A=T.providerId||T.provider;let R=v.get(A);R||(R={providerId:T.providerId,provider:T.provider,models:[],cacheRead:0},v.set(A,R)),R.models.push({key:T.model,calls:T.calls,success:T.success,error:0,avgMs:0,inputTokens:T.inputTokens,outputTokens:0,cacheRead:T.cacheRead,cacheCreation:T.cacheCreation,cacheHitRate:T.cacheHitRate}),R.cacheRead+=T.cacheRead}return[...v.values()].sort((T,A)=>A.cacheRead-T.cacheRead)}),y=Y(()=>E.value.length>0);function k(I){return I?I<1e3?String(I):I<1e6?(I/1e3).toFixed(I<1e4?1:0).replace(/\.0$/,"")+"k":(I/1e6).toFixed(1)+"M":"0"}return(I,v)=>(_(),N(a(mn),null,{default:g(()=>[h(a(Mn),null,{default:g(()=>[x("div",JO,[h(a(Rn),{class:"flex items-center gap-2 text-base"},{default:g(()=>[h(a(Sm),{class:"h-4 w-4 text-primary"}),z(" "+S(a(t)("stats.title")),1)]),_:1}),x("div",QO,[x("div",ZO,[(_(),K(Ce,null,st(n,$=>x("button",{key:$.v,type:"button",class:ke(["rounded-sm px-2.5 py-1 text-xs transition-colors",s.value===$.v?"bg-background font-medium shadow-sm":"text-muted-foreground hover:text-foreground"]),onClick:T=>s.value=$.v},S(a(t)(`stats.ranges.${$.key}`)),11,eT)),64))]),h(a(Ie),{variant:"outline",size:"sm",disabled:r.value,onClick:l},{default:g(()=>[r.value?(_(),N(a(St),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(_(),N(a(mr),{key:1,class:"h-3.5 w-3.5"})),x("span",tT,S(a(t)("stats.refresh")),1)]),_:1},8,["disabled"])])]),h(a(ys),null,{default:g(()=>[z(S(a(t)("stats.desc")),1)]),_:1})]),_:1}),h(a(hn),{class:"space-y-5"},{default:g(()=>[r.value&&!o.value?(_(),K("div",nT,[h(a(St),{class:"h-4 w-4 animate-spin"}),z(" "+S(a(t)("stats.loading")),1)])):m.value?o.value?(_(),K(Ce,{key:2},[x("div",oT,[x("div",rT,[x("div",aT,S(a(t)("stats.totals.calls")),1),x("div",lT,S(o.value.totals.calls),1)]),x("div",iT,[x("div",uT,S(a(t)("stats.totals.success")),1),x("div",cT,S(o.value.totals.success),1)]),x("div",dT,[x("div",fT,S(a(t)("stats.totals.error")),1),x("div",pT,S(o.value.totals.error),1)]),x("div",mT,[x("div",hT,S(a(t)("stats.totals.errorRate")),1),x("div",vT,S(u(o.value.totals.errorRate)),1)]),x("div",gT,[x("div",yT,S(a(t)("stats.totals.avgLatency")),1),x("div",bT,S(i(o.value.totals.avgMs)),1)]),x("div",_T,[x("div",wT,S(a(t)("stats.totals.p95")),1),x("div",xT,S(i(o.value.totals.p95Ms)),1)])]),C.value?(_(),K("div",kT,[x("div",CT,[x("div",ST,"↑ "+S(a(t)("stats.totals.inputTokens")),1),x("div",AT,S(k(o.value.totals.inputTokens)),1)]),x("div",ET,[x("div",OT,"↓ "+S(a(t)("stats.totals.outputTokens")),1),x("div",TT,S(k(o.value.totals.outputTokens)),1)]),x("div",PT,[x("div",$T,"⚡ "+S(a(t)("stats.totals.cache")),1),x("div",IT,S(k(b.value)),1)])])):me("",!0),x("div",null,[x("div",MT,[x("div",RT,S(a(t)("stats.byDay")),1),d.value?(_(),K("div",LT,[z(S(a(t)("stats.peak"))+" ",1),x("span",DT,S(d.value),1)])):me("",!0)]),x("div",NT,[x("div",FT,[x("div",qT,[(_(!0),K(Ce,null,st(o.value.byDay,$=>(_(),K("div",{key:$.day,class:"group relative flex min-w-0 flex-1 cursor-default flex-col justify-end"},[x("div",{style:vn({height:f($).success+"px"}),class:"w-full rounded-t-sm bg-emerald-500/70 transition-colors group-hover:bg-emerald-500"},null,4),x("div",{style:vn({height:f($).error+"px"}),class:ke(["w-full transition-colors group-hover:bg-destructive",f($).error?"bg-destructive/70":""])},null,6),x("div",BT,[x("div",VT,S(c($.day)),1),x("div",UT,S($.calls)+" "+S(a(t)("stats.callsAxis")),1),x("div",HT,[x("span",jT,S($.success),1),v[0]||(v[0]=x("span",{class:"text-muted-foreground"}," / ",-1)),x("span",WT,S($.error),1)])])]))),128))])]),x("div",KT,[x("span",null,S(o.value.byDay.length?c(o.value.byDay[0].day):""),1),x("span",null,S(o.value.byDay.length?c(o.value.byDay[o.value.byDay.length-1].day):""),1)])])]),x("div",zT,[x("div",GT,[h(Br,{title:a(t)("stats.byModel"),buckets:o.value.byModel,max:p(o.value.byModel),kind:"model"},null,8,["title","buckets","max"])]),h(Br,{title:a(t)("stats.byProvider"),buckets:o.value.byProvider,max:p(o.value.byProvider),kind:"provider"},null,8,["title","buckets","max"]),h(Br,{title:a(t)("stats.byFormat"),buckets:o.value.byFormat,max:p(o.value.byFormat),kind:"format"},null,8,["title","buckets","max"])]),y.value?(_(),K("div",YT,[x("div",XT,S(a(t)("stats.cacheBySource")),1),x("div",JT,[(_(!0),K(Ce,null,st(E.value,$=>(_(),N(Br,{key:$.providerId||$.provider,title:$.provider,buckets:$.models,max:p($.models),kind:"model"},null,8,["title","buckets","max"]))),128))])])):me("",!0)],64)):me("",!0):(_(),K("div",sT,S(a(t)("stats.empty")),1))]),_:1})]),_:1}))}}),ZT={class:"space-y-4"},eP={class:"space-y-2"},tP={class:"min-w-0"},nP={class:"mt-0.5 truncate font-mono text-sm"},sP={class:"min-w-0"},oP={class:"mt-0.5 truncate font-mono text-sm"},rP={class:"text-xs text-muted-foreground"},aP={class:"flex items-center justify-between gap-3 rounded-lg border border-primary/40 bg-primary/5 p-3"},lP={class:"min-w-0"},iP={class:"text-xs font-medium text-primary"},uP={class:"truncate font-mono text-sm"},cP={class:"flex items-center gap-1"},dP={class:"overflow-x-auto rounded-md border bg-muted/40 p-3 font-mono text-xs leading-relaxed"},fP=Q({__name:"Connect",setup(e){const{t}=Wt(),n={openai:"openai",anthropic:"anthropic",responses:"responses",curl:null};function s(m){const b=n[m];return b?tn[b]:null}const o=L(null),r=L(null),l=L(""),i=L(!1),u=Y(()=>{const m=window.location.hostname;if((m==="localhost"||m==="127.0.0.1")&&r.value){const b=window.location.port;return`${window.location.protocol}//${r.value}${b?":"+b:""}`}return window.location.origin}),c=Y(()=>`${u.value}/v1`);async function d(){o.value=(await He("GET","/admin/api-key")).apiKey,r.value=(await He("GET","/admin/connection")).lanIp}async function f(m,b){await Yi(b)?(l.value=m,setTimeout(()=>{l.value===m&&(l.value="")},1500)):Me(t("connect.copyFailed"),"error")}const p=Y(()=>[{key:"openai",title:t("connect.openaiTitle"),text:`export OPENAI_BASE_URL=${c.value}
282
+ */const El=De("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),Xa=Q({__name:"Dialog",props:{open:{type:Boolean},defaultOpen:{type:Boolean},modal:{type:Boolean},unmountOnHide:{type:Boolean}},emits:["update:open"],setup(e,{emit:t}){const o=Mt(e,t);return(r,l)=>(_(),N(a($1),Tt($t(a(o))),{default:g(()=>[ie(r.$slots,"default")]),_:3},16))}}),Ja=Q({__name:"DialogContent",props:{forceMount:{type:Boolean},disableOutsidePointerEvents:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},emits:["escapeKeyDown","pointerDownOutside","focusOutside","interactOutside","openAutoFocus","closeAutoFocus"],setup(e,{emit:t}){const n=e,s=t,o=Y(()=>{const{class:l,...i}=n;return i}),r=Mt(o,s);return(l,i)=>(_(),N(a(f0),null,{default:g(()=>[h(a(u0),{class:"fixed inset-0 z-50 bg-black/80"}),h(a(s0),Te(a(r),{class:a(Xe)("fixed left-[50%] top-[50%] z-50 grid max-h-[90vh] w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 overflow-y-auto border bg-background p-6 shadow-lg sm:rounded-lg",n.class)}),{default:g(()=>[ie(l.$slots,"default"),h(a(M1),{class:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background"},{default:g(()=>[h(a(vu),{class:"h-4 w-4"}),i[0]||(i[0]=x("span",{class:"sr-only"},"Close",-1))]),_:1})]),_:3},16,["class"])]),_:3}))}}),Qa=Q({__name:"DialogTitle",props:{asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(_(),N(a(m0),{class:ke(a(Xe)("text-lg font-semibold leading-none tracking-tight",t.class))},{default:g(()=>[ie(n.$slots,"default")]),_:3},8,["class"]))}}),Za=Q({__name:"DialogDescription",props:{asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(_(),N(a(r0),{class:ke(a(Xe)("text-sm text-muted-foreground",t.class))},{default:g(()=>[ie(n.$slots,"default")]),_:3},8,["class"]))}}),Kn=Q({__name:"Checkbox",props:bs({class:{type:[Boolean,null,String,Object,Array]},id:{}},{modelValue:{type:Boolean},modelModifiers:{}}),emits:["update:modelValue"],setup(e){const t=e,n=br(e,"modelValue");return(s,o)=>(_(),N(a(qw),{modelValue:n.value,"onUpdate:modelValue":o[0]||(o[0]=r=>n.value=r),id:t.id,class:ke(a(Xe)("peer h-4 w-4 shrink-0 cursor-pointer rounded-[4px] border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t.class))},{default:g(()=>[h(a(Vw),{class:"flex h-full w-full items-center justify-center text-current"},{default:g(()=>[h(a(Pn),{class:"h-3.5 w-3.5"})]),_:1})]),_:1},8,["modelValue","id","class"]))}}),_i=Q({__name:"Separator",props:{class:{type:[Boolean,null,String,Object,Array]},orientation:{}},setup(e){const t=e;return(n,s)=>(_(),N(a(Ek),{orientation:t.orientation??"horizontal",class:ke(a(Xe)("shrink-0 bg-border",t.orientation==="vertical"?"h-full w-px":"h-px w-full",t.class))},null,8,["orientation","class"]))}}),oC={class:"flex gap-3 pr-8"},rC={key:0,class:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-destructive/15 text-destructive"},aC={class:"min-w-0 flex-1 space-y-1.5"},lC={class:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end"},gu=Q({__name:"ConfirmDialog",props:bs({title:{},description:{},confirmText:{default:""},cancelText:{default:""},variant:{default:"default"},loading:{type:Boolean,default:!1}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:bs(["confirm"],["update:open"]),setup(e,{emit:t}){const{t:n}=Wt(),s=br(e,"open"),o=t;return(r,l)=>(_(),N(a(Xa),{open:s.value,"onUpdate:open":l[2]||(l[2]=i=>s.value=i)},{default:g(()=>[h(a(Ja),{class:"max-w-sm"},{default:g(()=>[x("div",oC,[e.variant==="destructive"?(_(),K("span",rC,[h(a(nC),{class:"h-4 w-4"})])):me("",!0),x("div",aC,[h(a(Qa),{class:"text-base leading-tight"},{default:g(()=>[z(S(e.title),1)]),_:1}),e.description?(_(),N(a(Za),{key:0},{default:g(()=>[z(S(e.description),1)]),_:1})):me("",!0)])]),x("div",lC,[h(a(Ie),{variant:"outline",disabled:e.loading,onClick:l[0]||(l[0]=i=>s.value=!1)},{default:g(()=>[z(S(e.cancelText||a(n)("common.cancel")),1)]),_:1},8,["disabled"]),h(a(Ie),{variant:e.variant,disabled:e.loading,onClick:l[1]||(l[1]=i=>o("confirm"))},{default:g(()=>[e.loading?(_(),N(a(St),{key:0,class:"h-4 w-4 animate-spin"})):me("",!0),z(" "+S(e.confirmText||a(n)("common.confirm")),1)]),_:1},8,["variant","disabled"])])]),_:1})]),_:1},8,["open"]))}}),iC={class:"flex items-center gap-2 pr-8"},uC={class:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-primary/15 text-primary"},cC={class:"min-w-0"},dC={key:0,class:"py-4 text-center text-sm text-muted-foreground"},fC={key:1,class:"py-4 text-center text-sm text-destructive"},pC={class:"space-y-1"},mC={key:0,class:"space-y-1.5 rounded-md border bg-muted/30 p-3 text-xs leading-relaxed text-muted-foreground"},hC={key:3,class:"space-y-3 rounded-lg border bg-muted/30 p-4"},vC={class:"space-y-1.5"},gC={class:"text-xs font-medium text-muted-foreground"},yC={class:"space-y-1.5"},bC={class:"text-xs font-medium text-muted-foreground"},_C={class:"space-y-3 rounded-md border bg-background/50 p-3"},wC={class:"space-y-2"},xC={class:"flex items-center gap-2.5"},kC={class:"flex items-center gap-2.5 pl-7"},CC={class:"flex items-center gap-2.5"},SC={class:"text-xs text-muted-foreground"},AC={key:0,class:"space-y-1.5"},EC={class:"text-xs font-medium text-muted-foreground"},OC={class:"text-xs text-muted-foreground"},TC={key:1,class:"space-y-1.5"},PC={class:"text-xs font-medium text-muted-foreground"},$C={class:"text-xs text-muted-foreground"},IC={class:"space-y-1.5"},MC={class:"text-xs font-medium text-muted-foreground"},RC={key:2,class:"text-sm text-destructive"},LC={class:"flex justify-end gap-2"},DC={key:4,class:"space-y-2"},NC={key:0,class:"flex items-center gap-3"},FC={class:"min-w-0 flex-1"},qC={class:"flex items-center gap-2"},BC={class:"truncate font-medium"},VC={key:0,class:"mt-0.5 truncate font-mono text-xs text-muted-foreground"},UC={key:1,class:"mt-0.5 truncate font-mono text-xs text-muted-foreground"},HC={key:1,class:"space-y-3"},jC={class:"space-y-1.5"},WC={class:"text-xs font-medium text-muted-foreground"},KC={class:"space-y-1.5"},zC={class:"text-xs font-medium text-muted-foreground"},GC={class:"space-y-3 rounded-md border bg-background/50 p-3"},YC={class:"space-y-2"},XC={class:"flex items-center gap-2.5"},JC={class:"flex items-center gap-2.5 pl-7"},QC={class:"flex items-center gap-2.5"},ZC={key:0,class:"space-y-1.5"},eS={class:"text-xs font-medium text-muted-foreground"},tS={class:"text-xs text-muted-foreground"},nS={key:1,class:"space-y-1.5"},sS={class:"text-xs font-medium text-muted-foreground"},oS={class:"text-xs text-muted-foreground"},rS={class:"space-y-1.5"},aS={class:"flex items-center justify-between"},lS={class:"text-xs font-medium text-muted-foreground"},iS={key:0,class:"text-xs text-muted-foreground"},uS={class:"space-y-1.5"},cS={class:"text-xs font-medium text-muted-foreground"},dS={class:"text-xs text-muted-foreground"},fS={class:"flex justify-end gap-2"},pS=Q({__name:"SourcesDialog",props:{open:{type:Boolean,default:!1},openModifiers:{}},emits:bs(["changed"],["update:open"]),setup(e,{emit:t}){const{t:n}=Wt(),s=br(e,"open"),o=t,r=L([]),l=L(!1),i=L(""),u=L(""),c=L(""),d=L(""),f=L(""),p=L(!0),m=L(!1),b=L(!1),C=L(!1),E=L(""),y=L(!1),k=L(!1),I=L(null),v=L(""),$=L(""),T=L(""),A=L(""),R=L(""),V=L(!0),J=L(!1),fe=L(!1),X=L(!1),ce=L({}),be=L(null),Z=L(!1),ue=L(!1);async function de(){l.value=!0,i.value="";try{const ge=await He("GET","/admin/providers");r.value=ge.providers}catch(ge){i.value=ge.message}finally{l.value=!1}}Fe(s,ge=>{ge&&de()});function se(ge,w){const M=ge==="new"?p:V,W=ge==="new"?m:J;if(w==="openai"){if(M.value&&!W.value)return;M.value=!M.value}else{if(W.value&&!M.value)return;W.value=!W.value}}function re(ge){const w=[];return(ge==="new"?p:V).value&&w.push("openai"),(ge==="new"?m:J).value&&w.push("anthropic"),w}async function q(){if(C.value)return;E.value="";const ge=re("new");if(!u.value||!f.value){E.value=n("sources.errRequired");return}if(!ge.length){E.value=n("sources.errFormat");return}if(p.value&&!c.value||m.value&&!d.value){E.value=n("sources.errBaseUrl");return}C.value=!0;try{const w=await He("POST","/admin/providers",{name:u.value,baseUrlOpenai:c.value,baseUrlAnthropic:d.value,apiKey:f.value,formats:ge,supportsResponses:p.value&&b.value});r.value=[...r.value,w.provider],u.value=f.value="",c.value=d.value="",b.value=!1,y.value=!1,Me(n("sources.added"),"success"),o("changed")}catch(w){Me(w.message,"error")}finally{C.value=!1}}function pe(ge){I.value=ge.id,v.value=ge.name,$.value=ge.baseUrlOpenai,T.value=ge.baseUrlAnthropic,A.value="",R.value=ge.rpm?String(ge.rpm):"",V.value=ge.formats.includes("openai"),J.value=ge.formats.includes("anthropic"),fe.value=!!ge.supportsResponses}function ee(){I.value=null}async function Ze(ge){if(X.value)return;const w=re("edit");if(!v.value){Me(n("sources.errRequired"),"error");return}if(!w.length){Me(n("sources.errFormat"),"error");return}if(V.value&&!$.value||J.value&&!T.value){Me(n("sources.errBaseUrl"),"error");return}X.value=!0;try{const M={name:v.value,baseUrlOpenai:$.value,baseUrlAnthropic:T.value,formats:w,supportsResponses:V.value&&fe.value,rpm:Number(R.value)||0};A.value&&(M.apiKey=A.value);const W=await He("PUT",`/admin/providers/${ge.id}`,M);r.value=r.value.map(le=>le.id===ge.id?W.provider:le),I.value=null,Me(n("sources.updated"),"success"),o("changed")}catch(M){Me(M.message,"error")}finally{X.value=!1}}async function Ve(ge){ce.value[ge.id]=!0;try{const w=await He("POST",`/admin/providers/${ge.id}/discover`);r.value=r.value.map(M=>M.id===ge.id?{...M,discoveredModels:w.models}:M),Me(n("sources.refreshDone",{name:ge.name}),w.models.length?"success":"default"),o("changed")}catch(w){Me(w.message,"error")}finally{ce.value[ge.id]=!1}}function $e(ge){be.value=ge,Z.value=!0}async function Be(){const ge=be.value;if(!(!ge||ue.value)){ue.value=!0;try{await He("DELETE",`/admin/providers/${ge.id}`),r.value=r.value.filter(w=>w.id!==ge.id),Me(n("sources.removed",{name:ge.name}),"success"),o("changed"),Z.value=!1}catch(w){Me(w.message,"error")}finally{ue.value=!1}}}function Ue(ge){var w;return((w=ge.discoveredModels)==null?void 0:w.length)??0}function rt(ge){return Ue(ge)>0?"found":ge.discoveredAt?"empty":"never"}function Re(ge){const w=rt(ge);return w==="found"?n("sources.discoveredCount",{n:Ue(ge)}):n(w==="empty"?"sources.noModelsFound":"sources.notScanned")}function ut(ge){const w=rt(ge);return w==="empty"?n("sources.noModelsHint"):w==="never"?n("sources.notScannedHint"):""}return(ge,w)=>(_(),K(Ce,null,[h(a(Xa),{open:s.value,"onUpdate:open":w[18]||(w[18]=M=>s.value=M)},{default:g(()=>[h(a(Ja),{class:"max-w-xl"},{default:g(()=>[x("div",iC,[x("span",uC,[h(a(yi),{class:"h-4 w-4"})]),x("div",cC,[h(a(Qa),{class:"text-base"},{default:g(()=>[z(S(a(n)("sources.manage")),1)]),_:1}),h(a(Za),null,{default:g(()=>[z(S(a(n)("sources.subtitle")),1)]),_:1})])]),l.value?(_(),K("p",dC,S(a(n)("common.loading")),1)):i.value?(_(),K("p",fC,S(i.value),1)):me("",!0),x("div",pC,[x("button",{type:"button",class:"inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground",onClick:w[0]||(w[0]=M=>k.value=!k.value)},[h(a(Om),{class:"h-3.5 w-3.5"}),z(" "+S(a(n)("sources.baseHelpToggle"))+" ",1),h(a(Ya),{class:ke(["h-3.5 w-3.5 transition-transform",{"rotate-180":k.value}])},null,8,["class"])]),k.value?(_(),K("div",mC,[x("p",null,S(a(n)("sources.baseHelpSplit")),1),x("p",null,[w[20]||(w[20]=x("span",{class:"font-medium text-foreground"},"openai",-1)),z(" — "+S(a(n)("sources.baseHelpOpenai")),1)]),x("p",null,[w[21]||(w[21]=x("span",{class:"font-medium text-foreground"},"anthropic",-1)),z(" — "+S(a(n)("sources.baseHelpAnthropic")),1)])])):me("",!0)]),!y.value&&r.value.length?(_(),N(a(Ie),{key:2,variant:"outline",class:"w-full justify-center",onClick:w[1]||(w[1]=M=>y.value=!0)},{default:g(()=>[h(a(ts),{class:"h-4 w-4"}),z(S(a(n)("sources.add")),1)]),_:1})):(_(),K("div",hC,[x("div",vC,[x("label",gC,S(a(n)("sources.nameLabel")),1),h(a(vt),{modelValue:u.value,"onUpdate:modelValue":w[2]||(w[2]=M=>u.value=M),placeholder:a(n)("sources.namePh"),autocomplete:"off","aria-label":"name"},null,8,["modelValue","placeholder"])]),x("div",yC,[x("label",bC,S(a(n)("sources.formats")),1),x("div",_C,[x("div",wC,[x("div",xC,[h(a(Kn),{"model-value":p.value,disabled:p.value&&!m.value,"aria-label":"openai","onUpdate:modelValue":w[3]||(w[3]=M=>se("new","openai"))},null,8,["model-value","disabled"]),w[22]||(w[22]=x("span",{class:"text-sm font-medium leading-none"},"openai",-1)),w[23]||(w[23]=x("span",{class:"text-xs text-muted-foreground"},"/chat/completions",-1))]),x("div",kC,[h(a(Kn),{modelValue:b.value,"onUpdate:modelValue":w[4]||(w[4]=M=>b.value=M),disabled:!p.value,"aria-label":a(n)("sources.responses")},null,8,["modelValue","disabled","aria-label"]),x("span",{class:ke(["text-sm leading-none",p.value?"":"text-muted-foreground"])},S(a(n)("sources.responses")),3),w[24]||(w[24]=x("span",{class:"text-xs text-muted-foreground"},"/responses",-1))])]),h(a(_i)),x("div",CC,[h(a(Kn),{"model-value":m.value,disabled:m.value&&!p.value,"aria-label":"anthropic","onUpdate:modelValue":w[5]||(w[5]=M=>se("new","anthropic"))},null,8,["model-value","disabled"]),w[25]||(w[25]=x("span",{class:"text-sm font-medium leading-none"},"anthropic",-1)),w[26]||(w[26]=x("span",{class:"text-xs text-muted-foreground"},"/messages",-1))])]),x("p",SC,S(a(n)("sources.addHint")),1)]),p.value?(_(),K("div",AC,[x("label",EC,S(a(n)("sources.urlLabelOpenai")),1),h(a(vt),{modelValue:c.value,"onUpdate:modelValue":w[6]||(w[6]=M=>c.value=M),placeholder:a(n)("sources.urlPhOpenai"),autocomplete:"off","aria-label":"openai base url"},null,8,["modelValue","placeholder"]),x("p",OC,S(a(n)("sources.urlHintOpenai")),1)])):me("",!0),m.value?(_(),K("div",TC,[x("label",PC,S(a(n)("sources.urlLabelAnthropic")),1),h(a(vt),{modelValue:d.value,"onUpdate:modelValue":w[7]||(w[7]=M=>d.value=M),placeholder:a(n)("sources.urlPhAnthropic"),autocomplete:"off","aria-label":"anthropic base url"},null,8,["modelValue","placeholder"]),x("p",$C,S(a(n)("sources.urlHintAnthropic")),1)])):me("",!0),x("div",IC,[x("label",MC,S(a(n)("sources.keyLabel")),1),h(a(vt),{modelValue:f.value,"onUpdate:modelValue":w[8]||(w[8]=M=>f.value=M),type:"password",placeholder:a(n)("sources.keyPh"),autocomplete:"new-password","aria-label":"api key"},null,8,["modelValue","placeholder"])]),E.value?(_(),K("p",RC,S(E.value),1)):me("",!0),x("div",LC,[r.value.length?(_(),N(a(Ie),{key:0,variant:"ghost",size:"sm",onClick:w[9]||(w[9]=M=>y.value=!1)},{default:g(()=>[z(S(a(n)("sources.cancel")),1)]),_:1})):me("",!0),h(a(Ie),{size:"sm",disabled:C.value,onClick:q},{default:g(()=>[C.value?(_(),N(a(St),{key:0,class:"h-4 w-4 animate-spin"})):(_(),N(a(ts),{key:1,class:"h-4 w-4"})),z(S(a(n)("sources.addBtn")),1)]),_:1},8,["disabled"])])])),r.value.length?(_(),K("div",DC,[(_(!0),K(Ce,null,st(r.value,M=>(_(),K("div",{key:M.id,class:"rounded-lg border p-3"},[I.value!==M.id?(_(),K("div",NC,[x("div",FC,[x("div",qC,[x("span",BC,S(M.name),1),(_(!0),K(Ce,null,st(M.formats,W=>(_(),N(a(_t),{key:W,variant:"secondary"},{default:g(()=>[z(S(W),1)]),_:2},1024))),128)),M.rpm?(_(),N(a(_t),{key:0,variant:"outline",title:a(n)("sources.rpmBadgeHint")},{default:g(()=>[z(S(a(n)("sources.rpmBadge",{n:M.rpm})),1)]),_:2},1032,["title"])):me("",!0),h(a(_t),{variant:"muted",title:ut(M)},{default:g(()=>[z(S(Re(M)),1)]),_:2},1032,["title"])]),M.formats.includes("openai")?(_(),K("div",VC,[w[27]||(w[27]=x("span",{class:"opacity-60"},"openai ·",-1)),z(" "+S(M.baseUrlOpenai),1)])):me("",!0),M.formats.includes("anthropic")?(_(),K("div",UC,[w[28]||(w[28]=x("span",{class:"opacity-60"},"anthropic ·",-1)),z(" "+S(M.baseUrlAnthropic),1)])):me("",!0)]),h(a(fi),null,{default:g(()=>[h(a(pi),null,{default:g(()=>[h(a(Ie),{variant:"ghost",size:"icon",class:"h-8 w-8","aria-label":a(n)("sources.moreActions")},{default:g(()=>[h(a(gi),{class:"h-4 w-4"})]),_:1},8,["aria-label"])]),_:1}),h(a(mi),{align:"end"},{default:g(()=>[h(a(Wn),{disabled:ce.value[M.id],onSelect:W=>Ve(M)},{default:g(()=>[ce.value[M.id]?(_(),N(a(St),{key:0,class:"animate-spin"})):(_(),N(a(mr),{key:1})),z(" "+S(a(n)("sources.refreshModels")),1)]),_:2},1032,["disabled","onSelect"]),h(a(Wn),{onSelect:W=>pe(M)},{default:g(()=>[h(a(Tm)),z(" "+S(a(n)("sources.editLabel")),1)]),_:1},8,["onSelect"]),h(a(hi)),h(a(Wn),{class:"text-destructive focus:bg-destructive/10 focus:text-destructive",onSelect:W=>$e(M)},{default:g(()=>[h(a(bi)),z(" "+S(a(n)("sources.deleteLabel")),1)]),_:1},8,["onSelect"])]),_:2},1024)]),_:2},1024)])):(_(),K("div",HC,[x("div",jC,[x("label",WC,S(a(n)("sources.nameLabel")),1),h(a(vt),{modelValue:v.value,"onUpdate:modelValue":w[10]||(w[10]=W=>v.value=W),placeholder:a(n)("sources.namePh"),autocomplete:"off","aria-label":"name"},null,8,["modelValue","placeholder"])]),x("div",KC,[x("label",zC,S(a(n)("sources.formats")),1),x("div",GC,[x("div",YC,[x("div",XC,[h(a(Kn),{"model-value":V.value,disabled:V.value&&!J.value,"aria-label":"openai","onUpdate:modelValue":w[11]||(w[11]=W=>se("edit","openai"))},null,8,["model-value","disabled"]),w[29]||(w[29]=x("span",{class:"text-sm font-medium leading-none"},"openai",-1)),w[30]||(w[30]=x("span",{class:"text-xs text-muted-foreground"},"/chat/completions",-1))]),x("div",JC,[h(a(Kn),{modelValue:fe.value,"onUpdate:modelValue":w[12]||(w[12]=W=>fe.value=W),disabled:!V.value,"aria-label":a(n)("sources.responses")},null,8,["modelValue","disabled","aria-label"]),x("span",{class:ke(["text-sm leading-none",V.value?"":"text-muted-foreground"])},S(a(n)("sources.responses")),3),w[31]||(w[31]=x("span",{class:"text-xs text-muted-foreground"},"/responses",-1))])]),h(a(_i)),x("div",QC,[h(a(Kn),{"model-value":J.value,disabled:J.value&&!V.value,"aria-label":"anthropic","onUpdate:modelValue":w[13]||(w[13]=W=>se("edit","anthropic"))},null,8,["model-value","disabled"]),w[32]||(w[32]=x("span",{class:"text-sm font-medium leading-none"},"anthropic",-1)),w[33]||(w[33]=x("span",{class:"text-xs text-muted-foreground"},"/messages",-1))])])]),V.value?(_(),K("div",ZC,[x("label",eS,S(a(n)("sources.urlLabelOpenai")),1),h(a(vt),{modelValue:$.value,"onUpdate:modelValue":w[14]||(w[14]=W=>$.value=W),placeholder:a(n)("sources.urlPhOpenai"),autocomplete:"off","aria-label":"openai base url"},null,8,["modelValue","placeholder"]),x("p",tS,S(a(n)("sources.urlHintOpenai")),1)])):me("",!0),J.value?(_(),K("div",nS,[x("label",sS,S(a(n)("sources.urlLabelAnthropic")),1),h(a(vt),{modelValue:T.value,"onUpdate:modelValue":w[15]||(w[15]=W=>T.value=W),placeholder:a(n)("sources.urlPhAnthropic"),autocomplete:"off","aria-label":"anthropic base url"},null,8,["modelValue","placeholder"]),x("p",oS,S(a(n)("sources.urlHintAnthropic")),1)])):me("",!0),x("div",rS,[x("div",aS,[x("label",lS,S(a(n)("sources.keyLabel")),1),M.apiKey?(_(),K("span",iS,S(a(n)("sources.currentKeyLabel"))+": "+S(M.apiKey),1)):me("",!0)]),h(a(vt),{modelValue:A.value,"onUpdate:modelValue":w[16]||(w[16]=W=>A.value=W),type:"password",placeholder:a(n)("sources.keyPhEdit"),autocomplete:"new-password","aria-label":"api key"},null,8,["modelValue","placeholder"])]),x("div",uS,[x("label",cS,S(a(n)("sources.rpmLabel")),1),h(a(vt),{modelValue:R.value,"onUpdate:modelValue":w[17]||(w[17]=W=>R.value=W),type:"number",min:"0",inputmode:"numeric",placeholder:a(n)("sources.rpmPh"),"aria-label":"rpm"},null,8,["modelValue","placeholder"]),x("p",dS,S(a(n)("sources.rpmHint")),1)]),x("div",fS,[h(a(Ie),{variant:"ghost",size:"sm",onClick:ee},{default:g(()=>[z(S(a(n)("sources.cancel")),1)]),_:1}),h(a(Ie),{size:"sm",disabled:X.value,onClick:W=>Ze(M)},{default:g(()=>[X.value?(_(),N(a(St),{key:0,class:"h-4 w-4 animate-spin"})):me("",!0),z(S(a(n)("sources.saveBtn")),1)]),_:1},8,["disabled","onClick"])])]))]))),128))])):me("",!0)]),_:1})]),_:1},8,["open"]),h(gu,{open:Z.value,"onUpdate:open":w[19]||(w[19]=M=>Z.value=M),variant:"destructive",title:a(n)("sources.remove"),description:be.value?a(n)("sources.confirmRemove",{name:be.value.name}):"","confirm-text":a(n)("sources.remove"),loading:ue.value,onConfirm:Be},null,8,["open","title","description","confirm-text","loading"])],64))}}),zo=Q({__name:"Select",props:{open:{type:Boolean},defaultOpen:{type:Boolean},defaultValue:{},modelValue:{},nullableValue:{},by:{type:[String,Function]},dir:{},multiple:{type:Boolean},autocomplete:{},disabled:{type:Boolean},name:{},required:{type:Boolean}},emits:["update:modelValue","update:open"],setup(e,{emit:t}){const o=Mt(e,t);return(r,l)=>(_(),N(a(jx),Tt($t(a(o))),{default:g(()=>[ie(r.$slots,"default")]),_:3},16))}}),Go=Q({__name:"SelectTrigger",props:{disabled:{type:Boolean},reference:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e,n=Y(()=>{const{class:s,...o}=t;return o});return(s,o)=>(_(),N(a(bk),Te(n.value,{class:a(Xe)("flex h-9 w-full items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t.class)}),{default:g(()=>[ie(s.$slots,"default"),h(a(ik),{"as-child":""},{default:g(()=>[h(a(Ya),{class:"h-4 w-4 opacity-50"})]),_:1})]),_:3},16,["class"]))}}),Yo=Q({__name:"SelectValue",props:{placeholder:{},asChild:{type:Boolean},as:{}},setup(e){const t=e;return(n,s)=>(_(),N(a(wk),Tt($t(t)),{default:g(()=>[ie(n.$slots,"default")]),_:3},16))}}),Xo=Q({__name:"SelectContent",props:{forceMount:{type:Boolean},position:{default:"popper"},bodyLock:{type:Boolean},memoDependencies:{},side:{},sideOffset:{},sideFlip:{type:Boolean},align:{},alignOffset:{},alignFlip:{type:Boolean},avoidCollisions:{type:Boolean},collisionBoundary:{},collisionPadding:{},arrowPadding:{},hideShiftedArrow:{type:Boolean},sticky:{},hideWhenDetached:{type:Boolean},positionStrategy:{},updatePositionStrategy:{},disableUpdateOnLayoutShift:{type:Boolean},prioritizePosition:{type:Boolean},reference:{},dir:{},asChild:{type:Boolean},as:{},disableOutsidePointerEvents:{type:Boolean},class:{type:[Boolean,null,String,Object,Array]}},emits:["closeAutoFocus","escapeKeyDown","pointerDownOutside"],setup(e,{emit:t}){const n=e,s=t,o=Y(()=>{const{class:l,...i}=n;return i}),r=Mt(o,s);return(l,i)=>(_(),N(a(gk),null,{default:g(()=>[h(a(ak),Te(a(r),{class:a(Xe)("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",n.position==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:translate-x-1 data-[side=right]:-translate-x-1 data-[side=top]:-translate-y-1",n.class)}),{default:g(()=>[h(a(kk),{class:ke(a(Xe)("p-1",n.position==="popper"&&"w-full min-w-[var(--reka-select-trigger-width)]"))},{default:g(()=>[ie(l.$slots,"default")]),_:3},8,["class"])]),_:3},16,["class"])]),_:3}))}}),mS={class:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center"},fn=Q({__name:"SelectItem",props:{value:{},disabled:{type:Boolean},textValue:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e,n=Y(()=>{const{class:s,...o}=t;return o});return(s,o)=>(_(),N(a(dk),Te(n.value,{class:a(Xe)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t.class)}),{default:g(()=>[x("span",mS,[h(a(pk),null,{default:g(()=>[h(a(Pn),{class:"h-4 w-4"})]),_:1})]),h(a(hk),null,{default:g(()=>[ie(s.$slots,"default")]),_:3})]),_:3},16,["class"]))}}),hS={class:"flex items-center gap-2 pr-8"},vS={class:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-primary/15 text-primary"},gS={class:"min-w-0"},yS={class:"space-y-3"},bS={class:"space-y-1.5"},_S={class:"text-xs font-medium text-muted-foreground"},wS={class:"text-xs text-muted-foreground"},xS={class:"font-medium text-foreground"},kS={key:0,class:"space-y-3 rounded-lg border bg-muted/30 p-4"},CS={class:"text-xs text-muted-foreground"},SS={key:0,class:"space-y-1.5"},AS={class:"text-xs font-medium text-muted-foreground"},ES={class:"space-y-1.5"},OS={class:"text-xs font-medium text-muted-foreground"},TS={class:"space-y-2 rounded-md border bg-background/50 p-3"},PS={class:"space-y-2"},$S={class:"flex items-center gap-2.5"},IS={class:"flex items-center gap-2.5 pl-7"},MS={class:"flex items-center gap-2.5"},RS={key:1,class:"space-y-1.5"},LS={class:"text-xs font-medium text-muted-foreground"},DS={class:"text-xs text-muted-foreground"},NS={key:2,class:"space-y-1.5"},FS={class:"text-xs font-medium text-muted-foreground"},qS={class:"text-xs text-muted-foreground"},BS={key:3,class:"space-y-1.5"},VS={class:"text-xs font-medium text-muted-foreground"},US={key:4,class:"text-sm text-destructive"},HS={key:1,class:"space-y-1.5"},jS={class:"flex items-center justify-between gap-2"},WS={class:"text-xs font-medium text-muted-foreground"},KS={key:0,class:"text-xs text-muted-foreground"},zS={key:0,class:"text-xs text-muted-foreground"},GS={key:0,class:"text-xs text-muted-foreground"},YS={key:1,class:"flex max-h-40 flex-wrap gap-1 overflow-y-auto rounded-md border bg-background/50 p-2"},XS=["aria-pressed","onClick"],JS={class:"space-y-1.5"},QS={class:"text-xs font-medium text-muted-foreground"},ZS=["placeholder"],eA={key:0,class:"text-xs text-muted-foreground"},tA={class:"flex justify-end gap-2"},Ol="__new__",yd="__none__",nA=Q({__name:"AddModelsDialog",props:bs({providers:{}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:bs(["changed"],["update:open"]),setup(e,{emit:t}){const{t:n}=Wt(),s=e,o=br(e,"open"),r=t,l=L(""),i=L(""),u=L(!1),c=L(""),d=L(""),f=L(""),p=L(""),m=L(!0),b=L(!1),C=L(!1),E=L(""),y=L(new Set),k=L([]),I=L("");Fe(o,se=>{se&&(l.value=s.providers.length?s.providers[0].id:Ol,i.value="",y.value=new Set,k.value=[],I.value="",c.value=p.value="",d.value=f.value="",m.value=!0,b.value=!1,C.value=!1,E.value="")}),Fe(l,()=>{y.value=new Set,I.value=""});const v=Y(()=>l.value===Ol),$=Y(()=>l.value===yd);function T(se){const re=[...se.formats];return se.supportsResponses&&!re.includes("responses")&&re.push("responses"),re}const A=Y(()=>{if(v.value||$.value)return T({formats:V(),supportsResponses:m.value&&C.value});const se=s.providers.find(re=>re.id===l.value);return se?T(se):[]});function R(se){if(se==="openai"){if(m.value&&!b.value)return;m.value=!m.value}else{if(b.value&&!m.value)return;b.value=!b.value}}function V(){const se=[];return m.value&&se.push("openai"),b.value&&se.push("anthropic"),se}function J(){return!c.value.trim()||!p.value?n("sources.errRequired"):V().length?m.value&&!d.value.trim()||b.value&&!f.value.trim()?n("sources.errBaseUrl"):"":n("sources.errFormat")}const fe=Y(()=>{const se=new Set,re=[];for(const q of i.value.split(/[\s,;]+/)){const pe=q.trim();pe&&!se.has(pe)&&(se.add(pe),re.push(pe))}return re}),X=Y(()=>{const se=new Set,re=[];for(const q of[...fe.value,...y.value])se.has(q)||(se.add(q),re.push(q));return re}),ce=Y(()=>{if($.value)return[];const se=s.providers.find(re=>re.id===l.value);return se?se.discoveredModels??[]:k.value}),be=Y(()=>{const se=I.value.trim().toLowerCase();return se?ce.value.filter(re=>re.toLowerCase().includes(se)):ce.value});function Z(se){const re=new Set(y.value);re.has(se)?re.delete(se):re.add(se),y.value=re}const ue=Y(()=>!!l.value&&X.value.length>0&&A.value.length>0&&!u.value);async function de(){if(ue.value){if(v.value){const se=J();if(se){E.value=se;return}}u.value=!0;try{let se=l.value,re=[],q=!1;if(v.value){const $e=await He("POST","/admin/providers",{name:c.value.trim(),baseUrlOpenai:d.value,baseUrlAnthropic:f.value,apiKey:p.value,formats:V(),supportsResponses:m.value&&C.value});se=$e.provider.id,l.value=se,k.value=$e.discovered??$e.provider.discoveredModels??[],re=T($e.provider),q=!0,Me(n("sources.added"),"success")}else if($.value)re=T({formats:V(),supportsResponses:m.value&&C.value});else{const $e=s.providers.find(Be=>Be.id===se);re=$e?T($e):[]}const pe=[];for(const $e of X.value)for(const Be of re)pe.push({name:$e,slot:Be});const ee=await Promise.allSettled(pe.map($e=>He("POST","/admin/models",{name:$e.name,format:$e.slot,providers:$.value?[]:[se]}))),Ze=new Set;let Ve=0;ee.forEach(($e,Be)=>{$e.status==="fulfilled"?Ze.add(pe[Be].name):Ve++}),Ze.size&&Me(n("models.addedToast",{n:Ze.size}),"success"),Ve&&Me(n("models.addModelsFailed",{n:Ve}),"error"),(q||Ze.size)&&r("changed"),Ze.size&&(o.value=!1)}finally{u.value=!1}}}return(se,re)=>(_(),N(a(Xa),{open:o.value,"onUpdate:open":re[11]||(re[11]=q=>o.value=q)},{default:g(()=>[h(a(Ja),{class:ke(v.value?"max-w-lg":"max-w-md")},{default:g(()=>[x("div",hS,[x("span",vS,[h(a(ts),{class:"h-4 w-4"})]),x("div",gS,[h(a(Qa),{class:"text-base"},{default:g(()=>[z(S(a(n)("models.addModels")),1)]),_:1}),h(a(Za),null,{default:g(()=>[z(S(a(n)("models.addModelsDesc")),1)]),_:1})])]),x("div",yS,[x("div",bS,[x("label",_S,S(a(n)("models.providerLabel")),1),h(a(zo),{modelValue:l.value,"onUpdate:modelValue":re[0]||(re[0]=q=>l.value=q)},{default:g(()=>[h(a(Go),null,{default:g(()=>[h(a(Yo),{placeholder:a(n)("models.providerPh")},null,8,["placeholder"])]),_:1}),h(a(Xo),null,{default:g(()=>[h(a(fn),{value:Ol},{default:g(()=>[z(S(a(n)("models.newSourceOpt")),1)]),_:1}),h(a(fn),{value:yd},{default:g(()=>[z(S(a(n)("models.noneSourceOpt")),1)]),_:1}),(_(!0),K(Ce,null,st(e.providers,q=>(_(),N(a(fn),{key:q.id,value:q.id},{default:g(()=>[z(S(q.name),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"]),x("p",wS,[z(S(a(n)("models.addModelsSlotsHint"))+" ",1),x("span",xS,S(A.value.join(" / ")||"—"),1)])]),v.value||$.value?(_(),K("div",kS,[x("p",CS,S(v.value?a(n)("models.addModelsNewHint"):a(n)("models.addModelsNoneHint")),1),v.value?(_(),K("div",SS,[x("label",AS,S(a(n)("sources.nameLabel")),1),h(a(vt),{modelValue:c.value,"onUpdate:modelValue":re[1]||(re[1]=q=>c.value=q),placeholder:a(n)("sources.namePh"),autocomplete:"off","aria-label":"name"},null,8,["modelValue","placeholder"])])):me("",!0),x("div",ES,[x("label",OS,S(a(n)("sources.formats")),1),x("div",TS,[x("div",PS,[x("div",$S,[h(a(Kn),{"model-value":m.value,disabled:m.value&&!b.value,"aria-label":"openai","onUpdate:modelValue":re[2]||(re[2]=q=>R("openai"))},null,8,["model-value","disabled"]),re[12]||(re[12]=x("span",{class:"text-sm font-medium leading-none"},"openai",-1)),re[13]||(re[13]=x("span",{class:"text-xs text-muted-foreground"},"/chat/completions",-1))]),x("div",IS,[h(a(Kn),{modelValue:C.value,"onUpdate:modelValue":re[3]||(re[3]=q=>C.value=q),disabled:!m.value,"aria-label":a(n)("sources.responses")},null,8,["modelValue","disabled","aria-label"]),x("span",{class:ke(["text-sm leading-none",m.value?"":"text-muted-foreground"])},S(a(n)("sources.responses")),3),re[14]||(re[14]=x("span",{class:"text-xs text-muted-foreground"},"/responses",-1))])]),h(a(_i)),x("div",MS,[h(a(Kn),{"model-value":b.value,disabled:b.value&&!m.value,"aria-label":"anthropic","onUpdate:modelValue":re[4]||(re[4]=q=>R("anthropic"))},null,8,["model-value","disabled"]),re[15]||(re[15]=x("span",{class:"text-sm font-medium leading-none"},"anthropic",-1)),re[16]||(re[16]=x("span",{class:"text-xs text-muted-foreground"},"/messages",-1))])])]),v.value&&m.value?(_(),K("div",RS,[x("label",LS,S(a(n)("sources.urlLabelOpenai")),1),h(a(vt),{modelValue:d.value,"onUpdate:modelValue":re[5]||(re[5]=q=>d.value=q),placeholder:a(n)("sources.urlPhOpenai"),autocomplete:"off","aria-label":"openai base url"},null,8,["modelValue","placeholder"]),x("p",DS,S(a(n)("sources.urlHintOpenai")),1)])):me("",!0),v.value&&b.value?(_(),K("div",NS,[x("label",FS,S(a(n)("sources.urlLabelAnthropic")),1),h(a(vt),{modelValue:f.value,"onUpdate:modelValue":re[6]||(re[6]=q=>f.value=q),placeholder:a(n)("sources.urlPhAnthropic"),autocomplete:"off","aria-label":"anthropic base url"},null,8,["modelValue","placeholder"]),x("p",qS,S(a(n)("sources.urlHintAnthropic")),1)])):me("",!0),v.value?(_(),K("div",BS,[x("label",VS,S(a(n)("sources.keyLabel")),1),h(a(vt),{modelValue:p.value,"onUpdate:modelValue":re[7]||(re[7]=q=>p.value=q),type:"password",placeholder:a(n)("sources.keyPh"),autocomplete:"new-password","aria-label":"api key"},null,8,["modelValue","placeholder"])])):me("",!0),v.value&&E.value?(_(),K("p",US,S(E.value),1)):me("",!0)])):me("",!0),!v.value&&!$.value?(_(),K("div",HS,[x("div",jS,[x("label",WS,S(a(n)("models.addModelsDiscoveredLabel")),1),ce.value.length?(_(),K("span",KS,S(a(n)("models.addModelsDiscoveredHint")),1)):me("",!0)]),ce.value.length?(_(),K(Ce,{key:1},[h(a(vt),{modelValue:I.value,"onUpdate:modelValue":re[8]||(re[8]=q=>I.value=q),placeholder:a(n)("models.searchPh"),autocomplete:"off"},null,8,["modelValue","placeholder"]),be.value.length?(_(),K("div",YS,[(_(!0),K(Ce,null,st(be.value,q=>(_(),K("button",{key:q,type:"button","aria-pressed":y.value.has(q),class:ke(["inline-flex items-center rounded-md border px-2 py-0.5 font-mono text-xs transition-colors",y.value.has(q)?"border-transparent bg-primary text-primary-foreground shadow-sm":"border-input text-muted-foreground hover:bg-accent hover:text-accent-foreground"]),onClick:pe=>Z(q)},S(q),11,XS))),128))])):(_(),K("p",GS,S(a(n)("models.addModelsDiscoveredNoMatch")),1))],64)):(_(),K("p",zS,S(a(n)("models.addModelsDiscoveredEmpty")),1))])):me("",!0),x("div",JS,[x("label",QS,S(a(n)("models.namesLabel")),1),yo(x("textarea",{"onUpdate:modelValue":re[9]||(re[9]=q=>i.value=q),placeholder:a(n)("models.addModelsNamesPh"),rows:"6",spellcheck:"false",class:"flex w-full resize-y rounded-md border border-input bg-transparent px-3 py-2 font-mono text-sm shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50"},null,8,ZS),[[Og,i.value]]),X.value.length?(_(),K("p",eA,S(a(n)("models.addModelsCount",{n:X.value.length})),1)):me("",!0)]),x("div",tA,[h(a(Ie),{variant:"outline",disabled:u.value,onClick:re[10]||(re[10]=q=>o.value=!1)},{default:g(()=>[z(S(a(n)("common.cancel")),1)]),_:1},8,["disabled"]),h(a(Ie),{disabled:!ue.value,onClick:de},{default:g(()=>[u.value?(_(),N(a(St),{key:0,class:"h-4 w-4 animate-spin"})):(_(),N(a(ts),{key:1,class:"h-4 w-4"})),z(" "+S(a(n)("models.addModelsBtn")),1)]),_:1},8,["disabled"])])])]),_:1},8,["class"])]),_:1},8,["open"]))}}),sA={key:0,class:"absolute z-50 mt-1 max-h-56 w-full overflow-auto rounded-md border bg-popover p-1 text-sm shadow-md"},oA=["onMousedown"],rA={key:1,class:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"},aA={class:"flex-1 truncate"},lA={key:0,class:"px-2 py-1 text-xs text-muted-foreground"},iA=Q({__name:"Combobox",props:{modelValue:{},options:{},placeholder:{},limit:{default:300}},emits:["update:modelValue"],setup(e,{emit:t}){const n=e,s=t,o=L(null),r=L(!1),l=Y(()=>{const p=n.modelValue.trim().toLowerCase();return p?n.options.filter(m=>m.toLowerCase().includes(p)):n.options}),i=Y(()=>l.value.slice(0,n.limit)),u=Y(()=>l.value.length-i.value.length);function c(p){s("update:modelValue",String(p)),r.value=!0}function d(p){s("update:modelValue",p),r.value=!1}function f(p){var b;const m=p.relatedTarget;m&&((b=o.value)!=null&&b.contains(m))||(r.value=!1)}return(p,m)=>(_(),K("div",{ref_key:"rootRef",ref:o,class:"relative",onFocusin:m[0]||(m[0]=b=>r.value=!0),onFocusout:f},[h(a(vt),{"model-value":e.modelValue,placeholder:e.placeholder,autocomplete:"off",spellcheck:"false","onUpdate:modelValue":c},null,8,["model-value","placeholder"]),r.value&&i.value.length?(_(),K("ul",sA,[(_(!0),K(Ce,null,st(i.value,b=>(_(),K("li",{key:b},[x("button",{type:"button",class:ke(["flex w-full items-center gap-2 rounded px-2 py-1.5 text-left font-mono hover:bg-accent hover:text-accent-foreground",b===e.modelValue?"text-primary":""]),onMousedown:Gt(C=>d(b),["prevent"])},[b===e.modelValue?(_(),N(a(Pn),{key:0,class:"h-3.5 w-3.5 shrink-0"})):(_(),K("span",rA)),x("span",aA,S(b),1)],42,oA)]))),128)),u.value>0?(_(),K("li",lA," +"+S(u.value)+" more — refine your search ",1)):me("",!0)])):me("",!0)],544))}}),uA={class:"flex items-center gap-2 pr-8"},cA={class:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-primary/15 text-primary"},dA={class:"min-w-0"},fA={class:"space-y-3"},pA={key:0,class:"rounded-md bg-muted/40 px-3 py-6 text-center text-sm text-muted-foreground"},mA={class:"space-y-1.5"},hA={class:"text-xs font-medium text-muted-foreground"},vA={key:0,class:"text-xs text-muted-foreground"},gA={class:"font-medium text-foreground"},yA={key:1,class:"text-xs text-amber-600 dark:text-amber-500"},bA={class:"space-y-1.5"},_A={class:"text-xs font-medium text-muted-foreground"},wA={class:"text-xs text-muted-foreground"},xA={class:"flex justify-end gap-2"},kA=Q({__name:"AddSourceDialog",props:bs({modelName:{},providers:{},enabledFormats:{},chainByFormat:{}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:bs(["added"],["update:open"]),setup(e,{emit:t}){const{t:n}=Wt(),s=e,o=br(e,"open"),r=t,l=encodeURIComponent,i=L(""),u=L(""),c=L(!1);function d(v,$){return $==="responses"?!!v.supportsResponses:v.formats.includes($)}function f(v){const $=s.providers.find(T=>T.id===v);return $?s.enabledFormats.filter(T=>d($,T)):[]}function p(v){return s.enabledFormats.filter($=>(s.chainByFormat[$]??[]).includes(v))}const m=Y(()=>s.providers.filter(v=>s.enabledFormats.some($=>d(v,$))).sort((v,$)=>v.name.localeCompare($.name))),b=Y(()=>{var v;return((v=s.providers.find($=>$.id===i.value))==null?void 0:v.discoveredModels)??[]}),C={openai:"models.fmtOpenaiShort",anthropic:"models.fmtAnthropicShort",responses:"models.fmtResponsesShort"},E=Y(()=>i.value?f(i.value).map(v=>n(C[v]??v)):[]),y=Y(()=>!!i.value&&p(i.value).length>0),k=Y(()=>!!i.value&&!c.value);Fe(o,v=>{var $;v&&(i.value=(($=m.value[0])==null?void 0:$.id)??"",u.value="")});async function I(){if(!k.value)return;const v=i.value;if(!v)return;const $=f(v),T=u.value.trim();c.value=!0;try{(await Promise.allSettled($.map(V=>He("POST",`/admin/models/${l(s.modelName)}/providers`,{format:V,providerId:v,model:T||void 0})))).filter(V=>V.status==="rejected").length?Me(n("models.addSourcePartial"),"error"):Me(n("models.sourceAdded"),"success"),r("added"),o.value=!1}catch(A){Me(A.message,"error")}finally{c.value=!1}}return(v,$)=>(_(),N(a(Xa),{open:o.value,"onUpdate:open":$[3]||($[3]=T=>o.value=T)},{default:g(()=>[h(a(Ja),{class:"max-w-md"},{default:g(()=>[x("div",uA,[x("span",cA,[h(a(ts),{class:"h-4 w-4"})]),x("div",dA,[h(a(Qa),{class:"text-base"},{default:g(()=>[z(S(a(n)("models.addSourceTitle")),1)]),_:1}),h(a(Za),null,{default:g(()=>[z(S(a(n)("models.addSourceDesc")),1)]),_:1})])]),x("div",fA,[m.value.length?(_(),K(Ce,{key:1},[x("div",mA,[x("label",hA,S(a(n)("models.providerLabel")),1),h(a(zo),{modelValue:i.value,"onUpdate:modelValue":$[0]||($[0]=T=>i.value=T)},{default:g(()=>[h(a(Go),null,{default:g(()=>[h(a(Yo),{placeholder:a(n)("models.providerPh")},null,8,["placeholder"])]),_:1}),h(a(Xo),null,{default:g(()=>[(_(!0),K(Ce,null,st(m.value,T=>(_(),N(a(fn),{key:T.id,value:T.id},{default:g(()=>[z(S(T.name),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"]),E.value.length?(_(),K("p",vA,[z(S(a(n)("models.addSourceTargetsHint"))+" ",1),x("span",gA,S(E.value.join(" / ")),1)])):me("",!0),y.value?(_(),K("p",yA,S(a(n)("models.addSourceDupHint")),1)):me("",!0)]),x("div",bA,[x("label",_A,S(a(n)("models.upstreamLabel")),1),h(iA,{modelValue:u.value,"onUpdate:modelValue":$[1]||($[1]=T=>u.value=T),options:b.value,placeholder:a(n)("models.upstreamPh")},null,8,["modelValue","options","placeholder"]),x("p",wA,S(a(n)("models.upstreamHint")),1)])],64)):(_(),K("div",pA,S(a(n)("models.addSourceNone")),1)),x("div",xA,[h(a(Ie),{variant:"outline",disabled:c.value,onClick:$[2]||($[2]=T=>o.value=!1)},{default:g(()=>[z(S(a(n)("common.cancel")),1)]),_:1},8,["disabled"]),h(a(Ie),{disabled:!k.value||!m.value.length,onClick:I},{default:g(()=>[c.value?(_(),N(a(St),{key:0,class:"h-4 w-4 animate-spin"})):(_(),N(a(ts),{key:1,class:"h-4 w-4"})),z(" "+S(a(n)("models.addToChain")),1)]),_:1},8,["disabled"])])])]),_:1})]),_:1},8,["open"]))}}),CA={class:"space-y-4"},SA={class:"flex h-11 w-11 items-center justify-center rounded-xl bg-primary/15 text-primary"},AA={class:"space-y-1"},EA={class:"font-medium"},OA={class:"max-w-sm text-sm text-muted-foreground"},TA={class:"flex flex-wrap items-center gap-2"},PA={class:"relative min-w-[180px] flex-1"},$A={class:"text-xs text-muted-foreground"},IA={key:0,class:"py-6 text-center text-sm text-muted-foreground"},MA={key:1,class:"py-6 text-center text-sm text-destructive"},RA={key:0,class:"relative overflow-hidden rounded-lg border border-border/60 bg-card"},LA={class:"flex items-center gap-2.5 border-b border-border/60 bg-muted/30 px-3 py-2"},DA={class:"text-sm font-semibold"},NA={class:"ml-auto inline-flex items-center rounded-md bg-primary/15 px-1.5 py-0.5 text-xs font-medium tabular-nums text-primary"},FA={class:"divide-y divide-border"},qA={class:"flex items-center gap-3"},BA=["aria-expanded","aria-label","onClick","onKeydown"],VA={class:"flex min-w-0 flex-1 flex-col items-start"},UA={class:"flex w-full items-center gap-1.5"},HA={class:"truncate font-mono text-sm font-medium"},jA=["title","aria-label","onClick"],WA={class:"w-full truncate text-xs text-muted-foreground"},KA={class:"flex shrink-0 items-center gap-1.5"},zA=["disabled","title","aria-label","onClick"],GA={key:0,class:"mt-2 space-y-3 rounded-md border bg-muted/30 p-2"},YA={class:"flex items-center gap-2 px-1"},XA={class:"text-xs font-semibold"},JA={class:"font-mono text-[11px] text-muted-foreground"},QA={key:0,class:"flex items-start gap-2 rounded bg-muted px-2 py-1.5 text-xs text-muted-foreground"},ZA={class:"shrink-0 font-medium"},eE={key:1,class:"px-1 py-1 text-xs text-muted-foreground"},tE={class:"w-4 shrink-0 text-right text-xs text-muted-foreground"},nE={class:"flex items-center gap-1.5 text-sm"},sE={key:2,class:"flex items-center gap-1"},oE=["value","placeholder","aria-label","title","onKeyup","onBlur"],rE=["title","onClick"],aE={key:7,class:"flex items-center gap-1"},lE=["value","placeholder","aria-label","title","onInput","onKeyup","onBlur"],iE=["title","onClick"],uE={class:"ml-auto flex items-center gap-0.5 opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100"},cE={key:0,class:"flex justify-center pt-1"},dE={class:"relative overflow-hidden rounded-lg border border-border/60 bg-card"},fE={class:"flex items-center gap-2.5 border-b border-border/60 bg-muted/30 px-3 py-2"},pE={class:"text-sm font-semibold"},mE={class:"ml-auto inline-flex items-center rounded-md bg-muted px-1.5 py-0.5 text-xs font-medium tabular-nums text-muted-foreground"},hE={key:0},vE={key:0,class:"py-3 text-center text-xs text-muted-foreground"},gE={key:1,class:"divide-y divide-border"},yE=["aria-expanded","aria-label","onClick"],bE={class:"text-sm font-medium"},_E={class:"inline-flex items-center rounded-md bg-muted px-1.5 py-0.5 text-xs font-medium tabular-nums text-muted-foreground"},wE={key:0,class:"divide-y divide-border/50 bg-muted/10"},xE={class:"flex min-w-0 items-center gap-1.5"},kE={class:"truncate font-mono text-sm"},CE=["title","aria-label","onClick"],SE={class:"flex shrink-0 items-center gap-1.5"},AE=["disabled","title","aria-label","onClick"],EE=8,OE=Q({__name:"Models",setup(e){const{t}=Wt(),n=["openai","anthropic","responses"],s=L([]),o=L([]),r=L(""),l=L(!1),i=L(""),u=L(!0),c=L(new Set),d=L(!1),f=L(!1),p=L(!1),m=L(!1),b=L({}),C=L({}),E=L({}),y=L({}),k=L({}),I=L({}),v=L({}),$=L({}),T=L(""),A=L(null),R=L(!1),V={mounted:B=>B.focus()},J=L(null),fe=L(!1),X=encodeURIComponent;async function ce(){l.value=!0,r.value="";try{const[B,F]=await Promise.all([He("GET","/admin/models"),He("GET","/admin/providers")]);s.value=B.models,o.value=F.providers}catch(B){r.value=B.message}finally{l.value=!1}}const be=Y(()=>new Map(o.value.map(B=>[B.id,B]))),Z=Y(()=>{const B=new Map;for(const F of o.value)for(const te of F.discoveredModels??[]){const D=B.get(te);D?D.push(F.id):B.set(te,[F.id])}return B}),ue=Y(()=>{const B=new Set;for(const te of o.value)for(const D of te.discoveredModels??[])B.add(D);for(const te of s.value)B.add(te.name);const F=te=>({enabled:(te==null?void 0:te.enabled)??!1,chain:((te==null?void 0:te.providers)??[]).map(D=>({id:D.id,name:D.name,model:D.model}))});return[...B].map(te=>{const D=s.value.find(Se=>Se.name===te),_e=(Z.value.get(te)??[]).map(Se=>be.value.get(Se)).filter(Se=>!!Se).map(Se=>({id:Se.id,name:Se.name,formats:Se.formats,supportsResponses:Se.supportsResponses}));return{name:te,openai:F(D==null?void 0:D.openai),anthropic:F(D==null?void 0:D.anthropic),responses:F(D==null?void 0:D.responses),offering:_e}})});function de(B){return n.filter(F=>B[F].enabled)}function se(B){return n.filter(F=>B.offering.some(te=>oe(te,F)))}function re(B){return se(B).filter(F=>!B[F].enabled)}function q(B,F){return B[F].enabled?"enabled":se(B).includes(F)?"enableable":"unsupported"}function pe(B,F){return B.offering.filter(te=>oe(te,F)).map(te=>te.id)}const ee=Y(()=>{const B=i.value.trim().toLowerCase();return ue.value.filter(F=>!B||F.name.toLowerCase().includes(B))}),Ze=Y(()=>ee.value.filter(B=>B.openai.enabled||B.anthropic.enabled||B.responses.enabled)),Ve=Y(()=>ee.value.filter(B=>!(B.openai.enabled||B.anthropic.enabled||B.responses.enabled)&&se(B).length>0)),$e=["embed","whisper","tts","dall-e","dall_e","image","moderation","audio","transcribe","rerank","realtime","sora"];function Be(B){const F=B.toLowerCase();return $e.some(te=>F.includes(te))}const Ue=L(!0),rt=Y(()=>Ve.value.filter(B=>Be(B.name)).length),Re=Y(()=>Ue.value?Ve.value.filter(B=>!Be(B.name)):Ve.value),ut=Y(()=>{const B=[];for(const F of o.value){const te=Re.value.filter(D=>D.offering.some(_e=>_e.id===F.id)).sort((D,_e)=>D.name.localeCompare(_e.name));te.length&&B.push({source:F,rows:te})}return B}),ge=L({});function w(B,F){return i.value.trim()?!0:B in ge.value?ge.value[B]:F<=EE}function M(B,F){i.value.trim()||(ge.value={...ge.value,[B]:!w(B,F)})}function W(B){const F=de(B);return o.value.filter(te=>F.some(D=>oe(te,D)))}function le(B){const F={};for(const te of n)F[te]=B[te].chain.map(D=>D.id);return F}function oe(B,F){return F==="responses"?!!B.supportsResponses:B.formats.includes(F)}const ne={openai:{key:"models.fmtOpenai",chip:"models.fmtOpenaiShort",endpoint:"/chat/completions"},anthropic:{key:"models.fmtAnthropic",chip:"models.fmtAnthropicShort",endpoint:"/messages"},responses:{key:"models.fmtResponses",chip:"models.fmtResponsesShort",endpoint:"/responses"}};function O(B){return c.value.has(B)}function P(B){const F=new Set(c.value);F.has(B)?F.delete(B):F.add(B),c.value=F}async function U(B){const F=await Yi(B);Me(t(F?"connect.copied":"connect.copyFailed"),F?"success":"error")}function j(B,F){B.target===B.currentTarget&&(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),P(F))}function he(B){return B.length?B.map(F=>F.name).join(" → "):t("models.noSourcesShort")}function ae(B){return de(B).map(F=>`${t(ne[F].chip)}: ${he(B[F].chain)}`).join(" · ")}function H(B,F){const te=B[F].chain;if(!te.length)return!1;const D=_e=>{var Se;return((Se=be.value.get(_e))==null?void 0:Se.discoveredModels)??[]};return!te.some(_e=>D(_e.id).includes(_e.model??B.name))&&te.some(_e=>D(_e.id).length>0)}function G(B){return de(B).some(F=>H(B,F))}function ve(B){let F=!1,te=null,D=null;for(const _e of de(B)){const Se=`${B.name}:${_e}`;y.value[Se]&&(F=!0);const at=v.value[Se];at!=null&&at.ok&&!te?te=at:at&&!at.ok&&!D&&(D=at)}return F?{state:"testing"}:te?{state:"ok",provider:te.provider}:D?{state:"fail",status:D.status,error:D.error}:null}function Ee(B,F){const te=q(B,F);return te==="enabled"?`border-transparent ${tn[F].solid} text-white shadow-sm`:te==="enableable"?"border-dashed border-input text-muted-foreground hover:bg-accent hover:text-accent-foreground":"border-transparent text-muted-foreground/40"}function Le(B,F){const te=q(B,F);return te==="enabled"?`${t(ne[F].key)} · ${t("models.chipOn")}`:te==="enableable"?`${t(ne[F].key)} · ${t("models.chipOff")}`:`${t(ne[F].key)} · ${t("models.chipNa")}`}async function Je(B,F){B[F].enabled?await Zt(B,F):await We(B,F)}async function We(B,F){const te=`${B.name}:${F}`;C.value[te]=!0;const D=B.offering.filter(at=>oe(at,F)),_e=D.map(at=>({id:at.id,name:at.name})),Se=s.value.find(at=>at.name===B.name);if(Se){Se[F].enabled=!0;for(const at of _e)Se[F].providers.find(Is=>Is.id===at.id)||Se[F].providers.push(at)}else s.value.push({name:B.name,openai:{enabled:F==="openai",providers:F==="openai"?_e:[]},anthropic:{enabled:F==="anthropic",providers:F==="anthropic"?_e:[]},responses:{enabled:F==="responses",providers:F==="responses"?_e:[]}});try{await He("POST","/admin/models",{name:B.name,format:F,providers:D.map(at=>at.id)}),Me(t("models.enabledToast",{name:`${B.name} [${F}]`}),"success")}catch(at){await ce(),Me(at.message,"error")}finally{C.value[te]=!1}}async function Kt(){if(f.value)return;f.value=!0;const B=[];for(const D of Re.value)for(const _e of re(D))B.push({name:D.name,fmt:_e,providers:pe(D,_e)});for(const D of B)C.value[`${D.name}:${D.fmt}`]=!0;const F=await Promise.allSettled(B.map(D=>He("POST","/admin/models",{name:D.name,format:D.fmt,providers:D.providers})));for(const D of B)C.value[`${D.name}:${D.fmt}`]=!1;if(await ce(),f.value=!1,!B.length)return;const te=F.filter(D=>D.status==="rejected").length;te?te===B.length?Me(t("models.enableAllFailed"),"error"):Me(t("models.enableAllPartial",{failed:te}),"error"):Me(t("models.enableAllDone"),"success")}async function Zt(B,F){const te=s.value.find(D=>D.name===B.name);te&&(te[F].enabled=!1);try{await He("POST",`/admin/models/${X(B.name)}/disable`,{format:F}),Me(t("models.disabledToast",{name:`${B.name} [${F}]`}),"success")}catch(D){await ce(),Me(D.message,"error")}}function Ps(B){J.value=B,fe.value=!0}async function Sr(B,F){const te=`${B.name}:${F}`;if(!y.value[te]){y.value[te]=!0;try{const D=await He("POST",`/admin/models/${X(B.name)}/test?format=${F}`);v.value[te]=D.result}catch(D){v.value[te]={ok:!1,status:0,format:F,error:D.message}}finally{y.value[te]=!1}}}async function qt(B){const F=de(B);F.length&&await Promise.all(F.map(te=>Sr(B,te)))}async function rn(B,F,te){const D=`${B.name}:${F}:${te}`;if(!k.value[D]){k.value[D]=!0;try{const _e=await He("POST",`/admin/models/${X(B.name)}/providers/test?format=${F}&index=${te}`);I.value[D]=_e.result}catch(_e){I.value[D]={ok:!1,status:0,format:F,error:_e.message}}finally{k.value[D]=!1}}}async function Ar(){const B=J.value;if(B){b.value[B.name]=!0;try{await He("DELETE",`/admin/models/${X(B.name)}`),s.value=s.value.filter(F=>F.name!==B.name),Me(t("models.removedToast",{name:B.name}),"success"),fe.value=!1}catch(F){Me(F.message,"error")}finally{b.value[B.name]=!1}}}async function Ao(B,F,te){const D=s.value.find(Se=>Se.name===B.name);if(!D)return;const _e=D[te].providers.slice();D[te].providers=F.map(Se=>_e[Se]);try{await He("PUT",`/admin/models/${X(B.name)}/priority`,{format:te,order:F})}catch(Se){D[te].providers=_e,Me(Se.message,"error")}}function Lm(B,F,te){if(F===0)return;const D=B[te].chain.map((_e,Se)=>Se);[D[F-1],D[F]]=[D[F],D[F-1]],Ao(B,D,te)}function Dm(B,F,te){if(F>=B[te].chain.length-1)return;const D=B[te].chain.map((_e,Se)=>Se);[D[F+1],D[F]]=[D[F],D[F+1]],Ao(B,D,te)}function Nm(B){A.value=B,R.value=!0}function Qs(B,F,te){return`${B.name}:${F}:${te}`}function Fm(B,F,te){return T.value===Qs(B,F,te)}function yu(B,F,te,D){const _e=Qs(B,F,D);$.value[_e]=te.model??"",T.value=_e}function qm(B,F,te){return $.value[Qs(B,F,te)]??""}function Bm(B,F,te,D){$.value[Qs(B,F,te)]=D}async function Vm(B,F,te,D){const _e=Qs(B,F,D);T.value="";const Se=($.value[_e]??"").trim(),at=(te.model??"").trim();if(Se===at)return;const Is=s.value.find(Zs=>Zs.name===B.name);Is&&(Is[F].providers[D].model=Se||void 0),$.value[_e]=Se;try{await He("PUT",`/admin/models/${X(B.name)}/map`,{format:F,index:D,model:Se}),Me(t("models.mapSaved"),"success")}catch(Zs){await ce(),Me(Zs.message,"error")}}function Um(B,F,te,D,_e){$.value[Qs(B,F,D)]=te.model??"",_e.blur()}const el=L(""),Eo=L("");function $s(B){var F;return((F=be.value.get(B))==null?void 0:F.rpm)??0}function Hm(B){return el.value===B.id}function bu(B){el.value=B.id,Eo.value=$s(B.id)?String($s(B.id)):""}function jm(B){Eo.value=B}async function Wm(B,F){const te=be.value.get(B);te&&await He("PUT",`/admin/providers/${B}`,{name:te.name,baseUrlOpenai:te.baseUrlOpenai,baseUrlAnthropic:te.baseUrlAnthropic,formats:te.formats,supportsResponses:te.supportsResponses??!1,rpm:F})}async function Km(B){const F=B.id;el.value="";const te=Number(Eo.value),D=Number.isFinite(te)&&te>0?Math.floor(te):0;if(D!==$s(F))try{await Wm(F,D),o.value=o.value.map(_e=>_e.id===F?{..._e,rpm:D}:_e),Me(D?t("sources.rpmSaved",{n:D}):t("sources.rpmCleared"),D?"success":"default")}catch(_e){Me(_e.message,"error")}}function zm(B,F){Eo.value=$s(B.id)?String($s(B.id)):"",F.blur()}async function Gm(B,F,te){const D=`${B.name}:${F}:${te}`;if(E.value[D])return;E.value[D]=!0;const _e=s.value.find(Se=>Se.name===B.name);_e&&_e[F].providers.splice(te,1);try{await He("DELETE",`/admin/models/${X(B.name)}/providers?format=${F}&index=${te}`),Me(t("models.sourceRemoved"),"success")}catch(Se){await ce(),Me(Se.message,"error")}finally{E.value[D]=!1}}async function Ym(){if(d.value||!o.value.length)return;d.value=!0;const B=o.value,F=await Promise.allSettled(B.map(D=>He("POST",`/admin/providers/${D.id}/discover`)));await ce();const te=F.map((D,_e)=>D.status==="rejected"?B[_e].name:null).filter(D=>!!D);te.length?te.length===B.length?Me(t("sources.refreshAllFailed"),"error"):Me(t("sources.refreshAllPartial",{failed:te.join("、")}),"error"):Me(t("sources.refreshAllDone"),"success"),d.value=!1}return pt(ce),(B,F)=>{var te;return _(),K("div",CA,[!l.value&&!o.value.length?(_(),N(a(mn),{key:0},{default:g(()=>[h(a(hn),{class:"flex flex-col items-center gap-3 py-12 text-center"},{default:g(()=>[x("span",SA,[h(a(yi),{class:"h-5 w-5"})]),x("div",AA,[x("div",EA,S(a(t)("models.empty")),1),x("p",OA,S(a(t)("models.emptyHint")),1)]),h(a(Ie),{onClick:F[0]||(F[0]=D=>p.value=!0)},{default:g(()=>[h(a(ts),{class:"h-4 w-4"}),z(S(a(t)("models.addSource")),1)]),_:1})]),_:1})]),_:1})):(_(),N(a(mn),{key:1},{default:g(()=>[h(a(Mn),null,{default:g(()=>[h(a(Rn),{class:"flex items-center gap-2 text-base"},{default:g(()=>[h(a(Am),{class:"h-4 w-4 text-primary"}),z(" "+S(a(t)("models.title")),1)]),_:1}),h(a(ys),null,{default:g(()=>[z(S(a(t)("models.desc")),1)]),_:1})]),_:1}),h(a(hn),{class:"space-y-4"},{default:g(()=>[x("div",TA,[x("div",PA,[h(a($m),{class:"absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),h(a(vt),{modelValue:i.value,"onUpdate:modelValue":F[1]||(F[1]=D=>i.value=D),placeholder:a(t)("models.searchPh"),class:"pl-8"},null,8,["modelValue","placeholder"])]),h(a(Ie),{size:"sm",onClick:F[2]||(F[2]=D=>m.value=!0)},{default:g(()=>[h(a(ts),{class:"h-4 w-4"}),z(S(a(t)("models.addModels")),1)]),_:1}),h(a(Ie),{variant:"outline",size:"sm",onClick:F[3]||(F[3]=D=>p.value=!0)},{default:g(()=>[h(a(yi),{class:"h-4 w-4"}),z(S(a(t)("models.manageSources")),1)]),_:1})]),x("p",$A,S(a(t)("models.chipLegend")),1),l.value?(_(),K("p",IA,S(a(t)("common.loading")),1)):r.value?(_(),K("p",MA,S(r.value),1)):(_(),K(Ce,{key:2},[Ze.value.length?(_(),K("section",RA,[F[16]||(F[16]=x("div",{class:"pointer-events-none absolute inset-y-0 left-0 w-1 bg-primary","aria-hidden":"true"},null,-1)),x("div",LA,[F[13]||(F[13]=x("span",{class:"h-2 w-2 shrink-0 rounded-full bg-primary"},null,-1)),x("span",DA,S(a(t)("models.enabledSection")),1),x("span",NA,S(Ze.value.length),1)]),x("div",FA,[(_(!0),K(Ce,null,st(Ze.value,D=>{var _e,Se,at,Is,Zs;return _(),K("div",{key:D.name,class:"px-3 py-2.5"},[x("div",qA,[x("div",{role:"button",tabindex:"0",class:"flex min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-md text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background","aria-expanded":O(D.name),"aria-label":O(D.name)?a(t)("models.collapseAria"):a(t)("models.expandAria"),onClick:Oe=>P(D.name),onKeydown:Oe=>j(Oe,D.name)},[h(a(vi),{class:ke(["h-4 w-4 shrink-0 text-muted-foreground transition-transform",{"rotate-90":O(D.name)}])},null,8,["class"]),x("span",VA,[x("span",UA,[x("span",HA,S(D.name),1),x("button",{type:"button",title:a(t)("connect.copy"),"aria-label":a(t)("connect.copy"),class:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground/50 transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:Gt(Oe=>U(D.name),["stop"])},[h(a(Jn),{class:"h-3 w-3"})],8,jA),((_e=ve(D))==null?void 0:_e.state)==="testing"?(_(),N(a(_t),{key:0,variant:"muted",class:"gap-1"},{default:g(()=>[h(a(St),{class:"h-3 w-3 animate-spin"}),z(S(a(t)("models.probeTesting")),1)]),_:1})):((Se=ve(D))==null?void 0:Se.state)==="ok"?(_(),N(a(_t),{key:1,variant:"success",title:a(t)("models.probeOkHint",{name:((at=ve(D))==null?void 0:at.provider)??""})},{default:g(()=>[z(S(a(t)("models.probeOk")),1)]),_:1},8,["title"])):((Is=ve(D))==null?void 0:Is.state)==="fail"?(_(),N(a(_t),{key:2,variant:"destructive",title:((Zs=ve(D))==null?void 0:Zs.error)||a(t)("models.probeFailHint")},{default:g(()=>{var Oe;return[z(S(a(t)("models.probeFail"))+" · "+S(((Oe=ve(D))==null?void 0:Oe.status)||"?"),1)]}),_:2},1032,["title"])):G(D)?(_(),N(a(_t),{key:3,variant:"secondary",title:a(t)("models.delistedHint")},{default:g(()=>[z(S(a(t)("models.delisted")),1)]),_:1},8,["title"])):me("",!0)]),x("span",WA,S(ae(D)),1)])],40,BA),x("div",KA,[(_(),K(Ce,null,st(n,Oe=>x("button",{key:Oe,type:"button",disabled:q(D,Oe)==="unsupported"||C.value[`${D.name}:${Oe}`],title:Le(D,Oe),"aria-label":Le(D,Oe),class:ke(["inline-flex items-center gap-1 rounded-md border px-2 py-0.5 text-xs font-medium transition-colors disabled:cursor-not-allowed",Ee(D,Oe)]),onClick:ht=>Je(D,Oe)},[C.value[`${D.name}:${Oe}`]?(_(),N(a(St),{key:0,class:"h-3 w-3 animate-spin"})):(_(),K("span",{key:1,class:ke(["rounded-full",q(D,Oe)==="enabled"?"h-1.5 w-1.5 bg-current":q(D,Oe)==="enableable"?"h-1.5 w-1.5 border border-current":"h-1.5 w-1.5"])},null,2)),z(" "+S(a(t)(ne[Oe].chip)),1)],10,zA)),64))]),h(a(fi),null,{default:g(()=>[h(a(pi),null,{default:g(()=>[h(a(Ie),{variant:"ghost",size:"icon",class:"h-8 w-8 shrink-0 text-muted-foreground","aria-label":a(t)("models.moreActions")},{default:g(()=>[h(a(gi),{class:"h-4 w-4"})]),_:1},8,["aria-label"])]),_:1}),h(a(mi),{align:"end"},{default:g(()=>{var Oe;return[h(a(Wn),{disabled:((Oe=ve(D))==null?void 0:Oe.state)==="testing"||!de(D).length,onSelect:ht=>qt(D)},{default:g(()=>{var ht;return[((ht=ve(D))==null?void 0:ht.state)==="testing"?(_(),N(a(St),{key:0,class:"animate-spin"})):(_(),N(a(El),{key:1})),z(" "+S(a(t)("models.testModel")),1)]}),_:2},1032,["disabled","onSelect"]),h(a(hi)),h(a(Wn),{class:"text-destructive focus:bg-destructive/10 focus:text-destructive",onSelect:ht=>Ps(D)},{default:g(()=>[h(a(bi)),z(" "+S(a(t)("models.removeModel")),1)]),_:1},8,["onSelect"])]}),_:2},1024)]),_:2},1024)]),O(D.name)?(_(),K("div",GA,[(_(!0),K(Ce,null,st(de(D),Oe=>(_(),K("div",{key:Oe,class:"space-y-1"},[x("div",YA,[x("span",{class:ke(["h-2 w-2 rounded-full",a(tn)[Oe].solid])},null,2),x("span",XA,S(a(t)(ne[Oe].key)),1),x("span",JA,S(ne[Oe].endpoint),1)]),H(D,Oe)?(_(),K("div",QA,[x("span",ZA,S(a(t)("models.delisted")),1),x("span",null,S(a(t)("models.delistedHint")),1)])):me("",!0),D[Oe].chain.length?me("",!0):(_(),K("div",eE,S(a(t)("models.noSources")),1)),(_(!0),K(Ce,null,st(D[Oe].chain,(ht,mt)=>{var _u,wu;return _(),K("div",{key:mt,class:"group flex items-center gap-2 rounded px-1 py-1 hover:bg-muted/40"},[x("span",tE,S(mt+1)+".",1),x("span",nE,[x("span",{class:ke(["h-1.5 w-1.5 rounded-full",a(ei)(ht.id).solid])},null,2),z(" "+S(ht.name),1)]),mt===0?(_(),N(a(_t),{key:0,variant:"default"},{default:g(()=>[z(S(a(t)("models.primary")),1)]),_:1})):(_(),N(a(_t),{key:1,variant:"muted"},{default:g(()=>[z(S(a(t)("models.fallback")),1)]),_:1})),Hm(ht)?(_(),K("span",sE,[h(a(Ko),{class:"h-3 w-3 text-muted-foreground"}),yo(x("input",{type:"number",min:"0",inputmode:"numeric",value:Eo.value,placeholder:a(t)("sources.rpmPh"),"aria-label":a(t)("sources.rpmLabel"),title:a(t)("sources.rpmHint"),class:"h-6 w-16 rounded-md border border-input bg-background px-2 font-mono text-xs shadow-sm transition-colors placeholder:font-sans placeholder:text-muted-foreground/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",onInput:F[4]||(F[4]=ct=>jm(ct.target.value)),onKeyup:[F[5]||(F[5]=Vs(ct=>ct.target.blur(),["enter"])),Vs(ct=>zm(ht,ct.target),["esc"])],onBlur:ct=>Km(ht)},null,40,oE),[[V]])])):$s(ht.id)>0?(_(),K("button",{key:3,type:"button",title:a(t)("sources.rpmBadgeHint"),class:"inline-flex items-center gap-1 rounded-full border border-input bg-background px-2 py-0.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:ct=>bu(ht)},[h(a(Ko),{class:"h-3 w-3"}),z(" "+S(a(t)("sources.rpmBadge",{n:$s(ht.id)})),1)],8,rE)):me("",!0),k.value[`${D.name}:${Oe}:${mt}`]?(_(),N(a(_t),{key:4,variant:"muted",class:"gap-1"},{default:g(()=>[h(a(St),{class:"h-3 w-3 animate-spin"}),z(S(a(t)("models.probeTesting")),1)]),_:1})):(_u=I.value[`${D.name}:${Oe}:${mt}`])!=null&&_u.ok?(_(),N(a(_t),{key:5,variant:"success",title:a(t)("models.probeOkHint",{name:ht.name})},{default:g(()=>[z(S(a(t)("models.probeOk")),1)]),_:1},8,["title"])):I.value[`${D.name}:${Oe}:${mt}`]?(_(),N(a(_t),{key:6,variant:"destructive",title:((wu=I.value[`${D.name}:${Oe}:${mt}`])==null?void 0:wu.error)||a(t)("models.probeFailHint")},{default:g(()=>{var ct;return[z(S(a(t)("models.probeFail"))+" · "+S(((ct=I.value[`${D.name}:${Oe}:${mt}`])==null?void 0:ct.status)||"?"),1)]}),_:2},1032,["title"])):me("",!0),Fm(D,Oe,mt)?(_(),K("div",aE,[F[14]||(F[14]=x("span",{class:"text-xs text-muted-foreground"},"→",-1)),yo(x("input",{type:"text",value:qm(D,Oe,mt),placeholder:a(t)("models.upstreamPh"),"aria-label":a(t)("models.upstreamLabel"),title:a(t)("models.upstreamHint"),spellcheck:"false",class:"h-6 w-40 rounded-md border border-input bg-background px-2 font-mono text-xs shadow-sm transition-colors placeholder:font-sans placeholder:text-muted-foreground/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",onInput:ct=>Bm(D,Oe,mt,ct.target.value),onKeyup:[F[6]||(F[6]=Vs(ct=>ct.target.blur(),["enter"])),Vs(ct=>Um(D,Oe,ht,mt,ct.target),["esc"])],onBlur:ct=>Vm(D,Oe,ht,mt)},null,40,lE),[[V]])])):ht.model?(_(),K("button",{key:8,type:"button",title:a(t)("models.upstreamHint"),class:"inline-flex items-center gap-1 rounded border border-transparent px-1.5 py-0.5 font-mono text-xs text-muted-foreground transition-colors hover:border-border hover:bg-background hover:text-foreground",onClick:ct=>yu(D,Oe,ht,mt)},[F[15]||(F[15]=x("span",null,"→",-1)),z(S(ht.model),1)],8,iE)):me("",!0),x("div",uE,[h(a(Ie),{variant:"ghost",size:"icon",class:"h-7 w-7",disabled:mt===0,"aria-label":a(t)("models.moveUpAria"),onClick:ct=>Lm(D,mt,Oe)},{default:g(()=>[h(a(Xk),{class:"h-4 w-4"})]),_:1},8,["disabled","aria-label","onClick"]),h(a(Ie),{variant:"ghost",size:"icon",class:"h-7 w-7",disabled:mt===D[Oe].chain.length-1,"aria-label":a(t)("models.moveDownAria"),onClick:ct=>Dm(D,mt,Oe)},{default:g(()=>[h(a(Yk),{class:"h-4 w-4"})]),_:1},8,["disabled","aria-label","onClick"]),h(a(fi),null,{default:g(()=>[h(a(pi),null,{default:g(()=>[h(a(Ie),{variant:"ghost",size:"icon",class:"h-7 w-7 text-muted-foreground","aria-label":a(t)("models.moreActions")},{default:g(()=>[h(a(gi),{class:"h-4 w-4"})]),_:1},8,["aria-label"])]),_:1}),h(a(mi),{align:"end"},{default:g(()=>[h(a(Wn),{disabled:k.value[`${D.name}:${Oe}:${mt}`],onSelect:ct=>rn(D,Oe,mt)},{default:g(()=>[k.value[`${D.name}:${Oe}:${mt}`]?(_(),N(a(St),{key:0,class:"animate-spin"})):(_(),N(a(El),{key:1})),z(" "+S(a(t)("models.testSource")),1)]),_:2},1032,["disabled","onSelect"]),h(a(Wn),{onSelect:ct=>yu(D,Oe,ht,mt)},{default:g(()=>[h(a(Tm),{class:"h-4 w-4"}),z(" "+S(a(t)("models.editUpstream")),1)]),_:1},8,["onSelect"]),h(a(Wn),{onSelect:ct=>bu(ht)},{default:g(()=>[h(a(Ko),{class:"h-4 w-4"}),z(" "+S(a(t)("sources.rpmLabel")),1)]),_:1},8,["onSelect"]),h(a(hi)),h(a(Wn),{class:"text-destructive focus:bg-destructive/10 focus:text-destructive",onSelect:ct=>Gm(D,Oe,mt)},{default:g(()=>[h(a(bi),{class:"h-4 w-4"}),z(" "+S(a(t)("models.removeSource")),1)]),_:1},8,["onSelect"])]),_:2},1024)]),_:2},1024)])])}),128))]))),128)),W(D).length?(_(),K("div",cE,[h(a(Ie),{variant:"outline",size:"sm",class:"h-7 gap-1 border-dashed text-muted-foreground",onClick:Oe=>Nm(D)},{default:g(()=>[h(a(ts),{class:"h-3.5 w-3.5"}),z(" "+S(a(t)("models.addSourceToChain")),1)]),_:1},8,["onClick"])])):me("",!0)])):me("",!0)])}),128))])])):me("",!0),x("section",dE,[F[18]||(F[18]=x("div",{class:"pointer-events-none absolute inset-y-0 left-0 w-1 bg-muted-foreground/40","aria-hidden":"true"},null,-1)),x("div",fE,[x("button",{type:"button",class:"flex min-w-0 flex-1 items-center gap-2.5 rounded px-1 py-0.5 text-left hover:bg-muted/50",onClick:F[7]||(F[7]=D=>u.value=!u.value)},[h(a(Ya),{class:ke(["h-4 w-4 shrink-0 text-muted-foreground transition-transform",{"-rotate-90":!u.value}])},null,8,["class"]),F[17]||(F[17]=x("span",{class:"h-2 w-2 shrink-0 rounded-full bg-muted-foreground/40"},null,-1)),x("span",pE,S(a(t)("models.availableSection")),1),x("span",mE,S(Re.value.length),1)]),rt.value>0?(_(),N(a(Ie),{key:0,variant:"ghost",size:"sm",class:ke(["h-7 gap-1.5 px-2.5",Ue.value?"bg-accent text-accent-foreground":"text-muted-foreground"]),title:Ue.value?a(t)("models.filterChatHint",{n:rt.value}):a(t)("models.filterAllHint"),onClick:F[8]||(F[8]=D=>Ue.value=!Ue.value)},{default:g(()=>[h(a(Em),{class:"h-3.5 w-3.5"}),z(" "+S(Ue.value?a(t)("models.filterChatOnly"):a(t)("models.filterInclude")),1)]),_:1},8,["class","title"])):me("",!0),h(a(Ie),{variant:"ghost",size:"sm",class:"h-7 gap-1.5 px-2.5",disabled:d.value,title:a(t)("sources.refreshAll"),onClick:Ym},{default:g(()=>[d.value?(_(),N(a(St),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(_(),N(a(mr),{key:1,class:"h-3.5 w-3.5"})),z(" "+S(a(t)("sources.refreshAll")),1)]),_:1},8,["disabled","title"]),Re.value.length?(_(),N(a(Ie),{key:1,size:"sm",variant:"secondary",class:"h-7 gap-1.5 px-2.5",disabled:f.value,onClick:Kt},{default:g(()=>[f.value?(_(),N(a(St),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(_(),N(a(El),{key:1,class:"h-3.5 w-3.5"})),z(" "+S(a(t)("models.enableAll")),1)]),_:1},8,["disabled"])):me("",!0)]),u.value?(_(),K("div",hE,[Re.value.length?(_(),K("div",gE,[(_(!0),K(Ce,null,st(ut.value,D=>(_(),K("div",{key:D.source.id},[x("button",{type:"button",class:"flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-muted/40","aria-expanded":w(D.source.id,D.rows.length),"aria-label":D.source.name,onClick:_e=>M(D.source.id,D.rows.length)},[h(a(vi),{class:ke(["h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform",{"rotate-90":w(D.source.id,D.rows.length)}])},null,8,["class"]),x("span",{class:ke(["h-1.5 w-1.5 shrink-0 rounded-full",a(ei)(D.source.id).solid])},null,2),x("span",bE,S(D.source.name),1),x("span",_E,S(D.rows.length),1)],8,yE),w(D.source.id,D.rows.length)?(_(),K("div",wE,[(_(!0),K(Ce,null,st(D.rows,_e=>(_(),K("div",{key:_e.name,class:"flex items-center justify-between gap-2 px-3 py-2 pl-9"},[x("div",xE,[x("span",kE,S(_e.name),1),x("button",{type:"button",title:a(t)("connect.copy"),"aria-label":a(t)("connect.copy"),class:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground/50 transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:Se=>U(_e.name)},[h(a(Jn),{class:"h-3 w-3"})],8,CE)]),x("div",SE,[(_(),K(Ce,null,st(n,Se=>x("button",{key:Se,type:"button",disabled:q(_e,Se)==="unsupported"||C.value[`${_e.name}:${Se}`],title:Le(_e,Se),"aria-label":Le(_e,Se),class:ke(["inline-flex items-center gap-1 rounded-md border px-2 py-0.5 text-xs font-medium transition-colors disabled:cursor-not-allowed",Ee(_e,Se)]),onClick:at=>Je(_e,Se)},[C.value[`${_e.name}:${Se}`]?(_(),N(a(St),{key:0,class:"h-3 w-3 animate-spin"})):(_(),K("span",{key:1,class:ke(["rounded-full",q(_e,Se)==="enabled"?"h-1.5 w-1.5 bg-current":q(_e,Se)==="enableable"?"h-1.5 w-1.5 border border-current":"h-1.5 w-1.5"])},null,2)),z(" "+S(a(t)(ne[Se].chip)),1)],10,AE)),64))])]))),128))])):me("",!0)]))),128))])):(_(),K("p",vE,S(Ue.value&&Ve.value.length?a(t)("models.availableAllFiltered",{n:rt.value}):a(t)("models.availableDesc")),1))])):me("",!0)])],64))]),_:1})]),_:1})),h(pS,{open:p.value,"onUpdate:open":F[9]||(F[9]=D=>p.value=D),onChanged:ce},null,8,["open"]),h(nA,{open:m.value,"onUpdate:open":F[10]||(F[10]=D=>m.value=D),providers:o.value,onChanged:ce},null,8,["open","providers"]),h(kA,{open:R.value,"onUpdate:open":F[11]||(F[11]=D=>R.value=D),"model-name":((te=A.value)==null?void 0:te.name)??"",providers:o.value,"enabled-formats":A.value?de(A.value):[],"chain-by-format":A.value?le(A.value):{},onAdded:ce},null,8,["open","model-name","providers","enabled-formats","chain-by-format"]),h(gu,{open:fe.value,"onUpdate:open":F[12]||(F[12]=D=>fe.value=D),variant:"destructive",title:a(t)("models.removeModel"),description:J.value?a(t)("models.confirmRemove",{name:J.value.name}):"","confirm-text":a(t)("models.removeModel"),loading:J.value?!!b.value[J.value.name]:!1,onConfirm:Ar},null,8,["open","title","description","confirm-text","loading"])])}}}),TE={class:"relative w-full overflow-auto"},Im=Q({__name:"Table",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(_(),K("div",TE,[x("table",{class:ke(a(Xe)("w-full caption-bottom text-sm",t.class))},[ie(n.$slots,"default")],2)]))}}),Mm=Q({__name:"TableHeader",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(_(),K("thead",{class:ke(a(Xe)("[&_tr]:border-b",t.class))},[ie(n.$slots,"default")],2))}}),Rm=Q({__name:"TableBody",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(_(),K("tbody",{class:ke(a(Xe)("[&_tr:last-child]:border-0",t.class))},[ie(n.$slots,"default")],2))}}),uo=Q({__name:"TableRow",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(_(),K("tr",{class:ke(a(Xe)("border-b transition-colors hover:bg-muted/40 data-[state=selected]:bg-muted",t.class))},[ie(n.$slots,"default")],2))}}),zt=Q({__name:"TableHead",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(_(),K("th",{class:ke(a(Xe)("h-10 px-3 text-left align-middle text-xs font-medium uppercase tracking-wide text-muted-foreground [&:has([role=checkbox])]:pr-0",t.class))},[ie(n.$slots,"default")],2))}}),Lt=Q({__name:"TableCell",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(_(),K("td",{class:ke(a(Xe)("p-3 align-middle [&:has([role=checkbox])]:pr-0",t.class))},[ie(n.$slots,"default")],2))}}),PE=Q({__name:"Popover",props:{defaultOpen:{type:Boolean},open:{type:Boolean},modal:{type:Boolean}},emits:["update:open"],setup(e,{emit:t}){const o=Mt(e,t);return(r,l)=>(_(),N(a(mx),Tt($t(a(o))),{default:g(()=>[ie(r.$slots,"default")]),_:3},16))}}),$E=Q({__name:"PopoverTrigger",props:{asChild:{type:Boolean},as:{}},setup(e){const t=e;return(n,s)=>(_(),N(a(Sx),Tt($t(t)),{default:g(()=>[ie(n.$slots,"default")]),_:3},16))}}),IE=Q({__name:"PopoverContent",props:{forceMount:{type:Boolean},memoDependencies:{},side:{},sideOffset:{default:4},sideFlip:{type:Boolean},align:{},alignOffset:{},alignFlip:{type:Boolean},avoidCollisions:{type:Boolean},collisionBoundary:{},collisionPadding:{},arrowPadding:{},hideShiftedArrow:{type:Boolean},sticky:{},hideWhenDetached:{type:Boolean},positionStrategy:{},updatePositionStrategy:{},disableUpdateOnLayoutShift:{type:Boolean},prioritizePosition:{type:Boolean},reference:{},dir:{},asChild:{type:Boolean},as:{},disableOutsidePointerEvents:{type:Boolean},class:{type:[Boolean,null,String,Object,Array]}},emits:["escapeKeyDown","pointerDownOutside","focusOutside","interactOutside","openAutoFocus","closeAutoFocus"],setup(e,{emit:t}){const n=e,s=t,o=Y(()=>{const{class:l,...i}=n;return i}),r=Mt(o,s);return(l,i)=>(_(),N(a(kx),null,{default:g(()=>[h(a(wx),Te(a(r),{class:a(Xe)("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2",n.class)}),{default:g(()=>[ie(l.$slots,"default")]),_:3},16,["class"])]),_:3}))}}),ME={class:"flex items-center justify-between gap-2"},RE={class:"flex gap-1"},LE={class:"sr-only"},DE={class:"flex flex-wrap items-center gap-2"},NE={class:"relative flex-1 sm:max-w-sm"},FE={key:0,class:"inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[10px] font-medium text-primary-foreground"},qE={class:"space-y-2.5"},BE={class:"flex items-center justify-between"},VE={class:"text-xs font-medium"},UE={class:"space-y-2"},HE={class:"grid grid-cols-[3.5rem_1fr] items-center gap-2"},jE={class:"text-xs text-muted-foreground"},WE={class:"grid grid-cols-[3.5rem_1fr] items-center gap-2"},KE={class:"text-xs text-muted-foreground"},zE={class:"grid grid-cols-[3.5rem_1fr] items-center gap-2"},GE={class:"text-xs text-muted-foreground"},YE={key:0,class:"flex flex-wrap items-center gap-1.5"},XE={class:"text-muted-foreground"},JE={class:"font-medium"},QE=["aria-label","onClick"],ZE={class:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground"},eO={key:1,class:"space-y-2 rounded-lg border border-amber-500/30 bg-amber-500/5 p-3"},tO={class:"flex items-center gap-1.5 text-xs font-medium text-amber-700 dark:text-amber-400"},nO={class:"space-y-1.5"},sO={class:"font-medium"},oO={class:"break-all text-muted-foreground"},rO={key:2,class:"space-y-2 rounded-lg border border-orange-500/30 bg-orange-500/5 p-3"},aO={class:"flex items-center gap-1.5 text-xs font-medium text-orange-700 dark:text-orange-400"},lO={class:"space-y-1.5"},iO={class:"font-medium"},uO={class:"text-muted-foreground"},cO={key:3,class:"py-6 text-center text-sm text-muted-foreground"},dO={key:4,class:"py-6 text-center text-sm text-muted-foreground"},fO={key:5,class:"overflow-x-auto"},pO={class:"flex flex-wrap items-center gap-x-2 gap-y-1 text-xs"},mO={class:"font-mono text-muted-foreground"},hO={class:"font-medium"},vO={class:"text-muted-foreground"},gO={class:"text-muted-foreground"},yO={class:"break-all text-muted-foreground"},bO={key:0,class:"text-muted-foreground/60"},_O={class:"inline-flex items-center gap-1.5"},wO={class:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 px-2 py-2 text-xs sm:grid-cols-[auto_1fr_auto_1fr]"},xO={class:"text-muted-foreground"},kO={class:"font-mono"},CO={class:"text-muted-foreground"},SO={class:"font-mono"},AO={class:"text-muted-foreground"},EO={class:"text-muted-foreground"},OO={class:"break-all font-mono"},TO={class:"text-muted-foreground"},PO={class:"font-mono"},$O={class:"text-foreground/80"},IO={class:"text-foreground/80"},MO={class:"text-amber-600 dark:text-amber-400"},RO={class:"text-muted-foreground"},LO={class:"break-all font-mono"},bd="myapikey.logs.filters",DO=Q({__name:"Logs",setup(e){const{t}=Wt(),n=L([]),s=L(!0),o=L(!1),r=L([]),l=L([]),i=L("all"),u=L("all"),c=L("all"),d=L(""),f=L(new Set),p=L(!1);try{const q=JSON.parse(localStorage.getItem(bd)||"null");q&&(typeof q.model=="string"&&(i.value=q.model),typeof q.provider=="string"&&(u.value=q.provider),(q.status==="success"||q.status==="error")&&(c.value=q.status),typeof q.query=="string"&&(d.value=q.query))}catch{}Fe([i,u,c,d],()=>{try{localStorage.setItem(bd,JSON.stringify({model:i.value,provider:u.value,status:c.value,query:d.value}))}catch{}});let m;async function b(){o.value=!0;try{const[q,pe]=await Promise.all([He("GET","/admin/logs").catch(()=>null),He("GET","/admin/circuit").catch(()=>null)]);q&&(n.value=q.logs),pe&&(r.value=pe.providers.filter(ee=>ee.state==="cooling"),l.value=pe.providers.filter(ee=>ee.rpm>0&&ee.rpmUsed>=ee.rpm&&ee.state!=="cooling"))}finally{o.value=!1}}async function C(q){await He("POST",`/admin/circuit/${q}/reset`).catch(()=>{}),await b()}function E(){y(),m=window.setInterval(b,4e3)}function y(){m&&(clearInterval(m),m=void 0)}function k(){s.value=!s.value,s.value?(b(),E()):y()}function I(q){return q>=200&&q<300?"success":q>=400?"destructive":"muted"}function v(q){var pe;return((pe=tn[q])==null?void 0:pe.badge)??""}function $(q){return q<1e3?`${q}ms`:`${(q/1e3).toFixed(1)}s`}function T(q){return q?q<1e3?String(q):q<1e6?(q/1e3).toFixed(q<1e4?1:0).replace(/\.0$/,"")+"k":(q/1e6).toFixed(1)+"M":"0"}function A(q){if(q<=0)return"0";const pe=Math.round(q*1e3)/10;return Number.isInteger(pe)?String(pe):pe.toFixed(1)}function R(q){return new Date(q).toLocaleTimeString()}function V(q){return new Date(q).toLocaleString()}function J(q){return`${q.ts}-${q.model}-${q.provider}-${q.status}-${q.kind??"call"}`}function fe(q){return f.value.has(J(q))}function X(q){const pe=new Set(f.value),ee=J(q);pe.has(ee)?pe.delete(ee):pe.add(ee),f.value=pe}const ce=Y(()=>[...new Set(n.value.map(q=>q.model))].sort()),be=Y(()=>[...new Set(n.value.map(q=>q.provider))].sort()),Z=Y(()=>{const q=d.value.trim().toLowerCase();return n.value.filter(pe=>{var ee;return!(i.value!=="all"&&pe.model!==i.value||u.value!=="all"&&pe.provider!==u.value||c.value==="success"&&!(pe.status>=200&&pe.status<300)||c.value==="error"&&pe.status<400||q&&!(pe.model.toLowerCase().includes(q)||(ee=pe.upstreamModel)!=null&&ee.toLowerCase().includes(q)||pe.provider.toLowerCase().includes(q)))})}),ue=Y(()=>{const q=Z.value.filter(Ve=>Ve.kind!=="cooldown"),pe=q.length,ee=q.filter(Ve=>Ve.status>=400).length,Ze=pe?Math.round(q.reduce((Ve,$e)=>Ve+$e.ms,0)/pe):0;return{total:pe,fail:ee,avgMs:Ze,errorRateStr:A(pe?ee/pe:0)}}),de=Y(()=>(i.value!=="all"?1:0)+(u.value!=="all"?1:0)+(c.value!=="all"?1:0)),se=Y(()=>{const q=[];return i.value!=="all"&&q.push({key:"model",label:t("logs.filter.model"),value:i.value,clear:()=>i.value="all"}),u.value!=="all"&&q.push({key:"provider",label:t("logs.filter.provider"),value:u.value,clear:()=>u.value="all"}),c.value!=="all"&&q.push({key:"status",label:t("logs.filter.status"),value:c.value==="success"?t("logs.filter.success"):t("logs.filter.error"),clear:()=>c.value="all"}),q});function re(){i.value="all",u.value="all",c.value="all"}return pt(()=>{b(),E()}),bn(y),(q,pe)=>(_(),N(a(mn),null,{default:g(()=>[h(a(Mn),null,{default:g(()=>[x("div",ME,[h(a(Rn),{class:"flex items-center gap-2 text-base"},{default:g(()=>[h(a(Cm),{class:"h-4 w-4 text-primary"}),z(" "+S(a(t)("logs.title"))+" ",1),s.value?(_(),N(a(_t),{key:0,variant:"success",class:"gap-1.5"},{default:g(()=>[pe[5]||(pe[5]=x("span",{class:"relative flex h-1.5 w-1.5"},[x("span",{class:"absolute inline-flex h-full w-full animate-ping rounded-full bg-current opacity-75"}),x("span",{class:"relative inline-flex h-1.5 w-1.5 rounded-full bg-current"})],-1)),z(" "+S(a(t)("logs.live")),1)]),_:1})):me("",!0)]),_:1}),x("div",RE,[h(a(Ie),{variant:"outline",size:"sm",disabled:o.value,onClick:b},{default:g(()=>[o.value?(_(),N(a(St),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(_(),N(a(mr),{key:1,class:"h-3.5 w-3.5"})),x("span",LE,S(a(t)("logs.refresh")),1)]),_:1},8,["disabled"]),h(a(Ie),{variant:"outline",size:"sm","aria-pressed":s.value,onClick:k},{default:g(()=>[s.value?(_(),N(a(Jk),{key:0,class:"h-3.5 w-3.5"})):(_(),N(a(Qk),{key:1,class:"h-3.5 w-3.5"})),z(" "+S(s.value?a(t)("logs.pause"):a(t)("logs.resume")),1)]),_:1},8,["aria-pressed"])])]),h(a(ys),null,{default:g(()=>[z(S(a(t)("logs.desc")),1)]),_:1})]),_:1}),h(a(hn),{class:"space-y-3"},{default:g(()=>[x("div",DE,[x("div",NE,[h(a($m),{class:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),h(a(vt),{modelValue:d.value,"onUpdate:modelValue":pe[0]||(pe[0]=ee=>d.value=ee),placeholder:a(t)("logs.searchPh"),class:"h-8 pl-8"},null,8,["modelValue","placeholder"])]),h(a(PE),{open:p.value,"onUpdate:open":pe[4]||(pe[4]=ee=>p.value=ee)},{default:g(()=>[h(a($E),{"as-child":""},{default:g(()=>[h(a(Ie),{variant:"outline",size:"sm",class:"h-8 gap-1.5"},{default:g(()=>[h(a(Em),{class:"h-3.5 w-3.5"}),z(" "+S(a(t)("logs.filter.title"))+" ",1),de.value?(_(),K("span",FE,S(de.value),1)):me("",!0)]),_:1})]),_:1}),h(a(IE),{align:"start",class:"w-72 p-3"},{default:g(()=>[x("div",qE,[x("div",BE,[x("span",VE,S(a(t)("logs.filter.title")),1),de.value?(_(),K("button",{key:0,type:"button",class:"text-xs text-primary hover:underline",onClick:re},S(a(t)("logs.filter.clear")),1)):me("",!0)]),x("div",UE,[x("div",HE,[x("span",jE,S(a(t)("logs.filter.model")),1),h(a(zo),{modelValue:i.value,"onUpdate:modelValue":pe[1]||(pe[1]=ee=>i.value=ee)},{default:g(()=>[h(a(Go),{class:"h-8 w-full"},{default:g(()=>[h(a(Yo),{placeholder:a(t)("logs.filter.model")},null,8,["placeholder"])]),_:1}),h(a(Xo),null,{default:g(()=>[h(a(fn),{value:"all"},{default:g(()=>[z(S(a(t)("logs.filter.all")),1)]),_:1}),(_(!0),K(Ce,null,st(ce.value,ee=>(_(),N(a(fn),{key:ee,value:ee},{default:g(()=>[z(S(ee),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"])]),x("div",WE,[x("span",KE,S(a(t)("logs.filter.provider")),1),h(a(zo),{modelValue:u.value,"onUpdate:modelValue":pe[2]||(pe[2]=ee=>u.value=ee)},{default:g(()=>[h(a(Go),{class:"h-8 w-full"},{default:g(()=>[h(a(Yo),{placeholder:a(t)("logs.filter.provider")},null,8,["placeholder"])]),_:1}),h(a(Xo),null,{default:g(()=>[h(a(fn),{value:"all"},{default:g(()=>[z(S(a(t)("logs.filter.all")),1)]),_:1}),(_(!0),K(Ce,null,st(be.value,ee=>(_(),N(a(fn),{key:ee,value:ee},{default:g(()=>[z(S(ee),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"])]),x("div",zE,[x("span",GE,S(a(t)("logs.filter.status")),1),h(a(zo),{modelValue:c.value,"onUpdate:modelValue":pe[3]||(pe[3]=ee=>c.value=ee)},{default:g(()=>[h(a(Go),{class:"h-8 w-full"},{default:g(()=>[h(a(Yo),{placeholder:a(t)("logs.filter.status")},null,8,["placeholder"])]),_:1}),h(a(Xo),null,{default:g(()=>[h(a(fn),{value:"all"},{default:g(()=>[z(S(a(t)("logs.filter.all")),1)]),_:1}),h(a(fn),{value:"success"},{default:g(()=>[z(S(a(t)("logs.filter.success")),1)]),_:1}),h(a(fn),{value:"error"},{default:g(()=>[z(S(a(t)("logs.filter.error")),1)]),_:1})]),_:1})]),_:1},8,["modelValue"])])])])]),_:1})]),_:1},8,["open"])]),se.value.length?(_(),K("div",YE,[(_(!0),K(Ce,null,st(se.value,ee=>(_(),K("span",{key:ee.key,class:"inline-flex items-center gap-1 rounded-full border border-input bg-muted/40 py-0.5 pl-2.5 pr-1 text-xs"},[x("span",XE,S(ee.label)+":",1),x("span",JE,S(ee.value),1),x("button",{type:"button",class:"rounded-full p-0.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground","aria-label":a(t)("logs.filter.remove",{label:ee.label}),onClick:ee.clear},[h(a(vu),{class:"h-3 w-3"})],8,QE)]))),128)),x("button",{type:"button",class:"text-xs text-muted-foreground hover:text-foreground",onClick:re},S(a(t)("logs.filter.clear")),1)])):me("",!0),x("div",ZE,[x("span",null,S(a(t)("logs.summary.window",{n:ue.value.total})),1),x("span",{class:ke({"text-destructive":ue.value.fail>0})},S(a(t)("logs.summary.errorRate",{pct:ue.value.errorRateStr})),3),x("span",null,S(a(t)("logs.summary.avgLatency",{ms:$(ue.value.avgMs)})),1)]),r.value.length?(_(),K("div",eO,[x("div",tO,[h(a(Al),{class:"h-4 w-4"}),z(" "+S(a(t)("logs.circuit.stripTitle")),1)]),x("ul",nO,[(_(!0),K(Ce,null,st(r.value,ee=>(_(),K("li",{key:ee.id,class:"flex flex-wrap items-center gap-x-2 gap-y-1 text-xs"},[x("span",sO,S(ee.name),1),h(a(_t),{variant:"warning",class:"gap-1 whitespace-nowrap"},{default:g(()=>[h(a(Al),{class:"h-3 w-3"}),z(" "+S(a(t)("logs.circuit.remaining",{s:ee.secondsLeft})),1)]),_:2},1024),x("span",oO,S(ee.lastReason||a(t)("logs.circuit.reasonUnknown")),1),h(a(Ie),{variant:"outline",size:"sm",class:"ml-auto h-6 gap-1",onClick:Ze=>C(ee.id)},{default:g(()=>[h(a(mr),{class:"h-3 w-3"}),z(" "+S(a(t)("logs.circuit.reset")),1)]),_:1},8,["onClick"])]))),128))])])):me("",!0),l.value.length?(_(),K("div",rO,[x("div",aO,[h(a(Ko),{class:"h-4 w-4"}),z(" "+S(a(t)("logs.pacing.stripTitle")),1)]),x("ul",lO,[(_(!0),K(Ce,null,st(l.value,ee=>(_(),K("li",{key:ee.id,class:"flex flex-wrap items-center gap-x-2 gap-y-1 text-xs"},[x("span",iO,S(ee.name),1),h(a(_t),{variant:"outline",class:"gap-1 whitespace-nowrap"},{default:g(()=>[h(a(Ko),{class:"h-3 w-3"}),z(" "+S(a(t)("logs.pacing.at",{used:ee.rpmUsed,cap:ee.rpm})),1)]),_:2},1024),x("span",uO,S(a(t)("logs.pacing.reason")),1)]))),128))])])):me("",!0),n.value.length?Z.value.length?(_(),K("div",fO,[h(a(Im),null,{default:g(()=>[h(a(Mm),null,{default:g(()=>[h(a(uo),null,{default:g(()=>[h(a(zt),{class:"w-8"}),h(a(zt),null,{default:g(()=>[z(S(a(t)("logs.col.time")),1)]),_:1}),h(a(zt),null,{default:g(()=>[z(S(a(t)("logs.col.model")),1)]),_:1}),h(a(zt),null,{default:g(()=>[z(S(a(t)("logs.col.provider")),1)]),_:1}),h(a(zt),null,{default:g(()=>[z(S(a(t)("logs.col.format")),1)]),_:1}),h(a(zt),{class:"text-right"},{default:g(()=>[z(S(a(t)("logs.col.latency")),1)]),_:1}),h(a(zt),{class:"text-right"},{default:g(()=>[z(S(a(t)("logs.col.status")),1)]),_:1})]),_:1})]),_:1}),h(a(Rm),null,{default:g(()=>[(_(!0),K(Ce,null,st(Z.value,ee=>(_(),K(Ce,{key:J(ee)},[ee.kind==="cooldown"?(_(),N(a(uo),{key:0,class:"bg-amber-500/5 hover:bg-amber-500/10"},{default:g(()=>[h(a(Lt),{colspan:"7",class:"py-2"},{default:g(()=>[x("div",pO,[x("span",mO,S(R(ee.ts)),1),h(a(_t),{variant:"warning",class:"gap-1 whitespace-nowrap"},{default:g(()=>[h(a(Al),{class:"h-3 w-3"}),z(" "+S(a(t)("logs.circuit.badge")),1)]),_:1}),x("span",hO,S(ee.provider),1),x("span",vO,S(a(t)("logs.circuit.failures",{n:ee.fails})),1),x("span",gO,S(a(t)("logs.circuit.cooldown",{s:Math.round((ee.cooldownMs??0)/1e3)})),1),x("span",yO,S(ee.error||a(t)("logs.circuit.reasonUnknown")),1)])]),_:2},1024)]),_:2},1024)):(_(),K(Ce,{key:1},[h(a(uo),{class:"cursor-pointer hover:bg-muted/50",onClick:Ze=>X(ee)},{default:g(()=>[h(a(Lt),{class:"w-8 text-muted-foreground"},{default:g(()=>[(_(),N(yr(fe(ee)?a(Ya):a(vi)),{class:"h-3.5 w-3.5"}))]),_:2},1024),h(a(Lt),{class:"font-mono text-xs text-muted-foreground",title:V(ee.ts)},{default:g(()=>[z(S(R(ee.ts)),1)]),_:2},1032,["title"]),h(a(Lt),{class:"font-mono text-xs"},{default:g(()=>[z(S(ee.model),1),ee.upstreamModel?(_(),K("span",bO," → "+S(ee.upstreamModel),1)):me("",!0)]),_:2},1024),h(a(Lt),{class:"text-sm"},{default:g(()=>[z(S(ee.provider),1)]),_:2},1024),h(a(Lt),null,{default:g(()=>[x("span",_O,[h(a(_t),{variant:"outline",class:ke(v(ee.format))},{default:g(()=>[z(S(ee.format),1)]),_:2},1032,["class"]),ee.stream?(_(),N(a(_t),{key:0,variant:"muted",class:"text-[10px]"},{default:g(()=>[z(S(a(t)("logs.stream")),1)]),_:1})):me("",!0)])]),_:2},1024),h(a(Lt),{class:"text-right font-mono text-xs text-muted-foreground"},{default:g(()=>[z(S($(ee.ms)),1)]),_:2},1024),h(a(Lt),{class:"text-right"},{default:g(()=>[h(a(_t),{variant:I(ee.status),class:"font-mono"},{default:g(()=>[z(S(ee.status),1)]),_:2},1032,["variant"])]),_:2},1024)]),_:2},1032,["onClick"]),fe(ee)?(_(),N(a(uo),{key:0,class:"hover:bg-transparent"},{default:g(()=>[h(a(Lt),{colspan:"7",class:"bg-muted/30"},{default:g(()=>[x("dl",wO,[x("dt",xO,S(a(t)("logs.detail.time")),1),x("dd",kO,S(V(ee.ts)),1),x("dt",CO,S(a(t)("logs.detail.latency")),1),x("dd",SO,S($(ee.ms)),1),x("dt",AO,S(a(t)("logs.detail.stream")),1),x("dd",null,S(ee.stream?a(t)("logs.detail.streamYes"):a(t)("logs.detail.streamNo")),1),ee.upstreamModel?(_(),K(Ce,{key:0},[x("dt",EO,S(a(t)("logs.detail.upstreamModel")),1),x("dd",OO,S(ee.upstreamModel),1)],64)):me("",!0),ee.usage?(_(),K(Ce,{key:1},[x("dt",TO,S(a(t)("logs.detail.tokens")),1),x("dd",PO,[x("span",$O,"↑ "+S(T(ee.usage.input)),1),pe[7]||(pe[7]=x("span",{class:"text-muted-foreground/50"}," · ",-1)),x("span",IO,"↓ "+S(T(ee.usage.output)),1),ee.usage.estimated?(_(),N(a(_t),{key:0,variant:"muted",class:"ml-1.5 text-[10px]"},{default:g(()=>[z("≈ "+S(a(t)("logs.detail.estimated")),1)]),_:1})):me("",!0),(ee.usage.cacheRead||0)+(ee.usage.cacheCreation||0)?(_(),K(Ce,{key:1},[pe[6]||(pe[6]=x("span",{class:"text-muted-foreground/50"}," · ",-1)),x("span",MO,"⚡ "+S(a(t)("logs.detail.cache"))+" "+S(T((ee.usage.cacheRead||0)+(ee.usage.cacheCreation||0))),1)],64)):me("",!0)])],64)):me("",!0),x("dt",RO,S(a(t)("logs.detail.error")),1),x("dd",LO,S(ee.error||a(t)("logs.detail.errorNone")),1)])]),_:2},1024)]),_:2},1024)):me("",!0)],64))],64))),128))]),_:1})]),_:1})])):(_(),K("p",dO,S(a(t)("logs.noMatch")),1)):(_(),K("p",cO,S(a(t)("logs.empty")),1))]),_:1})]),_:1}))}}),NO={key:0,class:"py-4 text-center text-xs text-muted-foreground"},FO={class:"flex items-center gap-1.5"},qO={class:"truncate font-mono text-xs"},BO={class:"flex items-center gap-2"},VO={class:"h-1.5 w-full max-w-[120px] overflow-hidden rounded-full bg-muted"},UO={class:"font-mono text-xs tabular-nums"},HO={key:0},jO={class:"text-foreground/80"},WO={class:"text-foreground/80"},KO={key:1,class:"text-muted-foreground/40"},zO={key:0,class:"inline-flex flex-col items-end leading-tight"},GO={class:"text-amber-600 dark:text-amber-400"},YO={class:"text-[10px] text-muted-foreground/60"},XO={key:1,class:"text-muted-foreground/40"},Br=Q({__name:"StatsBreakdown",props:{title:{},buckets:{},max:{},kind:{}},setup(e){const{t}=Wt();function n(d){return d<1e3?`${d}ms`:`${(d/1e3).toFixed(1)}s`}function s(d){return d?d<1e3?String(d):d<1e6?(d/1e3).toFixed(d<1e4?1:0).replace(/\.0$/,"")+"k":(d/1e6).toFixed(1)+"M":"0"}function o(d){if(!d)return"0%";const f=Math.round(d*1e3)/10;return(f%1===0?f.toFixed(0):f.toFixed(1))+"%"}const r=e,l=()=>r.buckets.some(d=>d.inputTokens||d.outputTokens),i=()=>r.buckets.some(d=>d.cacheRead||d.cacheCreation);function u(d,f){return f?Math.round(d/f*100):0}function c(d){var f;return(f=tn[d])==null?void 0:f.solid}return(d,f)=>(_(),N(a(mn),null,{default:g(()=>[h(a(Mn),{class:"pb-2"},{default:g(()=>[h(a(Rn),{class:"text-sm"},{default:g(()=>[z(S(e.title),1)]),_:1})]),_:1}),h(a(hn),null,{default:g(()=>[e.buckets.length?(_(),N(a(Im),{key:1},{default:g(()=>[h(a(Mm),null,{default:g(()=>[h(a(uo),null,{default:g(()=>[h(a(zt),null,{default:g(()=>[z(S(a(t)("stats.col.name")),1)]),_:1}),h(a(zt),{class:"w-1/3"},{default:g(()=>[z(S(a(t)("stats.col.calls")),1)]),_:1}),h(a(zt),{class:"text-right"},{default:g(()=>[z(S(a(t)("stats.col.success")),1)]),_:1}),h(a(zt),{class:"text-right"},{default:g(()=>[z(S(a(t)("stats.col.error")),1)]),_:1}),h(a(zt),{class:"text-right"},{default:g(()=>[z(S(a(t)("stats.col.avgLatency")),1)]),_:1}),l()?(_(),N(a(zt),{key:0,class:"text-right"},{default:g(()=>[z(S(a(t)("stats.col.tokens")),1)]),_:1})):me("",!0),i()?(_(),N(a(zt),{key:1,class:"text-right"},{default:g(()=>[z(S(a(t)("stats.col.cacheHit")),1)]),_:1})):me("",!0)]),_:1})]),_:1}),h(a(Rm),null,{default:g(()=>[(_(!0),K(Ce,null,st(e.buckets,p=>(_(),N(a(uo),{key:p.key},{default:g(()=>[h(a(Lt),{class:"py-1.5"},{default:g(()=>[x("div",FO,[e.kind==="format"&&c(p.key)?(_(),K("span",{key:0,class:ke(["h-2 w-2 shrink-0 rounded-full",c(p.key)])},null,2)):e.kind==="provider"&&p.id?(_(),K("span",{key:1,class:ke(["h-2 w-2 shrink-0 rounded-full",a(ei)(p.id).solid])},null,2)):me("",!0),x("span",qO,S(p.key),1)])]),_:2},1024),h(a(Lt),{class:"py-1.5"},{default:g(()=>[x("div",BO,[x("div",VO,[x("div",{class:"h-full rounded-full bg-primary/50",style:vn({width:u(p.calls,e.max)+"%"})},null,4)]),x("span",UO,S(p.calls),1)])]),_:2},1024),h(a(Lt),{class:"py-1.5 text-right font-mono text-xs text-emerald-600 dark:text-emerald-400"},{default:g(()=>[z(S(p.success),1)]),_:2},1024),h(a(Lt),{class:ke(["py-1.5 text-right font-mono text-xs",p.error?"text-destructive":"text-muted-foreground"])},{default:g(()=>[z(S(p.error),1)]),_:2},1032,["class"]),h(a(Lt),{class:"py-1.5 text-right font-mono text-xs text-muted-foreground"},{default:g(()=>[z(S(n(p.avgMs)),1)]),_:2},1024),l()?(_(),N(a(Lt),{key:0,class:"py-1.5 text-right font-mono text-xs tabular-nums"},{default:g(()=>[p.inputTokens||p.outputTokens?(_(),K("span",HO,[x("span",jO,S(s(p.inputTokens)),1),f[0]||(f[0]=x("span",{class:"text-muted-foreground/50"}," / ",-1)),x("span",WO,S(s(p.outputTokens)),1)])):(_(),K("span",KO,"—"))]),_:2},1024)):me("",!0),i()?(_(),N(a(Lt),{key:1,class:"py-1.5 text-right font-mono text-xs tabular-nums"},{default:g(()=>[p.cacheRead||p.cacheCreation?(_(),K("span",zO,[x("span",GO,S(o(p.cacheHitRate)),1),x("span",YO,"↑"+S(s(p.cacheRead)),1)])):(_(),K("span",XO,"—"))]),_:2},1024)):me("",!0)]),_:2},1024))),128))]),_:1})]),_:1})):(_(),K("p",NO,S(a(t)("stats.empty")),1))]),_:1})]),_:1}))}}),JO={class:"flex flex-wrap items-center justify-between gap-2"},QO={class:"flex items-center gap-2"},ZO={class:"inline-flex rounded-md border bg-muted/30 p-0.5"},eT=["onClick"],tT={class:"sr-only"},nT={key:0,class:"flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground"},sT={key:1,class:"py-10 text-center text-sm text-muted-foreground"},oT={class:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-6"},rT={class:"rounded-lg border bg-muted/20 p-3"},aT={class:"text-xs text-muted-foreground"},lT={class:"mt-1 font-mono text-xl tabular-nums"},iT={class:"rounded-lg border bg-muted/20 p-3"},uT={class:"text-xs text-muted-foreground"},cT={class:"mt-1 font-mono text-xl tabular-nums text-emerald-600 dark:text-emerald-400"},dT={class:"rounded-lg border bg-muted/20 p-3"},fT={class:"text-xs text-muted-foreground"},pT={class:"mt-1 font-mono text-xl tabular-nums text-destructive"},mT={class:"rounded-lg border bg-muted/20 p-3"},hT={class:"text-xs text-muted-foreground"},vT={class:"mt-1 font-mono text-xl tabular-nums"},gT={class:"rounded-lg border bg-muted/20 p-3"},yT={class:"text-xs text-muted-foreground"},bT={class:"mt-1 font-mono text-xl tabular-nums"},_T={class:"rounded-lg border bg-muted/20 p-3"},wT={class:"text-xs text-muted-foreground"},xT={class:"mt-1 font-mono text-xl tabular-nums"},kT={key:0,class:"grid grid-cols-3 gap-2"},CT={class:"rounded-lg border bg-muted/20 p-3"},ST={class:"text-xs text-muted-foreground"},AT={class:"mt-1 font-mono text-lg tabular-nums"},ET={class:"rounded-lg border bg-muted/20 p-3"},OT={class:"text-xs text-muted-foreground"},TT={class:"mt-1 font-mono text-lg tabular-nums"},PT={class:"rounded-lg border bg-muted/20 p-3"},$T={class:"text-xs text-muted-foreground"},IT={class:"mt-1 font-mono text-lg tabular-nums"},MT={class:"mb-2 flex items-center justify-between gap-2"},RT={class:"text-sm font-medium"},LT={key:0,class:"text-[11px] text-muted-foreground"},DT={class:"font-mono tabular-nums text-foreground"},NT={class:"rounded-lg border p-3"},FT={class:"relative pt-9"},qT={class:"flex h-40 gap-px"},BT={class:"pointer-events-none absolute bottom-full left-1/2 z-20 mb-1 hidden -translate-x-1/2 whitespace-nowrap rounded-md border bg-background px-2 py-1 text-center text-xs shadow-md group-hover:block"},VT={class:"font-medium"},UT={class:"font-mono tabular-nums"},HT={class:"text-[10px]"},jT={class:"text-emerald-600 dark:text-emerald-400"},WT={class:"text-destructive"},KT={class:"mt-1.5 flex justify-between text-[10px] text-muted-foreground"},zT={class:"grid gap-4 lg:grid-cols-2"},GT={class:"lg:col-span-2"},YT={key:1,class:"space-y-3"},XT={class:"text-sm font-medium"},JT={class:"grid gap-4 lg:grid-cols-2"},_d=160,QT=Q({__name:"Stats",setup(e){const{t}=Wt(),n=[{v:"24h",key:"h24"},{v:"7d",key:"d7"},{v:"30d",key:"d30"},{v:"90d",key:"d90"},{v:"all",key:"all"}],s=L(localStorage.getItem("myapikey.stats.range")||"7d");n.some(I=>I.v===s.value)||(s.value="7d"),Fe(s,I=>{try{localStorage.setItem("myapikey.stats.range",I)}catch{}});const o=L(null),r=L(!1);async function l(){r.value=!0;try{o.value=await He("GET",`/admin/stats?range=${s.value}`)}catch{o.value=null}finally{r.value=!1}}Fe(s,l),pt(l);function i(I){return I<1e3?`${I}ms`:`${(I/1e3).toFixed(1)}s`}function u(I){if(!I)return"0%";const v=Math.round(I*1e3)/10;return(v%1===0?v.toFixed(0):v.toFixed(1))+"%"}function c(I){const[v,$,T]=I.split("-").map(Number);return new Date(v,$-1,T).toLocaleDateString(void 0,{month:"short",day:"numeric"})}const d=Y(()=>{var I;return((I=o.value)==null?void 0:I.byDay.reduce((v,$)=>Math.max(v,$.calls),0))??0});function f(I){const v=d.value||1,$=I.calls/v*_d,T=I.error/v*_d;return{success:Math.max(0,Math.round($-T)),error:Math.round(T)}}function p(I){return I.reduce((v,$)=>Math.max(v,$.calls),0)||1}const m=Y(()=>!!o.value&&o.value.totals.calls>0),b=Y(()=>{var I,v;return(((I=o.value)==null?void 0:I.totals.cacheRead)??0)+(((v=o.value)==null?void 0:v.totals.cacheCreation)??0)}),C=Y(()=>!!o.value&&!!(o.value.totals.inputTokens||o.value.totals.outputTokens||b.value)),E=Y(()=>{var $;const I=((($=o.value)==null?void 0:$.byProviderModel)??[]).filter(T=>T.cacheRead||T.cacheCreation),v=new Map;for(const T of I){const A=T.providerId||T.provider;let R=v.get(A);R||(R={providerId:T.providerId,provider:T.provider,models:[],cacheRead:0},v.set(A,R)),R.models.push({key:T.model,calls:T.calls,success:T.success,error:0,avgMs:0,inputTokens:T.inputTokens,outputTokens:T.outputTokens,cacheRead:T.cacheRead,cacheCreation:T.cacheCreation,cacheHitRate:T.cacheHitRate}),R.cacheRead+=T.cacheRead}return[...v.values()].sort((T,A)=>A.cacheRead-T.cacheRead)}),y=Y(()=>E.value.length>0);function k(I){return I?I<1e3?String(I):I<1e6?(I/1e3).toFixed(I<1e4?1:0).replace(/\.0$/,"")+"k":(I/1e6).toFixed(1)+"M":"0"}return(I,v)=>(_(),N(a(mn),null,{default:g(()=>[h(a(Mn),null,{default:g(()=>[x("div",JO,[h(a(Rn),{class:"flex items-center gap-2 text-base"},{default:g(()=>[h(a(Sm),{class:"h-4 w-4 text-primary"}),z(" "+S(a(t)("stats.title")),1)]),_:1}),x("div",QO,[x("div",ZO,[(_(),K(Ce,null,st(n,$=>x("button",{key:$.v,type:"button",class:ke(["rounded-sm px-2.5 py-1 text-xs transition-colors",s.value===$.v?"bg-background font-medium shadow-sm":"text-muted-foreground hover:text-foreground"]),onClick:T=>s.value=$.v},S(a(t)(`stats.ranges.${$.key}`)),11,eT)),64))]),h(a(Ie),{variant:"outline",size:"sm",disabled:r.value,onClick:l},{default:g(()=>[r.value?(_(),N(a(St),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(_(),N(a(mr),{key:1,class:"h-3.5 w-3.5"})),x("span",tT,S(a(t)("stats.refresh")),1)]),_:1},8,["disabled"])])]),h(a(ys),null,{default:g(()=>[z(S(a(t)("stats.desc")),1)]),_:1})]),_:1}),h(a(hn),{class:"space-y-5"},{default:g(()=>[r.value&&!o.value?(_(),K("div",nT,[h(a(St),{class:"h-4 w-4 animate-spin"}),z(" "+S(a(t)("stats.loading")),1)])):m.value?o.value?(_(),K(Ce,{key:2},[x("div",oT,[x("div",rT,[x("div",aT,S(a(t)("stats.totals.calls")),1),x("div",lT,S(o.value.totals.calls),1)]),x("div",iT,[x("div",uT,S(a(t)("stats.totals.success")),1),x("div",cT,S(o.value.totals.success),1)]),x("div",dT,[x("div",fT,S(a(t)("stats.totals.error")),1),x("div",pT,S(o.value.totals.error),1)]),x("div",mT,[x("div",hT,S(a(t)("stats.totals.errorRate")),1),x("div",vT,S(u(o.value.totals.errorRate)),1)]),x("div",gT,[x("div",yT,S(a(t)("stats.totals.avgLatency")),1),x("div",bT,S(i(o.value.totals.avgMs)),1)]),x("div",_T,[x("div",wT,S(a(t)("stats.totals.p95")),1),x("div",xT,S(i(o.value.totals.p95Ms)),1)])]),C.value?(_(),K("div",kT,[x("div",CT,[x("div",ST,"↑ "+S(a(t)("stats.totals.inputTokens")),1),x("div",AT,S(k(o.value.totals.inputTokens)),1)]),x("div",ET,[x("div",OT,"↓ "+S(a(t)("stats.totals.outputTokens")),1),x("div",TT,S(k(o.value.totals.outputTokens)),1)]),x("div",PT,[x("div",$T,"⚡ "+S(a(t)("stats.totals.cache")),1),x("div",IT,S(k(b.value)),1)])])):me("",!0),x("div",null,[x("div",MT,[x("div",RT,S(a(t)("stats.byDay")),1),d.value?(_(),K("div",LT,[z(S(a(t)("stats.peak"))+" ",1),x("span",DT,S(d.value),1)])):me("",!0)]),x("div",NT,[x("div",FT,[x("div",qT,[(_(!0),K(Ce,null,st(o.value.byDay,$=>(_(),K("div",{key:$.day,class:"group relative flex min-w-0 flex-1 cursor-default flex-col justify-end"},[x("div",{style:vn({height:f($).success+"px"}),class:"w-full rounded-t-sm bg-emerald-500/70 transition-colors group-hover:bg-emerald-500"},null,4),x("div",{style:vn({height:f($).error+"px"}),class:ke(["w-full transition-colors group-hover:bg-destructive",f($).error?"bg-destructive/70":""])},null,6),x("div",BT,[x("div",VT,S(c($.day)),1),x("div",UT,S($.calls)+" "+S(a(t)("stats.callsAxis")),1),x("div",HT,[x("span",jT,S($.success),1),v[0]||(v[0]=x("span",{class:"text-muted-foreground"}," / ",-1)),x("span",WT,S($.error),1)])])]))),128))])]),x("div",KT,[x("span",null,S(o.value.byDay.length?c(o.value.byDay[0].day):""),1),x("span",null,S(o.value.byDay.length?c(o.value.byDay[o.value.byDay.length-1].day):""),1)])])]),x("div",zT,[x("div",GT,[h(Br,{title:a(t)("stats.byModel"),buckets:o.value.byModel,max:p(o.value.byModel),kind:"model"},null,8,["title","buckets","max"])]),h(Br,{title:a(t)("stats.byProvider"),buckets:o.value.byProvider,max:p(o.value.byProvider),kind:"provider"},null,8,["title","buckets","max"]),h(Br,{title:a(t)("stats.byFormat"),buckets:o.value.byFormat,max:p(o.value.byFormat),kind:"format"},null,8,["title","buckets","max"])]),y.value?(_(),K("div",YT,[x("div",XT,S(a(t)("stats.cacheBySource")),1),x("div",JT,[(_(!0),K(Ce,null,st(E.value,$=>(_(),N(Br,{key:$.providerId||$.provider,title:$.provider,buckets:$.models,max:p($.models),kind:"model"},null,8,["title","buckets","max"]))),128))])])):me("",!0)],64)):me("",!0):(_(),K("div",sT,S(a(t)("stats.empty")),1))]),_:1})]),_:1}))}}),ZT={class:"space-y-4"},eP={class:"space-y-2"},tP={class:"min-w-0"},nP={class:"mt-0.5 truncate font-mono text-sm"},sP={class:"min-w-0"},oP={class:"mt-0.5 truncate font-mono text-sm"},rP={class:"text-xs text-muted-foreground"},aP={class:"flex items-center justify-between gap-3 rounded-lg border border-primary/40 bg-primary/5 p-3"},lP={class:"min-w-0"},iP={class:"text-xs font-medium text-primary"},uP={class:"truncate font-mono text-sm"},cP={class:"flex items-center gap-1"},dP={class:"overflow-x-auto rounded-md border bg-muted/40 p-3 font-mono text-xs leading-relaxed"},fP=Q({__name:"Connect",setup(e){const{t}=Wt(),n={openai:"openai",anthropic:"anthropic",responses:"responses",curl:null};function s(m){const b=n[m];return b?tn[b]:null}const o=L(null),r=L(null),l=L(""),i=L(!1),u=Y(()=>{const m=window.location.hostname;if((m==="localhost"||m==="127.0.0.1")&&r.value){const b=window.location.port;return`${window.location.protocol}//${r.value}${b?":"+b:""}`}return window.location.origin}),c=Y(()=>`${u.value}/v1`);async function d(){o.value=(await He("GET","/admin/api-key")).apiKey,r.value=(await He("GET","/admin/connection")).lanIp}async function f(m,b){await Yi(b)?(l.value=m,setTimeout(()=>{l.value===m&&(l.value="")},1500)):Me(t("connect.copyFailed"),"error")}const p=Y(()=>[{key:"openai",title:t("connect.openaiTitle"),text:`export OPENAI_BASE_URL=${c.value}
283
283
  export OPENAI_API_KEY=${o.value??""}`},{key:"anthropic",title:t("connect.anthropicTitle"),text:`export ANTHROPIC_BASE_URL=${u.value}
284
284
  export ANTHROPIC_API_KEY=${o.value??""}`},{key:"curl",title:t("connect.curlTitle"),text:`curl ${c.value}/chat/completions \\
285
285
  -H "Authorization: Bearer ${o.value??""}" \\
@@ -15,7 +15,7 @@
15
15
  document.documentElement.classList.add("dark");
16
16
  }
17
17
  </script>
18
- <script type="module" crossorigin src="/assets/index-DtwXwAJg.js"></script>
18
+ <script type="module" crossorigin src="/assets/index-D9qLPKUa.js"></script>
19
19
  <link rel="stylesheet" crossorigin href="/assets/index-BxnR60oo.css">
20
20
  </head>
21
21
  <body>