import{da as n}from"./main-tangy-colts-beg.js";globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(e,a){return this.cache.has(e)?this.cache.get(e):(this.cache.set(e,a),a)}};const l=async e=>n({headers:{Authorization:["Bearer ",{encryption:"hmac_decrypt",value:e}]},method:"GET",url:"https://gmail.googleapis.com/gmail/v1/users/me/labels"});globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(e,a){return this.cache.has(e)?this.cache.get(e):(this.cache.set(e,a),a)}};const h=async e=>{e.setComponent("label-id",t=>{t.loading=!0});const a=await e.getConnection("expires_in");if(!a){e.setComponent("label-id",t=>{t.loading=!1});return}const{data:o,status:s}=await l(a.auth_details.access_token);if(s==="error"){e.setComponent("label-id",t=>{e.util.isSelectComponent(t)&&(t.status=s,t.invalidMessage=o)}),console.error("Failed to fetch spreadsheets");return}e.setComponent("label-id",t=>{var i;e.util.isSelectComponent(t)&&(t.options=(i=o==null?void 0:o.labels)==null?void 0:i.map(c=>({label:c.name,value:c.id})),t.loading=!1,t.status=void 0)})};export{h as f};
