package com.kakao.auth;

import android.content.Context;
import android.os.Bundle;
import com.bytedance.covode.number.Covode;
import com.kakao.auth.ageauth.DefaultAgeAuthService;
import com.kakao.auth.api.AuthApi;
import com.kakao.auth.callback.AccountResponseCallback;
import com.kakao.auth.network.response.AccessTokenInfoResponse;
import com.kakao.network.tasks.ITaskQueue;
import com.kakao.network.tasks.KakaoResultTask;
import com.kakao.network.tasks.KakaoTaskQueue;
import java.util.concurrent.Future;

public class AuthService {
    public static AuthService instance = new AuthService(AuthApi.getInstance(), KakaoTaskQueue.getInstance());
    public AuthApi api;
    public ITaskQueue taskQueue;

    public enum AgeAuthLevel {
        LEVEL_1("10", "AUTH_LEVEL1"),
        LEVEL_2("20", "AUTH_LEVEL2");
        
        public final String name;
        public final String value;

        public final String getName() {
            return this.name;
        }

        public final String getValue() {
            return this.value;
        }

        public static AgeAuthLevel convertByName(String str) {
            for (AgeAuthLevel ageAuthLevel : values()) {
                if (ageAuthLevel.getName().equals(str)) {
                    return ageAuthLevel;
                }
            }
            return null;
        }

        /* access modifiers changed from: public */
        AgeAuthLevel(String str, String str2) {
            this.value = str;
            this.name = str2;
        }
    }

    public enum AgeAuthStatus {
        SUCCESS(0),
        CLIENT_ERROR(-777),
        CANCELED_OPERATION(-778),
        UNAUTHORIZED(-401),
        BAD_PARAMETERS(-440),
        NOT_AUTHORIZED_AGE(-450),
        LOWER_AGE_LIMIT(-451),
        ALREADY_AGE_AUTHORIZED(-452),
        EXCEED_AGE_CHECK_LIMIT(-453),
        AGE_AUTH_RESULT_MISMATCH(-480),
        CI_RESULT_MISMATCH(-481),
        ERROR(-500),
        UNKOWN(-999);
        
        public final int value;

        public final int getValue() {
            return this.value;
        }

        public static AgeAuthStatus valueOf(int i) {
            for (AgeAuthStatus ageAuthStatus : values()) {
                if (ageAuthStatus.getValue() == i) {
                    return ageAuthStatus;
                }
            }
            return UNKOWN;
        }

        /* access modifiers changed from: public */
        AgeAuthStatus(int i) {
            this.value = i;
        }
    }

    public static AuthService getInstance() {
        return instance;
    }

    static {
        Covode.recordClassIndex(45739);
    }

    public void requestAccessTokenInfo(ApiResponseCallback<AccessTokenInfoResponse> apiResponseCallback) {
        this.taskQueue.addTask(new KakaoResultTask<AccessTokenInfoResponse>(apiResponseCallback) {
            static {
                Covode.recordClassIndex(45741);
            }

            public AccessTokenInfoResponse call() {
                return AuthService.this.api.requestAccessTokenInfo();
            }
        });
    }

    public AuthService(AuthApi authApi, ITaskQueue iTaskQueue) {
        this.api = authApi;
        this.taskQueue = iTaskQueue;
    }

    public Future<Integer> requestShowAgeAuthDialog(AccountResponseCallback accountResponseCallback, final Bundle bundle, final Context context) {
        return KakaoTaskQueue.getInstance().addTask(new KakaoResultTask<Integer>(accountResponseCallback) {
            static {
                Covode.recordClassIndex(45740);
            }

            public Integer call() {
                return Integer.valueOf(DefaultAgeAuthService.getInstance().requestAgeAuth(bundle, context));
            }
        });
    }
}
