import * as i0 from '@angular/core';
import { Injectable, Pipe } from '@angular/core';

class FilterByFieldPipe {
    /**
     *
     * @param collection - array of objects
     * @param fields - fields to filter by
     * @param str - filter value
     */
    transform(collection, fields, str, options) {
        if (str && str.length !== 0) {
            return collection.reduce((filterdCollection, obj, idx, initialCollection) => {
                let isExists = false;
                if (obj[options.ignoreKey]) {
                    isExists = true;
                }
                else {
                    fields.forEach(field => {
                        if (obj[field]) {
                            let value;
                            if (options.caseSensitive) {
                                value = obj[field].toString().includes(str);
                            }
                            else {
                                value = obj[field].toString().toLowerCase().includes(str.toLowerCase());
                            }
                            isExists = isExists || value;
                        }
                    });
                }
                if (isExists) {
                    filterdCollection.push(obj);
                }
                return filterdCollection;
            }, []);
        }
        else {
            return collection;
        }
    }
    static { this.ɵfac = function FilterByFieldPipe_Factory(t) { return new (t || FilterByFieldPipe)(); }; }
    static { this.ɵpipe = /*@__PURE__*/ i0.ɵɵdefinePipe({ name: "filterByField", type: FilterByFieldPipe, pure: true, standalone: true }); }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FilterByFieldPipe, factory: FilterByFieldPipe.ɵfac, providedIn: 'root' }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FilterByFieldPipe, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }, {
        type: Pipe,
        args: [{
                name: 'filterByField',
                standalone: true
            }]
    }], null, null); })();

class GetObjectLengthPipe {
    /**
     * get object length where the value is true
     * @param itemsMap
     */
    transform(itemsMap) {
        return Object.keys(itemsMap).filter(item => !!itemsMap[item]).length;
    }
    static { this.ɵfac = function GetObjectLengthPipe_Factory(t) { return new (t || GetObjectLengthPipe)(); }; }
    static { this.ɵpipe = /*@__PURE__*/ i0.ɵɵdefinePipe({ name: "objectLengthWhereValueTrue", type: GetObjectLengthPipe, pure: true, standalone: true }); }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: GetObjectLengthPipe, factory: GetObjectLengthPipe.ɵfac, providedIn: 'root' }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GetObjectLengthPipe, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }, {
        type: Pipe,
        args: [{
                name: 'objectLengthWhereValueTrue',
                standalone: true
            }]
    }], null, null); })();

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

export { FilterByFieldPipe, GetObjectLengthPipe };
//# sourceMappingURL=ironsource-fusion-ui-pipes-collection.mjs.map
