"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectorSettingsPage = void 0;
const ModelerCreatePage_1 = require("./ModelerCreatePage");
class ConnectorSettingsPage {
    page;
    urlInput;
    resultExpressionInput;
    authenticationTypeDropdown;
    usernameInput;
    passwordInput;
    methodTypeDropdown;
    resultVariableInput;
    bearerTokenInput;
    constructor(page) {
        this.page = page;
        this.urlInput = page.getByLabel('URL');
        this.resultExpressionInput = page.getByLabel('Result expression');
        this.authenticationTypeDropdown = page.getByLabel('Type');
        this.usernameInput = page.getByLabel('Username');
        this.passwordInput = page.getByLabel('Password');
        this.methodTypeDropdown = page.getByLabel('Method');
        this.resultVariableInput = page.getByLabel('Result variable');
        this.bearerTokenInput = page.getByLabel('Bearer token');
    }
    async clickUrlInput() {
        try {
            await this.urlInput.click({ timeout: 60000 });
        }
        catch {
            const modelerCreatePage = new ModelerCreatePage_1.ModelerCreatePage(this.page);
            await modelerCreatePage.clickStartEventElement();
            await modelerCreatePage.clickAppendTaskButton();
            await modelerCreatePage.clickChangeTypeButton();
            await modelerCreatePage.clickRestConnectorOption();
            await this.urlInput.click({ timeout: 60000 });
        }
    }
    async fillUrlInput(url) {
        await this.urlInput.fill(url);
    }
    async clickResultExpressionInput() {
        await this.resultExpressionInput.click();
    }
    async fillResultExpressionInput(resultExpression) {
        await this.resultExpressionInput.fill(resultExpression);
    }
    async selectAuthenticationType(authentication) {
        await this.authenticationTypeDropdown.selectOption(authentication);
    }
    async clickUsernameInput() {
        await this.usernameInput.click({ timeout: 30000 });
    }
    async fillUsernameInput(username) {
        await this.usernameInput.fill(username, { timeout: 30000 });
    }
    async clickPasswordInput() {
        await this.passwordInput.click();
    }
    async fillPasswordInput(password) {
        await this.passwordInput.fill(password);
    }
    async selectMethodType(method) {
        await this.methodTypeDropdown.selectOption(method, { timeout: 60000 });
    }
    async clickResultVariableInput() {
        await this.resultVariableInput.click();
    }
    async fillResultVariableInput(variable) {
        await this.resultVariableInput.fill(variable);
    }
    async clickBearerTokenInput() {
        await this.bearerTokenInput.click({ timeout: 30000 });
    }
    async fillBearerTokenInput(token) {
        await this.bearerTokenInput.fill(token);
    }
}
exports.ConnectorSettingsPage = ConnectorSettingsPage;
