"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = _default;

var _lodash = _interopRequireDefault(require("lodash"));

var _nameClass = _interopRequireDefault(require("../util/nameClass"));

var _withAlphaVariable = require("../util/withAlphaVariable");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _default() {
  return function ({
    addUtilities,
    theme,
    variants
  }) {
    function safeCall(callback, defaultValue) {
      try {
        return callback();
      } catch (_error) {
        return defaultValue;
      }
    }

    const ringColorDefault = (([r, g, b]) => {
      return `rgba(${r}, ${g}, ${b}, ${theme('ringOpacity.DEFAULT', '0.5')})`;
    })(safeCall(() => (0, _withAlphaVariable.toRgba)(theme('ringColor.DEFAULT')), ['147', '197', '253']));

    const utilities = _lodash.default.fromPairs(_lodash.default.map(theme('ringWidth'), (value, modifier) => {
      return [(0, _nameClass.default)('ring', modifier), {
        '--ring-inset': 'var(--tailwind-empty,/*!*/ /*!*/)',
        '--ring-offset-width': '0px',
        '--ring-offset-color': '#fff',
        '--ring-color': ringColorDefault,
        '--ring-offset-shadow': `var(--ring-inset) 0 0 0 var(--ring-offset-width) var(--ring-offset-color)`,
        '--ring-shadow': `var(--ring-inset) 0 0 0 calc(${value} + var(--ring-offset-width)) var(--ring-color)`,
        'box-shadow': [`var(--ring-offset-shadow)`, `var(--ring-shadow)`, `var(--box-shadow, 0 0 #0000)`].join(', ')
      }];
    }));

    addUtilities([utilities, {
      '.ring-inset': {
        '--ring-inset': 'inset'
      }
    }], variants('ringWidth'));
  };
}