import{n as P}from"./rolldown-runtime-M0oDzQ_3.js";import{Rn as t,Rt as M,Xt as n}from"./ui-vendor-CepnLjNg.js";import{_ as b,g as y}from"./vue-vendor-BQwgTLLQ.js";import{c as w,l as h}from"./_plugin-vue_export-helper-D2UTCjuN.js";import{_ as S,a as A,l as D,n as W,p as C}from"./system-3NMgaQdv.js";import{G as F,K,W as R,q as u}from"./index-8_-Evm_R.js";var q,E=P((()=>{b(),M(),D(),h(),K(),R(),q=y("models",()=>{const r=t([]),d=t([]),o=t(""),i=t(""),s=t(!1),v=n(()=>r.value.filter(e=>e.provider.startsWith("custom:"))),f=n(()=>r.value.filter(e=>!e.provider.startsWith("custom:"))),c=n(()=>r.value.flatMap(e=>e.models.map(a=>({id:a,provider:e.provider,label:e.label,base_url:e.base_url,isDefault:a===o.value&&e.provider===i.value}))));async function l(){if(w()){s.value=!0;try{const e=F().activeProfileName||"default",a=await A(e);r.value=a.groups,d.value=a.allProviders,o.value=a.default,i.value=a.default_provider||""}catch(e){console.error("Failed to fetch providers:",e)}finally{s.value=!1}}}async function m(e,a){await S({default:e,provider:a}),o.value=e,i.value=a,u().reloadModels()}async function p(e){await W(e),await l(),await u().reloadModels()}async function _(e){await C(e),await l(),await u().reloadModels()}return{providers:r,allProviders:d,defaultModel:o,defaultProvider:i,loading:s,customProviders:v,builtinProviders:f,allModels:c,fetchProviders:l,setDefaultModel:m,addProvider:p,removeProvider:_}})}));export{q as n,E as t};
