package androidx.emoji2.text;

import android.text.PrecomputedText;
import android.text.Spannable;
import android.text.SpannableString;
import java.util.stream.IntStream;

/* loaded from: classes.dex */
class q implements Spannable {

    /* renamed from: p, reason: collision with root package name */
    private boolean f4329p = false;

    /* renamed from: q, reason: collision with root package name */
    private Spannable f4330q;

    /* loaded from: classes.dex */
    private static class a {
        static IntStream a(CharSequence charSequence) {
            return charSequence.chars();
        }

        static IntStream b(CharSequence charSequence) {
            return charSequence.codePoints();
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static class b {
        b() {
        }

        abstract boolean a(CharSequence charSequence);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static class c extends b {
        c() {
        }

        @Override // androidx.emoji2.text.q.b
        boolean a(CharSequence charSequence) {
            return (charSequence instanceof PrecomputedText) || (charSequence instanceof androidx.core.text.d);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public q(Spannable spannable) {
        this.f4330q = spannable;
    }

    private void a() {
        Spannable spannable = this.f4330q;
        if (!this.f4329p && c().a(spannable)) {
            this.f4330q = new SpannableString(spannable);
        }
        this.f4329p = true;
    }

    static b c() {
        return new c();
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public Spannable b() {
        return this.f4330q;
    }

    @Override // java.lang.CharSequence
    public char charAt(int i10) {
        return this.f4330q.charAt(i10);
    }

    @Override // java.lang.CharSequence
    public IntStream chars() {
        return a.a(this.f4330q);
    }

    @Override // java.lang.CharSequence
    public IntStream codePoints() {
        return a.b(this.f4330q);
    }

    @Override // android.text.Spanned
    public int getSpanEnd(Object obj) {
        return this.f4330q.getSpanEnd(obj);
    }

    @Override // android.text.Spanned
    public int getSpanFlags(Object obj) {
        return this.f4330q.getSpanFlags(obj);
    }

    @Override // android.text.Spanned
    public int getSpanStart(Object obj) {
        return this.f4330q.getSpanStart(obj);
    }

    @Override // android.text.Spanned
    public Object[] getSpans(int i10, int i11, Class cls) {
        return this.f4330q.getSpans(i10, i11, cls);
    }

    @Override // java.lang.CharSequence
    public int length() {
        return this.f4330q.length();
    }

    @Override // android.text.Spanned
    public int nextSpanTransition(int i10, int i11, Class cls) {
        return this.f4330q.nextSpanTransition(i10, i11, cls);
    }

    @Override // android.text.Spannable
    public void removeSpan(Object obj) {
        a();
        this.f4330q.removeSpan(obj);
    }

    @Override // android.text.Spannable
    public void setSpan(Object obj, int i10, int i11, int i12) {
        a();
        this.f4330q.setSpan(obj, i10, i11, i12);
    }

    @Override // java.lang.CharSequence
    public CharSequence subSequence(int i10, int i11) {
        return this.f4330q.subSequence(i10, i11);
    }

    @Override // java.lang.CharSequence
    public String toString() {
        return this.f4330q.toString();
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public q(CharSequence charSequence) {
        this.f4330q = new SpannableString(charSequence);
    }
}
