import json
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from aiogram.utils.i18n import gettext as _
from aiogram.utils.keyboard import InlineKeyboardBuilder
from utils.helpers import iso2_to_flag
from keyboards.pagination import Pagination, PaginationISP
from handlers.user import proxy_api


def start_menu() -> InlineKeyboardMarkup:
    markup = InlineKeyboardMarkup(inline_keyboard=[
        [
            InlineKeyboardButton(text= _('keyboards.start_menu.control_panel'), callback_data='control_panel')
        ],
        [
            InlineKeyboardButton(text=_('keyboards.start_menu.buy_proxies'), callback_data='buy_proxies')
        ],
        [
            InlineKeyboardButton(text=_('keyboards.start_menu.change_lang'), callback_data='change_lang'),
            InlineKeyboardButton(text=_('keyboards.start_menu.activate_promo'), callback_data='activate_promo')
        ],
        [
            InlineKeyboardButton(text=_('keyboards.start_menu.referral'), callback_data='my_referral')
        ]
    ])
    return markup

def back_menu() -> InlineKeyboardMarkup:
    markup = InlineKeyboardMarkup(inline_keyboard=[
        [
            InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data='back')
        ]
    ])
    return markup

def back_panel_menu(subscribe_id: int) -> InlineKeyboardMarkup:
    markup = InlineKeyboardMarkup(inline_keyboard=[
        [
            InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data=f'plan_{subscribe_id}')
        ]
    ])
    return markup

def switch_language_menu(language: str) -> InlineKeyboardMarkup:
    inline_list = []

    if language == 'en':
        inline_list.append([
            InlineKeyboardButton(text= _('keyboards.switch_language.lang').format(lang_code="Russian"), callback_data='switch_lang_ru')
        ])

    if language == 'ru':
        inline_list.append(        [
            InlineKeyboardButton(text= _('keyboards.switch_language.lang').format(lang_code='Английский'), callback_data='switch_lang_en')
        ])

    inline_list.append([
            InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data='back')
    ])
    markup = InlineKeyboardMarkup(inline_keyboard=inline_list)
    return markup


def products_category_menu(data_products: dict) -> InlineKeyboardMarkup:
    inline_list = []

    for product in data_products:
        inline_list.append([InlineKeyboardButton(text=product["name"], callback_data='product_{}'.format(product["id"]))])

    inline_list.append([
            InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data='back')
    ])

    markup = InlineKeyboardMarkup(inline_keyboard=inline_list)
    return markup

def variants_category_menu(data_variants: dict, custom: bool = True) -> InlineKeyboardMarkup:
    builder = InlineKeyboardBuilder()

    for variant in data_variants:
        if 'шт' in variant['name']:
            variant = dict(variant)
            variant['name'] = variant['name'].replace('шт', _('keyboards.sht'))
        builder.add(InlineKeyboardButton(text=f'{variant["name"]} - {variant["price"]}$', callback_data='variant_{}'.format(variant["id"])))

    builder.adjust(3)

    if custom:
        builder.row(InlineKeyboardButton(text= _('keyboards.custom.proxy'), callback_data=f'custom_{data_variants[1]["product_id"]}'))

    builder.row(InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data='back'))
    return builder.as_markup()

def variants_ipv_category_menu(data_variants: dict) -> InlineKeyboardMarkup:
    builder = InlineKeyboardBuilder()
    sorted_variants = sorted(data_variants, key=lambda x: (x["name"].split(" ")[0], json.loads(x["attributes"]).get("plan")))
    column_1 = [variant for variant in sorted_variants if "30MBPS" in variant["name"] or "60MBPS" in variant["name"]]
    column_2 = [variant for variant in sorted_variants if "200MBPS" in variant["name"] or "120MBPS" in variant["name"]]

    max_rows = max(len(column_1), len(column_2))
    for i in range(max_rows):
        left_button = (
            InlineKeyboardButton(
                text=f'{column_1[i]["name"]} - {column_1[i]["price"]}$',
                callback_data=f'variant_{column_1[i]["id"]}'
            ) if i < len(column_2) else None
        )
        right_button = (
            InlineKeyboardButton(
                text=f'{column_2[i]["name"]} - {column_2[i]["price"]}$',
                callback_data=f'variant_{column_2[i]["id"]}'
            ) if i < len(column_1) else None
        )
        row = [btn for btn in (left_button, right_button) if btn]
        builder.row(*row)

    builder.row(InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data='back'))
    return builder.as_markup()

def payments_systems_menu(order_id: int, payments_systems: list) -> InlineKeyboardMarkup:
    builder = InlineKeyboardBuilder()

    if len(payments_systems) == 0:
        builder.add(InlineKeyboardButton(text= _('keyboards.payments_system.notfound'), callback_data='empty'))

    for payment in payments_systems:
        if payment["system"] == "heleket":
            builder.add(InlineKeyboardButton(text='♦️Heleket♦️', callback_data=f'payment_{order_id}_heleket'))
        if payment["system"] == "CrystalPAY":
            builder.add(InlineKeyboardButton(text='💎CrystalPAY💎', callback_data=f'payment_{order_id}_crystalpay'))

    builder.adjust(2)
    builder.row(InlineKeyboardButton(text= _('keyboards.ref.balance'),
                                     callback_data=f'payment_{order_id}_referral'))
    builder.row(InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data=f'order_back_{order_id}'))
    return builder.as_markup()

def payments_systems_custom_menu(order_id: int, payments_systems: list) -> InlineKeyboardMarkup:
    builder = InlineKeyboardBuilder()

    if len(payments_systems) == 0:
        builder.add(InlineKeyboardButton(text= _('keyboards.payments_system.notfound'), callback_data='empty'))

    for payment in payments_systems:
        if payment["system"] == "heleket":
            builder.add(InlineKeyboardButton(text='♦️Heleket♦️', callback_data=f'cus_payment_{order_id}_heleket'))
        if payment["system"] == "CrystalPAY":
            builder.add(InlineKeyboardButton(text='💎CrystalPAY💎', callback_data=f'cus_payment_{order_id}_crystalpay'))

    builder.adjust(2)
    builder.row(InlineKeyboardButton(text= _('keyboards.ref.balance'),
                                     callback_data=f'cus_payment_{order_id}_referral'))
    builder.row(InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data=f'order_back_{order_id}'))
    return builder.as_markup()

def check_payment(order_id: int, url: str) -> InlineKeyboardMarkup:
    markup = InlineKeyboardMarkup(inline_keyboard=[
        [
            InlineKeyboardButton(text=_('keyboards.url.payment'), url=url),
            InlineKeyboardButton(text=_('keyboards.check.payment'), callback_data=f'check_{order_id}')
        ],
        [
            InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data=f'order_back_{order_id}')
        ]
    ])
    return markup

def check_referral_payment(order_id: int) -> InlineKeyboardMarkup:
    markup = InlineKeyboardMarkup(inline_keyboard=[
        [
            InlineKeyboardButton(text=_('keyboards.accept_ref.balance'), callback_data=f'check_{order_id}'),
            InlineKeyboardButton(text=_('keyboards.cancel_ref.balance'), callback_data=f'order_back_{order_id}')
        ],
        [
            InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data='back')
        ]
    ])
    return markup

def check_add_payment(order_id: int, url: str) -> InlineKeyboardMarkup:
    markup = InlineKeyboardMarkup(inline_keyboard=[
        [
            InlineKeyboardButton(text=_('keyboards.url.payment'), url=url),
            InlineKeyboardButton(text=_('keyboards.check.payment'), callback_data=f'add_check_{order_id}')
        ],
        [
            InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data='back')
        ]
    ])
    return markup

def payments_systems_add_menu(order_id: int, payments_systems: list) -> InlineKeyboardMarkup:
    builder = InlineKeyboardBuilder()

    if len(payments_systems) == 0:
        builder.add(InlineKeyboardButton(text= _('keyboards.payments_system.notfound'), callback_data='empty'))

    for payment in payments_systems:
        if payment["system"] == "heleket":
            builder.add(InlineKeyboardButton(text='♦️Heleket♦️', callback_data=f'add_payment_{order_id}_heleket'))
        if payment["system"] == "CrystalPAY":
            builder.add(InlineKeyboardButton(text='💎CrystalPAY💎', callback_data=f'add_payment_{order_id}_crystalpay'))

    builder.adjust(2)
    builder.row(InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data=f'order_back_{order_id}'))
    return builder.as_markup()


def isp_proxies_menu() -> InlineKeyboardMarkup:
    builder = InlineKeyboardBuilder()

    countries = [
        ("🇬🇧 United Kingdom", "virm"),
        ("🇩🇪 Germany", "dtag"),
        ("🇺🇸 United States", "juic"),
        ("🇦🇺 Australia", "vocu"),
        ("🇳🇱 Netherlands", "dtag_nl"),
        ("🇵🇱 Poland", "pol"),
        ("🇧🇷 Brazil", "bra"),
        ("🇱🇻 Latvia", "lva"),
        ("🇫🇷 France", "fra"),
        ("🇷🇴 Romania", "rou"),
        ("🇨🇦 Canada", "can"),
        ("🇳🇴 Norway", "nor"),
        ("🇦🇹 Austria", "aut"),
        ("🇺🇦 Ukraine", "ukr"),
        ("🇹🇷 Turkey", "tur"),
        ("🇯🇵 Japan", "jpn"),
        ("🇮🇱 Israel", "isr"),
        ("🇹🇼 Taiwan", "twn"),
        ("🇰🇷 South Korea", "kor"),
        ("🇪🇸 Spain", "esp"),
        ("🇸🇬 Singapore", "sgp"),
        ("🇭🇰 Hong Kong", "hkn"),
        ("🇹🇭 Thailand", "tha"),
        ("🇮🇳 India", "ind"),
        ("🇮🇹 Italy", "ita"),
    ]

    for name, code in countries:
        button = InlineKeyboardButton(text=name, callback_data=f"region_{code}")
        builder.add(button)

    builder.adjust(3)
    builder.row(InlineKeyboardButton(text=_('keyboards.back_menu.back'), callback_data='back'))
    return builder.as_markup()

def success_payment_menu() -> InlineKeyboardMarkup:
    markup = InlineKeyboardMarkup(inline_keyboard=[
        [
            InlineKeyboardButton(text=_('keyboards.start_menu.control_panel'), callback_data='control_panel')
        ],
        [
            InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data='back')
        ]
    ])
    return markup

def back_control_panel(subscribe_id: int) -> InlineKeyboardMarkup:
    markup = InlineKeyboardMarkup(inline_keyboard=[
        [
            InlineKeyboardButton(text=_('keyboards.start_menu.control_panel'), callback_data=f'plan_{subscribe_id}')
        ],
        [
            InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data='back')
        ]
    ])
    return markup


def control_panel_menu(data_plans: list) -> InlineKeyboardMarkup:
    builder = InlineKeyboardBuilder()

    if len(data_plans) == 0:
        builder.add(InlineKeyboardButton(text=_('keyboards.plans.notfound'), callback_data='empty'))
        builder.row(InlineKeyboardButton(text=_('keyboards.back_menu.back'), callback_data='back'))
        return builder.as_markup()

    for plan in data_plans:
        builder.add(InlineKeyboardButton(text=f'#{plan["order_id"]} {plan["plan"]}', callback_data=f"plan_{plan['id']}"))

    builder.adjust(1)

    builder.row(InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data='back'))
    return builder.as_markup()


def plan_menu(plan: str, subscribe_id: int) -> InlineKeyboardMarkup:
    builder = InlineKeyboardBuilder()

    if plan == "ISP Proxies":
        builder.add(InlineKeyboardButton(text=_('keyboards.plan.change_credentials'),
                                         callback_data=f"change_credentials_{subscribe_id}"))

    if plan == "Mobile":
        builder.add(InlineKeyboardButton(text=_('keyboards.plan.change_loc'),
                                         callback_data=f"change_loc_{subscribe_id}"))
        builder.add(InlineKeyboardButton(text=_('keyboards.plan.protocol'),
                                         callback_data=f'change_protocol_{subscribe_id}'))
        builder.add(InlineKeyboardButton(text=_('keyboards.plan.isp'),
                                         callback_data=f'change_isp_{subscribe_id}'))
        builder.add(InlineKeyboardButton(text=_('keyboards.plan.sticky'),
                                         callback_data=f'change_sticky_{subscribe_id}'))
        builder.add(InlineKeyboardButton(text=_('keyboards.plan.add_plan'),
                                         callback_data=f"add_plan_{subscribe_id}"))

    if plan in ["IPV6 Bandwidth", "IPV6 Unlimited"]:
        builder.add(InlineKeyboardButton(text=_('keyboards.plan.change_loc'),
                                         callback_data=f"change_loc_{subscribe_id}"))
        builder.add(InlineKeyboardButton(text=_('keyboards.plan.protocol'),
                                         callback_data=f'change_protocol_{subscribe_id}'))
        builder.add(InlineKeyboardButton(text=_('keyboards.plan.sticky'),
                                         callback_data=f'change_sticky_{subscribe_id}'))
        builder.add(InlineKeyboardButton(text=_('keyboards.plan.whitelist'),
                                         callback_data=f'add_whitelist_{subscribe_id}'))
        if plan == 'IPV6 Bandwidth':
            builder.add(InlineKeyboardButton(text=_('keyboards.plan.add_plan'),
                                             callback_data=f"add_plan_{subscribe_id}"))

    if plan == 'Residential':
        builder.add(InlineKeyboardButton(text=_('keyboards.plan.change_loc'),
                                         callback_data=f"change_loc_{subscribe_id}"))
        builder.add(InlineKeyboardButton(text=_('keyboards.plan.state'),
                                         callback_data=f"change_state_{subscribe_id}"))
        builder.add(InlineKeyboardButton(text=_('keyboards.plan.city'),
                                         callback_data=f"change_city_{subscribe_id}"))
        builder.add(InlineKeyboardButton(text=_('keyboards.plan.sticky'),
                                         callback_data=f'change_sticky_{subscribe_id}'))
        builder.add(InlineKeyboardButton(text=_('keyboards.plan.region'),
                                         callback_data=f'change_region_{subscribe_id}'))
        builder.add(InlineKeyboardButton(text=_('keyboards.plan.isp'),
                                         callback_data=f'change_isp_{subscribe_id}'))
        builder.add(InlineKeyboardButton(text=_('keyboards.plan.add_plan'),
                                         callback_data=f"add_plan_{subscribe_id}"))

    builder.adjust(2)
    builder.row(InlineKeyboardButton(text=_('keyboards.plan.get_proxy'),
                                 callback_data=f"get_proxy_{subscribe_id}"))

    builder.row(InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data='back'))
    return builder.as_markup()

def change_credentials_menu(subscribe_id: int) -> InlineKeyboardMarkup:
    builder = InlineKeyboardBuilder()

    builder.add(InlineKeyboardButton(text=_('keyboards.change_credentials.random'),
                                     callback_data=f"random_credentials_{subscribe_id}"))
    builder.add(InlineKeyboardButton(text=_('keyboards.change_credentials.yours'),
                                     callback_data=f"yours_credentials_{subscribe_id}"))
    builder.adjust(2)

    builder.row(InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data='back'))
    return builder.as_markup()

def change_protocol_menu(subscribe_id: int) -> InlineKeyboardMarkup:
    builder = InlineKeyboardBuilder()

    builder.add(InlineKeyboardButton(text='HTTP',
                                     callback_data=f"set_protocol_{subscribe_id}_http"))
    builder.add(InlineKeyboardButton(text='SOCKS5',
                                     callback_data=f"set_protocol_{subscribe_id}_socks"))
    builder.adjust(2)

    builder.row(InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data='back'))
    return builder.as_markup()

def change_country_menu(data_country, subscribe_id: int) -> InlineKeyboardMarkup:
    builder = InlineKeyboardBuilder()

    for country in data_country:
        flag = iso2_to_flag(country['iso2'].lower())
        builder.add(InlineKeyboardButton(text=f"{flag}{country['name']}",
                                         callback_data=f"country_{subscribe_id}_{country['iso2']}"))

    builder.adjust(3)
    builder.row(InlineKeyboardButton(text= _('keyboards.delete.country'),
                                     callback_data=f'deleted_country_{subscribe_id}'))
    builder.row(InlineKeyboardButton(text= _('keyboards.back_menu.back'),
                                     callback_data='back'))
    return builder.as_markup()

def change_state_menu(data_state, subscribe_id: int) -> InlineKeyboardMarkup:
    builder = InlineKeyboardBuilder()

    for state in data_state:
        builder.add(InlineKeyboardButton(text=f"{state['code']}",
                                         callback_data=f"state_{subscribe_id}_{state['code']}"))

    builder.adjust(3)
    builder.row(InlineKeyboardButton(text= _('keyboards.delete.state'), callback_data=f'deleted_state_{subscribe_id}'))
    builder.row(InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data='back'))
    return builder.as_markup()

def change_city_menu(data_cities, subscribe_id: int) -> InlineKeyboardMarkup:
    builder = InlineKeyboardBuilder()

    for city in data_cities:
        builder.add(InlineKeyboardButton(text=f"{city['code']}",
                                         callback_data=f"city_{subscribe_id}_{city['code']}"))

    builder.adjust(3)
    builder.row(InlineKeyboardButton(text= _('keyboards.delete.city'), callback_data=f'deleted_city_{subscribe_id}'))
    builder.row(InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data='back'))
    return builder.as_markup()

def change_region_menu(data_regions, subscribe_id: int) -> InlineKeyboardMarkup:
    builder = InlineKeyboardBuilder()

    for region in data_regions:
        builder.add(InlineKeyboardButton(text=f"{region[0]}",
                                         callback_data=f"region:{subscribe_id}:{region[1]}"))

    builder.adjust(2)
    builder.row(InlineKeyboardButton(text= _('keyboards.delete.region'), callback_data=f'deleted_region_{subscribe_id}'))
    builder.row(InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data=f'plan_{subscribe_id}'))
    return builder.as_markup()


def change_residential_country_menu(subscribe_id: int, page: int = 0) -> InlineKeyboardMarkup:
    builder = InlineKeyboardBuilder()

    start_offset = page * 50
    end_offset = start_offset + 50

    data_country = proxy_api.get_residential_countries()

    for country in data_country[start_offset:end_offset]:
        flag = iso2_to_flag(country['country_code'].lower())
        builder.row(InlineKeyboardButton(text=f"{flag}{country['country_name']}",
                                         callback_data=f"country_{subscribe_id}_{country['country_code']}"))

    builder.adjust(3)

    buttons_row = []
    if page > 0:
        buttons_row.append(
            InlineKeyboardButton(
                text="⬅️",
                callback_data=Pagination(page=page - 1, subscribe_id=subscribe_id).pack(),
            )
        )

    if end_offset < len(data_country):
        buttons_row.append(
            InlineKeyboardButton(
                text="➡️",
                callback_data=Pagination(page=page + 1, subscribe_id=subscribe_id).pack(),
            )
        )

    builder.row(*buttons_row)
    builder.row(InlineKeyboardButton(text= _('keyboards.delete.country'),
                                     callback_data=f'deleted_country_{subscribe_id}'))
    builder.row(InlineKeyboardButton(text= _('keyboards.back_menu.back'),
                                     callback_data=f'plan_{subscribe_id}'))
    return builder.as_markup()

def change_isp_menu(data_isp: list, subscribe_id: int, page: int = 0) -> InlineKeyboardMarkup:
    builder = InlineKeyboardBuilder()

    start_offset = page * 30
    end_offset = start_offset + 30


    for isp in data_isp[start_offset:end_offset]:
        builder.row(InlineKeyboardButton(text=isp['name'][:64], callback_data=f"isp_{subscribe_id}_{isp['asn']}"))

    builder.adjust(3)

    buttons_row = []
    if page > 0:
        buttons_row.append(
            InlineKeyboardButton(
                text="⬅️",
                callback_data=PaginationISP(page=page - 1, subscribe_id=subscribe_id).pack(),
            )
        )

    if end_offset < len(data_isp):
        buttons_row.append(
            InlineKeyboardButton(
                text="➡️",
                callback_data=PaginationISP(page=page + 1, subscribe_id=subscribe_id).pack(),
            )
        )

    builder.row(*buttons_row)

    if len(data_isp) > 100:
        builder.row(InlineKeyboardButton(text= _('keyboards.isp.find'), callback_data=f'find_isp_{subscribe_id}'))

    builder.row(InlineKeyboardButton(text= _('keyboards.delete.isp'), callback_data=f'deleted_isp_{subscribe_id}'))
    builder.row(InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data=f'plan_{subscribe_id}'))
    return builder.as_markup()

def get_proxy_menu(subscribe_id: int, plan: str) -> InlineKeyboardMarkup:

    builder = InlineKeyboardBuilder()


    if plan != 'Residential':
        builder.add(InlineKeyboardButton(text=_('keyboards.with_settings'),
                                             callback_data=f"with_settings"))
    else:

        builder.add(InlineKeyboardButton(text=_('keyboards.proxy_options.country'),
                                         callback_data='country'))
        builder.add(InlineKeyboardButton(text=_('keyboards.proxy_options.country_isp'),
                                         callback_data='country_isp'))
        builder.add(InlineKeyboardButton(text=_('keyboards.proxy_options.country_state'),
                                         callback_data='country_state'))
        builder.add(InlineKeyboardButton(text=_('keyboards.proxy_options.country_state_city'),
                                         callback_data='country_state_city'))
        builder.add(InlineKeyboardButton(text=_('keyboards.proxy_options.regions'),
                                         callback_data='regions'))

    builder.add(InlineKeyboardButton(text=_('keyboards.without_settings'),
                                     callback_data=f"without_settings"))

    builder.adjust(2)

    builder.row(InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data=f'plan_{subscribe_id}'))
    return builder.as_markup()


def select_type_proxy_menu(subscribe_id: int) -> InlineKeyboardMarkup:
    builder = InlineKeyboardBuilder()

    builder.add(InlineKeyboardButton(text="login:password:hostname:port",
                                         callback_data=f"proxy_type_1"))
    builder.add(InlineKeyboardButton(text="login:password@hostname:port",
                                         callback_data=f"proxy_type_2"))
    builder.add(InlineKeyboardButton(text="hostname:port@login:password",
                                         callback_data=f"proxy_type_3"))
    builder.add(InlineKeyboardButton(text="hostname:port:login:password ",
                                         callback_data=f"proxy_type_4"))
    builder.adjust(1)

    builder.row(InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data=f'plan_{subscribe_id}'))
    return builder.as_markup()

def back_file_menu() -> InlineKeyboardMarkup:
    markup = InlineKeyboardMarkup(inline_keyboard=[
        [
            InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data='back_file')
        ]
    ])
    return markup

def promo_type_menu() -> InlineKeyboardMarkup:
    markup = InlineKeyboardMarkup(inline_keyboard=[
        [
            InlineKeyboardButton(text=_('keyboards.promo.traffic'), callback_data='traffic'),
            InlineKeyboardButton(text=_('keyboards.promo.discount'), callback_data='discount')
        ],
        [
            InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data='back')
        ]
    ])
    return markup

def add_plan_ipv6() -> InlineKeyboardMarkup:
    markup = InlineKeyboardMarkup(inline_keyboard=[
        [
            InlineKeyboardButton(text=_('keyboards.add_plan_ipv6.next'), callback_data='add_ipv6'),
        ],
        [
            InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data='back')
        ]
    ])
    return markup

def choose_active_sticky_menu(subscribe_id: int) -> InlineKeyboardMarkup:
    markup = InlineKeyboardMarkup(inline_keyboard=[
        [
            InlineKeyboardButton(text=_('keyboards.sticky.status.on'), callback_data=f'sticky_on_{subscribe_id}'),
            InlineKeyboardButton(text=_('keyboards.sticky.status.off'), callback_data=f'sticky_off_{subscribe_id}'),
        ],
        [
            InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data='back')
        ]
    ])
    return markup

def add_whitelist_menu(plan_id: str) -> InlineKeyboardMarkup:
    markup = InlineKeyboardMarkup(inline_keyboard=[
        [
            InlineKeyboardButton(text=_('keyboards.add_whitelist.add'), callback_data=f'whitelist_add_{plan_id}'),
            InlineKeyboardButton(text=_('keyboards.add_whitelist.remove'), callback_data=f'whitelist_remove_{plan_id}'),
        ],
        [
            InlineKeyboardButton(text= _('keyboards.back_menu.back'), callback_data=f'plan_{plan_id}')
        ]
    ])
    return markup