text: import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
  import _createClass from "@babel/runtime/helpers/esm/createClass";
  import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
  import _inherits from "@babel/runtime/helpers/esm/inherits";
  import { createElement } from "@wordpress/element";
  
  function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  
  /**
   * External dependencies
   */
  import { AccessibilityInfo, View, Platform } from 'react-native';
  /**
   * WordPress dependencies
   */
  
  import { __, sprintf } from '@wordpress/i18n';
  import { Component } from '@wordpress/element';
  /**
   * Internal dependencies
   */
  
  import Cell from '../cell';
  import Stepper from './stepper';
  import styles from './style.scss';
  var STEP_DELAY = 200;
  var DEFAULT_STEP = 1;
  
  var BottomSheetStepperCell = /*#__PURE__*/function (_Component) {
    _inherits(BottomSheetStepperCell, _Component);
  
    var _super = _createSuper(BottomSheetStepperCell);
  
    function BottomSheetStepperCell(props) {
      var _this;
  
      _classCallCheck(this, BottomSheetStepperCell);
  
      _this = _super.call(this, props);
      _this.announceValue = _this.announceValue.bind(_assertThisInitialized(_this));
      _this.onDecrementValue = _this.onDecrementValue.bind(_assertThisInitialized(_this));
      _this.onDecrementValuePressIn = _this.onDecrementValuePressIn.bind(_assertThisInitialized(_this));
      _this.onIncrementValue = _this.onIncrementValue.bind(_assertThisInitialized(_this));
      _this.onIncrementValuePressIn = _this.onIncrementValuePressIn.bind(_assertThisInitialized(_this));
      _this.onPressOut = _this.onPressOut.bind(_assertThisInitialized(_this));
      _this.startPressInterval = _this.startPressInterval.bind(_assertThisInitialized(_this));
      return _this;
    }
  
    _createClass(BottomSheetStepperCell, [{
      key: "componentWillUnmount",
      value: function componentWillUnmount() {
        clearTimeout(this.timeout);
        clearInterval(this.interval);
        clearTimeout(this.timeoutAnnounceValue);
      }
    }, {
      key: "onIncrementValue",
      value: function onIncrementValue() {
        var _this$props = this.props,
            step = _this$props.step,
            max = _this$props.max,
            onChange = _this$props.onChange,
            value = _this$props.value;
        var newValue = value + step;
  
        if (newValue <= max) {
          onChange(newValue);
          this.announceValue(newValue);
        }
      }
    }, {
      key: "onDecrementValue",
      value: function onDecrementValue() {
        var _this$props2 = this.props,
            step = _this$props2.step,
            min = _this$props2.min,
            onChange = _this$props2.onChange,
            value = _this$props2.value;
        var newValue = value - step;
  
        if (newValue >= min) {
          onChange(newValue);
          this.announceValue(newValue);
        }
      }
    }, {
      key: "onIncrementValuePressIn",
      value: function onIncrementValuePressIn() {
        var _this2 = this;
  
        this.onIncrementValue();
        this.timeout = setTimeout(function () {
          _this2.startPressInterval(_this2.onIncrementValue);
        }, 500);
      }
    }, {
      key: "onDecrementValuePressIn",
      value: function onDecrementValuePressIn() {
        var _this3 = this;
  
        this.onDecrementValue();
        this.timeout = setTimeout(function () {
          _this3.startPressInterval(_this3.onDecrementValue);
        }, 500);
      }
    }, {
      key: "onPressOut",
      value: function onPressOut() {
        clearTimeout(this.timeout);
        clearInterval(this.interval);
      }
    }, {
      key: "startPressInterval",
      value: function startPressInterval(callback) {
        var _this4 = this;
  
        var speed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : STEP_DELAY;
        var counter = 0;
        this.interval = setInterval(function () {
          callback();
          counter += 1;
  
          if (counter === 10) {
            clearInterval(_this4.interval);
  
            _this4.startPressInterval(callback, speed / 2);
          }
        }, speed);
      }
    }, {
      key: "announceValue",
      value: function announceValue(value) {
        var label = this.props.label;
  
        if (Platform.OS === 'ios') {
          // On Android it triggers the accessibilityLabel with the value change
          clearTimeout(this.timeoutAnnounceValue);
          this.timeoutAnnounceValue = setTimeout(function () {
            AccessibilityInfo.announceForAccessibility("".concat(value, " ").concat(label));
          }, 300);
        }
      }
    }, {
      key: "render",
      value: function render() {
        var _this5 = this;
  
        var _this$props3 = this.props,
            label = _this$props3.label,
            icon = _this$props3.icon,
            min = _this$props3.min,
            max = _this$props3.max,
            value = _this$props3.value,
            separatorType = _this$props3.separatorType;
        var isMinValue = value === min;
        var isMaxValue = value === max;
        var labelStyle = [styles.cellLabel, !icon ? styles.cellLabelNoIcon : {}];
        var accessibilityLabel = sprintf(
        /* translators: accessibility text. Inform about current value. %1$s: Control label %2$s: Current value. */
        __('%1$s. Current value is %2$s'), label, value);
        return createElement(View, {
          accessible: true,
          accessibilityRole: "adjustable",
          accessibilityLabel: accessibilityLabel,
          accessibilityActions: [{
            name: 'increment'
          }, {
            name: 'decrement'
          }],
          onAccessibilityAction: function onAccessibilityAction(event) {
            switch (event.nativeEvent.actionName) {
              case 'increment':
                _this5.onIncrementValue();
  
                break;
  
              case 'decrement':
                _this5.onDecrementValue();
  
                break;
            }
          }
        }, createElement(Cell, {
          accessibilityRole: "none",
          accessible: false,
          cellContainerStyle: styles.cellContainerStyles,
          cellRowContainerStyle: styles.cellRowStyles,
          disabled: true,
          editable: false,
          icon: icon,
          label: label,
          labelStyle: labelStyle,
          leftAlign: true,
          separatorType: separatorType
        }, createElement(Stepper, {
          isMaxValue: isMaxValue,
          isMinValue: isMinValue,
          onPressInDecrement: this.onDecrementValuePressIn,
          onPressInIncrement: this.onIncrementValuePressIn,
          onPressOut: this.onPressOut,
          value: value
        })));
      }
    }]);
  
    return BottomSheetStepperCell;
  }(Component);
  
  BottomSheetStepperCell.defaultProps = {
    step: DEFAULT_STEP
  };
  export default BottomSheetStepperCell;
  //# sourceMappingURL=index.native.js.map