package o;

import java.util.ArrayList;
import java.util.List;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.b7, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C0786b7 implements Appendable {
    public final StringBuilder l = new StringBuilder(16);
    public final ArrayList m;

    public C0786b7(C0977d7 c0977d7) {
        new ArrayList();
        this.m = new ArrayList();
        new ArrayList();
        a(c0977d7);
    }

    public final void a(C0977d7 c0977d7) {
        StringBuilder sb = this.l;
        int length = sb.length();
        sb.append(c0977d7.m);
        List list = c0977d7.l;
        if (list != null) {
            int size = list.size();
            for (int i = 0; i < size; i++) {
                C0881c7 c0881c7 = (C0881c7) list.get(i);
                this.m.add(new C0690a7(c0881c7.a, c0881c7.b + length, c0881c7.c + length, c0881c7.d));
            }
        }
    }

    @Override // java.lang.Appendable
    public final Appendable append(CharSequence charSequence) {
        if (charSequence instanceof C0977d7) {
            a((C0977d7) charSequence);
            return this;
        }
        this.l.append(charSequence);
        return this;
    }

    public final C0977d7 b() {
        StringBuilder sb = this.l;
        String string = sb.toString();
        ArrayList arrayList = this.m;
        ArrayList arrayList2 = new ArrayList(arrayList.size());
        int size = arrayList.size();
        for (int i = 0; i < size; i++) {
            C0690a7 c0690a7 = (C0690a7) arrayList.get(i);
            int length = sb.length();
            int i2 = c0690a7.c;
            if (i2 != Integer.MIN_VALUE) {
                length = i2;
            }
            if (length == Integer.MIN_VALUE) {
                AbstractC2228qH.b("Item.end should be set first");
            }
            arrayList2.add(new C0881c7(c0690a7.a, c0690a7.b, length, c0690a7.d));
        }
        return new C0977d7(string, arrayList2);
    }

    @Override // java.lang.Appendable
    public final Appendable append(CharSequence charSequence, int i, int i2) {
        boolean z = charSequence instanceof C0977d7;
        StringBuilder sb = this.l;
        if (z) {
            C0977d7 c0977d7 = (C0977d7) charSequence;
            int length = sb.length();
            sb.append((CharSequence) c0977d7.m, i, i2);
            List listA = AbstractC1168f7.a(c0977d7, i, i2, null);
            if (listA != null) {
                int size = listA.size();
                for (int i3 = 0; i3 < size; i3++) {
                    C0881c7 c0881c7 = (C0881c7) listA.get(i3);
                    this.m.add(new C0690a7(c0881c7.a, c0881c7.b + length, c0881c7.c + length, c0881c7.d));
                }
            }
            return this;
        }
        sb.append(charSequence, i, i2);
        return this;
    }

    @Override // java.lang.Appendable
    public final Appendable append(char c) {
        this.l.append(c);
        return this;
    }
}
