import{da as r}from"./main-tangy-colts-beg.js";import{n as u,a as d}from"./openaico-tangy-colts-beg-990.js";globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(t,a){return this.cache.has(t)?this.cache.get(t):(this.cache.set(t,a),a)}};const m=async t=>r({headers:{Authorization:["Bearer ",{encryption:"hmac_decrypt",value:t}]},method:"GET",url:"https://api.openai.com/v1/models"}),p=async t=>r({headers:{Authorization:["Bearer ",{encryption:"hmac_decrypt",value:t}]},method:"GET",url:"https://api.openai.com/v1/batches"});globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(t,a){return this.cache.has(t)?this.cache.get(t):(this.cache.set(t,a),a)}};const C=async t=>{t.setComponent("model-id",o=>{o.loading=!0});const a=await t.getConnection();if(a)try{const{data:o,status:e}=await m(a.auth_details.value);if(e!=="success")throw new Error("Invalid response format");const s=o.data.map(n=>({label:`${n.id}`,value:n.id})),i=s==null?void 0:s.filter(n=>!u.includes(n.value)),l=s==null?void 0:s.filter(n=>!d.includes(n.value)),h=t.thisNode.machineSlug;t.setComponent("model-id",n=>{if(!t.util.isSelectComponent(n))return;let c;switch(h){case"chatModel":case"createCompletion":{c=i;break}case"textToStructuredData":{c=l;break}}n.options=c,n.loading=!1})}catch(o){t.setComponent("model-id",e=>{t.util.isSelectComponent(e)&&(e.loading=!1,e.status="error",e.invalidMessage=o.message)})}},b=async t=>{t.setComponent("batch-id",o=>{o.loading=!0});const a=await t.getConnection();if(a)try{const{data:o,status:e}=await p(a.auth_details.value);if(e!=="success")throw new Error("Invalid response format");t.setComponent("batch-id",s=>{t.util.isSelectComponent(s)&&(s.options=o.data.map(i=>({label:`${i.id}`,value:i.id})),s.loading=!1)})}catch(o){t.setComponent("batch-id",e=>{t.util.isSelectComponent(e)&&(e.loading=!1,e.status="error",e.invalidMessage=o.message)})}};export{C as a,b as f};
