import { Subject } from 'rxjs';

import {
  Component,
  OnInit,
  OnDestroy,
  AfterViewInit,
  ChangeDetectionStrategy,
  ChangeDetectorRef,
  Inject,
  ViewChild,
  ComponentFactoryResolver,
  ViewContainerRef,
  ComponentRef,
  Input,
  EventEmitter,
  Output
} from '@angular/core';

@Component({
  selector: 'app-layouts-default-dialog',
  templateUrl: './default-dialog.layout.component.html',
  styleUrls: ['./default-dialog.layout.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class DefaultDialogLayoutComponent implements OnInit, OnDestroy {
  @Input()
  disableClose = false;

  @Output()
  closed = new EventEmitter<MouseEvent>();

  constructor(private changeDetectorRef: ChangeDetectorRef) {}

  private ngOnDestroySubject: Subject<boolean>;

  ngOnInit(): void {
    this.ngOnDestroySubject = new Subject<boolean>();
  }

  ngOnDestroy(): void {
    if (!!this.ngOnDestroySubject) {
      this.ngOnDestroySubject.complete();
    }
  }

  onClickClose(event: MouseEvent): void {
    this.closed.emit(event);
  }
}
