content: package kotlinx.coroutines.channels;
  
  import java.util.ArrayList;
  import kotlin.Metadata;
  import kotlin.Unit;
  import kotlin.jvm.functions.Function1;
  import kotlin.jvm.internal.Intrinsics;
  import kotlinx.coroutines.channels.AbstractSendChannel;
  import kotlinx.coroutines.internal.AtomicKt;
  import kotlinx.coroutines.internal.OnUndeliveredElementKt;
  import kotlinx.coroutines.internal.UndeliveredElementException;
  import kotlinx.coroutines.selects.SelectInstance;
  import kotlinx.coroutines.selects.SelectKt;
  import mt.Log1F380D;
  
  @Metadata(d1 = {"\u0000F\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0005\n\u0002\u0010\u0000\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\b\u0010\u0018\u0000*\u0004\b\u0000\u0010\u00012\b\u0012\u0004\u0012\u0002H\u00010\u0002B'\u0012 \u0010\u0003\u001a\u001c\u0012\u0004\u0012\u00028\u0000\u0012\u0004\u0012\u00020\u0005\u0018\u00010\u0004j\n\u0012\u0004\u0012\u00028\u0000\u0018\u0001`\u0006¢\u0006\u0002\u0010\u0007J\u0015\u0010\u000e\u001a\u00020\u000f2\u0006\u0010\u0010\u001a\u00028\u0000H\u0014¢\u0006\u0002\u0010\u0011J!\u0010\u0012\u001a\u00020\u000f2\u0006\u0010\u0010\u001a\u00028\u00002\n\u0010\u0013\u001a\u0006\u0012\u0002\b\u00030\u0014H\u0014¢\u0006\u0002\u0010\u0015J/\u0010\u0016\u001a\u00020\u00052\f\u0010\u0017\u001a\b\u0012\u0004\u0012\u00020\u00190\u00182\n\u0010\u001a\u001a\u0006\u0012\u0002\b\u00030\u001bH\u0014ø\u0001\u0000ø\u0001\u0001¢\u0006\u0004\b\u001c\u0010\u001dR\u0014\u0010\b\u001a\u00020\t8DX\u0004¢\u0006\u0006\u001a\u0004\b\b\u0010\nR\u0014\u0010\u000b\u001a\u00020\t8DX\u0004¢\u0006\u0006\u001a\u0004\b\u000b\u0010\nR\u0014\u0010\f\u001a\u00020\t8DX\u0004¢\u0006\u0006\u001a\u0004\b\f\u0010\nR\u0014\u0010\r\u001a\u00020\t8DX\u0004¢\u0006\u0006\u001a\u0004\b\r\u0010\n\u0002\u000b\n\u0002\b\u0019\n\u0005\b¡\u001e0\u0001¨\u0006\u001e"}, d2 = {"Lkotlinx/coroutines/channels/LinkedListChannel;", "E", "Lkotlinx/coroutines/channels/AbstractChannel;", "onUndeliveredElement", "Lkotlin/Function1;", "", "Lkotlinx/coroutines/internal/OnUndeliveredElement;", "(Lkotlin/jvm/functions/Function1;)V", "isBufferAlwaysEmpty", "", "()Z", "isBufferAlwaysFull", "isBufferEmpty", "isBufferFull", "offerInternal", "", "element", "(Ljava/lang/Object;)Ljava/lang/Object;", "offerSelectInternal", "select", "Lkotlinx/coroutines/selects/SelectInstance;", "(Ljava/lang/Object;Lkotlinx/coroutines/selects/SelectInstance;)Ljava/lang/Object;", "onCancelIdempotentList", "list", "Lkotlinx/coroutines/internal/InlineList;", "Lkotlinx/coroutines/channels/Send;", "closed", "Lkotlinx/coroutines/channels/Closed;", "onCancelIdempotentList-w-w6eGU", "(Ljava/lang/Object;Lkotlinx/coroutines/channels/Closed;)V", "kotlinx-coroutines-core"}, k = 1, mv = {1, 6, 0}, xi = 48)
  /* compiled from: 018D */
  public class LinkedListChannel<E> extends AbstractChannel<E> {
      public LinkedListChannel(Function1<? super E, Unit> onUndeliveredElement) {
          super(onUndeliveredElement);
      }
  
      /* access modifiers changed from: protected */
      public final boolean isBufferAlwaysEmpty() {
          return true;
      }
  
      /* access modifiers changed from: protected */
      public final boolean isBufferAlwaysFull() {
          return false;
      }
  
      /* access modifiers changed from: protected */
      public final boolean isBufferEmpty() {
          return true;
      }
  
      /* access modifiers changed from: protected */
      public final boolean isBufferFull() {
          return false;
      }
  
      /* access modifiers changed from: protected */
      public Object offerInternal(E element) {
          ReceiveOrClosed<?> sendBuffered;
          do {
              Object offerInternal = super.offerInternal(element);
              if (offerInternal == AbstractChannelKt.OFFER_SUCCESS) {
                  return AbstractChannelKt.OFFER_SUCCESS;
              }
              if (offerInternal == AbstractChannelKt.OFFER_FAILED) {
                  sendBuffered = sendBuffered(element);
                  if (sendBuffered == null) {
                      return AbstractChannelKt.OFFER_SUCCESS;
                  }
              } else if (offerInternal instanceof Closed) {
                  return offerInternal;
              } else {
                  String stringPlus = Intrinsics.stringPlus("Invalid offerInternal result ", offerInternal);
                  Log1F380D.a((Object) stringPlus);
                  throw new IllegalStateException(stringPlus.toString());
              }
          } while (!(sendBuffered instanceof Closed));
          return sendBuffered;
      }
  
      /* access modifiers changed from: protected */
      /* renamed from: onCancelIdempotentList-w-w6eGU  reason: not valid java name */
      public void m1552onCancelIdempotentListww6eGU(Object list, Closed<?> closed) {
          UndeliveredElementException undeliveredElementException = null;
          if (list != null) {
              UndeliveredElementException undeliveredElementException2 = null;
              if (!(list instanceof ArrayList)) {
                  Send send = (Send) list;
                  if (send instanceof AbstractSendChannel.SendBuffered) {
                      Function1 function1 = this.onUndeliveredElement;
                      if (function1 != null) {
                          undeliveredElementException2 = OnUndeliveredElementKt.callUndeliveredElementCatchingException(function1, ((AbstractSendChannel.SendBuffered) send).element, (UndeliveredElementException) null);
                      }
                      undeliveredElementException = undeliveredElementException2;
                  } else {
                      send.resumeSendClosed(closed);
                  }
              } else if (list != null) {
                  ArrayList arrayList = (ArrayList) list;
                  int size = arrayList.size() - 1;
                  if (size >= 0) {
                      do {
                          int i = size;
                          size--;
                          Send send2 = (Send) arrayList.get(i);
                          if (send2 instanceof AbstractSendChannel.SendBuffered) {
                              Function1 function12 = this.onUndeliveredElement;
                              undeliveredElementException = function12 == null ? null : OnUndeliveredElementKt.callUndeliveredElementCatchingException(function12, ((AbstractSendChannel.SendBuffered) send2).element, undeliveredElementException);
                              continue;
                          } else {
                              send2.resumeSendClosed(closed);
                              continue;
                          }
                      } while (size >= 0);
                  }
              } else {
                  throw new NullPointerException("null cannot be cast to non-null type java.util.ArrayList<E of kotlinx.coroutines.internal.InlineList>{ kotlin.collections.TypeAliasesKt.ArrayList<E of kotlinx.coroutines.internal.InlineList> }");
              }
          }
          if (undeliveredElementException != null) {
              throw undeliveredElementException;
          }
      }
  
      /* access modifiers changed from: protected */
      public Object offerSelectInternal(E element, SelectInstance<?> select) {
          Object obj;
          while (true) {
              if (getHasReceiveOrClosed()) {
                  obj = super.offerSelectInternal(element, select);
              } else {
                  obj = select.performAtomicTrySelect(describeSendBuffered(element));
                  if (obj == null) {
                      obj = AbstractChannelKt.OFFER_SUCCESS;
                  }
              }
              if (obj == SelectKt.getALREADY_SELECTED()) {
                  return SelectKt.getALREADY_SELECTED();
              }
              if (obj == AbstractChannelKt.OFFER_SUCCESS) {
                  return AbstractChannelKt.OFFER_SUCCESS;
              }
              if (obj != AbstractChannelKt.OFFER_FAILED && obj != AtomicKt.RETRY_ATOMIC) {
                  if (obj instanceof Closed) {
                      return obj;
                  }
                  String stringPlus = Intrinsics.stringPlus("Invalid result ", obj);
                  Log1F380D.a((Object) stringPlus);
                  throw new IllegalStateException(stringPlus.toString());
              }
          }
      }
  }
  