// Metro module 15769 (f15770). import AuthorizedAppsStore from "../oauth2/AuthorizedAppsStore"; import AccountLinkStore from "./AccountLinkStore"; import { AppStates, Endpoints } from "../../Constants"; import Durations from "../../utils/Durations"; import { HTTP } from "../../_bundle/sendRequest"; import AutomaticLifecycleManager from "../../lib/AutomaticLifecycleManager"; let c11269_8 = 20 * Durations.Millis.MINUTE; class AccountLinkManager extends AutomaticLifecycleManager { static displayName = "AccountLinkManager"; actions = { OAUTH2_TOKEN_CREATE: (a0) => this.handleOAuth2TokenCreate(a0), USER_AUTHORIZED_APPS_UPDATE: () => this.handleAuthorizedAppsUpdate(), APP_STATE_UPDATE: (a0) => this.handleAppStateUpdate(a0), ACCOUNT_LINK_AUTHORIZATION_COMPLETED: (a0) => this.handleAccountLinkAuthorizationCompleted(a0) }; evaluatePending() { const pendingAuthorizations = AccountLinkStore.getPendingAuthorizations(); if (pendingAuthorizations.size !== 0) { const r6 = Date.now(); for (const item of pendingAuthorizations) { const [r37, r38] = item; if (r6 - r38.startedAt > c11269_8) { AccountLinkStore.deletePendingAuthorization(r37); const accountLinkCallbacks2 = r38.accountLinkCallbacks; if (accountLinkCallbacks2 != null) { const onError = accountLinkCallbacks2.onError; if (onError != null) { onError.call(accountLinkCallbacks2, "Account link authorization timed out"); } } } else if (AuthorizedAppsStore.getNewestTokenForApplication(r37) != null) { const accountLinkCallbacks = r38.accountLinkCallbacks; if (accountLinkCallbacks != null) { const onSuccess = accountLinkCallbacks.onSuccess; if (onSuccess != null) { onSuccess.call(accountLinkCallbacks); } } AccountLinkStore.deletePendingAuthorization(r37); } } } } handleOAuth2TokenCreate(a0) { if (AccountLinkStore.getPendingAuthorizations().has(a0.application.id)) { this.evaluatePending(); } } handleAuthorizedAppsUpdate() { this.evaluatePending(); } handleAccountLinkAuthorizationCompleted(a0) { if (AccountLinkStore.getPendingAuthorizations().has(a0.applicationId)) { this.evaluatePending(); } } handleAppStateUpdate(a0) { if (a0.state === AppStates.ACTIVE) { this.evaluatePending(); } } } const accountLinkManager = new AccountLinkManager(); export default accountLinkManager; export async function claimIncentivizedAccountLinkingReward(c28153_0) { let c28153_3; let c28153_4 = 0; let c30918_0, c30918_1, c30918_2, c30918_3; L14: { try { c30918_0 = void 0; c30918_1 = void 0; c30918_2 = void 0; c30918_0 = c28153_0.applicationId; c30918_1 = c28153_0.onSuccess; c30918_2 = c28153_0.onError; await void 0; c28153_4 = 1; await HTTP.post({ url: Endpoints.OAUTH2_ACCOUNT_LINKING_ACHIEVEMENT, body: { application_id: c30918_0 }, rejectWithError: true }); const r77 = c30918_1; if (r77 != null) { r77(); } c28153_4 = 0; } catch ($e) { const r27 = $e; let r8 = r27; c28153_3 = r27; if (c28153_4 !== 0) { while (true) { try { const r86 = c28153_3; c28153_4 = 0; c30918_3 = r86; const r88 = c30918_2; if (r88 == null) { break L14; } r88(c30918_3); break L14; } catch (r83) { r8 = r83; c28153_3 = r83; if (c28153_4 === 0) { break; } } } } throw r8; } } } export { AccountLinkManager };