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; };

import React from 'react';
import { storiesOf } from '@storybook/react';
import { withKnobs, boolean, text } from '@storybook/addon-knobs';

import { Paragraph, Heading, CompHeading, SidebarHeading, DecorativeLink, UnorderedList, compHeadingOptions, sidebarHeadingOptions, decorativeLinkOptions, unorderedOptions } from './RichText.require';
import RichText from './index';
import RichTextDocs from './RichText.md';

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

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

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

    var k = _ref5[0],
        v = _ref5[1];
    return _ref6 = {}, _ref6[k] = v(SidebarHeading.defaultProps[k]), _ref6;
  }));
  var paraOptionsWithKnobs = {
    text: 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(unorderedOptions).map(function (_ref7) {
    var _ref8;

    var k = _ref7[0],
        v = _ref7[1];
    return _ref8 = {}, _ref8[k] = v(UnorderedList.defaultProps[k]), _ref8;
  }));
  var headerIndent = boolean('headerIndent', RichText.defaultProps.headerIndent, 'RichText');
  var anchorLinks = boolean('anchorLinks', RichText.defaultProps.anchorLinks, 'RichText');
  var description = {
    rteElements: [{
      path: '@atoms/11-text/paragraph.twig',
      data: {
        paragraph: {
          text: 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 React.createElement(
    RichText,
    _extends({ headerIndent: headerIndent, anchorLinks: anchorLinks }, description),
    React.createElement(CompHeading, compOptionsWithKnobs),
    React.createElement(SidebarHeading, sideOptionsWithKnobs),
    React.createElement(Paragraph, paraOptionsWithKnobs),
    React.createElement(Paragraph, { text: text('Paragraph2: text', 'foobarbaz', 'Paragraph') }),
    React.createElement(Heading, { text: text('Heading: text', 'This is a heading', 'Heading'), level: 1 }),
    React.createElement(UnorderedList, orderedOptionsWithKnobs),
    React.createElement(DecorativeLink, decoreOptionsWithKnobs)
  );
}, { info: RichTextDocs });