const initFlashMessages = () => {
    const closeBtns = document.querySelectorAll('.flash-message__close');
	for(const closeBtn of closeBtns) {
		closeBtn.addEventListener('click', () => {
			const fm = closeBtn.closest('.flash-message');
			fm.classList.add('flash-message--hidden');
		});
	};

	const flashMessages = document.querySelectorAll('.flash-message');
	if(flashMessages.length) {
		setTimeout(() => {
            for(const fm of flashMessages) {
                if(fm.getAttribute('data-hide')) {
					fm.classList.add('flash-message--hidden');
				}
            }
		}, 5000);
	}
}

export {
  initFlashMessages
}