0 ? popMenu() : (mobileMenu = false) }"
x-init="$watch('mobileMenu', (open) => {
document.body.classList.toggle('overflow-hidden', open);
if (!open) resetMenu();
})"
x-data="{
menuTree: JSON.parse('[{\u0022name\u0022:\u0022Home\u0022,\u0022url\u0022:\u0022\\\/\u0022,\u0022children\u0022:[]},{\u0022name\u0022:\u0022Shop\u0022,\u0022url\u0022:\u0022\\\/products\u0022,\u0022children\u0022:[]},{\u0022name\u0022:\u0022Sahanas Perfumes\u0022,\u0022url\u0022:\u0022\\\/products?collections=sahanas-perfumes\u0022,\u0022children\u0022:[]},{\u0022name\u0022:\u0022Misenta Global\u0022,\u0022url\u0022:\u0022\\\/products?collections=misenta-global\u0022,\u0022children\u0022:[]},{\u0022name\u0022:\u0022Wholesale\u0022,\u0022url\u0022:\u0022\\\/products?collections=wholesale\u0022,\u0022children\u0022:[]},{\u0022name\u0022:\u0022Export\u0022,\u0022url\u0022:\u0022\\\/products?collections=export\u0022,\u0022children\u0022:[]},{\u0022name\u0022:\u0022About Us\u0022,\u0022url\u0022:\u0022\\\/about-us\u0022,\u0022children\u0022:[]},{\u0022name\u0022:\u0022Contact\u0022,\u0022url\u0022:\u0022\\\/contact-us\u0022,\u0022children\u0022:[]}]'),
history: [],
depth: 0,
timer: null,
duration: 500,
// Go one level deeper
pushMenu(title, url, items) {
if (!items || !items.length) return;
clearTimeout(this.timer);
this.history = this.history.slice(0, this.depth);
this.history.push({ title: title, url: url, items: items });
this.depth = this.history.length;
},
// Step back one level, then drop the panel after it has slid away
popMenu() {
if (this.depth === 0) return;
this.depth--;
clearTimeout(this.timer);
this.timer = setTimeout(() => {
this.history = this.history.slice(0, this.depth);
}, this.duration);
},
// Back to the root menu
resetMenu() {
this.depth = 0;
clearTimeout(this.timer);
this.timer = setTimeout(() => { this.history = []; }, this.duration);
},
// Title of the panel one level up (used on the back button)
parentTitle(index) {
return index === 0 ? 'Menu' : this.history[index - 1].title;
},
hasLink(url) {
return url && url !== '#' && url !== 'javascript:void(0)';
},
isActive(url) {
if (!this.hasLink(url)) return false;
try {
const path = new URL(url, window.location.origin).pathname.replace(/\/$/, '') || '/';
const here = window.location.pathname.replace(/\/$/, '') || '/';
return path === here;
} catch (e) {
return false;
}
}
}">