/**
 * @fileoverview added by tsickle
 * Generated from: utils/test/widget-object/cypress-widget-finder.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
/*!
 * Copyright 2020 VMware, Inc.
 * SPDX-License-Identifier: BSD-2-Clause
 */
import { IdGenerator } from '../../id-generator/id-generator';
import { CypressLocatorDriver } from './cypress-widget-object';
/** @type {?} */
var idGenerator = new IdGenerator('cy-id');
/**
 * Knows how to find Cypress widget objects within the DOM.
 *
 * T is the type of data that this will output when you call `unwrap`.
 * In almost all cases, this should be a `Cypress.Chainable`.
 * We chose to provide this as a generic because for reasons seen in
 * [this PR](https://github.com/vmware/vmware-cloud-director-ui-components/pull/248)
 * we could not load the Cypress types in our library.
 * @template T
 */
var /**
 * Knows how to find Cypress widget objects within the DOM.
 *
 * T is the type of data that this will output when you call `unwrap`.
 * In almost all cases, this should be a `Cypress.Chainable`.
 * We chose to provide this as a generic because for reasons seen in
 * [this PR](https://github.com/vmware/vmware-cloud-director-ui-components/pull/248)
 * we could not load the Cypress types in our library.
 * @template T
 */
CypressWidgetObjectFinder = /** @class */ (function () {
    function CypressWidgetObjectFinder() {
    }
    /**
     * Finds a single widget object
     *
     * @param widgetConstructor - The constructor of the widget to use
     * @param ancestor - The CSS query or alias of the parent to begin the search from.
     *                 this will be passed to `cy.get` and is a global search.
     * @param cssSelector - The cssSelector to append to the tagName for the search
     *
     */
    /**
     * Finds a single widget object
     *
     * @template W, C
     * @param {?} widgetConstructor - The constructor of the widget to use
     * @param {?=} ancestor - The CSS query or alias of the parent to begin the search from.
     *                 this will be passed to `cy.get` and is a global search.
     * @param {?=} cssSelector - The cssSelector to append to the tagName for the search
     *
     * @return {?}
     */
    CypressWidgetObjectFinder.prototype.find = /**
     * Finds a single widget object
     *
     * @template W, C
     * @param {?} widgetConstructor - The constructor of the widget to use
     * @param {?=} ancestor - The CSS query or alias of the parent to begin the search from.
     *                 this will be passed to `cy.get` and is a global search.
     * @param {?=} cssSelector - The cssSelector to append to the tagName for the search
     *
     * @return {?}
     */
    function (widgetConstructor, ancestor, cssSelector) {
        /** @type {?} */
        var tagName = widgetConstructor.tagName;
        if (cssSelector) {
            tagName += "" + cssSelector;
        }
        /** @type {?} */
        var id = idGenerator.generate();
        /** @type {?} */
        var search = ancestor ? cy.get(ancestor).find(tagName) : cy.get(tagName);
        /** @type {?} */
        var root = search.as(id);
        /** @type {?} */
        var widget = new widgetConstructor(new CypressLocatorDriver(root, true, id));
        return (/** @type {?} */ (((/** @type {?} */ (widget)))));
    };
    return CypressWidgetObjectFinder;
}());
/**
 * Knows how to find Cypress widget objects within the DOM.
 *
 * T is the type of data that this will output when you call `unwrap`.
 * In almost all cases, this should be a `Cypress.Chainable`.
 * We chose to provide this as a generic because for reasons seen in
 * [this PR](https://github.com/vmware/vmware-cloud-director-ui-components/pull/248)
 * we could not load the Cypress types in our library.
 * @template T
 */
export { CypressWidgetObjectFinder };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3lwcmVzcy13aWRnZXQtZmluZGVyLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQHZjZC91aS1jb21wb25lbnRzLyIsInNvdXJjZXMiOlsidXRpbHMvdGVzdC93aWRnZXQtb2JqZWN0L2N5cHJlc3Mtd2lkZ2V0LWZpbmRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7QUFLQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDOUQsT0FBTyxFQUFFLG9CQUFvQixFQUFFLE1BQU0seUJBQXlCLENBQUM7O0lBSXpELFdBQVcsR0FBRyxJQUFJLFdBQVcsQ0FBQyxPQUFPLENBQUM7Ozs7Ozs7Ozs7O0FBVzVDOzs7Ozs7Ozs7OztJQUFBO0lBeUJBLENBQUM7SUF4Qkc7Ozs7Ozs7O09BUUc7Ozs7Ozs7Ozs7OztJQUNJL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