{"version":3,"file":"modernProductDetails.js","names":["document","addEventListener","attributeSelect","selectedValueUrl","$productContainer","$","trigger","url","container","ajax","method","success","data","response","isVaraint","isChoiceOfBonusProducts","parents","length","product","variationAttributes","attrs","msgs","attrsWithSwatches","forEach","attr","indexOf","id","values","attrValue","$attrValue","find","value","$swatchButton","parent","selected","addClass","siblings","text","assistiveSelectedText","removeClass","empty","removeAttr","selectable","processSwatchValues","$attr","$defaultOption","resetUrl","processNonSwatchValues","updateAttrs","resources","productType","readyToOrder","imgs","carousel","carouselId","append","i","alt","parseInt","index","title","appendTo","first","detach","createCarousel","images","large","replaceWith","price","html","promotionsHtml","availabilityValue","availabilityMessages","availability","messages","message","info_selectforstock","updateAvailability","attributes","attributeGroup","ID","attribute","label","getAttributesHtml","handleVariantResponse","optionsHtml","updateOptions","quantities","map","quantity","join","getQuantitySelector","updateQuantities","querySelectorAll","element","closest","isDisabled","hasAttribute","style","opacity","pointerEvents","cursor","parentColorDisabled","classList","contains","emblem","Imagewrappercontainer","querySelector","upButton","downButton","add","remove","firstChild","removeChild","wrapper","createElement","transform","image","div","border","setAttribute","img","src","mixBlendMode","appendChild","productImages","imageContainer","imageSelected","this","getAttribute","attachImageListeners","updateImage","spinner","stop","error","$el","quantitySelected","quantitySelectedModal","quantitySelectedPDP","undefined","val","getChildProducts","childProducts","each","push","pid","JSON","stringify","getOptions","options","$elOption","urlValue","selectedValueId","optionId","toArray","on","e","eq","dataUrl","editPid","URLSearchParams","window","location","search","get","css","selectedVariant","inCart","err","console","click","scrollTop","engravingline","input","idType","trim","editProductID","key","type","redirectUrl","sessionStorage","setItem","productId","href","xhr","status","log","preventDefault","currentTarget","addToCartUrl","pidsObj","setPids","hasClass","qty","getPidValue","form","messageType","newBonusDiscountLineItem","Object","keys","start","bonusUrl","bonusChoiceRuleBased","showProductsUrlRuleBased","showProductsUrlListBased","htmlString","maxBonusItems","uuid","pliUUID","pageSize","labels","selectprods","dataType","parsedHtml","parseHtml","renderedTemplate","enterDialogMessage","closeButtonText","body","footer","modal","chooseBonusProducts","setTimeout","handlePostCartAdd","reportingURL","animate","offset","top","cartURL"],"sources":["product/modernProductDetails.js"],"sourcesContent":["document.addEventListener(\"DOMContentLoaded\", function() {\n\n    function getLinkedVariantImage(params) {\n        $.ajax({\n            url:     params,\n            method:  \"GET\",\n            success: function(data) {\n                if (data.product.images.emblem && data.product.images.emblem.length > 0) {\n                    document.getElementById(\"emblemEngrave\").src = data.product.images.emblem[0].url;\n                }\n                // $(\".pdpLoader\").hide();\n            },\n            error: function() {\n                $.spinner().stop();\n            }\n        });\n    }\n    /**\n   * updates the product view when a product attribute is selected or deselected or when\n   *         changing quantity\n   * @param {string} selectedValueUrl - the Url for the selected variation value\n   * @param {jQuery} $productContainer - DOM element for current product\n   */\n    function attributeSelect(selectedValueUrl, $productContainer) {\n        // $(\".pdpLoader\").show();\n        if (selectedValueUrl) {\n            $(\"body\").trigger(\"product:beforeAttributeSelect\", {\n                url:       selectedValueUrl,\n                container: $productContainer\n            });\n\n            $.ajax({\n                url:     selectedValueUrl,\n                method:  \"GET\",\n                success: function(data) {\n                    handleVariantResponse(data, $productContainer);\n                    updateOptions(data.product.optionsHtml, $productContainer);\n                    updateQuantities(data.product.quantities, $productContainer);\n                    hideDisabledAttributes();\n                    updateImage(data.product.images.large, data.product.images.emblem);\n                    $(\"body\").trigger(\"product:afterAttributeSelect\", {\n                        data:      data,\n                        container: $productContainer\n                    });\n                    $.spinner().stop();\n                    // $(\".pdpLoader\").hide();\n                },\n                error: function() {\n                    $.spinner().stop();\n                }\n            });\n        }\n    }\n\n    function attachImageListeners() {\n        const imagesWrapper = document.querySelector(\".images-wrapper\");\n        const productImages = imagesWrapper.querySelectorAll(\n            \".product-colors-image\"\n        );\n\n        // Handle product image selection\n        productImages.forEach(function(imageContainer) {\n            imageContainer.addEventListener(\"click\", function() {\n                // Update selected image\n                const imageSelected = this.querySelector(\"img\").getAttribute(\"src\");\n                document\n                    .querySelector(\".Product-image img\")\n                    .setAttribute(\"src\", imageSelected);\n\n                // Remove border from all images\n                productImages.forEach(function(img) {\n                    img.classList.remove(\"product-colors-image-border\");\n                });\n                // Add border to the selected image\n                this.classList.add(\"product-colors-image-border\");\n            });\n        });\n    }\n\n    function updateImage(images, emblem) {\n        if (emblem && emblem.length > 0 && emblem[0].url) {\n            $(\"#emblemQr\").attr(\"src\", emblem[0].url);\n        }\n        // Select the existing image wrapper container\n        const Imagewrappercontainer = document.querySelector(\n            \".images-wrapper-container\"\n        );\n        const upButton = document.querySelector(\".up-button\");\n        const downButton = document.querySelector(\".down-button\");\n        if (images.length <= 5) {\n            if (upButton) upButton.classList.add(\"d-none\");\n            if (downButton) downButton.classList.add(\"d-none\");\n        } else {\n            if (upButton) upButton.classList.remove(\"d-none\");\n            if (downButton) downButton.classList.remove(\"d-none\");\n        }\n\n        // Remove all existing images\n        while (Imagewrappercontainer.firstChild) {\n            Imagewrappercontainer.removeChild(Imagewrappercontainer.firstChild);\n        }\n\n        // Create the new wrapper element\n        const wrapper = document.createElement(\"div\");\n        wrapper.classList.add(\"images-wrapper\");\n        wrapper.style.transform = \"translateY(0px)\";\n\n        // Loop through the images array and create elements dynamically\n        images.forEach(function(image) {\n            const div = document.createElement(\"div\");\n            div.classList.add(\"product-colors-image\");\n            if (image.border) {\n                div.classList.add(\"product-colors-image-border\");\n            }\n            div.setAttribute(\"role\", \"listbox\");\n\n            const img = document.createElement(\"img\");\n            img.src = image.url;\n            img.alt = image.alt;\n            img.classList.add(\"p-image\");\n            img.setAttribute(\"itemprop\", \"image\");\n            img.style.mixBlendMode = \"darken\";\n\n            div.appendChild(img);\n            wrapper.appendChild(div);\n        });\n\n        // Append the new wrapper to the Imagewrappercontainer\n        Imagewrappercontainer.appendChild(wrapper);\n        attachImageListeners();\n    }\n\n    function hideDisabledAttributes() {\n    // Hide and disable sizes which is not available\n        document\n            .querySelectorAll(\".size-custom-attribute\")\n            .forEach(function(element) {\n                var parent = element.closest(\".customize-size-container\");\n                if (!parent) return;\n\n                const isDisabled = element.hasAttribute(\"disabled\");\n                parent.style.opacity = isDisabled ? \"0.5\" : \"\";\n                parent.style.pointerEvents = isDisabled ? \"none\" : \"\";\n                parent.style.cursor = isDisabled ? \"not-allowed\" : \"\";\n            });\n\n        // Hide and disable color options which is not available\n        document.querySelectorAll('.customize-color-container').forEach(function(parent) {\n            const parentColorDisabled = parent.classList.contains('unselectable');\n            if (!parent) return;\n            parent.style.opacity = parentColorDisabled ? '0.5' : '';\n            parent.style.pointerEvents = parentColorDisabled ? 'none' : '';\n            parent.style.cursor = parentColorDisabled ? 'not-allowed' : '';\n        });\n    }\n\n    /**\n   * @typedef OptionSelectionResponse\n   * @type Object\n   * @property {string} priceHtml - Updated price HTML code\n   * @property {Object} options - Updated Options\n   * @property {string} options.id - Option ID\n   * @property {UpdatedOptionValue[]} options.values - Option values\n   */\n\n    /**\n   * Updates DOM using post-option selection Ajax response\n   *\n   * @param {OptionSelectionResponse} optionsHtml - Ajax response optionsHtml from selecting a product option\n   * @param {jQuery} $productContainer - DOM element for current product\n   */\n    function updateOptions(optionsHtml, $productContainer) {\n    // Update options\n        $productContainer.find(\".product-options\").empty().html(optionsHtml);\n    }\n\n    /**\n   * @typespec UpdatedQuantity\n   * @type Object\n   * @property {boolean} selected - Whether the quantity has been selected\n   * @property {string} value - The number of products to purchase\n   * @property {string} url - Compiled URL that specifies variation attributes, product ID, options,\n   *     etc.\n   */\n\n    /**\n   * Updates the quantity DOM elements post Ajax call\n   * @param {UpdatedQuantity[]} quantities -\n   * @param {jQuery} $productContainer - DOM container for a given product\n   */\n    function updateQuantities(quantities, $productContainer) {\n        if ($productContainer.parent(\".bonus-product-item\").length <= 0) {\n            var optionsHtml = quantities\n                .map(function(quantity) {\n                    var selected = quantity.selected ? \" selected \" : \"\";\n                    return (\n                        '<option value=\"' +\n            quantity.value +\n            '\"  data-url=\"' +\n            quantity.url +\n            '\"' +\n            selected +\n            \">\" +\n            quantity.value +\n            \"</option>\"\n                    );\n                })\n                .join(\"\");\n            getQuantitySelector($productContainer).empty().html(optionsHtml);\n        }\n    }\n    /**\n   * Retrieve contextual quantity selector\n   * @param {jquery} $el - DOM container for the relevant quantity\n   * @return {jquery} - quantity selector DOM container\n   */\n    function getQuantitySelector($el) {\n        var quantitySelected;\n        if ($el && $(\".set-items\").length) {\n            quantitySelected = $($el)\n                .closest(\".modern-product-detail\")\n                .find(\".quantity-select\");\n        } else if ($el && $(\".product-bundle\").length) {\n            var quantitySelectedModal = $($el)\n                .closest(\".modal-footer\")\n                .find(\".quantity-select\");\n            var quantitySelectedPDP = $($el)\n                .closest(\".bundle-footer\")\n                .find(\".quantity-select\");\n            if (quantitySelectedModal.val() === undefined) {\n                quantitySelected = quantitySelectedPDP;\n            } else {\n                quantitySelected = quantitySelectedModal;\n            }\n        } else {\n            quantitySelected = $(\".quantity-select\");\n        }\n        return quantitySelected;\n    }\n    /**\n   * Parses JSON from Ajax call made whenever an attribute value is [de]selected\n   * @param {Object} response - response from Ajax call\n   * @param {Object} response.product - Product object\n   * @param {string} response.product.id - Product ID\n   * @param {Object[]} response.product.variationAttributes - Product attributes\n   * @param {Object[]} response.product.images - Product images\n   * @param {boolean} response.product.hasRequiredAttrsSelected - Flag as to whether all required\n   *     attributes have been selected.  Used partially to\n   *     determine whether the Add to Cart button can be enabled\n   * @param {jQuery} $productContainer - DOM element for a given product.\n   */\n    function handleVariantResponse(response, $productContainer) {\n        var isChoiceOfBonusProducts =\n      $productContainer.parents(\".choose-bonus-product-dialog\").length > 0;\n        var isVaraint;\n        if (response.product.variationAttributes) {\n            updateAttrs(\n                response.product.variationAttributes,\n                $productContainer,\n                response.resources\n            );\n            isVaraint = response.product.productType === \"variant\";\n            if (isChoiceOfBonusProducts && isVaraint) {\n                $productContainer\n                    .parent(\".bonus-product-item\")\n                    .data(\"pid\", response.product.id);\n\n                $productContainer\n                    .parent(\".bonus-product-item\")\n                    .data(\"ready-to-order\", response.product.readyToOrder);\n            }\n        }\n\n        // Update primary images\n        var primaryImageUrls = response.product.images.large;\n        createCarousel(primaryImageUrls, $productContainer);\n\n        // Update pricing\n        if (!isChoiceOfBonusProducts) {\n            var $priceSelector = $(\".prices .price\", $productContainer).length\n                ? $(\".prices .price\", $productContainer)\n                : $(\".prices .price\");\n            $priceSelector.replaceWith(response.product.price.html);\n        }\n\n        // Update promotions\n        $productContainer\n            .find(\".promotions\")\n            .empty()\n            .html(response.product.promotionsHtml);\n\n        updateAvailability(response, $productContainer);\n\n        if (isChoiceOfBonusProducts) {\n            var $selectButton = $productContainer.find(\".select-bonus-product\");\n            $selectButton.trigger(\"bonusproduct:updateSelectButton\", {\n                product:           response.product,\n                $productContainer: $productContainer\n            });\n        } else {\n            // Enable \"Add to Cart\" button if all required attributes have been selected\n            $(\n                \"button.add-to-cart, button.add-to-cart-global, button.update-cart-product-global\"\n            )\n                .trigger(\"product:updateAddToCart\", {\n                    product:           response.product,\n                    $productContainer: $productContainer\n                })\n                .trigger(\"product:statusUpdate\", response.product);\n        }\n\n        // Update attributes\n        $productContainer\n            .find(\".main-attributes\")\n            .empty()\n            .html(getAttributesHtml(response.product.attributes));\n    }\n    /**\n   * Generates html for product attributes section\n   *\n   * @param {array} attributes - list of attributes\n   * @return {string} - Compiled HTML\n   */\n    function getAttributesHtml(attributes) {\n        if (!attributes) {\n            return \"\";\n        }\n\n        var html = \"\";\n\n        attributes.forEach(function(attributeGroup) {\n            if (attributeGroup.ID === \"mainAttributes\") {\n                attributeGroup.attributes.forEach(function(attribute) {\n                    html +=\n            '<div class=\"attribute-values\">' +\n            attribute.label +\n            \": \" +\n            attribute.value +\n            \"</div>\";\n                });\n            }\n        });\n\n        return html;\n    }\n    /**\n   * Routes the handling of attribute processing depending on whether the attribute has image\n   *     swatches or not\n   *\n   * @param {Object} attrs - Attribute\n   * @param {string} attr.id - Attribute ID\n   * @param {jQuery} $productContainer - DOM element for a given product\n   * @param {Object} msgs - object containing resource messages\n   */\n    function updateAttrs(attrs, $productContainer, msgs) {\n    // Currently, the only attribute type that has image swatches is Color.\n        var attrsWithSwatches = [\"color\"];\n\n        attrs.forEach(function(attr) {\n            if (attrsWithSwatches.indexOf(attr.id) > -1) {\n                processSwatchValues(attr, $productContainer, msgs);\n            } else {\n                processNonSwatchValues(attr, $productContainer);\n            }\n        });\n    }\n    /**\n   * Process attribute values associated with an attribute that does not have image swatches\n   *\n   * @param {Object} attr - Attribute\n   * @param {string} attr.id - Attribute ID\n   * @param {Object[]} attr.values - Array of attribute value objects\n   * @param {string} attr.values.value - Attribute coded value\n   * @param {string} attr.values.url - URL to de/select an attribute value of the product\n   * @param {boolean} attr.values.isSelectable - Flag as to whether an attribute value can be\n   *     selected.  If there is no variant that corresponds to a specific combination of attribute\n   *     values, an attribute may be disabled in the Product Detail Page\n   * @param {jQuery} $productContainer - DOM container for a given product\n   */\n    function processNonSwatchValues(attr, $productContainer) {\n        var $attr = '[data-attr=\"' + attr.id + '\"]';\n        var $defaultOption = $productContainer.find($attr + \" .select-\" + attr.id);\n        $defaultOption.attr(\"data-url\", attr.resetUrl);\n\n        attr.values.forEach(function(attrValue) {\n            var $attrValue = $productContainer.find(\n                $attr + ' [data-attr-value=\"' + attrValue.value + '\"]'\n            );\n            $attrValue.attr(\"data-url\", attrValue.url).removeAttr(\"disabled\");\n\n            if (!attrValue.selectable) {\n                $attrValue.attr(\"disabled\", true);\n            }\n        });\n    }\n    /**\n   * Process the attribute values for an attribute that has image swatches\n   *\n   * @param {Object} attr - Attribute\n   * @param {string} attr.id - Attribute ID\n   * @param {Object[]} attr.values - Array of attribute value objects\n   * @param {string} attr.values.value - Attribute coded value\n   * @param {string} attr.values.url - URL to de/select an attribute value of the product\n   * @param {boolean} attr.values.isSelectable - Flag as to whether an attribute value can be\n   *     selected.  If there is no variant that corresponds to a specific combination of attribute\n   *     values, an attribute may be disabled in the Product Detail Page\n   * @param {jQuery} $productContainer - DOM container for a given product\n   * @param {Object} msgs - object containing resource messages\n   */\n    function processSwatchValues(attr, $productContainer, msgs) {\n        attr.values.forEach(function(attrValue) {\n            var $attrValue = $productContainer.find(\n                '[data-attr=\"' +\n          attr.id +\n          '\"] [data-attr-value=\"' +\n          attrValue.value +\n          '\"]'\n            );\n            var $swatchButton = $attrValue.parent();\n\n            if (attrValue.selected) {\n                $attrValue.addClass(\"selected\");\n                $attrValue\n                    .siblings(\".selected-assistive-text\")\n                    .text(msgs.assistiveSelectedText);\n            } else {\n                $attrValue.removeClass(\"selected\");\n                $attrValue.siblings(\".selected-assistive-text\").empty();\n            }\n\n            if (attrValue.url) {\n                $swatchButton.attr(\"data-url\", attrValue.url);\n            } else {\n                $swatchButton.removeAttr(\"data-url\");\n            }\n\n            // Disable if not selectable\n            $attrValue.removeClass(\"selectable unselectable\");\n\n            $attrValue.addClass(attrValue.selectable ? \"selectable\" : \"unselectable\");\n        });\n    }\n    /**\n   * Dynamically creates Bootstrap carousel from response containing images\n   * @param {Object[]} imgs - Array of large product images,along with related information\n   * @param {jQuery} $productContainer - DOM element for a given product\n   */\n    function createCarousel(imgs, $productContainer) {\n        var carousel = $productContainer.find(\".carousel\");\n        $(carousel).carousel(\"dispose\");\n        var carouselId = $(carousel).attr(\"id\");\n        $(carousel)\n            .empty()\n            .append(\n                '<div class=\"carousel-inner\" role=\"listbox\"  style=\"mix-blend-mode: darken;\"></div>'\n            );\n        for (var i = 0; i < imgs.length; i++) {\n            $(\n                '<div class=\"carousel-item\"><img src=\"' +\n          imgs[i].url +\n          '\" class=\"d-block img-fluid\" alt=\"' +\n          imgs[i].alt +\n          \" image number \" +\n          parseInt(imgs[i].index, 10) +\n          '\" title=\"' +\n          imgs[i].title +\n          '\" itemprop=\"image\" /></div>'\n            ).appendTo($(carousel).find(\".carousel-inner\"));\n            $(\n                '<li data-target=\"#' +\n          carouselId +\n          '\" data-slide-to=\"' +\n          i +\n          '\" class=\"\"></li>'\n            ).appendTo($(carousel).find(\".carousel-indicators\"));\n        }\n        $($(carousel).find(\".carousel-item\")).first().addClass(\"active\");\n        $($(carousel).find(\".carousel-indicators > li\")).first().addClass(\"active\");\n        if (imgs.length === 1) {\n            $(\n                $(carousel).find('.carousel-indicators, a[class^=\"carousel-control-\"]')\n            ).detach();\n        }\n        $(carousel).carousel();\n        $($(carousel).find(\".carousel-indicators\")).attr(\"aria-hidden\", true);\n    }\n\n    /**\n   * Updates the availability status in the Product Detail Page\n   *\n   * @param {Object} response - Ajax response object after an\n   *                            attribute value has been [de]selected\n   * @param {jQuery} $productContainer - DOM element for a given product\n   */\n    function updateAvailability(response, $productContainer) {\n        var availabilityValue = \"\";\n        var availabilityMessages = response.product.availability.messages;\n        if (!response.product.readyToOrder) {\n            availabilityValue =\n        \"<li><div>\" + response.resources.info_selectforstock + \"</div></li>\";\n        } else {\n            availabilityMessages.forEach(function(message) {\n                availabilityValue += \"<li><div>\" + message + \"</div></li>\";\n            });\n        }\n\n        $($productContainer).trigger(\"product:updateAvailability\", {\n            product:           response.product,\n            $productContainer: $productContainer,\n            message:           availabilityValue,\n            resources:         response.resources\n        });\n    }\n    $(\"body\").on(\"product:afterAttributeSelect\", function(e, response) {\n        if ($(\".modern-product-detail>.bundle-items\").length) {\n            response.container.data(\"pid\", response.data.product.id);\n            response.container.find(\".product-id\").text(response.data.product.id);\n        } else if ($(\".product-set-detail\").eq(0)) {\n            response.container.data(\"pid\", response.data.product.id);\n            response.container.find(\".product-id\").text(response.data.product.id);\n        } else {\n            $(\".product-id\").text(response.data.product.id);\n            $('.modern-product-detail:not(\".bundle-item\")').data(\n                \"pid\",\n                response.data.product.id\n            );\n        }\n        var dataUrl = $(\"#selectedVariationURL\").attr(\"data-url\");\n        var urlParams = new URLSearchParams(window.location.search);\n        var editPid = urlParams.get(\"editPid\");\n    \n        if (editPid && editPid === response.data.product.id) {\n            $(\"#customizeid , #customizeidQr\")\n                .text(\"Next\")\n                .css({ opacity: \"1\", \"pointer-events\": \"auto\" });\n            return;\n        }\n    \n        $.ajax({\n            url:     dataUrl,\n            method:  \"POST\",\n            data:    { selectedVariant: response.data.product.id },\n            success: function(response) {\n                if (response.inCart) {\n                    $(\"#customizeid , #customizeidQr\")\n                        .text(\"Already In Your Cart\")\n                        .css({ opacity: \"0.5\", \"pointer-events\": \"none\" });\n                } else {\n                    $(\"#customizeid , #customizeidQr\")\n                        .text(\"Next\")\n                        .css({ opacity: \"1\", \"pointer-events\": \"auto\" });\n                }\n            },\n            error: function(err) {\n                console.error(\"Error fetching product variation:\", err);\n            }\n        });\n    });\n    $(\".bs-canvas-overlay-filter, .offcanvas-close-button\").click(function() {\n        $(\".offcanvas-body\").scrollTop(0);\n    });\n      \n    $('#customizeEngraveid.next-plan').click(function() {\n        var pid = null;\n        $(\".modern-product-detail\").each(function() {\n            pid = $(this).find(\".product-id\").text();\n        });\n        var engravingline = {};\n        $(\"#modern_engraving_form\")\n            .find(\".engraveInput\")\n            .each(function(index, input) {\n                engravingline[('engravingline' + (index + 1))] = $(input).val();\n            });\n        var idType = $('#idType').text().trim();\n        var url = $(\".move-to-plan\").val();\n        var editProductID = $('input[name=\"editProductID\"]').val();\n        var urlParams = new URLSearchParams(window.location.search);\n        var editPid = urlParams.get(\"editPid\");\n        \n        var data = {\n            pid:           pid,\n            editProductID: editProductID,\n            idType:        idType,\n            editPid:       editPid\n        };\n        $.each(engravingline, function(key, value) {\n            data[key] = value;\n        });\n    \n        $.ajax({\n            url:     url,\n            type:    \"POST\",\n            data:    data,\n            success: function(response) {\n                if (response.redirectUrl) {\n                    sessionStorage.setItem('productID', response.productId);\n                    window.location.href = response.redirectUrl;\n                }\n            },\n            error: function(xhr, status, error) {\n                console.log(\"Error:\", error);\n            }\n        });\n    });\n\n    $(document).on(\"click\", '[data-attr=\"color\"] div.color-custom', function(e) {\n        e.preventDefault();\n\n        if ($(this).attr(\"disabled\")) {\n            return;\n        }\n        var $productContainer = $(this).closest(\".set-item\");\n        if (!$productContainer.length) {\n            $productContainer = $(this).closest(\".modern-product-detail\");\n        }\n        // $(\".pdpLoader\").show();\n        attributeSelect($(this).attr(\"data-url\"), $productContainer);\n    });\n\n    $(document).on(\n        \"change\",\n        'select[class*=\"select-\"], .options-select',\n        function(e) {\n            e.preventDefault();\n\n            var $productContainer = $(this).closest(\".set-item\");\n            if (!$productContainer.length) {\n                $productContainer = $(this).closest(\".modern-product-detail\");\n            }\n            attributeSelect(e.currentTarget.value, $productContainer);\n        }\n    );\n\n    $(document).on(\n        \"click\",\n        '[data-attr=\"size\"] div.size-custom-attribute',\n        function(e) {\n            e.preventDefault();\n\n            if ($(this).attr(\"disabled\")) {\n                return;\n            }\n            var $productContainer = $(this).closest(\".set-item\");\n            if (!$productContainer.length) {\n                $productContainer = $(this).closest(\".modern-product-detail\");\n            }\n\n            attributeSelect($(this).attr(\"data-url\"), $productContainer, \"size\");\n        }\n    );\n\n    $(document).on(\n        \"click\",\n        \"button.add-to-cart, button.add-to-cart-global\",\n        function() {\n            var addToCartUrl;\n            var pid;\n            var pidsObj;\n            var setPids;\n\n            $(\"body\").trigger(\"product:beforeAddToCart\", this);\n\n            if ($(\".set-items\").length && $(this).hasClass(\"add-to-cart-global\")) {\n                setPids = [];\n\n                $(\".modern-product-detail\").each(function() {\n                    if (!$(this).hasClass(\"product-set-detail\")) {\n                        setPids.push({\n                            pid:     $(this).find(\".product-id\").text(),\n                            qty:     $(this).find(\".quantity-select\").val(),\n                            options: getOptions($(this))\n                        });\n                    }\n                });\n                pidsObj = JSON.stringify(setPids);\n            }\n\n            pid = getPidValue($(this));\n\n            var $productContainer = $(this).closest(\".modern-product-detail\");\n            if (!$productContainer.length) {\n                $productContainer = $(this)\n                    .closest(\".quick-view-dialog\")\n                    .find(\".modern-product-detail\");\n            }\n\n            addToCartUrl = getAddToCartUrl();\n\n            var form = {\n                pid:           pid,\n                pidsObj:       pidsObj,\n                childProducts: getChildProducts(),\n                quantity:      getQuantitySelected($(this))\n            };\n\n            if (!$(\".bundle-item\").length) {\n                form.options = getOptions($productContainer);\n            }\n\n            $(this).trigger(\"updateAddToCartFormData\", form);\n            if (addToCartUrl) {\n                $.ajax({\n                    url:     addToCartUrl,\n                    method:  \"POST\",\n                    data:    form,\n                    success: function(data) {\n                        handlePostCartAdd(data);\n                        $(\"body\").trigger(\"product:afterAddToCart\", data);\n                        $.spinner().stop();\n                        miniCartReportingUrl(data.reportingURL);\n                    },\n                    error: function() {\n                        $.spinner().stop();\n                    }\n                });\n            }\n            setTimeout(function() {\n                $(\"html, body\").animate({\n                    scrollTop: $(\".minicart-link\").offset().top - 200\n                });\n                var cartURL = $(\".minicart-link, .minicart-icon\").attr(\"href\");\n                location.href = cartURL;\n            }, 1500);\n        }\n    );\n\n    /**\n   * Retrieves the relevant pid value\n   * @param {jquery} $el - DOM container for a given add to cart button\n   * @return {string} - value to be used when adding product to cart\n   */\n    function getPidValue($el) {\n        var pid;\n\n        if ($(\"#quickViewModal\").hasClass(\"show\") && !$(\".product-set\").length) {\n            pid = $($el)\n                .closest(\".modal-content\")\n                .find(\".product-quickview\")\n                .data(\"pid\");\n        } else if ($(\".product-set-detail\").length || $(\".product-set\").length) {\n            pid = $($el).closest(\".modern-product-detail\").find(\".product-id\").text();\n        } else {\n            pid = $('.modern-product-detail:not(\".bundle-item\")').data(\"pid\");\n        }\n\n        return pid;\n    }\n\n    /**\n   * Retrieves url to use when adding a product to the cart\n   *\n   * @return {string} - The provided URL to use when adding a product to the cart\n   */\n    function getAddToCartUrl() {\n        return $(\".add-to-cart-url\").val();\n    }\n\n    /**\n   * Retrieves the bundle product item ID's for the Controller to replace bundle master product\n   * items with their selected variants\n   *\n   * @return {string[]} - List of selected bundle product item ID's\n   */\n    function getChildProducts() {\n        var childProducts = [];\n        $(\".bundle-item\").each(function() {\n            childProducts.push({\n                pid:      $(this).find(\".product-id\").text(),\n                quantity: parseInt($(this).find(\"label.quantity\").data(\"quantity\"), 10)\n            });\n        });\n\n        return childProducts.length ? JSON.stringify(childProducts) : [];\n    }\n\n    /**\n   * Retrieves the value associated with the Quantity pull-down menu\n   * @param {jquery} $el - DOM container for the relevant quantity\n   * @return {string} - value found in the quantity input\n   */\n    function getQuantitySelected($el) {\n        return getQuantitySelector($el).val();\n    }\n\n    /**\n   * Retrieve contextual quantity selector\n   * @param {jquery} $el - DOM container for the relevant quantity\n   * @return {jquery} - quantity selector DOM container\n   */\n    function getQuantitySelector($el) {\n        var quantitySelected;\n        if ($el && $(\".set-items\").length) {\n            quantitySelected = $($el)\n                .closest(\".modern-product-detail\")\n                .find(\".quantity-select\");\n        } else if ($el && $(\".product-bundle\").length) {\n            var quantitySelectedModal = $($el)\n                .closest(\".modal-footer\")\n                .find(\".quantity-select\");\n            var quantitySelectedPDP = $($el)\n                .closest(\".bundle-footer\")\n                .find(\".quantity-select\");\n            if (quantitySelectedModal.val() === undefined) {\n                quantitySelected = quantitySelectedPDP;\n            } else {\n                quantitySelected = quantitySelectedModal;\n            }\n        } else {\n            quantitySelected = $(\".quantity-select\");\n        }\n        return quantitySelected;\n    }\n\n    /**\n   * Retrieve product options\n   *\n   * @param {jQuery} $productContainer - DOM element for current product\n   * @return {string} - Product options and their selected values\n   */\n    function getOptions($productContainer) {\n        var options = $productContainer\n            .find(\".product-option\")\n            .map(function() {\n                var $elOption = $(this).find(\".options-select\");\n                var urlValue = $elOption.val();\n                var selectedValueId = $elOption\n                    .find('option[value=\"' + urlValue + '\"]')\n                    .data(\"value-id\");\n                return {\n                    optionId:        $(this).data(\"option-id\"),\n                    selectedValueId: selectedValueId\n                };\n            })\n            .toArray();\n\n        return JSON.stringify(options);\n    }\n\n    /**\n   * Updates the Mini-Cart quantity value after the customer has pressed the \"Add to Cart\" button\n   * @param {string} response - ajax response from clicking the add to cart button\n   */\n    function handlePostCartAdd(response) {\n        $(\".minicart\").trigger(\"count:update\", response);\n        var messageType = response.error ? \"alert-danger\" : \"alert-success\";\n        // show add to cart toast\n        if (\n            response.newBonusDiscountLineItem &&\n      Object.keys(response.newBonusDiscountLineItem).length !== 0\n        ) {\n            chooseBonusProducts(response.newBonusDiscountLineItem);\n        } else {\n            if ($(\".add-to-cart-messages\").length === 0) {\n                $(\"body\").append('<div class=\"add-to-cart-messages\"></div>');\n            }\n\n            $(\".add-to-cart-messages\").append(\n                '<div class=\"alert ' +\n          messageType +\n          ' add-to-basket-alert text-center\" role=\"alert\">' +\n          response.message +\n          \"</div>\"\n            );\n\n            setTimeout(function() {\n                $(\".add-to-basket-alert\").remove();\n            }, 5000);\n        }\n    }\n\n    /**\n   * Retrieves url to use when adding a product to the cart\n   *\n   * @param {Object} data - data object used to fill in dynamic portions of the html\n   */\n    function chooseBonusProducts(data) {\n        $(\".modal-body\").spinner().start();\n\n        if ($(\"#chooseBonusProductModal\").length !== 0) {\n            $(\"#chooseBonusProductModal\").remove();\n        }\n        var bonusUrl;\n        if (data.bonusChoiceRuleBased) {\n            bonusUrl = data.showProductsUrlRuleBased;\n        } else {\n            bonusUrl = data.showProductsUrlListBased;\n        }\n\n        var htmlString =\n      \"<!-- Modal -->\" +\n      '<div class=\"modal fade\" id=\"chooseBonusProductModal\" tabindex=\"-1\" role=\"dialog\">' +\n      '<span class=\"enter-message sr-only\" ></span>' +\n      '<div class=\"modal-dialog choose-bonus-product-dialog\" ' +\n      'data-total-qty=\"' +\n      data.maxBonusItems +\n      '\"' +\n      'data-UUID=\"' +\n      data.uuid +\n      '\"' +\n      'data-pliUUID=\"' +\n      data.pliUUID +\n      '\"' +\n      'data-addToCartUrl=\"' +\n      data.addToCartUrl +\n      '\"' +\n      'data-pageStart=\"0\"' +\n      'data-pageSize=\"' +\n      data.pageSize +\n      '\"' +\n      'data-moreURL=\"' +\n      data.showProductsUrlRuleBased +\n      '\"' +\n      'data-bonusChoiceRuleBased=\"' +\n      data.bonusChoiceRuleBased +\n      '\">' +\n      \"<!-- Modal content-->\" +\n      '<div class=\"modal-content\">' +\n      '<div class=\"modal-header\">' +\n      '    <span class=\"\">' +\n      data.labels.selectprods +\n      \"</span>\" +\n      '    <button type=\"button\" class=\"close pull-right\" data-dismiss=\"modal\">' +\n      '        <span aria-hidden=\"true\">&times;</span>' +\n      '        <span class=\"sr-only\"> </span>' +\n      \"    </button>\" +\n      \"</div>\" +\n      '<div class=\"modal-body\"></div>' +\n      '<div class=\"modal-footer\"></div>' +\n      \"</div>\" +\n      \"</div>\" +\n      \"</div>\";\n        $(\"body\").append(htmlString);\n        $(\".modal-body\").spinner().start();\n\n        $.ajax({\n            url:      bonusUrl,\n            method:   \"GET\",\n            dataType: \"json\",\n            success:  function(response) {\n                var parsedHtml = parseHtml(response.renderedTemplate);\n                $(\"#chooseBonusProductModal .modal-body\").empty();\n                $(\"#chooseBonusProductModal .enter-message\").text(\n                    response.enterDialogMessage\n                );\n                $(\"#chooseBonusProductModal .modal-header .close .sr-only\").text(\n                    response.closeButtonText\n                );\n                $(\"#chooseBonusProductModal .modal-body\").html(parsedHtml.body);\n                $(\"#chooseBonusProductModal .modal-footer\").html(parsedHtml.footer);\n                $(\"#chooseBonusProductModal\").modal(\"show\");\n                $.spinner().stop();\n            },\n            error: function() {\n                $.spinner().stop();\n            }\n        });\n    }\n    /**\n   * Makes a call to the server to report the event of adding an item to the cart\n   *\n   * @param {string | boolean} url - a string representing the end point to hit so that the event can be recorded, or false\n   */\n    function miniCartReportingUrl(url) {\n        if (url) {\n            $.ajax({\n                url:     url,\n                method:  \"GET\",\n                success: function() {\n                    // reporting urls hit on the server\n                },\n                error: function() {\n                    // no reporting urls hit on the server\n                }\n            });\n        }\n    }\n});\n"],"mappings":"AAAAA,SAASC,iBAAiB,oBAAoB,WAuB1C,SAASC,EAAgBC,EAAkBC,GAEnCD,IACAE,EAAE,QAAQC,QAAQ,gCAAiC,CAC/CC,IAAWJ,EACXK,UAAWJ,IAGfC,EAAEI,KAAK,CACHF,IAASJ,EACTO,OAAS,MACTC,QAAS,SAASC,IAyN9B,SAA+BC,EAAUT,GACrC,IAEIU,EAFAC,EACNX,EAAkBY,QAAQ,gCAAgCC,OAAS,EAE7DJ,EAASK,QAAQC,uBAmGzB,SAAqBC,EAAOhB,EAAmBiB,GAE3C,IAAIC,EAAoB,CA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