"use strict";(self.webpackChunkgulp_template=self.webpackChunkgulp_template||[]).push([[187],{4965:function(t,e,n){function o(){const t=document.querySelectorAll(".js-accordion:not(.init)");t.length&&t.forEach(t=>{const e=t.querySelector(".js-accordion-content"),n=t.querySelector(".js-accordion-button");n&&e&&(t.classList.add("init"),n.addEventListener("click",function(){t.classList.toggle("show"),t.classList.contains("show")?e.style.maxHeight=`${e.scrollHeight}px`:e.style.maxHeight=0}))})}n.d(e,{A:function(){return o}})},3218:function(t,e,n){function o(){const t=document.body,e=window.innerWidth-t.clientWidth;if(t.style.transition="margin-right 0.3s easy-in-out",t.style.marginRight=`${e}px`,t.style.overflow="hidden",!window.matchMedia("(min-width: 996px)").matches){const e=window.pageYOffset;t.style.top=-e+"px",t.style.position="fixed",t.style.width="100%"}}function c(){const t=document.body;if(t.style.transition="margin-right 0s easy-in-out",t.style.marginRight="0",t.style.overflow="unset",!window.matchMedia("(min-width: 996px)").matches){const e=Math.abs(parseInt(t.style.top||0,10));t.style.position="static",t.style.width="auto",t.style.removeProperty("top"),window.scrollTo(0,e||0)}}n.d(e,{$:function(){return o},W:function(){return c}})},4636:function(t,e,n){n.d(e,{F:function(){return p}});var o=n(600);function c(t,e,n,o,c,i,r){try{var s=t[i](r),a=s.value}catch(t){return void n(t)}s.done?e(a):Promise.resolve(a).then(o,c)}function i(t){return function(){var e=this,n=arguments;return new Promise(function(o,i){var r=t.apply(e,n);function s(t){c(r,o,i,s,a,"next",t)}function a(t){c(r,o,i,s,a,"throw",t)}s(void 0)})}}const r="active",s=document.querySelectorAll(".js-favorites-button-count"),a=document.querySelectorAll(".js-compare-button-count"),l=document.querySelectorAll(".js-basket-button-count");function d(t,e,n=!1){return i(function*(){var c;if((null===(c=window.APP)||void 0===c?void 0:c.FAVORITES)&&window.APP.FAVORITES.includes(Number(e))&&t.classList.add(r),!n)try{const n=yield(0,o.A)({ACTION:"add2favorites",ITEM_ID:e});if("OK"===n.STATUS){if(m(t,s,n.EVENT),f(s),"REMOVE"===n.EVENT){const t=window.APP.FAVORITES.indexOf(+e);-1!==t&&window.APP.FAVORITES.splice(t,1)}else window.APP.FAVORITES.push(+e);"REMOVE"===n.EVENT&&"/favorites/"===window.location.pathname&&(t.closest(".js-product-card").remove(),0===document.querySelectorAll(".js-product-card").length&&(document.querySelector(".js-wrap-favorites").innerHTML="",document.querySelector(".js-empty-info").classList.remove("hidden")))}}catch(t){console.log(t)}})()}function u(t,e,n=!1,c=1){return i(function*(){var i;if((null===(i=window.APP)||void 0===i?void 0:i.BASKET)&&Object.keys(window.APP.BASKET).includes(String(e))&&(t.innerText=t.dataset.incart,t.classList.add("js-added-to-cart")),!n&&t.classList.contains("js-added-to-cart"))window.location.href="/cart/";else if(!n)try{"OK"===(yield(0,o.A)({ACTION:"add2basket",ITEM_ID:e,QUANTITY:c})).STATUS&&(l.forEach(t=>{const e=t.innerText;Number(e)>98?t.innerText="99":t.innerText=Number(e)+1}),t.innerText=t.dataset.incart,t.classList.add("js-added-to-cart"),window.APP.BASKET[e]={PRODUCT_ID:Number(e),QUANTITY:c},t.classList.contains("js-reload-page")&&location.reload())}catch(t){console.log(t)}})()}function h(t,e,n=!1){return i(function*(){var c;if((null===(c=window.APP)||void 0===c?void 0:c.COMPARE)&&window.APP.COMPARE.includes(Number(e))&&t.classList.add(r),!n)try{const n=yield(0,o.A)({ACTION:"add2compare",ITEM_ID:e});if("OK"===n.STATUS)if(m(t,a,n.EVENT),f(a),"REMOVE"===n.EVENT){const t=window.APP.COMPARE.indexOf(+e);-1!==t&&window.APP.COMPARE.splice(t,1)}else window.APP.COMPARE.push(+e)}catch(t){console.log(t)}})()}function f(t){t.forEach(t=>{const e=t.innerText.includes("+")?t.innerText.split("+")[0]:t.innerText;Number(e)<=0?t.classList.add("hidden"):t.classList.remove("hidden")})}function m(t,e,n){t.classList.toggle(r),"REMOVE"===n?e.forEach(t=>{const e=t.innerText.includes("+")?t.innerText.split("+")[0]:t.innerText;t.innerText=Number(e)-1}):e.forEach(t=>{const e=t.innerText.includes("+")?t.innerText.split("+")[0]:t.innerText;t.innerText=Number(e)+1})}function p(t){t.length&&window.APP&&(t.forEach(t=>{const e=t.querySelectorAll(".js-add-to-cart"),n=t.querySelectorAll(".js-add-to-cart-obrazec"),c=t.querySelectorAll(".js-add-to-cart-catalog"),r=t.querySelectorAll(".js-add-to-favorite"),s=t.querySelectorAll(".js-add-to-compare"),a=t.querySelectorAll(".js-one-click-buy"),l=Number(t.dataset.id);e.length&&e.forEach(t=>{u(t,l,!0),t.addEventListener("click",function(){const e=this.closest(".js-actions-container"),n=null==e?void 0:e.querySelector(".js-count-picker-input"),o=n?Number(n.value):1;u(this,t.dataset.id||l,!1,o)})}),r.length&&r.forEach(t=>{d(t,l,!0),t.addEventListener("click",function(e){e.stopPropagation(),d(this,t.dataset.id||l)})}),s.length&&s.forEach(t=>{h(t,l,!0),t.addEventListener("click",function(e){e.stopPropagation(),h(this,t.dataset.id||l)})}),n.length&&n.forEach(t=>{const e=t.dataset.id;if(u(t,e,!0),window.APP.BASKET&&window.APP.BASKET[e]){const n=t.closest(".js-actions-container"),o=null==n?void 0:n.querySelector(".js-obrazec-checkbox");o&&(o.checked=!!window.APP.BASKET[e].NO_CUT)}t.addEventListener("click",function(){return i(function*(){const n=this.closest(".js-actions-container"),c=window.matchMedia("(min-width: 996px)").matches?t.previousElementSibling.querySelector(".js-count-picker-input"):n.querySelector(".js-count-picker-input"),i=Number(c.value);yield u(this,e,!1,i);try{yield(0,o.A)({ACTION:"setDntCut",ITEM_ID:e})}catch(t){console.log(t)}}).call(this)})}),c.length&&c.forEach(t=>{const e=t.dataset.id;u(t,e,!0),t.addEventListener("click",function(){return i(function*(){u(this,e)}).call(this)})}),a.length&&a.forEach(t=>{t.addEventListener("click",function(){return i(function*(){const e=document.querySelector(".js-count-picker-input"),n=e?Number(e.value):1,o=t.dataset.id||l;yield u(this,o,!1,n),window.location.replace("/order/")}).call(this)})})}),f(a),f(s))}},600:function(t,e,n){function o(t,e,n,o,c,i,r){try{var s=t[i](r),a=s.value}catch(t){return void n(t)}s.done?e(a):Promise.resolve(a).then(o,c)}function c(t){return function(){var e=this,n=arguments;return new Promise(function(c,i){var r=t.apply(e,n);function s(t){o(r,c,i,s,a,"next",t)}function a(t){o(r,c,i,s,a,"throw",t)}s(void 0)})}}function i(t){return c(function*(){const e=new FormData;for(let n in t)e.append(n,t[n]);e.append("IS_AJAX_ACTION","Y");try{const t=yield fetch("/",{method:"POST",headers:{"X-Requested-With":"XMLHttpRequest"},body:e});return yield t.json()}catch(t){return console.log("error",t),!1}})()}n.d(e,{A:function(){return i}})},1238:function(t,e,n){n.d(e,{A:function(){return a}});var o=n(4965),c=n(600),i=n(3218);function r(t,e,n,o,c,i,r){try{var s=t[i](r),a=s.value}catch(t){return void n(t)}s.done?e(a):Promise.resolve(a).then(o,c)}function s(t){return function(){var e=this,n=arguments;return new Promise(function(o,c){var i=t.apply(e,n);function s(t){r(i,o,c,s,a,"next",t)}function a(t){r(i,o,c,s,a,"throw",t)}s(void 0)})}}function a(){(0,o.A)();const t=document.querySelectorAll(".js-split-price");t.length&&t.forEach(t=>s(function*(){if(document.querySelector("[data-sum-discount-all-products]")){let t=document.querySelector("[data-sum-discount-all-products]").getAttribute("data-sum-discount-all-products");const e=yield(0,c.A)({ACTION:"getHalvaPlanHtml",PRICE:t});let n=document.querySelector(".split-price__cost"),o=document.querySelector(".js-split-price"),i=o?o.querySelector(".card-split-cost"):void 0;"success"===e.STATUS?(i&&i.remove(),n.innerHTML="Разбить на части без переплат",o.closest(".basket-aside__info-split").classList.remove("basket-aside__info-split--without-border"),o.appendChild((new DOMParser).parseFromString(e.html,"text/html").querySelector(".card-split-cost"))):("USER"===e.CODE?o.closest(".basket-aside__info-split").classList.add("basket-aside__info-split--without-border"):o.closest(".basket-aside__info-split").classList.remove("basket-aside__info-split--without-border"),n.innerHTML=e.MESSAGE,i&&i.classList.add("hidden"))}t.addEventListener("click",t=>{t.preventDefault()});const e=t.querySelectorAll('[data-modal="open"]'),n=document.querySelector('[data-modal="container"]'),o=n.querySelectorAll('[data-modal="close"]');e&&e.forEach(t=>{t&&t.addEventListener("click",t=>{t.stopPropagation(),t.preventDefault(),n.classList.add("active"),(0,i.$)()})}),o&&o.forEach(t=>{t&&t.addEventListener("click",t=>{t.stopPropagation(),n.classList.contains("active")&&(n.classList.remove("active"),(0,i.W)())})})})())}},9992:function(t,e,n){var o=n(4636),c=n(1238);window.addEventListener("DOMContentLoaded",function(){(0,c.A)(),NodeList.prototype.last=function(){return this[this.length-1]};const t=document.querySelector(".js-catalog-grid"),e=Number(t.dataset.countPage);let n=Number(t.dataset.curPage)+1;if(n>e)return;let i=!0,r=new IntersectionObserver((t,e)=>{t.forEach(t=>{t.isIntersecting&&i&&(e.unobserve(document.querySelectorAll(".js-catalog-card").last()),i=!1,document.querySelector(".js-loader").classList.add("show"),document.querySelector(".js-show-more-products").classList.add("hidden"),s())})},{threshold:.5});function s(){let c=document.location.href;BX.ajax.get(c,{PAGEN_2:n},function(c){document.querySelector(".js-loader").classList.remove("show");const s=(new DOMParser).parseFromString(c,"text/html").querySelectorAll(".js-product");(0,o.F)(s),s.forEach(e=>{const n=e.closest(".js-catalog-card");t.append(n)}),e!==n?(document.querySelector(".js-show-more-products").classList.remove("hidden"),n++,i=!0,r.observe(document.querySelectorAll(".js-catalog-card").last())):r.unobserve(document.querySelectorAll(".js-catalog-card").last())})}r.observe(document.querySelectorAll(".js-catalog-card").last()),document.querySelector(".js-show-more-products").addEventListener("click",()=>{i=!1,document.querySelector(".js-loader").classList.add("show"),document.querySelector(".js-show-more-products").classList.add("hidden"),s()})})}},function(t){t(t.s=9992)}]);