@charset "UTF-8";

// @description
// * dec-to-ptg function.
// * Converts a decimal value to its percentage equivalent.

// @access public

// @version 1.4.1

// @author Khaled Mohamed

// @license MIT

// @repository: https://github.com/Black-Axis/sass-pire

// @namespace converters

// @module converters/dec-to-ptg

// @dependencies:
// * - meta.type-of (SASS function).
// * - LibFunc.cut-unit (function).
// * - Error.throw (function).

// @param {Number} $ptg-value
// * The decimal value to be converted into percentage.
// * Defaults to 0.

// @throws {Error}
// * If the input is not a number.

// @example 1
// * .example {
// *   content: dec-to-ptg(0.5);
// * }

// @output 1
// * .example {
// *   content: 50%;
// * }

// @example 2
// * .example {
// *   content: dec-to-ptg();
// * }

// @output 2
// * .example {
// *   content: 0;
// * }

// @return {Number}
// * The percentage value of the input which is in decimal value.

@use "sass:meta";
@use "sass:math";
@use "../../functions/global/cut-unit" as LibFunc;
@use "../../development-utils/toggle-error-message" as Error;

@function dec-to-ptg($dec-value: 0) {
    @if meta.type-of($dec-value) != number {
        @return Error.throw("The parameter of dec-to-ptg function must be in a number type.");
    }

    @if $dec-value > 1 {
        @return Error.throw("The parameter value should be smaller than 1.");
    }

    $value-without-unit: LibFunc.cut-unit($dec-value);

    @if $dec-value == 0 {
        @return $value-without-unit;
    }

    @return ($value-without-unit * 100) + #{"%"};
}
