from typing import Tuple
from typing import Dict


def get_calibrated_plot_fonts(fig_size: Tuple[int, int]) -> Dict[str, float]:
    """
    Takes in figure-size (tuple), and returns dictionary containing fontsizes for all other aspects
    of the plot (calculated and set appropriately, based on the figure-size).
    The fontsizes dictionary will have the following keys: `['title_size', 'label_size', 'tick_size', 'legend_label_size', 'annotation_size']`
    """
    if isinstance(fig_size, tuple):
        if len(fig_size) == 2:
            width = int(fig_size[0])
        else:
            raise ValueError (f"Invalid value for `fig_size`. Expected tuple of length 2, but got tuple of length {len(fig_size)}")
    else:
        raise TypeError(f"Invalid type for `fig_size`. Expected 'tuple' but got '{type(fig_size)}'")
    title_to_width_ratio = round((40 / 24), 3)
    labels_to_width_ratio = round((25 / 24), 3)
    ticks_to_width_ratio = round((20 / 24), 3)
    legend_labels_to_width_ratio = round((24 / 24), 3)
    annotation_to_width_ratio = round((18 / 24), 3)
    dictionary_calibrated_plot_fonts = {
        'title_size': width * title_to_width_ratio,
        'label_size': width * labels_to_width_ratio,
        'tick_size': width * ticks_to_width_ratio,
        'legend_label_size': width * legend_labels_to_width_ratio,
        'annotation_size': width * annotation_to_width_ratio,
    }
    return dictionary_calibrated_plot_fonts