{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./cartridges/app_custom_core/cartridge/client/default/js/einsteinCarousel.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","processRecommendationsTile","$parentElement","einsteinUtils","anchorsArray","recommender","data","params","userId","getCQUserId","cookieId","getCQCookieId","ccver","recommendationsReceived","einsteinResponse","recommendedProducts","recs","length","components","template","swatches","displayRatings","map","recommendedProduct","tiledefinition","classxs","classsm","classmd","displayratings","model","type","id","url","URL","searchParams","append","JSON","stringify","$","ajax","href","dataType","success","html","find","$liTemplate","each","index","$newIndiator","clone","attr","removeClass","last","showControls","trigger","error","spinner","stop","fillDomElement","anchors","getRecs","clientId","widgets","push","recommenderName","parameters","callback","loadRecommendations","window","CQuotient","getEinsteinUtils","this","start","closest","sku","alt_id","createProductAnchor","createCategoryAnchor","document","ready"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAO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Ac2D,QAAQC,KAAK,CACvBC,gBAAiB3D,EACjB4D,WAAY1D,EACZ2D,SAAUrD,KAgCtB,SAASsD,IACL,IAAIhE,EAjJR,WACI,IAAIA,EAAgBiE,OAAOC,UAC3B,OAAIlE,GAAuD,mBAA9BA,EAAcM,aAAuE,mBAAhCN,EAAcQ,cACrFR,EAEJ,KA4IamE,GAChBnE,GAC2BmC,EAAE,sBACRQ,MAAK,WACtB,IAAI5C,EAAiBoC,EAAEiC,MAEvB,OADArE,EAAesD,UAAUgB,QACrBlC,EAAEiC,MAAME,QAAQ,gDAAgDxD,OACzDhB,EAA2BC,EAAgBC,EA9BlE,SAA6BD,GACzB,MAAO,CAAC,CACJ6B,GAAI7B,EAAeI,KAAK,oBACxBoE,IAAKxE,EAAeI,KAAK,sBACzBwB,KAAM5B,EAAeI,KAAK,wBAC1BqE,OAAQzE,EAAeI,KAAK,wBAyB6CsE,CAAoB1E,IAC9EoC,EAAEiC,MAAME,QAAQ,iDAAiDxD,OACjEhB,EAA2BC,EAAgBC,EAlBlE,SAA8BD,GAC1B,MAAO,CAAC,CAAE6B,GAAI7B,EAAeI,KAAK,gBAiB2CuE,CAAqB3E,IAEnFD,EAA2BC,EAAgBC,MAK9DmC,EAAEwC,UAAUC,OAAM,WACdZ","file":"default/js/einsteinCarousel.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 = 74);\n","'use strict';\n\n/**\n * Validates and Return the cquotient namespace provided by the commerce cloud platform\n * @returns {Object} - einsteinUtils or null\n */\nfunction getEinsteinUtils() {\n var einsteinUtils = window.CQuotient;\n if (einsteinUtils && (typeof einsteinUtils.getCQUserId === 'function') && (typeof einsteinUtils.getCQCookieId === 'function')) {\n return einsteinUtils;\n }\n return null;\n}\n\n/**\n * Renders the einstein response into a given dom element\n * @param {jQuery} $parentElement parent element where recommendations will show.\n */\nfunction showControls($parentElement) {\n var $liTemplate = $parentElement.find('.hidden-indicators-template li');\n var $carouselItems = $parentElement.find('.carousel-item');\n\n $carouselItems.each(function (index) {\n var $newIndiator = $liTemplate.clone();\n $newIndiator.attr('data-slide-to', index);\n $newIndiator.attr('data-target', '#' + $parentElement.attr('id'));\n if (index === 0) {\n $parentElement.find('.pd-carousel-indicators').append($newIndiator);\n } else {\n $newIndiator.removeClass('active');\n $parentElement.find('.pd-carousel-indicators').append($newIndiator);\n }\n $parentElement.find('.pd-carousel-indicators li').last().attr('data-position', index);\n $parentElement.removeClass('hide-indicators');\n });\n}\n\n/**\n * fills in the carousel with product tile html objects\n * @param {string} einsteinResponse string html for product tiles\n * @param {jQuery} $parentElement parent element where recommendations will show.\n */\nfunction fillDomElement(einsteinResponse, $parentElement) {\n var recommendedProducts = einsteinResponse[$parentElement.data('recommender')].recs;\n if (recommendedProducts && recommendedProducts.length > 0) {\n var template = $parentElement.data('template');\n var swatches = $parentElement.data('swatches');\n var displayRatings = $parentElement.data('displayratings');\n var components = [];\n components = recommendedProducts.map(function (recommendedProduct) {\n var tiledefinition = {};\n tiledefinition.classxs = $parentElement.data('bsxs');\n tiledefinition.classsm = $parentElement.data('bssm');\n tiledefinition.classmd = $parentElement.data('bsmd');\n tiledefinition.template = template;\n tiledefinition.swatches = swatches;\n tiledefinition.displayratings = displayRatings;\n tiledefinition.model = {\n type: 'product',\n id: recommendedProduct.id\n };\n return tiledefinition;\n });\n\n var url = new URL($parentElement.data('product-load-url'));\n url.searchParams.append('components', JSON.stringify(components));\n url.searchParams.append('limit', $parentElement.data('limit'));\n $.ajax({\n url: url.href,\n type: 'get',\n dataType: 'html',\n success: function (html) {\n $parentElement.find('.carousel-inner').html(html);\n showControls($parentElement);\n $('body').trigger('carousel:setup', {});\n },\n error: function () {\n $parentElement.spinner().stop();\n }\n });\n }\n}\n\n/**\n * Processes a recommendation tile, with an already initialized category specific anchors array\n * @param {jQuery} $parentElement parent element where recommendations will show.\n * @param {Object} einsteinUtils cquotient object\n * @param {Array} anchorsArray array of objects representing anchors\n */\nfunction processRecommendationsTile($parentElement, einsteinUtils, anchorsArray) {\n var recommender = $parentElement.data('recommender');\n\n var params = {\n userId: einsteinUtils.getCQUserId(),\n cookieId: einsteinUtils.getCQCookieId(),\n ccver: '1.01'\n };\n\n if (anchorsArray) {\n params.anchors = anchorsArray;\n }\n\n /**\n * Processes a recommendation responses\n * @param {Object} einsteinResponse cquotient object\n */\n function recommendationsReceived(einsteinResponse) {\n fillDomElement(einsteinResponse, $parentElement);\n $parentElement.spinner().stop();\n }\n\n if (einsteinUtils.getRecs) {\n einsteinUtils.getRecs(einsteinUtils.clientId, recommender, params, recommendationsReceived);\n } else {\n einsteinUtils.widgets = einsteinUtils.widgets || []; // eslint-disable-line no-param-reassign\n einsteinUtils.widgets.push({\n recommenderName: recommender,\n parameters: params,\n callback: recommendationsReceived\n });\n }\n}\n\n/**\n * Processes a recommendation tile, with an already initialized product specific anchors array\n * @param {jQuery} $parentElement parent element where recommendations will show.\n * @returns {Array} - containing an anchor object\n */\nfunction createProductAnchor($parentElement) {\n return [{\n id: $parentElement.data('primaryProductId'),\n sku: $parentElement.data('secondaryProductId'),\n type: $parentElement.data('alternativeGroupType'),\n alt_id: $parentElement.data('alternativeGroupId')\n }];\n}\n\n/**\n * Rerieves data attributes from parent element and converts to gretel compatible recommenders array\n * @param {jQuery} $parentElement parent element where recommendations will show.\n * @returns {Array} - containing an anchor object\n */\nfunction createCategoryAnchor($parentElement) {\n return [{ id: $parentElement.data('categoryId') }];\n}\n\n/**\n * Gets all placeholder elements, which hold einstein recommendations queries the details from the\n * einstein engine and feeds them back to the dom element\n */\nfunction loadRecommendations() {\n var einsteinUtils = getEinsteinUtils();\n if (einsteinUtils) {\n var $recommendationTiles = $('.einstein-carousel');\n $recommendationTiles.each(function () {\n var $parentElement = $(this);\n $parentElement.spinner().start();\n if ($(this).closest('.experience-einstein-einsteinCarouselProduct').length) {\n return processRecommendationsTile($parentElement, einsteinUtils, createProductAnchor($parentElement));\n } else if ($(this).closest('.experience-einstein-einsteinCarouselCategory').length) {\n return processRecommendationsTile($parentElement, einsteinUtils, createCategoryAnchor($parentElement));\n }\n return processRecommendationsTile($parentElement, einsteinUtils);\n });\n }\n}\n\n$(document).ready(function () {\n loadRecommendations();\n});\n"],"sourceRoot":""}