package kotlin.reflect.jvm.internal.impl.renderer;

import java.util.Iterator;
import java.util.List;
import kotlin.jvm.internal.t;
import kotlin.text.y;

/* loaded from: classes3.dex */
public abstract class n {
    public static final String a(ro.d dVar) {
        t.g(dVar, "<this>");
        List h10 = dVar.h();
        t.f(h10, "pathSegments(...)");
        return c(h10);
    }

    public static final String b(ro.f fVar) {
        t.g(fVar, "<this>");
        if (!e(fVar)) {
            String e10 = fVar.e();
            t.f(e10, "asString(...)");
            return e10;
        }
        StringBuilder sb2 = new StringBuilder();
        String e11 = fVar.e();
        t.f(e11, "asString(...)");
        sb2.append('`' + e11);
        sb2.append('`');
        return sb2.toString();
    }

    public static final String c(List pathSegments) {
        t.g(pathSegments, "pathSegments");
        StringBuilder sb2 = new StringBuilder();
        Iterator it = pathSegments.iterator();
        while (it.hasNext()) {
            ro.f fVar = (ro.f) it.next();
            if (sb2.length() > 0) {
                sb2.append(".");
            }
            sb2.append(b(fVar));
        }
        String sb3 = sb2.toString();
        t.f(sb3, "toString(...)");
        return sb3;
    }

    public static final String d(String lowerRendered, String lowerPrefix, String upperRendered, String upperPrefix, String foldedPrefix) {
        boolean P;
        boolean P2;
        t.g(lowerRendered, "lowerRendered");
        t.g(lowerPrefix, "lowerPrefix");
        t.g(upperRendered, "upperRendered");
        t.g(upperPrefix, "upperPrefix");
        t.g(foldedPrefix, "foldedPrefix");
        P = y.P(lowerRendered, lowerPrefix, false, 2, null);
        if (P) {
            P2 = y.P(upperRendered, upperPrefix, false, 2, null);
            if (P2) {
                String substring = lowerRendered.substring(lowerPrefix.length());
                t.f(substring, "substring(...)");
                String substring2 = upperRendered.substring(upperPrefix.length());
                t.f(substring2, "substring(...)");
                String str = foldedPrefix + substring;
                if (t.b(substring, substring2)) {
                    return str;
                }
                if (f(substring, substring2)) {
                    return str + '!';
                }
            }
        }
        return null;
    }

    private static final boolean e(ro.f fVar) {
        boolean z10;
        String e10 = fVar.e();
        t.f(e10, "asString(...)");
        if (i.f26418a.contains(e10)) {
            return true;
        }
        int i10 = 0;
        while (true) {
            if (i10 >= e10.length()) {
                z10 = false;
                break;
            }
            char charAt = e10.charAt(i10);
            if ((Character.isLetterOrDigit(charAt) || charAt == '_') ? false : true) {
                z10 = true;
                break;
            }
            i10++;
        }
        if (z10) {
            return true;
        }
        return (e10.length() == 0) || !Character.isJavaIdentifierStart(e10.codePointAt(0));
    }

    /* JADX WARN: Code restructure failed: missing block: B:6:0x003c, code lost:
    
        if (kotlin.jvm.internal.t.b(r7 + '?', r8) == false) goto L8;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final boolean f(String lower, String upper) {
        String J;
        boolean y10;
        t.g(lower, "lower");
        t.g(upper, "upper");
        J = y.J(upper, "?", "", false, 4, null);
        if (!t.b(lower, J)) {
            y10 = y.y(upper, "?", false, 2, null);
            if (y10) {
            }
            if (!t.b('(' + lower + ")?", upper)) {
                return false;
            }
        }
        return true;
    }
}
