import _extends from "@babel/runtime/helpers/extends";
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
import React, { useState } from 'react';
import { addStoryInGroup, COMPOSITIONS } from '../../../.storybook/utils';
import { IconBuildingSmallOutline, IconPhoneSmallOutline, IconMailSmallOutline } from '@teamleader/ui-icons';
import { Badge, Box, EmptyPassport, Passport } from '../../index';
import avatars from '../../static/data/avatar';
var contactAvatar = avatars[1].image;
var companyAvatar = avatars[2].image;
var emptyAvatar = avatars[3].image;
var contactLineItems = [{
  children: 'Dunder Miflin',
  icon: /*#__PURE__*/React.createElement(IconBuildingSmallOutline, null),
  href: '/companies.php?id=2',
  title: 'Dunder Miflin'
}, {
  children: '+1 257 689 5454',
  icon: /*#__PURE__*/React.createElement(IconPhoneSmallOutline, null),
  onClick: function onClick() {
    return console.log('Clicked on telephone number');
  },
  title: 'Dial +1 257 689 5454'
}, {
  children: 'david.brent@dundermiflin.com',
  icon: /*#__PURE__*/React.createElement(IconMailSmallOutline, null)
}];
var companyLineItems = [{
  children: '+1 257 689 5454',
  icon: /*#__PURE__*/React.createElement(IconPhoneSmallOutline, null),
  onClick: function onClick() {
    return console.log('Clicked on telephone number');
  },
  title: 'Dial +1 257 689 5454'
}, {
  children: 'david.brent@dundermiflin.com',
  icon: /*#__PURE__*/React.createElement(IconMailSmallOutline, null),
  href: 'mailto:david.brent@dundermiflin.com',
  title: 'Mail to david.brent@dundermiflin.com'
}];
export default {
  component: Passport,
  title: addStoryInGroup(COMPOSITIONS, 'Passport'),
  parameters: {
    info: {
      propTablesExclude: [Badge, Box]
    }
  }
};

var usePassportState = function usePassportState() {
  var _useState = useState(false),
      _useState2 = _slicedToArray(_useState, 2),
      active = _useState2[0],
      setActive = _useState2[1];

  var _useState3 = useState(undefined),
      _useState4 = _slicedToArray(_useState3, 2),
      anchorEl = _useState4[0],
      setAnchorEl = _useState4[1];

  var handleSetActiveClick = function handleSetActiveClick(event) {
    setAnchorEl(event.currentTarget);
    setActive(true);
  };

  var handleSetInactiveClick = function handleSetInactiveClick() {
    setActive(false);
  };

  return {
    active: active,
    anchorEl: anchorEl,
    handleButtonClick: handleSetActiveClick,
    handleCloseClick: handleSetInactiveClick
  };
};

export var contact = function contact(args) {
  var _usePassportState = usePassportState(),
      active = _usePassportState.active,
      anchorEl = _usePassportState.anchorEl,
      handleButtonClick = _usePassportState.handleButtonClick,
      handleCloseClick = _usePassportState.handleCloseClick;

  return /*#__PURE__*/React.createElement(Box, {
    display: "flex",
    justifyContent: "center"
  }, /*#__PURE__*/React.createElement(Badge, {
    onClick: handleButtonClick,
    icon: /*#__PURE__*/React.createElement(IconBuildingSmallOutline, null),
    inherit: false
  }, "David Brent"), /*#__PURE__*/React.createElement(Passport, _extends({}, args, {
    active: active,
    anchorEl: anchorEl,
    description: "Regional manager",
    onEscKeyDown: handleCloseClick,
    onOverlayClick: handleCloseClick,
    avatar: {
      imageUrl: contactAvatar,
      fullName: 'David Brent'
    },
    lineItems: contactLineItems,
    title: {
      children: 'David Brent',
      href: 'https://www.teamleader.eu'
    }
  })));
};
export var company = function company(args) {
  var _usePassportState2 = usePassportState(),
      active = _usePassportState2.active,
      anchorEl = _usePassportState2.anchorEl,
      handleButtonClick = _usePassportState2.handleButtonClick,
      handleCloseClick = _usePassportState2.handleCloseClick;

  return /*#__PURE__*/React.createElement(Box, {
    display: "flex",
    justifyContent: "center"
  }, /*#__PURE__*/React.createElement(Badge, {
    onClick: handleButtonClick,
    icon: /*#__PURE__*/React.createElement(IconBuildingSmallOutline, null),
    inherit: false
  }, "Dunder Miflin"), /*#__PURE__*/React.createElement(Passport, _extends({}, args, {
    active: active,
    anchorEl: anchorEl,
    description: ['1725 Slough Avenue', 'Sranton, PA 18540', 'United Kingdom'],
    onEscKeyDown: handleCloseClick,
    onOverlayClick: handleCloseClick,
    avatar: {
      imageUrl: companyAvatar,
      shape: 'rounded',
      fullName: 'Dunder Miflin'
    },
    lineItems: companyLineItems,
    title: "Dunder Miflin"
  })));
};
export var empty = function empty(args) {
  var _usePassportState3 = usePassportState(),
      active = _usePassportState3.active,
      anchorEl = _usePassportState3.anchorEl,
      handleButtonClick = _usePassportState3.handleButtonClick,
      handleCloseClick = _usePassportState3.handleCloseClick;

  return /*#__PURE__*/React.createElement(Box, {
    display: "flex",
    justifyContent: "center"
  }, /*#__PURE__*/React.createElement(Badge, {
    onClick: handleButtonClick,
    icon: /*#__PURE__*/React.createElement(IconBuildingSmallOutline, null),
    inherit: false
  }, "No information"), /*#__PURE__*/React.createElement(EmptyPassport, _extends({}, args, {
    active: active,
    anchorEl: anchorEl,
    link: {
      children: 'Start now',
      href: 'https://www.teamleader.eu'
    },
    description: "It looks like you haven't added any contact information yet.",
    onEscKeyDown: handleCloseClick,
    onOverlayClick: handleCloseClick,
    avatar: {
      imageUrl: emptyAvatar,
      fullName: 'No Information'
    },
    title: "No information to show"
  })));
};