@charset 'UTF-8';

////
/// Flavor SCSS Mixins Cursor
/// @group mixins-cursor
/// @author blackmirror1980
////

/// Cursor modes
///
/// @access private
/// @type list
$cursor-modes: array-concat((alias, all-scroll, auto, cell, context-menu, col-resize, copy, crosshair, default, e-resize, ew-resize, grab, grabbing, help, move, n-resize, ne-resize, nesw-resize, ns-resize, nw-resize, nwse-resize, no-drop, none, not-allowed, pointer, progress, row-resize, s-resize, se-resize, sw-resize, text, vertical-text, w-resize, wait, zoom-in, zoom-out), $css-default-modes);

/// Checks if something is a correct cursor mode
///
/// @access public
/// @param {string} $c - the cursor mode or url
/// @return {boolean} - true if is cursor mode or url
@function is-cursor($c) {
  @if is-defined($c) {
    @if array-contains($cursor-modes, $c) {
      @return true;
    }

    $curl: $c;

    @if is-array($curl) {
      // in this case the cursor url contains the fallback part
      @if is-array-comma($curl) {
        $curl: array-head($curl);
      }

      // in this case the cursor url contains also the cursor icon position numbers
      @if is-array-space($curl) {
        $curl: array-head($curl);
      }
    }

    @return is-url($curl);
  }

  @return false;
}

/// Cursor mixin
///
/// @link https://www.w3schools.com/cssref/pr_class_cursor.asp W3Schools cursor docs
/// @example scss - Usage
///   .cursor-element {
///     @include cursor(pointer);
///   }
///
/// @example css - Output
///   .cursor-element {
///     cursor: pointer;
///   }
///
/// @example scss - Usage - force mode
///   .cursor-element {
///     @include cursor(pointer, true);
///   }
///
/// @example css - Output - force mode
///   .cursor-element {
///     cursor: pointer;
///   }
///
///   .cursor-element:before,
///   .cursor-element:after {
///     cursor: pointer;
///   }
///
///   .cursor-element * {
///     cursor: pointer;
///   }
///
///   .cursor-element *:before,
///   .cursor-element *:after {
///     cursor: pointer;
///   }
/// @access public
/// @param {string} $c [default] - the cursor mode
/// @param {boolean} $force [false] - if true forces the cursor mode for all the child elements and before, after pseudo selectors
/// @param {boolean} $important [false] - if true, will render the important rule
@mixin cursor($c: default, $force: false, $important: false) {
  @if is-cursor($c) {
    cursor: $c important($important);

    @if $force {
      &:before,
      &:after {
        cursor: $c important($important);
      }

      * {
        cursor: $c important($important);

        &:before,
        &:after {
          cursor: $c important($important);
        }
      }
    }
  }
  @else {
    @warn '`cursor: #{$c}` is not a valid cursor value';
  }
}

/// Pointer events modes
///
/// @access private
/// @type list
$pointer-events-modes: array-concat((all, auto, bounding-box, fill, none, painted, stroke, unset, visible, visiblefill, visiblepainted, visiblestroke), $css-default-modes);

/// Checks if something is a correct pointer-events mode
///
/// @access public
/// @param {string} $pe - the pointer-events mode
/// @return {boolean} - true if is pointer-events mode
@function is-pointer-events($pe) {
  @return is-defined($pe) and array-contains($pointer-events-modes, $pe);
}

/// Pointer events mixin
///
/// @link https://www.w3schools.com/cssref/css3_pr_pointer-events.asp W3Schools pointer-events docs
/// @example scss - Usage
///   .pointer-events-element {
///     @include pointer-events(none);
///   }
///
/// @example css - Output
///   .pointer-events-element {
///     pointer-events: none;
///   }
/// @access public
/// @param {string} $pe [auto] - the pointer events mode
/// @param {boolean} $important [false] - if true, will render the important rule
@mixin pointer-events($pe: auto, $important: false) {
  @if is-pointer-events($pe) {
    pointer-events: $pe important($important);
  }
  @else {
    @warn '`pointer-events: #{$pe}` is not a valid pointer-events value';
  }
}
