////
/// (c) hidoo | MIT License
/// @group features
////

@use "sass:list";
@use "sass:meta";
@use "sass:map";
@use "../../settings";

/// Default options
/// @access private
/// @type Map
/// @prop {Boolean} not [false] - Deny selectors whether or not
///
$_default-options: (
  "not": false
) !default;

/// Utility for pseudo classes
/// @param {List} $selectors [()] - list of selectors
/// @param {List} $capturing-selectors [()] - capturing parent selectors
/// @param {Map} $options [()] - options
///
/// @example scss - scss inputs
///   .selector {
///     @include mixin.on((":hover", ":focus")) {
///       font-size: 16px;
///     }
///   }
///
/// @example scss - css outputs
///   .selector:where(:hover, :focus) {
///     font-size: 16px;
///   }
///
@mixin on($selectors: (), $capturing-selectors: (), $options: ()) {
  $opts: map.merge($_default-options, $options);
  $not: map.get($opts, "not");

  @if meta.type-of($selectors) == "list" and list.length($selectors) >= 1 {
    @if $not {
      $selectors: ":not(#{$selectors})";
    }

    @if meta.type-of($capturing-selectors) ==
      "list" and
      list.length($capturing-selectors) >=
      1
    {
      @at-root {
        :where(#{$capturing-selectors}):where(#{$selectors}) &,
        &:where(#{$selectors}) {
          @content;
        }
      }
    } @else {
      &:where(#{$selectors}) {
        @content;
      }
    }
  } @else {
    @if settings.$verbose {
      @warn "@mixin mixin.on: @content is not yield, because argument $selectors is empty.";
    }
  }
}
