text: import FavoriteMovieIdb from '../data/favorite-movie-idb';
  import { createLikeMovieButtonTemplate, createUnlikeMovieButtonTemplate } from '../views/templates/template-creator';
  
  const LikeButtonPresenter = {
    async init({ likeButtonContainer, movie }) {
      this._likeButtonContainer = likeButtonContainer;
      this._movie = movie;
  
      await this._renderButton();
    },
  
    async _renderButton() {
      const { id } = this._movie;
  
      if (await this._isMovieExist(id)) {
        this._renderLiked();
      } else {
        this._renderLike();
      }
    },
  
    async _isMovieExist(id) {
      const movie = await FavoriteMovieIdb.getMovie(id);
      return !!movie;
    },
  
    _renderLike() {
      this._likeButtonContainer.innerHTML = createLikeMovieButtonTemplate();
  
      const likeButton = document.querySelector('#likeButton');
      likeButton.addEventListener('click', async () => {
        await FavoriteMovieIdb.putMovie(this._movie);
        this._renderButton();
      });
    },
  
    _renderLiked() {
      this._likeButtonContainer.innerHTML = createUnlikeMovieButtonTemplate();
  
      const likeButton = document.querySelector('#likeButton');
      likeButton.addEventListener('click', async () => {
        await FavoriteMovieIdb.deleteMovie(this._movie.id);
        this._renderButton();
      });
    },
  };
  
  export default LikeButtonPresenter;
  