import { BreakpointObserver, Breakpoints } from "@angular/cdk/layout";
import { Injectable } from "@angular/core";
import { Subject, takeUntil } from "rxjs";

@Injectable({
  providedIn: "root",
})
export class ActiveSidebarService {
  activeSide = "IsActive";
  MobileShow = true;
  destroyed = new Subject<void>();
  isTouchEvent!: boolean;
  constructor(
    breakpointObserver: BreakpointObserver,
  ) {
    breakpointObserver.observe([Breakpoints.XSmall, Breakpoints.Small])
      .pipe(takeUntil(this.destroyed))
      .subscribe((result) => {
        if (
          result.breakpoints["(max-width: 599.98px)"] ||
          result.breakpoints["(min-width: 600px) and (max-width: 959.98px)"]
        ) {
          this.MobileShow = true;
        } else {
          this.MobileShow = false;
        }
      });
  }
  SideBar(ele: string) {
    // if (this.MobileShow) {
      if (this.activeSide == ele) {
        this.activeSide = "";
        //a.type == 'mouseenter' ? this.activeSide = "" : this.activeSide = "IsActive";
      } else {
        this.activeSide = "IsActive";
        //a.type == 'mouseenter' ? this.activeSide = "IsActive" : this.activeSide = "";
      // }
    }
  }
  //ActiveSideBar(ele) {
  //  this.activeSide = "";
  //}
  //DisActiveSideBar(ele) {
  //  this.activeSide = "IsActive";
  //}
}
