content: package androidx.core.content.res;
  
  import android.content.res.Resources;
  import android.content.res.TypedArray;
  import android.os.Build;
  import android.util.Base64;
  import android.util.TypedValue;
  import android.util.Xml;
  import androidx.core.R;
  import androidx.core.provider.FontRequest;
  import java.io.IOException;
  import java.lang.annotation.Retention;
  import java.lang.annotation.RetentionPolicy;
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.List;
  import org.xmlpull.v1.XmlPullParser;
  import org.xmlpull.v1.XmlPullParserException;
  
  public class FontResourcesParserCompat {
      private static final int DEFAULT_TIMEOUT_MILLIS = 500;
      public static final int FETCH_STRATEGY_ASYNC = 1;
      public static final int FETCH_STRATEGY_BLOCKING = 0;
      public static final int INFINITE_TIMEOUT_VALUE = -1;
      private static final int ITALIC = 1;
      private static final int NORMAL_WEIGHT = 400;
  
      static class Api21Impl {
          private Api21Impl() {
          }
  
          static int getType(TypedArray typedArray, int index) {
              return typedArray.getType(index);
          }
      }
  
      public interface FamilyResourceEntry {
      }
  
      @Retention(RetentionPolicy.SOURCE)
      public @interface FetchStrategy {
      }
  
      public static final class FontFamilyFilesResourceEntry implements FamilyResourceEntry {
          private final FontFileResourceEntry[] mEntries;
  
          public FontFamilyFilesResourceEntry(FontFileResourceEntry[] entries) {
              this.mEntries = entries;
          }
  
          public FontFileResourceEntry[] getEntries() {
              return this.mEntries;
          }
      }
  
      public static final class FontFileResourceEntry {
          private final String mFileName;
          private final boolean mItalic;
          private final int mResourceId;
          private final int mTtcIndex;
          private final String mVariationSettings;
          private final int mWeight;
  
          public FontFileResourceEntry(String fileName, int weight, boolean italic, String variationSettings, int ttcIndex, int resourceId) {
              this.mFileName = fileName;
              this.mWeight = weight;
              this.mItalic = italic;
              this.mVariationSettings = variationSettings;
              this.mTtcIndex = ttcIndex;
              this.mResourceId = resourceId;
          }
  
          public String getFileName() {
              return this.mFileName;
          }
  
          public int getResourceId() {
              return this.mResourceId;
          }
  
          public int getTtcIndex() {
              return this.mTtcIndex;
          }
  
          public String getVariationSettings() {
              return this.mVariationSettings;
          }
  
          public int getWeight() {
              return this.mWeight;
          }
  
          public boolean isItalic() {
              return this.mItalic;
          }
      }
  
      public static final class ProviderResourceEntry implements FamilyResourceEntry {
          private final FontRequest mRequest;
          private final int mStrategy;
          private final String mSystemFontFamilyName;
          private final int mTimeoutMs;
  
          public ProviderResourceEntry(FontRequest request, int strategy, int timeoutMs) {
              this(request, strategy, timeoutMs, (String) null);
          }
  
          public ProviderResourceEntry(FontRequest request, int strategy, int timeoutMs, String systemFontFamilyName) {
              this.mRequest = request;
              this.mStrategy = strategy;
              this.mTimeoutMs = timeoutMs;
              this.mSystemFontFamilyName = systemFontFamilyName;
          }
  
          public int getFetchStrategy() {
              return this.mStrategy;
          }
  
          public FontRequest getRequest() {
              return this.mRequest;
          }
  
          public String getSystemFontFamilyName() {
              return this.mSystemFontFamilyName;
          }
  
          public int getTimeout() {
              return this.mTimeoutMs;
          }
      }
  
      private FontResourcesParserCompat() {
      }
  
      private static int getType(TypedArray typedArray, int index) {
          if (Build.VERSION.SDK_INT >= 21) {
              return Api21Impl.getType(typedArray, index);
          }
          TypedValue typedValue = new TypedValue();
          typedArray.getValue(index, typedValue);
          return typedValue.type;
      }
  
      /* JADX WARNING: Removed duplicated region for block: B:0:0x0000 A[LOOP_START, MTH_ENTER_BLOCK] */
      /* JADX WARNING: Removed duplicated region for block: B:5:0x000e  */
      /* JADX WARNING: Removed duplicated region for block: B:7:0x0013  */
      /* Code decompiled incorrectly, please refer to instructions dump. */
      public static androidx.core.content.res.FontResourcesParserCompat.FamilyResourceEntry parse(org.xmlpull.v1.XmlPullParser r3, android.content.res.Resources r4) throws org.xmlpull.v1.XmlPullParserException, java.io.IOException {
          /*
          L_0x0000:
              int r0 = r3.next()
              r1 = r0
              r2 = 2
              if (r0 == r2) goto L_0x000c
              r0 = 1
              if (r1 == r0) goto L_0x000c
              goto L_0x0000
          L_0x000c:
              if (r1 != r2) goto L_0x0013
              androidx.core.content.res.FontResourcesParserCompat$FamilyResourceEntry r0 = readFamilies(r3, r4)
              return r0
          L_0x0013:
              org.xmlpull.v1.XmlPullParserException r0 = new org.xmlpull.v1.XmlPullParserException
              java.lang.String r2 = "No start tag found"
              r0.<init>(r2)
              throw r0
          */
          throw new UnsupportedOperationException("Method not decompiled: androidx.core.content.res.FontResourcesParserCompat.parse(org.xmlpull.v1.XmlPullParser, android.content.res.Resources):androidx.core.content.res.FontResourcesParserCompat$FamilyResourceEntry");
      }
  
      public static List<List<byte[]>> readCerts(Resources resources, int certsId) {
          if (certsId == 0) {
              return Collections.emptyList();
          }
          TypedArray obtainTypedArray = resources.obtainTypedArray(certsId);
          try {
              if (obtainTypedArray.length() == 0) {
                  return Collections.emptyList();
              }
              ArrayList arrayList = new ArrayList();
              if (getType(obtainTypedArray, 0) == 1) {
                  for (int i = 0; i < obtainTypedArray.length(); i++) {
                      int resourceId = obtainTypedArray.getResourceId(i, 0);
                      if (resourceId != 0) {
                          arrayList.add(toByteArrayList(resources.getStringArray(resourceId)));
                      }
                  }
              } else {
                  arrayList.add(toByteArrayList(resources.getStringArray(certsId)));
              }
              obtainTypedArray.recycle();
              return arrayList;
          } finally {
              obtainTypedArray.recycle();
          }
      }
  
      private static FamilyResourceEntry readFamilies(XmlPullParser parser, Resources resources) throws XmlPullParserException, IOException {
          parser.require(2, (String) null, "font-family");
          if (parser.getName().equals("font-family")) {
              return readFamily(parser, resources);
          }
          skip(parser);
          return null;
      }
  
      private static FamilyResourceEntry readFamily(XmlPullParser parser, Resources resources) throws XmlPullParserException, IOException {
          TypedArray obtainAttributes = resources.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.FontFamily);
          String string = obtainAttributes.getString(R.styleable.FontFamily_fontProviderAuthority);
          String string2 = obtainAttributes.getString(R.styleable.FontFamily_fontProviderPackage);
          String string3 = obtainAttributes.getString(R.styleable.FontFamily_fontProviderQuery);
          int resourceId = obtainAttributes.getResourceId(R.styleable.FontFamily_fontProviderCerts, 0);
          int integer = obtainAttributes.getInteger(R.styleable.FontFamily_fontProviderFetchStrategy, 1);
          int integer2 = obtainAttributes.getInteger(R.styleable.FontFamily_fontProviderFetchTimeout, DEFAULT_TIMEOUT_MILLIS);
          String string4 = obtainAttributes.getString(R.styleable.FontFamily_fontProviderSystemFontFamily);
          obtainAttributes.recycle();
          if (string == null || string2 == null || string3 == null) {
              ArrayList arrayList = new ArrayList();
              while (parser.next() != 3) {
                  if (parser.getEventType() == 2) {
                      if (parser.getName().equals("font")) {
                          arrayList.add(readFont(parser, resources));
                      } else {
                          skip(parser);
                      }
                  }
              }
              if (arrayList.isEmpty()) {
                  return null;
              }
              return new FontFamilyFilesResourceEntry((FontFileResourceEntry[]) arrayList.toArray(new FontFileResourceEntry[0]));
          }
          while (parser.next() != 3) {
              skip(parser);
          }
          return new ProviderResourceEntry(new FontRequest(string, string2, string3, readCerts(resources, resourceId)), integer, integer2, string4);
      }
  
      private static FontFileResourceEntry readFont(XmlPullParser parser, Resources resources) throws XmlPullParserException, IOException {
          TypedArray obtainAttributes = resources.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.FontFamilyFont);
          int i = obtainAttributes.getInt(obtainAttributes.hasValue(R.styleable.FontFamilyFont_fontWeight) ? R.styleable.FontFamilyFont_fontWeight : R.styleable.FontFamilyFont_android_fontWeight, NORMAL_WEIGHT);
          boolean z = 1 == obtainAttributes.getInt(obtainAttributes.hasValue(R.styleable.FontFamilyFont_fontStyle) ? R.styleable.FontFamilyFont_fontStyle : R.styleable.FontFamilyFont_android_fontStyle, 0);
          int i2 = obtainAttributes.hasValue(R.styleable.FontFamilyFont_ttcIndex) ? R.styleable.FontFamilyFont_ttcIndex : R.styleable.FontFamilyFont_android_ttcIndex;
          String string = obtainAttributes.getString(obtainAttributes.hasValue(R.styleable.FontFamilyFont_fontVariationSettings) ? R.styleable.FontFamilyFont_fontVariationSettings : R.styleable.FontFamilyFont_android_fontVariationSettings);
          int i3 = obtainAttributes.getInt(i2, 0);
          int i4 = obtainAttributes.hasValue(R.styleable.FontFamilyFont_font) ? R.styleable.FontFamilyFont_font : R.styleable.FontFamilyFont_android_font;
          int resourceId = obtainAttributes.getResourceId(i4, 0);
          String string2 = obtainAttributes.getString(i4);
          obtainAttributes.recycle();
          while (parser.next() != 3) {
              skip(parser);
          }
          int i5 = i4;
          return new FontFileResourceEntry(string2, i, z, string, i3, resourceId);
      }
  
      private static void skip(XmlPullParser parser) throws XmlPullParserException, IOException {
          int i = 1;
          while (i > 0) {
              switch (parser.next()) {
                  case 2:
                      i++;
                      break;
                  case 3:
                      i--;
                      break;
              }
          }
      }
  
      private static List<byte[]> toByteArrayList(String[] stringArray) {
          ArrayList arrayList = new ArrayList();
          for (String decode : stringArray) {
              arrayList.add(Base64.decode(decode, 0));
          }
          return arrayList;
      }
  }
  