import * as i0 from '@angular/core';
import { EventEmitter, Directive, ViewChild, Output, Input } from '@angular/core';
import { FormControl } from '@angular/forms';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import '@ironsource/fusion-ui/components/dropdown-search/v1';

const _c0 = ["searchComponent"];
class DropdownSelectBaseComponent {
    constructor() {
        this.searchValueChanged = new EventEmitter();
        this._configurations = {};
        this.searchValue = new FormControl();
        this.onDestroy$ = new Subject();
    }
    set configurations(configurations) {
        if (configurations.isOpen && this.searchComponent && this.searchComponent.inputComponent) {
            this.searchComponent.inputComponent.setFocus();
        }
        this._configurations = configurations || {};
    }
    get configurations() {
        return this._configurations;
    }
    ngOnInit() {
        this.searchValue.valueChanges.pipe(takeUntil(this.onDestroy$)).subscribe(value => this.searchValueChanged.next(value));
    }
    ngOnDestroy() {
        this.onDestroy$.next();
        this.onDestroy$.complete();
    }
    resetSearch() {
        this.searchValue.reset('', { onlySelf: true, emitEvent: false });
    }
    static { this.ɵfac = function DropdownSelectBaseComponent_Factory(t) { return new (t || DropdownSelectBaseComponent)(); }; }
    static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: DropdownSelectBaseComponent, viewQuery: function DropdownSelectBaseComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(_c0, 5);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.searchComponent = _t.first);
        } }, inputs: { configurations: "configurations" }, outputs: { searchValueChanged: "searchValueChanged" } }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DropdownSelectBaseComponent, [{
        type: Directive
    }], null, { searchComponent: [{
            type: ViewChild,
            args: ['searchComponent']
        }], searchValueChanged: [{
            type: Output
        }], configurations: [{
            type: Input
        }] }); })();

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

export { DropdownSelectBaseComponent };
//# sourceMappingURL=ironsource-fusion-ui-components-dropdown-select-common-base.mjs.map
