You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.0 KiB

4 years ago
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _parseWsc = require('./parseWsc');
  6. var _parseWsc2 = _interopRequireDefault(_parseWsc);
  7. var _minifyTrbl = require('./minifyTrbl');
  8. var _minifyTrbl2 = _interopRequireDefault(_minifyTrbl);
  9. var _validateWsc = require('./validateWsc');
  10. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11. const defaults = ['medium', 'none', 'currentcolor'];
  12. exports.default = v => {
  13. const values = (0, _parseWsc2.default)(v);
  14. if (!(0, _validateWsc.isValidWsc)(values)) {
  15. return (0, _minifyTrbl2.default)(v);
  16. }
  17. const value = [...values, ''].reduceRight((prev, cur, i, arr) => {
  18. if (cur === undefined || cur.toLowerCase() === defaults[i] && (!i || (arr[i - 1] || '').toLowerCase() !== cur.toLowerCase())) {
  19. return prev;
  20. }
  21. return cur + ' ' + prev;
  22. }).trim();
  23. return (0, _minifyTrbl2.default)(value || 'none');
  24. };
  25. module.exports = exports['default'];