import _taggedTemplateLiteralLoose from "@babel/runtime/helpers/taggedTemplateLiteralLoose";
import _extends from "@babel/runtime/helpers/extends";

var _templateObject;

import React from 'react';
import styled from 'styled-components';
import { useCookies, CookiesConsentEnum } from '@sentecacommerce-theme/lib';
import { Modal } from '../Common';
import { BasicConsent, AdvancedConsent, Details } from './Components';

var CookieConsent = (_ref) => {
  var {
    isEnabled,
    basic,
    advanced,
    details
  } = _ref;
  var {
    cookiesMap,
    consentTab,
    returnToBasic,
    openAdvanced,
    handleDetails,
    cookie,
    cookiesConsent,
    onSave,
    onAcceptAll,
    isChecked,
    handleToggle
  } = useCookies();
  var contentMap = {
    [CookiesConsentEnum.basic]: /*#__PURE__*/React.createElement(BasicConsent, _extends({}, basic, {
      setAdvanced: openAdvanced,
      giveConsent: onAcceptAll
    })),
    [CookiesConsentEnum.advancedProperties]: /*#__PURE__*/React.createElement(AdvancedConsent, _extends({}, advanced, {
      cookiesMap: cookiesMap,
      setDetails: handleDetails,
      handleToggle: handleToggle,
      onSave: onSave,
      onAcceptAll: onAcceptAll,
      isChecked: isChecked
    })),
    [CookiesConsentEnum.details]: /*#__PURE__*/React.createElement(Details, {
      cookie: cookie,
      cookiesMap: cookiesMap,
      labels: details.table,
      goBack: details.goBack,
      handleBack: openAdvanced
    })
  };
  var labelsMap = {
    [CookiesConsentEnum.basic]: 'Cookies',
    [CookiesConsentEnum.advancedProperties]: 'Advanced Settings'
  }; // TODO: make FixedElement component (portal) to handle the fixed position

  return /*#__PURE__*/React.createElement(Modal, {
    isCookies: true,
    open: !!isEnabled && !cookiesConsent,
    title: consentTab === CookiesConsentEnum.details ? cookie : labelsMap[consentTab],
    handleClose: returnToBasic
  }, /*#__PURE__*/React.createElement(Container, null, contentMap[consentTab]));
};

var Container = styled.div.attrs({
  className: 'd-flex flex-column container-fluid '
})(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n  line-height: 1.8rem;\n  transition: all 0.3s ease-in-out;\n  @media (min-width: ", ") {\n    position: relative;\n  }\n"])), (_ref2) => {
  var {
    theme
  } = _ref2;
  return theme.breakpoints.lg.min;
});
export { CookieConsent };
//# sourceMappingURL=cookieConsent.component.js.map