"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = require("react");
var _reactNative = require("react-native");
var _Typography = require("../Typography/Typography");
var _styles = require("./styles");
var _utils = require("../../../social/utils");
var _reactNativeSvg = require("react-native-svg");
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
const defaultTabContext = {
  variant: 'chip',
  activeTab: '',
  onChangeTab: () => {}
};
const TabContext = /*#__PURE__*/(0, _react.createContext)(defaultTabContext);
function useTabContext() {
  return (0, _react.useContext)(TabContext);
}
function Tabs({
  variant = 'chip',
  activeTab,
  onChangeTab,
  children
}) {
  return /*#__PURE__*/React.createElement(TabContext.Provider, {
    value: {
      variant,
      activeTab,
      onChangeTab
    }
  }, children);
}
function TabList({
  children,
  style,
  ...props
}) {
  const {
    styles: baseStyles
  } = (0, _styles.useStyles)();
  const styles = baseStyles;
  const {
    variant
  } = useTabContext();
  return /*#__PURE__*/React.createElement(_reactNative.View, _extends({}, props, {
    style: [styles[`${variant}TabList`], style]
  }), children);
}
function Tab({
  value,
  children,
  type = 'title',
  iconProps,
  ...props
}) {
  const {
    styles: baseStyles
  } = (0, _styles.useStyles)();
  const styles = baseStyles;
  const {
    activeTab,
    onChangeTab,
    variant
  } = useTabContext();
  const isActive = activeTab === value;
  const Label = type === 'body' ? _Typography.Typography.BodyBold : _Typography.Typography.TitleBold;
  return /*#__PURE__*/React.createElement(_reactNative.TouchableOpacity, _extends({
    activeOpacity: 0.7,
    onPress: () => onChangeTab(value),
    style: [styles[`${variant}Tab`], isActive && [styles[`active${(0, _utils.capitalize)(variant)}Tab`]]]
  }, props), variant === 'icon' ? /*#__PURE__*/React.createElement(_reactNativeSvg.SvgXml, {
    width: (iconProps === null || iconProps === void 0 ? void 0 : iconProps.width) || 24,
    height: (iconProps === null || iconProps === void 0 ? void 0 : iconProps.height) || 24,
    xml: (iconProps === null || iconProps === void 0 ? void 0 : iconProps.xml) ?? '',
    color: isActive ? styles[`active${(0, _utils.capitalize)(variant)}TabText`].color : styles[`${variant}TabText`].color
  }) : /*#__PURE__*/React.createElement(Label, {
    style: [styles[`${variant}TabText`], isActive && [styles[`active${(0, _utils.capitalize)(variant)}TabText`]]]
  }, children));
}
function TabContent({
  value,
  children
}) {
  const {
    activeTab
  } = useTabContext();
  const isActive = activeTab === value;
  return isActive ? children : null;
}
Tabs.Tab = Tab;
Tabs.List = TabList;
Tabs.Content = TabContent;
var _default = exports.default = Tabs;
//# sourceMappingURL=Tabs.js.map