'use strict';

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _react3 = require('@storybook/react');

var _addonKnobs = require('@storybook/addon-knobs');

var _RichText = require('./RichText.require');

var _index = require('./index');

var _index2 = _interopRequireDefault(_index);

var _RichText2 = require('./RichText.md');

var _RichText3 = _interopRequireDefault(_RichText2);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

(0, _react3.storiesOf)('organisms', module).addDecorator((0, _addonKnobs.withKnobs)({ escapeHTML: false })).add('RichText', function () {
  var decoreOptionsWithKnobs = Object.assign.apply(Object, Object.entries(_RichText.decorativeLinkOptions).map(function (_ref) {
    var _ref2;

    var k = _ref[0],
        v = _ref[1];
    return _ref2 = {}, _ref2[k] = v(_RichText.DecorativeLink.defaultProps[k]), _ref2;
  }));
  var compOptionsWithKnobs = Object.assign.apply(Object, Object.entries(_RichText.compHeadingOptions).map(function (_ref3) {
    var _ref4;

    var k = _ref3[0],
        v = _ref3[1];
    return _ref4 = {}, _ref4[k] = v(_RichText.CompHeading.defaultProps[k]), _ref4;
  }));
  var sideOptionsWithKnobs = Object.assign.apply(Object, Object.entries(_RichText.sidebarHeadingOptions).map(function (_ref5) {
    var _ref6;

    var k = _ref5[0],
        v = _ref5[1];
    return _ref6 = {}, _ref6[k] = v(_RichText.SidebarHeading.defaultProps[k]), _ref6;
  }));
  var paraOptionsWithKnobs = {
    text: (0, _addonKnobs.text)('Paragraph1: text', 'A <strong>paragraph</strong> (from the Greek paragraphos, "to write beside" or "written beside") is a self-contained unit of a discourse in writing dealing with a particular point or idea. A paragraph consists of one or more sentences. Though not required by the syntax of any language, paragraphs are usually an expected part of formal writing, used to organize longer prose.', 'Paragraph')
  };
  var orderedOptionsWithKnobs = Object.assign.apply(Object, Object.entries(_RichText.unorderedOptions).map(function (_ref7) {
    var _ref8;

    var k = _ref7[0],
        v = _ref7[1];
    return _ref8 = {}, _ref8[k] = v(_RichText.UnorderedList.defaultProps[k]), _ref8;
  }));
  var headerIndent = (0, _addonKnobs.boolean)('headerIndent', _index2.default.defaultProps.headerIndent, 'RichText');
  var anchorLinks = (0, _addonKnobs.boolean)('anchorLinks', _index2.default.defaultProps.anchorLinks, 'RichText');
  var description = {
    rteElements: [{
      path: '@atoms/11-text/paragraph.twig',
      data: {
        paragraph: {
          text: (0, _addonKnobs.text)('rteParagraph', 'Optional description', 'RichText')
        }
      }
    }, {
      path: '@atoms/08-lists/unordered-list.twig',
      data: {
        unorderedList: [{ text: 'This is a list item in an unordered list' }, { text: 'An unordered list is a list in which the sequence of items is not important. Sometimes, an unordered list is a bulleted list. And this is a long list item in an unordered list that can wrap onto a new line.' }, {
          text: 'Lists can be nested inside of each other',
          sublist: [{ text: 'This is a nested list item' }, { text: 'This is another nested list item in an unordered list' }]
        }, { text: 'This is the last list item' }]
      }
    }]
  };
  return _react2.default.createElement(
    _index2.default,
    _extends({ headerIndent: headerIndent, anchorLinks: anchorLinks }, description),
    _react2.default.createElement(_RichText.CompHeading, compOptionsWithKnobs),
    _react2.default.createElement(_RichText.SidebarHeading, sideOptionsWithKnobs),
    _react2.default.createElement(_RichText.Paragraph, paraOptionsWithKnobs),
    _react2.default.createElement(_RichText.Paragraph, { text: (0, _addonKnobs.text)('Paragraph2: text', 'foobarbaz', 'Paragraph') }),
    _react2.default.createElement(_RichText.Heading, { text: (0, _addonKnobs.text)('Heading: text', 'This is a heading', 'Heading'), level: 1 }),
    _react2.default.createElement(_RichText.UnorderedList, orderedOptionsWithKnobs),
    _react2.default.createElement(_RichText.DecorativeLink, decoreOptionsWithKnobs)
  );
}, { info: _RichText3.default });