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