"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _Text = _interopRequireDefault(require("../Typography/Text"));
var _IconButton = _interopRequireDefault(require("../IconButton/IconButton"));
var _Chip = _interopRequireDefault(require("../Chip/Chip"));
var _theming = require("../../core/theming");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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); }
const TableCell = _ref => {
  let {
    children,
    textStyle,
    style,
    align = 'left',
    text,
    caption,
    img,
    iconButton,
    chip,
    theme,
    ...rest
  } = _ref;
  let _type = null;
  if (children) return /*#__PURE__*/React.createElement(_reactNative.View, _extends({}, rest, {
    style: [styles.container, _reactNative.Platform.OS === 'web' && {
      flex: '0 auto'
    }, style]
  }), children);
  let containerStyle = {};
  let cellContent = null;
  if (text) {
    _type = 'text';
    containerStyle = {
      alignItems: align === 'left' && 'flex-start',
      flex: 1
    };
    cellContent = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Text.default, {
      numberOfLines: 1,
      style: styles.text,
      variant: "Caption"
    }, text), caption && /*#__PURE__*/React.createElement(_Text.default, {
      style: [styles.caption, {
        color: theme.colors.fg.subtle
      }],
      variant: "XSmall",
      numberOfLines: 1
    }, caption));
  } else if (img) {
    _type = 'image';
    containerStyle = {
      justifyContent: 'center',
      alignItems: 'center'
    };
    cellContent = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_reactNative.Image, _extends({
      style: styles.img
    }, img)));
  } else if (chip) {
    _type = 'chip';
    containerStyle = {
      justifyContent: 'center',
      alignItems: 'center'
    };
    cellContent = /*#__PURE__*/React.createElement(_Chip.default, chip);
  } else if (iconButton) {
    _type = 'button';
    containerStyle = {
      justifyContent: 'center',
      alignItems: 'center'
    };
    cellContent = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_IconButton.default, iconButton));
  } else {
    return null;
  }
  return /*#__PURE__*/React.createElement(_reactNative.View, _extends({}, rest, {
    style: [styles.container, _reactNative.Platform.OS === 'web' && {
      flex: '0 auto'
    }, containerStyle, style]
  }), cellContent);
};
TableCell.displayName = 'Table.Cell';
const styles = _reactNative.StyleSheet.create({
  container: {
    flexDirection: 'column',
    alignItems: 'center',
    justifyContent: 'center',
    //TODO make start instead should depend on align prop
    flex: 0,
    marginRight: 8
  },
  text: {
    fontWeight: 'bold'
  },
  caption: {
    fontWeight: 'bold'
  },
  img: {
    aspectRatio: 1,
    height: '100%',
    borderRadius: 12
  }
});
var _default = (0, _theming.withTheme)(TableCell);
exports.default = _default;
//# sourceMappingURL=TableCell.js.map