import { Component, Input } from '@angular/core';
import { gettext } from '@c8y/ngx-components';
import { has, uniq } from 'lodash-es';
import * as i0 from "@angular/core";
import * as i1 from "@c8y/ngx-components";
import * as i2 from "@angular/common";
import * as i3 from "@c8y/ngx-components/operations/stepper-frames";
export class ConfirmSoftwareSelectionStepComponent {
    ngOnChanges(changes) {
        if (changes.selectedItems) {
            const deviceTypes = this.deviceTypes;
            this.title =
                deviceTypes && deviceTypes.length
                    ? deviceTypes.join(', ')
                    : gettext('Undefined`device type`');
        }
    }
    get selectedToInstall() {
        return this.selectedItems.filter(software => software.action === 'install');
    }
    get selectedToDelete() {
        return this.selectedItems.filter(software => software.action === 'delete');
    }
    get deviceTypes() {
        return uniq(this.selectedItems
            .filter(val => has(val, ['software', 'c8y_Filter', 'type']))
            .map(val => val.software.c8y_Filter.type)
            .filter(val => !!val));
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ConfirmSoftwareSelectionStepComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: ConfirmSoftwareSelectionStepComponent, selector: "c8y-confirm-software-selection-step", inputs: { selectedItems: "selectedItems" }, usesOnChanges: true, ngImport: i0, template: "<c8y-preview-selection-frame [header]=\"'Confirm selection' | translate\">\n  <ng-container *previewBlock=\"'Device type' | translate\">\n    <ng-container *ngIf=\"deviceTypes.length > 0; else noType\">\n      <span *ngFor=\"let deviceType of deviceTypes; let last = last\"\n        >{{ deviceType }}{{ last ? '' : ', ' }}</span\n      >\n    </ng-container>\n    <ng-template #noType>\n      <em class=\"text-muted\" translate>Undefined`device type`</em>\n    </ng-template>\n  </ng-container>\n  <c8y-list-group\n    *previewBlock=\"'Installations/updates`software`' | translate; if: !!selectedToInstall.length\"\n  >\n    <c8y-li *ngFor=\"let selectedItem of selectedToInstall\">\n      <c8y-li-icon>\n        <i c8yIcon=\"c8y-tools\"></i>\n      </c8y-li-icon>\n      <c8y-li-body class=\"content-flex-10\">\n        <div class=\"col-6 text-truncate\" title=\"{{ selectedItem.software.name }}\">\n          {{ selectedItem.software.name }}\n        </div>\n        <div class=\"col-6 text-right\" *ngIf=\"!!selectedItem?.version?.c8y_Software?.version\">\n          <span class=\"text-label-small m-r-4\" translate> Version </span>\n          <span>\n            {{ selectedItem.version.c8y_Software.version }}\n          </span>\n        </div>\n      </c8y-li-body>\n    </c8y-li>\n  </c8y-list-group>\n  <c8y-list-group *previewBlock=\"'Removals`software`' | translate; if: !!selectedToDelete.length\">\n    <c8y-li *ngFor=\"let selectedItem of selectedToDelete\">\n      <c8y-li-icon>\n        <i c8yIcon=\"c8y-tools\"></i>\n      </c8y-li-icon>\n      <c8y-li-body class=\"content-flex-10\">\n        <div class=\"col-6\">\n          {{ selectedItem.software.name }}\n        </div>\n        <div class=\"col-6 text-right\">\n          <span class=\"text-label-small m-r-8\" translate> Version </span>\n          <span>\n            {{ selectedItem.version.c8y_Software.version }}\n          </span>\n        </div>\n      </c8y-li-body>\n    </c8y-li>\n  </c8y-list-group>\n</c8y-preview-selection-frame>\n", dependencies: [{ kind: "directive", type: i1.IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "directive", type: i1.C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i1.ListGroupComponent, selector: "c8y-list-group" }, { kind: "component", type: i1.ListItemComponent, selector: "c8y-list-item, c8y-li", inputs: ["active", "highlighted", "emptyActions", "dense", "collapsed", "selectable"], outputs: ["collapsedChange"] }, { kind: "component", type: i1.ListItemIconComponent, selector: "c8y-list-item-icon, c8y-li-icon", inputs: ["icon", "status"] }, { kind: "component", type: i1.ListItemBodyComponent, selector: "c8y-list-item-body, c8y-li-body", inputs: ["body"] }, { kind: "component", type: i3.PreviewSelectionFrameComponent, selector: "c8y-preview-selection-frame", inputs: ["header", "name", "description", "type"] }, { kind: "directive", type: i3.PreviewBlockDirective, selector: "[previewBlock]", inputs: ["previewBlock", "previewBlockIf"] }, { kind: "pipe", type: i1.C8yTranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ConfirmSoftwareSelectionStepComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-confirm-software-selection-step', template: "<c8y-preview-selection-frame [header]=\"'Confirm selection' | translate\">\n  <ng-container *previewBlock=\"'Device type' | translate\">\n    <ng-container *ngIf=\"deviceTypes.length > 0; else noType\">\n      <span *ngFor=\"let deviceType of deviceTypes; let last = last\"\n        >{{ deviceType }}{{ last ? '' : ', ' }}</span\n      >\n    </ng-container>\n    <ng-template #noType>\n      <em class=\"text-muted\" translate>Undefined`device type`</em>\n    </ng-template>\n  </ng-container>\n  <c8y-list-group\n    *previewBlock=\"'Installations/updates`software`' | translate; if: !!selectedToInstall.length\"\n  >\n    <c8y-li *ngFor=\"let selectedItem of selectedToInstall\">\n      <c8y-li-icon>\n        <i c8yIcon=\"c8y-tools\"></i>\n      </c8y-li-icon>\n      <c8y-li-body class=\"content-flex-10\">\n        <div class=\"col-6 text-truncate\" title=\"{{ selectedItem.software.name }}\">\n          {{ selectedItem.software.name }}\n        </div>\n        <div class=\"col-6 text-right\" *ngIf=\"!!selectedItem?.version?.c8y_Software?.version\">\n          <span class=\"text-label-small m-r-4\" translate> Version </span>\n          <span>\n            {{ selectedItem.version.c8y_Software.version }}\n          </span>\n        </div>\n      </c8y-li-body>\n    </c8y-li>\n  </c8y-list-group>\n  <c8y-list-group *previewBlock=\"'Removals`software`' | translate; if: !!selectedToDelete.length\">\n    <c8y-li *ngFor=\"let selectedItem of selectedToDelete\">\n      <c8y-li-icon>\n        <i c8yIcon=\"c8y-tools\"></i>\n      </c8y-li-icon>\n      <c8y-li-body class=\"content-flex-10\">\n        <div class=\"col-6\">\n          {{ selectedItem.software.name }}\n        </div>\n        <div class=\"col-6 text-right\">\n          <span class=\"text-label-small m-r-8\" translate> Version </span>\n          <span>\n            {{ selectedItem.version.c8y_Software.version }}\n          </span>\n        </div>\n      </c8y-li-body>\n    </c8y-li>\n  </c8y-list-group>\n</c8y-preview-selection-frame>\n" }]
        }], propDecorators: { selectedItems: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 