{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./cartridges/app_livingproof_sfra/cartridge/client/default/js/bonusProducts.js"],"names":[],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;AClFa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA,aAAa;AACb;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"default/js/bonusProducts.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./cartridges/app_livingproof_sfra/cartridge/client/default/js/bonusProducts.js\");\n","'use strict';\n\n$(document).ready(function () {\n var maxBonusItems;\n var bonusProductsObj = document.querySelector('.bonusProducts');\n var promotionSetItemsCount = bonusProductsObj ? bonusProductsObj.dataset.maxitems : 0;\n switch (promotionSetItemsCount) {\n case '1':\n maxBonusItems = 'one';\n break;\n case '2': \n maxBonusItems = 'two';\n break;\n case '3':\n maxBonusItems = 'three';\n break;\n case '4':\n maxBonusItems = 'four';\n break;\n case '5':\n maxBonusItems = 'five';\n break;\n case '6':\n maxBonusItems = 'six';\n break;\n default:\n maxBonusItems = parseInt(promotionSetItemsCount);\n };\n document.querySelector('.bonus-product-heading-count').innerText = maxBonusItems;\n $('.samples-addBonustocart').each(function (btn) {\n if ($(this).attr('value') === 'Added') {\n $(this).parent('form').addClass('addedBonus');\n }\n });\n});\nvar addBonustocart = function (bonusProductId) {\n $('.data-error').text('');\n var $selectedProducts = $('.addedBonus');\n var queryString = '?pids=';\n var pidsObject = {\n bonusProducts: []\n };\n var uuid; var pliuuid;\n var url = $('.bonusItemForm112')[0].action;\n $.each($selectedProducts, function () {\n var option = null;\n var pid = $(this).children('input[name=\"pid\"]')[0].defaultValue;\n uuid = $(this).children('input[name=\"bonusDiscountLineItemUUID\"]')[0].defaultValue;\n pliuuid = $(this).children('input[name=\"productUUID\"]')[0].defaultValue;\n\n if ($(this).data('optionid') && $(this).data('option-selected-value')) {\n option = {};\n option.optionId = $(this).data('optionid');\n option.productId = pid;\n option.selectedValueId = $(this).data('option-selected-value');\n }\n pidsObject.bonusProducts.push({\n pid: pid,\n qty: 1,\n options: [option]\n });\n pidsObject.totalQty = parseInt($('.bonusProducts').attr('data-maxItems'));\n });\n queryString += JSON.stringify(pidsObject);\n queryString = queryString + '&uuid=' + uuid;\n queryString = queryString + '&pliuuid=' + pliuuid;\n $.spinner().start();\n $.ajax({\n url: url + queryString,\n method: 'POST',\n success: function (data) {\n $.spinner().stop();\n $.each(data.basketModel.items, function (i) {\n if (data.basketModel.items[i].bonusProductLineItemUUID === 'bonus') {\n var productContainingBonusItems = data.basketModel.items[i].id;\n $.each(data.basketModel.items[i].bonusProducts, function (key, lineItem) {\n if (lineItem.id === bonusProductId) {\n $('.cart-product-' + productContainingBonusItems).addClass('bonus-product-line-item').append(getProductLineItem(lineItem));\n $('.cart-product-' + productContainingBonusItems).children().first().addClass('bonus-line-item-row');\n }\n });\n }\n });\n $('.minicart-quantity').html(data.totalQty);\n $('.page-title--container .number-of-items').html(data.totalQty + ' Items');\n },\n error: function () {\n $.spinner().stop();\n }\n });\n};\n\n$('body').on('click', '.samples-addBonustocart', function (e) {\n e.preventDefault();\n var bonusProductId = $(this).parent('form.bonusItemForm112').find('input.pid').val();\n $('.bonusProductError').css('display', 'none');\n if ($(this).attr('value') === 'Select') {\n // eslint-disable-next-line radix\n if ($('.addedBonus').length === parseInt($('.bonusProducts').attr('data-maxItems'))) {\n $('.bonusProductError').removeClass('d-none');\n } else {\n $(this).html('Added').prop('value', 'Added').addClass('btn-tertiary');\n $(this).closest('form').addClass('addedBonus');\n }\n } else {\n $(this).html('Select').prop('value', 'Select').removeClass('btn-tertiary');\n $(this).closest('form').removeClass('addedBonus');\n $('.bonus-product-' + bonusProductId).remove();\n }\n addBonustocart(bonusProductId);\n});\n\nvar getProductLineItem = function (lineItem) {\n var productLineItemString = '
'\n + '
'\n + '
'\n + '\"''\n + '
'\n + '
'\n + '
'\n + '
'\n + '
';\n var strikethrough = 'no-strikethrough';\n if (lineItem.isStrikeThroughCat === true) {\n strikethrough = 'strikethrough';\n }\n if (!$.isEmptyObject(lineItem.collection)) {\n productLineItemString += ''\n + '' + lineItem.collection.displayValue + '';\n if (lineItem.trademarkSymbolCat === true) {\n productLineItemString += 'TM';\n } else if (lineItem.registeredSymbolCat) {\n productLineItemString += '® ';\n }\n productLineItemString += '';\n }\n productLineItemString += ' ' + lineItem.productName + ''\n + '
'\n + '
';\n $.each(lineItem.variationAttributes, function (key, attribute) {\n productLineItemString += '
' + attribute.displayValue + '
';\n });\n $.each(lineItem.options, function (key, options) {\n productLineItemString += '
' + options.displayName + '
';\n });\n productLineItemString += '
Free
'\n + '
'\n + '
'\n + '
'\n + 'Free'\n + '
';\n return productLineItemString;\n};\n"],"sourceRoot":""}