@charset "UTF-8";

// @description
// * flex-basis mixin.
// * This mixin provides a convenient way to set the `flex-basis` property
// * with vendor prefixes for better cross-browser compatibility.

// @access public

// @version 1.4.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-basis

// @namespace main-props

// @module main-props/flex-basis

// @dependencies:
// * - meta.type-of (SASS function).
// * - math.unitless (SASS function).
// * - LibFunc1.is-in-list (function).
// * - LibFunc2.cut-unit (function).
// * - Error.throw (function).

// @param {String|Number} $val
// * The value for the `flex-basis` property.
// * Allowed values: max-content, min-content, fit-content, content,
// * inherit, auto, or a numeric value.
// * Default: auto.

// @throws {Error}
// * Throws an error if the provided $val is not one of the
// * allowed values.
// * If a numeric value is provided, it must include a unit.

// @example
// * .example {
// *   @include flex-basis(max-content);
// * }

// @output:
// * .example {
// *   -webkit-flex-basis: max-content;
// *   -ms-flex-basis: max-content;
// *   -ms-flex-preferred-size: max-content;
// *   -moz-flex-basis: max-content;
// *   -moz-box-sizing: max-content;
// *   -o-flex-basis: max-content;
// *   flex-basis: max-content;
// * }

// @note
// * There are two mixins in this file.
// * The first is the (flex-basis) mixin and second is (f-b) mixin.
// * The second one is for only simplicity when using (flex-basis) mixin.
// * The core logic of (f-b) mixin is to call the first one.
// * You can use one of them as you want.

@use "sass:meta";
@use "sass:list";
@use "sass:math";
@use "../../../functions/global" as LibFunc;
@use "../../../development-utils/toggle-error-message" as Error;

@mixin flex-basis($value: auto) {
    $flex-basis-props: (
        -webkit-flex-basis,
        -ms-flex-preferred-size,
        flex-basis
    ) !default;

    // stylelint-disable-next-line scss/dollar-variable-empty-line-before
    $flex-basis-values: (max-content, min-content, fit-content, content, inherit, auto) !default;

    @if meta.type-of($value) == string {
        @if meta.type-of($value) == string {
            @if LibFunc.is-in-list($flex-basis-values, $value) {
                @each $prop in $flex-basis-props {
                    #{$prop}: $value;
                }
            } @else {
                content: Error.throw("The parameter of flex-basis mixin must be one of: (#{$flex-basis-values}).");
            }
        }
    }

    @if meta.type-of($value) == number {
        @if $value < 0 {
            content: Error.throw("The parameter of flex-basis mixin must be greater than or equal to zero.");
        } @else {
            @each $prop in $flex-basis-props {
                #{$prop}: $value;
            }
        }
    }
}

@mixin f-b($value: auto) {
    @include flex-basis($value);
}
