"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.FormattedNumberComponents = void 0;
var _styledComponents = _interopRequireWildcard(require("styled-components"));
var _ = require("../../..");
var _Text = require("../Text/Text");
var _FormattedInput = _interopRequireDefault(require("./FormattedInput/FormattedInput"));
var _utils = require("./utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
var calculateHeight = function calculateHeight(p, variant, size) {
  if (variant === 'quiet') return 'auto';
  return size === 's' ? "".concat(p.theme.spacing.unit(8), "px") : "".concat(p.theme.spacing.unit(10), "px");
};
var width = (0, _styledComponents.css)(["width:", "px;"], function (p) {
  return p.size === 's' ? p.theme.spacing.unit(8) : p.theme.spacing.unit(10);
});
var height = (0, _styledComponents.css)(["height:", ";"], function (p) {
  return calculateHeight(p, p.variant, p.size);
});
var background = (0, _styledComponents.css)(["background-color:", ";"], function (p) {
  if (p.disabled && p.variant !== 'quiet') {
    return p.theme.color.disabledBackground;
  }
  if (p.variant === 'quiet') {
    return 'transparent';
  }
  return p.theme.color.inputBackground;
});
var hoverBorderStyles = (0, _styledComponents.css)(["", ""], function (p) {
  return p.disabled ? '' : "\n      &:hover {\n        border-color: ".concat(p.theme.color.inputBorderHover, ";\n        z-index: 2;\n      }\n");
});
var focusBorderStyles = (0, _styledComponents.css)(["&:focus{border-color:", ";z-index:3;}"], function (p) {
  return p.theme.color.borderActive;
});
var borderStyles = (0, _styledComponents.css)(["border:1px solid ", ";position:relative;", " ", " border-width:", ";&:focus{border-width:1px;}", ""], function (p) {
  if ((0, _utils.hasError)(p.error)) return p.theme.color.inputBorderError;
  if (p.success) return p.theme.color.inputBorderSuccess;
  return p.theme.color.inputBorder;
}, hoverBorderStyles, focusBorderStyles, function (p) {
  return p.variant === 'quiet' ? '0 0 2px 0' : '1px';
}, function (p) {
  return p.disabled && p.variant === 'quiet' ? "border-color: ".concat(p.theme.isDarkMode ? p.theme.color.inputBorder : p.theme.color.buttonBackgroundDisabled, ";") : '';
});
var Wrapper = (0, _styledComponents.default)(_.Flexbox).withConfig({
  displayName: "FormattedNumberstyles__Wrapper",
  componentId: "sc-16dlxk0-0"
})(["position:relative;box-shadow:0 1px 3px ", ";"], function (p) {
  return p.theme.color.shadowInput;
});
var getPositionStyles = function getPositionStyles(p) {
  if (p.position === 'right') return "right: ".concat(p.theme.spacing.unit(2), "px;");
  if (p.position === 'left') return "left: ".concat(p.theme.spacing.unit(2), "px;");
  return '';
};
var AddonBox = (0, _styledComponents.default)(_.Flexbox).withConfig({
  displayName: "FormattedNumberstyles__AddonBox",
  componentId: "sc-16dlxk0-1"
})(["position:absolute;top:0;height:100%;z-index:3;", ""], getPositionStyles);
var Stepper = _styledComponents.default.button.attrs(function () {
  return {
    type: 'button'
  };
}).withConfig({
  displayName: "FormattedNumberstyles__Stepper",
  componentId: "sc-16dlxk0-2"
})(["", " ", " ", " ", " padding:0;cursor:pointer;box-sizing:border-box;display:flex;align-items:center;justify-content:center;flex:1 0 auto;&:first-of-type{order:-1;border-top-left-radius:", ";border-bottom-left-radius:", ";}&:last-of-type{border-top-right-radius:", ";border-bottom-right-radius:", ";}&:active:enabled{background-color:", ";svg{fill:", ";}}"], width, height, background, borderStyles, function (p) {
  return p.theme.borderRadius4;
}, function (p) {
  return p.theme.borderRadius4;
}, function (p) {
  return p.theme.borderRadius4;
}, function (p) {
  return p.theme.borderRadius4;
}, function (p) {
  return p.theme.color.cta;
}, function (p) {
  return p.theme.color.buttonText;
});
var Input = (0, _styledComponents.default)(_FormattedInput.default).attrs(function () {
  return {
    type: 'text'
  };
}).withConfig({
  displayName: "FormattedNumberstyles__Input",
  componentId: "sc-16dlxk0-3"
})(["", " ", " ", " ", " padding:", "px;width:100%;color:", ";&:disabled{color:", ";}text-align:", ";box-sizing:border-box;border-radius:", ";", " ", " ", ";"], background, borderStyles, height, _Text.placeholderNormalization, function (p) {
  return p.theme.spacing.unit(p.variant === 'quiet' ? 0 : 2);
}, function (p) {
  return p.theme.color.text;
}, function (p) {
  return p.theme.color.disabledText;
}, function (p) {
  return p.showSteppers ? 'center' : 'left';
}, function (p) {
  return p.showSteppers ? '0' : p.theme.borderRadius4;
}, function (p) {
  return p.leftAddon || p.rightAddon ? "\n      padding-top: ".concat(p.theme.spacing.unit(2), "px;\n      padding-bottom: ").concat(p.theme.spacing.unit(2), "px;\n      ") : "\n      margin: 0 -1px;\n      min-width: 0;\n      z-index: 1;\n      ";
}, function (p) {
  return p.leftAddon ? "\n      padding-left: ".concat(p.theme.spacing.unit(8), "px;\n    ") : '';
}, function (p) {
  return p.variant === 'quiet' ? "color: ".concat(p.theme.isDarkMode ? p.theme.color.buttonText : p.theme.color.backgroundBlack, ";\n        &:disabled {\n          color: ").concat(p.theme.color.disabledText, ";\n        }\n        font-size: 28px;\n        font-weight: bold;\n        &:focus {\n          border-width: 0 0 2px 0;\n          outline: none;\n        }\n        &:-webkit-autofill {\n         -webkit-text-fill-color: ").concat(p.theme.color.cta, ";\n        }\n        ") : '';
});
var FormattedNumberComponents = exports.FormattedNumberComponents = {
  AddonBox: AddonBox,
  Input: Input,
  Stepper: Stepper,
  Wrapper: Wrapper
};