import{da as c}from"./main-tangy-colts-beg.js";globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(t,e){return this.cache.has(t)?this.cache.get(t):(this.cache.set(t,e),e)}};const l="https://openrouter.ai/api/v1",h=t=>c({headers:{Authorization:["Bearer ",{encryption:"hmac_decrypt",value:t}]},method:"GET",url:`${l}/models`});globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(t,e){return this.cache.has(t)?this.cache.get(t):(this.cache.set(t,e),e)}};const u=async t=>{t.setComponent("model-id",e=>{e.loading=!0});try{const e=await t.getConnection();if(!e)return;const n=e.auth_details.value,{data:a,status:s}=await h(n);if(s!=="success"){t.setComponent("model-id",o=>{t.util.isSelectComponent(o)&&(o.status=s,o.invalidMessage=a)});return}if(!(a!=null&&a.data)){t.setComponent("model-id",o=>{t.util.isSelectComponent(o)&&(o.options=[])});return}t.setComponent("model-id",o=>{t.util.isSelectComponent(o)&&(o.options=a.data.map(i=>({label:i.name||i.id,value:i.id})))})}finally{t.setComponent("model-id",e=>{e.loading=!1})}};export{u as f};
