{
  "version": 3,
  "sources": ["/cdn/shop/t/20/assets/bt-fre-bought.js?enable_js_minification=1"],
  "sourcesContent": ["var BTFreBought = {\n\tselectors: {\n\t\tselectedClass: 'selected',\n\t\tcheckbox: '.pg__fre-check',\n\t\tvariantSelect: '.variant-id',\n\t\tpItem: '.pg',\n\t\ttotalPrice: '.freb__total-price',\n\t\taddBtn: '.freb__add-btn',\n\t\tqtyBox: '.qty-box__input--fre',\n\t\twrap: '.fre-bought'\n\t},\n\n\tupdateTotalBox: function(wrap) {\n\t\tvar price = 0;\n\t\tvar comparePrice = 0;\n\t\tvar ins = this;\n\t\tvar count = 0;\n\t\twrap.find(this.selectors.pItem + '.' + this.selectors.selectedClass).each(function() {\n\t\t\tvar option = $(this).find(ins.selectors.variantSelect + ' option:selected');\n\t\t\tvar qty = parseInt($(this).find(ins.selectors.qtyBox).first().val());\n\t\t\tif(option.data('available')) {\n\t\t\t\tprice += parseInt(option.data('price')) * qty;\n\t\t\t\tcomparePrice += parseInt(option.data('compare-price')) * qty;\n\t\t\t\tcount++;\n\t\t\t}\n\t\t});\n\t\twrap.find(this.selectors.totalPrice).html(this.getTotalPriceHtml(price, comparePrice));\n\t\tif(count > 0) {\n\t\t\twrap.find(this.selectors.addBtn).removeAttr('disabled');\n\t\t} else {\n\t\t\twrap.find(this.selectors.addBtn).attr('disabled', 'disabled');\n\t\t}\n\t\tBT.convertCurrencySilence(wrap.find('span.money'));\n\t},\n\n\tgetTotalPriceHtml: function(price, comparePrice) {\n    var priceHtml = '';\n    if(comparePrice > price) {\n    \tpriceHtml += '<span class=\"product-price__price product-price__price--freb\">' + BT.getPriceHtml(price) + '</span>';\n      priceHtml += '<s class=\"product-price__price product-price__price--freb\">' + BT.getPriceHtml(comparePrice) + '</s>';      \n    } else {\n      priceHtml += '<span class=\"product-price__price product-price__price--freb\">' + BT.getPriceHtml(price) + '</span>';\n    }\n    return priceHtml;\n  },\n\n  init: function() {\n\t\tvar ins = this;\n\t\t$(this.selectors.checkbox).unbind('click');\n\t\t$(this.selectors.checkbox).on('click', function(e){\n\t\t\te.preventDefault();\n\t\t\t$(this).closest(ins.selectors.pItem).toggleClass(ins.selectors.selectedClass);\n\t\t\tins.updateTotalBox($(this).closest(ins.selectors.wrap));\n\t\t});\n\t\t$(this.selectors.variantSelect).unbind('change');\n\t\t$(this.selectors.variantSelect).on('change', function(){\n\t\t\tvar variantId = $(this).val();\n\t\t\tvar option = $(this).children('option[value=\"' + variantId + '\"]');\n\t\t\tvar pg = $(this).closest(ins.selectors.pItem);\n\t\t\tif(!option.data('available')) {\n\t\t\t\tpg.find(ins.selectors.checkbox).attr('disabled', 'disabled');\n\t\t\t} else {\n\t\t\t\tpg.find(ins.selectors.checkbox).removeAttr('disabled');\n\t\t\t}\n\t\t\tins.updateTotalBox(pg.closest(ins.selectors.wrap));\n\t\t});\n\t\t$(this.selectors.addBtn).unbind('click');\n\t\t$(this.selectors.addBtn).on('click', function() {\n\t\t\tvar wrap = $(this).closest(ins.selectors.wrap), params = [];\n\t\t\tvar selectedItems = wrap.find(ins.selectors.pItem + '.' + ins.selectors.selectedClass);\n\t\t\tselectedItems.each(function() {\n\t\t\t\tvar option = $(this).find(ins.selectors.variantSelect + ' option:selected');\n\t\t\t\tvar qty = $(this).find(ins.selectors.qtyBox).first().val();\n\t\t\t\tif(option.data('available')) {\n\t\t\t\t\tvar variantId = option.attr('value');\n\t\t\t\t\tparams.push({id: variantId, quantity: qty});\n\t\t\t\t}\n\t\t\t});\n\t\t\tBT.showLoadingFull();\n\n\t\t\tBT.callAjax(theme.cartAddUrl, 'post', {items: params}, 'json', function(){\n  \t\t\tdocument.location.href = theme.cartUrl;\n  \t\t});\n\t\t});\n\t\t$(document).on('change', this.selectors.qtyBox, function() {\n\t\t\tins.updateTotalBox($(this).closest(ins.selectors.wrap));\n\t\t});\n\t\tBT.applyCustomColorSwatches(this.selectors.wrap);\n\t}\n}"],
  "mappings": "AAAA,IAAI,YAAc,CACjB,UAAW,CACV,cAAe,WAC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