@charset "UTF-8";

// @description
// * flex-wrap mixin.
// * This mixin provides a convenient way to set the `flex-wrap` property
// * with vendor prefixes for better cross-browser compatibility.

// @access public

// @version 1.2.1

// @author Khaled Mohamed

// @license MIT

// @repository: https://github.com/Black-Axis/sass-pire

// @reference: https://developer.mozilla.org/en-US/docs/Web/CSS/flex-wrap

// @namespace main-props

// @module main-props/flex-wrap

// @dependencies:
// * - map.keys (SASS function).
// * - map.get (SASS function).
// * - LibMixin.prefixing-ms (mixin).
// * - LibFunc.is-in-list (function).
// * - Error.toggle (function).

// @param {String} $val
// * The value for the `flex-wrap` property.
// * Allowed values:
// * nowrap, wrap, wrap-reverse, "", no, yes, w, wrap-rev, w-rev, inherit.
// * Default: nowrap.

// @throws {Error}
// * Throws an error if the provided $val is not one of the
// * allowed values.

// @example
// * .example {
// *   @include flex-wrap(wrap);
// * }

// @output
// * .example {
// *   -webkit-flex-wrap: wrap;
// *   -ms-flex-wrap: wrap;
// *   flex-wrap: wrap;
// * }

// @note
// * There are two mixins in this file.
// * The first is the (flex-wrap) mixin and second is (f-w) mixin.
// * The second one is for only simplicity when using (flex-wrap) mixin.
// * The core logic of (f-w) mixin is to call the first one.
// * You can use one of them as you want.

// stylelint-disable scss/dollar-variable-empty-line-before

@use "sass:map";
@use "../../vendor-prefixes/prefix" as LibMixin;
@use "../../../functions/global/is-in-list" as LibFunc;
@use "../../../development-utils/toggle-error-message" as Error;

@mixin flex-wrap($value: nowrap) {
    $flex-wrap-values: (nowrap, wrap, wrap-reverse, "", no, yes, w, wrap-rev, w-rev, inherit) !default;

    $flex-wrap-map: (
        nowrap: nowrap,
        "": nowrap,
        no: nowrap,
        wrap: wrap,
        yes: wrap,
        w: wrap,
        wrap-reverse: wrap-reverse,
        wrap-rev: wrap-reverse,
        w-rev: wrap-reverse,
        inherit: inherit
    ) !default;

    @if LibFunc.is-in-list(map.keys($flex-wrap-map), $value) {
        // stylelint-disable-next-line scss/no-global-function-names
        $flex-wrap-value: map.get($flex-wrap-map, $value);

        @include LibMixin.prefixing-web-ms(flex-wrap, $flex-wrap-value);
    } @else {
        content: Error.throw("The parameter of flex-wrap mixin must be one of: (#{map-keys($flex-wrap-map)}).");
    }
}

@mixin f-w($value) {
    @include flex-wrap($value);
}
