"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),r=require("../constants/mobile.js");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(e);function o(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function a(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?o(Object(t),!0).forEach((function(r){n.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):o(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var i=/corva\.ai\/(.+?)\/packages/,p=/app\/(.+?)\/.*\.chunk\.js/,c=window.self!==window.top;var u=function(){try{var e=sessionStorage.getItem(r.MOBILE_AUTH_TOKEN_STORAGE_KEY);if(e)return e;var t=c?window.parent.location.href:window.location.href;return new URL(t).searchParams.get("token")}catch(e){return null}};exports.attachHTTPHeaders=function(e){var r=e.config,t=e.appKey,n=e.Authorization,o=a({},r.headers||{});return t&&(o["x-corva-app"]=t),n&&(o.Authorization=n),a(a({},r),{},{headers:o})},exports.getAppKeyAndId=function(){var e,r,t,n,o,a,c,u=null===(e=window)||void 0===e||null===(r=e.xprops)||void 0===r||null===(t=r.app)||void 0===t||null===(n=t.app)||void 0===n?void 0:n.app_key;if(u)return{appKey:u,appInstanceId:String(null===(o=window)||void 0===o||null===(a=o.xprops)||void 0===a||null===(c=a.app)||void 0===c?void 0:c.id)};var s=Error.stackTraceLimit;Error.stackTraceLimit=300;var l=new Error,d=l.stack.match(i)||l.stack.match(p);return Error.stackTraceLimit=s,d?{appKey:d[1].replace("/app/","."),appInstanceId:"nonisolated"}:void 0},exports.getAuthorizationHeaders=function(){var e=u();return e?{Authorization:"Bearer ".concat(e)}:{}},exports.getAuthorizationToken=u;
//# sourceMappingURL=utils.js.map
