const initFlashMessages = () => {
	Array.from(document.querySelectorAll('.flash-message__close')).forEach((closeBtn,i) => {
		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(() => {
			Array.from(flashMessages).forEach((fm,i) => {
				if(fm.getAttribute('data-hide')) {
					fm.classList.add('flash-message--hidden');
				}
			});
		}, 5000);
	}
}

export {
  initFlashMessages
}