<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">/**
 * РљРѕРјРїРѕРЅРµРЅС‚ РёРЅРёС†РёР°Р»РёР·РёСЂСѓРµС‚ СЂР°Р±РѕС‚Сѓ РєРЅРѕРїРѕРє "Р’ РєРѕСЂР·РёРЅСѓ", Р° С‚Р°РєР¶Рµ СЃР°РјРѕР№ РєРѕСЂР·РёРЅС‹
 */
new class Cart extends RsJsCore.classes.component {

    constructor(settings)
    {
        super();
        let defaults = {
            cartBlockMain: '#rs-cart',
            cartBlock:'.rs-cart-block',
            context: '[data-id]',

            addToCart: '.rs-to-cart',
            reserve: '.rs-reserve',
            alreadyInCartClass: 'added',
            addFromDialogClass: 'rs-buy',
            alreadyInCartClassTimeout:5,

            noShowModalCartClass: 'rs-no-modal-cart',

            offerFormName: '[name="offer"]',
            amountFormName: '[name="amount"]',
            multiOfferFormName: '[name^="multioffers"]',
            concomitantFormName: '[name^="concomitant"]',

            cartTotalPrice: '.rs-cart-items-price',
            cartTotalItems: '.rs-cart-items-count',
            cartActiveClass: 'active',

            checkoutButton: '.rs-go-checkout',
            checkoutButtonActiveClass: 'active',

            cartAmountField: '.rs-amount',
            cartPage: '#rs-cart-page',
            cartForm: '#rs-cart-form',
            cartItem: '.rs-cart-item',
            cartItemRemove: '.rs-remove',
            cartItemRemoveConcomitant: '.rs-remove-concomitant',
            cartItemOffer: '.rs-offer',
            cartItemMultiOffer: '.rs-multioffer',
            cartGoBackButton: '.rs-go-back',
            cartItemHiddenOffers: '.rs-hidden-multioffer',
            cartClean: '.rs-clean',
            cartApplyCoupon: '.rs-apply-coupon',
            productWrapper: '.rs-product-item',
            inLoadingClass: 'in-loading',
            cartConcomitantCheckbox: '.rs-concomitant-checkbox',

            //РЈРјРЅС‹Рµ РєРЅРѕРїРєРё, РїСЂРµРІСЂР°С‰Р°СЋС‰РёРµСЃСЏ РІ РєРѕР»РёС‡РµСЃС‚РІРѕ

        };

        this.settings = {...defaults, ...this.getExtendsSettings(), ...settings};
    }

    init() {
        this.utils.on('click', this.settings.addToCart, event =&gt; this.addToCart(event));
        this.utils.on('click', this.settings.reserve, event =&gt; this.reserve(event));
        this.utils.on('click', this.settings.checkoutButton, event =&gt; this.checkout(event));

        this.cartBlockMain = document.querySelector(this.settings.cartBlockMain);

        let cartPage = document.querySelector(this.settings.cartPage);
        if (cartPage) {
            this.initCart(cartPage.parentNode);
        }

        //РЈРјРЅС‹Рµ РєРЅРѕРїРєРё Р’ РєРѕСЂР·РёРЅСѓ СЃ РєРѕР»РёС‡РµСЃС‚РІРѕРј
        this.utils.on('click', this.settings.smartAmountBuyButton, event =&gt; this.smartAmountAdd(event));
    }

    /**
     * Р”РѕР±Р°РІР»СЏРµС‚ С‚РѕРІР°СЂ РІ РєРѕСЂР·РёРЅСѓ Рё РѕС‚РєСЂС‹РІР°РµС‚ РѕРєРЅРѕ СѓРїСЂРѕС‰РµРЅРЅРѕР№ РєРѕСЂР·РёРЅС‹
     *
     * @param event
     */
    addToCart(event) {
        let button = event.rsTarget;
        let context = button.closest(this.settings.context);
        this.changeStateToAdded(button);
        let formData = this.getProductParams(context);

        if (this.needShowSelectMultiofferDialog(button)) {
            let url = button.dataset.selectMultiofferHref;
            this.plugins.openDialog.show({
                url: url
            });
        } else {
            let url = button.dataset.href ? button.dataset.href : button.getAttribute('href');

            let noShowModalCart = !this.cartBlockMain
                || this.cartBlockMain.classList.contains(this.settings.noShowModalCartClass)
                || button.classList.contains(this.settings.noShowModalCartClass);

            this.requestToCart(url, formData, noShowModalCart);

            if (button.classList.contains(this.settings.addFromDialogClass) &amp;&amp; noShowModalCart) {
                this.plugins.modal.close();
            }
        }
    }

    /**
     * Р’С‹Р·С‹РІР°РµС‚ РѕРєРЅРѕ РІС‹Р±РѕСЂР° РєРѕРјРїР»РµРєС‚Р°С†РёРё РёР»Рё РѕРєРЅРѕ СЂРµР·РµСЂРІРёСЂРѕРІР°РЅРёСЏ С‚РѕРІР°СЂР°
     *
     * @param event
     */
    reserve(event) {
        let button = event.rsTarget;
        let url;

        if (this.needShowSelectMultiofferDialog(button)) {
            url = button.dataset.selectMultiofferHref;
        } else {
            url = button.dataset.href;
        }

        if (url) {
            this.plugins.openDialog.show({
                url: url
            });
        }
    }

    /**
     * Р’РѕР·РІСЂР°С‰Р°РµС‚ true, РµСЃР»Рё РїРѕ РЅР°Р¶Р°С‚РёСЋ РЅР° РґР°РЅРЅСѓСЋ РєРЅРѕРїРєСѓ РІ
     * С‚РµРєСѓС‰РµР№ СЃРёС‚СѓР°С†РёРё РЅСѓР¶РЅРѕ РѕС‚РѕР±СЂР°Р·РёС‚СЊ РґРёР°Р»РѕРі РІС‹Р±РѕСЂР° РєРѕРјРїР»РµРєС‚Р°С†РёР№
     *
     * @param button
     */
    needShowSelectMultiofferDialog(button)
    {
        if (!button.dataset.selectMultiofferHref) return false;
        let showOffersInListThemeOption = button.closest('[data-sol]');
        return !showOffersInListThemeOption || !window.matchMedia('(min-width: 992px)').matches;
    }

    /**
     * Р’С‹РїРѕР»РЅСЏРµС‚ Р·Р°РїСЂРѕСЃ Р·Р° СЃРµСЂРІРµСЂ
     * @param url
     * @param formData
     * @param noShowModalCartClass
     */
    requestToCart(url, formData, noShowModalCart) {
        this.utils.fetchJSON(url, {
            method:'POST',
            body: formData
        }).then((response) =&gt; {
            this.updateCartBlock(response);
            if (!noShowModalCart) {
                this.plugins.modal.open(response.html, (event) =&gt; {
                    this.initCart(event.target);
                });
            }
        });
    }

    /**
     * РРЅРёС†РёР°Р»РёР·РёСЂСѓРµС‚ СЃРѕР±С‹С‚РёСЏ РІРЅСѓС‚СЂРё РєРѕСЂР·РёРЅС‹
     *
     * @param context
     */
    initCart(context) {
        this.cartPage = context.querySelector(this.settings.cartPage);

        if (this.cartPage) {
            this.utils.on('change', this.settings.cartAmountField, event =&gt; this.refresh(), this.cartPage);
            this.utils.on('click', this.settings.cartItemRemove, event =&gt; this.removeProduct(event), this.cartPage);
            this.utils.on('click', this.settings.cartItemRemoveConcomitant, event =&gt; this.removeConcomitant(event), this.cartPage);
            this.utils.on('change', this.settings.cartConcomitantCheckbox, () =&gt; this.refresh(), this.cartPage);
            this.utils.on('click', this.settings.cartGoBackButton, () =&gt; this.goBack(), this.cartPage);
            this.utils.on('change', this.settings.cartItemOffer, () =&gt; this.refresh(), this.cartPage);
            this.utils.on('change', this.settings.cartItemMultiOffer, (event) =&gt; this.changeMultiOffer(event), this.cartPage);
            this.utils.on('click', this.settings.cartClean, event =&gt; this.cleanCart(event), this.cartPage);
            this.utils.on('click', this.settings.cartApplyCoupon, () =&gt; this.refresh(), this.cartPage);

            let form = this.cartPage.querySelector(this.settings.cartForm);
            if (form) {
                form.addEventListener('submit', (event) =&gt; {
                    clearTimeout(this.cartPage.changeTimer);
                    this.refresh();
                    event.preventDefault();
                });
            }
        }
    }

    /**
     *
     * @param context
     */
    getCurrentValueMatrix(context) {
        let multiofferValues = [];

        context.querySelectorAll('[data-prop-title]').forEach(element =&gt; {
            multiofferValues.push([element.dataset.propTitle, element.value]);
        });

        return multiofferValues;
    }

    changeMultiOffer(event) {
        let context = event.target.closest(this.settings.cartItem);
        let values = this.getCurrentValueMatrix(context);

        let hiddenOffers = context.querySelectorAll(this.settings.cartItemHiddenOffers);
        let offerInput = context.querySelector(this.settings.cartItemOffer);
        console.log(offerInput);

        let foundOfferInput;
        hiddenOffers.forEach(element =&gt; {
            if (element.dataset.info) {
                let info = JSON.parse(element.dataset.info);
                let counter = 0;
                info.forEach(inputPair =&gt; {
                    values.forEach(valuesPair =&gt; {
                        if (inputPair[0] === valuesPair[0]
                            &amp;&amp; inputPair[1] === valuesPair[1]) counter++;
                    });
                });

                if (counter === values.length) {
                    foundOfferInput = element;
                }
            }
        });

        if (foundOfferInput){ //Р•СЃР»Рё РєРѕРјРїР»РµРєС‚Р°С†РёСЏ РЅР°Р№РґРµРЅР°
            offerInput.value = foundOfferInput.value;
        } else { //Р•СЃР»Рё РЅРµ РЅР°Р№РґРµРЅР° РєРѕРјРїР»РµРєС‚Р°С†РёСЏ, РІС‹Р±РµСЂРµРј РЅСѓР»РµРІСѓСЋ
            offerInput.value = 0;
        }

        this.refresh();
    }

    /**
     * РЈРґР°Р»СЏРµС‚ РѕРґРёРЅ С‚РѕРІР°СЂ РёР· РєРѕСЂР·РёРЅС‹
     *
     * @param event
     */
    removeProduct(event) {
        event.preventDefault();
        if (!this.isLoading()) {
            let removeButton = event.rsTarget;
            let cartItem = removeButton.closest(this.settings.cartItem);
            if (cartItem) {
                cartItem.style.opacity = 0.5;
                let other = cartItem.parentNode.querySelectorAll('[data-id="' + cartItem.dataset.productId + '"]');

                if (!other.length) {
                    document.querySelectorAll(
                        this.settings.productWrapper + '[data-id="' + cartItem.dataset.productId + '"] ' + this.settings.addToCart)
                        .forEach(element =&gt; {
                            element.classList.remove(this.settings.alreadyInCartClass);
                        });
                }
            }

            this.refresh(removeButton.getAttribute('href'));
        }
    }

    /**
     * РћР±РЅРѕРІР»СЏРµС‚ РєРѕСЂР·РёРЅСѓ
     *
     * @param url
     * @param callback
     */
    refresh(url, callback) {

        let cartForm = this.cartPage.querySelector(this.settings.cartForm);
        let formData = new FormData(cartForm);

        if (!url) {
            url = cartForm.getAttribute('action');
        }

        cartForm.querySelectorAll('input, select, button').forEach(element =&gt; {
            element.disabled = true;
        });

        this.showLoading();
        this.utils.fetchJSON(url, {
            method:'POST',
            body: formData
        }).then(response =&gt; {
            if (response.redirect) {
                location.href = response.redirect;
            }

            if (response.cart.items_count === 0 &amp;&amp; this.plugins.modal.isOpen()) {
                this.plugins.modal.close();
            } else {
                let tmpDiv = document.createElement('div');
                tmpDiv.innerHTML = response.html;
                let element = tmpDiv.querySelector(this.settings.cartPage);
                if (element) {
                    this.cartPage.insertAdjacentElement('afterend', element);
                    let parent = this.cartPage.parentNode;
                    this.cartPage.remove();
                    this.initCart(parent);
                    parent.dispatchEvent(new CustomEvent('new-content', {bubbles: true}));
                    parent.dispatchEvent(new CustomEvent('cart.change', {"bubbles": true, "cancelable": true}));
                }
            }
            this.updateCartBlock(response);
            if (callback) callback(response);
        });
    }

    /**
     * РћР±РЅРѕРІР»СЏРµС‚ РїР°СЂР°РјРµС‚СЂС‹
     *
     * @param response
     */
    updateCartBlock(response) {
        if (response) {
            global.cartProducts = response.cart.session_cart_products;
            document.querySelectorAll(this.settings.cartBlock).forEach((cartBlock) =&gt; {

                let totalItems = cartBlock.querySelector(this.settings.cartTotalItems);
                let totalPrice = cartBlock.querySelector(this.settings.cartTotalPrice);
                let checkoutButton = cartBlock.querySelector(this.settings.checkoutButton);

                totalItems &amp;&amp; (totalItems.innerText = response.cart.items_count);
                totalPrice &amp;&amp; (totalPrice.innerText = response.cart.total_price);

                if (checkoutButton) {
                    if (response.cart.can_checkout &amp;&amp; parseFloat(response.cart.items_count) &gt; 0) {
                        checkoutButton.classList.add(this.settings.checkoutButtonActiveClass);
                    } else {
                        checkoutButton.classList.remove(this.settings.checkoutButtonActiveClass);
                    }
                }

                if (parseFloat(response.cart.items_count) &gt; 0) {
                    cartBlock.classList.add(this.settings.cartActiveClass);
                } else {
                    cartBlock.classList.remove(this.settings.cartActiveClass);
                }
                cartBlock.dispatchEvent(new CustomEvent('cartblock.update', {"bubbles": true, "cancelable": true}));
            });
        }
    }

    /**
     * РџРѕРєР°Р· Р·Р°РіСЂСѓР·РєРё
     */
    showLoading() {
        this.cartPage.classList.add(this.settings.inLoadingClass);
    }

    /**
     * Р’РѕР·РІСЂР°С‰Р°РµС‚ true, РµСЃР»Рё РІ РЅР°СЃС‚РѕСЏС‰РµРµ РІСЂРµРјСЏ РёРґРµС‚ Р·Р°РіСЂСѓР·РєР°
     *
     * @returns {boolean}
     */
    isLoading() {
        return this.cartPage.classList.contains(this.settings.inLoadingClass);
    }

    /**
     * РЎРѕР±РёСЂР°РµС‚ РїР°СЂР°РјРµС‚СЂС‹ С‚РѕРІР°СЂР°, РєРѕС‚РѕСЂС‹Р№ Р±СѓРґРµС‚ РґРѕР±Р°РІР»РµРЅ РІ РєРѕСЂР·РёРЅСѓ
     *
     * @param context
     */
    getProductParams(context) {
        let data = new FormData();
        if (context) {
            let radioInput = context.querySelector(this.settings.offerFormName + ':checked');
            let hiddenInput = context.querySelector(this.settings.offerFormName);
            let offerId = radioInput ? radioInput.value : (hiddenInput ? hiddenInput.value : 0);

            //РљРѕРјРїР»РµРєС‚Р°С†РёСЏ
            if (offerId) {
                data.append('offer', offerId);
            }

            //РљРѕР»РёС‡РµСЃС‚РІРѕ
            let amountElement = context.querySelector(this.settings.amountFormName);
            let amount = amountElement &amp;&amp; amountElement.value;
            if (amount) {
                data.append('amount', amount);
            }

            //РњРЅРѕРіРѕРјРµСЂРЅС‹Рµ РєРѕРјРїР»РµРєС‚Р°С†РёРё
            context.querySelectorAll(this.settings.multiOfferFormName + ':checked').forEach(element =&gt; {
                data.append(element.getAttribute('name'), element.value);
            });

            //РЎРѕРїСѓС‚СЃС‚РІСѓСЋС‰РёРµ С‚РѕРІР°СЂС‹
            context.querySelectorAll(this.settings.concomitantFormName + ':checked').forEach(element =&gt; {
                data.append(element.getAttribute('name'), element.value);
            });
        }

        data.append('floatCart', 1); //РЎРѕРѕР±С‰Р°РµРј, С‡С‚Рѕ РІРѕР·РІСЂР°С‰Р°С‚СЊ РЅР°РґРѕ СѓРїСЂРѕС‰РµРЅРЅСѓСЋ РєРѕСЂР·РёРЅСѓ

        return data;
    }

    /**
     * РР·РјРµРЅСЏРµС‚ РЅР°РґРїРёСЃСЊ РЅР° РєРЅРѕРїРєРµ, РїСЂРё РґРѕР±Р°РІР»РµРЅРёРё РІ РєРѕСЂР·РёРЅСѓ
     *
     * @param button
     */
    changeStateToAdded(button) {
        if (button.timeoutText) {
            clearTimeout(button.timeoutText);
        }

        let buttonSpan = button.querySelector('span');

        button.classList.add(this.settings.alreadyInCartClass);
        if (!button.dataset.storedText &amp;&amp; button.dataset.addText) {
            button.dataset.storedText = buttonSpan.innerHTML;
            buttonSpan.innerHTML = button.dataset.addText;
        }

        if (this.settings.alreadyInCartClassTimeout) {
            button.timeoutText = setTimeout(() =&gt; {
                button.classList.remove(this.settings.alreadyInCartClass);
                if (button.dataset.storedText) {
                    buttonSpan.innerHTML = button.dataset.storedText;
                    delete button.dataset.storedText;
                }
            }, this.settings.alreadyInCartClassTimeout * 1000);
        }
    }

    cleanCart(event) {
        event.preventDefault();
        document.querySelectorAll(this.settings.productWrapper + '[data-id] ' + this.settings.addToCart)
            .forEach((element) =&gt; {
                element.classList.remove(this.settings.alreadyInCartClass)
            });

        this.refresh(event.rsTarget.getAttribute('href'));
    }

    /**
     * Р’РѕР·РІСЂР°С‰Р°РµС‚ РїРѕР»СЊР·РѕРІР°С‚РµР»СЏ РЅР°Р·Р°Рґ Рє РїРѕРєСѓРїРєР°Рј
     */
    goBack() {
        history.back();
    }

    /**
     * РџСЂРѕРІРµСЂСЏРµС‚ РєРѕСЂР·РёРЅСѓ РЅР° РѕС€РёР±РєРё Рё РµСЃР»Рё РёС… РЅРµС‚, С‚Рѕ РїРµСЂРµРЅР°РїСЂР°РІР»СЏРµС‚
     * РїРѕР»СЊР·РѕРІР°С‚РµР»СЏ РЅР° РѕС„РѕСЂРјР»РµРЅРёРµ Р·Р°РєР°Р·Р°
     * @param event
     */
    checkout(event) {
        if (this.cartPage) {
            let cartForm = this.cartPage.querySelector(this.settings.cartForm);
            let url = cartForm.getAttribute('action');
            let checkoutParam = (url.indexOf('?') &gt; -1 ? '&amp;' : '?') + 'checkout=1';
            this.refresh(url + checkoutParam);
            event.preventDefault();
        }
    }

    onDocumentReady() {
        this.init();
    }

    onContentReady() {
        //РРЅРёС†РёР°Р»РёР·РёСЂСѓРµРј СѓРјРЅС‹Рµ РєРЅРѕРїРєРё РґРѕР±Р°РІР»РµРЅРёСЏ С‚РѕРІР°СЂР° РІ РєРѕСЂР·РёРЅСѓ
        SmartAmount.init();
    }
};



/**
 * ====================================================
 * РљР»Р°СЃСЃ РѕРїРёСЃС‹РІР°РµС‚ СЂР°Р±РѕС‚Сѓ РѕРґРЅРѕР№ СѓРјРЅРѕР№ РєРЅРѕРїРєРё Р’ РєРѕСЂР·РёРЅСѓ
 */
class SmartAmount
{
    constructor(element, settings) {

        let defaults = {
            smartAmount: '.rs-sa',
            smartAmountActiveClass: 'item-product-cart-action_amount',
            smartAmountBuyButton: '.rs-to-cart',
            smartAmountIncButton: '.rs-sa-inc',
            smartAmountDecButton: '.rs-sa-dec',
            smartAmountInput: '.rs-sa-input',
            productContext: '[data-id]',
            delayChangeAmount: 700
        };

        this.settings = {...settings, ...defaults};
        this.smartButton = element;

        this.smartButton.querySelector(this.settings.smartAmountBuyButton)
            .addEventListener('click', event =&gt; this.addProduct(event));

        this.smartButton.querySelector(this.settings.smartAmountIncButton)
            .addEventListener('click', event =&gt; this.incButton(event));

        this.smartButton.querySelector(this.settings.smartAmountDecButton)
            .addEventListener('click', event =&gt; this.decButton(event));

        this.amountInput = this.smartButton.querySelector(this.settings.smartAmountInput);
        this.amountInput.addEventListener('keyup', event =&gt; this.changeAmount(event));
        this.amountInput.addEventListener('blur', event =&gt; this.blur(event));
        this.amountParams = JSON.parse(this.smartButton.dataset.amountParams);

        document.addEventListener('cart.removeProduct', event =&gt; this.onRemoveProduct(event));

        this.restoreFromCache();
    }

    restoreFromCache() {
        let productId = this.smartButton.closest(this.settings.productContext).dataset.id;
        if (global.cartProducts) {
            let numList = global.cartProducts[productId];
            if (numList) {
                let total = 0;
                for (let num in numList) {
                    total = total + numList[num];
                }
                this.amountInput.value = total;
                this.smartButton.classList.add(this.settings.smartAmountActiveClass);
            } else {
                this.amountInput.value = 0;
                this.smartButton.classList.remove(this.settings.smartAmountActiveClass);
            }
        }
    }

    onRemoveProduct(event) {
        let productId = this.smartButton.closest(this.settings.productContext).dataset.id;
        if (event.detail.productId === productId) {
            this.amountInput.value = 0;
            this.amountInput.dispatchEvent(new CustomEvent('keyup', {
                bubbles: true,
                detail: {
                    noRefreshCart: true
                }
            }));
        }
    }

    /**
     * Р”РѕР±Р°РІР»СЏРµС‚ С‚РѕРІР°СЂ РІ РєРѕСЂР·РёРЅСѓ, РїРµСЂРµРєР»СЋС‡Р°РµС‚ СЃРѕСЃС‚РѕСЏРЅРёРµ РєРЅРѕРїРєРё РЅР° РєРѕР»РёС‡РµСЃС‚РІРѕ
     */
    addProduct() {
        this.amountInput.value = this.amountParams.amountAddToCart;
        this.smartButton.classList.add(this.settings.smartAmountActiveClass);
        this.smartButton.dispatchEvent(new CustomEvent('add-product', {bubbles: true}));
    }

    /**
     * РЈРІРµР»РёС‡РёРІР°РµС‚ РєРѕР»РёС‡РµСЃС‚РІРѕ С‚РѕРІР°СЂР° РІ РєРѕСЂР·РёРЅРµ
     */
    incButton() {
        let oldValue = parseFloat(this.amountInput.value);
        let newValue = Math.round((oldValue + this.amountParams.amountStep) * 1000) / 1000;
        let breakpoint = parseFloat(this.amountParams.amountBreakPoint);

        if (newValue &lt; this.amountParams.minAmount) {
            newValue = this.amountParams.minAmount;
        }
        if (oldValue &lt; breakpoint &amp;&amp; newValue &gt; breakpoint) {
            newValue = breakpoint;
        }
        if (this.amountParams.maxAmount !== null &amp;&amp; newValue &gt; this.amountParams.maxAmount) {
            newValue = this.amountParams.maxAmount;
            this.smartButton.dispatchEvent(new CustomEvent('max-limit', {bubbles:true}));
        } else {
            this.smartButton.dispatchEvent(new CustomEvent('increase-amount', {bubbles:true}));
        }
        this.amountInput.value = newValue;
        this.amountInput.dispatchEvent(new Event('keyup', {bubbles: true}));
    }

    /**
     * РЈРјРµРЅСЊС€Р°РµС‚ РєРѕР»РёС‡РµСЃС‚РІРѕ С‚РѕРІР°СЂР° РІ РєРѕСЂР·РёРЅРµ
     */
    decButton() {

        let oldValue = parseFloat(this.amountInput.value);
        let newValue = Math.round((oldValue - this.amountParams.amountStep) * 1000) / 1000;
        let breakpoint = parseFloat(this.amountParams.amountBreakPoint);

        if (newValue &lt; this.amountParams.minAmount) {
            newValue = 0;
        }

        if (oldValue &gt; breakpoint &amp;&amp; newValue &lt; breakpoint) {
            newValue = breakpoint;
        }

        if (newValue != 0 || !this.amountParams.forbidRemoveProducts) {
            this.smartButton.dispatchEvent(new CustomEvent('decrease-amount', {bubbles:true}));
            this.amountInput.value = newValue;
            this.amountInput.dispatchEvent(new Event('keyup', {bubbles: true}));
        }

        return false;
    }

    /**
     * РР·РјРµРЅСЏРµС‚ РєРѕР»РёС‡РµСЃС‚РІРѕ С‚РѕРІР°СЂР° РЅР° РІРІРµРґРµРЅРЅРѕРµ РІСЂСѓС‡РЅСѓСЋ
     */
    changeAmount(event) {
        clearTimeout(this.changeTimeout);
        this.changeTimeout = setTimeout(() =&gt; {
            let noChangesKeycodes = [16, 17, 18, 35, 36, 37, 39];
            if (noChangesKeycodes.includes(event.keyCode)) {
                return false;
            }

            let amount = this.amountInput.value;

            if (amount === '') {
                return false;
            }

            if (this.amountParams.maxAmount !== null &amp;&amp; amount &gt; parseFloat(this.amountParams.maxAmount)) {
                amount = this.amountParams.maxAmount;
                this.amountInput.value = amount;
                this.smartButton.dispatchEvent(new CustomEvent('max-limit', {bubbles: true}));
            }

            if (amount == 0) {
                this.smartButton.classList.remove(this.settings.smartAmountActiveClass);
                this.smartButton.dispatchEvent(new CustomEvent('remove-product', {bubbles: true}));
            }

            if (!event.detail || !event.detail.noRefreshCart) {
                let formData = new FormData();
                formData.append('id', this.smartButton.closest(this.settings.productContext).dataset.id);
                formData.append('amount', amount);

                RsJsCore.utils.fetchJSON(this.smartButton.dataset.url, {
                    method: 'post',
                    body: formData
                }).then(response =&gt; {
                    if (response.success) {
                        // РћР±РЅРѕРІР»СЏРµРј РєРѕСЂР·РёРЅСѓ РЅР° СЌРєСЂР°РЅРµ
                        RsJsCore.components.cart.updateCartBlock(response);
                    }
                });
            }
        }, this.settings.delayChangeAmount);
    }

    blur() {
        if (this.amountInput.value === '') {
            this.amountInput.value = 0;
            this.amountInput.dispatchEvent(new Event('keyup', {bubbles: true}));
        }
    }

    static init(selector) {
        document.querySelectorAll(selector ? selector : '.rs-sa').forEach(element =&gt; {
            if (!element.smartAmount) {
                element.smartAmount = new SmartAmount(element);
            }
        });
    }
};</pre></body></html>