import { Component, Input } from '@angular/core';
import { fuzzySort, getLatestLanguage } from '@aztrix/helpers';
import { of } from 'rxjs';
import { AbstractSelectSearch } from '../abstract-select-search';
import * as i0 from "@angular/core";
import * as i1 from "../select-search/select-search.component";
import * as i2 from "@aztrix/components/row-cell-view";
import * as i3 from "@aztrix/helpers";
export class ProposalSelectSearchComponent extends AbstractSelectSearch {
    constructor() {
        super(...arguments);
        this.searchCallback$ = (options, query) => {
            const searchOptions = options.map((proposal) => ({
                id: proposal.id,
                name: getLatestLanguage(proposal, this.languageCode)?.name,
            }));
            return of(fuzzySort(searchOptions, query, ['name']).map((result) => options.find((option) => option.id === result.id)));
        };
    }
}
ProposalSelectSearchComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: ProposalSelectSearchComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
ProposalSelectSearchComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.5", type: ProposalSelectSearchComponent, selector: "ax-proposal-select-search", inputs: { proposals: "proposals", languageCode: "languageCode" }, usesInheritance: true, ngImport: i0, template: "<ng-template #option let-result>\n  <ax-proposal-cell-view [proposal]=\"result\"></ax-proposal-cell-view>\n</ng-template>\n\n<ng-template #selected let-result>\n  <span>\n    {{ result | displayName }}\n  </span>\n</ng-template>\n\n<ax-select-search\n  [form]=\"form\"\n  [options]=\"proposals\"\n  [placeholder]=\"(multiple ? 'label.proposals' : 'label.proposal') | translate\"\n  [optionTemplate]=\"option\"\n  [selectedValueTemplate]=\"selected\"\n  [multiple]=\"multiple\"\n  [searchCallback$]=\"searchCallback$\"\n  [valueCallback]=\"valueCallback\"\n  [label]=\"label ? label : ((multiple ? 'label.proposals' : 'label.proposal') | translate)\"\n></ax-select-search>\n", dependencies: [{ kind: "component", type: i1.SelectSearchComponent, selector: "ax-select-search", inputs: ["form", "options", "placeholder", "optionTemplate", "selectedValueTemplate", "multiple", "label", "keys", "canAddNew", "required", "appearance", "errorsTemplate", "prefixTemplate", "disabled", "valueCallback", "searchCallback$"], outputs: ["addNewValue"] }, { kind: "component", type: i2.ProposalCellViewComponent, selector: "ax-proposal-cell-view", inputs: ["proposal", "languageCode"] }, { kind: "pipe", type: i3.TranslatePipe, name: "translate" }, { kind: "pipe", type: i3.DisplayNamePipe, name: "displayName" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: ProposalSelectSearchComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-proposal-select-search', template: "<ng-template #option let-result>\n  <ax-proposal-cell-view [proposal]=\"result\"></ax-proposal-cell-view>\n</ng-template>\n\n<ng-template #selected let-result>\n  <span>\n    {{ result | displayName }}\n  </span>\n</ng-template>\n\n<ax-select-search\n  [form]=\"form\"\n  [options]=\"proposals\"\n  [placeholder]=\"(multiple ? 'label.proposals' : 'label.proposal') | translate\"\n  [optionTemplate]=\"option\"\n  [selectedValueTemplate]=\"selected\"\n  [multiple]=\"multiple\"\n  [searchCallback$]=\"searchCallback$\"\n  [valueCallback]=\"valueCallback\"\n  [label]=\"label ? label : ((multiple ? 'label.proposals' : 'label.proposal') | translate)\"\n></ax-select-search>\n" }]
        }], propDecorators: { proposals: [{
                type: Input
            }], languageCode: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvcG9zYWwtc2VsZWN0LXNlYXJjaC5jb21wb25lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9saWJzL2NvbXBvbmVudHMvc2VsZWN0LXNlYXJjaC9wcm9wb3NhbC1zZWxlY3Qtc2VhcmNoL3Byb3Bvc2FsLXNlbGVjdC1zZWFyY2guY29tcG9uZW50LnRzIiwiLi4vLi4vLi4vLi4vLi4vLi4vbGlicy9jb21wb25lbnRzL3NlbGVjdC1zZWFyY2gvcHJvcG9zYWwtc2VsZ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