package com.ss.android.ugc.aweme.discover.api;

import X.0Gp;
import X.6tJ;
import X.7he;
import X.AVG;
import X.Crj;
import X.IUu;
import X.JLr;
import X.JMB;
import X.M12;
import X.Oae;
import X.PUu;
import X.PV0;
import X.SSK;
import com.bytedance.covode.number.Covode;
import com.google.gson.m;
import com.ss.android.ugc.aweme.app.api.Api;
import com.ss.android.ugc.aweme.discover.model.SearchChallengeList;
import com.ss.android.ugc.aweme.discover.model.SearchEffectListResponse;
import com.ss.android.ugc.aweme.discover.model.SearchLiveList;
import com.ss.android.ugc.aweme.discover.model.SearchMusicList;
import com.ss.android.ugc.aweme.discover.model.SearchUserList;
import java.util.LinkedHashMap;
import java.util.concurrent.ExecutionException;
import kotlin.h.b.n;

public final class SearchApi {
    public static final String LIZ = Api.LIZLLL;
    public static final SearchApi LIZIZ = new SearchApi();
    public static final Crj LIZJ = 7he.LIZ(Oae.LIZ);

    public interface RealApi {
        static {
            Covode.recordClassIndex(64445);
        }

        @IUu(LIZ = "/aweme/v1/challenge/search/")
        @6tJ
        JLr<SearchChallengeList> searchChallengeList(@PUu(LIZ = "cursor") long j, @PUu(LIZ = "keyword") String str, @PUu(LIZ = "enter_from") String str2, @PUu(LIZ = "count") int i, @PUu(LIZ = "hot_search") int i2, @PUu(LIZ = "source") String str3, @PUu(LIZ = "search_source") String str4, @PUu(LIZ = "search_id") String str5, @PUu(LIZ = "last_search_id") String str6, @PUu(LIZ = "query_correct_type") int i3, @PUu(LIZ = "search_context") String str7);

        @IUu(LIZ = "/aweme/v1/music/search/")
        @6tJ
        JLr<m> searchDynamicMusicList(@PUu(LIZ = "cursor") long j, @PUu(LIZ = "keyword") String str, @PUu(LIZ = "enter_from") String str2, @PUu(LIZ = "count") int i, @PUu(LIZ = "hot_search") int i2, @PUu(LIZ = "search_id") String str3, @PUu(LIZ = "last_search_id") String str4, @PUu(LIZ = "source") String str5, @PUu(LIZ = "search_source") String str6, @PUu(LIZ = "query_correct_type") int i3, @PUu(LIZ = "is_filter_search") int i4, @PUu(LIZ = "filter_by") int i5, @PUu(LIZ = "sort_type") int i6, @PV0 LinkedHashMap<String, Integer> linkedHashMap, @PUu(LIZ = "search_context") String str7);

        @IUu(LIZ = "/aweme/v1/loadmore/wish/")
        @6tJ
        0Gp<SearchEffectListResponse> searchEffectList(@PUu(LIZ = "keyword") String str, @PUu(LIZ = "alasrc") String str2, @PUu(LIZ = "source") String str3, @PUu(LIZ = "offset") int i, @PUu(LIZ = "limit") int i2, @PUu(LIZ = "aid") int i3, @PUu(LIZ = "search_id") String str4);

        @IUu(LIZ = "/aweme/v1/live/search/")
        @6tJ
        JLr<SearchLiveList> searchLiveList(@PUu(LIZ = "offset") long j, @PUu(LIZ = "keyword") String str, @PUu(LIZ = "count") int i, @PUu(LIZ = "search_source") String str2, @PUu(LIZ = "enter_from") String str3, @PUu(LIZ = "search_id") String str4, @PUu(LIZ = "source") String str5, @PUu(LIZ = "live_id_list") String str6, @PUu(LIZ = "last_search_id") String str7, @PUu(LIZ = "search_context") String str8);

        @IUu(LIZ = "/aweme/v1/music/search/")
        @6tJ
        JLr<SearchMusicList> searchMusicList(@PUu(LIZ = "cursor") long j, @PUu(LIZ = "keyword") String str, @PUu(LIZ = "enter_from") String str2, @PUu(LIZ = "count") int i, @PUu(LIZ = "hot_search") int i2, @PUu(LIZ = "search_id") String str3, @PUu(LIZ = "last_search_id") String str4, @PUu(LIZ = "source") String str5, @PUu(LIZ = "search_source") String str6, @PUu(LIZ = "query_correct_type") int i3, @PUu(LIZ = "is_filter_search") int i4, @PUu(LIZ = "filter_by") int i5, @PUu(LIZ = "sort_type") int i6, @PV0 LinkedHashMap<String, Integer> linkedHashMap, @PUu(LIZ = "search_context") String str7);

        @IUu(LIZ = "/aweme/v1/discover/search/")
        @6tJ
        JLr<SearchUserList> searchUserList(@PUu(LIZ = "cursor") long j, @PUu(LIZ = "keyword") String str, @PUu(LIZ = "enter_from") String str2, @PUu(LIZ = "count") int i, @PUu(LIZ = "type") int i2, @PUu(LIZ = "hot_search") int i3, @PUu(LIZ = "search_source") String str3, @PUu(LIZ = "search_id") String str4, @PUu(LIZ = "last_search_id") String str5, @PUu(LIZ = "query_correct_type") int i4, @PUu(LIZ = "search_channel") String str6, @PUu(LIZ = "sug_user_id") String str7, @PUu(LIZ = "is_rich_sug") String str8, @PUu(LIZ = "search_context") String str9, @PUu(LIZ = "is_filter_search") int i5, @PV0 LinkedHashMap<String, String> linkedHashMap);
    }

    public final RealApi LIZ() {
        return (RealApi) LIZJ.getValue();
    }

    static {
        Covode.recordClassIndex(64444);
    }

    public final SearchChallengeList LIZIZ(SSK ssk) {
        SSK ssk2 = ssk;
        M12.LIZ(ssk2);
        try {
            Object obj = LIZ().searchChallengeList(ssk2.LJIIIIZZ, ssk2.LIZ, ssk2.LJIIJ, ssk2.LJIIIZ, ssk2.LJ, "challenge", ssk2.LIZJ, ssk2.LJI, ssk2.LJII, ssk2.LJFF, ssk2.LJIJI).get();
            n.LIZIZ(obj, "");
            return (SearchChallengeList) obj;
        } catch (ExecutionException e) {
            RuntimeException compatibleException = JMB.getCompatibleException(e);
            n.LIZIZ(compatibleException, "");
            throw compatibleException;
        }
    }

    public final SearchLiveList LIZJ(SSK ssk) {
        M12.LIZ(ssk);
        try {
            Object obj = LIZ().searchLiveList(ssk.LJIIIIZZ, ssk.LIZ, ssk.LJIIIZ, ssk.LIZJ, ssk.LJIIJ, ssk.LJI, ssk.LIZLLL, ssk.LJIJ, ssk.LJII, ssk.LJIJI).get();
            n.LIZIZ(obj, "");
            return (SearchLiveList) obj;
        } catch (ExecutionException e) {
            RuntimeException compatibleException = JMB.getCompatibleException(e);
            n.LIZIZ(compatibleException, "");
            throw compatibleException;
        }
    }

    public final SearchUserList LIZ(SSK ssk) {
        LinkedHashMap linkedHashMap;
        SSK ssk2 = ssk;
        M12.LIZ(ssk2);
        try {
            RealApi LIZ2 = LIZ();
            long j = ssk2.LJIIIIZZ;
            String str = ssk2.LIZ;
            String str2 = ssk2.LJIIJ;
            int i = ssk2.LJIIIZ;
            int i2 = ssk2.LJ;
            String str3 = ssk2.LIZJ;
            String str4 = ssk2.LJI;
            String str5 = ssk2.LJII;
            int i3 = ssk2.LJFF;
            String str6 = ssk2.LJIIL;
            String str7 = ssk2.LJIILJJIL;
            String str8 = ssk2.LJIILL;
            String str9 = ssk2.LJIJI;
            AVG avg = ssk2.LJIIJJI;
            int i4 = 1;
            if (avg == null || avg.isDefaultOption()) {
                i4 = 0;
            }
            AVG avg2 = ssk2.LJIIJJI;
            if (avg2 == null || (linkedHashMap = avg2.userToFieldRequestMap()) == null) {
                linkedHashMap = new LinkedHashMap();
            }
            String str10 = str3;
            String str11 = str4;
            String str12 = str5;
            int i5 = i;
            int i6 = i2;
            String str13 = str;
            String str14 = str2;
            long j2 = j;
            Object obj = LIZ2.searchUserList(j2, str13, str14, i5, 1, i6, str10, str11, str12, i3, str6, str7, str8, str9, i4, linkedHashMap).get();
            n.LIZIZ(obj, "");
            return (SearchUserList) obj;
        } catch (ExecutionException e) {
            RuntimeException compatibleException = JMB.getCompatibleException(e);
            n.LIZIZ(compatibleException, "");
            throw compatibleException;
        }
    }

    public final SearchMusicList LIZLLL(SSK ssk) {
        boolean z;
        int i;
        int i2;
        LinkedHashMap linkedHashMap;
        SSK ssk2 = ssk;
        M12.LIZ(ssk2);
        try {
            RealApi LIZ2 = LIZ();
            long j = ssk2.LJIIIIZZ;
            String str = ssk2.LIZ;
            String str2 = ssk2.LJIIJ;
            int i3 = ssk2.LJIIIZ;
            int i4 = ssk2.LJ;
            String str3 = ssk2.LJI;
            String str4 = ssk2.LJII;
            String str5 = ssk2.LIZJ;
            int i5 = ssk2.LJFF;
            AVG avg = ssk2.LJIIJJI;
            if (avg != null) {
                z = avg.isDefaultOption();
            } else {
                z = true;
            }
            int i6 = 0;
            if (!z) {
                i = 1;
            } else {
                i = 0;
            }
            AVG avg2 = ssk2.LJIIJJI;
            if (avg2 != null) {
                i2 = avg2.getFilterBy();
            } else {
                i2 = 0;
            }
            try {
                AVG avg3 = ssk2.LJIIJJI;
                if (avg3 != null) {
                    i6 = avg3.getSortType();
                }
                AVG avg4 = ssk2.LJIIJJI;
                if (avg4 == null || (linkedHashMap = avg4.activityToFieldMap()) == null) {
                    linkedHashMap = new LinkedHashMap();
                }
                Object obj = LIZ2.searchMusicList(j, str, str2, i3, i4, str3, str4, "music", str5, i5, i, i2, i6, linkedHashMap, ssk2.LJIJI).get();
                n.LIZIZ(obj, "");
                return (SearchMusicList) obj;
            } catch (ExecutionException e) {
                e = e;
                RuntimeException compatibleException = JMB.getCompatibleException(e);
                n.LIZIZ(compatibleException, "");
                throw compatibleException;
            }
        } catch (ExecutionException e2) {
            e = e2;
            RuntimeException compatibleException2 = JMB.getCompatibleException(e);
            n.LIZIZ(compatibleException2, "");
            throw compatibleException2;
        }
    }

    public final m LJ(SSK ssk) {
        boolean z;
        int i;
        int i2;
        LinkedHashMap linkedHashMap;
        SSK ssk2 = ssk;
        M12.LIZ(ssk2);
        try {
            RealApi LIZ2 = LIZ();
            long j = ssk2.LJIIIIZZ;
            String str = ssk2.LIZ;
            String str2 = ssk2.LJIIJ;
            int i3 = ssk2.LJIIIZ;
            int i4 = ssk2.LJ;
            String str3 = ssk2.LJI;
            String str4 = ssk2.LJII;
            String str5 = ssk2.LIZJ;
            int i5 = ssk2.LJFF;
            AVG avg = ssk2.LJIIJJI;
            if (avg != null) {
                z = avg.isDefaultOption();
            } else {
                z = true;
            }
            int i6 = 0;
            if (!z) {
                i = 1;
            } else {
                i = 0;
            }
            AVG avg2 = ssk2.LJIIJJI;
            if (avg2 != null) {
                i2 = avg2.getFilterBy();
            } else {
                i2 = 0;
            }
            try {
                AVG avg3 = ssk2.LJIIJJI;
                if (avg3 != null) {
                    i6 = avg3.getSortType();
                }
                AVG avg4 = ssk2.LJIIJJI;
                if (avg4 == null || (linkedHashMap = avg4.activityToFieldMap()) == null) {
                    linkedHashMap = new LinkedHashMap();
                }
                Object obj = LIZ2.searchDynamicMusicList(j, str, str2, i3, i4, str3, str4, "music", str5, i5, i, i2, i6, linkedHashMap, ssk2.LJIJI).get();
                n.LIZIZ(obj, "");
                return (m) obj;
            } catch (ExecutionException e) {
                e = e;
                RuntimeException compatibleException = JMB.getCompatibleException(e);
                n.LIZIZ(compatibleException, "");
                throw compatibleException;
            }
        } catch (ExecutionException e2) {
            e = e2;
            RuntimeException compatibleException2 = JMB.getCompatibleException(e);
            n.LIZIZ(compatibleException2, "");
            throw compatibleException2;
        }
    }

    public final SearchLiveList LIZ(String str, long j, String str2, String str3, String str4, String str5) {
        String str6 = str;
        String str7 = str2;
        String str8 = str3;
        String str9 = str5;
        M12.LIZ(str6, str7, str8, str9);
        try {
            Object obj = LIZ().searchLiveList(j, str6, 20, str8, str4, str9, "", str7, "", "").get();
            n.LIZIZ(obj, "");
            return (SearchLiveList) obj;
        } catch (ExecutionException e) {
            RuntimeException compatibleException = JMB.getCompatibleException(e);
            n.LIZIZ(compatibleException, "");
            throw compatibleException;
        }
    }
}
