'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var themes = require('primevue/themes');

function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty$1(obj, key, value) { key = _toPropertyKey$1(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$1(t) { var i = _toPrimitive$1(t, "string"); return "symbol" == _typeof$1(i) ? i : i + ""; }
function _toPrimitive$1(t, r) { if ("object" != _typeof$1(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof$1(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray$1(arr); }
function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _typeof$1(o) { "@babel/helpers - typeof"; return _typeof$1 = "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$1(o); }
var sharedUtils = {
  object: {
    isEmpty: function isEmpty(value) {
      return value === null || value === undefined || value === '' || Array.isArray(value) && value.length === 0 || !(value instanceof Date) && _typeof$1(value) === 'object' && Object.keys(value).length === 0;
    },
    isNotEmpty: function isNotEmpty(value) {
      return !this.isEmpty(value);
    },
    isFunction: function isFunction(value) {
      return !!(value && value.constructor && value.call && value.apply);
    },
    isObject: function isObject(value) {
      var empty = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
      return value instanceof Object && value.constructor === Object && (empty || Object.keys(value).length !== 0);
    },
    isArray: function isArray(value) {
      var empty = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
      return Array.isArray(value) && (empty || value.length !== 0);
    },
    isString: function isString(value) {
      var empty = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
      return typeof value === 'string' && (empty || value !== '');
    },
    isNumber: function isNumber(value) {
      return !isNaN(value);
    },
    toFlatCase: function toFlatCase(str) {
      // convert snake, kebab, camel and pascal cases to flat case
      return this.isString(str) ? str.replace(/(-|_)/g, '').toLowerCase() : str;
    },
    toKebabCase: function toKebabCase(str) {
      // convert snake, camel and pascal cases to kebab case
      return this.isString(str) ? str.replace(/(_)/g, '-').replace(/[A-Z]/g, function (c, i) {
        return i === 0 ? c : '-' + c.toLowerCase();
      }).toLowerCase() : str;
    },
    toTokenKey: function toTokenKey(str) {
      return this.isString(str) ? str.replace(/[A-Z]/g, function (c, i) {
        return i === 0 ? c : '.' + c.toLowerCase();
      }).toLowerCase() : str;
    },
    merge: function merge(value1, value2) {
      if (this.isArray(value1)) {
        value1.push.apply(value1, _toConsumableArray(value2 || []));
      } else if (this.isObject(value1)) {
        Object.assign(value1, value2);
      }
    },
    mergeKeysByRegex: function mergeKeysByRegex() {
      var _this = this;
      var target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
      var regex = arguments.length > 2 ? arguments[2] : undefined;
      var mergedObj = _objectSpread({}, target);
      Object.keys(source).forEach(function (key) {
        if (_this.test(regex, key)) {
          if (_this.isObject(source[key]) && key in target && _this.isObject(target[key])) {
            mergedObj[key] = _this.mergeKeysByRegex(target[key], source[key], regex);
          } else {
            mergedObj[key] = source[key];
          }
        } else {
          mergedObj[key] = source[key];
        }
      });
      return mergedObj;
    },
    mergeKeys: function mergeKeys() {
      var _this2 = this;
      var target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
      var mergedObj = _objectSpread({}, target);
      Object.keys(source).forEach(function (key) {
        if (_this2.isObject(source[key]) && key in target && _this2.isObject(target[key])) {
          mergedObj[key] = _this2.mergeKeys(target[key], source[key]);
        } else {
          mergedObj[key] = source[key];
        }
      });
      return mergedObj;
    },
    getItemValue: function getItemValue(obj) {
      for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
        params[_key - 1] = arguments[_key];
      }
      return this.isFunction(obj) ? obj.apply(void 0, params) : obj;
    },
    getOptionValue: function getOptionValue(options) {
      var _this3 = this;
      var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
      var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
      var fKeys = this.toFlatCase(key).split('.');
      var fKey = fKeys.shift();
      return fKey ? this.isObject(options) ? this.getOptionValue(this.getItemValue(options[Object.keys(options).find(function (k) {
        return _this3.toFlatCase(k) === fKey;
      }) || ''], params), fKeys.join('.'), params) : undefined : this.getItemValue(options, params);
    },
    test: function test(regex, str) {
      if (regex) {
        var match = regex.test(str);
        regex.lastIndex = 0;
        return match;
      }
      return false;
    },
    toValue: function toValue(value) {
      // Check for Figma (value-type)
      return this.isObject(value) && value.hasOwnProperty('value') && value.hasOwnProperty('type') ? value.value : value;
    },
    toUnit: function toUnit(value) {
      var _this4 = this;
      var variable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
      var excludedProperties = ['opacity', 'z-index', 'line-height', 'font-weight', 'flex', 'flex-grow', 'flex-shrink', 'order'];
      if (!excludedProperties.some(function (property) {
        return variable.endsWith(property);
      })) {
        var val = "".concat(value).trim();
        var valArr = val.split(' ');
        return valArr.map(function (v) {
          return _this4.isNumber(v) ? "".concat(v, "px") : v;
        }).join(' ');
      }
      return value;
    },
    toNormalizePrefix: function toNormalizePrefix(prefix) {
      return prefix.replaceAll(/ /g, '').replace(/[^\w]/g, '-');
    },
    toNormalizeVariable: function toNormalizeVariable() {
      var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
      var variable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
      return this.toNormalizePrefix("".concat(this.isString(prefix, false) && this.isString(variable, false) ? "".concat(prefix, "-") : prefix).concat(variable));
    },
    getVariableName: function getVariableName() {
      var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
      var variable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
      return "--".concat(this.toNormalizeVariable(prefix, variable));
    },
    getVariableValue: function getVariableValue(value) {
      var _this5 = this;
      var variable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
      var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
      var excludedKeyRegexes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
      var fallback = arguments.length > 4 ? arguments[4] : undefined;
      if (this.isString(value)) {
        var regex = /{([^}]*)}/g;
        var val = value.trim();
        if (this.test(regex, val)) {
          var _val = val.replaceAll(regex, function (v) {
            var path = v.replace(/{|}/g, '');
            var keys = path.split('.').filter(function (_v) {
              return !excludedKeyRegexes.some(function (_r) {
                return _this5.test(_r, _v);
              });
            });
            return "var(".concat(_this5.getVariableName(prefix, _this5.toKebabCase(keys.join('-')))).concat(_this5.isNotEmpty(fallback) ? ", ".concat(fallback) : '', ")");
          });
          var calculationRegex = /(\d+\s+[\+\-\*\/]\s+\d+)/g;
          var cleanedVarRegex = /var\([^)]+\)/g;
          return this.test(calculationRegex, _val.replace(cleanedVarRegex, '0')) ? "calc(".concat(_val, ")") : _val;
        }
        return this.toUnit(val, variable);
      } else if (this.isNumber(value)) {
        return this.toUnit(value, variable);
      }
      return undefined;
    },
    getComputedValue: function getComputedValue() {
      var _this6 = this;
      var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var value = arguments.length > 1 ? arguments[1] : undefined;
      if (this.isString(value)) {
        var regex = /{([^}]*)}/g;
        var val = value.trim();
        return this.test(regex, val) ? val.replaceAll(regex, function (v) {
          return _this6.getOptionValue(obj, v.replace(/{|}/g, ''));
        }) : val;
      } else if (this.isNumber(value)) {
        return value;
      }
      return undefined;
    },
    setProperty: function setProperty(properties, key, value) {
      if (this.isString(key, false)) {
        properties.push("".concat(key, ":").concat(value, ";"));
      }
    },
    getRule: function getRule(selector, properties) {
      if (selector) {
        return "".concat(selector, "{").concat(properties, "}");
      }
      return '';
    },
    minifyCSS: function minifyCSS(css) {
      return css ? css.replace(/\/\*(?:(?!\*\/)[\s\S])*\*\/|[\r\n\t]+/g, '').replace(/ {2,}/g, ' ').replace(/ ([{:}]) /g, '$1').replace(/([;,]) /g, '$1').replace(/ !/g, '!').replace(/: /g, ':') : css;
    }
  },
  dom: {
    isClient: function isClient() {
      return !!(typeof window !== 'undefined' && window.document && window.document.createElement);
    },
    addClass: function addClass(element, className) {
      if (element && className && !this.hasClass(element, className)) {
        if (element.classList) element.classList.add(className);else element.className += ' ' + className;
      }
    },
    removeClass: function removeClass(element, className) {
      if (element && className) {
        if (element.classList) element.classList.remove(className);else element.className = element.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
      }
    },
    hasClass: function hasClass(element, className) {
      if (element) {
        if (element.classList) return element.classList.contains(className);else return new RegExp('(^| )' + className + '( |$)', 'gi').test(element.className);
      }
      return false;
    },
    removeMultipleClasses: function removeMultipleClasses(element, classNames) {
      var _this7 = this;
      if (element && classNames) {
        [classNames].flat().filter(Boolean).forEach(function (cNames) {
          return cNames.split(' ').forEach(function (className) {
            return _this7.removeClass(element, className);
          });
        });
      }
    }
  }
};

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); }
var _excluded = ["colorScheme"],
  _excluded2 = ["dark"],
  _excluded3 = ["colorScheme"],
  _excluded4 = ["dark"],
  _excluded5 = ["colorScheme"];
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
var themeUtils = {
  regex: {
    rules: {
      "class": {
        pattern: /^\.([a-zA-Z][\w-]*)$/,
        resolve: function resolve(value) {
          return {
            type: 'class',
            selector: value,
            matched: this.pattern.test(value.trim())
          };
        }
      },
      attr: {
        pattern: /^\[(.*)\]$/,
        resolve: function resolve(value) {
          return {
            type: 'attr',
            selector: ":root".concat(value),
            matched: this.pattern.test(value.trim())
          };
        }
      },
      media: {
        pattern: /^@media (.*)$/,
        resolve: function resolve(value) {
          return {
            type: 'media',
            selector: "".concat(value, "{:root{[CSS]}}"),
            matched: this.pattern.test(value.trim())
          };
        }
      },
      system: {
        pattern: /^system$/,
        resolve: function resolve(value) {
          return {
            type: 'system',
            selector: '@media (prefers-color-scheme: dark){:root{[CSS]}}',
            matched: this.pattern.test(value.trim())
          };
        }
      },
      custom: {
        resolve: function resolve(value) {
          return {
            type: 'custom',
            selector: value,
            matched: true
          };
        }
      }
    },
    resolve: function resolve(value) {
      var _this = this;
      var rules = Object.keys(this.rules).filter(function (k) {
        return k !== 'custom';
      }).map(function (r) {
        return _this.rules[r];
      });
      return [value].flat().map(function (v) {
        var _rules$map$find;
        return (_rules$map$find = rules.map(function (r) {
          return r.resolve(v);
        }).find(function (rr) {
          return rr.matched;
        })) !== null && _rules$map$find !== void 0 ? _rules$map$find : _this.rules.custom.resolve(v);
      });
    }
  },
  _toVariables: function _toVariables(theme, options) {
    return themes.toVariables(theme, {
      prefix: options === null || options === void 0 ? void 0 : options.prefix
    });
  },
  getCommon: function getCommon(_ref) {
    var _ref$name = _ref.name,
      name = _ref$name === void 0 ? '' : _ref$name,
      _ref$theme = _ref.theme,
      theme = _ref$theme === void 0 ? {} : _ref$theme;
      _ref.params;
      var set = _ref.set,
      defaults = _ref.defaults;
    var preset = theme.preset,
      options = theme.options;
    var primitive_css, semantic_css;
    if (themes.SharedUtils.object.isNotEmpty(preset)) {
      var primitive = preset.primitive,
        semantic = preset.semantic;
      var _ref2 = semantic || {},
        colorScheme = _ref2.colorScheme,
        sRest = _objectWithoutProperties(_ref2, _excluded);
      var _ref3 = colorScheme || {},
        dark = _ref3.dark,
        csRest = _objectWithoutProperties(_ref3, _excluded2);
      var prim_css = themes.SharedUtils.object.isNotEmpty(primitive) ? this._toVariables({
        primitive: primitive
      }, options).declarations : '';
      var sRest_css = themes.SharedUtils.object.isNotEmpty(sRest) ? this._toVariables({
        semantic: sRest
      }, options).declarations : '';
      var csRest_css = themes.SharedUtils.object.isNotEmpty(csRest) ? this._toVariables({
        light: csRest
      }, options).declarations : '';
      var dark_css = themes.SharedUtils.object.isNotEmpty(dark) ? this._toVariables({
        dark: dark
      }, options).declarations : '';
      primitive_css = this.transformCSS(name, prim_css, 'light', 'variable', options, set, defaults);
      var semantic_light_css = this.transformCSS(name, "".concat(sRest_css).concat(csRest_css, "color-scheme:light"), 'light', 'variable', options, set, defaults);
      var semantic_dark_css = this.transformCSS(name, "".concat(dark_css, "color-scheme:dark"), 'dark', 'variable', options, set, defaults);
      semantic_css = "".concat(semantic_light_css).concat(semantic_dark_css);
    }
    return {
      primitive: primitive_css,
      semantic: semantic_css
    };
  },
  getPreset: function getPreset(_ref4) {
    var _ref4$name = _ref4.name,
      name = _ref4$name === void 0 ? '' : _ref4$name,
      _ref4$preset = _ref4.preset,
      preset = _ref4$preset === void 0 ? {} : _ref4$preset,
      options = _ref4.options;
      _ref4.params;
      var set = _ref4.set,
      defaults = _ref4.defaults,
      selector = _ref4.selector;
    var _name = name.replace('-directive', '');
    var colorScheme = preset.colorScheme,
      vRest = _objectWithoutProperties(preset, _excluded3);
    var _ref5 = colorScheme || {},
      dark = _ref5.dark,
      csRest = _objectWithoutProperties(_ref5, _excluded4);
    var vRest_css = themes.SharedUtils.object.isNotEmpty(vRest) ? this._toVariables(_defineProperty({}, _name, vRest), options).declarations : '';
    var csRest_css = themes.SharedUtils.object.isNotEmpty(csRest) ? this._toVariables(_defineProperty({}, _name, csRest), options).declarations : '';
    var dark_css = themes.SharedUtils.object.isNotEmpty(dark) ? this._toVariables(_defineProperty({}, _name, dark), options).declarations : '';
    var light_variable_css = this.transformCSS(_name, "".concat(vRest_css).concat(csRest_css), 'light', 'variable', options, set, defaults, selector);
    var dark_variable_css = this.transformCSS(_name, dark_css, 'dark', 'variable', options, set, defaults, selector);
    return "".concat(light_variable_css).concat(dark_variable_css);
  },
  getPresetC: function getPresetC(_ref6) {
    var _preset$components;
    var _ref6$name = _ref6.name,
      name = _ref6$name === void 0 ? '' : _ref6$name,
      _ref6$theme = _ref6.theme,
      theme = _ref6$theme === void 0 ? {} : _ref6$theme,
      params = _ref6.params,
      set = _ref6.set,
      defaults = _ref6.defaults;
    var preset = theme.preset,
      options = theme.options;
    var cPreset = preset === null || preset === void 0 || (_preset$components = preset.components) === null || _preset$components === void 0 ? void 0 : _preset$components[name];
    return this.getPreset({
      name: name,
      preset: cPreset,
      options: options,
      params: params,
      set: set,
      defaults: defaults
    });
  },
  getPresetD: function getPresetD(_ref7) {
    var _preset$directives;
    var _ref7$name = _ref7.name,
      name = _ref7$name === void 0 ? '' : _ref7$name,
      _ref7$theme = _ref7.theme,
      theme = _ref7$theme === void 0 ? {} : _ref7$theme,
      params = _ref7.params,
      set = _ref7.set,
      defaults = _ref7.defaults;
    var dName = name.replace('-directive', '');
    var preset = theme.preset,
      options = theme.options;
    var dPreset = preset === null || preset === void 0 || (_preset$directives = preset.directives) === null || _preset$directives === void 0 ? void 0 : _preset$directives[dName];
    return this.getPreset({
      name: dName,
      preset: dPreset,
      options: options,
      params: params,
      set: set,
      defaults: defaults
    });
  },
  getColorSchemeOption: function getColorSchemeOption(options, defaults) {
    var _options$darkModeSele;
    return this.regex.resolve((_options$darkModeSele = options.darkModeSelector) !== null && _options$darkModeSele !== void 0 ? _options$darkModeSele : defaults.options.darkModeSelector);
  },
  getLayerOrder: function getLayerOrder(name) {
    var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
    var params = arguments.length > 2 ? arguments[2] : undefined;
    var cssLayer = options.cssLayer;
    if (cssLayer) {
      var order = themes.SharedUtils.object.getItemValue(cssLayer.order || 'primeui', params);
      return "@layer ".concat(order);
    }
    return '';
  },
  getCommonStyleSheet: function getCommonStyleSheet(_ref8) {
    var _ref8$name = _ref8.name,
      name = _ref8$name === void 0 ? '' : _ref8$name,
      _ref8$theme = _ref8.theme,
      theme = _ref8$theme === void 0 ? {} : _ref8$theme,
      params = _ref8.params,
      _ref8$props = _ref8.props,
      props = _ref8$props === void 0 ? {} : _ref8$props,
      set = _ref8.set,
      defaults = _ref8.defaults;
    var common_css = this.getCommon({
      name: name,
      theme: theme,
      params: params,
      set: set,
      defaults: defaults
    });
    var _props = Object.entries(props).reduce(function (acc, _ref9) {
      var _ref10 = _slicedToArray(_ref9, 2),
        k = _ref10[0],
        v = _ref10[1];
      return acc.push("".concat(k, "=\"").concat(v, "\"")) && acc;
    }, []).join(' ');
    return Object.entries(common_css || {}).reduce(function (acc, _ref11) {
      var _ref12 = _slicedToArray(_ref11, 2),
        key = _ref12[0],
        value = _ref12[1];
      if (value) {
        var _css = themes.SharedUtils.object.minifyCSS(value);
        var id = "".concat(key, "-variables");
        acc.push("<style type=\"text/css\" data-primevue-style-id=\"".concat(id, "\" ").concat(_props, ">").concat(_css, "</style>"));
      }
      return acc;
    }, []).join('');
  },
  getStyleSheet: function getStyleSheet(_ref13) {
    var _ref13$name = _ref13.name,
      name = _ref13$name === void 0 ? '' : _ref13$name,
      _ref13$theme = _ref13.theme,
      theme = _ref13$theme === void 0 ? {} : _ref13$theme,
      params = _ref13.params,
      _ref13$props = _ref13.props,
      props = _ref13$props === void 0 ? {} : _ref13$props,
      set = _ref13.set,
      defaults = _ref13.defaults;
    var presetC_css = this.getPresetC({
      name: name,
      theme: theme,
      params: params,
      set: set,
      defaults: defaults
    });
    var _props = Object.entries(props).reduce(function (acc, _ref14) {
      var _ref15 = _slicedToArray(_ref14, 2),
        k = _ref15[0],
        v = _ref15[1];
      return acc.push("".concat(k, "=\"").concat(v, "\"")) && acc;
    }, []).join(' ');
    return presetC_css ? "<style type=\"text/css\" data-primevue-style-id=\"".concat(name, "-variables\" ").concat(_props, ">").concat(themes.SharedUtils.object.minifyCSS(presetC_css), "</style>") : '';
  },
  createTokens: function createTokens() {
    var _this2 = this;
    var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    var defaults = arguments.length > 1 ? arguments[1] : undefined;
    var parentKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
    var parentPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
    var tokens = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
    Object.entries(obj).forEach(function (_ref16) {
      var _ref17 = _slicedToArray(_ref16, 2),
        key = _ref17[0],
        value = _ref17[1];
      var currentKey = themes.SharedUtils.object.test(defaults.variable.excludedKeyRegex, key) ? parentKey : parentKey ? "".concat(parentKey, ".").concat(themes.SharedUtils.object.toTokenKey(key)) : themes.SharedUtils.object.toTokenKey(key);
      var currentPath = parentPath ? "".concat(parentPath, ".").concat(key) : key;
      if (themes.SharedUtils.object.isObject(value)) {
        _this2.createTokens(value, defaults, currentKey, currentPath, tokens);
      } else {
        tokens[currentKey] || (tokens[currentKey] = {
          paths: [],
          computed: function computed(colorScheme) {
            var tokenPathMap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
            if (colorScheme) {
              var path = this.paths.find(function (p) {
                return p.scheme === colorScheme;
              }) || this.paths.find(function (p) {
                return p.scheme === 'none';
              });
              return path === null || path === void 0 ? void 0 : path.computed(colorScheme, tokenPathMap['binding']);
            }
            return this.paths.map(function (p) {
              return p.computed(p.scheme, tokenPathMap[p.scheme]);
            });
          }
        });
        tokens[currentKey].paths.push({
          path: currentPath,
          value: value,
          scheme: currentPath.includes('colorScheme.light') ? 'light' : currentPath.includes('colorScheme.dark') ? 'dark' : 'none',
          computed: function computed(colorScheme) {
            var _binding;
            var tokenPathMap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
            var regex = /{([^}]*)}/g;
            var computedValue = value;
            tokenPathMap['name'] = this.path;
            tokenPathMap[_binding = 'binding'] || (tokenPathMap[_binding] = {});
            if (themes.SharedUtils.object.test(regex, value)) {
              var val = value.trim();
              var _val = val.replaceAll(regex, function (v) {
                var _tokens$path;
                var path = v.replace(/{|}/g, '');
                return (_tokens$path = tokens[path]) === null || _tokens$path === void 0 || (_tokens$path = _tokens$path.computed(colorScheme, tokenPathMap)) === null || _tokens$path === void 0 ? void 0 : _tokens$path.value;
              });
              var calculationRegex = /(\d+\w*\s+[\+\-\*\/]\s+\d+\w*)/g;
              var cleanedVarRegex = /var\([^)]+\)/g;
              computedValue = themes.SharedUtils.object.test(calculationRegex, _val.replace(cleanedVarRegex, '0')) ? "calc(".concat(_val, ")") : _val;
            }
            themes.SharedUtils.object.isEmpty(tokenPathMap['binding']) && delete tokenPathMap['binding'];
            return {
              colorScheme: colorScheme,
              path: this.path,
              paths: tokenPathMap,
              value: computedValue.includes('undefined') ? undefined : computedValue
            };
          }
        });
      }
    });
    return tokens;
  },
  getTokenValue: function getTokenValue(tokens, path, defaults) {
    var _tokens$token;
    var normalizePath = function normalizePath(str) {
      var strArr = str.split('.');
      return strArr.filter(function (s) {
        return !themes.SharedUtils.object.test(defaults.variable.excludedKeyRegex, s.toLowerCase());
      }).join('.');
    };
    var token = normalizePath(path);
    var colorScheme = path.includes('colorScheme.light') ? 'light' : path.includes('colorScheme.dark') ? 'dark' : undefined;
    var computedValues = [(_tokens$token = tokens[token]) === null || _tokens$token === void 0 ? void 0 : _tokens$token.computed(colorScheme)].flat().filter(function (computed) {
      return computed;
    });
    return computedValues.length === 1 ? computedValues[0].value : computedValues.reduce(function () {
      var acc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var computed = arguments.length > 1 ? arguments[1] : undefined;
      var cs = computed.colorScheme,
        rest = _objectWithoutProperties(computed, _excluded5);
      acc[cs] = rest;
      return acc;
    }, undefined);
  },
  transformCSS: function transformCSS(name, css, mode, type) {
    var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
    var set = arguments.length > 5 ? arguments[5] : undefined;
    var defaults = arguments.length > 6 ? arguments[6] : undefined;
    var selector = arguments.length > 7 ? arguments[7] : undefined;
    if (themes.SharedUtils.object.isNotEmpty(css)) {
      var cssLayer = options.cssLayer;
      if (type !== 'style') {
        var colorSchemeOption = this.getColorSchemeOption(options, defaults);
        var _css = selector ? themes.SharedUtils.object.getRule(selector, css) : css;
        css = mode === 'dark' ? colorSchemeOption.reduce(function (acc, _ref18) {
          var _selector = _ref18.selector;
          if (themes.SharedUtils.object.isNotEmpty(_selector)) {
            acc += _selector.includes('[CSS]') ? _selector.replace('[CSS]', _css) : themes.SharedUtils.object.getRule(_selector, _css);
          }
          return acc;
        }, '') : themes.SharedUtils.object.getRule(selector !== null && selector !== void 0 ? selector : ':root', css);
      }
      if (cssLayer) {
        var layerOptions = {
          name: 'primeui',
          order: 'primeui'
        };
        themes.SharedUtils.object.isObject(cssLayer) && (layerOptions.name = themes.SharedUtils.object.getItemValue(cssLayer.name, {
          name: name,
          type: type
        }));
        if (themes.SharedUtils.object.isNotEmpty(layerOptions.name)) {
          css = themes.SharedUtils.object.getRule("@layer ".concat(layerOptions.name), css);
          set === null || set === void 0 || set.layerNames(layerOptions.name);
        }
      }
      return css;
    }
    return '';
  }
};

exports.SharedUtils = sharedUtils;
exports.ThemeUtils = themeUtils;
