package c.i.a.c.h2.y; import androidx.annotation.Nullable; import c.d.b.a.a; import c.i.a.c.i2.f0; import com.airbnb.lottie.parser.AnimatableValueParser; import java.io.File; import java.util.Objects; import java.util.regex.Matcher; import java.util.regex.Pattern; /* compiled from: SimpleCacheSpan */ public final class r extends h { public static final Pattern o = Pattern.compile("^(.+)\\.(\\d+)\\.(\\d+)\\.v1\\.exo$", 32); public static final Pattern p = Pattern.compile("^(.+)\\.(\\d+)\\.(\\d+)\\.v2\\.exo$", 32); public static final Pattern q = Pattern.compile("^(\\d+)\\.(\\d+)\\.(\\d+)\\.v3\\.exo$", 32); public r(String str, long j, long j2, long j3, @Nullable File file) { super(str, j, j2, j3, file); } /* JADX WARNING: Code restructure failed: missing block: B:28:0x00d1, code lost: if (r16.renameTo(r1) == false) goto L_0x00a2; */ /* JADX WARNING: Removed duplicated region for block: B:27:0x00a4 */ /* JADX WARNING: Removed duplicated region for block: B:30:0x00d6 A[RETURN] */ /* JADX WARNING: Removed duplicated region for block: B:31:0x00d7 */ @Nullable public static r g(File file, long j, long j2, j jVar) { File file2; long j3; String str; File file3; String name = file.getName(); if (!name.endsWith(".v3.exo")) { String name2 = file.getName(); Matcher matcher = p.matcher(name2); if (matcher.matches()) { str = matcher.group(1); Objects.requireNonNull(str); int i = f0.a; int length = str.length(); int i2 = 0; int i3 = 0; for (int i4 = 0; i4 < length; i4++) { if (str.charAt(i4) == '%') { i3++; } } if (i3 != 0) { int i5 = length - (i3 * 2); StringBuilder sb = new StringBuilder(i5); Matcher matcher2 = f0.g.matcher(str); while (i3 > 0 && matcher2.find()) { String group = matcher2.group(1); Objects.requireNonNull(group); sb.append((CharSequence) str, i2, matcher2.start()); sb.append((char) Integer.parseInt(group, 16)); i2 = matcher2.end(); i3--; } if (i2 < length) { sb.append((CharSequence) str, i2, length); } if (sb.length() == i5) { str = sb.toString(); } } if (str != null) { File parentFile = file.getParentFile(); AnimatableValueParser.H(parentFile); int i6 = jVar.d(str).a; String group2 = matcher.group(2); Objects.requireNonNull(group2); long parseLong = Long.parseLong(group2); String group3 = matcher.group(3); Objects.requireNonNull(group3); file3 = h(parentFile, i6, parseLong, Long.parseLong(group3)); } file3 = null; if (file3 == null) { return null; } file2 = file3; name = file3.getName(); } else { matcher = o.matcher(name2); if (matcher.matches()) { str = matcher.group(1); Objects.requireNonNull(str); if (str != null) { } file3 = null; if (file3 == null) { } } } str = null; if (str != null) { } file3 = null; if (file3 == null) { } } else { file2 = file; } Matcher matcher3 = q.matcher(name); if (!matcher3.matches()) { return null; } String group4 = matcher3.group(1); Objects.requireNonNull(group4); String str2 = jVar.b.get(Integer.parseInt(group4)); if (str2 == null) { return null; } long length2 = j == -1 ? file2.length() : j; if (length2 == 0) { return null; } String group5 = matcher3.group(2); Objects.requireNonNull(group5); long parseLong2 = Long.parseLong(group5); if (j2 == -9223372036854775807L) { String group6 = matcher3.group(3); Objects.requireNonNull(group6); j3 = Long.parseLong(group6); } else { j3 = j2; } return new r(str2, parseLong2, length2, j3, file2); } public static File h(File file, int i, long j, long j2) { StringBuilder sb = new StringBuilder(); sb.append(i); sb.append("."); sb.append(j); sb.append("."); return new File(file, a.y(sb, j2, ".v3.exo")); } }