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C,SACE,WACJpH,gBAAgBmE,OHyHb,WACL,MAAMkD,SAAW7H,SAASmF,iBAAiB,qBAE3B,MAAZ0C,UAEJA,SAASpG,SAASqG,UAChB,MAAMC,SAAWD,QAAQE,QAAQC,gBAEjCH,QAAQ3D,cAAc,IAAIC,MAAM,WAGhB,KAAZ2D,UACFD,QAAQxF,MAAM4F,YAAY,aAAc,KAAKH,aAC/C,GAEJ,CGvIII,GACA,eAAexD,MACjB,EAGF9D,OAAO6D,iBAAiB,oBAAoB,KAC1CkD,UAAU,G","sources":["webpack://build/../naturalathletic/assets/javascripts/components/utilities.js","webpack://build/../naturalathletic/assets/javascripts/pages/tag/filters.js","webpack://build/../naturalathletic/assets/javascripts/components/infinityScroll.js","webpack://build/../naturalathletic/assets/javascripts/pages/tag.js"],"sourcesContent":["// ===============================================================\n// ADIÇÃO MANUAL DE ASSET\n// ===============================================================\n// Usado para incluir assets no código de forma manual, conforme a necessidade\nexport function addAsset(source, onloadCallback) {\n\n if (!source || source === '') return console.error(`addAsset: caminho não definido.`)\n\n if (source.includes('.js')) {\n const scriptTag = document.createElement('script')\n scriptTag.setAttribute('src', source);\n\n if (onloadCallback && typeof onloadCallback === 'function') {\n scriptTag.onload = onloadCallback\n }\n\n return document.body.appendChild(scriptTag)\n\n } else if (source.includes('.css')) {\n const linkTag = document.createElement('link')\n linkTag.setAttribute('rel', 'stylesheet')\n linkTag.setAttribute('type', 'text/css')\n linkTag.setAttribute('href', source)\n return document.head.appendChild(linkTag)\n\n } else {\n const error = `addAsset: Erro ao criar o asset. Tipo de script não definido, ou não possui tratamento para este tipo de asset.`\n return console.error(error, source)\n }\n}\n\n// ===============================================================\n// BUSCA O CARRINHO ATIVO\n// ===============================================================\nexport async function getCart() {\n try {\n const response = await fetch('/carrinho', {\n headers: {\n 'Accept': 'application/json'\n }\n });\n\n return await response.json()\n\n } catch (error) {\n console.error('Erro ao buscar os dados do carrinho');\n console.error(error);\n return false\n }\n}\n\n// ===============================================================\n// SERIALIZE ARRAY\n// ===============================================================\nexport function serializeArray(form) {\n\n const formData = new FormData(form);\n const data = {};\n\n for (const [name, value] of formData) {\n data[name] = value\n }\n\n const formBody = [];\n\n for (const key in data) {\n const encodeKey = encodeURIComponent(key)\n const encodeValue = encodeURIComponent(data[key])\n formBody.push(`${encodeKey}=${encodeValue}`)\n }\n\n return formBody.join('&')\n \n}\n\n// ===============================================================\n// URL ENCODE FORM DATA\n// ===============================================================\nexport function urlencodeFormData(formData) {\n let string = '';\n\n function encode(s) {\n return encodeURIComponent(s).replace(/%20/g, '+');\n }\n\n for (const pair of formData.entries()) {\n if (typeof pair[1] == 'string') {\n string += (string ? '&' : '') + encode(pair[0]) + '=' + encode(pair[1]);\n }\n }\n return string;\n}\n\n// ===============================================================\n// SLIDE TOGGLE\n// ===============================================================\nexport function slideToggle(contentWrapper, content, duration = 500) {\n let initialHeight = window.getComputedStyle(contentWrapper).height;\n\n if (initialHeight == '0px') {\n return slideDown(contentWrapper, content, duration);\n } else {\n return slideUp(contentWrapper, duration);\n }\n}\n\n// ===============================================================\n// SLIDE UP\n// ===============================================================\nexport function slideUp(contentWrapper, duration = 500) {\n contentWrapper.style.height = '0px';\n contentWrapper.style.transition = `height ${duration} ease`;\n}\n\n// ===============================================================\n// SLIDE DOWN\n// ===============================================================\nexport function slideDown(contentWrapper, content, duration = 500) {\n let innerHeight = content.clientHeight;\n\n contentWrapper.style.height = `${innerHeight}px`;\n contentWrapper.style.transition = `height ${duration} ease`;\n}\n\n// ===============================================================\n// UPDATE DISCOUNT IN PRODUCT BLOCK\n// ===============================================================\nexport function updatePriceBlock() {\n const priceEls = document.querySelectorAll('[data-init-price]');\n\n if (priceEls == null) return;\n\n priceEls.forEach((priceEl) => {\n const discount = priceEl.dataset.discountPercent;\n\n priceEl.dispatchEvent(new Event('change'));\n\n // discount\n if (discount != '0') {\n priceEl.style.setProperty('--discount', `'-${discount}%'`);\n }\n });\n}\n\n// ===============================================================\n// PREÇO POR AJAX\n// ===============================================================\nexport function getPriceProd() {\n var selectors = document.querySelectorAll('[data-update-price]');\n var attr = 'update-price';\n\n if (selectors.length() > 0) {\n selectors.forEach((selector) => {\n var prodId = selector.dataset(attr);\n var url = '/produto/preco/' + prodId;\n\n if (prodId != '' && prodId != null) {\n $.ajax({\n url: url,\n type: 'GET',\n })\n .done((resp) => {\n selector.innerHTML = resp;\n })\n .fail((resp) => {\n console.error(resp);\n });\n }\n });\n }\n}\n\n// ===============================================================\n// DEBOUNCE\n// ===============================================================\n/*\n Debounce retorna uma função que enquanto continuar sendo chamada não é executada\n A função só será executada quando para de ser chamada por N milisegundos\n Útil para melhorar a performance de códigos que são executados muitas vezes por segundo, como o $(window).resize()\n\n Ex:\n \n $(window).resize(debounce(function() {\n // código a ser executado\n }, 500))\n \n No exemplo acima a função só será executada 500ms depois do último resize\n Abra o link abaixo e redimensione a janela branca e acompanhe o output do console\n Exemplo codepen: https://codepen.io/valkervieira/pen/oNgqyWY\n\n Um caso comum de uso é em lojas onde a seleção de um filtro na página de tag recarrega automáticamente a página\n Com o debounce o usuário pode escolher vários filtros rapidamente e a página só recarrega quando parar de escolher\n*/\n\nexport function debounce(func, wait, immediate) {\n var timeout;\n immediate || (immediate = true);\n\n return function () {\n var context = this,\n args = arguments;\n\n var later = function () {\n timeout = null;\n if (!immediate) func.apply(context, args);\n };\n\n var callNow = immediate && !timeout;\n\n clearTimeout(timeout);\n\n timeout = setTimeout(later, wait);\n\n if (callNow) func.apply(context, args);\n };\n}\n\n// ===============================================================\n// THROTTLE\n// ===============================================================\n/*\n Throttle diminui a frequencia que uma função é executada\n Enquanto no debounce a função só é executada quando para de ser chamada, no throttle ela\n continua sendo executada só que em um intervalo mínimo de N milisegundos (default = 250)\n\n Ex:\n\n $(window).resize(throttle() {\n // código a ser executado\n }, 500)\n\n No exemplo acima a função resize é chamada várias vezes por segundo mas só é executada 1 vez a cada 500ms\n Abra o link abaixo, redimensione a janela branca e acompanhe o console\n Exemplo codepen: https://codepen.io/valkervieira/pen/yLyKEPW\n\n Um caso comum de uso é checar se o scroll passou de um determinado ponto, para fixar um header ou alterar algum elemento do DOM\n*/\nexport function throttle(fn, threshhold, scope) {\n threshhold || (threshhold = 250);\n var last, deferTimer;\n return function () {\n var context = scope || this;\n\n var now = +new Date(),\n args = arguments;\n if (last && now < last + threshhold) {\n // hold on to it\n clearTimeout(deferTimer);\n deferTimer = setTimeout(function () {\n last = now;\n fn.apply(context, args);\n }, threshhold);\n } else {\n last = now;\n fn.apply(context, args);\n }\n };\n}\n\n// ===============================================================\n// FORMAT MONEY\n// ===============================================================\nexport function formatMoney(value) {\n // FORMATA UM VALOR\n return (\n 'R$ ' +\n value\n .toFixed(2)\n .replace('.', ',')\n .replace(/(\\d)(?=(\\d{3})+\\,)/g, '$1.')\n );\n}\n\n// ===============================================================\n// FORMAT VALUE\n// ===============================================================\n\nexport const formatValue = function (value = '') {\n let parsedValue = value;\n if (typeof value === 'number') {\n parsedValue = value.toFixed(2).toString();\n }\n return parsedValue.replace('.', ',');\n};\n\n// ===============================================================\n// VALIDA QUANTIDADE\n// ===============================================================\nexport function validateQuantity(_val) {\n // VALIDA SE A QUANTIDADE INFORMADA É UM NÚMERO\n if (!isNaN(_val)) {\n if (parseInt(_val) > 0) {\n return true;\n }\n }\n\n return false;\n}\n\n// ===============================================================\n// CLEAR NUMBER\n// ===============================================================\nexport function getClearNumber(_val) {\n // RETORNA UM NÚMERO LIMPO COMO INT\n if (!isNaN(_val)) {\n var clearNumber = parseInt(_val);\n\n return clearNumber;\n }\n\n return false;\n}\n\n// ===============================================================\n// BUSCA\n// ===============================================================\nexport function setSearch() {\n const toggleButton = document.querySelectorAll('[data-toggle-search]');\n const search = document.querySelector('[data-search-container]');\n const input = document.querySelector('[data-search-input]');\n\n toggleButton.length > 0 && toggleButton.forEach(button => {\n button.addEventListener('click', () => {\n\n if (search.classList.contains('open')) {\n search.classList.remove('open');\n\n } else {\n search.classList.add('open');\n setTimeout(() => { input.focus() }, 400);\n }\n })\n })\n}\n","import { addAsset } from '../../components/utilities';\n\nexport const FilterComponent = {\n root: document.querySelector('#component-products-filter-root'),\n mobileButton: document.querySelector('#open-filter-mobile'),\n settings: window.filterSettings || false,\n showPriceSlider: false,\n instance: false,\n\n sortArrayValues: function (array, property) {\n let sortedArray = array.sort((a, b) => {\n if (a[property] < b[property]) return -1;\n if (b[property] > b[property]) return 1;\n return 0;\n });\n\n // Define ordenação dos tamanhos\n const customOrder = ['pp', 'p', 'm', 'g', 'gg', 'xg', 'xgg'];\n sortedArray.forEach((item) => {\n item.sort = 99;\n customOrder.forEach((order, index) => {\n if (item[property].toLowerCase() === order) item.sort = index;\n });\n });\n\n return sortedArray.sort((a, b) => {\n if (a.sort < b.sort) return -1;\n if (b.sort > b.sort) return 1;\n return 0;\n });\n },\n\n setTagTypes: function () {\n const { settings } = FilterComponent;\n const tags = [];\n\n if (settings.aggregations) {\n const aggregations = settings.aggregations;\n\n // Filtro de categoria\n if (aggregations.types.categoria)\n tags.push({\n title: 'Categoria',\n type: 'categoria',\n style: 'list',\n options: FilterComponent.sortArrayValues(aggregations.types.categoria, 'title'),\n });\n }\n\n return tags;\n },\n\n setPropeties: function () {\n const { settings } = FilterComponent;\n const properties = [];\n\n if (settings.aggregations) {\n const aggregations = settings.aggregations;\n\n // Filtros Atributo 1\n if (aggregations.properties.property1.length > 0)\n properties.push({\n title: 'Tamanho',\n property: 'property1',\n style: 'grid',\n options: FilterComponent.sortArrayValues(aggregations.properties.property1, 'value'),\n patterns: settings.patterns,\n });\n\n // Filtros Atributo 2\n if (aggregations.properties.property2.length > 0)\n properties.push({\n title: 'Cor',\n property: 'property2',\n style: 'colors',\n colorsProps: {\n showTitle: true,\n showColor: true,\n },\n options: FilterComponent.sortArrayValues(aggregations.properties.property2, 'value'),\n patterns: settings.patterns,\n });\n\n // Filtros Atributo 3\n if (aggregations.properties.property3.length > 0)\n properties.push({\n title: 'Fragrância',\n property: 'property3',\n style: 'list',\n options: FilterComponent.sortArrayValues(aggregations.properties.property3, 'value'),\n patterns: settings.patterns,\n });\n }\n\n return properties;\n },\n\n setPricesRanges: function () {\n const { settings, showPriceSlider } = FilterComponent;\n let priceSettings = {\n price: false,\n priceProps: false,\n };\n\n // Exibe o slider de preço. Caso tenha faixas de preço,\n // preferência fica para as faixas (abaixo)\n if (showPriceSlider) {\n priceSettings.price = [settings.aggregations.min_price, settings.aggregations.max_price];\n }\n\n // Exibe as opções de faixa de preço\n if (settings.prices_range.length > 0) {\n priceSettings.priceProps = {\n mode: 'options',\n options: settings.prices_range,\n };\n priceSettings.price = [settings.aggregations.min_price, settings.aggregations.max_price];\n }\n\n return priceSettings;\n },\n\n setFilters: function () {\n const { root } = FilterComponent;\n const tags = FilterComponent.setTagTypes();\n const properties = FilterComponent.setPropeties();\n const priceSettings = FilterComponent.setPricesRanges();\n\n const componentFilters = new Vnda.Component.ProductsFilter({\n mode: 'horizontal',\n hasSort: true,\n filterOnClick: true,\n resetMode: 'all',\n tags,\n properties,\n price: priceSettings.price,\n priceProps: priceSettings.priceProps,\n });\n\n // Renderiza o componente\n componentFilters.render(root);\n FilterComponent.instance = componentFilters;\n root.dispatchEvent(new Event('vnda:filter-component-loaded'));\n },\n\n loadFilters: function () {\n const { settings } = FilterComponent;\n if (!settings) return;\n addAsset(settings.script, FilterComponent.setFilters);\n addAsset(settings.styles);\n },\n\n show: function () {\n const { root } = FilterComponent;\n\n if (!FilterComponent.instance) {\n FilterComponent.loadFilters();\n root.addEventListener('vnda:filter-component-loaded', () => {\n FilterComponent.instance.toggle();\n });\n } else {\n FilterComponent.instance.toggle();\n }\n },\n\n init: function () {\n const { root } = FilterComponent;\n if (!root) return;\n FilterComponent.loadFilters();\n },\n};\n","const InfinityScroll = {\n params: window._pagination,\n priceProds: {\n selector: '[data-update-price]',\n attr: 'update-price',\n },\n productsWrapper: document.querySelectorAll('.section-list-products')[0],\n productWrapper: document.querySelectorAll('.list-products')[0],\n button: document.querySelector('[data-load-more]'),\n stopLoading: function () {\n const button = this.button;\n\n if (button != null) button.parentElement.removeChild(button);\n },\n setCurrentPage: function (_number) {\n const totalPages = this.params.totalPages;\n\n if (_number <= totalPages) {\n this.params.currentPage = _number;\n\n if (this.params.currentPage >= totalPages) this.stopLoading();\n\n if (_number < totalPages) return (this.params.nextUrl = this.params.pages[_number].url);\n }\n },\n\n setScript: function (script) {\n const newScript = document.createElement('script');\n newScript.innerText = script.innerText;\n return document.body.appendChild(newScript);\n },\n\n loadProducts: async function () {\n const nextUrl = this.params.nextUrl;\n const response = await fetch(nextUrl);\n const data = await response.text();\n\n const parser = new DOMParser();\n const doc = parser.parseFromString(data, 'text/html');\n const script = doc.querySelector('[data-product-variants]');\n\n // Busca por scripts para compra rápida\n const scripts = doc.querySelectorAll('[data-variants-script]');\n if (scripts.length > 0)\n scripts.forEach((script) => {\n InfinityScroll.setScript(script);\n });\n\n return doc.querySelectorAll('.product-block');\n },\n updatePrice: function () {\n window.Vnda.Component.Price.update();\n },\n getNextPage: async function () {\n const currentPage = this.params.currentPage;\n const wrapper = this.productsWrapper;\n const productWrapper = this.productWrapper;\n\n if (!wrapper.classList.contains('-searching')) {\n this.productsWrapper.classList.add('-searching');\n this.button.classList.add('-searching');\n\n const newProducts = await this.loadProducts();\n\n newProducts.forEach((product) => {\n productWrapper.appendChild(product);\n });\n\n this.setCurrentPage(currentPage + 1);\n\n window.ProductPurchase.init(true);\n window.lazyLoad.init()\n this.updatePrice();\n\n wrapper.classList.remove('-searching');\n this.button.classList.remove('-searching');\n }\n },\n\n init: function () {\n const button = this.button;\n\n if (typeof this.params != undefined) {\n if (button != null) {\n button.addEventListener(\n 'click',\n () => {\n this.getNextPage();\n },\n { passive: true }\n );\n }\n }\n },\n};\n\nexport default InfinityScroll;\n","import { FilterComponent } from './tag/filters';\nimport InfinityScroll from '../components/infinityScroll';\nimport { updatePriceBlock } from '../components/utilities.js';\n\nconst Tag = {\n init: function () {\n FilterComponent.init();\n updatePriceBlock();\n InfinityScroll.init();\n },\n};\n\nwindow.addEventListener('DOMContentLoaded', () => {\n Tag.init();\n});\n"],"names":["addAsset","source","onloadCallback","console","error","includes","scriptTag","document","createElement","setAttribute","onload","body","appendChild","linkTag","head","FilterComponent","root","querySelector","mobileButton","settings","window","filterSettings","showPriceSlider","instance","sortArrayValues","array","property","sortedArray","sort","a","b","customOrder","forEach","item","order","index","toLowerCase","setTagTypes","tags","aggregations","types","categoria","push","title","type","style","options","setPropeties","properties","property1","length","patterns","property2","colorsProps","showTitle","showColor","property3","setPricesRanges","priceSettings","price","priceProps","min_price","max_price","prices_range","mode","setFilters","componentFilters","Vnda","Component","ProductsFilter","hasSort","filterOnClick","resetMode","render","dispatchEvent","Event","loadFilters","script","styles","show","toggle","addEventListener","init","InfinityScroll","params","_pagination","priceProds","selector","attr","productsWrapper","querySelectorAll","productWrapper","button","stopLoading","this","parentElement","removeChild","setCurrentPage","_number","totalPages","currentPage","nextUrl","pages","url","setScript","newScript","innerText","loadProducts","async","response","fetch","data","text","doc","DOMParser","parseFromString","scripts","updatePrice","Price","update","getNextPage","wrapper","classList","contains","add","product","ProductPurchase","lazyLoad","remove","undefined","passive","Tag","priceEls","priceEl","discount","dataset","discountPercent","setProperty","updatePriceBlock"],"sourceRoot":""}