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

@use "sass:meta";
@use "sass:string";
@use "./font";
@use "./placeholder";
@use "../../settings";

/// default list of units that applying font
/// @access private
/// @type List
///
$_default-font-applying-units: (
  "icon",
  "text",
  "pict",
  "button",
  "table",
  "document",
  "input",
  "toggle",
  "select"
) !default;

/// bootstrap
/// @param {Boolean} $enable-font-applying [true] enable applying font settings or not
/// @param {Boolean} $enable-font-applying-feature-settings [true] enable applying font feature settings or not
/// @param {List} $font-applying-units [true] list of units that applying font
///
/// @deprecated
///
/// @example scss - scss inputs
///   @include mixin.bootstrap();
///
/// @example scss - scss inputs
///   @include mixin.bootstrap() {
///     // with applying additional settings to all units
///   };
///
@mixin bootstrap(
  $enable-font-applying: true,
  $enable-font-applying-feature-settings: true,
  $font-applying-units: $_default-font-applying-units
) {
  @warn "[DEPRECATED] mixin.bootstrap is deprecated. Use instead _bootstrap.scss directly.";

  // set base font size
  @if settings.$font-enable-relative-size and
    meta.type-of(settings.$font-base-size) ==
    "number"
  {
    html {
      font-size: settings.$font-base-size;
    }
  }

  // apply font settings
  @if $enable-font-applying {
    $selector: string.unique-id();

    @include placeholder.define($name: $selector) {
      @include font.apply-family($value: "default");

      @if $enable-font-applying-feature-settings {
        @include font.apply-feature-settings();
      }

      // for mobile browser
      // + https://caniuse.com/#search=text-size-adjust
      text-size-adjust: 100%;
    }

    // apply settings all units
    @if meta.type-of($font-applying-units) == "list" {
      @each $unit in $font-applying-units {
        [class^="#{settings.$prefix}-#{$unit}"],
        [class*=" #{settings.$prefix}-#{$unit}"] {
          @extend %#{$selector};

          @if meta.content-exists() {
            @content;
          }
        }
      }
    }
  }
}
