package cz.moneta.test.dsl.newib.settings.cards;

import cz.moneta.test.harness.support.web.*;
import cz.moneta.test.dsl.newib.NewIbPageFlow;

import static cz.moneta.test.dsl.newib.settings.cards.CardsSettingsPage.TITLE_XPATH;

@Wait(value = {TITLE_XPATH}, waitSecondsForElement = 30)
public interface CardsSettingsPage extends NewIbPageFlow<CardsSettingsPage> {
    String TITLE_XPATH = "//h2[@class='t-title t-title--h3' and text()='Karty']";
    String CREDIT_CARDS_TAB_XPATH = "//span[@data-testid='credit-cards-tab' and text()='Kreditní']";
    String NO_CREDIT_CARDS_XPATH = "//div[@data-testid='TextComponent' and text()='Momentálně nemáte žádné kreditní karty.']";
    String DEBIT_CARDS_TAB_XPATH = "//span[@data-testid='debit-cards-tab' and text()='Debetní']";
    String DEBIT_CARDS_TO_THE_ACCOUNT_XPATH = "//span[@data-testid='TextComponent']/small[normalize-space(.)='Debetní karty k účtu']";
    String CARDS_TO_THE_ACCOUNT_XPATH = "//h5[@class='t-title t-title--h5 u-mb--0 u-mr--0' and text()='Karty k účtu (2)']";
    String CARD_DETAIL_BUTTON_XPATH = "//div[@class='c-card u-p--xSmall u-pb--0 item-row']";
    String CARD_DETAIL_TITLE_XPATH = "//h3[@class='t-title t-title--h5 u-pl--large' and text()='Informace o kartě, nastavení']";
    String CARD_DETAIL_FULL_XPATH = "//table[contains (., 'Číslo účtu') and contains(., 'Stav') and contains(., 'Typ karty')  and contains(., 'Platnost do') and contains(., 'Limit pro výběr z bankomatu (denní)') and contains(., 'Limit pro platby na internetu (denní)') and contains(., 'Limit pro platby v obchodech') and contains(., 'a MO/TO (denní)') and contains(., 'Povolení internetových a MO/TO plateb') and contains(., 'Platby s konverzí DCC') and contains(., '3D Secure') and contains(., 'Číslo pro 3D Secure SMS') and contains(., 'ePIN')]";
    String ADJUST_SETTINGS_BUTTON_XPATH = "//button[@data-testid='Button' and text()='Upravit nastavení']";
    String ONLINE_PAYMENT_TITLE_XPATH = "//h5[@class='t-title t-title--h5' and text()='Placení na internetu']";
    String INTERNET_AND_MOTO_PAYMENTS_LABEL_XPATH = "//label[@class='f-label2' and text()='Povolení internetových a MO/TO plateb']";
    String INTERNET_AND_MOTO_PAYMENTS_TURN_ON_XPATH = "//li[@id='allowInternetMOTOTransactions_value-true']";
    String INTERNET_AND_MOTO_PAYMENTS_TURN_OFF_XPATH = "//li[@id='allowInternetMOTOTransactions_value-false']";
    String DCC_TURN_OFF_XPATH = "//li[@id='allowDccTransactions_value-false']";
    String DCC_TURN_ON_XPATH = "//li[@id='allowDccTransactions_value-true']";
    String ATM_WITHDRAWAL_LIMIT_XPATH = "//input[@id='limitAtm']";
    String ONLINE_PAYMENTS_LIMIT_XPATH = "//input[@id='limitMoto']";
    String PAYMENTS_IN_STORES_LIMIT_XPATH = "//input[@id='limitCashlessTrans']";
    String CONTINUE_BUTTON_XPATH = "//button[@data-testid='submit']";
    String VALIDATION_MESSAGE_ATM_LIMIT_XPATH = "//div[@id='limitAtm_errorMessage' and text()='Částka přesahuje maximální povolený limit 150000 CZK.']";
    String VALIDATION_MESSAGE_ONLINE_PAYMENTS_LIMIT_XPATH = "//div[@id='limitMoto_errorMessage' and text()='Částka přesahuje maximální povolený limit 150000 CZK.']";
    String VALIDATION_PAYMENTS_IN_STORES_LIMIT_XPATH = "//div[@id='limitCashlessTrans_errorMessage' and text()='Částka přesahuje maximální povolený limit 150000 CZK.']";
    String SUMMARY_TITLE_XPATH = "//h2[@class='t-title t-title--h3' and text()='Nastavení karty']";
    String SUMMARY_INTERNET_AND_MOTO_PAYMENTS_XPATH = "//span[@data-testid='item-info-allowInternetMOTOTransactions']";
    String SUMMARY_DCC_XPATH = "//span[@data-testid='item-info-dcc']";
    String SUMMARY_ATM_WITHDRAWAL_LIMIT_XPATH = "//span[@data-testid='item-info-atmWithdrawalLimit' and contains(., '150') and contains(., '000')]";
    String SUMMARY_ONLINE_PAYMENTS_LIMIT_XPATH = "//span[@data-testid='item-info-internetPaymentsLimit' and contains(., '150') and contains(., '000')]";
    String SUMMARY_INTERNET_AND_MOTO_PAYMENTS_LIMIT_XPATH = "//span[@data-testid='item-info-paymentsInStoresAndMoToLimitDebit' and contains(., '150') and contains(., '000')]";
    String SUMMARY_ACCEPT_BUTTON_XPATH = "//button[@data-testid='submit' and text()='Potvrdit']";

    String MOBILE_KEY_INPUT_XPATH = "//label[@for='mobileKey']//following-sibling::div//input[@id='mobileKey']";
    String MOBILE_KEY_SEND_BTN_XPATH = "//button[@data-testid='secondFactorSend']";
    String VICTORY_TITLE_AND_TEXT_XPATH = "//h2[@class='t-title t-title--h4' and text()='Požadavek změny nastavení karty jsme přijali ke zpracování']";
    String BACK_TO_CARDS_BUTTON_XPATH = "//button[@data-testid='go-back-to-cards' and text()='Zpět na detail karet']";
    String DCC_ALERT_XPATH = "//div[@class='c-alert__text' and text()='Obvykle mají nevýhodný kurz při převodu měn. Doporučujeme je vypnout.']";
    String BLOCK_AND_CANCEL_CARD_BUTTON_XPATH = "//button[@class='c-btn c-btn--small c-btn--border c-btn--error' and text()='Zablokovat / Zrušit kartu']";
    String CARD_BLOCKING_TITLE_XPATH = "//h1[@class='t-title t-title--h3' and text()='Blokace karty online']";
    String CARD_BLOCKING_TYPE_TITLE_XPATH = "//h2[@class='t-title t-title--h5' and text()='Zvolte typ blokace karty']";
    String CARD_BLOCKING_TYPES_XPATH = "//span[@class='f-radio__text' and contains(., 'Dočasně zablokovat') or contains(., 'Zablokovat a vydat novou') or contains(., 'Zablokovat a zrušit')]";
    String CARD_BLOCKING_TYPES_DETAILS_XPATH = "//small[@class='u-textXSmall' and contains(., 'Pokud kartu teprve hledáte a chcete se k ní brzy vrátit, kartu zablokujeme na 30 dní. Během té doby budete mít možnost ji odblokovat nebo trvale zablokovat.') or contains(., 'Pokud je karta v nebezpečí, ihned ji zrušíme a odešleme novou.') or contains(., 'Pokud o kartu nemáte zájem, zrušíme ji a kdykoliv můžete požádat o novou.')]";
    String OTHER_SETTINGS_TITLE_XPATH = "//h2[@class='t-title t-title--h5' and text()='Další nastavení']";
    String SEND_SMS_TEXT_XPATH = "//label[@id='unblockNotificationEnabled-label' and text()='Zaslat SMS o odblokování']";
    String BLOCK_AND_NEW_ONE_RADIOBUTTON_XPATH = "//li[@id='type_value-RENEWAL']";
    String REASON_FOR_BLOCKING_TITLE_XPATH = "//h2[@class='t-title t-title--h5' and text()='Důvod blokace']";
    String THEFT_CARD_XPATH = "//span[@id='text-blockReasonCode-THEFT' and contains(., 'Krádež nebo zneužití')]";
    String LOSS_CARD_XPATH = "//span[@id='text-blockReasonCode-LOSS' and contains(., 'Ztráta')]";
    String BLOCK_AND_CANCEL_RADIOBUTTON_XPATH = "//li[@id='type_value-CANCEL']";
    String TEMPORARILY_BLOCK_RADIOBUTTON_XPATH = "//li[@id='type_value-BLOCK']";
    String SMS_TOGGLE_XPATH = "//button[@id='unblockNotificationEnabled']";
    String CONTINUE_BLOCKING_CARD_BUTTON_XPATH = "//button[@data-testid='cardBlockSelectionNext' and text()='Pokračovat']";
    String VALIDATION_MESSAGE_UNBLOCK_MOBILE_NUMBER_XPATH = "//div[@id='unblockMobileNumber_errorMessage']";
    String UNBLOCK_MOBILE_NUMBER_XPATH = "//input[@id='unblockMobileNumber']";
    String CARD_BLOCKING_VICTORY_TITLE_XPATH = "//h2[@class='t-title t-title--h4 styles_title__NAx0Q' and contains(., 'Kartu udržíme pod zámkem do')]";
    String CARD_BLOCKING_VICTORY_TEXT_XPATH = "//p[@data-testid='TextComponent' and contains(normalize-space(.), 'Po tomto datu ji opět odblokujeme a vás informujeme SMS na číslo +420 702 111 111.') and contains(normalize-space(.), 'Můžete ji do té doby kdykoli odblokovat nebo trvale zablokovat.')]";
    String BACK_BUTTON_ON_VICTORY_SCREEN_XPATH = "//button[@data-testid='card-block-victoryNext' and text()='Zpět na kartu']";
    String UNBLOCK_BUTTON_XPATH = "//button[@class='c-btn c-btn--small c-btn--border c-btn--primary c-compact-buttons__button' and text()='Odblokovat kartu']";
    String CARD_BLOCKING_TYPES_ON_UNBLOCK_SCREEN_XPATH = "//span[@class='f-radio__text' and contains(., 'Odblokovat') or contains(., 'Zablokovat a vydat novou') or contains(., 'Zablokovat a zrušit')]";
    String CARD_UNBLOCKING_VICTORY_TITLE_XPATH = "//h2[@class='t-title t-title--h4 styles_title__NAx0Q' and contains(., 'Karta je znovu aktivní')]";
    String CARD_UNBLOCKING_VICTORY_TEXT_XPATH = "//p[@data-testid='TextComponent' and contains(., 'Můžete s ní začít okamžitě platit.')]";
    String CREDIT_CARD_DETAIL_FULL_XPATH = "//table[contains (., 'Číslo účtu') and contains(., 'Číslo smlouvy') and contains(., 'Stav') and contains(., 'Typ karty') and contains(., 'Platnost do') and contains(., 'Limit pro výběr z bankomatu (denní)') and contains(., 'Limit pro platby na internetu (denní)') and contains(., 'Limit pro platby v obchodech') and contains(., 'MO/TO, příkazy k úhradě (denní)') and contains(., 'Povolení internetových a MO/TO plateb') and contains(., 'Platby s konverzí DCC') and contains(., '3D Secure') and contains(., 'Číslo pro 3D Secure SMS') and contains(., 'ePIN')]";
    String CREDIT_CARD_DETAIL_TITLE_XPATH = "//h5[@class='t-title t-title--h5' and text()='Zůstatky a úvěrový rámec']";
    String CREDIT_CARD_BALANCES_AND_LIMIT_DETAIL_XPATH = "//table[contains (., 'Zbývající částka k čerpání') and contains(., 'Pro výběr v hotovosti zbývá') and contains(., 'Aktuálně vyčerpáno') and contains(., 'Celkový úvěrový rámec') and contains(., 'Pro výběr v hotovosti') and contains(., 'Minimální měsíční splátka') and contains(., 'Nejbližší minimální splátka') and contains(., 'Poslední splátka')]";
    String CREDIT_CARD_BENEFIT_PACKAGES_TITLE_XPATH = "//h3[@class='t-title t-title--h5' and text()='Balíčky výhod']";
    String CREDIT_CARD_BENEFIT_PACKAGES_DETAIL_XPATH = "//table[contains (., 'Balíček výhod') and contains(., 'Platnost od')]";
    String CREDIT_LIMIT_INCREASE_BUTTON_XPATH = "//button[@class='c-btn c-btn--small c-btn--border c-btn--primary' and text()='Navýšení úvěrového rámce']";
    String CREDIT_LIMIT_INCREASE_MODAL_XPATH = "//h2[@class='t-title t-title--h3 c-modal__title' and text()='Na této funkci pracujeme']";
    String CREDIT_LIMIT_INCREASE_CLOSE_MODAL_BUTTON_XPATH = "//button[@class='c-btn c-btn--border c-btn--primary' and text()='Zavřít']";
    String CREDIT_CARD_XPATH = "//small[normalize-space(.)='MoneyCard Smart']";

    @Click(CREDIT_CARDS_TAB_XPATH)
    CardsSettingsPage clickOnCreditCardsTab();

    @CheckElementPresent(NO_CREDIT_CARDS_XPATH)
    CardsSettingsPage checkNoCreditCards();

    @Click(DEBIT_CARDS_TAB_XPATH)
    CardsSettingsPage clickOnDebitCardsTab();

    @Wait(value = DEBIT_CARDS_TO_THE_ACCOUNT_XPATH, until = Until.CLICKABLE)
    @Click(DEBIT_CARDS_TO_THE_ACCOUNT_XPATH)
    CardsSettingsPage clickOnDebitCardsToTheAccount();

    @Wait(value = CARDS_TO_THE_ACCOUNT_XPATH, until = Until.CLICKABLE)
    @Click(CARDS_TO_THE_ACCOUNT_XPATH)
    CardsSettingsPage clickOnCardsToTheAccount();

    @Wait(value = CARD_DETAIL_BUTTON_XPATH, until = Until.CLICKABLE)
    @Click(CARD_DETAIL_BUTTON_XPATH)
    CardsSettingsPage clickOnCardDetail();

    @Wait(value = CARD_DETAIL_TITLE_XPATH, until = Until.CLICKABLE)
    @CheckElementPresent(CARD_DETAIL_TITLE_XPATH)
    CardsSettingsPage checkCardDetailTitle();

    @CheckElementPresent(CARD_DETAIL_FULL_XPATH)
    CardsSettingsPage checkCardDetailFull();

    @Click(ADJUST_SETTINGS_BUTTON_XPATH)
    CardsSettingsPage clickOnAdjustSettings();

    @CheckElementPresent(ONLINE_PAYMENT_TITLE_XPATH)
    CardsSettingsPage checkOnlinePaymentTitle();

    @CheckElementPresent(INTERNET_AND_MOTO_PAYMENTS_LABEL_XPATH)
    CardsSettingsPage checkLabelInternetAndMotoPayments();

    @Click(INTERNET_AND_MOTO_PAYMENTS_TURN_ON_XPATH)
    CardsSettingsPage clickOnInternetAndMotoPaymentsTurnOn();

    @Click(INTERNET_AND_MOTO_PAYMENTS_TURN_OFF_XPATH)
    CardsSettingsPage clickOnInternetAndMotoPaymentsTurnOff();

    @Click(DCC_TURN_OFF_XPATH)
    CardsSettingsPage clickOnDccTurnOff();

    @Click(DCC_TURN_ON_XPATH)
    CardsSettingsPage clickOnDccTurnOn();

    @TypeInto(value = ATM_WITHDRAWAL_LIMIT_XPATH, clear = true)
    CardsSettingsPage fillAtmWithdrawalLimit(String limit);

    @TypeInto(value = ONLINE_PAYMENTS_LIMIT_XPATH, clear = true)
    CardsSettingsPage fillOnlinePaymentsLimit(String limit);

    @TypeInto(value = PAYMENTS_IN_STORES_LIMIT_XPATH, clear = true)
    CardsSettingsPage fillPaymentsInStoresLimit(String limit);

    @Click(CONTINUE_BUTTON_XPATH)
    CardsSettingsPage clickOnContinue();

    @CheckElementPresent(VALIDATION_MESSAGE_ATM_LIMIT_XPATH)
    CardsSettingsPage checkValidationMessageAtmLimit();

    @CheckElementPresent(VALIDATION_MESSAGE_ONLINE_PAYMENTS_LIMIT_XPATH)
    CardsSettingsPage checkValidationMessageOnlinePaymentsLimit();

    @CheckElementPresent(VALIDATION_PAYMENTS_IN_STORES_LIMIT_XPATH)
    CardsSettingsPage checkValidationPaymentsInStoresLimit();

    @CheckElementPresent(SUMMARY_TITLE_XPATH)
    CardsSettingsPage checkSummaryTitle();

    @CheckElementContent(value = SUMMARY_INTERNET_AND_MOTO_PAYMENTS_XPATH, by = Lookup.XPATH)
    CardsSettingsPage checkSummaryInternetAndMotoPaymentsLabel(String choice);

    @CheckElementContent(value = SUMMARY_DCC_XPATH, by = Lookup.XPATH)
    CardsSettingsPage checkSummaryDcc(String choice);

    @CheckElementPresent(SUMMARY_ATM_WITHDRAWAL_LIMIT_XPATH)
    CardsSettingsPage checkSummaryAtmWithdrawalLimit();

    @CheckElementPresent(SUMMARY_ONLINE_PAYMENTS_LIMIT_XPATH)
    CardsSettingsPage checkSummaryOnlinePaymentsLimit();

    @CheckElementPresent(SUMMARY_INTERNET_AND_MOTO_PAYMENTS_LIMIT_XPATH)
    CardsSettingsPage checkSummaryInternetAndMotoPaymentsLimit();

    @Click(SUMMARY_ACCEPT_BUTTON_XPATH)
    CardsSettingsPage clickOnSummaryAcceptButton();

    @TypeInto(MOBILE_KEY_INPUT_XPATH)
    CardsSettingsPage fillMobileKey(String mobileKey);

    @Click(MOBILE_KEY_SEND_BTN_XPATH)
    CardsSettingsPage clickOnContinueMobileKey();

    @CheckElementPresent(VICTORY_TITLE_AND_TEXT_XPATH)
    CardsSettingsPage checkVictoryTitle();

    @Click(BACK_TO_CARDS_BUTTON_XPATH)
    CardsSettingsPage clickBackToCardsButton();

    @CheckElementPresent(DCC_ALERT_XPATH)
    CardsSettingsPage checkDccAlert();

    @Click(BLOCK_AND_CANCEL_CARD_BUTTON_XPATH)
    CardsSettingsPage clickOnBlockAndCancelCardButton();

    @CheckElementPresent(CARD_BLOCKING_TITLE_XPATH)
    CardsSettingsPage checkBlockCardTitle();

    @CheckElementPresent(CARD_BLOCKING_TYPE_TITLE_XPATH)
    CardsSettingsPage checkCardBlockingTypeTitle();

    @CheckElementPresent(CARD_BLOCKING_TYPES_XPATH)
    CardsSettingsPage checkCardBlockingTypes();

    @CheckElementPresent(CARD_BLOCKING_TYPES_DETAILS_XPATH)
    CardsSettingsPage checkCardBlockingTypesDetails();

    @CheckElementPresent(OTHER_SETTINGS_TITLE_XPATH)
    CardsSettingsPage checkOtherSettingsTitle();

    @CheckElementPresent(SEND_SMS_TEXT_XPATH)
    CardsSettingsPage checkSendSmsText();

    @Click(BLOCK_AND_NEW_ONE_RADIOBUTTON_XPATH)
    CardsSettingsPage clickOnBlockAndNewOne();

    @CheckElementPresent(REASON_FOR_BLOCKING_TITLE_XPATH)
    CardsSettingsPage checkReasonForBlockingTitle();

    @CheckElementPresent(THEFT_CARD_XPATH)
    CardsSettingsPage checkTheftCard();

    @CheckElementPresent(LOSS_CARD_XPATH)
    CardsSettingsPage checkLossCard();

    @Click(BLOCK_AND_CANCEL_RADIOBUTTON_XPATH)
    CardsSettingsPage clickOnBlockAndCancel();

    @Click(TEMPORARILY_BLOCK_RADIOBUTTON_XPATH)
    CardsSettingsPage clickOnTemporarilyBlock();

    @Click(SMS_TOGGLE_XPATH)
    CardsSettingsPage clickOnSmsToggle();

    @Click(CONTINUE_BLOCKING_CARD_BUTTON_XPATH)
    CardsSettingsPage clickOnContinueBlockingCardButton();

    @CheckElementContent(value = VALIDATION_MESSAGE_UNBLOCK_MOBILE_NUMBER_XPATH, by = Lookup.XPATH)
    CardsSettingsPage checkValidationMessage(String message);

    @TypeInto(value = UNBLOCK_MOBILE_NUMBER_XPATH, clear = true)
    CardsSettingsPage fillUnblockMobileNumber(String number);

    @CheckElementPresent(CARD_BLOCKING_VICTORY_TITLE_XPATH)
    CardsSettingsPage checkCardBlockingVictoryTitle();

    @CheckElementPresent(CARD_BLOCKING_VICTORY_TEXT_XPATH)
    CardsSettingsPage checkCardBlockingVictoryText();

    @Click(BACK_BUTTON_ON_VICTORY_SCREEN_XPATH)
    CardsSettingsPage clickOnBackButtonOnVictoryScreen();

    @Click(UNBLOCK_BUTTON_XPATH)
    CardsSettingsPage clickOnUnblockButton();

    @CheckElementPresent(CARD_BLOCKING_TYPES_ON_UNBLOCK_SCREEN_XPATH)
    CardsSettingsPage checkCardBlockingTypesOnUnblockScreen();

    @CheckElementPresent(CARD_UNBLOCKING_VICTORY_TITLE_XPATH)
    CardsSettingsPage checkCardUnblockingVictoryTitle();

    @CheckElementPresent(CARD_UNBLOCKING_VICTORY_TEXT_XPATH)
    CardsSettingsPage checkCardUnblockingVictoryText();

    @CheckElementPresent(CREDIT_CARD_DETAIL_FULL_XPATH)
    CardsSettingsPage checkCreditCardDetailFull();

    @CheckElementPresent(CREDIT_CARD_DETAIL_TITLE_XPATH)
    CardsSettingsPage checkCreditCardDetailTitle();

    @CheckElementPresent(CREDIT_CARD_BALANCES_AND_LIMIT_DETAIL_XPATH)
    CardsSettingsPage checkCreditCardBalancesAndLimitDetail();

    @CheckElementPresent(CREDIT_CARD_BENEFIT_PACKAGES_TITLE_XPATH)
    CardsSettingsPage checkCreditCardBenefitPackagesTitle();

    @CheckElementPresent(CREDIT_CARD_BENEFIT_PACKAGES_DETAIL_XPATH)
    CardsSettingsPage checkCreditCardBenefitPackagesDetail();

    @Click(CREDIT_LIMIT_INCREASE_BUTTON_XPATH)
    CardsSettingsPage clickOnCreditLimitIncreaseButton();

    @CheckElementPresent(CREDIT_LIMIT_INCREASE_MODAL_XPATH)
    CardsSettingsPage checkCreditLimitIncreaseModal();

    @Click(CREDIT_LIMIT_INCREASE_CLOSE_MODAL_BUTTON_XPATH)
    CardsSettingsPage clickOnCreditLimitIncreaseCloseModalButton();

    @Click(CREDIT_CARD_XPATH)
    CardsSettingsPage clickOnCreditCard();
}