@charset "UTF-8";

// @description
// * has-view-unit function.
// * It checks if the provided argument has viewport units.

// @access public

// @version 1.5.0

// @author Khaled Mohamed

// @license MIT

// @repository: https://github.com/Black-Axis/sass-pire

// @namespace type-checks

// @module type-checks/has-view-unit

// @dependencies:
// * - meta.type-of (SASS function).
// * - list.index (SASS function).
// * - math.unit (SASS function).
// * - Error.throw (function).

// @param {number} $val
// * The number to check for viewport units.

// @throws {string}
// * Throws an error if @param is not a number or param is
// * not in $viewport-units list.

// @example
// * .example {
// *   content: has-view-unit(12lvh);
// * }

// @output
// * .example {
// *   content: true;
// * }

// @returns {boolean} - Returns true if the argument has one of the
// * viewport units, otherwise false.

@use "sass:meta";
@use "sass:list";
@use "sass:math";
@use "../../development-utils/toggle-error-message" as Error;

@function has-view-unit($value) {
    @if meta.type-of($value) != number {
        @return Error.throw("The parameter of has-view-unit function must be in a number type.");
    }

    $viewport-units: (
        vw,
        svw,
        lvw,
        dvw,
        vh,
        lvh,
        dvh,
        vi,
        svi,
        lvi,
        vmin,
        svmin,
        lvmin,
        dvmin,
        vmax,
        svmax,
        lvmax,
        dvmax,
        vb,
        lvb,
        dvb
    ) !default;
    $flag: true;

    @if not list.index($viewport-units, math.unit($value)) {
        $flag: false;
    }

    @return $flag;
}
