@function __camel-case-compounder($result, $word, $index) {
    $word: to-lower-case($word);

    @return if($index > 1,
        $result + to-upper-case(__char-at($word, 1)) + str-slice($word, 2),
        $word);
}


@function __camel-case($arguments...) {
    $compounder: __create-compounder('__camel-case-compounder');

    @return __exec($compounder, $arguments...);
}


@function __capitalize($string) {
    $string: __base-to-string($string);
    $char: str-slice($string, 1, 1);
    $char: to-upper-case($char);
    $rest: str-slice($string, 2);
    $result: $char + $rest;

    @return if(str-length($string) > 0,
        $result,
        false);
}


@function __kebab-case-compounder($result, $word, $index: 0) {
    $pre: if($index > 1, '-', '');
    $word: to-lower-case($word);
    $result: $result + $pre + $word;

    @return $result;
}


@function __kebab-case($arguments...) {
    $compounder: __create-compounder('__kebab-case-compounder');

    @return __exec($compounder, $arguments...);
}


@function __snake-case-compounder($result, $word, $index) {
    $pre: if($index > 1, '_', '');
    $word: to-lower-case($word);
    $result: $result + $pre + $word;

    @return $result;
}


@function __snake-case($arguments...) {
    $compounder: __create-compounder('__snake-case-compounder');

    @return __exec($compounder, $arguments...);
}


@function __start-case-compounder($result, $word, $index) {
    $pre: if($index > 1, ' ', '');
    $char: __char-at($word, 1);
    $char: to-upper-case($char);
    $rest: str-slice($word, 2);
    $result: $result + $pre + $char + $rest;

    @return $result;
}


@function __start-case($arguments...) {
    $compounder: __create-compounder('__start-case-compounder');

    @return __exec($compounder, $arguments...);
}


/// Converts `$string` to camel case.
/// See [Wikipedia](https://en.wikipedia.org/wiki/CamelCase) for more details.
///
///
/// @access public
/// @group String
/// @param {string} $string [''] - The string to convert.
/// @returns {string} Returns the camel cased string.
/// @example scss
/// $foo: _camel-case('Foo Bar');
/// // => 'fooBar'
/// $foo: _camel-case('--foo-bar');
/// // => 'fooBar'
/// $foo: _camel-case('__foo_bar__');
/// // => 'fooBar'

@function _camel-case($args...) {
    @return call(get-function('__camel-case'), $args...);
}


/// Capitalizes the first character of `$string`.
///
///
/// @access public
/// @group String
/// @param {string} $string [''] - The string to capitalize.
/// @returns {string} Returns the capitalized string.
/// @example scss
/// $foo: _capitalize('fred');
/// // => 'Fred'

@function _capitalize($args...) {
    @return call(get-function('__capitalize'), $args...);
}


/// Converts `$string` to kebab case.
/// See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles) for
/// more details.
///
///
/// @access public
/// @group String
/// @param {string} $string [''] - The string to convert.
/// @returns {string} Returns the kebab cased string.
/// @example scss
/// $foo: _kebab-case('Foo Bar');
/// // => 'foo-bar'
/// $foo: _kebab-case('fooBar');
/// // => 'foo-bar'
/// $foo: _kebab-case('__foo_bar__');
/// // => 'foo-bar'

@function _kebab-case($args...) {
    @return call(get-function('__kebab-case'), $args...);
}


/// Converts `$string` to snake case.
/// See [Wikipedia](https://en.wikipedia.org/wiki/Snake_case) for more details.
///
///
/// @access public
/// @group String
/// @param {string} $string [''] - The string to convert.
/// @returns {string} Returns the snake cased string.
/// @example scss
/// $foo: _snake-case('Foo Bar');
/// // => 'foo_bar'
/// $foo: _snake-case('fooBar');
/// // => 'foo_bar'
/// $foo: _snake-case('--foo-bar');
/// // => 'foo_bar'

@function _snake-case($args...) {
    @return call(get-function('__snake-case'), $args...);
}


/// Converts `$string` to start case.
/// See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage)
/// for more details.
///
///
/// @access public
/// @group String
/// @param {string} $string [''] - The string to convert.
/// @returns {string} Returns the start cased string.
/// @example scss
/// $foo: _start-case('--foo-bar');
/// // => 'Foo Bar'
/// $foo: _start-case('fooBar');
/// // => 'Foo Bar'
/// $foo: _start-case('__foo_bar__');
/// // => 'Foo Bar'

@function _start-case($args...) {
    @return call(get-function('__start-case'), $args...);
}
