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