"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.Divider = void 0;

var _style = _interopRequireDefault(require("styled-jsx/style"));

var _react = _interopRequireDefault(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _useTheme = _interopRequireDefault(require("../../hooks/useTheme"));

var _isThemePalette = _interopRequireDefault(require("../../utils/isThemePalette"));

var _jsxRuntime = require("react/jsx-runtime");

// Generated with util/create-component.js
const Divider = props => {
  const theme = (0, _useTheme.default)();
  const {
    gap = 2,
    spacing = 1,
    volume = 1,
    color = "subtext",
    direction = "horizontal",
    shape = "square",
    children,
    className,
    ...otherProps
  } = props;

  function handleValue(value) {
    return value !== null ? typeof value === "number" ? `${value * theme.layout.spacingUnit}px` : value : "0px";
  }

  function handleShape() {
    switch (shape) {
      case "round":
        return "border-radius: 1.5em;";

      case "rounded":
        return "border-radius: 0.7em;";

      case "square":
        return "border-radius: 0em;";

      default:
        return "border-radius: 0.7em;";
    }
  }

  function handleColor() {
    switch (color) {
      case "text":
        return theme.palette.text;

      case "subtext":
        return theme.palette.subtext;

      case "highlight":
        return theme.palette.highlight;

      case "background":
        return theme.palette.background;

      case "shade":
        return theme.palette.shade;

      default:
        return (0, _isThemePalette.default)(color) ? theme.palette[color][500] : color;
    }
  }

  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
    "data-testid": "Wps-Divider",
    ...otherProps,
    className: _style.default.dynamic([["841869195", [handleColor(), handleShape(), typeof volume === "number" ? `calc(${volume} * 1px)` : volume, handleValue(spacing), typeof volume === "number" ? `calc(${volume} * 1px)` : volume, handleValue(spacing), theme.palette.background, theme.palette.text, handleValue(gap), handleValue(gap)]]]) + " " + (otherProps && otherProps.className != null && otherProps.className || (0, _classnames.default)("Wps-Divider", direction, className) || ""),
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_style.default, {
      id: "841869195",
      dynamic: [handleColor(), handleShape(), typeof volume === "number" ? `calc(${volume} * 1px)` : volume, handleValue(spacing), typeof volume === "number" ? `calc(${volume} * 1px)` : volume, handleValue(spacing), theme.palette.background, theme.palette.text, handleValue(gap), handleValue(gap)],
      children: `.Wps-Divider.__jsx-style-dynamic-selector{background:${handleColor()};position:relative;${handleShape()};}.Wps-Divider.horizontal.__jsx-style-dynamic-selector{width:auto;max-width:100%;height:${typeof volume === "number" ? `calc(${volume} * 1px)` : volume};margin:${handleValue(spacing)} auto;}.Wps-Divider.vertical.__jsx-style-dynamic-selector{height:100%;max-height:100%;width:${typeof volume === "number" ? `calc(${volume} * 1px)` : volume};margin:auto ${handleValue(spacing)};}.Wps-DividerText.__jsx-style-dynamic-selector{position:absolute;left:50%;top:50%;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);transform:translate(-50%,-50%);font-size:1rem;background-color:${theme.palette.background};color:${theme.palette.text};}.Wps-DividerText.horizontal.__jsx-style-dynamic-selector{min-height:100%;padding:0 ${handleValue(gap)};}.Wps-DividerText.vertical.__jsx-style-dynamic-selector{padding:${handleValue(gap)} 0;}`
    }), children && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
      className: _style.default.dynamic([["841869195", [handleColor(), handleShape(), typeof volume === "number" ? `calc(${volume} * 1px)` : volume, handleValue(spacing), typeof volume === "number" ? `calc(${volume} * 1px)` : volume, handleValue(spacing), theme.palette.background, theme.palette.text, handleValue(gap), handleValue(gap)]]]) + " " + `Wps-DividerText ${direction}`,
      children: children
    })]
  });
};

exports.Divider = Divider;