"use strict";

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

var _postcssRtl = _interopRequireDefault(require("postcss-rtl"));

var _postcssSelectorReplace = _interopRequireDefault(require("postcss-selector-replace"));

var _ExcludePlugin = require("./custom_postcss_loaders/ExcludePlugin");

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

// import CheckPlugin from './custom_postcss_loaders/CheckPlugin';
// console.log({ postcssRTLPlugin });
function postcssPlugins(options) {
  const {
    plugins,
    selectorReplace
  } = options.css;
  return [selectorReplace && (0, _postcssSelectorReplace.default)(selectorReplace), ...(0, _ExcludePlugin.excludeEmptyCheckPlugin)({
    enable: plugins.rtl.enable,
    exclude: plugins.rtl.exclude,
    plugins: [(0, _postcssRtl.default)({
      addPrefixToSelector: function addPrefixToSelector(selector, prefix) {
        if (prefix === '[dir]') {
          return selector;
        }

        return `${prefix} ${selector}`; // Make selectors like [dir=rtl] > .selector
      }
    })]
  })].filter(Boolean);
}