"use strict";

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

var _postcss = _interopRequireDefault(require("postcss"));

var _evaluateTailwindFunctions = _interopRequireDefault(require("../lib/evaluateTailwindFunctions"));

var _substituteScreenAtRules = _interopRequireDefault(require("../lib/substituteScreenAtRules"));

var _rewriteTailwindImports = _interopRequireDefault(require("./lib/rewriteTailwindImports"));

var _setupContext = _interopRequireDefault(require("./lib/setupContext"));

var _removeLayerAtRules = _interopRequireDefault(require("./lib/removeLayerAtRules"));

var _expandTailwindAtRules = _interopRequireDefault(require("./lib/expandTailwindAtRules"));

var _expandApplyAtRules = _interopRequireDefault(require("./lib/expandApplyAtRules"));

var _collapseAdjacentRules = _interopRequireDefault(require("./lib/collapseAdjacentRules"));

var _sharedState = require("./lib/sharedState");

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

function _default(configOrPath = {}) {
  return [_sharedState.env.DEBUG && function (root) {
    console.log('\n');
    console.time('JIT TOTAL');
    return root;
  }, function (root, result) {
    function registerDependency(fileName, type = 'dependency') {
      result.messages.push({
        type,
        plugin: 'tailwindcss-jit',
        parent: result.opts.from,
        file: fileName
      });
    }

    (0, _rewriteTailwindImports.default)(root);
    let context = (0, _setupContext.default)(configOrPath)(result, root);

    if (!_sharedState.env.TAILWIND_DISABLE_TOUCH) {
      if (context.configPath !== null) {
        registerDependency(context.configPath);
      }
    }

    return (0, _postcss.default)([(0, _removeLayerAtRules.default)(context), (0, _expandTailwindAtRules.default)(context, registerDependency), (0, _expandApplyAtRules.default)(context), (0, _evaluateTailwindFunctions.default)(context.tailwindConfig), (0, _substituteScreenAtRules.default)(context.tailwindConfig), (0, _collapseAdjacentRules.default)(context)]).process(root, {
      from: undefined
    });
  }, _sharedState.env.DEBUG && function (root) {
    console.timeEnd('JIT TOTAL');
    console.log('\n');
    return root;
  }].filter(Boolean);
}