package b1;

import C3.D;
import C3.E;
import C3.G;
import C3.W;
import N1.C0207h;
import java.io.IOException;
import java.io.StringReader;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
import u0.F;
import x0.AbstractC1709a;

/* JADX INFO: renamed from: b1.d, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public abstract class AbstractC0532d {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final String[] f9180a = {"Camera:MotionPhoto", "GCamera:MotionPhoto", "Camera:MicroVideo", "GCamera:MicroVideo"};

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final String[] f9181b = {"Camera:MotionPhotoPresentationTimestampUs", "GCamera:MotionPhotoPresentationTimestampUs", "Camera:MicroVideoPresentationTimestampUs", "GCamera:MicroVideoPresentationTimestampUs"};

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final String[] f9182c = {"Camera:MicroVideoOffset", "GCamera:MicroVideoOffset"};

    /* JADX WARN: Code restructure failed: missing block: B:42:0x00c4, code lost:
    
        return null;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static C0207h a(String str) throws XmlPullParserException, IOException {
        long j8;
        XmlPullParser xmlPullParserNewPullParser = XmlPullParserFactory.newInstance().newPullParser();
        xmlPullParserNewPullParser.setInput(new StringReader(str));
        xmlPullParserNewPullParser.next();
        if (!AbstractC1709a.v(xmlPullParserNewPullParser, "x:xmpmeta")) {
            throw F.a(null, "Couldn't find xmp metadata");
        }
        E e8 = G.f1197r;
        W wB = W.f1225u;
        long j9 = -9223372036854775807L;
        loop0: while (true) {
            xmlPullParserNewPullParser.next();
            if (AbstractC1709a.v(xmlPullParserNewPullParser, "rdf:Description")) {
                String[] strArr = f9180a;
                int i = 0;
                int i5 = 0;
                while (true) {
                    if (i5 >= 4) {
                        break loop0;
                    }
                    String strR = AbstractC1709a.r(xmlPullParserNewPullParser, strArr[i5]);
                    if (strR == null) {
                        i5++;
                    } else {
                        if (Integer.parseInt(strR) != 1) {
                            break;
                        }
                        String[] strArr2 = f9181b;
                        int i8 = 0;
                        while (true) {
                            if (i8 >= 4) {
                                break;
                            }
                            String strR2 = AbstractC1709a.r(xmlPullParserNewPullParser, strArr2[i8]);
                            if (strR2 != null) {
                                j8 = Long.parseLong(strR2);
                                if (j8 == -1) {
                                    break;
                                }
                            } else {
                                i8++;
                            }
                        }
                        j8 = -9223372036854775807L;
                        String[] strArr3 = f9182c;
                        while (true) {
                            if (i >= 2) {
                                E e9 = G.f1197r;
                                wB = W.f1225u;
                                break;
                            }
                            String strR3 = AbstractC1709a.r(xmlPullParserNewPullParser, strArr3[i]);
                            if (strR3 != null) {
                                wB = G.s(new C0530b(0L, "image/jpeg", 0L), new C0530b(Long.parseLong(strR3), "video/mp4", 0L));
                                break;
                            }
                            i++;
                        }
                        j9 = j8;
                    }
                }
            } else if (AbstractC1709a.v(xmlPullParserNewPullParser, "Container:Directory")) {
                wB = b(xmlPullParserNewPullParser, "Container", "Item");
            } else if (AbstractC1709a.v(xmlPullParserNewPullParser, "GContainer:Directory")) {
                wB = b(xmlPullParserNewPullParser, "GContainer", "GContainerItem");
            }
            if (AbstractC1709a.u(xmlPullParserNewPullParser, "x:xmpmeta")) {
                if (!wB.isEmpty()) {
                    return new C0207h(1, j9, wB);
                }
            }
        }
    }

    public static W b(XmlPullParser xmlPullParser, String str, String str2) throws XmlPullParserException, IOException {
        D dJ = G.j();
        String strConcat = str.concat(":Item");
        String strConcat2 = str.concat(":Directory");
        do {
            xmlPullParser.next();
            if (AbstractC1709a.v(xmlPullParser, strConcat)) {
                String strConcat3 = str2.concat(":Mime");
                String strConcat4 = str2.concat(":Semantic");
                String strConcat5 = str2.concat(":Length");
                String strConcat6 = str2.concat(":Padding");
                String strR = AbstractC1709a.r(xmlPullParser, strConcat3);
                String strR2 = AbstractC1709a.r(xmlPullParser, strConcat4);
                String strR3 = AbstractC1709a.r(xmlPullParser, strConcat5);
                String strR4 = AbstractC1709a.r(xmlPullParser, strConcat6);
                if (strR == null || strR2 == null) {
                    return W.f1225u;
                }
                dJ.a(new C0530b(strR3 != null ? Long.parseLong(strR3) : 0L, strR, strR4 != null ? Long.parseLong(strR4) : 0L));
            }
        } while (!AbstractC1709a.u(xmlPullParser, strConcat2));
        return dJ.g();
    }
}
