-module(the_stars@utils). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/the_stars/utils.gleam"). -export([clamp_int/3, clamp_float/3, hex_to_int/1, int_to_hex_char/1]). -file("src/the_stars/utils.gleam", 6). -spec clamp_int(integer(), integer(), integer()) -> integer(). clamp_int(Value, Min, Max) -> _pipe = Value, _pipe@1 = gleam@int:min(_pipe, Max), gleam@int:max(_pipe@1, Min). -file("src/the_stars/utils.gleam", 12). -spec clamp_float(float(), float(), float()) -> float(). clamp_float(Value, Min, Max) -> _pipe = Value, _pipe@1 = gleam@float:min(_pipe, Max), gleam@float:max(_pipe@1, Min). -file("src/the_stars/utils.gleam", 18). -spec hex_to_int(binary()) -> {ok, integer()} | {error, nil}. hex_to_int(Value) -> Value@1 = string:uppercase(Value), case Value@1 of <<"0"/utf8>> -> {ok, 0}; <<"1"/utf8>> -> {ok, 1}; <<"2"/utf8>> -> {ok, 2}; <<"3"/utf8>> -> {ok, 3}; <<"4"/utf8>> -> {ok, 4}; <<"5"/utf8>> -> {ok, 5}; <<"6"/utf8>> -> {ok, 6}; <<"7"/utf8>> -> {ok, 7}; <<"8"/utf8>> -> {ok, 8}; <<"9"/utf8>> -> {ok, 9}; <<"A"/utf8>> -> {ok, 10}; <<"B"/utf8>> -> {ok, 11}; <<"C"/utf8>> -> {ok, 12}; <<"D"/utf8>> -> {ok, 13}; <<"E"/utf8>> -> {ok, 14}; <<"F"/utf8>> -> {ok, 15}; _ -> {error, nil} end. -file("src/the_stars/utils.gleam", 47). -spec int_to_hex_char(integer()) -> {ok, binary()} | {error, the_stars@errors:parse_error()}. int_to_hex_char(Value) -> case (Value >= 0) andalso (Value =< 15) of false -> {error, invalid_value}; true -> case Value < 10 of true -> {ok, erlang:integer_to_binary(Value)}; false -> Codepoint@1 = case begin _pipe = 65 + (Value - 10), gleam@string:utf_codepoint(_pipe) end of {ok, Codepoint} -> Codepoint; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"the_stars/utils"/utf8>>, function => <<"int_to_hex_char"/utf8>>, line => 55, value => _assert_fail, start => 1089, 'end' => 1183, pattern_start => 1100, pattern_end => 1113}) end, {ok, gleam_stdlib:utf_codepoint_list_to_string([Codepoint@1])} end end.