var _examples$TOAST_EXAMP;

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

/*
Copyright (c) 2018 Uber Technologies, Inc.

This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
import * as React from 'react';
import { styled } from '../styles/index.js';
import { Toast, toaster, ToasterContainer, KIND, PLACEMENT } from './index.js';
import { Button, KIND as ButtonKind, SIZE } from '../button/index.js';
import examples from './examples-list.js';
export var suite = 'Toast Test Suite';
var Centered = styled('div', {
  position: 'relative',
  display: 'flex',
  flexDirection: 'column',
  justifyContent: 'center',
  alignItems: 'center',
  lineHeight: 1.5
});
Centered.displayName = "Centered";
var Space = styled('span', {
  display: 'inline-block',
  lineHeight: 1.5,
  marginTop: '10px',
  marginRight: '10px',
  marginLeft: '10px'
});
Space.displayName = "Space";

var getBtnStyle = function getBtnStyle(color) {
  return function (_ref) {
    var $theme = _ref.$theme;
    var hoverStyle = {
      backgroundColor: $theme.colors["".concat(color, "500")]
    };
    var activeStyle = {
      backgroundColor: $theme.colors["".concat(color, "600")]
    };
    return {
      backgroundColor: $theme.colors[color],
      ':hover:enabled': hoverStyle,
      ':focus:enabled': hoverStyle,
      ':active:enabled': activeStyle
    };
  };
};

var ToasterExample =
/*#__PURE__*/
function (_React$Component) {
  _inherits(ToasterExample, _React$Component);

  function ToasterExample() {
    var _getPrototypeOf2;

    var _this;

    _classCallCheck(this, ToasterExample);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(ToasterExample)).call.apply(_getPrototypeOf2, [this].concat(args)));

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "add", function (kind, props) {
      return function () {
        var _this$getToastProps = _this.getToastProps(props),
            children = _this$getToastProps.children,
            toastProps = _objectWithoutProperties(_this$getToastProps, ["children"]);

        toaster[kind](children, toastProps);
      };
    });

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "addInfo", _this.add(KIND.info));

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "addPositive", _this.add(KIND.positive));

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "addWarning", _this.add(KIND.warning));

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "addNegative", _this.add(KIND.negative));

    return _this;
  }

  _createClass(ToasterExample, [{
    key: "getToastProps",
    value: function getToastProps(props) {
      return _objectSpread({
        onClose: function onClose() {
          // eslint-disable-next-line no-console
          console.log('Toast dismissed');
        },
        autoHideDuration: 5000,
        children: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'
      }, props);
    }
  }, {
    key: "render",
    value: function render() {
      return React.createElement("div", null, React.createElement(Button, {
        onClick: this.addInfo
      }, "Info toast"), React.createElement(Space, null), React.createElement(Button, {
        onClick: this.addPositive,
        overrides: {
          BaseButton: {
            style: getBtnStyle('positive')
          }
        }
      }, "Success toast"), React.createElement(Space, null), React.createElement(Button, {
        onClick: this.addWarning,
        overrides: {
          BaseButton: {
            style: getBtnStyle('warning')
          }
        }
      }, "Warning toast"), React.createElement(Space, null), React.createElement(Button, {
        onClick: this.addNegative,
        overrides: {
          BaseButton: {
            style: getBtnStyle('negative')
          }
        }
      }, "Negative toast"), React.createElement(Space, null), React.createElement(Button, {
        onClick: function onClick() {
          toaster.positive('hi');
        },
        overrides: {
          BaseButton: {
            style: getBtnStyle('positive')
          }
        }
      }, "Use ToasterContainer autoHideDuration"));
    }
  }]);

  return ToasterExample;
}(React.Component);

var ToasterAdvancedExample =
/*#__PURE__*/
function (_React$Component2) {
  _inherits(ToasterAdvancedExample, _React$Component2);

  function ToasterAdvancedExample() {
    var _getPrototypeOf3;

    var _this2;

    _classCallCheck(this, ToasterAdvancedExample);

    for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
      args[_key2] = arguments[_key2];
    }

    _this2 = _possibleConstructorReturn(this, (_getPrototypeOf3 = _getPrototypeOf(ToasterAdvancedExample)).call.apply(_getPrototypeOf3, [this].concat(args)));

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "keyToUpdate", void 0);

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "state", {
      cleared: false
    });

    return _this2;
  }

  _createClass(ToasterAdvancedExample, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      this.addNotifications();
    }
  }, {
    key: "addNotifications",
    value: function addNotifications() {
      toaster.info('Info notification', {
        closeable: false
      });
      toaster.positive(React.createElement("span", null, "Positive notification"));
      this.keyToUpdate = toaster.warning('Warning notification');
    }
  }, {
    key: "render",
    value: function render() {
      var _this3 = this;

      return React.createElement("div", null, React.createElement(Space, null, React.createElement(Button, {
        onClick: function onClick() {
          var kind = {
            '0': KIND.info,
            '1': KIND.positive,
            '2': KIND.warning
          }[Math.floor(Math.random() * Math.floor(3))];
          toaster.update(_this3.keyToUpdate, {
            kind: kind,
            children: "Updated ".concat(kind, " notification")
          });
        }
      }, "Update to random")), React.createElement(Space, null, React.createElement(Button, {
        onClick: function onClick() {
          toaster.clear();

          _this3.setState({
            cleared: true
          });
        }
      }, "Clear all")), React.createElement(Space, null, React.createElement(Button, {
        disabled: !this.state.cleared,
        onClick: function onClick() {
          _this3.addNotifications();

          _this3.setState({
            cleared: false
          });
        }
      }, "Add toasts")));
    }
  }]);

  return ToasterAdvancedExample;
}(React.Component);

export default (_examples$TOAST_EXAMP = {}, _defineProperty(_examples$TOAST_EXAMP, examples.TOAST_EXAMPLE, function Story1() {
  return React.createElement(Centered, null, React.createElement(Toast, null, "Default info notification"), React.createElement(Toast, null, function (_ref2) {
    var dismiss = _ref2.dismiss;
    return React.createElement(React.Fragment, null, "Info notification with no close button and children as a function.", React.createElement("div", null, React.createElement(Space, null, React.createElement(Button, {
      onClick: dismiss,
      kind: ButtonKind.secondary,
      size: SIZE.compact
    }, "Click to dismiss"))));
  }), React.createElement(Toast, {
    kind: KIND.positive
  }, "Positive notification"), React.createElement(Toast, {
    kind: KIND.warning
  }, "Warning notification"), React.createElement(Toast, {
    kind: KIND.negative
  }, "Negative notification"));
}), _defineProperty(_examples$TOAST_EXAMP, examples.TOASTER_EXAMPLE, function Story2() {
  return React.createElement(Centered, null, React.createElement(ToasterContainer, {
    placement: PLACEMENT.bottomRight,
    autoHideDuration: 500
  }), React.createElement(ToasterExample, null));
}), _defineProperty(_examples$TOAST_EXAMP, examples.TOASTER_ADVANCED_EXAMPLE, function Story2() {
  return React.createElement(Centered, null, React.createElement(ToasterContainer, {
    placement: PLACEMENT.bottom
  }), React.createElement(ToasterAdvancedExample, null));
}), _defineProperty(_examples$TOAST_EXAMP, examples.OVERRIDES_EXAMPLE, function Story3() {
  return React.createElement(Centered, null, React.createElement(Toast, {
    overrides: {
      Body: {
        style: {
          backgroundImage: 'linear-gradient(#400080, transparent), linear-gradient(200deg, #d047d1, #ff0000, #ffff00)'
        }
      },
      CloseIcon: {
        props: {
          title: 'Dismiss'
        },
        style: {
          backgroundColor: '#fff',
          color: '#000',
          borderRadius: '50%',
          paddingTop: '5px',
          paddingBottom: '5px',
          paddingLeft: '5px',
          paddingRight: '5px'
        }
      }
    }
  }, "Toast with overrides"));
}), _examples$TOAST_EXAMP);