# Path: conjureup/ui/widgets/buttons.py
# class ValuedMenuSelectButton(StyledButton):
#     button_class = MenuSelectButton
#     enabled_styles = ('body', 'menu_button focus')
#     disabled_styles = ('info_context', 'disabled_button')
# 
#     def __init__(self, label, value, enabled=True, user_data=None):
#         self.value = value
#         super().__init__(label, None, enabled, user_data)


from collections.abc import Mapping, Reversible
from urwid import CheckBox, Pile, RadioButton
from conjureup.ui.widgets.buttons import ValuedMenuSelectButton
    def __init__(self, *args, **kwargs):
        self.group = []
        super().__init__(*args, **kwargs)

    def _create_option(self, label, value):
        return self.option_type(self.group, label, value)

    def select_first_option(self):
        """
        Select the first option.
        """
        for item in self.contents:
            if isinstance(item, self.option_type):
                item.set_state(True)
                break

    def select_option(self, value):
        """
        Select an option by value.
        """
        for item in self.contents:
            if isinstance(item, self.option_type):
                item.set_state(item.value == value)


class OptionalRadioList(RadioList):
    option_type = OptionalValuedRadioButton


class MenuSelectButtonList(SelectList):

# Path: conjureup/ui/widgets/buttons.py
# class ValuedMenuSelectButton(StyledButton):
#     button_class = MenuSelectButton
#     enabled_styles = ('body', 'menu_button focus')
#     disabled_styles = ('info_context', 'disabled_button')
# 
#     def __init__(self, label, value, enabled=True, user_data=None):
#         self.value = value
#         super().__init__(label, None, enabled, user_data)


# Path: conjureup/ui/widgets/selectors.py
from collections.abc import Mapping, Reversible
from urwid import CheckBox, Pile, RadioButton
from conjureup.ui.widgets.buttons import ValuedMenuSelectButton

    def __init__(self, *args, **kwargs):
        self.group = []
        super().__init__(*args, **kwargs)

    def _create_option(self, label, value):
        return self.option_type(self.group, label, value)

    def select_first_option(self):
        """
        Select the first option.
        """
        for item in self.contents:
            if isinstance(item, self.option_type):
                item.set_state(True)
                break

    def select_option(self, value):
        """
        Select an option by value.
        """
        for item in self.contents:
            if isinstance(item, self.option_type):
                item.set_state(item.value == value)


class OptionalRadioList(RadioList):
    option_type = OptionalValuedRadioButton


class MenuSelectButtonList(SelectList):

    option_type = ValuedMenuSelectButton