X-plore v4.37.09版本的 MD5 值为:1ac588cd7c13e9578c2d4266387e2f4f

以下内容为反编译后的 e.java 源代码,内容仅作参考


package K6;

import B.hRCx.IaBiDJU;
import E7.GoWq.crhKwHUeawinK;
import F2.ZMqY.WdjwpVRPRVA;
import F6.AbstractC1142k;
import F6.AbstractC1143l;
import F6.C;
import F6.C1141j;
import F6.C1145n;
import F6.F;
import F7.C1160d;
import F7.t;
import F7.w;
import P.AbstractC1363o;
import P.F0;
import P.InterfaceC1357l;
import P.P0;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.accounts.AccountManagerCallback;
import android.accounts.AccountsException;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Parcelable;
import b7.x;
import c3.dDy.EPlQ;
import com.lonelycatgames.Xplore.App;
import com.lonelycatgames.Xplore.FileSystem.h;
import h7.AbstractC6725n;
import h7.AbstractC6736y;
import h7.C6709J;
import h7.C6730s;
import h7.InterfaceC6723l;
import i7.AbstractC6821C;
import i7.Q;
import i7.S;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import o6.ji.wDaOapwXfiyW;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import p3.KLvM.OJPcPhffzFBKVl;
import r.aa.pWhGPktqxGVuO;
import u6.AbstractC7556B;
import v7.InterfaceC7625a;
import w7.AbstractC7771k;
import w7.AbstractC7777q;
import w7.AbstractC7780t;
import w7.AbstractC7781u;
import w7.AbstractC7784x;
import w7.C7755N;
import w7.C7759S;
import z.InterfaceC7946a;
import z6.AbstractC7990b;
import z6.AbstractC7992d;
import z6.C7989a;

public final class e extends K6.b implements AbstractC7992d.j {

    public static final d f6744B0 = new d(null);

    public static final int f6745C0 = 8;

    private static final AbstractC7990b.C0993b f6746D0 = new b(AbstractC7556B.f55683V0, c.f6756I);

    private static final SimpleDateFormat f6747E0;

    private static final SimpleDateFormat f6748F0;

    private static final Map f6749G0;

    private final InterfaceC6723l f6750A0;

    private final String f6751w0;

    private Intent f6752x0;

    private a f6753y0;

    private final String f6754z0;

    public static final class a extends Account {

        private String f6755a;

        public a(String str, String str2) {
            super(str, "com.google");
            AbstractC7780t.f(str, "name");
            this.f6755a = str2;
        }

        public final String a() {
            return this.f6755a;
        }

        public final void b(String str) {
            this.f6755a = str;
        }
    }

    public static final class b extends AbstractC7990b.C0993b {
        b(int i9, c cVar) {
            super(i9, "Google Drive", cVar, true);
        }

        @Override
        public boolean a(App app) {
            AbstractC7780t.f(app, "app");
            return App.f43875F0.k(app) || e.f6744B0.g(app);
        }
    }

    class c extends AbstractC7777q implements v7.p {

        public static final c f6756I = new c();

        c() {
            super(2, e.class, "<init>", "<init>(Lcom/lonelycatgames/Xplore/FileSystem/net/CloudFileSystem;Landroid/net/Uri;)V", 0);
        }

        @Override
        public final e r(C7989a c7989a, Uri uri) {
            AbstractC7780t.f(c7989a, "p0");
            AbstractC7780t.f(uri, "p1");
            return new e(c7989a, uri, null);
        }
    }

    public static final class d {
        private d() {
        }

        public d(AbstractC7771k abstractC7771k) {
            this();
        }

        public final boolean g(App app) {
            return com.lonelycatgames.Xplore.e.v(app.U(), "google_drive_oauth", false, 2, null);
        }

        public final boolean i(C c9) {
            AbstractC7992d.j jVar = c9 instanceof AbstractC7992d.j ? (AbstractC7992d.j) c9 : null;
            if (jVar != null) {
                return jVar.o("in_shared_drives") || jVar.o("shared_drive");
            }
            return false;
        }

        public final boolean j(C c9) {
            AbstractC7992d.j jVar = c9 instanceof AbstractC7992d.j ? (AbstractC7992d.j) c9 : null;
            if (jVar != null) {
                return jVar.o("shared_drives");
            }
            return false;
        }

        public final boolean k(C c9) {
            AbstractC7992d.j jVar = c9 instanceof AbstractC7992d.j ? (AbstractC7992d.j) c9 : null;
            if (jVar != null) {
                return jVar.o("trash") || jVar.o("in_trash");
            }
            return false;
        }

        public final JSONObject l(String str, String str2) {
            URLConnection openConnection = new URL("https://oauth2.googleapis.com/token").openConnection();
            AbstractC7780t.d(openConnection, "null cannot be cast to non-null type java.net.HttpURLConnection");
            HttpURLConnection httpURLConnection = (HttpURLConnection) openConnection;
            httpURLConnection.setRequestMethod("POST");
            httpURLConnection.setDoOutput(true);
            String str3 = "grant_type=" + str + "&client_id=489911891903-lofc7cesboa1tnaa532f2ukr4gmag46g.apps.googleusercontent.com&client_secret=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&redirect_uri=" + Uri.encode("https://www.lonelycatgames.com/internal/xplore/authcode") + '&' + str2;
            httpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            OutputStream outputStream = httpURLConnection.getOutputStream();
            try {
                byte[] bytes = str3.getBytes(C1160d.f4033b);
                AbstractC7780t.e(bytes, "getBytes(...)");
                outputStream.write(bytes);
                C6709J c6709j = C6709J.f49946a;
                t7.c.a(outputStream, null);
                int responseCode = httpURLConnection.getResponseCode();
                if (responseCode != 200) {
                    throw new IOException("Invalid response: " + responseCode);
                }
                InputStream inputStream = httpURLConnection.getInputStream();
                try {
                    AbstractC7780t.c(inputStream);
                    String o02 = t6.k.o0(inputStream);
                    t7.c.a(inputStream, null);
                    try {
                        return new JSONObject(o02);
                    } catch (JSONException e9) {
                        throw new IOException(t6.k.Q(e9));
                    }
                } finally {
                }
            } finally {
            }
        }

        public final long m(JSONObject jSONObject) {
            String optString = jSONObject.optString("modifiedTime");
            if (optString.length() <= 0) {
                optString = null;
            }
            if (optString != null) {
                return AbstractC7990b.f60542s0.e(optString, e.f6747E0, true);
            }
            return 0L;
        }

        public final AbstractC7990b.C0993b h() {
            return e.f6746D0;
        }
    }

    public static final class C0200e extends A6.a {

        public static final class a extends AbstractC7781u implements InterfaceC7625a {

            final String f6757b;

            a(String str) {
                super(0);
                this.f6757b = str;
            }

            @Override
            public final Object c() {
                return e.f6744B0.l("authorization_code", "code=" + this.f6757b);
            }
        }

        public static final class b extends AbstractC7781u implements v7.l {
            b() {
                super(1);
            }

            public final void a(Object obj) {
                AbstractC7780t.f(obj, "r");
                boolean z8 = false | false;
                String str = obj instanceof String ? (String) obj : null;
                if (obj instanceof JSONObject) {
                    JSONObject jSONObject = (JSONObject) obj;
                    String optString = jSONObject.optString("access_token");
                    AbstractC7780t.c(optString);
                    if (optString.length() > 0) {
                        C0200e.J(C0200e.this).u3(optString, jSONObject.optString("refresh_token"));
                        C0200e.this.f();
                        C1141j.o1(C0200e.J(C0200e.this), C0200e.this.u(), false, null, 6, null);
                        return;
                    } else {
                        String optString2 = jSONObject.optString("error_description");
                        AbstractC7780t.c(optString2);
                        String str2 = optString2.length() > 0 ? optString2 : null;
                        str = str2 == null ? jSONObject.optString("error", "Auth failed") : str2;
                    }
                }
                C0200e.this.G(str);
            }

            @Override
            public Object h(Object obj) {
                a(obj);
                return C6709J.f49946a;
            }
        }

        public C0200e(X6.m mVar, e eVar) {
            super(mVar, eVar, "https://www.lonelycatgames.com/internal/xplore/authcode", false, 8, null);
            AbstractC7780t.f(mVar, "p");
            AbstractC7780t.f(eVar, "server");
        }

        public static final e J(C0200e c0200e) {
            return (e) c0200e.v();
        }

        @Override
        protected void A(String str) {
            AbstractC7780t.f(str, "url");
            Uri parse = Uri.parse(str);
            AbstractC7780t.e(parse, "parse(...)");
            L(parse);
        }

        @Override
        protected void F(String str) {
            AbstractC7780t.f(str, "s");
            App.f43875F0.e(str);
        }

        @Override
        public void H() {
            w().getSettings().setUserAgentString("Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Mobile Safari/537.36");
            w().loadUrl(((e) v()).L3().toString());
        }

        public final void L(Uri uri) {
            AbstractC7780t.f(uri, "uri");
            String queryParameter = uri.getQueryParameter("code");
            if (queryParameter != null) {
                B(new a(queryParameter), new b());
                return;
            }
            String queryParameter2 = uri.getQueryParameter("error_description");
            if (queryParameter2 == null) {
                queryParameter2 = uri.getQueryParameter("error");
            }
            G(queryParameter2);
        }
    }

    private static final class f extends AbstractC7992d.l {

        private String f6759g0;

        public f(AbstractC7992d abstractC7992d, String str, Map map) {
            super(abstractC7992d, str, map);
            AbstractC7780t.f(abstractC7992d, "server");
            AbstractC7780t.f(str, "id");
        }

        @Override
        public Object clone() {
            return super.clone();
        }

        public final String x1() {
            return this.f6759g0;
        }

        public final void y1(String str) {
            this.f6759g0 = str;
        }
    }

    private static final class g extends AbstractC7992d.b {

        private final String f6760j0;

        public g(AbstractC7990b abstractC7990b, String str, Map map, String str2, long j9) {
            super(abstractC7990b, str, j9, map);
            AbstractC7780t.f(abstractC7990b, "se");
            AbstractC7780t.f(str, "id");
            this.f6760j0 = str2;
        }

        public g(AbstractC7990b abstractC7990b, String str, Map map, String str2, long j9, int i9, AbstractC7771k abstractC7771k) {
            this(abstractC7990b, str, map, (i9 & 8) != 0 ? null : str2, (i9 & 16) != 0 ? 0L : j9);
        }

        @Override
        public void I(F f9, CharSequence charSequence) {
            AbstractC7780t.f(f9, "vh");
            if (charSequence == null) {
                charSequence = this.f6760j0;
            }
            super.I(f9, charSequence);
        }

        @Override
        public Object clone() {
            return super.clone();
        }
    }

    private final class h extends OutputStream implements h.l {

        private final OutputStream f6761E;

        private C1145n f6762F;

        final e f6763G;

        private final HttpURLConnection f6764a;

        private final String f6765b;

        private final C1141j f6766c;

        private String f6767d;

        private String f6768e;

        public h(e eVar, HttpURLConnection httpURLConnection, String str, String str2, String str3, C1141j c1141j) {
            AbstractC7780t.f(httpURLConnection, EPlQ.xjqFbEkYjxZtG);
            AbstractC7780t.f(str, "metadataJson");
            AbstractC7780t.f(str2, "mimeType");
            AbstractC7780t.f(str3, "fullPath");
            this.f6763G = eVar;
            this.f6764a = httpURLConnection;
            this.f6765b = str3;
            this.f6766c = c1141j;
            httpURLConnection.setDoOutput(true);
            httpURLConnection.setChunkedStreamingMode(16384);
            String f9 = f();
            httpURLConnection.setRequestProperty("Content-Type", "multipart/related; charset=UTF-8; boundary=" + f9);
            StringBuilder sb = new StringBuilder();
            sb.append("Media multipart posting\r\n\r\n");
            j(sb, f9, "application/json; charset=UTF-8");
            t.i(sb, str, "\r\n");
            j(sb, f9, str2);
            this.f6767d = sb.toString();
            this.f6768e = "\r\n--" + f9 + "--\r\n";
            OutputStream outputStream = httpURLConnection.getOutputStream();
            AbstractC7780t.e(outputStream, "getOutputStream(...)");
            this.f6761E = outputStream;
        }

        private final String d(HttpURLConnection httpURLConnection, int i9) {
            String str = null;
            try {
                InputStream errorStream = httpURLConnection.getErrorStream();
                if (errorStream != null) {
                    str = this.f6763G.V1(t6.k.o0(errorStream), httpURLConnection.getHeaderField("Content-Type"));
                    t6.k.k(errorStream);
                }
            } catch (IOException unused) {
            }
            if (str != null) {
                return str;
            }
            if (i9 == 0) {
                return "HTTP ERROR";
            }
            return "HTTP ERROR: " + i9;
        }

        private final String f() {
            StringBuilder sb = new StringBuilder();
            int c9 = A7.c.f419a.c(11) + 30;
            for (int i9 = 0; i9 < c9; i9++) {
                int c10 = A7.c.f419a.c(62);
                sb.append((char) (c10 < 10 ? c10 + 48 : c10 < 36 ? c10 + 87 : c10 + 29));
            }
            String sb2 = sb.toString();
            AbstractC7780t.e(sb2, "toString(...)");
            return sb2;
        }

        private final void h() {
            String str = this.f6767d;
            if (str != null) {
                OutputStream outputStream = this.f6761E;
                byte[] bytes = str.getBytes(C1160d.f4033b);
                AbstractC7780t.e(bytes, "getBytes(...)");
                outputStream.write(bytes);
                this.f6767d = null;
            }
        }

        private final void j(StringBuilder sb, String str, String str2) {
            sb.append("--");
            sb.append(str);
            sb.append("\r\n");
            if (str2 != null) {
                t.i(sb, "Content-Type", ": ", str2, "\r\n");
            }
            sb.append("\r\n");
        }

        @Override
        public C1145n b() {
            close();
            C1145n c1145n = this.f6762F;
            if (c1145n == null) {
                throw new FileNotFoundException();
            }
            if (c1145n != null) {
                return c1145n;
            }
            AbstractC7780t.r("createdFile");
            return null;
        }

        @Override
        public void close() {
            Set E8;
            String str = this.f6768e;
            if (str == null) {
                return;
            }
            h();
            flush();
            OutputStream outputStream = this.f6761E;
            byte[] bytes = str.getBytes(C1160d.f4033b);
            AbstractC7780t.e(bytes, "getBytes(...)");
            outputStream.write(bytes);
            this.f6768e = null;
            this.f6761E.close();
            int responseCode = this.f6764a.getResponseCode();
            if (responseCode != 200 && responseCode != 201) {
                throw new IOException("Upload error code: " + d(this.f6764a, responseCode));
            }
            JSONObject g9 = AbstractC7990b.f60542s0.g(this.f6764a);
            long m9 = e.f6744B0.m(g9);
            com.lonelycatgames.Xplore.FileSystem.h h02 = this.f6763G.h0();
            e eVar = this.f6763G;
            String string = g9.getString("id");
            AbstractC7780t.e(string, "getString(...)");
            this.f6762F = h02.P(new AbstractC7992d.k(eVar, string, null, 4, null), this.f6765b, m9, this.f6766c);
            Cloneable cloneable = this.f6766c;
            C7989a.b bVar = cloneable instanceof C7989a.b ? (C7989a.b) cloneable : null;
            if (bVar != null && (E8 = bVar.E()) != null) {
                E8.add(this.f6763G.p0());
            }
            this.f6763G.o3(true);
        }

        @Override
        public Void write(int i9) {
            throw new IllegalStateException("not supported".toString());
        }

        @Override
        public void write(byte[] bArr, int i9, int i10) {
            AbstractC7780t.f(bArr, "buffer");
            h();
            this.f6761E.write(bArr, i9, i10);
        }
    }

    public static final class i extends AbstractC7992d.b {

        private final int f6769j0;

        public static final class a extends AbstractC7781u implements v7.p {

            final InterfaceC7946a f6771c;

            final b0.g f6772d;

            final int f6773e;

            a(InterfaceC7946a interfaceC7946a, b0.g gVar, int i9) {
                super(2);
                this.f6771c = interfaceC7946a;
                this.f6772d = gVar;
                this.f6773e = i9;
            }

            public final void a(InterfaceC1357l interfaceC1357l, int i9) {
                i.this.k1(this.f6771c, this.f6772d, interfaceC1357l, F0.a(this.f6773e | 1));
            }

            @Override
            public Object r(Object obj, Object obj2) {
                a((InterfaceC1357l) obj, ((Number) obj2).intValue());
                return C6709J.f49946a;
            }
        }

        public i(AbstractC7990b abstractC7990b, String str) {
            super(abstractC7990b, "", 0L, r6, 4, null);
            Map e9;
            AbstractC7780t.f(abstractC7990b, "se");
            AbstractC7780t.f(str, "name");
            e9 = Q.e(AbstractC6736y.a("shared_drives", ""));
            this.f6769j0 = super.y0() - 3;
            c1(str);
        }

        @Override
        public Object clone() {
            return super.clone();
        }

        @Override
        public void k1(InterfaceC7946a interfaceC7946a, b0.g gVar, InterfaceC1357l interfaceC1357l, int i9) {
            int i10;
            AbstractC7780t.f(interfaceC7946a, "<this>");
            AbstractC7780t.f(gVar, "modifier");
            InterfaceC1357l p9 = interfaceC1357l.p(525985963);
            if ((i9 & 14) == 0) {
                i10 = (p9.P(interfaceC7946a) ? 4 : 2) | i9;
            } else {
                i10 = i9;
            }
            if ((i9 & 112) == 0) {
                i10 |= p9.P(gVar) ? 32 : 16;
            }
            if ((i10 & 91) == 18 && p9.s()) {
                p9.z();
            } else {
                if (AbstractC1363o.G()) {
                    AbstractC1363o.S(525985963, i10, -1, "com.lonelycatgames.Xplore.clouds.GoogleDriveServerV4.SharedDrivesDirEntry.DrawIconOverlay (GoogleDriveServerV4.kt:379)");
                }
                AbstractC1142k.f(interfaceC7946a, gVar, p9, (i10 & 14) | (i10 & 112));
                if (AbstractC1363o.G()) {
                    AbstractC1363o.R();
                }
            }
            P0 v8 = p9.v();
            if (v8 != null) {
                v8.a(new a(interfaceC7946a, gVar, i9));
            }
        }

        @Override
        public int y0() {
            return this.f6769j0;
        }
    }

    public static final class j extends AbstractC7992d.b {

        private final int f6774j0;

        public static final class a extends AbstractC7781u implements v7.p {

            final InterfaceC7946a f6776c;

            final b0.g f6777d;

            final int f6778e;

            a(InterfaceC7946a interfaceC7946a, b0.g gVar, int i9) {
                super(2);
                this.f6776c = interfaceC7946a;
                this.f6777d = gVar;
                this.f6778e = i9;
            }

            public final void a(InterfaceC1357l interfaceC1357l, int i9) {
                j.this.k1(this.f6776c, this.f6777d, interfaceC1357l, F0.a(this.f6778e | 1));
            }

            @Override
            public Object r(Object obj, Object obj2) {
                a((InterfaceC1357l) obj, ((Number) obj2).intValue());
                return C6709J.f49946a;
            }
        }

        public j(AbstractC7990b abstractC7990b, String str) {
            super(abstractC7990b, "", 0L, r6, 4, null);
            Map e9;
            AbstractC7780t.f(abstractC7990b, "se");
            AbstractC7780t.f(str, "name");
            e9 = Q.e(AbstractC6736y.a("shared_with_me", ""));
            this.f6774j0 = super.y0() - 2;
            c1(str);
        }

        @Override
        public Object clone() {
            return super.clone();
        }

        @Override
        public void k1(InterfaceC7946a interfaceC7946a, b0.g gVar, InterfaceC1357l interfaceC1357l, int i9) {
            int i10;
            AbstractC7780t.f(interfaceC7946a, "<this>");
            AbstractC7780t.f(gVar, "modifier");
            InterfaceC1357l p9 = interfaceC1357l.p(1833365430);
            if ((i9 & 14) == 0) {
                i10 = (p9.P(interfaceC7946a) ? 4 : 2) | i9;
            } else {
                i10 = i9;
            }
            if ((i9 & 112) == 0) {
                i10 |= p9.P(gVar) ? 32 : 16;
            }
            if ((i10 & 91) == 18 && p9.s()) {
                p9.z();
            } else {
                if (AbstractC1363o.G()) {
                    AbstractC1363o.S(1833365430, i10, -1, "com.lonelycatgames.Xplore.clouds.GoogleDriveServerV4.SharedWithMeDirEntry.DrawIconOverlay (GoogleDriveServerV4.kt:365)");
                }
                AbstractC1142k.c(interfaceC7946a, gVar, p9, (i10 & 14) | (i10 & 112));
                if (AbstractC1363o.G()) {
                    AbstractC1363o.R();
                }
            }
            P0 v8 = p9.v();
            if (v8 != null) {
                v8.a(new a(interfaceC7946a, gVar, i9));
            }
        }

        @Override
        public int y0() {
            return this.f6774j0;
        }
    }

    public static final class k extends AbstractC7992d.b {

        private final int f6779j0;

        public static final class a extends AbstractC7781u implements v7.p {

            final InterfaceC7946a f6781c;

            final b0.g f6782d;

            final int f6783e;

            a(InterfaceC7946a interfaceC7946a, b0.g gVar, int i9) {
                super(2);
                this.f6781c = interfaceC7946a;
                this.f6782d = gVar;
                this.f6783e = i9;
            }

            public final void a(InterfaceC1357l interfaceC1357l, int i9) {
                k.this.k1(this.f6781c, this.f6782d, interfaceC1357l, F0.a(this.f6783e | 1));
            }

            @Override
            public Object r(Object obj, Object obj2) {
                a((InterfaceC1357l) obj, ((Number) obj2).intValue());
                return C6709J.f49946a;
            }
        }

        public k(AbstractC7990b abstractC7990b, String str) {
            super(abstractC7990b, "", 0L, r6, 4, null);
            Map e9;
            AbstractC7780t.f(abstractC7990b, "se");
            AbstractC7780t.f(str, "name");
            e9 = Q.e(AbstractC6736y.a("trash", ""));
            this.f6779j0 = super.y0() - 1;
            c1(str);
        }

        @Override
        public Object clone() {
            return super.clone();
        }

        @Override
        public void k1(InterfaceC7946a interfaceC7946a, b0.g gVar, InterfaceC1357l interfaceC1357l, int i9) {
            int i10;
            AbstractC7780t.f(interfaceC7946a, "<this>");
            AbstractC7780t.f(gVar, "modifier");
            InterfaceC1357l p9 = interfaceC1357l.p(-1820270059);
            if ((i9 & 14) == 0) {
                i10 = (p9.P(interfaceC7946a) ? 4 : 2) | i9;
            } else {
                i10 = i9;
            }
            if ((i9 & 112) == 0) {
                i10 |= p9.P(gVar) ? 32 : 16;
            }
            if ((i10 & 91) == 18 && p9.s()) {
                p9.z();
            } else {
                if (AbstractC1363o.G()) {
                    AbstractC1363o.S(-1820270059, i10, -1, "com.lonelycatgames.Xplore.clouds.GoogleDriveServerV4.TrashDirEntry.DrawIconOverlay (GoogleDriveServerV4.kt:352)");
                }
                AbstractC1142k.e(interfaceC7946a, gVar, p9, (i10 & 14) | (i10 & 112));
                if (AbstractC1363o.G()) {
                    AbstractC1363o.R();
                }
            }
            P0 v8 = p9.v();
            if (v8 != null) {
                v8.a(new a(interfaceC7946a, gVar, i9));
            }
        }

        @Override
        public int y0() {
            return this.f6779j0;
        }
    }

    public static final class l extends AbstractC7781u implements v7.p {

        final X6.m f6785c;

        l(X6.m mVar) {
            super(2);
            this.f6785c = mVar;
        }

        public final void a(boolean z8, Intent intent) {
            if (!z8 || intent == null) {
                e.this.M3(this.f6785c);
                return;
            }
            String stringExtra = intent.getStringExtra("authAccount");
            if (stringExtra != null) {
                e eVar = e.this;
                X6.m mVar = this.f6785c;
                AbstractC7990b.l3(eVar, Uri.encode(stringExtra), null, 2, null);
                C1141j.o1(eVar, mVar, true, null, 4, null);
            }
        }

        @Override
        public Object r(Object obj, Object obj2) {
            a(((Boolean) obj).booleanValue(), (Intent) obj2);
            return C6709J.f49946a;
        }
    }

    public static final class m extends AbstractC7781u implements v7.p {

        final X6.m f6787c;

        m(X6.m mVar) {
            super(2);
            this.f6787c = mVar;
        }

        public final void a(boolean z8, Intent intent) {
            if (z8) {
                return;
            }
            e.this.f6753y0 = null;
            if (e.f6744B0.g(e.this.V())) {
                App.D2(e.this.V(), "Trying alternative way to login", false, 2, null);
                e.this.M3(this.f6787c);
            }
        }

        @Override
        public Object r(Object obj, Object obj2) {
            a(((Boolean) obj).booleanValue(), (Intent) obj2);
            return C6709J.f49946a;
        }
    }

    static final class n extends AbstractC7781u implements InterfaceC7625a {
        n() {
            super(0);
        }

        @Override
        public final Boolean c() {
            boolean z8 = false;
            try {
                if (e.this.G3("drives?fields=drives(id)").getJSONArray("drives").length() > 0) {
                    z8 = true;
                }
            } catch (Exception e9) {
                e9.printStackTrace();
            }
            return Boolean.valueOf(z8);
        }
    }

    public static final class o extends AbstractC7992d.k {

        private final String f6789a0;

        o(C7755N c7755n, C7755N c7755n2, Map map, AbstractC7992d abstractC7992d) {
            super(abstractC7992d, (String) r3, map);
            Object obj = c7755n2.f58206a;
            AbstractC7780t.e(obj, "element");
            this.f6789a0 = (String) c7755n.f58206a;
        }

        @Override
        public Object clone() {
            return super.clone();
        }

        @Override
        public String l0() {
            return this.f6789a0;
        }
    }

    public static final class q extends AbstractC7781u implements v7.l {

        final boolean f6790b;

        final JSONObject f6791c;

        q(boolean z8, JSONObject jSONObject) {
            super(1);
            this.f6790b = z8;
            this.f6791c = jSONObject;
        }

        public final void a(HttpURLConnection httpURLConnection) {
            AbstractC7780t.f(httpURLConnection, "$this$createAndRunHttpConnection");
            if (this.f6790b) {
                httpURLConnection.setRequestProperty("X-HTTP-Method-Override", "PATCH");
            }
            if (this.f6791c != null) {
                httpURLConnection.setDoOutput(true);
                httpURLConnection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
                OutputStream outputStream = httpURLConnection.getOutputStream();
                AbstractC7780t.e(outputStream, "getOutputStream(...)");
                String jSONObject = this.f6791c.toString();
                AbstractC7780t.e(jSONObject, "toString(...)");
                t6.k.N0(outputStream, jSONObject);
            }
        }

        @Override
        public Object h(Object obj) {
            a((HttpURLConnection) obj);
            return C6709J.f49946a;
        }
    }

    static {
        Map j9;
        Locale locale = Locale.US;
        f6747E0 = new SimpleDateFormat("y-M-d'T'H:m:s", locale);
        f6748F0 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", locale);
        j9 = S.j(AbstractC6736y.a("docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"), AbstractC6736y.a("pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation"), AbstractC6736y.a("png", "image/png"), AbstractC6736y.a("xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"));
        f6749G0 = j9;
    }

    private e(C7989a c7989a, Uri uri) {
        super(c7989a, uri, AbstractC7556B.f55683V0, null, 8, null);
        InterfaceC6723l b9;
        this.f6751w0 = "root";
        this.f6754z0 = V().o0() + " (gzip)";
        e1("Google Drive");
        t2(uri);
        b9 = AbstractC6725n.b(new n());
        this.f6750A0 = b9;
    }

    public e(C7989a c7989a, Uri uri, AbstractC7771k abstractC7771k) {
        this(c7989a, uri);
    }

    private final synchronized void D3() {
        try {
            a aVar = this.f6753y0;
            if (aVar == null) {
                w3();
            } else if (aVar.a() == null) {
                try {
                    if (!J3(aVar)) {
                        App.f43875F0.v("Failed to get Google auth token");
                    }
                } catch (AccountsException e9) {
                    e9.printStackTrace();
                    App.f43875F0.v("Failed to get Google auth token: " + e9.getMessage());
                    throw new IOException(t6.k.Q(e9));
                }
            }
        } catch (Throwable th) {
            throw th;
        }
    }

    private final String F3(AbstractC7992d.j jVar) {
        String format;
        if (jVar.o("trash")) {
            format = "explicitlyTrashed=true";
        } else if (jVar.o("shared_with_me")) {
            format = "sharedWithMe=true";
        } else {
            C7759S c7759s = C7759S.f58210a;
            format = String.format(Locale.ROOT, "'%s' in parents", Arrays.copyOf(new Object[]{jVar.a()}, 1));
            AbstractC7780t.e(format, "format(...)");
        }
        return format;
    }

    public final JSONObject G3(String str) {
        return H3(null, "https://www.googleapis.com/drive/v3/" + str);
    }

    private final JSONObject H3(String str, String str2) {
        HttpURLConnection O22;
        String b9 = AbstractC7990b.f60542s0.b(str2, "prettyPrint=false");
        try {
            O22 = AbstractC7990b.O2(this, str, b9, null, 4, null);
        } catch (h.j e9) {
            a aVar = this.f6753y0;
            C6709J c6709j = null;
            if (aVar != null) {
                if (aVar.a() == null) {
                    throw e9;
                }
                AccountManager.get(V()).invalidateAuthToken(((Account) aVar).type, aVar.a());
                aVar.b(null);
                try {
                    if (!J3(aVar)) {
                        throw e9;
                    }
                    c6709j = C6709J.f49946a;
                } catch (AccountsException unused) {
                    throw e9;
                }
            }
            if (c6709j == null) {
                Y2();
            }
            O22 = AbstractC7990b.O2(this, str, b9, null, 4, null);
        }
        return AbstractC7990b.f60542s0.g(O22);
    }

    private final String I3(C c9, String str) {
        AbstractC7990b.c cVar;
        String f9;
        boolean t9;
        try {
            cVar = AbstractC7990b.f60542s0;
            f9 = cVar.f(c9);
        } catch (Exception e9) {
            e9.printStackTrace();
        }
        if (f9 == null) {
            return null;
        }
        String b9 = cVar.b("files", "fields=files(id,name)");
        C7759S c7759s = C7759S.f58210a;
        String format = String.format(Locale.ROOT, "'%s' in parents AND name='%s' AND trashed=false", Arrays.copyOf(new Object[]{f9, str}, 2));
        AbstractC7780t.e(format, "format(...)");
        String b10 = cVar.b(b9, "q=" + Uri.encode(format));
        if (f6744B0.i(c9)) {
            b10 = cVar.b(b10, "supportsAllDrives=true&includeItemsFromAllDrives=true");
        }
        JSONArray jSONArray = G3(b10).getJSONArray("files");
        if (jSONArray.length() > 0) {
            JSONObject jSONObject = jSONArray.getJSONObject(0);
            String string = jSONObject.getString("name");
            t9 = w.t(str, string, true);
            if (t9) {
                return jSONObject.getString("id");
            }
            throw new IllegalStateException(("Name mismatch: " + string + "!=" + str).toString());
        }
        return null;
    }

    private final boolean J3(a aVar) {
        Parcelable parcelable;
        Object parcelable2;
        AccountManager accountManager = AccountManager.get(V());
        AbstractC7780t.e(accountManager, "get(...)");
        boolean z8 = false;
        Bundle result = accountManager.getAuthToken((Account) aVar, "oauth2:https://www.googleapis.com/auth/drive", (Bundle) null, false, (AccountManagerCallback<Bundle>) null, (Handler) null).getResult();
        AbstractC7780t.e(result, "getResult(...)");
        Bundle bundle = result;
        aVar.b(bundle.getString("authtoken"));
        if (aVar.a() != null) {
            return true;
        }
        b7.t tVar = b7.t.f22031a;
        if (Build.VERSION.SDK_INT >= 33) {
            parcelable2 = bundle.getParcelable("intent", Intent.class);
            parcelable = (Parcelable) parcelable2;
        } else {
            parcelable = (Intent) bundle.getParcelable("intent");
        }
        Intent intent = (Intent) parcelable;
        this.f6752x0 = intent;
        if (intent == null) {
            return false;
        }
        throw new h.j("Authorize access for " + ((Account) aVar).name);
    }

    private final boolean K3() {
        return ((Boolean) this.f6750A0.getValue()).booleanValue();
    }

    public final Uri.Builder L3() {
        return new Uri.Builder().scheme("https").authority("accounts.google.com").path("o/oauth2/v2/auth").appendQueryParameter("prompt", "consent").appendQueryParameter("access_type", "offline").appendQueryParameter("response_type", "code").appendQueryParameter("client_id", "489911891903-lofc7cesboa1tnaa532f2ukr4gmag46g.apps.googleusercontent.com").appendQueryParameter("scope", "https://www.googleapis.com/auth/drive").appendQueryParameter("redirect_uri", "https://www.lonelycatgames.com/internal/xplore/authcode");
    }

    public final void M3(X6.m mVar) {
        if (!f6744B0.g(V())) {
            App.D2(V(), "Device doesn't have Google services", false, 2, null);
        } else if (V().v1()) {
            G(new C0200e(mVar, this), mVar);
        } else {
            Uri.Builder L32 = L3();
            AbstractC7780t.e(L32, "<get-loginUrl>(...)");
            AbstractC7990b.E2(this, mVar, L32, null, null, 12, null);
        }
    }

    private static final String N3(e eVar, String str) {
        return eVar.G3("files/" + str + "?fields=thumbnailLink").optString("thumbnailLink");
    }

    private final JSONObject O3(String str, String str2, JSONObject jSONObject) {
        boolean a9 = AbstractC7780t.a("PATCH", str);
        if (a9) {
            str = "POST";
        }
        return AbstractC7990b.f60542s0.g(N2(str, "https://www.googleapis.com/drive/v3/" + str2, new q(a9, jSONObject)));
    }

    @Override
    public boolean A2() {
        return true;
    }

    @Override
    protected void C2(HttpURLConnection httpURLConnection) {
        AbstractC7780t.f(httpURLConnection, "con");
        a aVar = this.f6753y0;
        C6709J c6709j = null;
        if (aVar != null) {
            String a9 = aVar.a();
            if (a9 == null) {
                throw new h.j(null, 1, null);
            }
            httpURLConnection.setRequestProperty("Authorization", "Bearer " + a9);
            c6709j = C6709J.f49946a;
        }
        if (c6709j == null) {
            super.C2(httpURLConnection);
        }
        httpURLConnection.setRequestProperty("User-Agent", this.f6754z0);
    }

    public final void E3(X6.m mVar) {
        AbstractC7780t.f(mVar, "pane");
        if (this.f6753y0 != null) {
            Intent intent = this.f6752x0;
            if (intent != null) {
                this.f6752x0 = null;
                try {
                    mVar.X0().Q3(intent, new m(mVar));
                    return;
                } catch (Exception e9) {
                    e9.printStackTrace();
                    return;
                }
            }
            return;
        }
        if (!App.f43875F0.k(V())) {
            M3(mVar);
            return;
        }
        Intent newChooseAccountIntent = AccountManager.newChooseAccountIntent(null, null, new String[]{"com.google"}, null, null, null, null);
        AbstractC7780t.e(newChooseAccountIntent, OJPcPhffzFBKVl.XHnLoCLEK);
        try {
            mVar.X0().Q3(newChooseAccountIntent, new l(mVar));
        } catch (Exception e10) {
            V().z2(e10);
        }
    }

    @Override
    public boolean F2(C1141j c1141j) {
        AbstractC7780t.f(c1141j, "de");
        if (f6744B0.k(c1141j)) {
            return false;
        }
        return G2(c1141j);
    }

    @Override
    public boolean G2(C1141j c1141j) {
        AbstractC7780t.f(c1141j, "de");
        if (!(c1141j instanceof AbstractC7992d.j)) {
            return false;
        }
        AbstractC7992d.j jVar = (AbstractC7992d.j) c1141j;
        return (jVar.o("trash") || jVar.o("shared_drives") || jVar.o(IaBiDJU.XffZDgT) || t6.k.Y(jVar.i("caps"), 1)) ? false : true;
    }

    @Override
    public boolean H2(C c9) {
        AbstractC7780t.f(c9, "le");
        if (!AbstractC7780t.a(c9, this) && (c9 instanceof AbstractC7992d.j)) {
            AbstractC7992d.j jVar = (AbstractC7992d.j) c9;
            if (!jVar.o("trash") && !jVar.o("shared_drives") && !jVar.o(WdjwpVRPRVA.svJpWSYT) && !t6.k.Y(jVar.i("caps"), 2)) {
                return true;
            }
        }
        return false;
    }

    @Override
    public boolean J2(C c9) {
        AbstractC7780t.f(c9, "le");
        if ((c9 instanceof AbstractC7992d.j) && !t6.k.Y(((AbstractC7992d.j) c9).i("caps"), 4)) {
            return super.J2(c9);
        }
        return false;
    }

    @Override
    public boolean K2(C c9) {
        AbstractC7780t.f(c9, "le");
        return !f6744B0.k(c9);
    }

    @Override
    protected boolean M2(C1141j c1141j, String str) {
        AbstractC7780t.f(c1141j, "dir");
        AbstractC7780t.f(str, "name");
        return I3(c1141j, str) != null;
    }

    @Override
    public C1141j P2(C1141j c1141j, String str) {
        Map hashMap;
        AbstractC7780t.f(c1141j, "parent");
        AbstractC7780t.f(str, "name");
        Map t9 = ((AbstractC7992d.j) c1141j).t();
        if (t9 == null || hashMap == null) {
            hashMap = new HashMap();
        }
        Map map = hashMap;
        if (map.remove("shared_drive") != null) {
            map.put("in_shared_drives", "");
        }
        String I32 = I3(c1141j, str);
        if (I32 != null) {
            return new AbstractC7992d.b(this, I32, 0L, map, 4, null);
        }
        AbstractC7990b.c cVar = AbstractC7990b.f60542s0;
        String f9 = cVar.f(c1141j);
        String b9 = cVar.b("files", "fields=id");
        if (f6744B0.i(c1141j)) {
            b9 = cVar.b(b9, "supportsAllDrives=true");
        }
        String string = O3("POST", b9, t6.k.c0(AbstractC6736y.a("name", str), AbstractC6736y.a(N1("D2UYQJeXPefKh3SWP4cuVQ"), "application/vnd.google-apps.folder"), AbstractC6736y.a("parents", t6.k.b0(f9)))).getString("id");
        AbstractC7780t.c(string);
        return new AbstractC7992d.b(this, string, t6.k.B(), map);
    }

    @Override
    public void R2(C c9) {
        AbstractC7780t.f(c9, "le");
        AbstractC7990b.c cVar = AbstractC7990b.f60542s0;
        String str = "files/" + cVar.f(c9);
        d dVar = f6744B0;
        if (dVar.k(c9)) {
            AbstractC7990b.O2(this, "DELETE", "https://www.googleapis.com/drive/v3/" + str, null, 4, null);
            return;
        }
        String b9 = cVar.b(str, crhKwHUeawinK.wvElAQjW);
        if (dVar.i(c9)) {
            b9 = cVar.b(b9, "supportsAllDrives=true");
        }
        O3("PATCH", b9, t6.k.c0(AbstractC6736y.a(N1("kRXjQE6fhWL/fYISukbDZQ"), Boolean.TRUE)));
    }

    @Override
    public OutputStream S1(C c9, String str, long j9, Long l9) {
        AbstractC7780t.f(c9, "le");
        d dVar = f6744B0;
        if (dVar.k(c9)) {
            throw new IOException("Can't write in Trash");
        }
        AbstractC7990b.c cVar = AbstractC7990b.f60542s0;
        String f9 = cVar.f(c9);
        if (f9 == null) {
            throw new IOException("No file id");
        }
        String I32 = str != null ? I3(c9, str) : f9;
        Uri.Builder appendQueryParameter = Uri.parse("https://www.googleapis.com/upload/drive/v3/files").buildUpon().appendQueryParameter("uploadType", "multipart");
        if (I32 != null) {
            appendQueryParameter.appendPath(I32);
        }
        if (dVar.i(c9)) {
            appendQueryParameter.appendQueryParameter("supportsAllDrives", "true");
        }
        appendQueryParameter.appendQueryParameter("fields", "id,name,modifiedTime");
        Uri build = appendQueryParameter.build();
        AbstractC7780t.e(build, "build(...)");
        HttpURLConnection h02 = t6.k.h0(build);
        try {
            D3();
            C2(h02);
            JSONObject jSONObject = new JSONObject();
            if (I32 != null) {
                h02.setRequestMethod("PATCH");
            } else {
                if (str == null) {
                    throw new IllegalStateException("Check failed.".toString());
                }
                h02.setRequestMethod("POST");
                jSONObject.put("name", str);
                jSONObject.put(N1("B3oFnMlae42VSgRiDlNUEA"), t6.k.b0(f9));
            }
            if (l9 != null) {
                jSONObject.put("modifiedTime", cVar.c(l9.longValue(), f6748F0, true));
            }
            String E8 = t6.k.E(str == null ? c9.p0() : str);
            String B02 = V().B0(E8);
            String y8 = B02 == null ? t6.k.y(E8) : B02;
            String jSONObject2 = jSONObject.toString();
            AbstractC7780t.e(jSONObject2, "toString(...)");
            return new h(this, h02, jSONObject2, y8, str != null ? c9.j0(str) : c9.i0(), str != null ? c9 instanceof C1141j ? (C1141j) c9 : null : c9.u0());
        } catch (h.j e9) {
            throw new IOException(t6.k.Q(e9));
        }
    }

    @Override
    public AbstractC7990b.C0993b U2() {
        return f6746D0;
    }

    @Override
    public String V1(String str, String str2) {
        boolean D8;
        AbstractC7780t.f(str, "content");
        if (str2 != null) {
            int i9 = 3 << 0;
            D8 = w.D(str2, "application/json", false, 2, null);
            if (D8) {
                try {
                    String optString = new JSONObject(str).getJSONObject("error").optString("message");
                    AbstractC7780t.c(optString);
                    if (optString.length() > 0) {
                        return optString;
                    }
                } catch (JSONException e9) {
                    e9.printStackTrace();
                }
            }
        }
        return super.V1(str, str2);
    }

    @Override
    public boolean Z2(AbstractC7990b abstractC7990b) {
        AbstractC7780t.f(abstractC7990b, "other");
        return this.f6753y0 == null ? super.Z2(abstractC7990b) : AbstractC7780t.a(a2(), abstractC7990b.a2());
    }

    @Override
    public String a() {
        return this.f6751w0;
    }

    @Override
    public Object clone() {
        return super.clone();
    }

    @Override
    public void d3(C c9, C1141j c1141j, String str) {
        String c02;
        AbstractC7780t.f(c9, "le");
        AbstractC7780t.f(c1141j, "newParent");
        if (L2(c1141j, str == null ? c9.p0() : str)) {
            throw new IOException("File already exists");
        }
        AbstractC7990b.c cVar = AbstractC7990b.f60542s0;
        String f9 = cVar.f(c9);
        JSONArray jSONArray = G3(cVar.b("files/" + f9, "fields=parents")).getJSONArray("parents");
        AbstractC7780t.e(jSONArray, "getJSONArray(...)");
        List L02 = t6.k.L0(jSONArray);
        String b9 = cVar.b("files/" + f9, "fields=id");
        String f10 = cVar.f(c1141j);
        if (!L02.isEmpty()) {
            StringBuilder sb = new StringBuilder();
            sb.append("removeParents=");
            c02 = AbstractC6821C.c0(L02, ",", null, null, 0, null, null, 62, null);
            sb.append(c02);
            b9 = cVar.b(b9, sb.toString());
        }
        String b10 = cVar.b(b9, "addParents=" + f10);
        d dVar = f6744B0;
        if (dVar.i(c9)) {
            b10 = cVar.b(b10, "supportsAllDrives=true");
        }
        JSONObject jSONObject = new JSONObject();
        if (dVar.k(c9)) {
            jSONObject.put("trashed", false);
        }
        if (str != null) {
            jSONObject.put("name", str);
        }
        Long valueOf = Long.valueOf(c9.m());
        if (valueOf.longValue() == 0) {
            valueOf = null;
        }
        if (valueOf != null) {
            jSONObject.put("modifiedTime", cVar.c(valueOf.longValue(), f6748F0, true));
        }
        O3("PATCH", b10, jSONObject);
    }

    @Override
    public boolean e3() {
        return false;
    }

    @Override
    public void f3(Uri uri, X6.m mVar) {
        AbstractC7780t.f(uri, "uri");
        AbstractC7780t.f(mVar, "pane");
        C0200e c0200e = new C0200e(mVar, this);
        c0200e.L(uri);
        G(c0200e, mVar);
    }

    @Override
    public int i(String str) {
        return AbstractC7992d.j.a.c(this, str);
    }

    @Override
    public void i3(C c9, String str) {
        AbstractC7780t.f(c9, "le");
        AbstractC7780t.f(str, "newName");
        if (AbstractC7780t.a(c9, this)) {
            j3(str);
        } else {
            AbstractC7990b.c cVar = AbstractC7990b.f60542s0;
            String b9 = cVar.b("files/" + cVar.f(c9), "fields=id");
            if (f6744B0.i(c9)) {
                b9 = cVar.b(b9, "supportsAllDrives=true");
            }
            O3("PATCH", b9, t6.k.c0(AbstractC6736y.a(N1("KwBlG3ag8x7WczGxiwEQ2w"), str)));
        }
    }

    @Override
    public void j2(h.f fVar) {
        String F32;
        String b9;
        boolean z8;
        String b10;
        String str;
        String str2;
        C c9;
        String str3;
        HashMap hashMap;
        Map u9;
        int i9;
        String str4;
        int i10;
        HashMap hashMap2;
        C7755N c7755n;
        String str5;
        String str6;
        String str7;
        String str8;
        JSONArray jSONArray;
        String str9;
        boolean D8;
        o oVar;
        C1145n c1145n;
        long j9;
        String str10;
        Map u10;
        int i11;
        String str11;
        String str12;
        String str13;
        HashMap hashMap3;
        String str14;
        String str15;
        Map t9;
        AbstractC7780t.f(fVar, "lister");
        D3();
        super.j2(fVar);
        try {
            ?? m9 = fVar.m();
            d dVar = f6744B0;
            String str16 = "files";
            String str17 = "drives";
            String str18 = "getString(...)";
            if (dVar.j(m9)) {
                b10 = AbstractC7990b.f60542s0.b("drives", "fields=*");
            } else {
                if (AbstractC7780t.a(m9, this)) {
                    C7759S c7759s = C7759S.f58210a;
                    String format = String.format(Locale.ROOT, "'%s' in parents", Arrays.copyOf(new Object[]{"root"}, 1));
                    AbstractC7780t.e(format, "format(...)");
                    String string = V().getString(u6.F.f56481s2);
                    AbstractC7780t.e(string, "getString(...)");
                    fVar.d(new k(this, string));
                    String string2 = V().getString(u6.F.f56471r2);
                    AbstractC7780t.e(string2, "getString(...)");
                    fVar.d(new j(this, string2));
                    if (K3()) {
                        String string3 = V().getString(u6.F.f56241T5);
                        AbstractC7780t.e(string3, "getString(...)");
                        fVar.d(new i(this, string3));
                    }
                    F32 = format;
                    z8 = true;
                    b9 = "files";
                } else {
                    AbstractC7780t.d(m9, "null cannot be cast to non-null type com.lonelycatgames.Xplore.FileSystem.net.ServerEntry.ServerEntryWithId");
                    F32 = F3((AbstractC7992d.j) m9);
                    if (!dVar.j(m9) && !dVar.i(m9)) {
                        b9 = "files";
                        z8 = !dVar.k(m9);
                    }
                    b9 = AbstractC7990b.f60542s0.b("files", "supportsAllDrives=true&includeItemsFromAllDrives=true");
                    z8 = !dVar.k(m9);
                }
                if (z8) {
                    F32 = F32 + " AND trashed=false";
                }
                if (F32.length() > 0) {
                    b9 = AbstractC7990b.f60542s0.b(b9, "q=" + Uri.encode(F32));
                }
                b10 = AbstractC7990b.f60542s0.b(b9, "fields=nextPageToken,files(kind,id,name,mimeType,modifiedTime,size,description,shortcutDetails)");
            }
            String str19 = b10;
            HashMap hashMap4 = new HashMap();
            AbstractC7992d.j jVar = m9 instanceof AbstractC7992d.j ? (AbstractC7992d.j) m9 : null;
            String str20 = "caps";
            if (jVar != null && (t9 = jVar.t()) != null) {
                for (Map.Entry entry : t9.entrySet()) {
                    String str21 = (String) entry.getKey();
                    String str22 = (String) entry.getValue();
                    switch (str21.hashCode()) {
                        case -800155735:
                            if (!str21.equals("in_shared_drives")) {
                                break;
                            }
                            break;
                        case -711194320:
                            if (str21.equals("shared_drive")) {
                                hashMap4.put("in_shared_drives", str22);
                                break;
                            } else {
                                continue;
                            }
                        case -572187325:
                            if (str21.equals("shared_drives")) {
                                hashMap4.put("shared_drive", str22);
                                break;
                            } else {
                                continue;
                            }
                        case -16960610:
                            if (!str21.equals("in_trash")) {
                                break;
                            }
                            break;
                        case 3046113:
                            if (!str21.equals("caps")) {
                                break;
                            }
                            break;
                        case 110621496:
                            if (str21.equals("trash")) {
                                hashMap4.put("in_trash", str22);
                                break;
                            } else {
                                continue;
                            }
                    }
                    hashMap4.put(str21, str22);
                }
            }
            String str23 = null;
            C c10 = m9;
            while (true) {
                JSONObject G32 = G3(str23 != null ? AbstractC7990b.f60542s0.b(str19, "pageToken=" + str23) : str19);
                String X8 = t6.k.X(G32, "nextPageToken");
                String str24 = "name";
                String str25 = "id";
                String str26 = "kind";
                if (f6744B0.j(c10)) {
                    JSONArray jSONArray2 = G32.getJSONArray(str17);
                    AbstractC7780t.e(jSONArray2, "getJSONArray(...)");
                    int length = jSONArray2.length();
                    int i12 = 0;
                    C c11 = c10;
                    while (i12 < length) {
                        String str27 = str19;
                        JSONObject jSONObject = (JSONObject) jSONArray2.get(i12);
                        C c12 = c11;
                        u10 = S.u(hashMap4);
                        int i13 = i12;
                        String string4 = jSONObject.getString(str26);
                        JSONArray jSONArray3 = jSONArray2;
                        if (AbstractC7780t.a(string4, "drive#drive")) {
                            JSONObject jSONObject2 = jSONObject.getJSONObject("capabilities");
                            int i14 = !jSONObject2.optBoolean(wDaOapwXfiyW.wnu) ? 1 : 0;
                            i11 = length;
                            if (!jSONObject2.optBoolean("canRename")) {
                                i14 |= 4;
                            }
                            if (!jSONObject2.optBoolean("canTrashChildren")) {
                                i14 |= 2;
                            }
                            if (i14 != 0) {
                                u10.put(str20, String.valueOf(i14));
                            }
                            String string5 = jSONObject.getString(str25);
                            AbstractC7780t.e(string5, str18);
                            str11 = str20;
                            str12 = str26;
                            str13 = str25;
                            hashMap3 = hashMap4;
                            str14 = str27;
                            str15 = str17;
                            AbstractC7992d.b bVar = new AbstractC7992d.b(this, string5, 0L, u10, 4, null);
                            bVar.Z0(jSONObject.optBoolean("hidden"));
                            String string6 = jSONObject.getString("name");
                            AbstractC7780t.e(string6, str18);
                            fVar.c(bVar, string6);
                        } else {
                            i11 = length;
                            str11 = str20;
                            str12 = str26;
                            str13 = str25;
                            hashMap3 = hashMap4;
                            str14 = str27;
                            str15 = str17;
                            App.f43875F0.v("Unsupported drive kind: " + string4);
                        }
                        i12 = i13 + 1;
                        hashMap4 = hashMap3;
                        str19 = str14;
                        c11 = c12;
                        str17 = str15;
                        jSONArray2 = jSONArray3;
                        length = i11;
                        str20 = str11;
                        str26 = str12;
                        str25 = str13;
                    }
                    str = str20;
                    str2 = str19;
                    c9 = c11;
                    str3 = str17;
                    hashMap = hashMap4;
                } else {
                    str = str20;
                    String str28 = "kind";
                    String str29 = "id";
                    str2 = str19;
                    c9 = c10;
                    str3 = str17;
                    HashMap hashMap5 = hashMap4;
                    JSONArray jSONArray4 = G32.getJSONArray(str16);
                    AbstractC7780t.e(jSONArray4, "getJSONArray(...)");
                    int length2 = jSONArray4.length();
                    int i15 = 0;
                    while (i15 < length2) {
                        JSONObject jSONObject3 = (JSONObject) jSONArray4.get(i15);
                        String str30 = str28;
                        String string7 = jSONObject3.getString(str30);
                        if (AbstractC7780t.a(string7, "drive#file")) {
                            u9 = S.u(hashMap5);
                            C7755N c7755n2 = new C7755N();
                            c7755n2.f58206a = jSONObject3.getString(str24);
                            C7755N c7755n3 = new C7755N();
                            String str31 = str29;
                            c7755n3.f58206a = jSONObject3.getString(str31);
                            String optString = jSONObject3.optString("mimeType");
                            str29 = str31;
                            if (AbstractC7780t.a(optString, "application/vnd.google-apps.shortcut")) {
                                JSONObject optJSONObject = jSONObject3.optJSONObject("shortcutDetails");
                                if (optJSONObject != null) {
                                    String optString2 = optJSONObject.optString("targetMimeType");
                                    c7755n3.f58206a = optJSONObject.optString("targetId");
                                    optString = optString2;
                                }
                            }
                            i9 = i15;
                            long m10 = f6744B0.m(jSONObject3);
                            str4 = str24;
                            if (AbstractC7780t.a(optString, "application/vnd.google-apps.folder")) {
                                String X9 = t6.k.X(jSONObject3, "description");
                                Object obj = c7755n3.f58206a;
                                AbstractC7780t.e(obj, "element");
                                str6 = str29;
                                str5 = str30;
                                i10 = length2;
                                hashMap2 = hashMap5;
                                str7 = "element";
                                jSONArray = jSONArray4;
                                str9 = str18;
                                c1145n = new g(this, (String) obj, u9, X9, 0L, 16, null);
                                c7755n = c7755n2;
                                str8 = str16;
                            } else {
                                i10 = length2;
                                hashMap2 = hashMap5;
                                c7755n = c7755n2;
                                str5 = str30;
                                str6 = str29;
                                str7 = "element";
                                Object obj2 = c7755n.f58206a;
                                AbstractC7780t.e(obj2, str7);
                                String E8 = t6.k.E((String) obj2);
                                C7755N c7755n4 = new C7755N();
                                str8 = str16;
                                String B02 = V().B0(E8);
                                if (B02 == null) {
                                    B02 = optString.length() > 0 ? optString : null;
                                }
                                c7755n4.f58206a = B02;
                                jSONArray = jSONArray4;
                                str9 = str18;
                                long optLong = jSONObject3.optLong("size", -1L);
                                String g9 = x5.p.f58787a.g((String) c7755n4.f58206a);
                                if (fVar.E((String) c7755n4.f58206a)) {
                                    Object obj3 = c7755n3.f58206a;
                                    AbstractC7780t.e(obj3, str7);
                                    c1145n = new f(this, (String) obj3, u9);
                                } else if (fVar.G(g9, E8)) {
                                    Object obj4 = c7755n3.f58206a;
                                    AbstractC7780t.e(obj4, str7);
                                    c1145n = new AbstractC7992d.n(this, (String) obj4, u9);
                                } else if (fVar.D(g9, E8)) {
                                    Object obj5 = c7755n3.f58206a;
                                    AbstractC7780t.e(obj5, str7);
                                    c1145n = new AbstractC7992d.f(this, (String) obj5, u9);
                                } else if (fVar.F((String) c7755n4.f58206a)) {
                                    Object obj6 = c7755n3.f58206a;
                                    AbstractC7780t.e(obj6, str7);
                                    c1145n = new AbstractC7992d.m(this, (String) obj6, u9);
                                } else {
                                    AbstractC7780t.c(optString);
                                    D8 = w.D(optString, "application/vnd.google-apps.", false, 2, null);
                                    if (D8) {
                                        AbstractC7780t.c(optString);
                                        String substring = optString.substring(28);
                                        AbstractC7780t.e(substring, "substring(...)");
                                        switch (substring.hashCode()) {
                                            case -2120983604:
                                                if (substring.equals("spreadsheet")) {
                                                    str10 = "xlsx";
                                                    break;
                                                }
                                                break;
                                            case 696975130:
                                                if (substring.equals("presentation")) {
                                                    str10 = "pptx";
                                                    break;
                                                } else {
                                                    break;
                                                }
                                            case 861720859:
                                                if (substring.equals("document")) {
                                                    str10 = "docx";
                                                    break;
                                                } else {
                                                    break;
                                                }
                                            case 1913009182:
                                                if (substring.equals("drawing")) {
                                                    str10 = "png";
                                                    break;
                                                } else {
                                                    break;
                                                }
                                        }
                                        str10 = null;
                                        if (str10 != null) {
                                            c7755n4.f58206a = f6749G0.get(str10);
                                            u9.put("export", str10);
                                            oVar = new o(c7755n, c7755n3, u9, c());
                                            c7755n.f58206a = ((String) c7755n.f58206a) + '.' + str10;
                                            optLong = -1;
                                            if (oVar != null) {
                                                Object obj7 = c7755n3.f58206a;
                                                AbstractC7780t.e(obj7, str7);
                                                c1145n = new AbstractC7992d.k(this, (String) obj7, u9);
                                            } else {
                                                c1145n = oVar;
                                            }
                                            j9 = optLong;
                                            c1145n.m1(m10);
                                            c1145n.l1(j9);
                                            c1145n.n1((String) c7755n4.f58206a);
                                        }
                                    }
                                    oVar = null;
                                    if (oVar != null) {
                                    }
                                    j9 = optLong;
                                    c1145n.m1(m10);
                                    c1145n.l1(j9);
                                    c1145n.n1((String) c7755n4.f58206a);
                                }
                                j9 = optLong;
                                c1145n.m1(m10);
                                c1145n.l1(j9);
                                c1145n.n1((String) c7755n4.f58206a);
                            }
                            Object obj8 = c7755n.f58206a;
                            AbstractC7780t.e(obj8, str7);
                            fVar.c(c1145n, (String) obj8);
                            i15 = i9 + 1;
                            str24 = str4;
                            str16 = str8;
                            hashMap5 = hashMap2;
                            str18 = str9;
                            str29 = str6;
                            length2 = i10;
                            jSONArray4 = jSONArray;
                            str28 = str5;
                        } else {
                            App.f43875F0.v("Unsupported file kind: " + string7);
                        }
                        i9 = i15;
                        str5 = str30;
                        i10 = length2;
                        str4 = str24;
                        hashMap2 = hashMap5;
                        str8 = str16;
                        jSONArray = jSONArray4;
                        str9 = str18;
                        str6 = str29;
                        i15 = i9 + 1;
                        str24 = str4;
                        str16 = str8;
                        hashMap5 = hashMap2;
                        str18 = str9;
                        str29 = str6;
                        length2 = i10;
                        jSONArray4 = jSONArray;
                        str28 = str5;
                    }
                    hashMap = hashMap5;
                }
                String str32 = str16;
                String str33 = str18;
                if (X8 == null || fVar.r()) {
                    return;
                }
                str23 = X8;
                str19 = str2;
                c10 = c9;
                str17 = str3;
                str16 = str32;
                hashMap4 = hashMap;
                str18 = str33;
                str20 = str;
            }
        } catch (JSONException e9) {
            throw new IOException(t6.k.Q(e9));
        }
    }

    @Override
    public InputStream k2(C c9, int i9, long j9) {
        String N32;
        AbstractC7780t.f(c9, "le");
        if (!(c9 instanceof AbstractC7992d.j)) {
            throw new IOException("Not server entry");
        }
        try {
            D3();
            String f9 = AbstractC7990b.f60542s0.f(c9);
            if (i9 == 1) {
                try {
                    if (c9 instanceof f) {
                        N32 = ((f) c9).x1();
                        if (N32 == null) {
                            N32 = N3(this, f9);
                            new AbstractC7784x(c9) {
                                @Override
                                public Object get() {
                                    return ((f) this.f58225b).x1();
                                }

                                @Override
                                public void set(Object obj) {
                                    ((f) this.f58225b).y1((String) obj);
                                }
                            }.set(N32);
                        }
                    } else {
                        N32 = N3(this, f9);
                    }
                } catch (Exception unused) {
                }
                if (N32 == null) {
                    String str = "https://www.googleapis.com/drive/v3/files/" + f9;
                    String s9 = ((AbstractC7992d.j) c9).s("export");
                    if (s9 != null) {
                        AbstractC7990b.c cVar = AbstractC7990b.f60542s0;
                        str = cVar.b(str + "/export", "mimeType=" + ((String) f6749G0.get(s9)));
                    }
                    N32 = AbstractC7990b.f60542s0.b(str, "alt=media");
                }
                return AbstractC7990b.h3(this, N32, j9, false, 4, null);
            }
            N32 = null;
            if (N32 == null) {
            }
            return AbstractC7990b.h3(this, N32, j9, false, 4, null);
        } catch (h.j e9) {
            throw new IOException(t6.k.Q(e9));
        }
    }

    @Override
    public boolean o(String str) {
        return AbstractC7992d.j.a.b(this, str);
    }

    @Override
    public C1141j o2(C c9) {
        AbstractC7992d.h hVar;
        List L02;
        Object V8;
        AbstractC7780t.f(c9, "le");
        D3();
        JSONArray optJSONArray = G3("files/" + AbstractC7990b.f60542s0.f(c9) + "?fields=parents").optJSONArray("parents");
        if (optJSONArray != null && (L02 = t6.k.L0(optJSONArray)) != null) {
            V8 = AbstractC6821C.V(L02);
            String str = (String) V8;
            if (str != null) {
                hVar = new AbstractC7992d.h(this, str);
                return hVar;
            }
        }
        hVar = null;
        return hVar;
    }

    @Override
    protected void p3(HttpURLConnection httpURLConnection) {
        String str;
        String responseMessage;
        String headerField;
        boolean D8;
        InputStream errorStream;
        AbstractC7780t.f(httpURLConnection, "con");
        try {
            errorStream = httpURLConnection.getErrorStream();
        } catch (Exception unused) {
        }
        if (errorStream != null) {
            str = t6.k.o0(errorStream);
            int responseCode = httpURLConnection.getResponseCode();
            if (str != null && responseCode == 403 && (headerField = httpURLConnection.getHeaderField(pWhGPktqxGVuO.eiFJUD)) != null) {
                int i9 = 2 >> 2;
                D8 = w.D(headerField, "application/json", false, 2, null);
                if (D8) {
                    try {
                        if (AbstractC7780t.a(new JSONObject(str).getJSONObject("error").getJSONArray("errors").getJSONObject(0).getString("reason"), "userRateLimitExceeded")) {
                            Thread.sleep(300L);
                            return;
                        }
                    } catch (JSONException unused2) {
                    }
                }
            }
            responseMessage = httpURLConnection.getResponseMessage();
            if (responseMessage == null) {
                responseMessage = "";
            }
            throw new x.c(responseCode, responseMessage, "HTTP err: " + W1(str, httpURLConnection));
        }
        str = null;
        int responseCode2 = httpURLConnection.getResponseCode();
        if (str != null) {
            int i92 = 2 >> 2;
            D8 = w.D(headerField, "application/json", false, 2, null);
            if (D8) {
            }
        }
        responseMessage = httpURLConnection.getResponseMessage();
        if (responseMessage == null) {
        }
        throw new x.c(responseCode2, responseMessage, "HTTP err: " + W1(str, httpURLConnection));
    }

    @Override
    public void q3(C c9) {
        AbstractC7780t.f(c9, "le");
        JSONObject G32 = G3("files/" + AbstractC7990b.f60542s0.f(c9) + "?fields=size,modifiedTime");
        long m9 = f6744B0.m(G32);
        if (c9 instanceof C1145n) {
            C1145n c1145n = (C1145n) c9;
            c1145n.m1(m9);
            c1145n.l1(G32.optLong("size", -1L));
        }
    }

    @Override
    protected void r3() {
        String str;
        JSONObject optJSONObject;
        String X8;
        try {
            Uri a22 = a2();
            boolean z8 = (a22 != null ? a22.getFragment() : null) == null;
            if (z8) {
                str = "storageQuota,user";
            } else {
                str = "storageQuota";
            }
            JSONObject G32 = G3("about?fields=" + str);
            JSONObject jSONObject = G32.getJSONObject("storageQuota");
            m3(new AbstractC1143l.b(jSONObject.optLong("usage"), jSONObject.optLong("limit")));
            if (!z8 || (optJSONObject = G32.optJSONObject("user")) == null || (X8 = t6.k.X(optJSONObject, "displayName")) == null) {
                return;
            }
            i3(this, X8);
        } catch (JSONException e9) {
            throw new IOException(t6.k.Q(e9));
        }
    }

    @Override
    public String s(String str) {
        return AbstractC7992d.j.a.d(this, str);
    }

    @Override
    public Map t() {
        return AbstractC7992d.j.a.a(this);
    }

    @Override
    public void t2(Uri uri) {
        boolean H8;
        String userInfo = uri != null ? uri.getUserInfo() : null;
        if (userInfo != null) {
            H8 = F7.x.H(userInfo, '@', false, 2, null);
            if (H8) {
                s3(uri, false);
                n3(null);
                if (userInfo != null) {
                    a aVar = this.f6753y0;
                    this.f6753y0 = new a(userInfo, aVar != null ? aVar.a() : null);
                    String fragment = uri.getFragment();
                    if (fragment != null) {
                        userInfo = fragment;
                    }
                    c1(userInfo);
                    return;
                }
                return;
            }
        }
        super.t2(uri);
    }

    @Override
    protected C6730s t3(String str) {
        AbstractC7780t.f(str, "refreshToken");
        return AbstractC6736y.a(f6744B0.l("refresh_token", "refresh_token=" + str).getString("access_token"), str);
    }

    @Override
    public boolean z2() {
        return true;
    }
}