"use strict";

var _react = _interopRequireDefault(require("react"));
var _redux = require("redux");
var _reactRedux = require("react-redux");
var _react2 = require("@storybook/react");
var _ThemeProvider = _interopRequireDefault(require("../../../../Screens/Configurator/ThemeProvider"));
var _index = _interopRequireDefault(require("./index"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
var initialState = {
  availableOption: {
    identifier: '010002011000',
    imageIdentifier: '010002011000',
    title: 'Argentina 1000',
    priceFormatted: '€ 123.00',
    amount_is_selectable: false,
    check_results: {
      status: true
    }
  },
  unavailableOption: {
    identifier: '010002011000',
    imageIdentifier: '',
    title: 'Argentina 1000',
    priceFormatted: '€ 123.00',
    amount_is_selectable: false,
    check_results: {
      status: true
    }
  },
  optionWithSelectableAmount: {
    identifier: '010002011000',
    imageIdentifier: '',
    title: 'Argentina 1000',
    priceFormatted: '€ 123.00',
    amount_is_selectable: true,
    check_results: {
      status: true
    }
  },
  optionWithDetails: {
    identifier: '010002011000',
    imageIdentifier: '',
    title: 'Argentina 1000',
    priceFormatted: '€ 123.00',
    "abstract": 'abstract',
    amount_is_selectable: false,
    check_results: {
      status: true
    }
  },
  incompatibleOption: {
    identifier: '010002011000',
    imageIdentifier: '',
    title: 'Argentina 1000',
    priceFormatted: '€ 123.00',
    "abstract": 'abstract',
    amount_is_selectable: false
  },
  optionNotInStock: {
    identifier: '010002011000',
    imageIdentifier: '',
    title: 'Argentina 1000',
    priceFormatted: '€ 123.00',
    stock: {
      traffic_light: 'red'
    }
  },
  optionWithDelay: {
    identifier: '010002011000',
    imageIdentifier: '',
    title: 'Argentina 1000',
    priceFormatted: '€ 123.00',
    stock: {
      traffic_light: 'yellow'
    }
  },
  optionWithOptionGroup: {
    identifier: '010002011000',
    imageIdentifier: '',
    title: 'Argentina 1000',
    priceFormatted: '€ 123.00',
    option_group: {
      children: [{
        identifier: '1',
        title: 'Child 1'
      }, {
        identifier: '2',
        title: 'Child 2'
      }],
      title: 'My group'
    }
  },
  translations: {
    imageNotAvailable: 'No preview available',
    details: 'Details',
    incompatibility: 'Incompatibility',
    notAvailable: 'Not avaiable',
    lateDelivery: 'Late delivery'
  }
};
var reducer = function reducer() {
  var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  var action = arguments.length > 1 ? arguments[1] : undefined;
  return _objectSpread(_objectSpread({}, action), state);
};
var store = (0, _redux.createStore)(reducer, ['Use Redux']);
var createStory = function createStory(option) {
  return /*#__PURE__*/_react["default"].createElement(_reactRedux.Provider, {
    store: store
  }, /*#__PURE__*/_react["default"].createElement(_ThemeProvider["default"], null, /*#__PURE__*/_react["default"].createElement("div", {
    style: {
      backgroundColor: 'lightblue',
      width: '350px'
    }
  }, /*#__PURE__*/_react["default"].createElement(_index["default"], {
    option: option,
    translations: initialState.translations
  }))));
};
(0, _react2.storiesOf)('Option', module).add('with available image', function () {
  return createStory(initialState.availableOption);
}).add('with unavailable image', function () {
  return createStory(initialState.unavailableOption);
}).add('with selectable amount', function () {
  return createStory(initialState.optionWithSelectableAmount);
}).add('with details', function () {
  return createStory(initialState.optionWithDetails);
}).add('with incompatibility link', function () {
  return createStory(initialState.incompatibleOption);
}).add('with stock - not available', function () {
  return createStory(initialState.optionNotInStock);
}).add('with stock - late delivery', function () {
  return createStory(initialState.optionWithDelay);
}).add('with option group', function () {
  return createStory(initialState.optionWithOptionGroup);
});