import "@material/mwc-icon-button";
import { mdiMenu } from "@mdi/js";
import { UnsubscribeFunc } from "home-assistant-js-websocket";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import { fireEvent } from "../common/dom/fire_event";
import { computeDomain } from "../common/entity/compute_domain";
import { subscribeNotifications } from "../data/persistent_notification";
import { HomeAssistant } from "../types";
import "./ha-svg-icon";
@customElement("ha-menu-button")
class HaMenuButton extends LitElement {
@property({ type: Boolean }) public hassio = false;
@property() public narrow!: boolean;
@property({ attribute: false }) public hass!: HomeAssistant;
@state() private _hasNotifications = false;
private _alwaysVisible = false;
private _attachNotifOnConnect = false;
private _unsubNotifications?: UnsubscribeFunc;
public connectedCallback() {
super.connectedCallback();
if (this._attachNotifOnConnect) {
this._attachNotifOnConnect = false;
this._subscribeNotifications();
}
}
public disconnectedCallback() {
super.disconnectedCallback();
if (this._unsubNotifications) {
this._attachNotifOnConnect = true;
this._unsubNotifications();
this._unsubNotifications = undefined;
}
}
protected render(): TemplateResult {
const hasNotifications =
(this.narrow || this.hass.dockedSidebar === "always_hidden") &&
(this._hasNotifications ||
Object.keys(this.hass.states).some(
(entityId) => computeDomain(entityId) === "configurator"
));
return html`