System.register(["@angular/core", "@angular/forms", "@angular/material/dialog", "@angular/cdk/text-field", "rxjs/operators", "lodash", "@stratusjs/runtime/stratus", "@stratusjs/core/environment", "../core/responsive.component"], function (exports_1, context_1) {
    "use strict";
    var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
        var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
        if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
        else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
        return c > 3 && r && Object.defineProperty(target, key, r), r;
    };
    var __metadata = (this && this.__metadata) || function (k, v) {
        if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
    };
    var __param = (this && this.__param) || function (paramIndex, decorator) {
        return function (target, key) { decorator(target, key, paramIndex); }
    };
    var core_1, forms_1, dialog_1, text_field_1, operators_1, lodash_1, stratus_1, environment_1, responsive_component_1, systemDir, moduleName, parentModuleName, min, localDir, CodeViewDialogComponent;
    var __moduleName = context_1 && context_1.id;
    return {
        setters: [
            function (core_1_1) {
                core_1 = core_1_1;
            },
            function (forms_1_1) {
                forms_1 = forms_1_1;
            },
            function (dialog_1_1) {
                dialog_1 = dialog_1_1;
            },
            function (text_field_1_1) {
                text_field_1 = text_field_1_1;
            },
            function (operators_1_1) {
                operators_1 = operators_1_1;
            },
            function (lodash_1_1) {
                lodash_1 = lodash_1_1;
            },
            function (stratus_1_1) {
                stratus_1 = stratus_1_1;
            },
            function (environment_1_1) {
                environment_1 = environment_1_1;
            },
            function (responsive_component_1_1) {
                responsive_component_1 = responsive_component_1_1;
            }
        ],
        execute: function () {
            systemDir = '@stratusjs/angular';
            moduleName = 'code-view-dialog';
            parentModuleName = 'editor';
            min = !environment_1.cookie('env') ? '.min' : '';
            localDir = `${stratus_1.Stratus.BaseUrl}${boot.configuration.paths[`${systemDir}/*`].replace(/[^/]*$/, '').replace(/\/dist\/$/, '/src/')}`;
            CodeViewDialogComponent = class CodeViewDialogComponent extends responsive_component_1.ResponsiveComponent {
                constructor(dialogRef, data, ref, fb, ngZone) {
                    super();
                    this.dialogRef = dialogRef;
                    this.data = data;
                    this.ref = ref;
                    this.fb = fb;
                    this.ngZone = ngZone;
                    this.title = moduleName + '_component';
                    this._ = lodash_1.default;
                    this.Stratus = stratus_1.Stratus;
                    this.form = this.fb.group({
                        dataString: new forms_1.FormControl(),
                    });
                    this.monacoOptions = {
                        theme: 'vs-dark',
                        language: 'html'
                    };
                }
                ngOnInit() {
                    this.uid = lodash_1.default.uniqueId(`sa_${lodash_1.default.snakeCase(moduleName)}_component_`);
                    stratus_1.Stratus.Instances[this.uid] = this;
                    stratus_1.Stratus.Internals.CssLoader(`${localDir}/${parentModuleName}/${moduleName}.component${min}.css`);
                    this.model = this.data.model;
                    this.property = this.data.property;
                    const dataControl = this.form.get('dataString');
                    dataControl.patchValue(this.model.get(this.property));
                    dataControl.valueChanges.forEach((value) => {
                        if (!this.model.completed) {
                            return;
                        }
                        if (value === null) {
                            value = '';
                        }
                        this.model.set(this.property, value);
                    });
                    this.refresh();
                }
                onCancelClick() {
                    this.dialogRef.close();
                    this.refresh();
                }
                triggerResize() {
                    this.ngZone.onStable.pipe(operators_1.take(1))
                        .subscribe(() => this.autosize.resizeToFitContent(true));
                }
            };
            __decorate([
                core_1.ViewChild('autosize'),
                __metadata("design:type", text_field_1.CdkTextareaAutosize)
            ], CodeViewDialogComponent.prototype, "autosize", void 0);
            CodeViewDialogComponent = __decorate([
                core_1.Component({
                    selector: `sa-${moduleName}`,
                    templateUrl: `${localDir}/${parentModuleName}/${moduleName}.component${min}.html`,
                }),
                __param(1, core_1.Inject(dialog_1.MAT_DIALOG_DATA)),
                __metadata("design:paramtypes", [dialog_1.MatDialogRef, Object, core_1.ChangeDetectorRef,
                    forms_1.FormBuilder,
                    core_1.NgZone])
            ], CodeViewDialogComponent);
            exports_1("CodeViewDialogComponent", CodeViewDialogComponent);
        }
    };
});

//# sourceMappingURL=code-view-dialog.component.js.map
