'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 _addonActions = require('@storybook/addon-actions');

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

var _index2 = _interopRequireDefault(_index);

var _Header = require('./Header.md');

var _Header2 = _interopRequireDefault(_Header);

var _MainNavKnob = require('../../molecules/MainNav/MainNav.knob.options');

var _MainNavKnob2 = _interopRequireDefault(_MainNavKnob);

var _UtilityNavKnob = require('../UtilityNav/UtilityNav.knob.options');

var _UtilityNavKnob2 = _interopRequireDefault(_UtilityNavKnob);

var _stateseal = require('../../../assets/images/stateseal.png');

var _stateseal2 = _interopRequireDefault(_stateseal);

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

(0, _react3.storiesOf)('organisms/Header', module).addDecorator((0, _addonKnobs.withKnobs)({ escapeHTML: false })).add('Header with MainNav & UtilityNav', function () {
  var mainNavProps = {
    onNavigateCallBack: (0, _addonActions.action)('onNavigateCallBack'),
    mainNav: []
  };
  mainNavProps.mainNav = _MainNavKnob2.default.mainNav.map(function (nav, navIndex) {
    var active = false;
    if (typeof nav.active === 'string') {
      active = nav.active.toLowerCase() === 'true';
    } else if (typeof nav.active === 'boolean') {
      active = nav.active;
    } else {
      active = false;
    }
    var storyProps = {
      href: (0, _addonKnobs.text)('Header mainNav, item' + navIndex + ': href', nav.href, 'Main Nav: Item ' + navIndex),
      text: (0, _addonKnobs.text)('Header mainNav, item' + navIndex + ': text', nav.text, 'Main Nav: Item ' + navIndex),
      active: (0, _addonKnobs.boolean)('Header mainNav, item' + navIndex + ': active', active, 'Main Nav: Item ' + navIndex),
      subNav: (0, _addonKnobs.object)('Header mainNav, item' + navIndex + ': subNav', nav.subNav, 'Main Nav: Item ' + navIndex)
    };
    return storyProps;
  });
  var utilityProps = {
    items: []
  };
  utilityProps.items = _UtilityNavKnob2.default.items.map(function (item, itemIndex) {
    var icons = {
      building: 'building',
      login: 'login'
    };
    var storyProps = {
      text: (0, _addonKnobs.text)('Header utilityNav, item' + itemIndex + ': text', item.text, 'Utility Nav: Item ' + itemIndex),
      ariaLabelText: (0, _addonKnobs.text)('Header utilityNav, item' + itemIndex + ': ariaLabelText', item.ariaLabelText, 'Utility Nav: Item ' + itemIndex),
      closeText: (0, _addonKnobs.text)('Header utilityNav, item' + itemIndex + ': closeText', item.closeText, 'Utility Nav: Item ' + itemIndex),
      panel: (0, _addonKnobs.object)('Header utilityNav, item' + itemIndex + ': panel', item.panel, 'Utility Nav: Item ' + itemIndex)
    };
    storyProps.icon = (0, _addonKnobs.select)('Header utilityNav, item' + itemIndex + ': icons', icons, item.icon, 'Utility Nav: Item ' + itemIndex);
    return storyProps;
  });
  var headerSearchProps = {
    placeholder: (0, _addonKnobs.text)('Header headerSearch: placeholder', 'Search Mass.gov', 'Header Search'),
    buttonSearch: {
      'aria-label': 'Search',
      onClick: function onClick() {
        (0, _addonActions.action)('Search button clicked');
      },
      usage: 'secondary'
    },
    onSubmit: (0, _addonActions.action)('Form submitted'),
    onChange: (0, _addonActions.action)('Text input modified')
  };
  var siteLogoProps = {
    url: {
      domain: (0, _addonKnobs.text)('Header siteLogo: url domain', 'https://www.mass.gov/', 'Site Logo')
    },
    image: {
      src: (0, _addonKnobs.text)('Header siteLogo: image src', _stateseal2.default, 'Site Logo'),
      alt: (0, _addonKnobs.text)('Header siteLogo: image alt', 'Massachusetts state seal', 'Site Logo'),
      width: (0, _addonKnobs.number)('Header siteLogo: image width', 45, 'Site Logo'),
      height: (0, _addonKnobs.number)('Header siteLogo: image height', 45, 'Site Logo')
    },
    siteName: (0, _addonKnobs.text)('Header siteLogo: siteName', 'Mass.gov', 'Site Logo'),
    title: (0, _addonKnobs.text)('Header siteLogo: title', 'Mass.gov homepage', 'Site Logo')
  };
  var headerProps = {
    utilityNav: utilityProps,
    headerSearch: _extends({}, headerSearchProps),
    mainNav: mainNavProps,
    hideHeaderSearch: (0, _addonKnobs.boolean)('hideHeaderSearch', false),
    hideBackTo: (0, _addonKnobs.boolean)('hideBackTo', true),
    siteLogo: siteLogoProps,
    searchRedirect: {
      baseUrl: (0, _addonKnobs.text)('Header searchRedirect: baseUrl', 'https://search.mass.gov'),
      searchTermParam: (0, _addonKnobs.text)('Header searchRedirect: searchTermParam', 'q'),
      queryParams: (0, _addonKnobs.object)('Header searchRedirect: queryParams', { page: '1' })
    }
  };
  return _react2.default.createElement(_index2.default, headerProps);
}, { info: _Header2.default }).add('Header without MainNav', function () {
  var utilityProps = {
    items: []
  };
  utilityProps.items = _UtilityNavKnob2.default.items.map(function (item, itemIndex) {
    var icons = {
      building: 'building',
      login: 'login'
    };
    var storyProps = {
      text: (0, _addonKnobs.text)('Header utilityNav, item' + itemIndex + ': text', item.text, 'Utility Nav: Item ' + itemIndex),
      ariaLabelText: (0, _addonKnobs.text)('Header utilityNav, item' + itemIndex + ': ariaLabelText', item.ariaLabelText, 'Utility Nav: Item ' + itemIndex),
      closeText: (0, _addonKnobs.text)('Header utilityNav, item' + itemIndex + ': closeText', item.closeText, 'Utility Nav: Item ' + itemIndex),
      panel: (0, _addonKnobs.object)('Header utilityNav, item' + itemIndex + ': panel', item.panel, 'Utility Nav: Item ' + itemIndex)
    };
    storyProps.icon = (0, _addonKnobs.select)('Header utilityNav, item' + itemIndex + ': icons', icons, item.icon, 'Utility Nav: Item ' + itemIndex);
    return storyProps;
  });
  var headerSearchProps = {
    placeholder: (0, _addonKnobs.text)('Header headerSearch: placeholder', 'Search Mass.gov', 'Header Search'),
    buttonSearch: {
      'aria-label': 'Search',
      onClick: function onClick() {
        (0, _addonActions.action)('Search button clicked');
      },
      usage: 'secondary'
    },
    onSubmit: (0, _addonActions.action)('Form submitted'),
    onChange: (0, _addonActions.action)('Text input modified')
  };
  var siteLogoProps = {
    url: {
      domain: (0, _addonKnobs.text)('Header siteLogo: url domain', 'https://www.mass.gov/', 'Site Logo')
    },
    image: {
      src: (0, _addonKnobs.text)('Header siteLogo: image src', _stateseal2.default, 'Site Logo'),
      alt: (0, _addonKnobs.text)('Header siteLogo: image alt', 'Massachusetts state seal', 'Site Logo'),
      width: (0, _addonKnobs.number)('Header siteLogo: image width', 45, 'Site Logo'),
      height: (0, _addonKnobs.number)('Header siteLogo: image height', 45, 'Site Logo')
    },
    siteName: (0, _addonKnobs.text)('Header siteLogo: siteName', 'Mass.gov', 'Site Logo'),
    title: (0, _addonKnobs.text)('Header siteLogo: title', 'Mass.gov homepage', 'Site Logo')
  };
  var headerProps = {
    utilityNav: utilityProps,
    headerSearch: _extends({}, headerSearchProps),
    hideHeaderSearch: (0, _addonKnobs.boolean)('hideHeaderSearch', false),
    hideBackTo: (0, _addonKnobs.boolean)('hideBackTo', true),
    siteLogo: siteLogoProps,
    searchRedirect: {
      baseUrl: (0, _addonKnobs.text)('Header searchRedirect: baseUrl', 'https://search.mass.gov'),
      searchTermParam: (0, _addonKnobs.text)('Header searchRedirect: searchTermParam', 'q'),
      queryParams: (0, _addonKnobs.object)('Header searchRedirect: queryParams', { page: '1' })
    }
  };
  return _react2.default.createElement(_index2.default, headerProps);
}, { info: _Header2.default }).add('Header without UtilityNav', function () {
  var mainNavProps = {
    onNavigateCallBack: (0, _addonActions.action)('onNavigateCallBack'),
    mainNav: []
  };
  mainNavProps.mainNav = _MainNavKnob2.default.mainNav.map(function (nav, navIndex) {
    var active = false;
    if (typeof nav.active === 'string') {
      active = nav.active.toLowerCase() === 'true';
    } else if (typeof nav.active === 'boolean') {
      active = nav.active;
    } else {
      active = false;
    }
    var storyProps = {
      href: (0, _addonKnobs.text)('Header mainNav, item' + navIndex + ': href', nav.href, 'Main Nav: Item ' + navIndex),
      text: (0, _addonKnobs.text)('Header mainNav, item' + navIndex + ': text', nav.text, 'Main Nav: Item ' + navIndex),
      active: (0, _addonKnobs.boolean)('Header mainNav, item' + navIndex + ': active', active, 'Main Nav: Item ' + navIndex),
      subNav: (0, _addonKnobs.object)('Header mainNav, item' + navIndex + ': subNav', nav.subNav, 'Main Nav: Item ' + navIndex)
    };
    return storyProps;
  });
  var headerSearchProps = {
    placeholder: (0, _addonKnobs.text)('Header headerSearch: placeholder', 'Search Mass.gov', 'Header Search'),
    buttonSearch: {
      'aria-label': 'Search',
      onClick: function onClick() {
        (0, _addonActions.action)('Search button clicked');
      },
      usage: 'secondary'
    },
    onSubmit: (0, _addonActions.action)('Form submitted'),
    onChange: (0, _addonActions.action)('Text input modified')
  };
  var siteLogoProps = {
    url: {
      domain: (0, _addonKnobs.text)('Header siteLogo: url domain', 'https://www.mass.gov/', 'Site Logo')
    },
    image: {
      src: (0, _addonKnobs.text)('Header siteLogo: image src', _stateseal2.default, 'Site Logo'),
      alt: (0, _addonKnobs.text)('Header siteLogo: image alt', 'Massachusetts state seal', 'Site Logo'),
      width: (0, _addonKnobs.number)('Header siteLogo: image width', 45, 'Site Logo'),
      height: (0, _addonKnobs.number)('Header siteLogo: image height', 45, 'Site Logo')
    },
    siteName: (0, _addonKnobs.text)('Header siteLogo: siteName', 'Mass.gov', 'Site Logo'),
    title: (0, _addonKnobs.text)('Header siteLogo: title', 'Mass.gov homepage', 'Site Logo')
  };
  var headerProps = {
    headerSearch: _extends({}, headerSearchProps),
    mainNav: mainNavProps,
    hideHeaderSearch: (0, _addonKnobs.boolean)('hideHeaderSearch', false),
    hideBackTo: (0, _addonKnobs.boolean)('hideBackTo', true),
    siteLogo: siteLogoProps,
    searchRedirect: {
      baseUrl: (0, _addonKnobs.text)('Header searchRedirect: baseUrl', 'https://search.mass.gov'),
      searchTermParam: (0, _addonKnobs.text)('Header searchRedirect: searchTermParam', 'q'),
      queryParams: (0, _addonKnobs.object)('Header searchRedirect: queryParams', { page: '1' })
    }
  };
  return _react2.default.createElement(_index2.default, headerProps);
}, { info: _Header2.default }).add('Header without MainNav, UtilityNav, & Search', function () {
  var headerSearchProps = {
    placeholder: (0, _addonKnobs.text)('Header headerSearch: placeholder', 'Search Mass.gov', 'Header Search'),
    buttonSearch: {
      'aria-label': 'Search',
      onClick: function onClick() {
        (0, _addonActions.action)('Search button clicked');
      },
      usage: 'secondary'
    },
    onSubmit: (0, _addonActions.action)('Form submitted'),
    onChange: (0, _addonActions.action)('Text input modified')
  };
  var siteLogoProps = {
    url: {
      domain: (0, _addonKnobs.text)('Header siteLogo: url domain', 'https://www.mass.gov/', 'Site Logo')
    },
    image: {
      src: (0, _addonKnobs.text)('Header siteLogo: image src', _stateseal2.default, 'Site Logo'),
      alt: (0, _addonKnobs.text)('Header siteLogo: image alt', 'Massachusetts state seal', 'Site Logo'),
      width: (0, _addonKnobs.number)('Header siteLogo: image width', 45, 'Site Logo'),
      height: (0, _addonKnobs.number)('Header siteLogo: image height', 45, 'Site Logo')
    },
    siteName: (0, _addonKnobs.text)('Header siteLogo: siteName', 'Mass.gov', 'Site Logo'),
    title: (0, _addonKnobs.text)('Header siteLogo: title', 'Mass.gov homepage', 'Site Logo')
  };
  var headerProps = {
    headerSearch: _extends({}, headerSearchProps),
    hideHeaderSearch: (0, _addonKnobs.boolean)('hideHeaderSearch', true),
    hideBackTo: (0, _addonKnobs.boolean)('hideBackTo', true),
    siteLogo: siteLogoProps,
    searchRedirect: {
      baseUrl: (0, _addonKnobs.text)('Header searchRedirect: baseUrl', 'https://search.mass.gov'),
      searchTermParam: (0, _addonKnobs.text)('Header searchRedirect: searchTermParam', 'q'),
      queryParams: (0, _addonKnobs.object)('Header searchRedirect: queryParams', { page: '1' })
    }
  };
  return _react2.default.createElement(_index2.default, headerProps);
}, { info: _Header2.default });