var url = $('#url').val();

(function(c, l, p) {
    function f(a, d) {
        this.element = a;
        this.settings = c.extend({}, n, d);
        this._defaults = n;
        this._name = "slicknav";
        this.init()
    }
    var n = {
        label: "",
        duplicate: !0,
        duration: 200,
        easingOpen: "swing",
        easingClose: "swing",
        closedSymbol: "<span class='glyphicon glyphicon-menu-down' aria-hidden='true'></span>",
        openedSymbol: "<span class='glyphicon glyphicon-menu-up' aria-hidden='true'></span>",
        prependTo: "body",
        appendTo: "",
        parentTag: "a",
        closeOnClick: !1,
        allowParentLinks: !1,
        nestedParentLinks: !0,
        showChildren: !1,
        removeIds: !1,
        removeClasses: !1,
        removeStyles: !1,
        brand: "",
        url: url,
        init: function() {},
        beforeOpen: function() {},
        beforeClose: function() {},
        afterOpen: function() {},
        afterClose: function() {}
    };
    f.prototype.init = function() {
        var a = this,
            d = c(this.element),
            b = this.settings,
            e;
        b.duplicate ? (a.mobileNav = d.clone(), a.mobileNav.removeAttr("id"), a.mobileNav.find("*").each(function(a, b) {
            c(b).removeAttr("id")
        })) : (a.mobileNav = d, a.mobileNav.removeAttr("id"), a.mobileNav.find("*").each(function(a, b) {
            c(b).removeAttr("id")
        }));
        b.removeClasses && (a.mobileNav.removeAttr("class"), a.mobileNav.find("*").each(function(a, b) {
            c(b).removeAttr("class")
        }));
        b.removeStyles && (a.mobileNav.removeAttr("style"),
            a.mobileNav.find("*").each(function(a, b) {
                c(b).removeAttr("style")
            }));
        d = "slicknav_icon";
        "" === b.label && (d += " slicknav_no-text");
        "a" == b.parentTag && (b.parentTag = 'a href="#"');
        a.mobileNav.attr("class", "slicknav_nav");
        e = c('<div class="slicknav_menu" id="menu-mobile"><a href="'+b.url+'" class="slicknav_index"></a><a class="hidden-md hidden-lg carrinho-mobile" href="'+b.url+'carrinho"></a></div>');
        if ("" !== b.brand) {
            var h = c('<div class="slicknav_brand">' + b.brand + "</div>");
            c(e).append(h)
        }
        a.btn = c(["<" + b.parentTag + ' aria-haspopup="true" tabindex="0" class="slicknav_btn slicknav_collapsed">', '<span class="slicknav_menutxt">' +
            b.label + "</span>", '<span class="' + d + '">', '</span>', "</" + b.parentTag + ">"
        ].join(""));
        c(e).append(a.btn);
        "" !== b.appendTo ? c(b.appendTo).append(e) : c(b.prependTo).prepend(e);
        e.append(a.mobileNav);
        d = a.mobileNav.find("li");
        c(d).each(function() {
            var g = c(this),
                d = {};
            d.children = g.children("ul").attr("role", "menu");
            g.data("menu", d);
            if (0 < d.children.length) {
                var d = g.contents(),
                    e = !1,
                    h = [];
                c(d).each(function() {
                    if (c(this).is("ul")) return !1;
                    h.push(this);
                    c(this).is("a") && (e = !0)
                });
                d = c("<" + b.parentTag + ' role="menuitem" aria-haspopup="true" tabindex="-1" class="slicknav_item"/>');
                b.allowParentLinks && !b.nestedParentLinks && e ? c(h).wrapAll('<span class="slicknav_parent-link slicknav_row"/>').parent() : c(h).wrapAll(d).parent().addClass("slicknav_row");
                b.showChildren ? g.addClass("slicknav_open") : g.addClass("slicknav_collapsed");
                g.addClass("slicknav_parent");
                var f = c('<span class="slicknav_arrow">' + (b.showChildren ? b.openedSymbol : b.closedSymbol) + "</span>");
                b.allowParentLinks && !b.nestedParentLinks && e && (f = f.wrap(d).parent());
                c(h).last().after(f)
            } else 0 === g.children().length && g.addClass("slicknav_txtnode");
            g.children("a").attr("role", "menuitem").click(function(d) {
                b.closeOnClick && !c(d.target).parent().closest("li").hasClass("slicknav_parent") && c(a.btn).click()
            });
            b.closeOnClick && b.allowParentLinks && (g.children("a").children("a").click(function(b) {
                c(a.btn).click()
            }), g.find(".slicknav_parent-link a:not(.slicknav_item)").click(function(b) {
                c(a.btn).click()
            }))
        });
        c(d).each(function() {
            var d = c(this).data("menu");
            b.showChildren || a._visibilityToggle(d.children, null, !1, null, !0)
        });
        a._visibilityToggle(a.mobileNav, null, !1, "init", !0);
        a.mobileNav.attr("role", "menu");
        c(l).mousedown(function() {
            a._outlines(!1)
        });
        c(l).keyup(function() {
            a._outlines(!0)
        });
        c(a.btn).click(function(b) {
            b.preventDefault();
            a._menuToggle()
        });
        a.mobileNav.on("click", ".slicknav_item", function(b) {
            b.preventDefault();
            a._itemClick(c(this))
        });
        c(a.btn).keydown(function(b) {
            13 == (b || event).keyCode && (b.preventDefault(),
                a._menuToggle())
        });
        a.mobileNav.on("keydown", ".slicknav_item", function(b) {
            13 == (b || event).keyCode && (b.preventDefault(), a._itemClick(c(b.target)))
        });
        b.allowParentLinks && b.nestedParentLinks && c(".slicknav_item a").click(function(a) {
            a.stopImmediatePropagation()
        })
    };
    f.prototype._menuToggle = function(a) {
        a = this.btn;
        var c = this.mobileNav;
        a.hasClass("slicknav_collapsed") ? (a.removeClass("slicknav_collapsed"), a.addClass("slicknav_open")) : (a.removeClass("slicknav_open"), a.addClass("slicknav_collapsed"));
        a.addClass("slicknav_animating");
        this._visibilityToggle(c, a.parent(), !0, a)
    };
    f.prototype._itemClick = function(a) {
        var c = this.settings,
            b = a.data("menu");
        b || (b = {}, b.arrow = a.children(".slicknav_arrow"), b.ul = a.next("ul"), b.parent = a.parent(), b.parent.hasClass("slicknav_parent-link") && (b.parent = a.parent().parent(), b.ul = a.parent().next("ul")), a.data("menu", b));
        b.parent.hasClass("slicknav_collapsed") ? (b.arrow.html(c.openedSymbol), b.parent.removeClass("slicknav_collapsed"), b.parent.addClass("slicknav_open")) : (b.arrow.html(c.closedSymbol), b.parent.addClass("slicknav_collapsed"),
            b.parent.removeClass("slicknav_open"));
        b.parent.addClass("slicknav_animating");
        this._visibilityToggle(b.ul, b.parent, !0, a)
    };
    f.prototype._visibilityToggle = function(a, d, b, e, h) {
        var f = this,
            k = f.settings,
            l = f._getActionItems(a),
            m = 0;
        b && (m = k.duration);
        a.hasClass("slicknav_hidden") ? (a.removeClass("slicknav_hidden"), h || k.beforeOpen(e), a.slideDown(m, k.easingOpen, function() {
            c(e).removeClass("slicknav_animating");
            c(d).removeClass("slicknav_animating");
            h || k.afterOpen(e)
        }), a.attr("aria-hidden", "false"), l.attr("tabindex",
            "0"), f._setVisAttr(a, !1)) : (a.addClass("slicknav_hidden"), h || k.beforeClose(e), a.slideUp(m, this.settings.easingClose, function() {
            a.attr("aria-hidden", "true");
            l.attr("tabindex", "-1");
            f._setVisAttr(a, !0);
            a.hide();
            c(e).removeClass("slicknav_animating");
            c(d).removeClass("slicknav_animating");
            h ? "init" == e && k.init() : k.afterClose(e)
        }))
    };
    f.prototype._setVisAttr = function(a, d) {
        var b = this,
            e = a.children("li").children("ul").not(".slicknav_hidden");
        d ? e.each(function() {
            var a = c(this);
            a.attr("aria-hidden", "true");
            b._getActionItems(a).attr("tabindex",
                "-1");
            b._setVisAttr(a, d)
        }) : e.each(function() {
            var a = c(this);
            a.attr("aria-hidden", "false");
            b._getActionItems(a).attr("tabindex", "0");
            b._setVisAttr(a, d)
        })
    };
    f.prototype._getActionItems = function(a) {
        var c = a.data("menu");
        if (!c) {
            var c = {},
                b = a.children("li"),
                e = b.find("a");
            c.links = e.add(b.find(".slicknav_item"));
            a.data("menu", c)
        }
        return c.links
    };
    f.prototype._outlines = function(a) {
        a ? c(".slicknav_item, .slicknav_btn").css("outline", "") : c(".slicknav_item, .slicknav_btn").css("outline", "none")
    };
    f.prototype.toggle =
        function() {
            this._menuToggle()
        };
    f.prototype.open = function() {
        this.btn.hasClass("slicknav_collapsed") && this._menuToggle()
    };
    f.prototype.close = function() {
        this.btn.hasClass("slicknav_open") && this._menuToggle()
    };
    c.fn.slicknav = function(a) {
        var d = arguments;
        if (void 0 === a || "object" === typeof a) return this.each(function() {
            c.data(this, "plugin_slicknav") || c.data(this, "plugin_slicknav", new f(this, a))
        });
        if ("string" === typeof a && "_" !== a[0] && "init" !== a) {
            var b;
            this.each(function() {
                var e = c.data(this, "plugin_slicknav");
                e instanceof f && "function" === typeof e[a] && (b = e[a].apply(e, Array.prototype.slice.call(d, 1)))
            });
            return void 0 !== b ? b : this
        }
    }
})(jQuery, document, window);