"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.createTheme = void 0;
var _designTokens = require("@nordnet/design-tokens");
var _utils = require("../common/utils");
var _createLightColors = require("./createLightColors");
var _createDarkColors = require("./createDarkColors");
var breakpoints = {
  xs: {
    size: 360,
    offset: 0
  },
  sm: {
    size: 768,
    offset: 6
  },
  md: {
    size: 992,
    offset: 6
  },
  lg: {
    size: 1280,
    offset: 6
  },
  xl: {
    size: 1680,
    offset: 6
  }
};
var size = {
  xs: 360,
  sm: 768,
  md: 992,
  lg: 1280,
  xl: 1680
};
var zIndex = {
  footer: 100,
  header: 200,
  dropdown: 300,
  overlay: 400,
  modal: 500,
  overlayInModal: 600
};
var getColorTokens = function getColorTokens(theme) {
  if (theme === 'dark') return _designTokens.darkTheme;
  if (theme === 'a11y') return _designTokens.a11yTheme;
  return _designTokens.lightTheme;
};
var getBreakpointNumber = function getBreakpointNumber(s) {
  return (0, _utils.isNumber)(s) ? s : s.size;
};
var createTheme = exports.createTheme = function createTheme() {
  var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  var _config$a11yColors = config.a11yColors,
    a11yColors = _config$a11yColors === void 0 ? false : _config$a11yColors,
    _config$darkColors = config.darkColors,
    darkColors = _config$darkColors === void 0 ? false : _config$darkColors,
    _config$tokensTheme = config.tokensTheme,
    tokensTheme = _config$tokensTheme === void 0 ? 'light' : _config$tokensTheme;
  var type = a11yColors ? 'a11y' : 'default';
  var color = darkColors ? (0, _createDarkColors.createDarkColors)((0, _createDarkColors.getColorDarkScheme)(type)) : (0, _createLightColors.createLightColors)((0, _createLightColors.getColorLightScheme)(type));
  var GUTTER = 5;
  var UNIT = 4;
  var unit = function unit(times) {
    return times * UNIT;
  };
  unit.valueOf = function () {
    return UNIT;
  };
  unit.toString = function () {
    return UNIT.toString();
  };
  var spacing = {
    unit: unit,
    gutter: GUTTER
  };
  var RADIUS_XSMALL = 2;
  var RADIUS_SMALL = 4;
  var RADIUS_MEDIUM = 8;
  var RADIUS_LARGE = 20;
  var RADIUS_100 = 100;
  var borderRadius = function borderRadius(x) {
    return "".concat(x.toString(), "px");
  };
  var borderRadius2 = "".concat(RADIUS_XSMALL, "px");
  var borderRadius4 = "".concat(RADIUS_SMALL, "px");
  var borderRadius8 = "".concat(RADIUS_MEDIUM, "px");
  var borderRadius20 = "".concat(RADIUS_LARGE, "px");
  var borderRadius100 = "".concat(RADIUS_100, "px");
  return {
    animation: {
      easing: {},
      duration: {}
    },
    breakpoints: breakpoints,
    color: color,
    colorTokens: getColorTokens(tokensTheme).color,
    lightColor: (0, _createLightColors.createLightColors)((0, _createLightColors.getColorLightScheme)(type)),
    darkColor: (0, _createDarkColors.createDarkColors)((0, _createDarkColors.getColorDarkScheme)(type)),
    isHighContrastMode: a11yColors,
    isDarkMode: darkColors,
    media: {
      between: function between(s1, s2) {
        var number1 = getBreakpointNumber(s1);
        var number2 = getBreakpointNumber(s2);
        return "@media (min-width: ".concat(number1, "px) and (max-width: ").concat(number2 - 1, "px)");
      },
      greaterThan: function greaterThan(s) {
        var number = getBreakpointNumber(s);
        return "@media (min-width: ".concat(number, "px)");
      },
      lessThan: function lessThan(s) {
        var number = getBreakpointNumber(s);
        return "@media (max-width: ".concat(number - 1, "px)");
      }
    },
    size: (0, _utils.deprecate)('theme.size, please use theme.breakpoint instead.')(size),
    spacing: spacing,
    zIndex: zIndex,
    borderRadius: borderRadius,
    borderRadius2: borderRadius2,
    borderRadius4: borderRadius4,
    borderRadius8: borderRadius8,
    borderRadius20: borderRadius20,
    borderRadius100: borderRadius100
  };
};