package com.facetec.sdk; import java.io.EOFException; import java.io.IOException; import java.io.Writer; /* loaded from: classes.dex */ public final class fd { public static eb e(fu fuVar) throws ef { boolean z; try { try { fuVar.i(); } catch (EOFException e) { e = e; z = true; } try { return fs.B.a(fuVar); } catch (EOFException e2) { e = e2; z = false; if (z) { return ea.a; } throw new ei(e); } } catch (fz e3) { throw new ei(e3); } catch (IOException e4) { throw new ed(e4); } catch (NumberFormatException e5) { throw new ei(e5); } } public static void c(eb ebVar, ga gaVar) throws IOException { fs.B.b(gaVar, ebVar); } public static Writer a(Appendable appendable) { return appendable instanceof Writer ? (Writer) appendable : new c(appendable); } /* loaded from: classes.dex */ static final class c extends Writer { private final Appendable a; private final e c = new e(); @Override // java.io.Writer, java.io.Closeable, java.lang.AutoCloseable public final void close() { } @Override // java.io.Writer, java.io.Flushable public final void flush() { } c(Appendable appendable) { this.a = appendable; } @Override // java.io.Writer public final void write(char[] cArr, int i, int i2) throws IOException { this.c.d = cArr; this.a.append(this.c, i, i2 + i); } @Override // java.io.Writer public final void write(int i) throws IOException { this.a.append((char) i); } /* loaded from: classes.dex */ static final class e implements CharSequence { char[] d; e() { } @Override // java.lang.CharSequence public final int length() { return this.d.length; } @Override // java.lang.CharSequence public final char charAt(int i) { return this.d[i]; } @Override // java.lang.CharSequence public final CharSequence subSequence(int i, int i2) { return new String(this.d, i, i2 - i); } } } }