import {LitElement} from 'lit';

export class RhodecodeFavicon extends LitElement {
  static properties = {
    favicon: {type: Object},
    counter: {type: Number}
  };

  constructor() {
    super();
    this.favicon = null;
    this.counter = 0;
  }

  connectedCallback() {
    super.connectedCallback();
    this.favicon = new Favico({
      type: 'rectangle',
      animation: 'none'
    });
  }

  updated(changedProperties) {
    if (changedProperties.has('counter') && this.favicon) {
      this.favicon.badge(this.counter);
    }
  }
}

customElements.define('rhodecode-favicon', RhodecodeFavicon);
