',
''
].join('');
}).join('');
dropdown.innerHTML = [
'',
' '
].join('');
loopHead.insertAdjacentHTML('beforebegin', spotlightMarkup);
};
const buildStorePerPageControls = function() {
const loopHead = document.querySelector('.shop-loop-head');
if (!loopHead || document.querySelector('.codex-store-per-page')) {
return;
}
const toolsHost = loopHead.querySelector('.wd-shop-tools') || loopHead;
const values = [12, 24, 48];
const params = new URLSearchParams(window.location.search || '');
const current = values.indexOf(Number(params.get('per_page'))) !== -1 ? Number(params.get('per_page')) : 12;
const links = values.map(function(value) {
const nextParams = new URLSearchParams(window.location.search || '');
if (value === 12) {
nextParams.delete('per_page');
} else {
nextParams.set('per_page', String(value));
}
const query = nextParams.toString();
const href = window.location.pathname + (query ? '?' + query : '');
return '' + value + '';
}).join('');
toolsHost.insertAdjacentHTML('afterbegin', '');
};
const buildStoreHomeSections = function() {
if (!pageBody.classList.contains('post-type-archive-product')) {
return;
}
const payload = window.__codexStoreHomeData || {};
if (!payload.departments || !payload.departments.length || document.querySelector('.codex-store-home-shell')) {
return;
}
const spotlight = document.querySelector('.codex-store-spotlight');
if (!spotlight) {
return;
}
const sectionParts = ['
',
'',
'
'
].join('');
dropdown.classList.add('codex-shop-mega-ready');
dropdown.dataset.codexShopMegaReady = '1';
};
const normalizeMovementLabels = function() {
if (!document.body || !document.createTreeWalker) {
return;
}
const movementUpper = 'MOVI' + 'MENTO';
const movementTitle = 'Movi' + 'mento';
const movementFinder = new RegExp('\\b(?:' + movementUpper + '|' + movementTitle + ')\\b');
const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, {
acceptNode: function(node) {
const parent = node.parentElement;
if (!parent || /^(script|style|textarea|input|select)$/i.test(parent.tagName)) {
return NodeFilter.FILTER_REJECT;
}
return movementFinder.test(node.nodeValue || '') ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
}
});
const nodes = [];
let node = walker.nextNode();
while (node) {
nodes.push(node);
node = walker.nextNode();
}
nodes.forEach(function(textNode) {
textNode.nodeValue = textNode.nodeValue
.replace(new RegExp('\\b' + movementUpper + '\\b', 'g'), 'MOVIMENTAÇÃO DE CARGA')
.replace(new RegExp('\\b' + movementTitle + '\\b', 'g'), 'Movimentação de Carga');
});
};
enhanceTopShopDropdown();
normalizeMovementLabels();
window.setTimeout(enhanceTopShopDropdown, 600);
window.setTimeout(normalizeMovementLabels, 700);
window.setTimeout(enhanceTopShopDropdown, 1600);
window.setTimeout(normalizeMovementLabels, 1700);
})();
(function() {
const pageBody = document.body;
if (!pageBody) {
return;
}
const isStorePage = pageBody.classList.contains('codex-store-modern');
const isHomePage = pageBody.classList.contains('codex-home-modern');
if (!isStorePage && !isHomePage) {
return;
}
const homeLabel = 'In' + String.fromCharCode(237) + 'cio';
document.querySelectorAll('.menu-item-home .nav-link-text, .mobile-pages-menu .menu-item-home .nav-link-text').forEach(function(node) {
node.textContent = homeLabel;
});
if (!isStorePage) {
return;
}
const storeWhatsAppBase = 'https://api.whatsapp.com/send?phone=552125897011&text=';
const normalizeText = function(value) {
return (value || '').replace(/\s+/g, ' ').trim();
};
const decodeEntities = function(value) {
const textarea = document.createElement('textarea');
textarea.innerHTML = value || '';
return textarea.value;
};
const escapeAttribute = function(value) {
return String(value || '').replace(/"/g, '"');
};
const escapeHtml = function(value) {
return String(value || '')
.replace(/&/g, '&')
.replace(//g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''');
};
const truncateText = function(value, maxLength) {
const text = normalizeText(value);
if (!text || text.length <= maxLength) {
return text;
}
return text.slice(0, maxLength).replace(/\s+\S*$/, '') + '...';
};
const prettifyLabel = function(slug) {
const normalized = (slug || '').toLowerCase();
const labelMap = {
'epi': 'EPI',
'epis': 'EPIs',
'movimentacao-de-carga': 'Movimentação de Carga',
'movimento': 'Movimentação de Carga',
'rodas-e-rodizios': 'Rodas e Rodízios',
'hortifruti': 'Hortifruti'
};
if (labelMap[normalized]) {
return labelMap[normalized];
}
return normalized
.replace(/^product_cat-/, '')
.replace(/[-_]+/g, ' ')
.replace(/\b\w/g, function(letter) {
return letter.toUpperCase();
});
};
const extractProductLink = function(productItem) {
const anchors = Array.prototype.slice.call(productItem.querySelectorAll('a[href]'));
for (let index = 0; index < anchors.length; index += 1) {
const href = anchors[index].getAttribute('href') || '';
if (/\/produto\//i.test(href)) {
return href.replace(/#.*$/, '');
}
}
const productId = productItem.getAttribute('data-id') || '';
return productId ? window.location.origin + '/?post_type=product&p=' + productId : window.location.href;
};
const collectCategoryLabels = function(productItem) {
const classList = (productItem.className || '').split(/\s+/);
const labels = [];
classList.forEach(function(className) {
if (!/^product_cat-/i.test(className)) {
return;
}
const rawSlug = className.replace(/^product_cat-/i, '');
if (rawSlug === 'sem-categoria' || rawSlug === 'uncategorized') {
return;
}
const label = prettifyLabel(rawSlug);
if (label && labels.indexOf(label) === -1) {
labels.push(label);
}
});
return labels.slice(0, 3);
};
const extractProductId = function(productItem) {
const dataId = productItem.getAttribute('data-id') || productItem.getAttribute('data-product_id') || '';
if (dataId) {
return dataId;
}
const productClass = ((productItem.className || '').match(/\bpost-(\d+)\b/) || [])[1];
if (productClass) {
return productClass;
}
const addButton = productItem.querySelector('[data-product_id]');
return addButton ? (addButton.getAttribute('data-product_id') || '') : '';
};
const extractSku = function(productItem, title) {
const skuNode = productItem.querySelector('.sku, [data-product_sku]');
const skuValue = skuNode ? (skuNode.getAttribute('data-product_sku') || skuNode.textContent || '') : '';
const cleanedSku = normalizeText(skuValue).replace(/^SKU:\s*/i, '');
if (cleanedSku) {
return cleanedSku;
}
const titleMatch = String(title || '').match(/(?:CA\s*)?\d{3,6}\s*$/i);
return titleMatch ? titleMatch[0].trim() : '';
};
const buildAddToQuoteHref = function(productItem, fallbackHref) {
const originalButton = productItem.querySelector('a.add_to_cart_button[href], a[href*="add-to-cart"]');
if (originalButton && originalButton.getAttribute('href')) {
return originalButton.getAttribute('href');
}
const productId = extractProductId(productItem);
return productId ? (window.location.pathname + '?add-to-cart=' + encodeURIComponent(productId)) : fallbackHref;
};
const buildCommercialExcerpt = function(title, categories, rawExcerpt) {
const titleText = normalizeText(title);
const joined = (titleText + ' ' + (categories || []).join(' ')).toLowerCase();
const raw = normalizeText(rawExcerpt || '')
.replace(/https?:\/\/\S+/g, '')
.replace(/\b(?:wikipedia|policloreto de vinila|equipamento de proteção individual)\b/gi, '')
.replace(/\s{2,}/g, ' ');
if (/contentor/.test(joined)) {
return 'Indicado para coleta, armazenamento e movimentação de resíduos em condomínios, empresas, indústrias, hospitais e áreas públicas.';
}
if (/lixeira|cesto/.test(joined)) {
return 'Solução para descarte, coleta interna e organização de resíduos em áreas comuns, empresas e operações profissionais.';
}
if (/carrinho/.test(joined)) {
return 'Apoio para transporte, coleta, limpeza e movimentação interna em rotinas operacionais e manutenção predial.';
}
if (/tatame|piso|borracha/.test(joined)) {
return 'Produto indicado para proteção de superfície, conforto, acabamento e segurança em ambientes profissionais.';
}
if (/bota|luva|capacete|máscara|mascara|óculos|oculos|protetor|respirador|epi/.test(joined)) {
return 'EPI para apoiar segurança, proteção e rotina operacional conforme aplicação, ambiente e especificação do produto.';
}
if (/uniforme|jaleco|camisa|macacão|macacao/.test(joined)) {
return 'Linha para padronização de equipes, operação, atendimento, manutenção e identificação profissional.';
}
if (/mangueira/.test(joined)) {
return 'Linha indicada para apoio técnico, abastecimento, jardim, pressão, incêndio e aplicações operacionais.';
}
if (/sinal|cone|placa|fita/.test(joined)) {
return 'Item para orientação visual, isolamento, segurança de fluxo e organização de áreas profissionais.';
}
return truncateText(raw || 'Produto disponível para orçamento consultivo com a equipe comercial da Megabor.', 160);
};
const getStoreDepartmentIconSvg = function(slug, label) {
const key = String(slug || '').toLowerCase();
const text = String(label || '').toLowerCase();
const icons = {
epi: '',
sinalizacao: '',
lixeiras: '',
carrinhos: '',
'caixas-plasticas': '',
uniformes: '',
pisos: '',
mangueiras: ''
};
if (icons[key]) {
return icons[key];
}
if (/epi|proteção|protecao|segurança|seguranca/.test(text)) {
return icons.epi;
}
if (/sinal|cone|placa/.test(text)) {
return icons.sinalizacao;
}
if (/lixeira|contentor/.test(text)) {
return icons.lixeiras;
}
if (/carrinho/.test(text)) {
return icons.carrinhos;
}
if (/caixa/.test(text)) {
return icons['caixas-plasticas'];
}
if (/uniforme/.test(text)) {
return icons.uniformes;
}
if (/piso|tatame/.test(text)) {
return icons.pisos;
}
if (/mangueira/.test(text)) {
return icons.mangueiras;
}
return icons['caixas-plasticas'];
};
const normalizeStoreChildLabel = function(label) {
const text = normalizeText(label || 'Subcategoria');
return text
.replace(/\bAcesórios\b/gi, 'Acessórios')
.replace(/\bAcesorios\b/gi, 'Acessórios')
.replace(/\bAcessorios\b/gi, 'Acessórios');
};
const buildStoreSpotlight = function() {
if (pageBody.classList.contains('tax-product_cat')) {
return;
}
const loopHead = document.querySelector('.shop-loop-head');
if (!loopHead || document.querySelector('.codex-store-spotlight')) {
return;
}
const titleNode = document.querySelector('.woocommerce-products-header .page-title, .main-title');
const rawTitle = normalizeText(titleNode ? titleNode.textContent : '');
const storeTitle = rawTitle || 'Loja Megabor';
const isMainShop = pageBody.classList.contains('post-type-archive-product');
const titleTag = isMainShop ? 'h1' : 'h2';
const spotlightTitle = isMainShop ? 'Loja Megabor: produtos sob consulta para empresas e operações' : storeTitle + ' com vitrine comercial e navegação de loja';
const spotlightText = isMainShop ? 'Encontre uniformes profissionais, EPIs, contentores, lixeiras, pisos, tatames, carrinhos, mangueiras, sinalização, caixas plásticas, escadas e suprimentos operacionais para empresas, condomínios, indústrias, hospitais, escolas e órgãos públicos.' : 'Explore produtos em um formato mais direto: imagem limpa, descrição objetiva, filtros laterais e caminho rápido para produto ou orçamento comercial.';
const spotlightSupport = isMainShop ? '', cards, '
',
'Adicione os itens ao orçamento e envie sua demanda pelo WhatsApp para receber atendimento consultivo da equipe Megabor.
' : ''; const spotlightMarkup = [ '',
'Catálogo consultivo Megabor',
'<' + titleTag + ' class="codex-store-spotlight__title">' + spotlightTitle + '' + titleTag + '>',
'
',
'',
'' + spotlightText + '
', spotlightSupport, 'Sob consultaAtendimento B2BFiltros por linhaOrçamento por WhatsApp
',
'',
''];
const buildStoreDepartmentChildren = function(department) {
return (department.children || []).slice(0, 8).map(function(child) {
const childName = normalizeStoreChildLabel(child.name || 'Subcategoria');
return [
'',
'', escapeHtml(childName), '',
''
].join('');
}).join('');
};
const initialDepartment = payload.departments[0] || {};
const initialPreview = initialDepartment.preview || {};
sectionParts.push('');
sectionParts.push(' ');
if (payload.brands && ((payload.brands.banners && payload.brands.banners.length) || (payload.brands.logos && payload.brands.logos.length))) {
sectionParts.push('');
if (payload.brands.banners && payload.brands.banners.length) {
sectionParts.push('');
}
if (payload.brands.logos && payload.brands.logos.length) {
const repeatedBrands = payload.brands.logos.concat(payload.brands.logos);
sectionParts.push('');
}
sectionParts.push(' ');
}
if (payload.shelves && payload.shelves.length) {
payload.shelves.forEach(function(shelf) {
sectionParts.push([
'',
' ');
});
}
sectionParts.push('
');
spotlight.insertAdjacentHTML('afterend', sectionParts.join(''));
const departmentsRoot = document.querySelector('.codex-store-home-departments');
if (!departmentsRoot) {
return;
}
const titleTarget = departmentsRoot.querySelector('[data-store-dept-title]');
const textTarget = departmentsRoot.querySelector('[data-store-dept-text]');
const childrenTarget = departmentsRoot.querySelector('[data-store-dept-children]');
const productTarget = departmentsRoot.querySelector('[data-store-dept-product]');
const productNameTarget = departmentsRoot.querySelector('[data-store-dept-product-name]');
const productImageTarget = departmentsRoot.querySelector('[data-store-dept-product-image]');
const departmentNodes = Array.prototype.slice.call(departmentsRoot.querySelectorAll('[data-store-department]'));
const updateDepartmentPanel = function(department) {
if (!department) {
return;
}
const preview = department.preview || {};
departmentNodes.forEach(function(node) {
node.classList.toggle('is-active', node.getAttribute('data-store-department') === String(department.slug || department.name || ''));
});
if (titleTarget) {
titleTarget.textContent = department.name || 'Categoria';
}
if (textTarget) {
textTarget.textContent = department.text || 'Seleção comercial da Megabor para atendimento consultivo e orçamento sob demanda.';
}
if (childrenTarget) {
childrenTarget.innerHTML = buildStoreDepartmentChildren(department);
}
if (productTarget) {
productTarget.href = preview.href || department.href || '#';
}
const previewName = decodeEntities(preview.name || department.name || 'Produto Megabor');
if (productNameTarget) {
productNameTarget.textContent = previewName;
}
if (productImageTarget && preview.image) {
productImageTarget.src = preview.image;
productImageTarget.alt = previewName;
}
};
departmentNodes.forEach(function(node) {
const departmentKey = node.getAttribute('data-store-department');
const department = (payload.departments || []).find(function(item) {
return String(item.slug || item.name || '') === departmentKey;
});
node.addEventListener('mouseenter', function() {
updateDepartmentPanel(department);
});
node.addEventListener('focusin', function() {
updateDepartmentPanel(department);
});
});
};
const buildStoreCards = function() {
const productsGrid = document.querySelector('.products[data-source="main_loop"]');
if (!productsGrid) {
return;
}
productsGrid.classList.add('codex-store-grid');
productsGrid.style.setProperty('--wd-col-lg', '3');
productsGrid.style.setProperty('--wd-col-md', '2');
productsGrid.style.setProperty('--wd-col-sm', '1');
Array.prototype.slice.call(productsGrid.querySelectorAll(':scope > .wd-product')).forEach(function(productItem) {
if (productItem.classList.contains('codex-store-ready')) {
return;
}
productItem.querySelectorAll('.wd-post-meta, .wd-post-author, .wd-post-date, .wd-modified-date, .wd-post-reply, .entry-meta, .posted-on, .byline, .comments-link').forEach(function(node) {
node.remove();
});
productItem.querySelectorAll('.wd-entry-content a[href^="http"]').forEach(function(anchor) {
anchor.replaceWith(document.createTextNode(anchor.textContent || ''));
});
const titleNode = productItem.querySelector('.wd-entities-title, .wd-post-title, .entry-title, h1');
const imageNode = productItem.querySelector('.wd-post-image img, img.wp-post-image, .attachment-post-thumbnail');
const excerptNode = productItem.querySelector('.wd-entry-content > p, .wd-entry-content p');
const productLink = extractProductLink(productItem);
const title = normalizeText(titleNode ? decodeEntities(titleNode.innerHTML || titleNode.textContent) : 'Produto Megabor');
const imageSrc = imageNode ? (imageNode.getAttribute('src') || imageNode.getAttribute('data-src') || '') : '';
const imageAlt = imageNode ? normalizeText(imageNode.getAttribute('alt') || title) : title;
const categories = collectCategoryLabels(productItem);
const excerpt = buildCommercialExcerpt(title, categories, excerptNode ? decodeEntities(excerptNode.innerHTML || excerptNode.textContent) : '');
const sku = extractSku(productItem, title);
const addHref = buildAddToQuoteHref(productItem, productLink);
const productId = extractProductId(productItem);
const tagsMarkup = categories.length ? categories.map(function(label) {
return '' + label + '';
}).join('') : 'Catálogo Megabor';
const addAttrs = productId ? ' data-quantity="1" data-product_id="' + escapeAttribute(productId) + '" rel="nofollow"' : '';
productItem.innerHTML = [
'');
payload.departments.forEach(function(department) {
const departmentName = department.name || 'Categoria';
sectionParts.push([
'',
'',
'', getStoreDepartmentIconSvg(department.slug, departmentName), '',
'', escapeHtml(departmentName), '',
'', (department.count || 0), ' itens',
'',
' '
].join(''));
});
sectionParts.push('
');
const initialPreviewName = decodeEntities(initialPreview.name || initialDepartment.name || 'Produto Megabor');
sectionParts.push([
'',
'
' : ''),
'',
'
'
].join(''));
sectionParts.push('',
'
',
'',
'',
'Produto em destaque',
'Sob consulta',
'', escapeHtml(initialPreviewName), '',
'Ver produto',
'',
(initialPreview.image ? '', escapeHtml(initialDepartment.name || 'Categoria'), '
', '', escapeHtml(initialDepartment.text || 'Seleção comercial da Megabor para atendimento consultivo e orçamento sob demanda.'), '
', '', buildStoreDepartmentChildren(initialDepartment), '
',
'');
repeatedBrands.forEach(function(brand) {
sectionParts.push([
'',
'
',
''
].join(''));
});
sectionParts.push('
',
'
',
'',
'
',
'Ver todos',
'', shelf.name || 'Categoria', '
', '', ''
].join(''));
(shelf.products || []).forEach(function(product) {
sectionParts.push([
'',
'',
(product.image ? '
' : ''),
'',
' '
].join(''));
});
sectionParts.push('
',
'',
'
',
'', product.name || 'Produto', '
', '', product.excerpt || 'Produto disponível para orçamento consultivo.', '
', 'Sob consulta via orçamento comercial
',
'',
'',
(imageSrc ? '
' : ''),
'',
'
'
].join('');
productItem.classList.add('codex-store-ready');
});
};
const normalizeStoreHierarchy = function() {
if (!pageBody.classList.contains('post-type-archive-product')) {
return;
}
const dropdown = document.querySelector('.wd-header-cats .wd-dropdown-cats');
if (dropdown) {
dropdown.querySelectorAll('.wd-product, article.product, .product-grid-item').forEach(function(node) {
const productNode = node.closest('.wd-product, article.product, .product-grid-item');
if (productNode && dropdown.contains(productNode)) {
productNode.remove();
}
});
}
const loopHead = document.querySelector('.shop-loop-head');
const spotlight = document.querySelector('.codex-store-spotlight');
const storeHome = document.querySelector('.codex-store-home-shell');
const productsGrid = document.querySelector('.products[data-source="main_loop"], .products');
if (!loopHead || !spotlight) {
return;
}
if (spotlight.closest('.shop-loop-head') === loopHead && loopHead.parentNode) {
loopHead.parentNode.insertBefore(spotlight, loopHead);
}
if (storeHome && storeHome.closest('.shop-loop-head') === loopHead) {
spotlight.insertAdjacentElement('afterend', storeHome);
}
if (storeHome && storeHome.nextElementSibling !== loopHead) {
storeHome.insertAdjacentElement('afterend', loopHead);
return;
}
if (!storeHome && productsGrid && productsGrid.previousElementSibling !== loopHead) {
productsGrid.parentNode.insertBefore(loopHead, productsGrid);
}
};
buildStoreSpotlight();
buildStoreHomeSections();
buildStoreCards();
buildStorePerPageControls();
normalizeStoreHierarchy();
const productsHost = document.querySelector('.wd-products-element');
if (productsHost && !productsHost.dataset.codexObserverReady) {
productsHost.dataset.codexObserverReady = 'true';
const rebuildStore = function() {
window.requestAnimationFrame(function() {
buildStoreSpotlight();
buildStoreHomeSections();
buildStoreCards();
buildStorePerPageControls();
normalizeStoreHierarchy();
});
};
const observer = new MutationObserver(rebuildStore);
observer.observe(productsHost, { childList: true, subtree: true });
window.setTimeout(rebuildStore, 400);
window.setTimeout(rebuildStore, 1200);
window.setTimeout(rebuildStore, 2200);
}
const footer = document.querySelector('.wd-footer.footer-container');
if (footer) {
const mapUrl = 'https://www.google.com/maps/place/Megabor+-+Uniformes+e+EPI+-+Rio+de+Janeiro/@-22.9036996,-43.2151039,17.75z/data=!4m15!1m8!3m7!1s0x997efd306831a9:0x8abb9c7935cc810e!2sR.+Figueira+de+Melo,+262+-+Imperial+de+S%C3%A3o+Crist%C3%B3v%C3%A3o,+Rio+de+Janeiro+-+RJ,+20941-001!3b1!8m2!3d-22.903727!4d-43.2151552!16s%2Fg%2F11c43xdkdw!3m5!1s0x997f1feab02183:0xbb692ae711fa2f3!8m2!3d-22.9037273!4d-43.2151444!16s%2Fg%2F11jclzcqv6?entry=ttu&g_ep=EgoyMDI2MDYyNC4wIKXMDSoASAFQAw%3D%3D';
const phoneHref = 'tel:+552125897011';
const locationWidget = footer.querySelector('.footer-column-4 .wd-widget');
if (locationWidget) {
const items = locationWidget.querySelectorAll('li');
if (items[0] && !items[0].querySelector('a')) {
items[0].innerHTML = 'R. Figueira de Melo, 262';
}
if (items[2] && !items[2].querySelector('a')) {
items[2].innerHTML = 'Telefone: (21) 2589-7011';
}
}
const emptyColumn = footer.querySelector('.footer-column-5');
if (emptyColumn && !emptyColumn.querySelector('img, svg, a, li, p, .wp-block-social-links li')) {
emptyColumn.remove();
}
const copyrights = footer.querySelector('.wd-copyrights');
if (copyrights) {
copyrights.innerHTML = '';
copyrights.style.display = 'none';
}
footer.querySelectorAll('.wd-copyrights, .main-footer, .footer-container').forEach(function(scope) {
const text = (scope.textContent || '').toLowerCase();
if (text.indexOf('you must select your brand attribute') !== -1 || text.indexOf('based on woodmart theme') !== -1) {
scope.querySelectorAll('*').forEach(function(node) {
const nodeText = (node.textContent || '').toLowerCase().trim();
if (!nodeText) {
return;
}
if (nodeText.indexOf('you must select your brand attribute') !== -1 || nodeText.indexOf('based on woodmart theme') !== -1) {
node.remove();
}
});
}
});
document.querySelectorAll('.home .wd-footer.footer-container a, .home .wd-footer.footer-container span, .home .wd-footer.footer-container div, .home .wd-footer.footer-container p').forEach(function(node) {
const value = (node.textContent || '').trim();
if (!value) {
return;
}
if (/based on woodmart theme/i.test(value) || /you must select your brand attribute/i.test(value)) {
node.remove();
}
});
}
})();
/* ]]> */
',
'',
'
',
'' + title + '
', (sku ? 'Código/SKU: ' + escapeHtml(sku) + '' : ''), '' + excerpt + '
', '', '',
'Adicionar ao orçamento',
'Ver detalhes',
'
',
'