import { Component, ContentChildren, Input, QueryList, } from '@angular/core';
import { AztrixQuillButtonDirective } from '@aztrix/quill';
import { combineLatest, ReplaySubject, Subscription } from 'rxjs';
import { ValueEdit } from './value-edit';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "./value-edits/rich-text-edit/rich-text-edit.component";
import * as i3 from "./value-edits/date-edit/date-edit.component";
import * as i4 from "./value-edits/boolean-edit/boolean-edit.component";
import * as i5 from "./value-edits/text-edit/text-edit.component";
import * as i6 from "./value-edits/textarea-edit/textarea-edit.component";
import * as i7 from "./value-edits/url-edit/url-edit.component";
import * as i8 from "./value-edits/phone-edit/phone-edit.component";
export class ValueEditComponent extends ValueEdit {
    constructor() {
        super(...arguments);
        this._buttons$ = new ReplaySubject(1);
        this._quillEditor$ = new ReplaySubject(1);
        this._subscription = new Subscription();
    }
    ngOnInit() {
        this._subscription = combineLatest([this._buttons$, this._quillEditor$]).subscribe(([buttons, quillEditor]) => {
            for (const button of buttons.toArray() || []) {
                button.quillEditorChange.next(quillEditor);
            }
        });
    }
    ngAfterContentInit() {
        if (this.buttons) {
            this._buttons$.next(this.buttons);
        }
    }
    ngOnDestroy() {
        this._subscription.unsubscribe();
    }
    setEditor(quillEditor) {
        if (quillEditor) {
            this._quillEditor$.next(quillEditor);
        }
    }
    get inputType() {
        switch (this.type) {
            case 'EMAIL':
                return 'email';
            case 'TEXT':
                return 'text';
            case 'NUMBER':
                return 'number';
            default:
                console.error(`Unknown type ${this.type}`);
                return undefined;
        }
    }
}
ValueEditComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: ValueEditComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
ValueEditComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.5", type: ValueEditComponent, selector: "ax-value-edit", inputs: { type: "type", numberConfig: "numberConfig" }, queries: [{ propertyName: "buttons", predicate: AztrixQuillButtonDirective }], usesInheritance: true, ngImport: i0, template: "<ng-template #content>\n  <ng-content></ng-content>\n</ng-template>\n\n<ng-template #ready>\n  <ng-container [ngSwitch]=\"type\">\n    <ax-boolean-edit\n      *ngSwitchCase=\"'BOOLEAN'\"\n      [form]=\"form\"\n      [name]=\"name\"\n      [label]=\"label\"\n      [floatLabel]=\"floatLabel\"\n      [placeholder]=\"placeholder\"\n      [icon]=\"icon\"\n      [hint]=\"hint\"\n      [autofocus]=\"autofocus\"\n      [required]=\"required\"\n      [autocompleteAttr]=\"autocompleteAttr\"\n      [errorsTemplate]=\"errorsTemplate\"\n      [published]=\"published\"\n    >\n      <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n    </ax-boolean-edit>\n    <ax-textarea-edit\n      *ngSwitchCase=\"'TEXT_AREA'\"\n      [form]=\"form\"\n      [name]=\"name\"\n      [label]=\"label\"\n      [floatLabel]=\"floatLabel\"\n      [placeholder]=\"placeholder\"\n      [icon]=\"icon\"\n      [hint]=\"hint\"\n      [autofocus]=\"autofocus\"\n      [required]=\"required\"\n      [matAutocomplete]=\"matAutocomplete\"\n      [autocompleteAttr]=\"autocompleteAttr\"\n      [errorsTemplate]=\"errorsTemplate\"\n      [published]=\"published\"\n      [readonly]=\"readonly\"\n      (focused)=\"focused.emit()\"\n    >\n      <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n    </ax-textarea-edit>\n    <ax-url-edit\n      *ngSwitchCase=\"'URL'\"\n      [form]=\"form\"\n      [name]=\"name\"\n      [label]=\"label\"\n      [floatLabel]=\"floatLabel\"\n      [placeholder]=\"placeholder\"\n      [icon]=\"icon\"\n      [hint]=\"hint\"\n      [autofocus]=\"autofocus\"\n      [required]=\"required\"\n      [matAutocomplete]=\"matAutocomplete\"\n      [autocompleteAttr]=\"autocompleteAttr\"\n      [errorsTemplate]=\"errorsTemplate\"\n      [published]=\"published\"\n      [readonly]=\"readonly\"\n      [prefix]=\"prefix\"\n      (focused)=\"focused.emit()\"\n    >\n      <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n    </ax-url-edit>\n    <ax-phone-edit\n      *ngSwitchCase=\"'PHONE'\"\n      [form]=\"form\"\n      [name]=\"name\"\n      [label]=\"label\"\n      [floatLabel]=\"floatLabel\"\n      [placeholder]=\"placeholder\"\n      [icon]=\"icon\"\n      [hint]=\"hint\"\n      [autofocus]=\"autofocus\"\n      [required]=\"required\"\n      [matAutocomplete]=\"matAutocomplete\"\n      [autocompleteAttr]=\"autocompleteAttr\"\n      [errorsTemplate]=\"errorsTemplate\"\n      [published]=\"published\"\n      [readonly]=\"readonly\"\n      (focused)=\"focused.emit()\"\n    >\n      <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n    </ax-phone-edit>\n    <ax-rich-text-edit\n      *ngSwitchCase=\"'RICH_TEXT'\"\n      [form]=\"form\"\n      [name]=\"name\"\n      [label]=\"label\"\n      [floatLabel]=\"floatLabel\"\n      [placeholder]=\"placeholder\"\n      [icon]=\"icon\"\n      [hint]=\"hint\"\n      [autofocus]=\"autofocus\"\n      [required]=\"required\"\n      [matAutocomplete]=\"matAutocomplete\"\n      [autocompleteAttr]=\"autocompleteAttr\"\n      [errorsTemplate]=\"errorsTemplate\"\n      [published]=\"published\"\n      [readonly]=\"readonly\"\n      (quillEditorChange)=\"setEditor($event)\"\n      (focused)=\"focused.emit()\"\n    >\n      <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n    </ax-rich-text-edit>\n    <ax-date-edit\n      *ngSwitchCase=\"'DATE'\"\n      [form]=\"form\"\n      [name]=\"name\"\n      [label]=\"label\"\n      [floatLabel]=\"floatLabel\"\n      [placeholder]=\"placeholder\"\n      [icon]=\"icon\"\n      [hint]=\"hint\"\n      [autofocus]=\"autofocus\"\n      [required]=\"required\"\n      [matAutocomplete]=\"matAutocomplete\"\n      [autocompleteAttr]=\"autocompleteAttr\"\n      [errorsTemplate]=\"errorsTemplate\"\n      [published]=\"published\"\n      [readonly]=\"readonly\"\n      (focused)=\"focused.emit()\"\n    >\n      <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n    </ax-date-edit>\n    <ax-text-edit\n      *ngSwitchDefault\n      [inputType]=\"inputType\"\n      [numberConfig]=\"numberConfig\"\n      [form]=\"form\"\n      [name]=\"name\"\n      [label]=\"label\"\n      [floatLabel]=\"floatLabel\"\n      [placeholder]=\"placeholder\"\n      [icon]=\"icon\"\n      [hint]=\"hint\"\n      [autofocus]=\"autofocus\"\n      [required]=\"required\"\n      [matAutocomplete]=\"matAutocomplete\"\n      [autocompleteAttr]=\"autocompleteAttr\"\n      [errorsTemplate]=\"errorsTemplate\"\n      [prefix]=\"prefix\"\n      [postfix]=\"postfix\"\n      [published]=\"published\"\n      [readonly]=\"readonly\"\n      (focused)=\"focused.emit()\"\n    >\n      <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n    </ax-text-edit>\n  </ng-container>\n</ng-template>\n\n<div *ngIf=\"!form; else ready\" class=\"loading\">&nbsp;</div>\n", styles: [".loading{height:64px}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i1.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { kind: "component", type: i2.RichTextEditComponent, selector: "ax-rich-text-edit", outputs: ["quillEditorChange"] }, { kind: "component", type: i3.DateEditComponent, selector: "ax-date-edit", inputs: ["minDate", "maxDate", "startView"] }, { kind: "component", type: i4.BooleanEditComponent, selector: "ax-boolean-edit" }, { kind: "component", type: i5.TextEditComponent, selector: "ax-text-edit", inputs: ["inputType", "numberConfig"] }, { kind: "component", type: i6.TextareaEditComponent, selector: "ax-textarea-edit" }, { kind: "component", type: i7.UrlEditComponent, selector: "ax-url-edit" }, { kind: "component", type: i8.PhoneEditComponent, selector: "ax-phone-edit" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: ValueEditComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-value-edit', template: "<ng-template #content>\n  <ng-content></ng-content>\n</ng-template>\n\n<ng-template #ready>\n  <ng-container [ngSwitch]=\"type\">\n    <ax-boolean-edit\n      *ngSwitchCase=\"'BOOLEAN'\"\n      [form]=\"form\"\n      [name]=\"name\"\n      [label]=\"label\"\n      [floatLabel]=\"floatLabel\"\n      [placeholder]=\"placeholder\"\n      [icon]=\"icon\"\n      [hint]=\"hint\"\n      [autofocus]=\"autofocus\"\n      [required]=\"required\"\n      [autocompleteAttr]=\"autocompleteAttr\"\n      [errorsTemplate]=\"errorsTemplate\"\n      [published]=\"published\"\n    >\n      <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n    </ax-boolean-edit>\n    <ax-textarea-edit\n      *ngSwitchCase=\"'TEXT_AREA'\"\n      [form]=\"form\"\n      [name]=\"name\"\n      [label]=\"label\"\n      [floatLabel]=\"floatLabel\"\n      [placeholder]=\"placeholder\"\n      [icon]=\"icon\"\n      [hint]=\"hint\"\n      [autofocus]=\"autofocus\"\n      [required]=\"required\"\n      [matAutocomplete]=\"matAutocomplete\"\n      [autocompleteAttr]=\"autocompleteAttr\"\n      [errorsTemplate]=\"errorsTemplate\"\n      [published]=\"published\"\n      [readonly]=\"readonly\"\n      (focused)=\"focused.emit()\"\n    >\n      <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n    </ax-textarea-edit>\n    <ax-url-edit\n      *ngSwitchCase=\"'URL'\"\n      [form]=\"form\"\n      [name]=\"name\"\n      [label]=\"label\"\n      [floatLabel]=\"floatLabel\"\n      [placeholder]=\"placeholder\"\n      [icon]=\"icon\"\n      [hint]=\"hint\"\n      [autofocus]=\"autofocus\"\n      [required]=\"required\"\n      [matAutocomplete]=\"matAutocomplete\"\n      [autocompleteAttr]=\"autocompleteAttr\"\n      [errorsTemplate]=\"errorsTemplate\"\n      [published]=\"published\"\n      [readonly]=\"readonly\"\n      [prefix]=\"prefix\"\n      (focused)=\"focused.emit()\"\n    >\n      <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n    </ax-url-edit>\n    <ax-phone-edit\n      *ngSwitchCase=\"'PHONE'\"\n      [form]=\"form\"\n      [name]=\"name\"\n      [label]=\"label\"\n      [floatLabel]=\"floatLabel\"\n      [placeholder]=\"placeholder\"\n      [icon]=\"icon\"\n      [hint]=\"hint\"\n      [autofocus]=\"autofocus\"\n      [required]=\"required\"\n      [matAutocomplete]=\"matAutocomplete\"\n      [autocompleteAttr]=\"autocompleteAttr\"\n      [errorsTemplate]=\"errorsTemplate\"\n      [published]=\"published\"\n      [readonly]=\"readonly\"\n      (focused)=\"focused.emit()\"\n    >\n      <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n    </ax-phone-edit>\n    <ax-rich-text-edit\n      *ngSwitchCase=\"'RICH_TEXT'\"\n      [form]=\"form\"\n      [name]=\"name\"\n      [label]=\"label\"\n      [floatLabel]=\"floatLabel\"\n      [placeholder]=\"placeholder\"\n      [icon]=\"icon\"\n      [hint]=\"hint\"\n      [autofocus]=\"autofocus\"\n      [required]=\"required\"\n      [matAutocomplete]=\"matAutocomplete\"\n      [autocompleteAttr]=\"autocompleteAttr\"\n      [errorsTemplate]=\"errorsTemplate\"\n      [published]=\"published\"\n      [readonly]=\"readonly\"\n      (quillEditorChange)=\"setEditor($event)\"\n      (focused)=\"focused.emit()\"\n    >\n      <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n    </ax-rich-text-edit>\n    <ax-date-edit\n      *ngSwitchCase=\"'DATE'\"\n      [form]=\"form\"\n      [name]=\"name\"\n      [label]=\"label\"\n      [floatLabel]=\"floatLabel\"\n      [placeholder]=\"placeholder\"\n      [icon]=\"icon\"\n      [hint]=\"hint\"\n      [autofocus]=\"autofocus\"\n      [required]=\"required\"\n      [matAutocomplete]=\"matAutocomplete\"\n      [autocompleteAttr]=\"autocompleteAttr\"\n      [errorsTemplate]=\"errorsTemplate\"\n      [published]=\"published\"\n      [readonly]=\"readonly\"\n      (focused)=\"focused.emit()\"\n    >\n      <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n    </ax-date-edit>\n    <ax-text-edit\n      *ngSwitchDefault\n      [inputType]=\"inputType\"\n      [numberConfig]=\"numberConfig\"\n      [form]=\"form\"\n      [name]=\"name\"\n      [label]=\"label\"\n      [floatLabel]=\"floatLabel\"\n      [placeholder]=\"placeholder\"\n      [icon]=\"icon\"\n      [hint]=\"hint\"\n      [autofocus]=\"autofocus\"\n      [required]=\"required\"\n      [matAutocomplete]=\"matAutocomplete\"\n      [autocompleteAttr]=\"autocompleteAttr\"\n      [errorsTemplate]=\"errorsTemplate\"\n      [prefix]=\"prefix\"\n      [postfix]=\"postfix\"\n      [published]=\"published\"\n      [readonly]=\"readonly\"\n      (focused)=\"focused.emit()\"\n    >\n      <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n    </ax-text-edit>\n  </ng-container>\n</ng-template>\n\n<div *ngIf=\"!form; else ready\" class=\"loading\">&nbsp;</div>\n", styles: [".loading{height:64px}\n"] }]
        }], propDecorators: { type: [{
                type: Input
            }], numberConfig: [{
                type: Input
            }], buttons: [{
                type: ContentChildren,
                args: [AztrixQuillButtonDirective]
            }] } });
//# sourceMappingURL=data:application/json;base64, 