import { ArrowDown, ArrowUp, ChevronRight } from '@procore/core-icons/dist';
import styled, { css } from 'styled-components';
import { Card } from '../Card';
import { Checkbox } from '../Checkbox';
import { StyledDateInputDelimiter, StyledDateInputIconContainer, StyledDateInputSegment } from '../DateInput/DateInput.styles';
import { DateSelect } from '../DateSelect';
import { Input } from '../Input';
import { Select } from '../Select';
import { StyledSelectArrow, StyledSelectButtonLabel, StyledSelectClearIcon } from '../Select/Select.styles';
import { TextArea } from '../TextArea';
import { getTypographyIntent, typographyWeights } from '../Typography/Typography.styles';
import { colors } from '../_styles/colors';
import { getFocus } from '../_styles/mixins';
import { spacing } from '../_styles/spacing';
var tableBgColor = colors.white;
var tableBorderRadius = 4;
var tableBorderStyle = 'solid';
var tableBorderWidth = 1;
var tableBorderColor = colors.gray85;
var tableBorder = "".concat(tableBorderWidth, "px ").concat(tableBorderStyle, " ").concat(tableBorderColor);
var tableGroupRowBgColor = colors.gray98;
var tableGroupBodyRowIndentation = spacing.md;
var tableGroupHeaderRowIndentation = spacing.xl;
var tableHeaderBgColor = colors.gray96;
var tableHeaderBgColorHover = colors.gray94;
var tableHeaderBgColorActive = colors.gray94;
var tableHeaderBorderColor = colors.gray90;
var tableHeaderBorderRight = "".concat(tableBorderWidth, "px ").concat(tableBorderStyle, " ").concat(tableHeaderBorderColor);
var tableHeaderFontColor = colors.gray30;
var tableHeaderFontColorActive = colors.gray15;
var tableHeaderFontWeight = typographyWeights.semibold;
var tableHeaderHeight = 48;
var tableHeaderPadding = spacing.lg;
var tableSortFontColor = colors.gray70;
var tableSortFontColorHover = colors.gray45;
var tableSortFontColorActive = colors.blue50;
var tableCellTextColor = colors.gray15;
var tableCellIconColor = colors.gray45;
var tableCellInputPlaceholderColor = colors.gray70;
var tableCellInputBorder = '1px solid transparent';
var tableCellInputRowHoverBgColor = colors.gray96;
var tableCellInputFocusBgColor = colors.white;
var tableCellInputHoverBgColor = colors.blue94;
var tableCellInputFocusBorder = "1px solid ".concat(colors.blue50);
var tableCellInputErrorBgColor = colors.red98;
var tableCellInputErrorBorder = "1px solid ".concat(colors.red50);
var tableRowBorderBottom = /*#__PURE__*/css(["border-bottom:", ";&:last-child{border-bottom:0;}"], tableBorder);
export var StyledTableHeaderCellContainer = /*#__PURE__*/styled.div.withConfig({
  displayName: "StyledTableHeaderCellContainer",
  componentId: "core-11_23_1__sc-1xlaqc6-0"
})([""]);
export var StyledTableHeaderCellLabel = /*#__PURE__*/styled.div.withConfig({
  displayName: "StyledTableHeaderCellLabel",
  componentId: "core-11_23_1__sc-1xlaqc6-1"
})(["display:inline-block;flex:1 1 auto;position:relative;"]);
export var StyledCheckbox = /*#__PURE__*/styled(Checkbox).withConfig({
  displayName: "StyledCheckbox",
  componentId: "core-11_23_1__sc-1xlaqc6-2"
})([""]);
export var StyledTableBodyCell = /*#__PURE__*/styled.td.withConfig({
  displayName: "StyledTableBodyCell",
  componentId: "core-11_23_1__sc-1xlaqc6-3"
})(["position:relative;vertical-align:middle;", ""], function (_ref) {
  var $snugfit = _ref.$snugfit;
  return $snugfit && css(["white-space:nowrap;width:0.1%;"]);
});
export var StyledTableHeaderCell = /*#__PURE__*/styled.th.withConfig({
  displayName: "StyledTableHeaderCell",
  componentId: "core-11_23_1__sc-1xlaqc6-4"
})(["", " font-weight:", ";border-right:", ";color:", ";height:", "px;padding:", "px;position:relative;text-align:left;transition:background-color 0.2s ease-in-out;&:last-child{border-right:0;}", "{display:flex;align-items:center;}", " ", "{min-height:14px;}", " ", " ", " ", " ", ""], getTypographyIntent('small'), tableHeaderFontWeight, tableHeaderBorderRight, tableHeaderFontColor, tableHeaderHeight, tableHeaderPadding, StyledTableHeaderCellContainer, StyledTableHeaderCellContainer, StyledTableHeaderCellLabel, function (_ref2) {
  var $sortable = _ref2.$sortable;
  return $sortable && css(["cursor:pointer;padding:", "px;", ",", "{color:", ";opacity:0;transition:all 0.15s ease-in-out;position:absolute;}::before,::after{font-size:16px;}&:hover{background-color:", ";", "{color:", ";}}"], spacing.lg, StyledTableHeaderCellSortIconAsc, StyledTableHeaderCellSortIconDesc, tableSortFontColor, tableHeaderBgColorHover, StyledTableHeaderCellSortIconAsc, tableSortFontColorHover);
}, function (_ref3) {
  var $variant = _ref3.$variant;
  return ($variant === 'asc' || $variant === 'desc') && css(["background-color:", ";color:", ";&::before,&::after,", ",", "{opacity:1;}"], tableHeaderBgColorActive, tableHeaderFontColorActive, StyledTableHeaderCellSortIconAsc, StyledTableHeaderCellSortIconDesc);
}, function (_ref4) {
  var $variant = _ref4.$variant;
  return $variant === 'asc' && css(["", ",&::before{color:", ";}&:hover{", ",&::before{color:", ";}", ",&::after{color:", ";}}"], StyledTableHeaderCellSortIconAsc, tableSortFontColorActive, StyledTableHeaderCellSortIconAsc, tableSortFontColorActive, StyledTableHeaderCellSortIconDesc, tableSortFontColorHover);
}, function (_ref5) {
  var $variant = _ref5.$variant;
  return $variant === 'desc' && css(["", ",&::after{color:", ";}&:hover{", ",&::before{color:", ";}", ",&::after{color:", ";}}"], StyledTableHeaderCellSortIconDesc, tableSortFontColorActive, StyledTableHeaderCellSortIconAsc, tableSortFontColorHover, StyledTableHeaderCellSortIconDesc, tableSortFontColorActive);
}, function (_ref6) {
  var $variant = _ref6.$variant,
    $snugfit = _ref6.$snugfit;
  return ($variant === 'snugfit' || $snugfit) && css(["width:0.1%;"]);
});
export var StyledTableHeaderCellIconWrapper = /*#__PURE__*/styled.div.withConfig({
  displayName: "StyledTableHeaderCellIconWrapper",
  componentId: "core-11_23_1__sc-1xlaqc6-5"
})(["height:20px;line-height:20px;padding:0 ", "px 0 ", "px;width:20px;"], spacing.lg, spacing.sm);
export var StyledTableHeaderCellSortIconAsc = /*#__PURE__*/styled(ArrowUp).withConfig({
  displayName: "StyledTableHeaderCellSortIconAsc",
  componentId: "core-11_23_1__sc-1xlaqc6-6"
})([""]);
export var StyledTableHeaderCellSortIconDesc = /*#__PURE__*/styled(ArrowDown).withConfig({
  displayName: "StyledTableHeaderCellSortIconDesc",
  componentId: "core-11_23_1__sc-1xlaqc6-7"
})([""]);
export var StyledHead = /*#__PURE__*/styled.thead.withConfig({
  displayName: "StyledHead",
  componentId: "core-11_23_1__sc-1xlaqc6-8"
})(["background-color:", ";transition:background-color 0.2s ease-in-out;", " &:hover{", "{", ",", "{&::after,&::before{opacity:1;}}}}"], tableHeaderBgColor, tableRowBorderBottom, StyledTableHeaderCell, StyledTableHeaderCellSortIconAsc, StyledTableHeaderCellSortIconDesc);
export var StyledCaratWrapper = /*#__PURE__*/styled.div.withConfig({
  displayName: "StyledCaratWrapper",
  componentId: "core-11_23_1__sc-1xlaqc6-9"
})(["font-size:16px;color:", ";padding-right:", "px;transition:all 0.2s ease-in-out;& + ", "{margin:0 ", "px;}"], colors.gray70, spacing.xs, StyledCheckbox, spacing.xs);
export var StyledCarat = /*#__PURE__*/styled(ChevronRight).withConfig({
  displayName: "StyledCarat",
  componentId: "core-11_23_1__sc-1xlaqc6-10"
})(["", ""], function (_ref7) {
  var $expanded = _ref7.$expanded;
  return $expanded && css(["transform:rotate(90deg);"]);
});
var cellInputCSS = /*#__PURE__*/css(["background-color:rgba(255,255,255,0);&&&{border:", ";border-radius:4px;width:100%;&::placeholder{color:", ";}&::-ms-clear{display:none;}&:hover{border-color:transparent;}&:focus{background-color:", ";border-style:solid;border-width:1px;border-color:", ";box-shadow:0 0 0 1px ", ";outline:none;}&:disabled{border:", ";color:", ";}}"], tableCellInputBorder, tableCellInputPlaceholderColor, colors.white, colors.blue40, colors.blue40, tableCellInputBorder, colors.gray70);
export var StyledTableCellSelect = /*#__PURE__*/styled(Select).withConfig({
  displayName: "StyledTableCellSelect",
  componentId: "core-11_23_1__sc-1xlaqc6-11"
})(["", ";background-color:transparent;border-color:transparent;height:auto;&:hover{background-color:transparent;}&:active:hover{border-color:", ";}&:focus{background-color:", ";cursor:pointer;", " ", "{white-space:nowrap;}", "{opacity:1;pointer-events:all;}", " ", "}", "{white-space:normal;}", ",", "{opacity:0;pointer-events:none;}", " ", ""], cellInputCSS, colors.gray85, colors.white, getFocus(), StyledSelectButtonLabel, StyledSelectArrow, function (_ref8) {
  var $hasClearIcon = _ref8.$hasClearIcon;
  return $hasClearIcon && css(["", "{opacity:1;pointer-events:all;}"], StyledSelectClearIcon);
}, function (_ref9) {
  var _ref9$$placeholder = _ref9.$placeholder,
    $placeholder = _ref9$$placeholder === void 0 ? false : _ref9$$placeholder;
  return $placeholder && css(["", "{opacity:1;pointer-events:all;}"], StyledSelectButtonLabel);
}, StyledSelectButtonLabel, StyledSelectArrow, StyledSelectClearIcon, function (_ref10) {
  var _ref10$$placeholder = _ref10.$placeholder,
    $placeholder = _ref10$$placeholder === void 0 ? false : _ref10$$placeholder;
  return $placeholder && css(["", "{opacity:0;pointer-events:none;}"], StyledSelectButtonLabel);
}, function (_ref11) {
  var loading = _ref11.loading;
  return loading && css(["background-color:", ";border-color:", ";", "{white-space:nowrap;}"], colors.white, colors.gray85, StyledSelectButtonLabel);
});
export var StyledTableCellInput = /*#__PURE__*/styled(Input).withConfig({
  displayName: "StyledTableCellInput",
  componentId: "core-11_23_1__sc-1xlaqc6-12"
})(["", ""], cellInputCSS);
export var StyledTableCellDateInput = /*#__PURE__*/styled(DateSelect).withConfig({
  displayName: "StyledTableCellDateInput",
  componentId: "core-11_23_1__sc-1xlaqc6-13"
})(["background-color:transparent;border-color:transparent;&:active:hover{border-color:", ";}&&&:focus-within{", ";background-color:", ";}", " ", "{opacity:0;}", "{&[data-qa-table-visible='false']{opacity:0;}}", "{&[data-placeholder='true']{opacity:0;}}&:focus-within{", "{opacity:1;}", "{&[data-qa-table-visible='false']{opacity:1;}}", "{&[data-placeholder='true']{opacity:1;}}}"], colors.gray45, getFocus(), colors.white, function (_ref12) {
  var error = _ref12.error;
  return error && css(["border-color:", ";"], colors.red50);
}, StyledDateInputIconContainer, StyledDateInputDelimiter, StyledDateInputSegment, StyledDateInputIconContainer, StyledDateInputDelimiter, StyledDateInputSegment);
export var StyledTableCellTextArea = /*#__PURE__*/styled(TextArea).withConfig({
  displayName: "StyledTableCellTextArea",
  componentId: "core-11_23_1__sc-1xlaqc6-14"
})(["", " &&{height:", "px;min-height:", "px;overflow:hidden;padding-top:", "px;resize:none;width:100%;", "}"], cellInputCSS, spacing.xxl, spacing.xxl, spacing.xs, function (_ref13) {
  var $resizable = _ref13.$resizable;
  return $resizable && css(["&:focus{min-height:64px;overflow:auto;resize:vertical;}"]);
});
export var StyledTableCellText = /*#__PURE__*/styled.div.withConfig({
  displayName: "StyledTableCellText",
  componentId: "core-11_23_1__sc-1xlaqc6-15"
})(["margin:", "px;display:flex;color:", ";", ""], spacing.lg, tableCellTextColor, function (_ref14) {
  var $percent = _ref14.$percent,
    $currency = _ref14.$currency;
  return ($percent || $currency) && css(["justify-content:flex-end;"]);
});
export var StyledIconCell = /*#__PURE__*/styled.div.withConfig({
  displayName: "StyledIconCell",
  componentId: "core-11_23_1__sc-1xlaqc6-16"
})(["display:flex;color:", ";"], tableCellIconColor);
export var StyledSelectCellWrapper = /*#__PURE__*/styled.div.withConfig({
  displayName: "StyledSelectCellWrapper",
  componentId: "core-11_23_1__sc-1xlaqc6-17"
})(["display:flex;flex-direction:column;"]);
export var StyledTableInlineEditErrorBox = /*#__PURE__*/styled.div.withConfig({
  displayName: "StyledTableInlineEditErrorBox",
  componentId: "core-11_23_1__sc-1xlaqc6-18"
})(["", " color:", ";font-style:italic;background:", ";border-radius:0 2px 2px 2px;box-shadow:0 1px 2px rgba(0,0,0,0.2),0 1px 3px rgba(0,0,0,0.1);padding:6px ", "px;position:absolute;max-width:160px;z-index:1;", ""], getTypographyIntent('small'), colors.white, colors.red50, spacing.md, function (_ref15) {
  var $size = _ref15.$size;
  var sizes = {
    xs: 36,
    sm: 48,
    md: 80,
    lg: 112,
    block: null,
    xl: null
  };
  if (!$size || !sizes[$size]) {
    return '';
  }
  return css(["min-width:", "px;"], sizes[$size]);
});
export var StyledTableInlineEditContainer = /*#__PURE__*/styled.div.withConfig({
  displayName: "StyledTableInlineEditContainer",
  componentId: "core-11_23_1__sc-1xlaqc6-19"
})(["background-color:", ";margin:", "px ", "px;position:relative;", " ", ""], tableBgColor, spacing.sm, spacing.xs, function (_ref16) {
  var $error = _ref16.$error;
  return $error && css(["position:static;background-color:", ";", ",", ",", ",", "{border:", ";border-radius:4px 4px 0 0;border-bottom:none;&:hover{border-bottom:none;}&:focus{background-color:", ";border:", ";border-bottom:none;}}"], tableCellInputErrorBgColor, StyledTableCellDateInput, StyledTableCellInput, StyledTableCellSelect, StyledTableCellTextArea, tableCellInputErrorBorder, tableCellInputFocusBgColor, tableCellInputFocusBorder);
}, function (_ref17) {
  var $size = _ref17.$size;
  var sizes = {
    xs: 36,
    sm: 48,
    md: 80,
    lg: 112,
    block: null,
    xl: null
  };
  if ($size === 'block') {
    return css(["position:relative;", "{width:100%;max-width:100%;}"], StyledTableInlineEditErrorBox);
  }
  if (!$size || !sizes[$size]) {
    return '';
  }
  return css(["width:", "px;"], sizes[$size]);
});
export var StyledTableBodyRow = /*#__PURE__*/styled.tr.withConfig({
  displayName: "StyledTableBodyRow",
  componentId: "core-11_23_1__sc-1xlaqc6-20"
})(["", " ", " &:focus-within{", "{background-color:", ";&.disabled{background-color:transparent;}}", ".error{background-color:", ";}}&:hover{", "{background-color:", ";cursor:pointer;&:hover{background-color:", ";}&.disabled{&,&:hover{background-color:transparent;cursor:default;}}}", ".error{background-color:", ";&:hover{background-color:", ";}", ",", ",", "{border:", ";border-bottom:none;&:hover{border-bottom:none;}&:focus{border:", ";border-bottom:none;}}}}"], tableRowBorderBottom, function (_ref18) {
  var $overdue = _ref18.$overdue;
  return $overdue && css(["", ",", ",", ",", ",", "{color:", ";}"], StyledTableCellText, StyledTableCellSelect, StyledTableCellInput, StyledTableCellDateInput, StyledTableCellTextArea, colors.red50);
}, StyledTableInlineEditContainer, tableCellInputRowHoverBgColor, StyledTableInlineEditContainer, tableCellInputErrorBgColor, StyledTableInlineEditContainer, tableCellInputRowHoverBgColor, tableCellInputHoverBgColor, StyledTableInlineEditContainer, tableCellInputErrorBgColor, tableCellInputErrorBgColor, StyledTableCellInput, StyledTableCellSelect, StyledTableCellTextArea, tableCellInputErrorBorder, tableCellInputFocusBorder);
export var StyledTableGroupRowContent = /*#__PURE__*/styled.div.withConfig({
  displayName: "StyledTableGroupRowContent",
  componentId: "core-11_23_1__sc-1xlaqc6-21"
})([""]);
export var StyledTableGroupRowHeader = /*#__PURE__*/styled.div.withConfig({
  displayName: "StyledTableGroupRowHeader",
  componentId: "core-11_23_1__sc-1xlaqc6-22"
})([""]);
export var StyledTableGroupRowTitle = /*#__PURE__*/styled.span.withConfig({
  displayName: "StyledTableGroupRowTitle",
  componentId: "core-11_23_1__sc-1xlaqc6-23"
})([""]);
export var StyledTableGroupRow = /*#__PURE__*/styled.tr.withConfig({
  displayName: "StyledTableGroupRow",
  componentId: "core-11_23_1__sc-1xlaqc6-24"
})(["background-color:", ";", " ", "{margin-left:", "px;padding:", "px 0;display:flex;flex-direction:row;}", "{display:flex;align-items:center;}", "{font-weight:", ";padding-left:", "px;}", ""], tableGroupRowBgColor, tableRowBorderBottom, StyledTableGroupRowContent, spacing.lg, spacing.lg, StyledTableGroupRowHeader, StyledTableGroupRowTitle, tableHeaderFontWeight, spacing.lg, function (_ref19) {
  var $depth = _ref19.$depth;
  if (typeof $depth !== 'number') {
    return '';
  }
  return css(["> td{padding-left:", "px !important;}~ ", "{> td:first-child{padding-left:", "px !important;}}"], $depth * tableGroupHeaderRowIndentation, StyledTableBodyRow, ($depth + 1) * tableGroupHeaderRowIndentation + tableGroupBodyRowIndentation);
});
export var StyledTableWrapper = /*#__PURE__*/styled(Card).withConfig({
  displayName: "StyledTableWrapper",
  componentId: "core-11_23_1__sc-1xlaqc6-25"
})(["border-radius:", "px;border:", ";", ",tbody{&:first-child{tr:first-child{", ",td{&:first-child{border-top-left-radius:", "px;}&:last-child{border-top-right-radius:", "px;}}}}&:last-child{tr:last-child{", ",td{&:first-child{border-bottom-left-radius:", "px;}&:last-child{border-bottom-right-radius:", "px;}}}}}", ""], tableBorderRadius, tableBorder, StyledHead, StyledTableHeaderCell, tableBorderRadius, tableBorderRadius, StyledTableHeaderCell, tableBorderRadius, tableBorderRadius, function (_ref20) {
  var $withShelf = _ref20.$withShelf;
  return $withShelf && css(["position:relative;height:100%;"]);
});
var BodyRow = StyledTableBodyRow;
var GroupRow = StyledTableGroupRow;
export var StyledTable = /*#__PURE__*/styled.table.withConfig({
  displayName: "StyledTable",
  componentId: "core-11_23_1__sc-1xlaqc6-26"
})(["background-color:", ";border-collapse:collapse;border-radius:", "px;", " width:100%;td:first-child ", "{padding-left:", "px;}", " ", " + ", "{margin-left:", "px;padding-left:0;}", " ", " ", " + ", " > td{padding-left:", "px;}", " + ", " + ", " > td{padding-left:", "px;}", " + ", " + ", " + ", " > td{padding-left:", "px;}", " + ", " + ", " + ", " + ", " > td{padding-left:", "px;}", " ~ ", "{", "{padding-left:0;margin:0 ", "px;}& > td:first-child{padding-left:", "px;}}", " + ", " ~ ", "{& > td:first-child{padding-left:", "px;}}", " + ", " + ", " ~ ", "{& > td:first-child{padding-left:", "px;}}", " + ", " + ", " + ", " ~ ", "{& > td:first-child{padding-left:", "px;}}", " + ", " + ", " + ", " + ", " ~ ", "{& > td:first-child{padding-left:", "px;}}"], tableBgColor, tableBorderRadius, getTypographyIntent('body'), StyledCheckbox, spacing.lg, StyledTableGroupRow, StyledCaratWrapper, StyledCheckbox, spacing.xs, function (_ref21) {
  var $fixed = _ref21.$fixed;
  return $fixed && css(["table-layout:fixed;"]);
}, function (_ref22) {
  var $inline = _ref22.$inline;
  return $inline && css(["border-top:1px solid ", ";border-bottom:1px solid ", ";"], colors.gray85, colors.gray85);
}, GroupRow, GroupRow, tableGroupHeaderRowIndentation, GroupRow, GroupRow, GroupRow, 2 * tableGroupHeaderRowIndentation, GroupRow, GroupRow, GroupRow, GroupRow, 3 * tableGroupHeaderRowIndentation, GroupRow, GroupRow, GroupRow, GroupRow, GroupRow, 4 * tableGroupHeaderRowIndentation, GroupRow, BodyRow, StyledCheckbox, spacing.xs, tableGroupHeaderRowIndentation + tableGroupBodyRowIndentation, GroupRow, GroupRow, BodyRow, 2 * tableGroupHeaderRowIndentation + tableGroupBodyRowIndentation, GroupRow, GroupRow, GroupRow, BodyRow, 3 * tableGroupHeaderRowIndentation + tableGroupBodyRowIndentation, GroupRow, GroupRow, GroupRow, GroupRow, BodyRow, 4 * tableGroupHeaderRowIndentation + tableGroupBodyRowIndentation, GroupRow, GroupRow, GroupRow, GroupRow, GroupRow, BodyRow, 5 * tableGroupHeaderRowIndentation + tableGroupBodyRowIndentation);
export var StyledLoadingContainer = /*#__PURE__*/styled.div.withConfig({
  displayName: "StyledLoadingContainer",
  componentId: "core-11_23_1__sc-1xlaqc6-27"
})(["cursor:default;align-items:center;background:", ";display:flex;height:100%;justify-content:center;opacity:0.9;position:absolute;width:100%;z-index:2;"], colors.gray96);
//# sourceMappingURL=Table.styles.js.map