function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }

import React from "react";
import styles from "./Tab.module.css";
import getCompliedClassName from "../../utils/getCompliedClassName";
export function TabContainerLayer(props) {
  let {
    customClassName = {},
    children
  } = props;
  let tabContainerClassName = getCompliedClassName(customClassName, {
    [styles.tabContainer]: true
  }, {
    [customClassName.tabContainer]: customClassName.tabContainer
  });
  return /*#__PURE__*/React.createElement("div", {
    className: tabContainerClassName
  }, children);
}
export default function TabContainer(props) {
  let {
    children
  } = props;
  return /*#__PURE__*/React.createElement(TabContainerLayer, props, " ", children, " ");
}
export function TabContext(props) {
  return /*#__PURE__*/React.createElement(TabContainerLayer, props, " ", props.children, " ");
}
export function TabBar(props) {
  let {
    children,
    customClassName = {},
    tabListAriaProps
  } = props;
  let tabBarClassName = getCompliedClassName(customClassName, {
    [styles.tabBar]: true
  }, {
    [customClassName.tabBar]: customClassName.tabBar
  });
  return /*#__PURE__*/React.createElement("div", _extends({
    className: tabBarClassName
  }, tabListAriaProps), children);
}
export function TabBarNavLine(props) {
  let {
    children,
    customClassName = {},
    navLineRef,
    tabListAriaProps
  } = props;
  let tabBarClassName = getCompliedClassName(customClassName, {
    [styles.tabBarNavBase]: true
  }, {
    [customClassName.tabBar]: customClassName.tabBar
  });
  return /*#__PURE__*/React.createElement("div", _extends({
    className: tabBarClassName
  }, tabListAriaProps), children, /*#__PURE__*/React.createElement("div", {
    className: styles.navLine,
    ref: navLineRef
  }));
}
export function Tab(props) {
  let {
    onChange,
    children,
    disabled,
    customClassName = {},
    getRef,
    tabAriaProps,
    active,
    focusProps
  } = props;
  let tabClassName = getCompliedClassName(customClassName, {
    [styles.tab]: true && !customClassName.tab,
    [styles.tabSelect]: active && !customClassName.selected,
    [styles.tabDisabled]: !!disabled && !customClassName.disabled
  }, {
    [customClassName.tab]: !!customClassName.tab,
    [customClassName.selected]: active && !!customClassName.selected,
    [customClassName.disabled]: !!customClassName.disabled
  });
  return /*#__PURE__*/React.createElement("div", _extends({
    onClick: !disabled ? onChange : null,
    className: tabClassName,
    ref: getRef
  }, tabAriaProps, focusProps), children);
}
export function TabWithIcon(props) {
  let {
    tabCondition,
    onChange,
    selectedValue,
    value,
    children,
    customClassName = {},
    getRef
  } = props;
  let selectedTab = tabCondition(value, selectedValue);
  let tabClassName = getCompliedClassName(customClassName, {
    [styles.tab]: true,
    [styles.tabSelect]: selectedTab
  }, {
    [customClassName.tab]: customClassName.tab,
    [customClassName.selected]: selectedTab && customClassName.selected
  });
  return /*#__PURE__*/React.createElement("div", {
    onClick: onChange && onChange.bind(null, value),
    className: tabClassName,
    ref: getRef
  }, children);
}
export function TabContent(props) {
  let {
    children,
    customClassName = {}
  } = props;
  let tabContentClassName = getCompliedClassName(customClassName, {
    [styles.tabContent]: true
  }, {
    [customClassName.tabContent]: customClassName.tabContent
  });
  return /*#__PURE__*/React.createElement("div", {
    className: tabContentClassName
  }, children);
}
export function TabPanel(props) {
  let {
    selectedValue,
    value,
    tabCondition,
    children,
    customClassName = {},
    tabPanelAriaProps
  } = props;
  let selectedTab = tabCondition(value, selectedValue);
  let tabPanelClassName = getCompliedClassName(customClassName, {
    [styles.tabPanel]: true
  }, {
    [customClassName.tabPanel]: customClassName.tabPanel
  });
  return selectedTab ? /*#__PURE__*/React.createElement("div", _extends({
    className: tabPanelClassName
  }, tabPanelAriaProps), children) : null;
}