"""Utility functions to access addon preferences and properties."""

from typing import TYPE_CHECKING

import bpy

from rizomuvbridge_ultimate import constants

if TYPE_CHECKING:
    from rizomuvbridge_ultimate.preferences import RizomUVBridgePreferences
    from rizomuvbridge_ultimate.properties import RizomUVBridgeUVMaps


def get_addon_prefs() -> "RizomUVBridgePreferences":
    """Access to the addon preferences.

    Returns
    -------
        RizomUVBridgePreferences: Addon preferences, saves to the Blender preferences.

    """
    return bpy.context.preferences.addons[constants.PACKAGE_NAME].preferences


def get_uvmaps_prop() -> "RizomUVBridgeUVMaps":
    """Access to the UVMaps property.

    Returns
    -------
        RizomUVBridgeUVMaps: The WindowManager UVMap property for displaying UVMap in UI.

    """
    return bpy.context.window_manager.RizomUVBridgeUVMaps
