"use strict";var h=Object.create;var a=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var T=Object.getPrototypeOf;var z=Object.prototype.hasOwnProperty;var i=(e,o)=>a(e,"name",{value:o,configurable:true});var k=(e,o)=>{for(var r in o)a(e,r,{get:o[r],enumerable:true})};var c=(e,o,r,t)=>{if(o&&typeof o==="object"||typeof o==="function"){for(let n of y(o))if(!z.call(e,n)&&n!==r)a(e,n,{get:()=>o[n],enumerable:!(t=l(o,n))||t.enumerable})}return e};var g=(e,o,r)=>(r=e!=null?h(T(e)):{},c(o||!e||!e.__esModule?a(r,"default",{value:e,enumerable:true}):r,e));var w=e=>c(a({},"__esModule",{value:true}),e);var X={};k(X,{prepareAuthRequest:()=>u,prepareLocalToken:()=>f,sendAuthRequest:()=>F});module.exports=w(X);var d=require("mobx");var p=g(require("mobx-localstorage"));var m=require("../../environment-remote");var s=require("../apiBase");const u=i((e={method:"GET"},o=true)=>{const r=Object.assign(e,{mode:"cors",headers:{"Content-Type":"application/json","X-Franz-Source":"desktop","X-Franz-Version":m.ferdiumVersion,"X-Franz-platform":process.platform,"X-Franz-Timezone-Offset":new Date().getTimezoneOffset(),"X-Franz-System-Locale":m.ferdiumLocale,...e.headers}});if(o){r.headers.Authorization=`Bearer ${p.default.getItem("authToken")}`}return r},"prepareAuthRequest");const f=i(async e=>{await(0,d.when)(()=>!(0,s.needsToken)()||!!(0,s.localServerToken)(),{timeout:2e3});const o=(0,s.localServerToken)();if(o){e.headers["X-Ferdium-Local-Token"]=o}},"prepareLocalToken");const F=i(async(e,o,r)=>{const t=u(o,r);await f(t);return window.fetch(e,t)},"sendAuthRequest");
