import { AuthorizationEventTypes } from './AuthorizationEventTypes.js';
import { ContextEvent } from '../BaseEvents.js';
export class AuthorizationEvents {
    static get OAuth2() {
        return OAuth2Events;
    }
    static get Oidc() {
        return OidcEvents;
    }
}
class OAuth2Events {
    /**
     * @param config Authorization options.
     * @param target A node on which to dispatch the event.
     * @returns Promise resolved with authorization result
     */
    static async authorize(config, target = window) {
        const e = new ContextEvent(AuthorizationEventTypes.OAuth2.authorize, config);
        target.dispatchEvent(e);
        return e.detail.result;
    }
    /**
     * @param config Authorization options.
     * @param target A node on which to dispatch the event.
     * @returns Promise resolved when the token is removed
     */
    static async removeToken(config, target = window) {
        const e = new ContextEvent(AuthorizationEventTypes.OAuth2.removeToken, config);
        target.dispatchEvent(e);
        return e.detail.result;
    }
}
class OidcEvents {
    /**
     * @param config Authorization options.
     * @param target A node on which to dispatch the event.
     * @returns Promise resolved with authorization result
     */
    static async authorize(config, target = window) {
        const e = new ContextEvent(AuthorizationEventTypes.Oidc.authorize, config);
        target.dispatchEvent(e);
        return e.detail.result;
    }
    /**
     * @param config Authorization options.
     * @param target A node on which to dispatch the event.
     * @returns Promise resolved when the token is removed
     */
    static async removeTokens(config, target = window) {
        const e = new ContextEvent(AuthorizationEventTypes.Oidc.removeTokens, config);
        target.dispatchEvent(e);
        return e.detail.result;
    }
}
//# sourceMappingURL=AuthorizationEvents.js.map