';body.appendChild(div)}
totalEl.textContent=fmt(cartGrandTotal())+' ₽';foot.style.display='flex';cartUpdateBadge();cartSave()}
function cartOpen(){cartRender();q('#pc-cart-drawer').classList.add('pc__cart-drawer--open');q('#pc-cart-overlay').classList.add('pc__cart-overlay--open');document.body.style.overflow='hidden'}
function cartClose(){q('#pc-cart-drawer').classList.remove('pc__cart-drawer--open');q('#pc-cart-overlay').classList.remove('pc__cart-overlay--open');document.body.style.overflow=''}
var _ctt=null;function cartToast(m){var el=q('#pc-cart-toast'),t=q('#pc-cart-toast-text');t.textContent=m||'Добавлено в корзину';el.classList.add('pc__cart-toast--show');clearTimeout(_ctt);_ctt=setTimeout(function(){el.classList.remove('pc__cart-toast--show')},2200)}
function cartAddCurrent(){var p=GP();if(!p)return;var cp=GCPM();if(!cp||cp===0){cartToast('Данная конфигурация недоступна');return}var found=-1;for(var i=0;i=0){CART[found].qty+=S.q;CART[found].pricePerM2=cp}else{CART.push({id:++CART_ID,profileKey:S.pk,profileLabel:p.l,coating:S.co,coatingLabel:CO[S.co]||S.co,color:S.cc,colorLabel:FCN(S.cc)||S.cc,thickness:S.th,length:S.ln,fullWidth:p.fW,qty:S.q,pricePerM2:cp})}cartUpdateBadge();cartToast('Товар добавлен в корзину');var btn=q('#pc-btn-order'),span=btn.querySelector('span'),orig=span.textContent;btn.classList.add('pc__btn--order--added');span.textContent='Добавлено ✓';setTimeout(function(){btn.classList.remove('pc__btn--order--added');span.textContent=orig},1600)}
function cartLoad(){try{var raw=localStorage.getItem('pc_cart');if(raw){var parsed=JSON.parse(raw);if(Array.isArray(parsed))CART=parsed;var mx=0;for(var i=0;imx)mx=CART[i].id}CART_ID=mx}}catch(e){CART=[]}cartUpdateBadge()}
function cartCheckout(){if(CART.length===0)return;var items=[];for(var i=0;i1)CART[mi].qty--;else CART.splice(mi,1);cartRender();return}var pl=e.target.closest('[data-cart-plus]');if(pl){CART[parseInt(pl.getAttribute('data-cart-plus'),10)].qty++;cartRender()}});q('#pc-cart-clear').addEventListener('click',function(){CART=[];cartRender();cartToast('Корзина очищена')});q('#pc-cart-checkout').addEventListener('click',cartCheckout);document.addEventListener('keydown',function(e){if(e.key==='Escape')cartClose()})}
var _pcInited=false;
function _pcDoInit(){if(_pcInited)return;_pcInited=true;S.ln=parseFloat(q('#pc-length').value)||1;S.q=parseInt(q('#pc-qty').value,10)||1;S.co=q('#pc-coating').value;render();rSB();rMP();bindE();cartLoad();cartBind()}
function _pcTryInit(){if(!q('#pc-sidebar'))return false;try{_pcDoInit();return true}catch(e){console.error('[PC]',e);return false}}
if(_pcTryInit()){}
var _pcAttempts=0;
var _pcInterval=setInterval(function(){_pcAttempts++;if(_pcTryInit()||_pcAttempts>150){clearInterval(_pcInterval)}},200);
if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',function(){_pcTryInit();clearInterval(_pcInterval)})}
window.addEventListener('load',function(){_pcTryInit();clearInterval(_pcInterval)});
if(typeof MutationObserver!=='undefined'&&document.body){var _pcObs=new MutationObserver(function(){if(_pcTryInit())_pcObs.disconnect()});_pcObs.observe(document.body,{childList:true,subtree:true});setTimeout(function(){try{_pcObs.disconnect()}catch(e){}},30000)}
})();
Связаться с нами
+7 (912) 320-40-66
Кровля, фасад, забор — все получится ОК, если выбрать ПрофлистОК