var w=Object.defineProperty;var g=(o,t,e)=>t in o?w(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var h=(o,t,e)=>(g(o,typeof t!="symbol"?t+"":t,e),e);import{p as y}from"./popupNotifcation.bdafa9de.js";import{L as b,N as E,O as A,l as d}from"./vue-router.3768b992.js";(function(){try{var o=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(o._sentryDebugIds=o._sentryDebugIds||{},o._sentryDebugIds[t]="2aeacf28-af2f-4daa-9208-e47baa812b89",o._sentryDebugIdIdentifier="sentry-dbid-2aeacf28-af2f-4daa-9208-e47baa812b89")}catch{}})();class m{constructor(){h(this,"storage");this.storage=new b(E.string(),"auth:jwt")}async authenticate(t){f.post("authn/authenticate",{email:t})}async verify(t,e){const a=await f.post("authn/verify",{email:t,token:e});if(!(a&&"jwt"in a))throw new Error("Invalid token");return this.saveJWT(a.jwt),this.getAuthor()}saveJWT(t){this.storage.set(t)}getAuthor(){const t=this.storage.get();if(t)try{const e=A(t);if(e.exp&&e.exp>Date.now()/1e3)return{jwt:t,claims:e}}catch{console.warn("Invalid JWT")}return null}removeAuthor(){this.storage.remove()}get headers(){const t=this.getAuthor();return t?{"Author-Authorization":`Bearer ${t.jwt}`}:{}}}const i=new m,T=()=>window.location.host.includes(".abstra.io"),R={"cloud-api":"/api/cloud-api",onboarding:"https://onboarding.abstra.app"},O={"cloud-api":"https://cloud-api.abstra.cloud",onboarding:"https://onboarding.abstra.app"},l=o=>{const t="VITE_"+d.toUpper(d.snakeCase(o)),e={VITE_SENTRY_RELEASE:"b0151191d7fab1cfe20ce4ad208f3296e6ee83e9",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0}[t];return e||(T()?R[o]:O[o])},c={cloudApi:l("cloud-api"),onboarding:l("onboarding")};class u extends Error{constructor(t,e){super(t),this.status=e}static async fromResponse(t){const e=await t.text();return new u(e,t.status)}}class f{static async get(t,e){const a=Object.fromEntries(Object.entries(e!=null?e:{}).filter(([,p])=>p!=null)),n=Object.keys(a).length>0?`?${new URLSearchParams(a).toString()}`:"",s=await fetch(`${c.cloudApi}/console/${t}${n}`,{headers:{...i.headers}});if(s.status===403){y("You are not authorized to access this resource","Click here to go back to the home page.",()=>{window.location.href="/"});return}const r=await s.text();return r?JSON.parse(r):null}static async getBlob(t){return await(await fetch(`${c.cloudApi}/console/${t}`,{headers:{...i.headers}})).blob()}static async post(t,e,a){const n=!!(a!=null&&a["Content-Type"])&&a["Content-Type"]!=="application/json",s=await fetch(`${c.cloudApi}/console/${t}`,{method:"POST",headers:{"Content-Type":"application/json",...i.headers,...a},body:n?e:JSON.stringify(e)});if(!s.ok)throw await u.fromResponse(s);const r=await s.text();return r?JSON.parse(r):null}static async patch(t,e){const a=await fetch(`${c.cloudApi}/console/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json",...i.headers},body:JSON.stringify(e)});if(!a.ok)throw await u.fromResponse(a);const n=await a.text();return n?JSON.parse(n):null}static async delete(t){const e=await fetch(`${c.cloudApi}/console/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json",...i.headers}});if(!e.ok)throw await u.fromResponse(e)}}export{f as C,i as a};
//# sourceMappingURL=gateway.462076e6.js.map
