{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./codebase/orange/cartridges/app_pagedesigner_core/cartridge/client/default/js/experience/components/commerceAssets/comparator.js","webpack:///./codebase/orange/cartridges/app_storefront_core/cartridge/client/default/js/dataLayer/dataLayer.js","webpack:///./codebase/orange/cartridges/app_storefront_core/cartridge/client/default/js/globalModal/globalModalConfig.js","webpack:///./codebase/orange/cartridges/app_storefront_core/cartridge/client/default/js/utils/helpers.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,0BAA0B,mBAAO,CAAC,yJAAoC;;AAEtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,mBAAO,CAAC,qIAA0B;AAC1D,sBAAsB,mBAAO,CAAC,yHAAoB;AAClD;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;;AAEL;AACA,2DAA2D,qBAAqB;AAChF;AACA,KAAK;AACL,CAAC;;AAED;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa;AACb;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wC;AACA,mBAAmB;AACnB;AACA;AACA;AACA,aAAa,sBAAsB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB,aAAa;AACb;;AAEA,KAAK;;AAEL;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA,iBAAiB;AACjB;AACA,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;;;;;;;;;;;;AChOA;AACA;;AAEa;;AAEb;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA;AACA;AACA,aAAa;AACb;AACA,aAAa;AACb,SAAS;AACT;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,MAAM;AACjB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uHAAuH;AACvH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;;;;;;;;;;;ACjQa;;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,CAAC;;;;;;;;;;;;;AC3BY;;AAEb;AACA;AACA,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,QAAQ;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,UAAU,OAAO;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa;AACb;AACA;AACA;AACA,CAAC;AACD,iBAAiB,OAAO,SAAS,IAAI,cAAc,WAAW;;AAE9D;AACA,8BAA8B,WAAW;AACzC;;AAEA;AACA;AACA,gCAAgC,aAAa,YAAY,SAAS;AAClE;AACA;;AAEA;AACA,uBAAuB,KAAK;AAC5B;;AAEA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,QAAQ;AAClB,UAAU,OAAO;AACjB;AACA;AACA;AACA,CAAC;AACD,iBAAiB,OAAO,SAAS,IAAI,WAAW,eAAe;AAC/D;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,QAAQ;AAClB,UAAU,OAAO;AACjB;AACA;AACA;AACA,CAAC;AACD,iBAAiB,OAAO,WAAW,KAAK;AACxC;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,8CAA8C;;AAE9C;AACA;AACA;AACA;AACA,KAAK;AACL,qBAAqB;AACrB;;AAEA;;AAEA;;AAEA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA,SAAS,IAAI;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA","file":"default\\js\\experience\\components\\commerceAssets\\comparator.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 = \"./codebase/orange/cartridges/app_pagedesigner_core/cartridge/client/default/js/experience/components/commerceAssets/comparator.js\");\n","const globalModalConfig = require('core/globalModal/globalModalConfig');\r\n\r\n// Selecting DOM elements and storing them in variables\r\nconst alertsComparator = $('.js-alerts-comparator');\r\nconst comparatorButton = $('.js-comparator-button');\r\nconst comparatorStickyWarning = $('.js-comparator-sticky-warning');\r\nconst comparatorStickyInfo = $('.js-comparator-sticky-info');\r\nconst comparatorStickyButton = $('.js-comparator-sticky-button');\r\nconst comparatorStickyText = $('.js-comparator-sticky-text');\r\nconst comparatorElements = $('.js-comparator-elements');\r\nconst modalBodyContent = $('.js-modal-body-content');\r\nconst modalDrawer = $('.modal--drawer');\r\nconst dataLayerHelper = require('core/dataLayer/dataLayer');\r\nconst clientHelpers = require('core/utils/helpers')\r\nlet removeModalClass = false;\r\n\r\n$(document).ready(function () {\r\n // Get the current pageName\r\n const pageName = dataLayerHelper.methods.getPageName();\r\n let comparatorDataLayer = {};\r\n\r\n addAlertObserver();\r\n\r\n // Adding click event to comparator button\r\n comparatorButton.on('click', function() {\r\n handleComparatorButtonsStatus($(this));\r\n // Updating the comparator sticky bar based on the number of active comparators\r\n updateComparatorSticky();\r\n });\r\n // Adding click event to comparator sticky button\r\n comparatorStickyButton.on('click', function () {\r\n showComparatorModal(comparatorDataLayer);\r\n });\r\n\r\n modalDrawer.on('hidden.bs.modal', function () {\r\n dataLayerHelper.methods.buildDataLayerViewGeneral({'pageName': pageName});\r\n dataLayerHelper.methods.removeDataLayerViewGeneralData(comparatorDataLayer, ['pageName']);\r\n });\r\n});\r\n\r\nfunction getSelectedProducts(id) {\r\n return $('.js-comparator-button.active').map(function() {\r\n return $(this).data(id);\r\n }).get().join(',');\r\n}\r\n\r\nfunction showComparatorModal(comparatorDataLayer) {\r\n // Getting the selected products' IDs\r\n sendDataLayerSelectedProducts();\r\n const selectedProducts = getSelectedProducts('id');\r\n\r\n $.ajax({\r\n url: $('#comparatorModalEndpoint').val(),\r\n type: 'post',\r\n data: {\r\n productsAdded: selectedProducts,\r\n products : $('#prodIds').val()\r\n },\r\n dataType: 'json',\r\n success: function (data) {\r\n updateComparatorModal(data);\r\n\r\n // Add comparator properties to data layer\r\n if (data.comparatorDataLayer) {\r\n comparatorDataLayer = data.comparatorDataLayer;\r\n dataLayerHelper.methods.buildDataLayerViewGeneral(comparatorDataLayer);\r\n }\r\n\r\n // Adding click event to add to cart button\r\n addEventAddToCart();\r\n\r\n $(\".js-more-info-tariff\", $('.productTile')).on('click', function () {\r\n const buffer = 'masInfo:'+$(this).attr('data-position')+':'+$(this).attr('data-oid');\r\n dataLayerHelper.methods.buildDataLayerEventLinkCheckout('comparador', 'clickButton', buffer);\r\n });\r\n }\r\n });\r\n}\r\n\r\nfunction sendDataLayerSelectedProducts() {\r\n const selectedProducts = getSelectedProducts('idsiebel');\r\n const category = dataLayerHelper.methods.getPageCategory();\r\n dataLayerHelper.methods.buildDataLayerEventLink('cintilloComparador:' + category, 'clickButton', 'comparar:' + selectedProducts);\r\n}\r\n\r\nfunction addEventAddToCart() {\r\n $('.js-add-to-cart', $('.productTile')).unbind('click');\r\n $('.js-add-to-cart', $('.productTile')).on('click', function (e) {\r\n e.preventDefault();\r\n e.stopImmediatePropagation();\r\n const nextStepUrl = $(this).attr('data-next-step');\r\n const buffer = 'loQuiero:'+$(this).attr('data-position')+':'+$(this).attr('data-idsiebel');\r\n const action = $(this).data('action');\r\n const cat = $(this).data('oid'); \r\n var obj = {'category': cat, 'tokenname':$(\".js-csrf-global\").attr(\"name\"), 'token': $(\".js-csrf-global\").val(), 'url':$(this).data('action-dl')};\r\n if (obj.cat !== null && obj.token !== null && obj.tokenname !== null){\r\n dataLayerHelper.methods.addProductToDataLayer(obj).then(function () {\r\n dataLayerHelper.methods.buildDataLayerEventLinkCheckout('comparador', 'clickButton', buffer, 'add');\r\n }).catch(function () {})\r\n .then (function () {\r\n $.spinner().start();\r\n // Sending an AJAX request to add the product to cart\r\n clientHelpers.ajax.addToCart({\r\n action: action,\r\n cat: cat,\r\n nextStepUrl: nextStepUrl\r\n });\r\n });\r\n }\r\n \r\n });\r\n \r\n}\r\n\r\nfunction updateComparatorModal(data) {\r\n if (data.comparator) {\r\n $(globalModalConfig.GLOBAL_MODAL_BODY_CONTENT_ID).html(data.comparator);\r\n $(globalModalConfig.GLOBAL_MODAL_TITLE_ID).html($(\"#comparatorModalTitle\").val());\r\n\r\n // Updating the modal body content with the comparator data\r\n modalBodyContent.html(data.comparator);\r\n modalDrawer.addClass('modal--drawer--tariff-comparator modal--drawer--tariff-comparator-V02');\r\n leftTableMargin();\r\n\r\n if (removeModalClass === false) {\r\n // Removing the modal class after it is hidden\r\n modalDrawer.on('hidden.bs.modal', function () {\r\n modalDrawer.removeClass('modal--drawer--tariff-comparator modal--drawer--tariff-comparator-V02');\r\n });\r\n removeModalClass = true;\r\n }\r\n }\r\n}\r\n\r\nfunction addAlertObserver() {\r\n // Creating a MutationObserver to observe changes in the DOM\r\n const observer = new MutationObserver(function (mutations) {\r\n mutations.forEach(function (mutation) {\r\n if (mutation.addedNodes.length > 0) {\r\n mutation.addedNodes.forEach(function (node) {\r\n // Checking if the added node is an alert\r\n if (node.classList && node.classList.contains('alert')) {\r\n // Unbinding click event from comparator button and binding it again to reset the comparator\r\n alertsComparator.off('click', '.btn-borderless-black');\r\n alertsComparator.on('click', '.btn-borderless-black', function (e) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n clearSelection();\r\n });\r\n }\r\n });\r\n }\r\n });\r\n });\r\n\r\n // Configuring the observer\r\n observer.observe(document.querySelector('.js-alerts-comparator'), {\r\n childList: true,\r\n subtree: true\r\n });\r\n}\r\n\r\nfunction updateComparatorSticky() {\r\n if ($('.js-comparator-button.active').length > 0) {\r\n if ($('.js-comparator-button.active').length === 1) {\r\n // Show comparator sticky warning\r\n comparatorStickyWarning.removeClass('d-none');\r\n comparatorStickyInfo.addClass('d-none');\r\n comparatorStickyButton.prop('disabled', true);\r\n comparatorStickyText.html(comparatorStickyText.data('text-need-more'));\r\n } else if ($('.js-comparator-button.active').length > 1) {\r\n // Show comparator sticky info\r\n comparatorStickyInfo.removeClass('d-none');\r\n comparatorStickyWarning.addClass('d-none');\r\n comparatorStickyButton.prop('disabled', false);\r\n comparatorElements.html('(' + $('.js-comparator-button.active').length + ')');\r\n comparatorStickyText.html(comparatorStickyText.data('text-compare'));\r\n }\r\n } else {\r\n comparatorStickyWarning.addClass('d-none');\r\n }\r\n}\r\n\r\nfunction handleComparatorButtonsStatus(btn) {\r\n if (btn.hasClass('active')) {\r\n // Removing active class and changing button text to default\r\n btn.removeClass('active');\r\n btn.html(btn.data('text-default'));\r\n comparatorButton.not('.active').prop('disabled',false);\r\n } else {\r\n // Adding active class and changing button text to remove\r\n btn.addClass('active');\r\n btn.html(btn.data('text-remove'));\r\n // Disabling non-active comparator buttons if the maximum number of comparators is reached\r\n if (parseInt($('#maxCompare').val()) <= $('.js-comparator-button.active').length) {\r\n comparatorButton.not('.active').prop('disabled',true);\r\n }\r\n }\r\n}\r\n\r\nfunction clearSelection() {\r\n sendDataLayerClearSelection();\r\n comparatorButton.removeClass(\"active\");\r\n comparatorButton.prop(\"disabled\",false);\r\n comparatorButton.html(comparatorButton.data(\"text-default\"));\r\n comparatorStickyInfo.addClass(\"d-none\");\r\n comparatorStickyWarning.addClass(\"d-none\");\r\n}\r\n\r\nfunction sendDataLayerClearSelection() {\r\n const selectedProducts = getSelectedProducts('idsiebel');\r\n const category = dataLayerHelper.methods.getPageCategory();\r\n dataLayerHelper.methods.buildDataLayerEventLink('cintilloComparador:'+category, 'clickLink', 'cerrar:'+selectedProducts);\r\n}\r\n\r\n// Function to set the left margin of the tariff cards\r\nfunction leftTableMargin(){\r\n const tariffCards = document.querySelectorAll('.card-container');\r\n let tariffCardSize = 0;\r\n tariffCards.forEach( card => {\r\n tariffCardSize = card.offsetHeight > tariffCardSize ? card.offsetHeight : tariffCardSize;\r\n });\r\n const r = document.documentElement;\r\n r.style.setProperty('--comparative-list-top-margin', tariffCardSize + 'px');\r\n}\r\n","/* eslint-disable camelcase */\r\n/* eslint-disable no-undef */\r\n\r\n'use strict';\r\n\r\n/**\r\n * Gets the product name from the utag_data object\r\n * @returns {string} the product name or an empty string if not found\r\n */\r\nfunction getProductName() {\r\n return (typeof utag_data !== 'undefined' && utag_data.product_name !== undefined) ? utag_data.product_name : '';\r\n}\r\n\r\n/**\r\n * Gets the product category from utag_data\r\n * @returns {string} the product category from utag_data\r\n */\r\nfunction getProductCategory() {\r\n return (typeof utag_data !== 'undefined' && utag_data.product_category !== undefined) ? utag_data.product_category : '';\r\n}\r\n\r\n/**\r\n * Gets the page category from utag_data\r\n * @returns {string} the page category from utag_data\r\n */\r\nfunction getPageCategory() {\r\n return (typeof utag_data !== 'undefined' && utag_data.pageCategory !== undefined) ? utag_data.pageCategory : '';\r\n}\r\n\r\n/**\r\n * Gets the page name from the utag_data object\r\n * @returns {string} the page name or an empty string if not found\r\n */\r\nfunction getPageName() {\r\n return (typeof utag_data !== 'undefined' && utag_data.pageName !== undefined) ? utag_data.pageName : '';\r\n}\r\n\r\n/**\r\n * Gets the page name from the utag_data object\r\n * @returns {string} the page name without web:orange: or an empty string if not found\r\n */\r\nfunction getPageNameWithoutWebOrange() {\r\n var name = getPageName().replace('web:orange:', '').replace('tiendaOnline:', '');\r\n return name;\r\n}\r\n\r\n/**\r\n * Checks if the user is a client\r\n * @returns {boolean} - true if the user is a client, false otherwise\r\n */\r\nfunction isClient() {\r\n return (typeof utag_data !== 'undefined' && utag_data.userType === 'cliente');\r\n}\r\n\r\n/**\r\n * Returns the page type from utag_data\r\n * @returns {string} - the page type from utag_data\r\n */\r\nfunction getPageType() {\r\n return (typeof utag_data !== 'undefined' && utag_data.pageType !== 'undefined') ? utag_data.pageType : '';\r\n}\r\n\r\n/**\r\n * Builds a data layer event link\r\n * @param {Object} obj - object with data button\r\n * @returns {Promise} A Promise that resolves when the AJAX request is complete and any returned data has been added to the `utag_data` object.\r\n */\r\nfunction addProductToDataLayer(obj) {\r\n return new Promise(function (resolve, reject) {\r\n if (obj.tokenname !== null && obj.token !== null && obj.category !== null && typeof utag_data !== 'undefined') {\r\n var data = {};\r\n data.id = obj.category;\r\n data[obj.tokenname] = obj.token;\r\n $.ajax({\r\n url: obj.url,\r\n type: 'post',\r\n data: data,\r\n dataType: 'json'\r\n }).done((resp) => {\r\n if (resp) {\r\n if (Object.keys(resp.data).length) {\r\n Object.keys(resp.data).forEach(key => {\r\n utag_data[key] = resp.data[key];\r\n });\r\n }\r\n }\r\n resolve();\r\n }).fail(() => {\r\n reject();\r\n });\r\n } else {\r\n reject();\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Builds a data layer event link\r\n * @param {string} zone - the event zone\r\n * @param {string} type - the event type\r\n * @param {string} name - the event name\r\n * @param {string} [event=null] - the Tealium event (optional)\r\n */\r\nfunction buildDataLayerEventLink(zone, type, name, event = null) {\r\n if (zone && name && typeof utag_data !== 'undefined' && typeof utag !== 'undefined') {\r\n utag_data.event_zone = zone;\r\n utag_data.event_name = name;\r\n utag_data.event_type = type;\r\n if (event !== null) {\r\n utag_data.tealium_event = event;\r\n }\r\n utag.track('link', utag_data);\r\n }\r\n}\r\n\r\n/**\r\n * Builds a data layer event link for the given zone, type, name and event\r\n * @param {string} zone - the zone of the event\r\n * @param {string} type - the type of the event\r\n * @param {string} name - the name of the event\r\n * @param {Object} [event] - the event object (optional)\r\n */\r\nfunction buildDataLayerEventLinkCheckout(zone, type, name, event = null) {\r\n if (typeof utag_data !== 'undefined') {\r\n zone = 'tiendaOnline:' + zone;\r\n if (isClient()) {\r\n zone = 'areaCliente:' + zone;\r\n }\r\n buildDataLayerEventLink(zone, type, name, event);\r\n }\r\n}\r\n\r\n/**\r\n * Builds the data layer view for the given section and data\r\n * @param {string} section - the section of the data layer\r\n * @param {Object} data - the data to be added to the data layer\r\n * @returns {void}\r\n */\r\nfunction buildDataLayerView(section, data) {\r\n if (typeof utag_data !== 'undefined' && typeof utag !== 'undefined') {\r\n var pageData = $('.js-data-layer').data('layer-' + section);\r\n if (pageData !== '') {\r\n utag_data.pageName = pageData.pageName;\r\n utag_data.pageType = pageData.pageType;\r\n var step = pageData.pageType.split(':');\r\n utag_data.checkoutStep = step[1].replace('paso', '');\r\n utag_data.pageVirtual = window.location.protocol + '//' + utag_data['dom.domain'] + utag_data['dom.pathname'];\r\n if (utag_data['dom.pathname'].slice(-1) !== '/') {\r\n utag_data.pageVirtual += '/';\r\n }\r\n utag_data.pageVirtual += pageData.stepID;\r\n }\r\n utag_data.tealium_event = 'checkout';\r\n if (Object.keys(data).length) {\r\n Object.keys(data).forEach(key => {\r\n utag_data[key] = data[key];\r\n });\r\n }\r\n\r\n // load again the view data\r\n utag.track('view', utag_data);\r\n\r\n // replace variable in script\r\n // eslint-disable-next-line no-use-before-define\r\n replaceScript();\r\n }\r\n}\r\n\r\n/**\r\n * Builds the data layer view general\r\n * @param {Object} data - the data to be added to the data layer\r\n */\r\nfunction buildDataLayerViewGeneral(data) {\r\n if (typeof utag_data !== 'undefined' && typeof utag !== 'undefined') {\r\n Object.keys(data).forEach(key => {\r\n utag_data[key] = data[key];\r\n });\r\n\r\n // load again the view data\r\n utag.track('view', utag_data);\r\n\r\n // replace variable in script\r\n // eslint-disable-next-line no-use-before-define\r\n replaceScript();\r\n }\r\n}\r\n\r\n/**\r\n * Removes the general data from the data layer and reloads the view data\r\n * @param {Object} data - the data to be removed from the data layer\r\n * @param {Array} except - the keys to be excluded from the removal\r\n * @returns {void}\r\n */\r\nfunction removeDataLayerViewGeneralData(data, except = []) {\r\n if (typeof utag_data !== 'undefined' && typeof utag !== 'undefined') {\r\n Object.keys(data).forEach(key => {\r\n if (except.indexOf(key) === -1) {\r\n delete utag_data[key];\r\n }\r\n });\r\n\r\n // load again the view data\r\n utag.track('view', utag_data);\r\n\r\n // replace variable in script\r\n // eslint-disable-next-line no-use-before-define\r\n replaceScript();\r\n }\r\n}\r\n\r\n/**\r\n * Replaces a script element with a new one that contains the `utag_data` variable.\r\n *\r\n * @function\r\n * @name replaceScript\r\n * @returns {void}\r\n *\r\n * @description\r\n * This function replaces a script element with a new one that contains the `utag_data` variable. The `utag_data` variable is a global variable that contains data for the Tealium tag management system.\r\n * This function assumes that there is an existing script element with the ID `js-data-layer-script` on the page. The `utag_data` variable must be defined and accessible in the global scope for this function to work properly.\r\n */\r\nfunction replaceScript() {\r\n if (typeof utag_data !== 'undefined') {\r\n // Get the script element to replace\r\n var scriptToReplace = document.getElementById('js-data-layer-script');\r\n if (scriptToReplace) {\r\n // Create a new script element\r\n var script = document.createElement('script');\r\n script.type = 'text/javascript';\r\n script.id = 'js-data-layer-script';\r\n // Create a text node with the utag_data variable\r\n var scriptContent = document.createTextNode('var utag_data = ' + JSON.stringify(utag_data, null, ' ') + ';');\r\n script.appendChild(scriptContent);\r\n // Replace the old script element with the new one\r\n scriptToReplace.parentNode.replaceChild(script, scriptToReplace);\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = {\r\n methods: {\r\n buildDataLayerView: buildDataLayerView,\r\n buildDataLayerEventLinkCheckout: buildDataLayerEventLinkCheckout,\r\n buildDataLayerEventLink: buildDataLayerEventLink,\r\n getProductName: getProductName,\r\n buildDataLayerViewGeneral: buildDataLayerViewGeneral,\r\n getProductCategory: getProductCategory,\r\n getPageCategory: getPageCategory,\r\n getPageType: getPageType,\r\n getPageName: getPageName,\r\n getPageNameWithoutWebOrange: getPageNameWithoutWebOrange,\r\n removeDataLayerViewGeneralData: removeDataLayerViewGeneralData,\r\n addProductToDataLayer: addProductToDataLayer,\r\n isClient: isClient,\r\n replaceScript: replaceScript\r\n\r\n }\r\n};\r\n","'use strict';\r\n\r\n/**\r\n * Global Modal Configuration\r\n *\r\n * @module globalModal/globalModalConfig\r\n */\r\nmodule.exports = Object.freeze({\r\n GLOBAL_MODAL_SAVE_ID: '.js-modal-save',\r\n GLOBAL_MODAL_CLOSE_ID: '.js-modal-close',\r\n GLOBAL_MODAL_ID: 'body #globalModal-drawer',\r\n GLOBAL_MODAL_BODY_CONTENT_ID: '.js-modal-body-content',\r\n GLOBAL_MODAL_TITLE_ID: '.js-modal-title',\r\n GLOBAL_MODAL_ALERT_BTN_ID: '.js-modal-alert-btn',\r\n GLOBAL_MODAL_ALERT_ID: '#js-modal-alert',\r\n GLOBAL_MODAL_ALERT_BIGTITLE_ID: '.modal-title',\r\n GLOBAL_MODAL_ALERT_TITLE_ID: '.js-modal-alert-title',\r\n GLOBAL_MODAL_ALERT_BODY_ID: '.js-modal-alert-body',\r\n GLOBAL_MODAL_ALERT_OUTER_ID: '#js-modal-alert-outer',\r\n GLOBAL_MODAL_ALERT_OUTER_BODY_ID: '.js-modal-alert-outer-body',\r\n GLOBAL_MODAL_ALERT_OUTER_TITLE_ID: '#js-modal-alert-outer .modal-title',\r\n GLOBAL_MODAL_ALERT_FOOTER_ID: '.js-modal-alert-footer',\r\n GLOBAL_MODAL_ALERT_FOOTER_BODY_ID: '.js-modal-alert-footer-body',\r\n GLOBAL_MODAL_ALERT_FOOTER_BUTTONS_ID: '.js-modal-alert-footer-buttons',\r\n GLOBAL_MODAL_ALERT_FOOTER_BUTTON_ID: '.js-modal-alert-footer-button',\r\n GLOBAL_MODAL_ALERT_FOOTER_BUTTON_REJECT_ID: '.js-modal-alert-reject',\r\n GLOBAL_MODAL_ALERT_FOOTER_BUTTON_ACCEPT_ID: '.js-modal-alert-accept'\r\n});\r\n","'use strict';\r\n\r\n/**\r\n* Makes an AJAX request and optionally stops the spinner\r\n* @param {Object} params - the parameters for the request\r\n* @param {string} params.url - the URL for the request\r\n* @param {boolean} params.stopSpinner - whether to stop the spinner after the request is complete\r\n*/\r\nfunction processRequest({\r\n url,\r\n stopSpinner,\r\n extraLines,\r\n extraCatId,\r\n callback = false\r\n}) {\r\n $.ajax({\r\n url: url,\r\n type: 'get',\r\n dataType: 'json',\r\n success: function (response) {\r\n if (!extraLines || (extraLines && extraCatId)) {\r\n var nextStepUrlResponse = response.nextStepUrl;\r\n window.location.href = nextStepUrlResponse;\r\n } else {\r\n // eslint-disable-next-line no-lonely-if\r\n if (callback) {\r\n callback(response);\r\n }\r\n }\r\n if (stopSpinner) {\r\n $.spinner().stop();\r\n }\r\n },\r\n error: function (error) {\r\n var params = error.responseJSON ? error.responseJSON.queryString || '' : '';\r\n if (params.indexOf('addToCartTariffError') !== -1) {\r\n var errorParams = params.split('&')[0].split('=');\r\n if (errorParams[0] === 'addToCartTariffError') {\r\n window.location.href = $('#urlBambuErrorRedirect').val();\r\n return;\r\n }\r\n }\r\n\r\n if (stopSpinner) {\r\n $.spinner().stop();\r\n }\r\n }\r\n });\r\n}\r\n\r\n/**\r\n* Triggers the cart:render event and passes the rendered elements\r\n* @param {Object} response - the response object from the server\r\n*/\r\nfunction renderCartCallback(response) {\r\n const renderedElements = {\r\n renderedSummary: response.renderedSummary,\r\n renderedLines: response.renderedLines,\r\n renderedSticky: response.renderedSticky,\r\n renderedStickyModal: response.renderedStickyModal,\r\n renderedExtraServices: response.renderedExtraServices,\r\n renderedTabpanels: response.renderedTabpanels\r\n };\r\n $(document).trigger('cart:render', [renderedElements]);\r\n}\r\n/**\r\n * Adds a product to the cart\r\n * @param {Object} params - an object containing the action and catID\r\n * @returns {void}\r\n */\r\nfunction addToCart({\r\n action, cat, stopSpinner = true, extraLines = false, extraCatId = '', changeTariff, nextStepUrl, otts\r\n}) {\r\n let url = `${action}?catID=${cat}&extraLines=${extraLines}`;\r\n\r\n if (extraCatId !== '') {\r\n url += `&extraCatId=${extraCatId}`;\r\n }\r\n\r\n if (changeTariff) {\r\n let nextStep = encodeURIComponent(nextStepUrl);\r\n url += `&changeTariff=${changeTariff}&nextStep=${nextStep}`;\r\n stopSpinner = false;\r\n }\r\n\r\n if (otts != null) {\r\n url += `&ott=${otts}`;\r\n }\r\n\r\n processRequest({\r\n url, stopSpinner, extraLines, extraCatId, callback: renderCartCallback\r\n });\r\n}\r\n\r\n/**\r\n* Updates the cart with the given action and category\r\n* @param {Object} params - parameters for the update\r\n* @param {string} params.action - the action to perform on the cart\r\n* @param {string} params.cat - the category of the product\r\n* @param {boolean} [params.stopSpinner=true] - whether to stop the spinner\r\n* @param {string} [params.oldProductUUID] - the UUID of the old product\r\n*/\r\nfunction updateCart({\r\n action, cat, stopSpinner = true, oldProductUUID\r\n}) {\r\n let url = `${action}?catID=${cat}&pliuuid=${oldProductUUID}`;\r\n const extraLines = true;\r\n processRequest({\r\n url, stopSpinner, extraLines, callback: renderCartCallback\r\n });\r\n}\r\n\r\n/**\r\n* Deletes an item from the cart\r\n* @param {Object} params - parameters for the request\r\n* @param {string} params.action - the action url\r\n* @param {boolean} [params.stopSpinner=true] - whether to stop the spinner\r\n* @param {string} params.deletedUUID - the UUID of the item to be deleted\r\n*/\r\nfunction removeFromCart({\r\n action, stopSpinner = true, UUID\r\n}) {\r\n let url = `${action}?pliuuid=${UUID}`;\r\n const extraLines = true;\r\n processRequest({\r\n url, stopSpinner, extraLines, callback: renderCartCallback\r\n });\r\n}\r\n\r\n/**\r\n * Determines if the client should be shown customer service options.\r\n *\r\n * This function checks the following conditions:\r\n * 1. Reads the `utag_main` cookie and verifies it is not null and includes \"a116-\".\r\n * 2. Reads the `_nc_` cookie and verifies it is not null and includes \"c=1\".\r\n * 3. Checks if the `window.location.pathname` includes \"index_cliente\" or \"clientes\".\r\n *\r\n * If any of these conditions are met, the function returns `true`.\r\n *\r\n * @returns {boolean} `true` if the client should be shown customer service options, otherwise `false`.\r\n */\r\nfunction isClientToShowCustomerService() {\r\n // Obtenemos el valor del input y lo parseamos\r\n var cookiesToReviewElement = document.querySelector('.js-cookies-to-review');\r\n if (!cookiesToReviewElement) return false; // Si no existe el input, devolvemos false\r\n\r\n var cookiesToReview = cookiesToReviewElement.value;\r\n var parsedCookiesToReview;\r\n try {\r\n parsedCookiesToReview = JSON.parse(cookiesToReview);\r\n } catch (e) {\r\n return false; // Si no es un JSON válido, devolvemos false\r\n }\r\n\r\n if (!parsedCookiesToReview) return false;\r\n\r\n var isClientToShowCS = false;\r\n\r\n // Guardamos cookies en un objeto clave-valor para búsquedas rápidas\r\n var cookieObject = document.cookie\r\n .split(';')\r\n .reduce(function (acc, cookie) {\r\n var parts = cookie.split('=');\r\n acc[parts[0].trim()] = parts[1] ? parts[1].trim() : '';\r\n return acc;\r\n }, {});\r\n\r\n // Comprobamos las cookies que deben estar presentes y sus valores\r\n parsedCookiesToReview.cookies.forEach(function (cookie) {\r\n var cookieValue = cookieObject[cookie.name];\r\n if (cookieValue && cookieValue.includes(cookie.value)) {\r\n isClientToShowCS = true;\r\n }\r\n });\r\n\r\n // Comprobamos si el pathname actual coincide con alguno de los definidos\r\n var pathname = window.location.pathname;\r\n parsedCookiesToReview.pathNames.forEach(function (path) {\r\n if (pathname.includes(path.value)) {\r\n isClientToShowCS = true;\r\n }\r\n });\r\n\r\n // Devolver el objeto toInclude si alguna de las condiciones es verdadera\r\n return isClientToShowCS ? (parsedCookiesToReview.toInclude || false) : false;\r\n}\r\n\r\nconst ajax = {\r\n addToCart,\r\n updateCart,\r\n removeFromCart\r\n};\r\n\r\nmodule.exports = {\r\n ajax: ajax,\r\n isClientToShowCustomerService: isClientToShowCustomerService\r\n};\r\n"],"sourceRoot":""}