import { ChangeDetectionStrategy, Component, ContentChild, Input, TemplateRef, } from '@angular/core';
import { Subject } from 'rxjs';
import * as i0 from "@angular/core";
import * as i1 from "./radio-card-fieldset.component";
import * as i2 from "@clr/angular";
import * as i3 from "@angular/common";
import * as i4 from "../form-field/form-field-control.directive";
import * as i5 from "../select-toggle/select-toggle.component";
export class RadioCardComponent {
    constructor(fieldset, changeDetector) {
        this.fieldset = fieldset;
        this.changeDetector = changeDetector;
        this.idChange$ = new Subject();
        this.name = this.fieldset.groupName;
    }
    ngOnInit() {
        this.subscription = this.fieldset.selectedIdChange$.subscribe(id => {
            this.changeDetector.markForCheck();
        });
    }
    ngOnDestroy() {
        if (this.subscription) {
            this.subscription.unsubscribe();
        }
    }
    isSelected(item) {
        return this.fieldset.isSelected(item);
    }
    isFocussed(item) {
        return this.fieldset.isFocussed(item);
    }
    selectChanged(item) {
        this.fieldset.selectChanged(item);
    }
    setFocussedId(item) {
        this.fieldset.setFocussedId(item);
    }
    getItemId(item) {
        return this.fieldset.idFn(item);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.2", ngImport: i0, type: RadioCardComponent, deps: [{ token: i1.RadioCardFieldsetComponent }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.2", type: RadioCardComponent, selector: "vdr-radio-card", inputs: { item: "item" }, queries: [{ propertyName: "itemTemplate", first: true, predicate: TemplateRef, descendants: true }], exportAs: ["VdrRadioCard"], ngImport: i0, template: "<label\n    [ngClass]=\"{\n        'selected': isSelected(item),\n        'focussed': isFocussed(item)\n    }\"\n    class=\"radio-card\"\n>\n    <input\n        type=\"radio\"\n        [name]=\"name\"\n        [value]=\"getItemId(item)\"\n        class=\"hidden\"\n        (focus)=\"setFocussedId(item)\"\n        (blur)=\"setFocussedId(undefined)\"\n        (change)=\"selectChanged(item)\"\n    />\n    <vdr-select-toggle [selected]=\"isSelected(item)\" size=\"small\"></vdr-select-toggle>\n    <div class=\"content\">\n        <ng-content></ng-content>\n    </div>\n</label>\n", styles: [":host{display:inline-block}.radio-card{background:none;position:relative;display:block;border:1px solid var(--clr-btn-default-border-color, #0072a3);border-radius:var(--clr-btn-border-radius, .15rem);padding:6px;text-align:start;margin:6px}.radio-card:hover{cursor:pointer;outline:1px solid var(--color-primary-500)}.radio-card.selected{outline:1px solid var(--color-primary-500);background-color:var(--color-primary-100)}input.hidden{visibility:hidden;position:absolute}vdr-select-toggle{position:absolute;top:3px;left:3px}.content{margin-inline-start:24px}\n"], dependencies: [{ kind: "directive", type: i2.ClrLabel, selector: "label", inputs: ["for"] }, { kind: "directive", type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i4.FormFieldControlDirective, selector: "input, textarea, select" }, { kind: "component", type: i5.SelectToggleComponent, selector: "vdr-select-toggle", inputs: ["size", "selected", "hiddenWhenOff", "disabled", "label"], outputs: ["selectedChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.2", ngImport: i0, type: RadioCardComponent, decorators: [{
            type: Component,
            args: [{ selector: 'vdr-radio-card', exportAs: 'VdrRadioCard', changeDetection: ChangeDetectionStrategy.OnPush, template: "<label\n    [ngClass]=\"{\n        'selected': isSelected(item),\n        'focussed': isFocussed(item)\n    }\"\n    class=\"radio-card\"\n>\n    <input\n        type=\"radio\"\n        [name]=\"name\"\n        [value]=\"getItemId(item)\"\n        class=\"hidden\"\n        (focus)=\"setFocussedId(item)\"\n        (blur)=\"setFocussedId(undefined)\"\n        (change)=\"selectChanged(item)\"\n    />\n    <vdr-select-toggle [selected]=\"isSelected(item)\" size=\"small\"></vdr-select-toggle>\n    <div class=\"content\">\n        <ng-content></ng-content>\n    </div>\n</label>\n", styles: [":host{display:inline-block}.radio-card{background:none;position:relative;display:block;border:1px solid var(--clr-btn-default-border-color, #0072a3);border-radius:var(--clr-btn-border-radius, .15rem);padding:6px;text-align:start;margin:6px}.radio-card:hover{cursor:pointer;outline:1px solid var(--color-primary-500)}.radio-card.selected{outline:1px solid var(--color-primary-500);background-color:var(--color-primary-100)}input.hidden{visibility:hidden;position:absolute}vdr-select-toggle{position:absolute;top:3px;left:3px}.content{margin-inline-start:24px}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.RadioCardFieldsetComponent }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { item: [{
                type: Input
            }], itemTemplate: [{
                type: ContentChild,
                args: [TemplateRef]
            }] } });
//# sourceMappingURL=data:application/json;base64, 