import { __awaiter } from 'tslib';
import { element, by, browser, ExpectedConditions, protractor } from 'protractor';

class AlArchipeligo17PageObject {
    constructor() {
        this.archipeligo17UserMenu = element(by.css('al-archipeligo17-user-menu'));
        this.accountSelector = this.archipeligo17UserMenu.element(by.css('div.entity-wrapper.textual-label div.user-menu-block'));
        this.ellipsisUserMenu = this.archipeligo17UserMenu.element(by.css('div.stacked-vertical i'));
    }
    /**
     * It allows changing the account by passing a string with the id or the name of the account,
     * if there is more than one account that matches the string, the first one will be selected.
     */
    changeAccount(account) {
        return __awaiter(this, void 0, void 0, function* () {
            yield browser.wait(ExpectedConditions.visibilityOf(this.accountSelector));
            yield this.accountSelector.click();
            const accountInput = this.archipeligo17UserMenu.element(by.css('p-dropdown input.ui-dropdown-label'));
            yield accountInput.sendKeys(account);
            const dropdownPanel = this.archipeligo17UserMenu.element(by.css('p-dropdown div.ui-dropdown-panel'));
            yield browser.wait(ExpectedConditions.visibilityOf(dropdownPanel));
            const elmAccount = dropdownPanel.element(by.css('p-dropdownitem:first-child li'));
            yield browser.wait(ExpectedConditions.presenceOf(elmAccount));
            yield elmAccount.click();
        });
    }
    goToUserOption(option) {
        return __awaiter(this, void 0, void 0, function* () {
            yield browser.wait(ExpectedConditions.presenceOf(this.ellipsisUserMenu));
            yield this.ellipsisUserMenu.click();
            const items = this.archipeligo17UserMenu.all(by.xpath(`//p-menu[contains(@class, 'elipsis-menu')]//li[not(contains(@class, 'ui-helper-hidden'))]`));
            yield browser.wait(ExpectedConditions.presenceOf(items.get(0)));
            const elem = items.filter((item) => __awaiter(this, void 0, void 0, function* () { return (yield item.getText()) === option; }));
            yield elem.get(0).click().then(() => browser.sleep(500));
        });
    }
}

class AlArchipeligo19NavHeaderPageObject {
    constructor() {
        this.archipeligo19Header = element(by.css('al-archipeligo19-app-header'));
        this.archipeligoCustomerSelector = this.archipeligo19Header.element(by.css('.al-account-selector'));
        this.menuToggle = element(by.className('menu-toggle'));
    }
    toggleMenu() {
        return __awaiter(this, void 0, void 0, function* () {
            yield this.menuToggle.click();
        });
    }
    /**
     * It allows changing the account by passing a string with the id or the name of the account,
     * if there is more than one account that matches the string, the first one will be selected.
     */
    changeAccount(account) {
        return __awaiter(this, void 0, void 0, function* () {
            yield this.archipeligoCustomerSelector.click();
            const customerSearchInput = this.archipeligoCustomerSelector.element(by.css('.ng-dropdown-panel input'));
            yield browser.wait(ExpectedConditions.presenceOf(customerSearchInput));
            yield customerSearchInput.sendKeys(account);
            yield customerSearchInput.sendKeys(protractor.Key.ENTER);
        });
    }
}

class AlArchipeligo19SidenavPageObject {
    constructor() {
        this.sideNavContainer = element(by.className('sidenav-container'));
        this.EC = protractor.ExpectedConditions;
    }
    clickNavItem(parentItemIconName, childItemName) {
        return __awaiter(this, void 0, void 0, function* () {
            yield browser.wait(this.EC.visibilityOf(this.sideNavContainer));
            const iconEl = element(by.cssContainingText('i', parentItemIconName));
            const parentEl = iconEl.element(by.xpath('..')); // I hate that im having to use xpath here :-(
            yield parentEl.click();
            if (childItemName) {
                const childItem = element(by.cssContainingText('a', childItemName));
                yield browser.wait(this.EC.visibilityOf(childItem));
                yield element(by.cssContainingText('a', childItemName)).click();
            }
        });
    }
}

/**
 * Generated bundle index. Do not edit.
 */

export { AlArchipeligo17PageObject, AlArchipeligo19NavHeaderPageObject, AlArchipeligo19SidenavPageObject };
//# sourceMappingURL=al-ng-navigation-components-protractor.js.map
