"use strict";const s="Something went wrong, please, try again.";function c(e){return e&&e.replace(/=+$/,"")}function l(e,r){return!!e&&!!r&&c(e)===c(r)}function d(e){let r;if(/code|token|error/.test(window.location.hash)?r=window.location.hash.substring(1):r=location.search.substring(1),!r)throw console.error("No query string in OAuth 2 redirect URL"),new Error(s);const o=new URLSearchParams(r),t=o.get("access_token"),n=o.get("code"),i=o.get("token_type"),a=o.get("expires_in"),u=o.get("state"),h=o.get("error"),w=o.get("error_description")||s;if(h)throw new Error(w);if(!l(u,e?.state))throw new Error("Outdated OAuth2 state");if(e?.flow==="implicit"){if(!t)throw new Error(`Your OAuth2 authentication service provider redirected you without an "access_token".
Please, try again or make sure your OAuth2 settings are correct.`);if(!i)throw new Error(`Your OAuth2 authentication service provider redirected you without a "token_type".
Please, try again or make sure your OAuth2 settings are correct.`);e?.successCallback({access_token:t,token_type:i,expires_in:a,auth_code:""})}if(e?.flow==="authorizationCode"){if(!n)throw new Error(`Your OAuth2 authentication service provider redirected you without authorization "code".
Please, try again or make sure your OAuth2 settings are correct.`);e?.successCallback({auth_code:n,access_token:"",token_type:"bearer"})}}function g(){const e=window.opener?.redirectOAuth2;try{d(e)}catch(r){e?.errorCallback(r)}window.close()}window.onload=g;
