{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./cartridges/app_suzano_custom/cartridge/client/default/js/util.js","webpack:///./cartridges/app_suzano_custom/cartridge/client/default/js/imports/modal.js","webpack:///./cartridges/app_suzano_custom/cartridge/client/default/js/components/modalCep.js","webpack:///./cartridges/app_suzano_custom/cartridge/client/default/js/components/modalTrackOrder.js","webpack:///./cartridges/app_suzano_custom/cartridge/client/default/js/sellersCarousel.js","webpack:///./cartridges/app_suzano_custom/cartridge/client/default/js/unavailableModal.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,KAAK;AACL;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;;;;;;;;;;;;ACnBA,qBAAqB,mBAAO,CAAC,yBAAa;;AAE1C;AACA;AACA,uBAAuB,mBAAO,CAAC,oCAAwB;AACvD;AACA,mBAAmB,mBAAO,CAAC,2CAA+B;AAC1D,mBAAmB,mBAAO,CAAC,gCAAoB;AAC/C,mBAAmB,mBAAO,CAAC,iCAAqB;AAChD,CAAC;;;;;;;;;;;;;;ACTY;;AAEb;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;;AAEA,2BAA2B;AAC3B,QAAQ,4CAA4C;AACpD;AACA,CAAC;;AAED,6B;AACA,oB;AACA,UAAU,iC;AACV,K;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,KAAK;AACL,CAAC;;AAED;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB;AACjB;AACA;AACA,aAAa;AACb;;AAEA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,KAAK;AACL,CAAC;;AAED;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,mCAAmC,WAAW;AAC9C;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa;AACb;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6CAA6C,4BAA4B,GAAG,2BAA2B,GAAG,0BAA0B;AACpI;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA,aAAa;AACb,oCAAoC;AACpC,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA,aAAa;AACb,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA,CAAC;AACD;AACA;AACA,CAAC;;AAED;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,gBAAgB,GAAG,iBAAiB;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB,2CAA2C;AAC3C,iBAAiB;AACjB,aAAa;AACb;AACA;AACA,aAAa;AACb,aAAa;AACb;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,qCAAqC,kBAAkB;AACvD;AACA;;AAEA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL,CAAC;;AAED;AACA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,CAAC;;AAED;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA,CAAC;;AAED;AACA,yDAAyD;;AAEzD;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL,kBAAkB;AAClB;AACA;;AAEA;AACA;;AAEA;AACA;AACA,yCAAyC,sBAAsB;AAC/D;AACA;AACA,iBAAiB;AACjB;AACA;AACA,aAAa;AACb;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA;AACA;AACA,qBAAqB;AACrB;;AAEA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,mBAAmB,gCAAgC;AACnD;AACA;AACA;AACA;AACA,kDAAkD,oCAAoC,WAAW,oCAAoC,SAAS,oCAAoC;AAClL,iDAAiD,gCAAgC;AACjF;;AAEA;AACA;AACA,SAAS;AACT;AACA;AACA,qEAAqE,sBAAsB,WAAW,kBAAkB;AACxH;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,wDAAwD,uDAAuD;;AAE/G;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB,iBAAiB;AACjB;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA,CAAC,E;;;;;;;;;;;;;AC9pBY;;AAEb;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAS;AACT;AACA,KAAK;AACL,CAAC;;AAED;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA,kCAAkC,uBAAuB;AACzD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA,KAAK;AACL,CAAC;;AAED;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa;AACb,SAAS;AACT;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,SAAS;AACT,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,KAAK;AACL,CAAC;;;;;;;;;;;;;ACrMD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;AACH,CAAC,E;;;;;;;;;;;;;;AC9ED;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B,MAAM,GAAG,WAAW,GAAG,UAAU;AAChE;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,qCAAqC;AACrC,iCAAiC;AACjC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC;AACrC;AACA;;AAEA,6BAA6B;AAC7B;AACA;;AAEA;AACA;AACA,yBAAyB;AACzB;AACA,iBAAiB;AACjB,aAAa;;AAEb;AACA;AACA;AACA;AACA,qDAAqD,qBAAqB;AAC1E;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA,sDAAsD,qBAAqB;AAC3E;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA,sDAAsD,IAAI;AAC1D;AACA;AACA,SAAS;;AAET,G","file":"./cartridges/app_suzano_custom/cartridge/static/default/js/imports/modal.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 = \"2gsu\");\n","'use strict';\n\nmodule.exports = function (include) {\n if (typeof include === 'function') {\n include();\n } else if (typeof include === 'object') {\n Object.keys(include).forEach(function (key) {\n if (typeof include[key] === 'function') {\n include[key]();\n }\n });\n }\n $('.phoneNumberCheckout').mask('(00) 0000-00009', {\n translation: {\n 9: {\n pattern: /[0-9]/\n }\n }\n });\n};\n","var processInclude = require(\"suzano/util\");\n\n$(document).ready(function () {\n if(!$('#vueAppCheckout').length){\n processInclude(require('../components/modalCep'));\n }\n processInclude(require('../components/modalTrackOrder'));\n processInclude(require('../sellersCarousel'));\n processInclude(require('../unavailableModal'));\n});\n","'use strict';\n\nfunction appendToUrl(url, params) {\n var newUrl = url;\n newUrl += (newUrl.indexOf('?') !== -1 ? '&' : '?') + Object.keys(params).map(function (key) {\n return key + '=' + encodeURIComponent(params[key]);\n }).join('&');\n\n return newUrl;\n}\n\n$('.mask-name').mask('A', {'translation': {\n A: {pattern: /[a-zA-Zà-úÀ-Ú ]/, recursive: true},\n }\n});\n\n$('.mask-number').mask('0', { \n 'translation': { \n 0: { pattern: /\\d/, recursive: true } \n } \n});\n\n$(document).on('submit', '.address-form-modal', function (e) {\n e.preventDefault();\n var url = $(this).attr('action');\n var form = $(this);\n var redirectURL = window.location.href;\n\n $(\".input-content-cep button\").addClass(\"is__loading\");\n\n $.ajax({\n url: url,\n type: 'post',\n dataType: 'json',\n data: $(form).serialize(),\n\n success: function (data) {\n var cepProductId = $('#cepProductId').val();\n var element = $('button.add-to-cart-carousel[data-pid=\"' + cepProductId + '\"]')[0];\n $('body').trigger('addToCart:event', element);\n\n //datalayer trigger add_cep\n $('body').trigger('dataLayerPush:event', data.add_cep);\n\n if (data && data.hasUnavailableProducts && data.unavailableProducts && data.unavailableProducts.length > 0) {\n showUnavailableProductsModal(data.unavailableProducts);\n } else {\n location.href = redirectURL;\n }\n },\n error: function (err) {\n $(\".input-content-cep button\").removeClass(\"is__loading\");\n console.log(err);\n }\n });\n});\n\n// verifica se os campos do endereço completo estão preenchidos\n$('.modalCep-form-allFields input').on('input', function() {\n var $form = $('.modalCep-form-allFields');\n var $submitButton = $form.find('button[type=\"submit\"]');\n var allFilled = true;\n \n if ($form.find('.invalid-feedback').is(':visible')) {\n $form.find('.invalid-feedback').css('display', 'none');\n }\n\n $form.find('.form-group input').each(function(index, element) {\n if ($(element).val().trim() === '') {\n return allFilled = true;\n }else {\n allFilled = false\n }\n });\n $submitButton.attr('disabled', allFilled ? true : false)\n})\n\n$(document).on('submit', '.modalCep-form-allFields', function (e) {\n e.preventDefault();\n var url = $(this).attr('action');\n var form = $(this);\n var redirectURL = window.location.href;\n\n $(\".input-content-cep button\").addClass(\"is__loading\");\n\n $.ajax({\n url: url,\n type: 'post',\n dataType: 'json',\n data: $(form).serialize(),\n\n success: function (data) {\n if (!data.error){\n var cepProductId = $('#cepProductId').val();\n var element = $('button.add-to-cart-carousel[data-pid=\"' + cepProductId + '\"]')[0];\n $('body').trigger('addToCart:event', element);\n \n if (data && data.hasUnavailableProducts && data.unavailableProducts && data.unavailableProducts.length > 0) {\n showUnavailableProductsModal(data.unavailableProducts);\n } else {\n location.href = redirectURL;\n }\n } else {\n $('.modalCep-form-allFields').find('.invalid-feedback').css('display','block')\n\n }\n },\n error: function (err) {\n $(\".input-content-cep button\").removeClass(\"is__loading\");\n console.log(err);\n }\n });\n})\n\n$('#zipCodeModal').on('input', function() {\n let zipCode = $(this).val().replace(/\\D/g, '');\n let url = $(this).data('url');\n\n if (zipCode.length > 5) {\n zipCode = zipCode.substring(0, 5) + '-' + zipCode.substring(5, 8);\n }\n\n $(this).val(zipCode);\n let postalCode = $(this).val();\n\n if ($(this).val().length === 9) {\n $(\".btn-modal-cep\").addClass(\"is__loading\");\n $.ajax({\n url: appendToUrl(url, {postalCode}),\n type: 'GET',\n success: function (data) {\n $(\".btn-modal-cep\").removeClass(\"is__loading\");\n\n if (data.success) {\n var addressData = data.addressData\n $('.modal-button.edit').removeClass('d-none');\n $('#address1Modal').val(addressData.logradouro);\n $('#address1Modal').prop('readonly', true);\n $('#addressDistrictModal').val(addressData.bairro);\n $('#addressDistrictModal').prop('readonly', true);\n $('#inputStateModal').val(addressData.uf).change();\n $('#inputStateModal').prop('readonly', true);\n $('#inputCityModal').val(addressData.localidade);\n $('#inputCityModal').prop('readonly', true);\n $('.modalCep-form-onlyCep .btn-modal-cep').removeAttr('disabled');\n } else {\n $('#zipCodeModal').addClass('is-invalid').siblings('.invalid-feedback').html(data.error);\n $('#address1Modal').prop('readonly', false);\n $('#addressDistrictModal').prop('readonly', false);\n $('#inputStateModal').prop('readonly', false);\n $('#inputCityModal').prop('readonly', false);\n $('.modal-button').filter(':visible').addClass('d-none');\n $('.modalCep-form-onlyCep .btn-modal-cep').attr('disabled', true);\n\n }\n },\n error: function (data) {\n $(\".btn-modal-cep\").removeClass(\"is__loading\");\n }\n });\n } else {\n $('#address1Modal').val('');\n $('#addressDistrictModal').val('');\n $('#inputStateModal').val('');\n $('#inputCityModal').val('');\n }\n});\n\nfunction cep() {\n if (\n $('#inputStateModal').val() &&\n $('#address1Modal').val() &&\n $('#inputCityModal').val()\n ) {\n $.ajax({\n url: `https://viacep.com.br/ws/${$('#inputStateModal').val()}/${$('#inputCityModal').val()}/${$('#address1Modal').val()}/json/`,\n type: 'GET',\n success: function (data) {\n if (data.erro) {\n $('.erroModal').addClass('is-invalid').siblings('.invalid-feedback').html('Dados inválidos');\n $('.modal-button').filter(':visible').addClass('d-none');\n } else {\n $('#zipCodeModal').val(data[0].cep);\n $('form .form-group input').trigger('keypress');\n $('.modal-button.edit.d-none').removeClass('d-none');\n }\n },\n error: function (data) { }\n });\n $('#address1Modal, #inputCityModal').on('input', function () {\n let address = $(this)\n .val()\n .replace(/[^a-zA-ZÀ-ÿçÇ ]/g, '');\n $(this).val(address);\n });\n\n $('.saveAddress-btn').on('click', function () {\n let fields = $('form .form-group input');\n\n fields.each(function () {\n let inputValue = $(this).val();\n if (inputValue.length < 1 && $(this).attr('required')) {\n $(this)\n .addClass('is-invalid')\n .siblings('.invalid-feedback')\n .html('Preencha esse campo');\n } else {\n $(this)\n .removeClass('is-invalid')\n .siblings('.invalid-feedback')\n .html('');\n }\n });\n });\n\n $('form .form-group input').on('keypress', function () {\n let inputValue = $(this).val();\n if (inputValue.length > 0) {\n $(this)\n .removeClass('is-invalid')\n .siblings('.invalid-feedback')\n .html('');\n }\n });\n }\n}\n\nfunction validateUnavailableProducts(){\n var inputUnavailableProducts = $('input[name=\"unavailableProducts\"]')\n var unavailableInformation = inputUnavailableProducts.val();\n var url = inputUnavailableProducts.data('action');\n if(unavailableInformation === 'true'){\n var redirectURL = window.location.href;\n $(\".input-content-cep button\").addClass(\"is__loading\");\n $.ajax({\n url: url,\n type: 'get',\n dataType: 'json',\n \n success: function (data) {\n if (data.productsData.hasUnavailableProducts && data.productsData.unavailableProducts) {\n showUnavailableProductsModal(data.productsData.unavailableProducts);\n $('#cepModal').show()\n } else {\n location.href = redirectURL;\n }\n },\n error: function (err) {\n $(\".input-content-cep button\").removeClass(\"is__loading\");\n console.log(err);\n }\n });\n }\n}\n\n$('.button-edit-modalCep').on('click', function (event) {\n event.stopPropagation();\n $('.cardCep, .newCepFields, .btn-hiden ,.title-standard, .title-standard-edit').toggleClass('d-none');\n});\n\n$('#inputStateModal').on('input', function () {\n cep();\n});\n$('#address1Modal,#inputCityModal').on('blur', function () {\n cep();\n});\n\n$('body').on('click', '#saveButtonModal', function (e) {\n location.reload();\n});\n\n$('#localization').on('click', function () {\n if ('geolocation' in navigator) {\n navigator.geolocation.getCurrentPosition(\n function (position) {\n const coords = {\n latitude: position.coords.latitude,\n longitude: position.coords.longitude\n };\n const url = $('#localization').data('googleapi');\n $.ajax({\n url: url.replace(\n 'usercoords',\n `${coords.latitude},${coords.longitude}`\n ),\n method: 'get',\n dataType: 'json',\n success: function (data) {\n $('#localization').data('googleapi');\n $('#zipCodeModal').val(data.results[0].address_components[6].short_name);\n $('#address1Modal').val(data.results[0].address_components[1].short_name);\n $('#addressDistrictModal').val(data.results[0].address_components[2].short_name);\n $('#inputCityModal').val(data.results[0].address_components[3].short_name);\n $('#inputStateModal').val(data.results[0].address_components[4].short_name).change();\n $('.modal-button.edit.d-none').removeClass('d-none');\n },\n error: function (err) { }\n });\n },\n function (error) {\n console.log(error);\n },\n { enableHighAccuracy: true }\n );\n } else {\n alert(\n 'Lamento, mas os serviços de geolocalização não são suportados pelo seu browser.'\n );\n }\n});\n\n$('body').on('click', '.cardCep', function (e) {\n e.preventDefault();\n var url = $(this).data('action');\n var uuid = $(this).data('uuid');\n $.ajax({\n url: url,\n type: 'post',\n dataType: 'json',\n data: {\n uuid: uuid\n },\n success: function (data) {\n $('.locationIcon.click.desktop').html(data.shorTextLocation);\n $('#saveButtonModal').attr('data-address1', data.address.address1);\n $('#saveButtonModal').attr(\n 'data-number',\n data.address.at_address_number\n );\n $('#saveButtonModal').attr('data-uuid', data.address.UUID);\n\n $('.cardCep').removeClass('selectedAddress-card');\n $(`.cardCep[data-uuid=\"${data.address.UUID}\"]`).addClass(\n 'selectedAddress-card'\n );\n\n location.reload();\n },\n error: function (err) {\n }\n });\n});\n\n$('body').on('click', '.redirect-editAddress', function (event) {\n var inputs = document.querySelectorAll('.address-form-modal input');\n\n var formNotEmpty = Array.from(inputs).every(function (input) {\n return input.value.trim() !== '';\n });\n\n if (formNotEmpty) {\n event.preventDefault();\n var linkUrl = $(this).data('href');\n window.open(linkUrl, '_blank');\n }\n});\n\nif ($('.cep-text').text().includes('Entrega em')) {\n $('.close-button').css('display', 'none');\n $('.modal.p-0.show').css('pointer-events', 'none');\n}\n\n$('.cep-text').click(function () {\n $('.close-button').css('display', 'block');\n $('.modal.p-0.show').css('pointer-events', 'auto');\n});\n\n/**\nvar timeoutId;\n$(document).ready(function () {\n var popoverCEP = $('input[name=\"popover-cep-value\"]').val();\n window.localStorage.setItem('popoverCEP', popoverCEP);\n if (popoverCEP !== 'true') {\n timeoutId = setTimeout(function() {\n $('.popover-cep').fadeIn(500);\n }, 7000);\n }\n});\n\n$('body').on('click', '.js-close-popover, .js-searchBar__input', function (e) {\n clearTimeout(timeoutId);\n $('.popover-cep').css('display', 'none');\n});\n */\nfunction calcHeightModalCep(){\n var modalCepHeight =$('.modalCepContent').height();\n var modalScroll = $( '.modal-list-scroll').first();\n var offset = modalScroll.offset();\n var heightList = modalCepHeight - offset.top;\n return heightList;\n}\n\n$(document).on('shown.bs.modal', '#cepModal', function () {\n var viewSize = $(window).width();\n\n if (viewSize <= 430) {\n var heightList = calcHeightModalCep();\n $('.modal-list-scroll').css('height', heightList);\n }else{\n $('.modal-list-scroll').css('height', '188px');\n }\n\n});\n\n$( window ).on( \"resize\", function() {\n var modalCEP = ($(\"#cepModal\").data('bs.modal') || {})._isShown ;\n\n if(modalCEP){\n var viewSize = $(window).width();\n\n if (viewSize <= 430) {\n var heightList = calcHeightModalCep();\n $('.modal-list-scroll').css('height', heightList);\n }else{\n $('.modal-list-scroll').css('height', '188px');\n }\n }\n});\n\nfunction modalObserver(){\n var modal = document.getElementById('cepModal');\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(mutation) {\n if (mutation.type === 'attributes' && mutation.attributeName === 'class') {\n if (modal.classList.contains('show')) {\n $('#cepProductId').val('');\n }\n }\n });\n });\n var config = { attributes: true };\n observer.observe(modal, config);\n}\n\nfunction checkLocationPermission() {\n var defaultCep = $('input[name=\"defaultCep\"]').val();\n\n if( defaultCep !== 'false' && navigator.permissions){\n if (navigator.permissions) {\n navigator.permissions.query({ name: 'geolocation' }).then(function (permissionStatus) {\n if (permissionStatus.state === 'granted') {\n return;\n } else {\n requestLocationPermission()\n }\n });\n }\n }\n}\n\nfunction requestLocationPermission() {\n if (navigator.geolocation) {\n\n // reset button props\n $('.js-request-user-location').removeClass('disabled')\n $('.js-request-user-location').css('pointer-events','unset')\n\n navigator.geolocation.getCurrentPosition(\n function (position) {\n var latitude = position.coords.latitude;\n var longitude = position.coords.longitude;\n var currentLatlng = latitude+','+longitude\n\n // console.log(\"🚀 ~ navigator.geolocation latitude: \", latitude)\n // console.log(\"🚀 ~ navigator.geolocation longitude: \", longitude)\n\n var url = $('input[name=\"saveLocation\"]').val();\n var latlng = $('input[name=\"latlng\"]').val();\n var setByModal = $('input[name=\"setByModal\"]').val();\n\n // if(latlng!==currentLatlng && setByModal!=='true') {\n $.ajax({\n url: url,\n type: 'post',\n dataType: 'json',\n data: {\n lat: latitude,\n lng:longitude\n },\n success: function (data) {\n //datalayer trigger add_cep\n $('body').trigger('dataLayerPush:event', data.add_cep);\n location.reload();\n },\n error: function () {\n $('.js-request-user-location').removeClass('is__loading')\n }\n });\n // }\n\n },\n function (error) {\n console.error('Erro ao obter a localização: ', error);\n // disabled location button\n $('.js-request-user-location').removeClass('is__loading')\n $('.js-request-user-location').addClass('disabled')\n $('.js-request-user-location').css('pointer-events','none')\n }\n );\n } else {\n console.error('Geolocalização não é suportada por este navegador.');\n $('.js-request-user-location').removeClass('is__loading')\n }\n}\n\nfunction showUnavailableProductsModal(unavailableProducts) {\n var itemsHtml = '';\n var unavailableProductsIDList = [];\n var totalMessage = $('.msgWillRemoved').html();\n totalMessage = totalMessage.replace('totalProductsToBeRemoved', unavailableProducts.length);\n if (unavailableProducts.length == 1) {\n totalMessage = totalMessage.replace('produtos serão removidos', 'produto será removido');\n }\n $('.msgWillRemoved').html(totalMessage);\n\n for (var i = 0; i < unavailableProducts.length; i++) {\n var unavailableProduct = unavailableProducts[i];\n itemsHtml += \n `
${unavailableProduct.product.name}
\nIndisponível
'\n } else {\n var quantityAddedToBasket = unavailableProduct.quantityAddedToBasket.toString();\n var quantityAvailable = unavailableProduct.ats.toString();\n itemsHtml += `${quantityAddedToBasket}un → ${quantityAvailable}un
`;\n }\n\n itemsHtml += ''+response+'
'\n +''+message+''\n +'Para cancelar seu pedido, entre em contato com nosso suporte. Você pode nos enviar um e-mail para ' \n +''+email+''+' ou nos chamar pelo '\n +'WhatsApp'+'
'\n +'