"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FormJsPage = void 0;
const test_1 = require("@playwright/test");
class FormJsPage {
    page;
    aiFormGeneratorButton;
    formRequestInput;
    generateFormButton;
    formEditor;
    filePicker;
    generalPanel;
    keyInput;
    uploadMultipleFilesToggle;
    documentReferenceInput;
    documentPreview;
    deployFormButton;
    deployModalSubmitButton;
    deploySuccessNotification;
    constructor(page) {
        this.page = page;
        this.aiFormGeneratorButton = page.getByRole('button', {
            name: 'AI Form Generator',
        });
        this.formRequestInput = page.getByPlaceholder('A form for an american standard loan request');
        this.generateFormButton = page.getByRole('button', { name: 'Generate form' });
        this.formEditor = page.getByLabel('Form Definition');
        this.filePicker = page.locator('button[data-field-type="filepicker"]');
        this.generalPanel = this.generalPanel = page
            .locator('[data-group-id="group-general"]')
            .first();
        this.keyInput = page.getByRole('textbox', { name: 'key' });
        this.uploadMultipleFilesToggle = page.locator('div[data-entry-id="multiple"] .bio-properties-panel-toggle-switch__switcher');
        this.documentReferenceInput = page.getByRole('textbox', {
            name: 'document reference',
        });
        this.documentPreview = page.locator('button[data-field-type="documentPreview"]');
        this.deployFormButton = page.locator('button.cds--btn--primary', {
            hasText: 'Deploy',
        });
        this.deployModalSubmitButton = page.locator('button[data-modal-primary-focus="true"][type="submit"]');
        this.deploySuccessNotification = page
            .locator('.cds--toast-notification--success')
            .filter({ hasText: 'Form deployed!' });
    }
    async clickAIFormGeneratorButton() {
        await this.aiFormGeneratorButton.click();
    }
    async clickFormRequestInput() {
        await this.formRequestInput.click();
    }
    async fillFormRequestInput(formRequest) {
        await this.formRequestInput.fill(formRequest);
    }
    async clickGenerateFormButton() {
        await this.generateFormButton.click();
    }
    async dragAndDrop(source, target) {
        await source.waitFor();
        await target.waitFor();
        await source.dragTo(target);
    }
    async clickGeneralPropertiesPanel() {
        await this.generalPanel.click({ timeout: 60000 });
    }
    async fillKeyInput(key) {
        await this.keyInput.fill(key, { timeout: 60000 });
    }
    async enableUploadMultipleFiles() {
        await this.uploadMultipleFilesToggle.click({ timeout: 60000 });
    }
    async filldocumentReferenceInput(key) {
        await this.documentReferenceInput.fill(key, { timeout: 60000 });
    }
    async clickDeployFormButton() {
        await this.deployFormButton.click({ timeout: 60000 });
    }
    async clickDeployModalSubmitButton() {
        await this.deployModalSubmitButton.click({ timeout: 60000 });
    }
    async deployForm() {
        await this.clickDeployFormButton();
        await this.clickDeployModalSubmitButton();
        await (0, test_1.expect)(this.deploySuccessNotification).toBeVisible({ timeout: 30000 });
    }
}
exports.FormJsPage = FormJsPage;
