content: package com.google.android.material.bottomsheet;
  
  import android.animation.ValueAnimator;
  import android.content.Context;
  import android.content.res.ColorStateList;
  import android.content.res.TypedArray;
  import android.os.Build;
  import android.os.Parcel;
  import android.os.Parcelable;
  import android.util.AttributeSet;
  import android.util.Log;
  import android.util.TypedValue;
  import android.view.MotionEvent;
  import android.view.VelocityTracker;
  import android.view.View;
  import android.view.ViewConfiguration;
  import android.view.ViewGroup;
  import android.view.ViewParent;
  import androidx.constraintlayout.core.widgets.analyzer.BasicMeasure;
  import androidx.coordinatorlayout.widget.CoordinatorLayout;
  import androidx.core.graphics.Insets;
  import androidx.core.math.MathUtils;
  import androidx.core.view.ViewCompat;
  import androidx.core.view.WindowInsetsCompat;
  import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
  import androidx.core.view.accessibility.AccessibilityViewCommand;
  import androidx.customview.view.AbsSavedState;
  import androidx.customview.widget.ViewDragHelper;
  import com.google.android.material.R;
  import com.google.android.material.internal.ViewUtils;
  import com.google.android.material.resources.MaterialResources;
  import com.google.android.material.shape.MaterialShapeDrawable;
  import com.google.android.material.shape.ShapeAppearanceModel;
  import java.lang.annotation.Retention;
  import java.lang.annotation.RetentionPolicy;
  import java.lang.ref.WeakReference;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.Map;
  
  public class BottomSheetBehavior<V extends View> extends CoordinatorLayout.Behavior<V> {
      private static final int CORNER_ANIMATION_DURATION = 500;
      private static final int DEF_STYLE_RES = R.style.Widget_Design_BottomSheet_Modal;
      private static final float HIDE_FRICTION = 0.1f;
      private static final float HIDE_THRESHOLD = 0.5f;
      private static final int NO_MAX_SIZE = -1;
      public static final int PEEK_HEIGHT_AUTO = -1;
      public static final int SAVE_ALL = -1;
      public static final int SAVE_FIT_TO_CONTENTS = 2;
      public static final int SAVE_HIDEABLE = 4;
      public static final int SAVE_NONE = 0;
      public static final int SAVE_PEEK_HEIGHT = 1;
      public static final int SAVE_SKIP_COLLAPSED = 8;
      private static final int SIGNIFICANT_VEL_THRESHOLD = 500;
      public static final int STATE_COLLAPSED = 4;
      public static final int STATE_DRAGGING = 1;
      public static final int STATE_EXPANDED = 3;
      public static final int STATE_HALF_EXPANDED = 6;
      public static final int STATE_HIDDEN = 5;
      public static final int STATE_SETTLING = 2;
      private static final String TAG = "BottomSheetBehavior";
      int activePointerId;
      private ColorStateList backgroundTint;
      private final ArrayList<BottomSheetCallback> callbacks = new ArrayList<>();
      private int childHeight;
      int collapsedOffset;
      private final ViewDragHelper.Callback dragCallback = new ViewDragHelper.Callback() {
          private long viewCapturedMillis;
  
          private boolean releasedLow(View child) {
              return child.getTop() > (BottomSheetBehavior.this.parentHeight + BottomSheetBehavior.this.getExpandedOffset()) / 2;
          }
  
          public int clampViewPositionHorizontal(View child, int left, int dx) {
              return child.getLeft();
          }
  
          public int clampViewPositionVertical(View child, int top, int dy) {
              return MathUtils.clamp(top, BottomSheetBehavior.this.getExpandedOffset(), BottomSheetBehavior.this.hideable ? BottomSheetBehavior.this.parentHeight : BottomSheetBehavior.this.collapsedOffset);
          }
  
          public int getViewVerticalDragRange(View child) {
              return BottomSheetBehavior.this.hideable ? BottomSheetBehavior.this.parentHeight : BottomSheetBehavior.this.collapsedOffset;
          }
  
          public void onViewDragStateChanged(int state) {
              if (state == 1 && BottomSheetBehavior.this.draggable) {
                  BottomSheetBehavior.this.setStateInternal(1);
              }
          }
  
          public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
              BottomSheetBehavior.this.dispatchOnSlide(top);
          }
  
          public void onViewReleased(View releasedChild, float xvel, float yvel) {
              int i;
              if (yvel < 0.0f) {
                  if (BottomSheetBehavior.this.fitToContents) {
                      i = 3;
                  } else {
                      int top = releasedChild.getTop();
                      long currentTimeMillis = System.currentTimeMillis() - this.viewCapturedMillis;
                      if (BottomSheetBehavior.this.shouldSkipHalfExpandedStateWhenDragging()) {
                          i = BottomSheetBehavior.this.shouldExpandOnUpwardDrag(currentTimeMillis, (((float) top) * 100.0f) / ((float) BottomSheetBehavior.this.parentHeight)) ? 3 : 4;
                      } else {
                          i = top > BottomSheetBehavior.this.halfExpandedOffset ? 6 : 3;
                      }
                  }
              } else if (BottomSheetBehavior.this.hideable && BottomSheetBehavior.this.shouldHide(releasedChild, yvel)) {
                  i = ((Math.abs(xvel) >= Math.abs(yvel) || yvel <= 500.0f) && !releasedLow(releasedChild)) ? BottomSheetBehavior.this.fitToContents ? 3 : Math.abs(releasedChild.getTop() - BottomSheetBehavior.this.getExpandedOffset()) < Math.abs(releasedChild.getTop() - BottomSheetBehavior.this.halfExpandedOffset) ? 3 : 6 : 5;
              } else if (yvel == 0.0f || Math.abs(xvel) > Math.abs(yvel)) {
                  int top2 = releasedChild.getTop();
                  i = BottomSheetBehavior.this.fitToContents ? Math.abs(top2 - BottomSheetBehavior.this.fitToContentsOffset) < Math.abs(top2 - BottomSheetBehavior.this.collapsedOffset) ? 3 : 4 : top2 < BottomSheetBehavior.this.halfExpandedOffset ? top2 < Math.abs(top2 - BottomSheetBehavior.this.collapsedOffset) ? 3 : BottomSheetBehavior.this.shouldSkipHalfExpandedStateWhenDragging() ? 4 : 6 : Math.abs(top2 - BottomSheetBehavior.this.halfExpandedOffset) < Math.abs(top2 - BottomSheetBehavior.this.collapsedOffset) ? BottomSheetBehavior.this.shouldSkipHalfExpandedStateWhenDragging() ? 4 : 6 : 4;
              } else if (BottomSheetBehavior.this.fitToContents) {
                  i = 4;
              } else {
                  int top3 = releasedChild.getTop();
                  i = Math.abs(top3 - BottomSheetBehavior.this.halfExpandedOffset) < Math.abs(top3 - BottomSheetBehavior.this.collapsedOffset) ? BottomSheetBehavior.this.shouldSkipHalfExpandedStateWhenDragging() ? 4 : 6 : 4;
              }
              BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.this;
              bottomSheetBehavior.startSettling(releasedChild, i, bottomSheetBehavior.shouldSkipSmoothAnimation());
          }
  
          public boolean tryCaptureView(View child, int pointerId) {
              if (BottomSheetBehavior.this.state == 1 || BottomSheetBehavior.this.touchingScrollingChild) {
                  return false;
              }
              if (BottomSheetBehavior.this.state == 3 && BottomSheetBehavior.this.activePointerId == pointerId) {
                  View view = BottomSheetBehavior.this.nestedScrollingChildRef != null ? (View) BottomSheetBehavior.this.nestedScrollingChildRef.get() : null;
                  if (view != null && view.canScrollVertically(-1)) {
                      return false;
                  }
              }
              this.viewCapturedMillis = System.currentTimeMillis();
              return BottomSheetBehavior.this.viewRef != null && BottomSheetBehavior.this.viewRef.get() == child;
          }
      };
      /* access modifiers changed from: private */
      public boolean draggable = true;
      float elevation = -1.0f;
      private int expandHalfwayActionId = -1;
      int expandedOffset;
      /* access modifiers changed from: private */
      public boolean fitToContents = true;
      int fitToContentsOffset;
      /* access modifiers changed from: private */
      public int gestureInsetBottom;
      private boolean gestureInsetBottomIgnored;
      int halfExpandedOffset;
      float halfExpandedRatio = 0.5f;
      boolean hideable;
      private boolean ignoreEvents;
      private Map<View, Integer> importantForAccessibilityMap;
      private int initialY;
      /* access modifiers changed from: private */
      public int insetBottom;
      /* access modifiers changed from: private */
      public int insetTop;
      private ValueAnimator interpolatorAnimator;
      private boolean isShapeExpanded;
      private int lastNestedScrollDy;
      int lastStableState = 4;
      /* access modifiers changed from: private */
      public boolean marginLeftSystemWindowInsets;
      /* access modifiers changed from: private */
      public boolean marginRightSystemWindowInsets;
      /* access modifiers changed from: private */
      public boolean marginTopSystemWindowInsets;
      /* access modifiers changed from: private */
      public MaterialShapeDrawable materialShapeDrawable;
      private int maxHeight = -1;
      private int maxWidth = -1;
      private float maximumVelocity;
      private boolean nestedScrolled;
      WeakReference<View> nestedScrollingChildRef;
      /* access modifiers changed from: private */
      public boolean paddingBottomSystemWindowInsets;
      /* access modifiers changed from: private */
      public boolean paddingLeftSystemWindowInsets;
      /* access modifiers changed from: private */
      public boolean paddingRightSystemWindowInsets;
      private boolean paddingTopSystemWindowInsets;
      int parentHeight;
      int parentWidth;
      /* access modifiers changed from: private */
      public int peekHeight;
      private boolean peekHeightAuto;
      private int peekHeightGestureInsetBuffer;
      private int peekHeightMin;
      private int saveFlags = 0;
      private ShapeAppearanceModel shapeAppearanceModelDefault;
      /* access modifiers changed from: private */
      public boolean skipCollapsed;
      int state = 4;
      private final BottomSheetBehavior<V>.StateSettlingTracker stateSettlingTracker = new StateSettlingTracker();
      boolean touchingScrollingChild;
      private boolean updateImportantForAccessibilityOnSiblings = false;
      private VelocityTracker velocityTracker;
      ViewDragHelper viewDragHelper;
      WeakReference<V> viewRef;
  
      public static abstract class BottomSheetCallback {
          /* access modifiers changed from: package-private */
          public void onLayout(View bottomSheet) {
          }
  
          public abstract void onSlide(View view, float f);
  
          public abstract void onStateChanged(View view, int i);
      }
  
      @Retention(RetentionPolicy.SOURCE)
      public @interface SaveFlags {
      }
  
      protected static class SavedState extends AbsSavedState {
          public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.ClassLoaderCreator<SavedState>() {
              public SavedState createFromParcel(Parcel in) {
                  return new SavedState(in, (ClassLoader) null);
              }
  
              public SavedState createFromParcel(Parcel in, ClassLoader loader) {
                  return new SavedState(in, loader);
              }
  
              public SavedState[] newArray(int size) {
                  return new SavedState[size];
              }
          };
          boolean fitToContents;
          boolean hideable;
          int peekHeight;
          boolean skipCollapsed;
          final int state;
  
          public SavedState(Parcel source) {
              this(source, (ClassLoader) null);
          }
  
          public SavedState(Parcel source, ClassLoader loader) {
              super(source, loader);
              this.state = source.readInt();
              this.peekHeight = source.readInt();
              boolean z = false;
              this.fitToContents = source.readInt() == 1;
              this.hideable = source.readInt() == 1;
              this.skipCollapsed = source.readInt() == 1 ? true : z;
          }
  
          @Deprecated
          public SavedState(Parcelable superstate, int state2) {
              super(superstate);
              this.state = state2;
          }
  
          public SavedState(Parcelable superState, BottomSheetBehavior<?> bottomSheetBehavior) {
              super(superState);
              this.state = bottomSheetBehavior.state;
              this.peekHeight = bottomSheetBehavior.peekHeight;
              this.fitToContents = bottomSheetBehavior.fitToContents;
              this.hideable = bottomSheetBehavior.hideable;
              this.skipCollapsed = bottomSheetBehavior.skipCollapsed;
          }
  
          public void writeToParcel(Parcel out, int flags) {
              super.writeToParcel(out, flags);
              out.writeInt(this.state);
              out.writeInt(this.peekHeight);
              out.writeInt(this.fitToContents ? 1 : 0);
              out.writeInt(this.hideable ? 1 : 0);
              out.writeInt(this.skipCollapsed ? 1 : 0);
          }
      }
  
      @Retention(RetentionPolicy.SOURCE)
      public @interface StableState {
      }
  
      @Retention(RetentionPolicy.SOURCE)
      public @interface State {
      }
  
      private class StateSettlingTracker {
          private final Runnable continueSettlingRunnable;
          /* access modifiers changed from: private */
          public boolean isContinueSettlingRunnablePosted;
          /* access modifiers changed from: private */
          public int targetState;
  
          private StateSettlingTracker() {
              this.continueSettlingRunnable = new Runnable() {
                  public void run() {
                      boolean unused = StateSettlingTracker.this.isContinueSettlingRunnablePosted = false;
                      if (BottomSheetBehavior.this.viewDragHelper != null && BottomSheetBehavior.this.viewDragHelper.continueSettling(true)) {
                          StateSettlingTracker stateSettlingTracker = StateSettlingTracker.this;
                          stateSettlingTracker.continueSettlingToState(stateSettlingTracker.targetState);
                      } else if (BottomSheetBehavior.this.state == 2) {
                          BottomSheetBehavior.this.setStateInternal(StateSettlingTracker.this.targetState);
                      }
                  }
              };
          }
  
          /* access modifiers changed from: package-private */
          public void continueSettlingToState(int targetState2) {
              if (BottomSheetBehavior.this.viewRef != null && BottomSheetBehavior.this.viewRef.get() != null) {
                  this.targetState = targetState2;
                  if (!this.isContinueSettlingRunnablePosted) {
                      ViewCompat.postOnAnimation((View) BottomSheetBehavior.this.viewRef.get(), this.continueSettlingRunnable);
                      this.isContinueSettlingRunnablePosted = true;
                  }
              }
          }
      }
  
      public BottomSheetBehavior() {
      }
  
      public BottomSheetBehavior(Context context, AttributeSet attrs) {
          super(context, attrs);
          this.peekHeightGestureInsetBuffer = context.getResources().getDimensionPixelSize(R.dimen.mtrl_min_touch_target_size);
          TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attrs, R.styleable.BottomSheetBehavior_Layout);
          if (obtainStyledAttributes.hasValue(R.styleable.BottomSheetBehavior_Layout_backgroundTint)) {
              this.backgroundTint = MaterialResources.getColorStateList(context, obtainStyledAttributes, R.styleable.BottomSheetBehavior_Layout_backgroundTint);
          }
          if (obtainStyledAttributes.hasValue(R.styleable.BottomSheetBehavior_Layout_shapeAppearance)) {
              this.shapeAppearanceModelDefault = ShapeAppearanceModel.builder(context, attrs, R.attr.bottomSheetStyle, DEF_STYLE_RES).build();
          }
          createMaterialShapeDrawableIfNeeded(context);
          createShapeValueAnimator();
          if (Build.VERSION.SDK_INT >= 21) {
              this.elevation = obtainStyledAttributes.getDimension(R.styleable.BottomSheetBehavior_Layout_android_elevation, -1.0f);
          }
          if (obtainStyledAttributes.hasValue(R.styleable.BottomSheetBehavior_Layout_android_maxWidth)) {
              setMaxWidth(obtainStyledAttributes.getDimensionPixelSize(R.styleable.BottomSheetBehavior_Layout_android_maxWidth, -1));
          }
          if (obtainStyledAttributes.hasValue(R.styleable.BottomSheetBehavior_Layout_android_maxHeight)) {
              setMaxHeight(obtainStyledAttributes.getDimensionPixelSize(R.styleable.BottomSheetBehavior_Layout_android_maxHeight, -1));
          }
          TypedValue peekValue = obtainStyledAttributes.peekValue(R.styleable.BottomSheetBehavior_Layout_behavior_peekHeight);
          if (peekValue == null || peekValue.data != -1) {
              setPeekHeight(obtainStyledAttributes.getDimensionPixelSize(R.styleable.BottomSheetBehavior_Layout_behavior_peekHeight, -1));
          } else {
              setPeekHeight(peekValue.data);
          }
          setHideable(obtainStyledAttributes.getBoolean(R.styleable.BottomSheetBehavior_Layout_behavior_hideable, false));
          setGestureInsetBottomIgnored(obtainStyledAttributes.getBoolean(R.styleable.BottomSheetBehavior_Layout_gestureInsetBottomIgnored, false));
          setFitToContents(obtainStyledAttributes.getBoolean(R.styleable.BottomSheetBehavior_Layout_behavior_fitToContents, true));
          setSkipCollapsed(obtainStyledAttributes.getBoolean(R.styleable.BottomSheetBehavior_Layout_behavior_skipCollapsed, false));
          setDraggable(obtainStyledAttributes.getBoolean(R.styleable.BottomSheetBehavior_Layout_behavior_draggable, true));
          setSaveFlags(obtainStyledAttributes.getInt(R.styleable.BottomSheetBehavior_Layout_behavior_saveFlags, 0));
          setHalfExpandedRatio(obtainStyledAttributes.getFloat(R.styleable.BottomSheetBehavior_Layout_behavior_halfExpandedRatio, 0.5f));
          TypedValue peekValue2 = obtainStyledAttributes.peekValue(R.styleable.BottomSheetBehavior_Layout_behavior_expandedOffset);
          if (peekValue2 == null || peekValue2.type != 16) {
              setExpandedOffset(obtainStyledAttributes.getDimensionPixelOffset(R.styleable.BottomSheetBehavior_Layout_behavior_expandedOffset, 0));
          } else {
              setExpandedOffset(peekValue2.data);
          }
          this.paddingBottomSystemWindowInsets = obtainStyledAttributes.getBoolean(R.styleable.BottomSheetBehavior_Layout_paddingBottomSystemWindowInsets, false);
          this.paddingLeftSystemWindowInsets = obtainStyledAttributes.getBoolean(R.styleable.BottomSheetBehavior_Layout_paddingLeftSystemWindowInsets, false);
          this.paddingRightSystemWindowInsets = obtainStyledAttributes.getBoolean(R.styleable.BottomSheetBehavior_Layout_paddingRightSystemWindowInsets, false);
          this.paddingTopSystemWindowInsets = obtainStyledAttributes.getBoolean(R.styleable.BottomSheetBehavior_Layout_paddingTopSystemWindowInsets, true);
          this.marginLeftSystemWindowInsets = obtainStyledAttributes.getBoolean(R.styleable.BottomSheetBehavior_Layout_marginLeftSystemWindowInsets, false);
          this.marginRightSystemWindowInsets = obtainStyledAttributes.getBoolean(R.styleable.BottomSheetBehavior_Layout_marginRightSystemWindowInsets, false);
          this.marginTopSystemWindowInsets = obtainStyledAttributes.getBoolean(R.styleable.BottomSheetBehavior_Layout_marginTopSystemWindowInsets, false);
          obtainStyledAttributes.recycle();
          this.maximumVelocity = (float) ViewConfiguration.get(context).getScaledMaximumFlingVelocity();
      }
  
      private int addAccessibilityActionForState(V v, int stringResId, int state2) {
          return ViewCompat.addAccessibilityAction(v, v.getResources().getString(stringResId), createAccessibilityViewCommandForState(state2));
      }
  
      private void calculateCollapsedOffset() {
          int calculatePeekHeight = calculatePeekHeight();
          if (this.fitToContents) {
              this.collapsedOffset = Math.max(this.parentHeight - calculatePeekHeight, this.fitToContentsOffset);
          } else {
              this.collapsedOffset = this.parentHeight - calculatePeekHeight;
          }
      }
  
      private void calculateHalfExpandedOffset() {
          this.halfExpandedOffset = (int) (((float) this.parentHeight) * (1.0f - this.halfExpandedRatio));
      }
  
      /* JADX WARNING: Code restructure failed: missing block: B:8:0x0025, code lost:
          r0 = r3.gestureInsetBottom;
       */
      /* Code decompiled incorrectly, please refer to instructions dump. */
      private int calculatePeekHeight() {
          /*
              r3 = this;
              boolean r0 = r3.peekHeightAuto
              if (r0 == 0) goto L_0x001d
              int r0 = r3.peekHeightMin
              int r1 = r3.parentHeight
              int r2 = r3.parentWidth
              int r2 = r2 * 9
              int r2 = r2 / 16
              int r1 = r1 - r2
              int r0 = java.lang.Math.max(r0, r1)
              int r1 = r3.childHeight
              int r1 = java.lang.Math.min(r0, r1)
              int r2 = r3.insetBottom
              int r1 = r1 + r2
              return r1
          L_0x001d:
              boolean r0 = r3.gestureInsetBottomIgnored
              if (r0 != 0) goto L_0x0033
              boolean r0 = r3.paddingBottomSystemWindowInsets
              if (r0 != 0) goto L_0x0033
              int r0 = r3.gestureInsetBottom
              if (r0 <= 0) goto L_0x0033
              int r1 = r3.peekHeight
              int r2 = r3.peekHeightGestureInsetBuffer
              int r0 = r0 + r2
              int r0 = java.lang.Math.max(r1, r0)
              return r0
          L_0x0033:
              int r0 = r3.peekHeight
              int r1 = r3.insetBottom
              int r0 = r0 + r1
              return r0
          */
          throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.bottomsheet.BottomSheetBehavior.calculatePeekHeight():int");
      }
  
      private AccessibilityViewCommand createAccessibilityViewCommandForState(final int state2) {
          return new AccessibilityViewCommand() {
              public boolean perform(View view, AccessibilityViewCommand.CommandArguments arguments) {
                  BottomSheetBehavior.this.setState(state2);
                  return true;
              }
          };
      }
  
      private void createMaterialShapeDrawableIfNeeded(Context context) {
          if (this.shapeAppearanceModelDefault != null) {
              MaterialShapeDrawable materialShapeDrawable2 = new MaterialShapeDrawable(this.shapeAppearanceModelDefault);
              this.materialShapeDrawable = materialShapeDrawable2;
              materialShapeDrawable2.initializeElevationOverlay(context);
              ColorStateList colorStateList = this.backgroundTint;
              if (colorStateList != null) {
                  this.materialShapeDrawable.setFillColor(colorStateList);
                  return;
              }
              TypedValue typedValue = new TypedValue();
              context.getTheme().resolveAttribute(16842801, typedValue, true);
              this.materialShapeDrawable.setTint(typedValue.data);
          }
      }
  
      private void createShapeValueAnimator() {
          ValueAnimator ofFloat = ValueAnimator.ofFloat(new float[]{0.0f, 1.0f});
          this.interpolatorAnimator = ofFloat;
          ofFloat.setDuration(500);
          this.interpolatorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
              public void onAnimationUpdate(ValueAnimator animation) {
                  float floatValue = ((Float) animation.getAnimatedValue()).floatValue();
                  if (BottomSheetBehavior.this.materialShapeDrawable != null) {
                      BottomSheetBehavior.this.materialShapeDrawable.setInterpolation(floatValue);
                  }
              }
          });
      }
  
      public static <V extends View> BottomSheetBehavior<V> from(V v) {
          ViewGroup.LayoutParams layoutParams = v.getLayoutParams();
          if (layoutParams instanceof CoordinatorLayout.LayoutParams) {
              CoordinatorLayout.Behavior behavior = ((CoordinatorLayout.LayoutParams) layoutParams).getBehavior();
              if (behavior instanceof BottomSheetBehavior) {
                  return (BottomSheetBehavior) behavior;
              }
              throw new IllegalArgumentException("The view is not associated with BottomSheetBehavior");
          }
          throw new IllegalArgumentException("The view is not a child of CoordinatorLayout");
      }
  
      private int getChildMeasureSpec(int parentMeasureSpec, int padding, int maxSize, int childDimension) {
          int childMeasureSpec = ViewGroup.getChildMeasureSpec(parentMeasureSpec, padding, childDimension);
          if (maxSize == -1) {
              return childMeasureSpec;
          }
          int mode = View.MeasureSpec.getMode(childMeasureSpec);
          int size = View.MeasureSpec.getSize(childMeasureSpec);
          switch (mode) {
              case BasicMeasure.EXACTLY:
                  return View.MeasureSpec.makeMeasureSpec(Math.min(size, maxSize), BasicMeasure.EXACTLY);
              default:
                  return View.MeasureSpec.makeMeasureSpec(size == 0 ? maxSize : Math.min(size, maxSize), Integer.MIN_VALUE);
          }
      }
  
      private int getTopOffsetForState(int state2) {
          switch (state2) {
              case 3:
                  return getExpandedOffset();
              case 4:
                  return this.collapsedOffset;
              case 5:
                  return this.parentHeight;
              case 6:
                  return this.halfExpandedOffset;
              default:
                  throw new IllegalArgumentException("Invalid state to get top offset: " + state2);
          }
      }
  
      private float getYVelocity() {
          VelocityTracker velocityTracker2 = this.velocityTracker;
          if (velocityTracker2 == null) {
              return 0.0f;
          }
          velocityTracker2.computeCurrentVelocity(1000, this.maximumVelocity);
          return this.velocityTracker.getYVelocity(this.activePointerId);
      }
  
      private boolean isLayouting(V v) {
          ViewParent parent = v.getParent();
          return parent != null && parent.isLayoutRequested() && ViewCompat.isAttachedToWindow(v);
      }
  
      private void replaceAccessibilityActionForState(V v, AccessibilityNodeInfoCompat.AccessibilityActionCompat action, int state2) {
          ViewCompat.replaceAccessibilityAction(v, action, (CharSequence) null, createAccessibilityViewCommandForState(state2));
      }
  
      private void reset() {
          this.activePointerId = -1;
          VelocityTracker velocityTracker2 = this.velocityTracker;
          if (velocityTracker2 != null) {
              velocityTracker2.recycle();
              this.velocityTracker = null;
          }
      }
  
      private void restoreOptionalState(SavedState ss) {
          int i = this.saveFlags;
          if (i != 0) {
              if (i == -1 || (i & 1) == 1) {
                  this.peekHeight = ss.peekHeight;
              }
              int i2 = this.saveFlags;
              if (i2 == -1 || (i2 & 2) == 2) {
                  this.fitToContents = ss.fitToContents;
              }
              int i3 = this.saveFlags;
              if (i3 == -1 || (i3 & 4) == 4) {
                  this.hideable = ss.hideable;
              }
              int i4 = this.saveFlags;
              if (i4 == -1 || (i4 & 8) == 8) {
                  this.skipCollapsed = ss.skipCollapsed;
              }
          }
      }
  
      private void runAfterLayout(V v, Runnable runnable) {
          if (isLayouting(v)) {
              v.post(runnable);
          } else {
              runnable.run();
          }
      }
  
      private void setWindowInsetsListener(View child) {
          final boolean z = Build.VERSION.SDK_INT >= 29 && !isGestureInsetBottomIgnored() && !this.peekHeightAuto;
          if (this.paddingBottomSystemWindowInsets || this.paddingLeftSystemWindowInsets || this.paddingRightSystemWindowInsets || this.marginLeftSystemWindowInsets || this.marginRightSystemWindowInsets || this.marginTopSystemWindowInsets || z) {
              ViewUtils.doOnApplyWindowInsets(child, new ViewUtils.OnApplyWindowInsetsListener() {
                  public WindowInsetsCompat onApplyWindowInsets(View view, WindowInsetsCompat insets, ViewUtils.RelativePadding initialPadding) {
                      Insets insets2 = insets.getInsets(WindowInsetsCompat.Type.systemBars());
                      Insets insets3 = insets.getInsets(WindowInsetsCompat.Type.mandatorySystemGestures());
                      int unused = BottomSheetBehavior.this.insetTop = insets2.top;
                      boolean isLayoutRtl = ViewUtils.isLayoutRtl(view);
                      int paddingBottom = view.getPaddingBottom();
                      int paddingLeft = view.getPaddingLeft();
                      int paddingRight = view.getPaddingRight();
                      if (BottomSheetBehavior.this.paddingBottomSystemWindowInsets) {
                          int unused2 = BottomSheetBehavior.this.insetBottom = insets.getSystemWindowInsetBottom();
                          paddingBottom = initialPadding.bottom + BottomSheetBehavior.this.insetBottom;
                      }
                      if (BottomSheetBehavior.this.paddingLeftSystemWindowInsets) {
                          paddingLeft = (isLayoutRtl ? initialPadding.end : initialPadding.start) + insets2.left;
                      }
                      if (BottomSheetBehavior.this.paddingRightSystemWindowInsets) {
                          paddingRight = (isLayoutRtl ? initialPadding.start : initialPadding.end) + insets2.right;
                      }
                      ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
                      boolean z = false;
                      if (BottomSheetBehavior.this.marginLeftSystemWindowInsets && marginLayoutParams.leftMargin != insets2.left) {
                          marginLayoutParams.leftMargin = insets2.left;
                          z = true;
                      }
                      if (BottomSheetBehavior.this.marginRightSystemWindowInsets && marginLayoutParams.rightMargin != insets2.right) {
                          marginLayoutParams.rightMargin = insets2.right;
                          z = true;
                      }
                      if (BottomSheetBehavior.this.marginTopSystemWindowInsets && marginLayoutParams.topMargin != insets2.top) {
                          marginLayoutParams.topMargin = insets2.top;
                          z = true;
                      }
                      if (z) {
                          view.setLayoutParams(marginLayoutParams);
                      }
                      view.setPadding(paddingLeft, view.getPaddingTop(), paddingRight, paddingBottom);
                      if (z) {
                          int unused3 = BottomSheetBehavior.this.gestureInsetBottom = insets3.bottom;
                      }
                      if (BottomSheetBehavior.this.paddingBottomSystemWindowInsets || z) {
                          BottomSheetBehavior.this.updatePeekHeight(false);
                      }
                      return insets;
                  }
              });
          }
      }
  
      private boolean shouldHandleDraggingWithHelper() {
          return this.viewDragHelper != null && (this.draggable || this.state == 1);
      }
  
      /* access modifiers changed from: private */
      public void startSettling(View child, int state2, boolean isReleasingView) {
          int topOffsetForState = getTopOffsetForState(state2);
          ViewDragHelper viewDragHelper2 = this.viewDragHelper;
          if (viewDragHelper2 != null && (!isReleasingView ? viewDragHelper2.smoothSlideViewTo(child, child.getLeft(), topOffsetForState) : viewDragHelper2.settleCapturedViewAt(child.getLeft(), topOffsetForState))) {
              setStateInternal(2);
              updateDrawableForTargetState(state2);
              this.stateSettlingTracker.continueSettlingToState(state2);
              return;
          }
          setStateInternal(state2);
      }
  
      private void updateAccessibilityActions() {
          View view;
          WeakReference<V> weakReference = this.viewRef;
          if (weakReference != null && (view = (View) weakReference.get()) != null) {
              ViewCompat.removeAccessibilityAction(view, 524288);
              ViewCompat.removeAccessibilityAction(view, 262144);
              ViewCompat.removeAccessibilityAction(view, 1048576);
              int i = this.expandHalfwayActionId;
              if (i != -1) {
                  ViewCompat.removeAccessibilityAction(view, i);
              }
              int i2 = 6;
              if (!this.fitToContents && this.state != 6) {
                  this.expandHalfwayActionId = addAccessibilityActionForState(view, R.string.bottomsheet_action_expand_halfway, 6);
              }
              if (this.hideable && this.state != 5) {
                  replaceAccessibilityActionForState(view, AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_DISMISS, 5);
              }
              switch (this.state) {
                  case 3:
                      if (this.fitToContents) {
                          i2 = 4;
                      }
                      replaceAccessibilityActionForState(view, AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_COLLAPSE, i2);
                      return;
                  case 4:
                      if (this.fitToContents) {
                          i2 = 3;
                      }
                      replaceAccessibilityActionForState(view, AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_EXPAND, i2);
                      return;
                  case 6:
                      replaceAccessibilityActionForState(view, AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_COLLAPSE, 4);
                      replaceAccessibilityActionForState(view, AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_EXPAND, 3);
                      return;
                  default:
                      return;
              }
          }
      }
  
      private void updateDrawableForTargetState(int state2) {
          ValueAnimator valueAnimator;
          if (state2 != 2) {
              boolean z = state2 == 3;
              if (this.isShapeExpanded != z) {
                  this.isShapeExpanded = z;
                  if (this.materialShapeDrawable != null && (valueAnimator = this.interpolatorAnimator) != null) {
                      if (valueAnimator.isRunning()) {
                          this.interpolatorAnimator.reverse();
                          return;
                      }
                      float f = z ? 0.0f : 1.0f;
                      this.interpolatorAnimator.setFloatValues(new float[]{1.0f - f, f});
                      this.interpolatorAnimator.start();
                  }
              }
          }
      }
  
      private void updateImportantForAccessibility(boolean expanded) {
          Map<View, Integer> map;
          WeakReference<V> weakReference = this.viewRef;
          if (weakReference != null) {
              ViewParent parent = ((View) weakReference.get()).getParent();
              if (parent instanceof CoordinatorLayout) {
                  CoordinatorLayout coordinatorLayout = (CoordinatorLayout) parent;
                  int childCount = coordinatorLayout.getChildCount();
                  if (Build.VERSION.SDK_INT >= 16 && expanded) {
                      if (this.importantForAccessibilityMap == null) {
                          this.importantForAccessibilityMap = new HashMap(childCount);
                      } else {
                          return;
                      }
                  }
                  for (int i = 0; i < childCount; i++) {
                      View childAt = coordinatorLayout.getChildAt(i);
                      if (childAt != this.viewRef.get()) {
                          if (expanded) {
                              if (Build.VERSION.SDK_INT >= 16) {
                                  this.importantForAccessibilityMap.put(childAt, Integer.valueOf(childAt.getImportantForAccessibility()));
                              }
                              if (this.updateImportantForAccessibilityOnSiblings) {
                                  ViewCompat.setImportantForAccessibility(childAt, 4);
                              }
                          } else if (this.updateImportantForAccessibilityOnSiblings && (map = this.importantForAccessibilityMap) != null && map.containsKey(childAt)) {
                              ViewCompat.setImportantForAccessibility(childAt, this.importantForAccessibilityMap.get(childAt).intValue());
                          }
                      }
                  }
                  if (!expanded) {
                      this.importantForAccessibilityMap = null;
                  } else if (this.updateImportantForAccessibilityOnSiblings) {
                      ((View) this.viewRef.get()).sendAccessibilityEvent(8);
                  }
              }
          }
      }
  
      /* access modifiers changed from: private */
      public void updatePeekHeight(boolean animate) {
          View view;
          if (this.viewRef != null) {
              calculateCollapsedOffset();
              if (this.state == 4 && (view = (View) this.viewRef.get()) != null) {
                  if (animate) {
                      setState(4);
                  } else {
                      view.requestLayout();
                  }
              }
          }
      }
  
      public void addBottomSheetCallback(BottomSheetCallback callback) {
          if (!this.callbacks.contains(callback)) {
              this.callbacks.add(callback);
          }
      }
  
      public void disableShapeAnimations() {
          this.interpolatorAnimator = null;
      }
  
      /* access modifiers changed from: package-private */
      public void dispatchOnSlide(int top) {
          float f;
          View view = (View) this.viewRef.get();
          if (view != null && !this.callbacks.isEmpty()) {
              int i = this.collapsedOffset;
              if (top > i || i == getExpandedOffset()) {
                  int i2 = this.collapsedOffset;
                  f = ((float) (i2 - top)) / ((float) (this.parentHeight - i2));
              } else {
                  int i3 = this.collapsedOffset;
                  f = ((float) (i3 - top)) / ((float) (i3 - getExpandedOffset()));
              }
              float f2 = f;
              for (int i4 = 0; i4 < this.callbacks.size(); i4++) {
                  this.callbacks.get(i4).onSlide(view, f2);
              }
          }
      }
  
      /* access modifiers changed from: package-private */
      public View findScrollingChild(View view) {
          if (ViewCompat.isNestedScrollingEnabled(view)) {
              return view;
          }
          if (!(view instanceof ViewGroup)) {
              return null;
          }
          ViewGroup viewGroup = (ViewGroup) view;
          int childCount = viewGroup.getChildCount();
          for (int i = 0; i < childCount; i++) {
              View findScrollingChild = findScrollingChild(viewGroup.getChildAt(i));
              if (findScrollingChild != null) {
                  return findScrollingChild;
              }
          }
          return null;
      }
  
      public int getExpandedOffset() {
          if (this.fitToContents) {
              return this.fitToContentsOffset;
          }
          return Math.max(this.expandedOffset, this.paddingTopSystemWindowInsets ? 0 : this.insetTop);
      }
  
      public float getHalfExpandedRatio() {
          return this.halfExpandedRatio;
      }
  
      public int getLastStableState() {
          return this.lastStableState;
      }
  
      /* access modifiers changed from: package-private */
      public MaterialShapeDrawable getMaterialShapeDrawable() {
          return this.materialShapeDrawable;
      }
  
      public int getMaxHeight() {
          return this.maxHeight;
      }
  
      public int getMaxWidth() {
          return this.maxWidth;
      }
  
      public int getPeekHeight() {
          if (this.peekHeightAuto) {
              return -1;
          }
          return this.peekHeight;
      }
  
      /* access modifiers changed from: package-private */
      public int getPeekHeightMin() {
          return this.peekHeightMin;
      }
  
      public int getSaveFlags() {
          return this.saveFlags;
      }
  
      public boolean getSkipCollapsed() {
          return this.skipCollapsed;
      }
  
      public int getState() {
          return this.state;
      }
  
      public boolean isDraggable() {
          return this.draggable;
      }
  
      public boolean isFitToContents() {
          return this.fitToContents;
      }
  
      public boolean isGestureInsetBottomIgnored() {
          return this.gestureInsetBottomIgnored;
      }
  
      public boolean isHideable() {
          return this.hideable;
      }
  
      public boolean isNestedScrollingCheckEnabled() {
          return true;
      }
  
      public void onAttachedToLayoutParams(CoordinatorLayout.LayoutParams layoutParams) {
          super.onAttachedToLayoutParams(layoutParams);
          this.viewRef = null;
          this.viewDragHelper = null;
      }
  
      public void onDetachedFromLayoutParams() {
          super.onDetachedFromLayoutParams();
          this.viewRef = null;
          this.viewDragHelper = null;
      }
  
      public boolean onInterceptTouchEvent(CoordinatorLayout parent, V v, MotionEvent event) {
          ViewDragHelper viewDragHelper2;
          if (!v.isShown() || !this.draggable) {
              this.ignoreEvents = true;
              return false;
          }
          int actionMasked = event.getActionMasked();
          if (actionMasked == 0) {
              reset();
          }
          if (this.velocityTracker == null) {
              this.velocityTracker = VelocityTracker.obtain();
          }
          this.velocityTracker.addMovement(event);
          View view = null;
          switch (actionMasked) {
              case 0:
                  int x = (int) event.getX();
                  this.initialY = (int) event.getY();
                  if (this.state != 2) {
                      WeakReference<View> weakReference = this.nestedScrollingChildRef;
                      View view2 = weakReference != null ? (View) weakReference.get() : null;
                      if (view2 != null && parent.isPointInChildBounds(view2, x, this.initialY)) {
                          this.activePointerId = event.getPointerId(event.getActionIndex());
                          this.touchingScrollingChild = true;
                      }
                  }
                  this.ignoreEvents = this.activePointerId == -1 && !parent.isPointInChildBounds(v, x, this.initialY);
                  break;
              case 1:
              case 3:
                  this.touchingScrollingChild = false;
                  this.activePointerId = -1;
                  if (this.ignoreEvents) {
                      this.ignoreEvents = false;
                      return false;
                  }
                  break;
          }
          if (!this.ignoreEvents && (viewDragHelper2 = this.viewDragHelper) != null && viewDragHelper2.shouldInterceptTouchEvent(event)) {
              return true;
          }
          WeakReference<View> weakReference2 = this.nestedScrollingChildRef;
          if (weakReference2 != null) {
              view = (View) weakReference2.get();
          }
          return actionMasked == 2 && view != null && !this.ignoreEvents && this.state != 1 && !parent.isPointInChildBounds(view, (int) event.getX(), (int) event.getY()) && this.viewDragHelper != null && Math.abs(((float) this.initialY) - event.getY()) > ((float) this.viewDragHelper.getTouchSlop());
      }
  
      public boolean onLayoutChild(CoordinatorLayout parent, V v, int layoutDirection) {
          if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(v)) {
              v.setFitsSystemWindows(true);
          }
          if (this.viewRef == null) {
              this.peekHeightMin = parent.getResources().getDimensionPixelSize(R.dimen.design_bottom_sheet_peek_height_min);
              setWindowInsetsListener(v);
              this.viewRef = new WeakReference<>(v);
              MaterialShapeDrawable materialShapeDrawable2 = this.materialShapeDrawable;
              if (materialShapeDrawable2 != null) {
                  ViewCompat.setBackground(v, materialShapeDrawable2);
                  MaterialShapeDrawable materialShapeDrawable3 = this.materialShapeDrawable;
                  float f = this.elevation;
                  if (f == -1.0f) {
                      f = ViewCompat.getElevation(v);
                  }
                  materialShapeDrawable3.setElevation(f);
                  boolean z = this.state == 3;
                  this.isShapeExpanded = z;
                  this.materialShapeDrawable.setInterpolation(z ? 0.0f : 1.0f);
              } else {
                  ColorStateList colorStateList = this.backgroundTint;
                  if (colorStateList != null) {
                      ViewCompat.setBackgroundTintList(v, colorStateList);
                  }
              }
              updateAccessibilityActions();
              if (ViewCompat.getImportantForAccessibility(v) == 0) {
                  ViewCompat.setImportantForAccessibility(v, 1);
              }
          }
          if (this.viewDragHelper == null) {
              this.viewDragHelper = ViewDragHelper.create(parent, this.dragCallback);
          }
          int top = v.getTop();
          parent.onLayoutChild(v, layoutDirection);
          this.parentWidth = parent.getWidth();
          this.parentHeight = parent.getHeight();
          int height = v.getHeight();
          this.childHeight = height;
          int i = this.parentHeight;
          int i2 = i - height;
          int i3 = this.insetTop;
          if (i2 < i3) {
              if (this.paddingTopSystemWindowInsets) {
                  this.childHeight = i;
              } else {
                  this.childHeight = i - i3;
              }
          }
          this.fitToContentsOffset = Math.max(0, i - this.childHeight);
          calculateHalfExpandedOffset();
          calculateCollapsedOffset();
          int i4 = this.state;
          if (i4 == 3) {
              ViewCompat.offsetTopAndBottom(v, getExpandedOffset());
          } else if (i4 == 6) {
              ViewCompat.offsetTopAndBottom(v, this.halfExpandedOffset);
          } else if (this.hideable && i4 == 5) {
              ViewCompat.offsetTopAndBottom(v, this.parentHeight);
          } else if (i4 == 4) {
              ViewCompat.offsetTopAndBottom(v, this.collapsedOffset);
          } else if (i4 == 1 || i4 == 2) {
              ViewCompat.offsetTopAndBottom(v, top - v.getTop());
          }
          this.nestedScrollingChildRef = new WeakReference<>(findScrollingChild(v));
          for (int i5 = 0; i5 < this.callbacks.size(); i5++) {
              this.callbacks.get(i5).onLayout(v);
          }
          return true;
      }
  
      public boolean onMeasureChild(CoordinatorLayout parent, V v, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) {
          ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
          v.measure(getChildMeasureSpec(parentWidthMeasureSpec, parent.getPaddingLeft() + parent.getPaddingRight() + marginLayoutParams.leftMargin + marginLayoutParams.rightMargin + widthUsed, this.maxWidth, marginLayoutParams.width), getChildMeasureSpec(parentHeightMeasureSpec, parent.getPaddingTop() + parent.getPaddingBottom() + marginLayoutParams.topMargin + marginLayoutParams.bottomMargin + heightUsed, this.maxHeight, marginLayoutParams.height));
          return true;
      }
  
      public boolean onNestedPreFling(CoordinatorLayout coordinatorLayout, V v, View target, float velocityX, float velocityY) {
          WeakReference<View> weakReference;
          if (!isNestedScrollingCheckEnabled() || (weakReference = this.nestedScrollingChildRef) == null || target != weakReference.get()) {
              return false;
          }
          return this.state != 3 || super.onNestedPreFling(coordinatorLayout, v, target, velocityX, velocityY);
      }
  
      public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, V v, View target, int dx, int dy, int[] consumed, int type) {
          if (type != 1) {
              WeakReference<View> weakReference = this.nestedScrollingChildRef;
              View view = weakReference != null ? (View) weakReference.get() : null;
              if (!isNestedScrollingCheckEnabled() || target == view) {
                  int top = v.getTop();
                  int i = top - dy;
                  if (dy > 0) {
                      if (i < getExpandedOffset()) {
                          consumed[1] = top - getExpandedOffset();
                          ViewCompat.offsetTopAndBottom(v, -consumed[1]);
                          setStateInternal(3);
                      } else if (this.draggable) {
                          consumed[1] = dy;
                          ViewCompat.offsetTopAndBottom(v, -dy);
                          setStateInternal(1);
                      } else {
                          return;
                      }
                  } else if (dy < 0 && !target.canScrollVertically(-1)) {
                      int i2 = this.collapsedOffset;
                      if (i > i2 && !this.hideable) {
                          consumed[1] = top - i2;
                          ViewCompat.offsetTopAndBottom(v, -consumed[1]);
                          setStateInternal(4);
                      } else if (this.draggable) {
                          consumed[1] = dy;
                          ViewCompat.offsetTopAndBottom(v, -dy);
                          setStateInternal(1);
                      } else {
                          return;
                      }
                  }
                  dispatchOnSlide(v.getTop());
                  this.lastNestedScrollDy = dy;
                  this.nestedScrolled = true;
              }
          }
      }
  
      public void onNestedScroll(CoordinatorLayout coordinatorLayout, V v, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type, int[] consumed) {
      }
  
      public void onRestoreInstanceState(CoordinatorLayout parent, V v, Parcelable state2) {
          SavedState savedState = (SavedState) state2;
          super.onRestoreInstanceState(parent, v, savedState.getSuperState());
          restoreOptionalState(savedState);
          if (savedState.state == 1 || savedState.state == 2) {
              this.state = 4;
              this.lastStableState = 4;
              return;
          }
          int i = savedState.state;
          this.state = i;
          this.lastStableState = i;
      }
  
      public Parcelable onSaveInstanceState(CoordinatorLayout parent, V v) {
          return new SavedState(super.onSaveInstanceState(parent, v), (BottomSheetBehavior<?>) this);
      }
  
      public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, V v, View directTargetChild, View target, int axes, int type) {
          this.lastNestedScrollDy = 0;
          this.nestedScrolled = false;
          return (axes & 2) != 0;
      }
  
      public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, V v, View target, int type) {
          int i;
          WeakReference<View> weakReference;
          if (v.getTop() == getExpandedOffset()) {
              setStateInternal(3);
          } else if (!isNestedScrollingCheckEnabled() || ((weakReference = this.nestedScrollingChildRef) != null && target == weakReference.get() && this.nestedScrolled)) {
              if (this.lastNestedScrollDy > 0) {
                  i = this.fitToContents ? 3 : v.getTop() > this.halfExpandedOffset ? 6 : 3;
              } else if (this.hideable && shouldHide(v, getYVelocity())) {
                  i = 5;
              } else if (this.lastNestedScrollDy == 0) {
                  int top = v.getTop();
                  if (this.fitToContents) {
                      i = Math.abs(top - this.fitToContentsOffset) < Math.abs(top - this.collapsedOffset) ? 3 : 4;
                  } else {
                      int i2 = this.halfExpandedOffset;
                      i = top < i2 ? top < Math.abs(top - this.collapsedOffset) ? 3 : shouldSkipHalfExpandedStateWhenDragging() ? 4 : 6 : Math.abs(top - i2) < Math.abs(top - this.collapsedOffset) ? 6 : 4;
                  }
              } else if (this.fitToContents) {
                  i = 4;
              } else {
                  int top2 = v.getTop();
                  i = Math.abs(top2 - this.halfExpandedOffset) < Math.abs(top2 - this.collapsedOffset) ? 6 : 4;
              }
              startSettling(v, i, false);
              this.nestedScrolled = false;
          }
      }
  
      public boolean onTouchEvent(CoordinatorLayout parent, V v, MotionEvent event) {
          if (!v.isShown()) {
              return false;
          }
          int actionMasked = event.getActionMasked();
          if (this.state == 1 && actionMasked == 0) {
              return true;
          }
          if (shouldHandleDraggingWithHelper()) {
              this.viewDragHelper.processTouchEvent(event);
          }
          if (actionMasked == 0) {
              reset();
          }
          if (this.velocityTracker == null) {
              this.velocityTracker = VelocityTracker.obtain();
          }
          this.velocityTracker.addMovement(event);
          if (shouldHandleDraggingWithHelper() && actionMasked == 2 && !this.ignoreEvents && Math.abs(((float) this.initialY) - event.getY()) > ((float) this.viewDragHelper.getTouchSlop())) {
              this.viewDragHelper.captureChildView(v, event.getPointerId(event.getActionIndex()));
          }
          return !this.ignoreEvents;
      }
  
      public void removeBottomSheetCallback(BottomSheetCallback callback) {
          this.callbacks.remove(callback);
      }
  
      @Deprecated
      public void setBottomSheetCallback(BottomSheetCallback callback) {
          Log.w(TAG, "BottomSheetBehavior now supports multiple callbacks. `setBottomSheetCallback()` removes all existing callbacks, including ones set internally by library authors, which may result in unintended behavior. This may change in the future. Please use `addBottomSheetCallback()` and `removeBottomSheetCallback()` instead to set your own callbacks.");
          this.callbacks.clear();
          if (callback != null) {
              this.callbacks.add(callback);
          }
      }
  
      public void setDraggable(boolean draggable2) {
          this.draggable = draggable2;
      }
  
      public void setExpandedOffset(int offset) {
          if (offset >= 0) {
              this.expandedOffset = offset;
              return;
          }
          throw new IllegalArgumentException("offset must be greater than or equal to 0");
      }
  
      public void setFitToContents(boolean fitToContents2) {
          if (this.fitToContents != fitToContents2) {
              this.fitToContents = fitToContents2;
              if (this.viewRef != null) {
                  calculateCollapsedOffset();
              }
              setStateInternal((!this.fitToContents || this.state != 6) ? this.state : 3);
              updateAccessibilityActions();
          }
      }
  
      public void setGestureInsetBottomIgnored(boolean gestureInsetBottomIgnored2) {
          this.gestureInsetBottomIgnored = gestureInsetBottomIgnored2;
      }
  
      public void setHalfExpandedRatio(float ratio) {
          if (ratio <= 0.0f || ratio >= 1.0f) {
              throw new IllegalArgumentException("ratio must be a float value between 0 and 1");
          }
          this.halfExpandedRatio = ratio;
          if (this.viewRef != null) {
              calculateHalfExpandedOffset();
          }
      }
  
      public void setHideable(boolean hideable2) {
          if (this.hideable != hideable2) {
              this.hideable = hideable2;
              if (!hideable2 && this.state == 5) {
                  setState(4);
              }
              updateAccessibilityActions();
          }
      }
  
      public void setHideableInternal(boolean hideable2) {
          this.hideable = hideable2;
      }
  
      public void setMaxHeight(int maxHeight2) {
          this.maxHeight = maxHeight2;
      }
  
      public void setMaxWidth(int maxWidth2) {
          this.maxWidth = maxWidth2;
      }
  
      public void setPeekHeight(int peekHeight2) {
          setPeekHeight(peekHeight2, false);
      }
  
      public final void setPeekHeight(int peekHeight2, boolean animate) {
          boolean z = false;
          if (peekHeight2 == -1) {
              if (!this.peekHeightAuto) {
                  this.peekHeightAuto = true;
                  z = true;
              }
          } else if (this.peekHeightAuto || this.peekHeight != peekHeight2) {
              this.peekHeightAuto = false;
              this.peekHeight = Math.max(0, peekHeight2);
              z = true;
          }
          if (z) {
              updatePeekHeight(animate);
          }
      }
  
      public void setSaveFlags(int flags) {
          this.saveFlags = flags;
      }
  
      public void setSkipCollapsed(boolean skipCollapsed2) {
          this.skipCollapsed = skipCollapsed2;
      }
  
      public void setState(int state2) {
          if (state2 == 1 || state2 == 2) {
              throw new IllegalArgumentException("STATE_" + (state2 == 1 ? "DRAGGING" : "SETTLING") + " should not be set externally.");
          } else if (this.hideable || state2 != 5) {
              final int i = (state2 != 6 || !this.fitToContents || getTopOffsetForState(state2) > this.fitToContentsOffset) ? state2 : 3;
              WeakReference<V> weakReference = this.viewRef;
              if (weakReference == null || weakReference.get() == null) {
                  setStateInternal(state2);
                  return;
              }
              final View view = (View) this.viewRef.get();
              runAfterLayout(view, new Runnable() {
                  public void run() {
                      BottomSheetBehavior.this.startSettling(view, i, false);
                  }
              });
          } else {
              Log.w(TAG, "Cannot set state: " + state2);
          }
      }
  
      /* access modifiers changed from: package-private */
      public void setStateInternal(int state2) {
          View view;
          if (this.state != state2) {
              this.state = state2;
              if (state2 == 4 || state2 == 3 || state2 == 6 || (this.hideable && state2 == 5)) {
                  this.lastStableState = state2;
              }
              WeakReference<V> weakReference = this.viewRef;
              if (weakReference != null && (view = (View) weakReference.get()) != null) {
                  if (state2 == 3) {
                      updateImportantForAccessibility(true);
                  } else if (state2 == 6 || state2 == 5 || state2 == 4) {
                      updateImportantForAccessibility(false);
                  }
                  updateDrawableForTargetState(state2);
                  for (int i = 0; i < this.callbacks.size(); i++) {
                      this.callbacks.get(i).onStateChanged(view, state2);
                  }
                  updateAccessibilityActions();
              }
          }
      }
  
      public void setUpdateImportantForAccessibilityOnSiblings(boolean updateImportantForAccessibilityOnSiblings2) {
          this.updateImportantForAccessibilityOnSiblings = updateImportantForAccessibilityOnSiblings2;
      }
  
      public boolean shouldExpandOnUpwardDrag(long dragDurationMillis, float yPositionPercentage) {
          return false;
      }
  
      /* access modifiers changed from: package-private */
      public boolean shouldHide(View child, float yvel) {
          if (this.skipCollapsed) {
              return true;
          }
          if (child.getTop() < this.collapsedOffset) {
              return false;
          }
          return Math.abs((((float) child.getTop()) + (0.1f * yvel)) - ((float) this.collapsedOffset)) / ((float) calculatePeekHeight()) > 0.5f;
      }
  
      public boolean shouldSkipHalfExpandedStateWhenDragging() {
          return false;
      }
  
      public boolean shouldSkipSmoothAnimation() {
          return true;
      }
  }
  