{
  "version": 3,
  "sources": ["/cdn/shop/t/35/assets/custom.js?cb681802=1"],
  "sourcesContent": ["\n    var host = window.location.host;\n    var sub = host.split('.')[0];\n\tif(sub == 'trial50') { \n        document.location.href = 'https://natureszestnutrition.com/pages/promotional-lp';\n    }\n\n\nwindow.onload = function() {\n        var elementToMove = document.querySelector('.slp-content'); \n        var targetLocation = document.querySelector('.loyaltyprogram-container');\n\n        if (elementToMove && targetLocation) {\n            targetLocation.appendChild(elementToMove);\n        } else {\n            console.error('Element or target location not found');\n        }\n    };\n\n\n\ndocument.addEventListener('DOMContentLoaded', function() {\n  const buyAgainButtons = document.querySelectorAll('.buyagain-cart');\n\n  buyAgainButtons.forEach(function(button) {\n    button.addEventListener('click', function() {\n      const variantId = this.getAttribute('data-variant-id');\n      addToCart(variantId);\n    });\n  });\n\n  function addToCart(variantId) {\n    fetch('/cart/add.js', {\n      method: 'POST',\n      headers: {\n        'Content-Type': 'application/json',\n      },\n      body: JSON.stringify({\n        items: [{\n          id: variantId,\n          quantity: 1\n        }]\n      })\n    })\n    .then(response => {\n      if (response.ok) {\n        // Redirect to the cart page\n        window.location.href = '/cart';\n      } else {\n        throw new Error('Failed to add item to cart');\n      }\n    })\n    .catch((error) => {\n      console.error('Error:', error);\n      // Handle error (e.g., show an error message)\n    });\n  }\n});\n\n\n\n\n\ndocument.addEventListener('DOMContentLoaded', function() {\n    // Function to process added elements\n    function processElements() {\n        var zeroPriceElement = document.querySelectorAll('.appstle_cart_sellingPlan_price');\n        zeroPriceElement.forEach(function(el) {\n            var zeroPriceElementText = el.textContent.replace(\"\u00A3\",\"\");\n            var zeroPriceElementNumber = parseInt(zeroPriceElementText, 10);\n            if(zeroPriceElementNumber == 0) {\n                var zeroPriceElementParent = el.closest(\"div\").parentElement;\n                var quantitySelector = zeroPriceElementParent.previousElementSibling;\n                quantitySelector.classList.add(\"zero-price\");\n                quantitySelector.style.pointerEvents = \"none\";\n                \n                // Adjust the quantity for zero-priced items\n                adjustQuantityForZeroPricedItems(quantitySelector);\n            }      \n        });\n    }\n\n    // New function to adjust quantity for zero-priced items\n    function adjustQuantityForZeroPricedItems(quantitySelector) {\n        var quantityInput = quantitySelector.querySelector('input[type=\"number\"]');\n        if (quantityInput && parseInt(quantityInput.value, 10) > 1) {\n            quantityInput.value = 1; // Set quantity back to 1\n        }\n    }\n\n    // Function to revert pointer events to \"auto\" for quantitySelectors when applicable\n    function revertPointerEvents() {\n        var moneyElements = document.querySelectorAll('.money');\n        moneyElements.forEach(function(el) {\n            var quantitySelector = el.closest(\"div\").parentElement.previousElementSibling;\n            if (quantitySelector && quantitySelector.classList.contains(\"zero-price\")) {\n                quantitySelector.style.pointerEvents = \"auto\";\n                quantitySelector.classList.remove(\"zero-price\");\n            }\n        });\n    }\n\n    function mutationCallback(mutationsList, observer) {\n        for(let mutation of mutationsList) {\n            if(mutation.type === 'childList') {\n                mutation.addedNodes.forEach(node => {\n                    if(node.nodeType === Node.ELEMENT_NODE) {\n                        if(node.matches('.appstle_cart_sellingPlan_price') || node.querySelector('.appstle_cart_sellingPlan_price')) {\n                            processElements();\n                        }\n                        if(node.matches('.money') || node.querySelector('.money')) {\n                            revertPointerEvents();\n                        }\n                    }\n                });\n                mutation.removedNodes.forEach(node => {\n                    if(node.nodeType === Node.ELEMENT_NODE) {\n                        if(node.matches('.appstle_cart_sellingPlan_price') || node.closest('.appstle_cart_sellingPlan_price')) {\n                            revertPointerEvents();\n                        }\n                    }\n                });\n            }\n        }\n    }\n\n    var observer = new MutationObserver(mutationCallback);\n    var config = { childList: true, subtree: true };\n    observer.observe(document.body, config);\n\n    // Initial processing\n    processElements();\n    function PromotionalItemQtyDisable() {\n      let promotionalElement = document.querySelector('li[data-cartitem-id=\"45064186888460\"');\n      if(promotionalElement) {\n        let qtyBox = promotionalElement.querySelector('.cart-item__quantity');\n        qtyBox.classList.add(\"zero-price\");\n        qtyBox.style.pointerEvents = \"none\";\n      }\n    }\n    PromotionalItemQtyDisable();\n});\n\n\n"],
  "m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