package cz.moneta.test.dsl.ufo.operations.ufoOperations;

import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.endpoints.ufo.UfoEndpoint;
import cz.moneta.test.harness.support.web.Click;
import cz.moneta.test.harness.support.web.CustomAction;
import cz.moneta.test.harness.support.web.Lookup;
import cz.moneta.test.harness.support.web.Select;
import cz.moneta.test.harness.support.web.TypeInto;
import cz.moneta.test.harness.support.web.Until;
import cz.moneta.test.harness.support.web.Wait;
import cz.moneta.test.harness.support.web.WebFlow;

import static cz.moneta.test.dsl.ufo.operations.shared.SharedElements.LOAD_IMG_DIV_CLASS;
import static cz.moneta.test.dsl.ufo.operations.ufoOperations.ACQ702_S008_AccountStatement.SEND_BUTTON_XPATH;

@Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE, waitSecondsForElement = 50)
@Wait(value = SEND_BUTTON_XPATH, waitSecondsForElement = 50)
public interface ACQ702_S008_AccountStatement extends WebFlow<ACQ702_S008_AccountStatement>, StoreAccessor {

    String SEND_BUTTON_XPATH = "ACQ702_S008_B001";
    String LASTNAME_INPUT_XPATH = "ACQ702_S008_E002";
    String SURNAME_INPUT_XPATH = "ACQ702_S008_E004";
    String ICO_INPUT_XPATH = "ACQ702_S008_E013";
    String ACCOUNT_NUMBER_INPUT_XPATH = "ACQ702_S008_E016";
    String STREET_INPUT_XPATH = "ACQ702_S008_E006";
    String CISLO_POPISNY_INPUT_XPATH = "ACQ702_S008_E007";
    String CISLO_DOMU_INPUT_XPATH = "ACQ702_S008_E015";
    String TOWN_INPUT_XPATH = "ACQ702_S008_E008";
    String ZIP_CODE_INPUT_XPATH = "ACQ702_S008_E009";
    String SENDER_INTAKE_INPUT_XPATH = "ACQ702_S008_E012";
    String INCOME_1_INPUT_XPATH = "ACQ702_S008_E010";
    String INCOME_2_INPUT_XPATH = "ACQ702_S008_E021";
    String INCOME_3_INPUT_XPATH = "ACQ702_S008_E020";
    String CONFIRMATION_DATE_INPUT_XPATH = "ACQ702_S008_E014";

    String STAMP_CHBOX_XPATH = "ACQ702_S008_H002_1";

    String SELECT_OWNER_BU_XPATH = "ACQ702_S008_C003";
    String SELECT_COUNTRY_XPATH = "ACQ702_S008_C001";

    String SEND_BUTTON_2_XPATH = "SCH708_S001_B001";
    String SEND_BUTTON_3_XPATH = "SCH711_S002_B002";

    @Click(value = SEND_BUTTON_XPATH, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE, waitSecondsForElement = 30))
    ACQ702_S008_AccountStatement clickSend();

    @Click(value = STAMP_CHBOX_XPATH)
    ACQ702_S008_AccountStatement clickStamp();

    @TypeInto(value = LASTNAME_INPUT_XPATH)
    ACQ702_S008_AccountStatement fillLastName(String input);

    @TypeInto(value = SURNAME_INPUT_XPATH)
    ACQ702_S008_AccountStatement fillSurname(String input);

    @TypeInto(value = ICO_INPUT_XPATH)
    ACQ702_S008_AccountStatement fillICO(String input);

    @TypeInto(value = ACCOUNT_NUMBER_INPUT_XPATH)
    ACQ702_S008_AccountStatement fillAccountNumber(String input);

    @TypeInto(value = STREET_INPUT_XPATH)
    ACQ702_S008_AccountStatement fillStreet(String input);

    @TypeInto(value = CISLO_POPISNY_INPUT_XPATH)
    ACQ702_S008_AccountStatement fillNumberP(String input);

    @TypeInto(value = CISLO_DOMU_INPUT_XPATH)
    ACQ702_S008_AccountStatement fillNumberO(String input);

    @TypeInto(value = TOWN_INPUT_XPATH)
    ACQ702_S008_AccountStatement fillTown(String input);

    @TypeInto(value = ZIP_CODE_INPUT_XPATH)
    ACQ702_S008_AccountStatement fillZIPCode(String input);

    @TypeInto(value = SENDER_INTAKE_INPUT_XPATH, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    ACQ702_S008_AccountStatement fillSenderIntake(String input);

    @TypeInto(value = INCOME_1_INPUT_XPATH)
    ACQ702_S008_AccountStatement fillFirstIncome(String input);

    @TypeInto(value = INCOME_2_INPUT_XPATH)
    ACQ702_S008_AccountStatement fillSecondIncome(String input);

    @TypeInto(value = INCOME_3_INPUT_XPATH)
    ACQ702_S008_AccountStatement fillThirdIncome(String input);

    @TypeInto(value = CONFIRMATION_DATE_INPUT_XPATH)
    ACQ702_S008_AccountStatement fillConfirmationDate(String input);

    @Select(value = SELECT_OWNER_BU_XPATH)
    ACQ702_S008_AccountStatement selectOwnerBU(String selectValue);

    @Select(value = SELECT_COUNTRY_XPATH)
    ACQ702_S008_AccountStatement selectCountry(String selectValue);

    @Wait(value = SEND_BUTTON_2_XPATH, waitSecondsForElement = 10)
    @Click(value = SEND_BUTTON_2_XPATH, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE, waitSecondsForElement = 40))
    ACQ702_S008_AccountStatement clickNextSend();

    @Wait(value = SEND_BUTTON_3_XPATH, waitSecondsForElement = 10)
    @Click(value = SEND_BUTTON_3_XPATH, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE, waitSecondsForElement = 40))
    ACQ702_S008_AccountStatement clickLastSend();

    @CustomAction
    default UKO720_S001_TaskDetail closeWindow() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.closePopup(20);
        return null;
    }

}