text: "use strict";var urlList=getUrlFromLocalStorage(),form=document.querySelector(".url-form"),input=document.querySelector(".url-form__input"),addUrlButton=document.querySelector(".url-form__button"),cardSection=document.querySelector(".favorites-wrapper");function drawFavorites(){var t=document.querySelector("#favorites-template").innerHTML.trim(),r=Handlebars.compile(t),e=urlList.reduce(function(t,e){return t+r(e)},"");cardSection.insertAdjacentHTML("afterbegin",e)}function onUrlAdding(t){t.preventDefault();var e=/[(http(s)?):\/\/(www\.)?a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/;e.test(input.value)&&!urlList.find(function(t){return t.url===input.value})?(cardSection.innerHTML="",urlList.unshift({url:input.value}),setUrlToLocalStorage(urlList),drawFavorites()):urlList.find(function(t){return t.url===input.value})?alert("Такая закладка уже существует!"):e.test(input.value)||alert("Не прошло валидацию!"),form.reset()}function onDeleteClick(t){if("BUTTON"===t.target.nodeName){var e=t.target.parentNode,r=e.querySelector(".favorites-card__url").textContent,n=urlList.indexOf(urlList.find(function(t){return t.url===r}));e.remove(),urlList.splice([n],1),setUrlToLocalStorage(urlList)}}function setUrlToLocalStorage(t){localStorage.setItem("favourites-links",JSON.stringify(t))}function getUrlFromLocalStorage(){var t=localStorage.getItem("favourites-links");return t?JSON.parse(t):[]}drawFavorites(),console.log(urlList),form.addEventListener("submit",onUrlAdding),cardSection.addEventListener("click",onDeleteClick);