/*
Copyright 2021 Q-CTRL. All rights reserved.

Licensed under the Q-CTRL Terms of service (the "License"). Unauthorized
copying or use of this file, via any medium, is strictly prohibited.
Proprietary and confidential. You may not use this file except in compliance
with the License. You may obtain a copy of the License at

    https://q-ctrl.com/terms

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS. See the
License for the specific language.
*/
const _ = require("lodash");

const plugin = require("tailwindcss/plugin");

const errorVariants = plugin(function ({
  addVariant,
  e
}) {
  addVariant('error', ({
    modifySelectors,
    separator
  }) => {
    modifySelectors(({
      className
    }) => {
      return `.${e(`error${separator}${className}`)}[error], .${e(`error${separator}checked${separator}${className}`)}[error]:checked, .${e(`error${separator}hover${separator}${className}`)}[error]:hover, .${e(`error${separator}focus${separator}${className}`)}[error]:focus, .${e(`error${separator}active${separator}${className}`)}[error]:active`;
    });
  });
});
const groupErrorVariants = plugin(function ({
  addVariant,
  e
}) {
  addVariant('group-error', ({
    modifySelectors,
    separator
  }) => {
    modifySelectors(({
      className
    }) => {
      return `.group[error] .${e(`group-error${separator}${className}`)}, .group[error]:checked .${e(`group-error${separator}checked${separator}${className}`)}, .group[error]:hover .${e(`group-error${separator}hover${separator}${className}`)}, .group[error]:focus .${e(`group-error${separator}focus${separator}${className}`)}, .group[error]:active .${e(`group-error${separator}active${separator}${className}`)}`;
    });
  });
});
const successVariants = plugin(function ({
  addVariant,
  e
}) {
  addVariant('success', ({
    modifySelectors,
    separator
  }) => {
    modifySelectors(({
      className
    }) => {
      return `.${e(`success${separator}${className}`)}[success], .${e(`success${separator}checked${separator}${className}`)}[success]:checked, .${e(`success${separator}hover${separator}${className}`)}[success]:hover, .${e(`success${separator}focus${separator}${className}`)}[success]:focus, .${e(`success${separator}active${separator}${className}`)}[success]:active`;
    });
  });
});
const groupSuccessVariants = plugin(function ({
  addVariant,
  e
}) {
  addVariant('group-success', ({
    modifySelectors,
    separator
  }) => {
    modifySelectors(({
      className
    }) => {
      return `.group[success] .${e(`group-success${separator}${className}`)}, .group[success]:checked .${e(`group-success${separator}checked${separator}${className}`)}, .group[success]:hover .${e(`group-success${separator}hover${separator}${className}`)}, .group[success]:focus .${e(`group-success${separator}focus${separator}${className}`)}, .group[success]:active .${e(`group-success${separator}active${separator}${className}`)}`;
    });
  });
});
module.exports = {
  errorVariants,
  groupErrorVariants,
  successVariants,
  groupSuccessVariants
};