const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["chunks/popup-C9isn0D2.js","assets/popup-YACEJWXS.css","chunks/refreshToken-DSpFO4Jw.js"])))=>i.map(i=>d[i]);
import{d as u,u as E,s as e,a as s,b as _,_ as d,h as t,A as a,B as r}from"./popup-C9isn0D2.js";const T=u("userAccessStore",()=>({canUserAccess:async()=>{const i=E();try{if(!(await e.getUserSession()).accessToken)return void(i.isAuthorized=!1);i.isUserLoading=!0;const r=await s.getMe();if(r&&"error"in r)return;if(r?.id){i.user=r,i.isAuthorized=!0,_.identify(r.id.toString(),{email:r.email,isPremium:r.active_subscription}),_.track("user_logged_in");const{useAcquisitionSurveyStore:e}=await d(async()=>{const{useAcquisitionSurveyStore:e}=await import("./popup-C9isn0D2.js").then(e=>e.e);return{useAcquisitionSurveyStore:e}},__vite__mapDeps([0,1]));e().maybeStart(r)}}catch(o){const n=o;if(n.isTimeout||"ECONNABORTED"===n.code)return void(await t(o,{method:a.GET_USER}));if(401===n.response?.status){const t=await(async()=>{const t=E();try{const{refreshToken:i}=await d(async()=>{const{refreshToken:e}=await import("./refreshToken-DSpFO4Jw.js");return{refreshToken:e}},__vite__mapDeps([2,0,1])),a=await i();if(a){const e=await s.getMe();if(e&&!("error"in e)&&e.id)return t.user=e,t.isAuthorized=!0,chrome.runtime.sendMessage({type:r.UPDATE_REFRESH_TOKEN_TIMER,data:{expiresIn:a}}),!0}return t.isAuthorized=!1,e.clearUserSession(),chrome.runtime.sendMessage({type:r.RESET_REFRESH_TOKEN_TIMER,data:!0}),!1}catch(i){return t.isAuthorized=!1,e.clearUserSession(),chrome.runtime.sendMessage({type:r.RESET_REFRESH_TOKEN_TIMER,data:!0}),!1}})();if(t)return}else await t(o,{method:a.GET_USER}),i.isAuthorized=!1,e.clearUserSession(),chrome.runtime.sendMessage({type:r.RESET_REFRESH_TOKEN_TIMER,data:!0})}finally{i.isUserLoading=!1}}}));export{T as useUserAccessStore};
