@charset "UTF-8";

// @description
// * str-to-bool function.
// * This function converts a value with string type into boolean.

// @access public

// @version 1.0.0

// @author Khaled Mohamed

// @license MIT

// @repository: https://github.com/Black-Axis/sass-pire

// @namespace converters

// @module converters/str-to-bool

// @dependencies:
// * - meta.type-of (SASS function).
// * - Error.throw (function).

// @param {String} $value
// * The value in string type to convert into boolean.

// @throw {Exception}
// * Throws exceptions if the provided parameter is not a string.
// * or the string is not "true" or "false" values.

// @example
// * .example {
// *   content: str-to-bool("false");
// * }

// @output
// * .example {
// *   content: false;
// * }

// @return {bool} - Returns the converted boolean value.
// * True if the string is "true", false otherwise.

@use "sass:meta";
@use "../../development-utils/toggle-error-message" as Error;

@function str-to-bool($value) {
    @if meta.type-of($value) != "string" {
        @return Error.throw("The parameter of str-to-bool function must be in a string type.");
    }

    $result: true;

    @if $value == "true" or $value == "false" {
        @if $value == "false" {
            $result: false;
        }
    } @else {
        @return Error.throw("The parameter of str-to-bool must be \"true\" or \"false\" in string type.");
    }

    @return $result;
}
