!function(n, t) {
    "function" == typeof define && define.amd ? define(["jquery"], function(n) {
        return t(n)
    }) : "object" == typeof module && module.exports ? module.exports = t(require("jquery")) : t(n.jQuery)
}(this, function(n) {
    !function(n) {
        "use strict";
        function f(t) {
            return n.each([{
                re: /[\xC0-\xC6]/g,
                ch: "A"
            }, {
                re: /[\xE0-\xE6]/g,
                ch: "a"
            }, {
                re: /[\xC8-\xCB]/g,
                ch: "E"
            }, {
                re: /[\xE8-\xEB]/g,
                ch: "e"
            }, {
                re: /[\xCC-\xCF]/g,
                ch: "I"
            }, {
                re: /[\xEC-\xEF]/g,
                ch: "i"
            }, {
                re: /[\xD2-\xD6]/g,
                ch: "O"
            }, {
                re: /[\xF2-\xF6]/g,
                ch: "o"
            }, {
                re: /[\xD9-\xDC]/g,
                ch: "U"
            }, {
                re: /[\xF9-\xFC]/g,
                ch: "u"
            }, {
                re: /[\xC7-\xE7]/g,
                ch: "c"
            }, {
                re: /[\xD1]/g,
                ch: "N"
            }, {
                re: /[\xF1]/g,
                ch: "n"
            }], function() {
                t = t ? t.replace(this.re, this.ch) : ""
            }),
            t
        }
        function e(i) {
            var f = arguments, r = i, u, e;
            return [].shift.apply(f),
            e = this.each(function() {
                var o = n(this), i, e, s, h;
                if (o.is("select")) {
                    if (i = o.data("selectpicker"),
                    e = "object" == typeof r && r,
                    i) {
                        if (e)
                            for (s in e)
                                e.hasOwnProperty(s) && (i.options[s] = e[s])
                    } else
                        h = n.extend({}, t.DEFAULTS, n.fn.selectpicker.defaults || {}, o.data(), e),
                        h.template = n.extend({}, t.DEFAULTS.template, n.fn.selectpicker.defaults ? n.fn.selectpicker.defaults.template : {}, o.data().template, e.template),
                        o.data("selectpicker", i = new t(this,h));
                    "string" == typeof r && (u = i[r]instanceof Function ? i[r].apply(i, f) : i.options[r])
                }
            }),
            "undefined" != typeof u ? u : e
        }
        var i, u, o, h;
        String.prototype.includes || !function() {
            var i = {}.toString
              , n = function() {
                try {
                    var n = {}
                      , t = Object.defineProperty
                      , i = t(n, n, n) && t
                } catch (n) {}
                return i
            }()
              , r = "".indexOf
              , t = function(n) {
                var u, s;
                if (null == this)
                    throw new TypeError;
                if (u = String(this),
                n && "[object RegExp]" == i.call(n))
                    throw new TypeError;
                var f = u.length
                  , e = String(n)
                  , h = e.length
                  , o = arguments.length > 1 ? arguments[1] : void 0
                  , t = o ? Number(o) : 0;
                return t != t && (t = 0),
                s = Math.min(Math.max(t, 0), f),
                !(h + s > f) && r.call(u, e, t) != -1
            };
            n ? n(String.prototype, "includes", {
                value: t,
                configurable: !0,
                writable: !0
            }) : String.prototype.includes = t
        }();
        String.prototype.startsWith || !function() {
            var n = function() {
                try {
                    var n = {}
                      , t = Object.defineProperty
                      , i = t(n, n, n) && t
                } catch (n) {}
                return i
            }()
              , i = {}.toString
              , t = function(n) {
                var u, f, r;
                if (null == this)
                    throw new TypeError;
                if (u = String(this),
                n && "[object RegExp]" == i.call(n))
                    throw new TypeError;
                var e = u.length
                  , o = String(n)
                  , s = o.length
                  , h = arguments.length > 1 ? arguments[1] : void 0
                  , t = h ? Number(h) : 0;
                if (t != t && (t = 0),
                f = Math.min(Math.max(t, 0), e),
                s + f > e)
                    return !1;
                for (r = -1; ++r < s; )
                    if (u.charCodeAt(f + r) != o.charCodeAt(r))
                        return !1;
                return !0
            };
            n ? n(String.prototype, "startsWith", {
                value: t,
                configurable: !0,
                writable: !0
            }) : String.prototype.startsWith = t
        }();
        Object.keys || (Object.keys = function(n, t, i) {
            i = [];
            for (t in n)
                i.hasOwnProperty.call(n, t) && i.push(t);
            return i
        }
        );
        i = {
            useDefault: !1,
            _set: n.valHooks.select.set
        };
        n.valHooks.select.set = function(t, r) {
            return r && !i.useDefault && n(t).data("selected", !0),
            i._set.apply(this, arguments)
        }
        ;
        u = null;
        o = function() {
            try {
                return new Event("change"),
                !0
            } catch (n) {
                return !1
            }
        }();
        n.fn.triggerNative = function(n) {
            var t, i = this[0];
            i.dispatchEvent ? (o ? t = new Event(n,{
                bubbles: !0
            }) : (t = document.createEvent("Event"),
            t.initEvent(n, !0, !1)),
            i.dispatchEvent(t)) : i.fireEvent ? (t = document.createEventObject(),
            t.eventType = n,
            i.fireEvent("on" + n, t)) : this.trigger(n)
        }
        ;
        n.expr.pseudos.icontains = function(t, i, r) {
            var u = n(t).find("a")
              , f = (u.data("tokens") || u.text()).toString().toUpperCase();
            return f.includes(r[3].toUpperCase())
        }
        ;
        n.expr.pseudos.ibegins = function(t, i, r) {
            var u = n(t).find("a")
              , f = (u.data("tokens") || u.text()).toString().toUpperCase();
            return f.startsWith(r[3].toUpperCase())
        }
        ;
        n.expr.pseudos.aicontains = function(t, i, r) {
            var u = n(t).find("a")
              , f = (u.data("tokens") || u.data("normalizedText") || u.text()).toString().toUpperCase();
            return f.includes(r[3].toUpperCase())
        }
        ;
        n.expr.pseudos.aibegins = function(t, i, r) {
            var u = n(t).find("a")
              , f = (u.data("tokens") || u.data("normalizedText") || u.text()).toString().toUpperCase();
            return f.startsWith(r[3].toUpperCase())
        }
        ;
        var s = function(n) {
            var i = function(t) {
                return n[t]
            }
              , t = "(?:" + Object.keys(n).join("|") + ")"
              , r = RegExp(t)
              , u = RegExp(t, "g");
            return function(n) {
                return n = null == n ? "" : "" + n,
                r.test(n) ? n.replace(u, i) : n
            }
        }
          , r = s({
            "&": "&amp;",
            "<": "&lt;",
            ">": "&gt;",
            '"': "&quot;",
            "'": "&#x27;",
            "`": "&#x60;"
        })
          , c = s({
            "&amp;": "&",
            "&lt;": "<",
            "&gt;": ">",
            "&quot;": '"',
            "&#x27;": "'",
            "&#x60;": "`"
        })
          , t = function(r, u) {
            i.useDefault || (n.valHooks.select.set = i._set,
            i.useDefault = !0);
            this.$element = n(r);
            this.$newElement = null;
            this.$button = null;
            this.$menu = null;
            this.$lis = null;
            this.options = u;
            null === this.options.title && (this.options.title = this.$element.attr("title"));
            var f = this.options.windowPadding;
            "number" == typeof f && (this.options.windowPadding = [f, f, f, f]);
            this.val = t.prototype.val;
            this.render = t.prototype.render;
            this.refresh = t.prototype.refresh;
            this.setStyle = t.prototype.setStyle;
            this.selectAll = t.prototype.selectAll;
            this.deselectAll = t.prototype.deselectAll;
            this.destroy = t.prototype.destroy;
            this.remove = t.prototype.remove;
            this.show = t.prototype.show;
            this.hide = t.prototype.hide;
            this.init()
        };
        t.VERSION = "1.12.4";
        t.DEFAULTS = {
            noneSelectedText: "Nothing selected",
            noneResultsText: "No results matched {0}",
            countSelectedText: function(n) {
                return 1 == n ? "{0} item selected" : "{0} items selected"
            },
            maxOptionsText: function(n, t) {
                return [1 == n ? "Limit reached ({n} item max)" : "Limit reached ({n} items max)", 1 == t ? "Group limit reached ({n} item max)" : "Group limit reached ({n} items max)"]
            },
            selectAllText: "Select All",
            deselectAllText: "Deselect All",
            doneButton: !1,
            doneButtonText: "Close",
            multipleSeparator: ", ",
            styleBase: "btn",
            style: "btn-default",
            size: "auto",
            title: null,
            selectedTextFormat: "values",
            width: !1,
            container: !1,
            hideDisabled: !1,
            showSubtext: !1,
            showIcon: !0,
            showContent: !0,
            dropupAuto: !0,
            header: !1,
            liveSearch: !1,
            liveSearchPlaceholder: null,
            liveSearchNormalize: !1,
            liveSearchStyle: "contains",
            actionsBox: !1,
            iconBase: "glyphicon",
            tickIcon: "glyphicon-ok",
            showTick: !1,
            template: {
                caret: '<span class="caret"><\/span>'
            },
            maxOptions: !1,
            mobile: !1,
            selectOnTab: !1,
            dropdownAlignRight: !1,
            windowPadding: 0
        };
        t.prototype = {
            constructor: t,
            init: function() {
                var t = this
                  , i = this.$element.attr("id");
                this.$element.addClass("bs-select-hidden");
                this.liObj = {};
                this.multiple = this.$element.prop("multiple");
                this.autofocus = this.$element.prop("autofocus");
                this.$newElement = this.createView();
                this.$element.after(this.$newElement).appendTo(this.$newElement);
                this.$button = this.$newElement.children("button");
                this.$menu = this.$newElement.children(".dropdown-menu");
                this.$menuInner = this.$menu.children(".inner");
                this.$searchbox = this.$menu.find("input");
                this.$element.removeClass("bs-select-hidden");
                this.options.dropdownAlignRight === !0 && this.$menu.addClass("dropdown-menu-right");
                "undefined" != typeof i && (this.$button.attr("data-id", i),
                n('label[for="' + i + '"]').click(function(n) {
                    n.preventDefault();
                    t.$button.focus()
                }));
                this.checkDisabled();
                this.clickListener();
                this.options.liveSearch && this.liveSearchListener();
                this.render();
                this.setStyle();
                this.setWidth();
                this.options.container && this.selectPosition();
                this.$menu.data("this", this);
                this.$newElement.data("this", this);
                this.options.mobile && this.mobile();
                this.$newElement.on({
                    "hide.bs.dropdown": function(n) {
                        t.$menuInner.attr("aria-expanded", !1);
                        t.$element.trigger("hide.bs.select", n)
                    },
                    "hidden.bs.dropdown": function(n) {
                        t.$element.trigger("hidden.bs.select", n)
                    },
                    "show.bs.dropdown": function(n) {
                        t.$menuInner.attr("aria-expanded", !0);
                        t.$element.trigger("show.bs.select", n)
                    },
                    "shown.bs.dropdown": function(n) {
                        t.$element.trigger("shown.bs.select", n)
                    }
                });
                t.$element[0].hasAttribute("required") && this.$element.on("invalid", function() {
                    t.$button.addClass("bs-invalid");
                    t.$element.on({
                        "focus.bs.select": function() {
                            t.$button.focus();
                            t.$element.off("focus.bs.select")
                        },
                        "shown.bs.select": function() {
                            t.$element.val(t.$element.val()).off("shown.bs.select")
                        },
                        "rendered.bs.select": function() {
                            this.validity.valid && t.$button.removeClass("bs-invalid");
                            t.$element.off("rendered.bs.select")
                        }
                    });
                    t.$button.on("blur.bs.select", function() {
                        t.$element.focus().blur();
                        t.$button.off("blur.bs.select")
                    })
                });
                setTimeout(function() {
                    t.$element.trigger("loaded.bs.select")
                })
            },
            createDropdown: function() {
                var t = this.multiple || this.options.showTick ? " show-tick" : ""
                  , i = this.$element.parent().hasClass("input-group") ? " input-group-btn" : ""
                  , u = this.autofocus ? " autofocus" : ""
                  , f = this.options.header ? '<div class="popover-title"><button type="button" class="close" aria-hidden="true">&times;<\/button>' + this.options.header + "<\/div>" : ""
                  , e = this.options.liveSearch ? '<div class="bs-searchbox"><input type="text" class="form-control" autocomplete="off"' + (null === this.options.liveSearchPlaceholder ? "" : ' placeholder="' + r(this.options.liveSearchPlaceholder) + '"') + ' role="textbox" aria-label="Search"><\/div>' : ""
                  , o = this.multiple && this.options.actionsBox ? '<div class="bs-actionsbox"><div class="btn-group btn-group-sm btn-block"><button type="button" class="actions-btn bs-select-all btn btn-default">' + this.options.selectAllText + '<\/button><button type="button" class="actions-btn bs-deselect-all btn btn-default">' + this.options.deselectAllText + "<\/button><\/div><\/div>" : ""
                  , s = this.multiple && this.options.doneButton ? '<div class="bs-donebutton"><div class="btn-group btn-block"><button type="button" class="btn btn-sm btn-default">' + this.options.doneButtonText + "<\/button><\/div><\/div>" : ""
                  , h = '<div class="btn-group bootstrap-select' + t + i + '"><button type="button" class="' + this.options.styleBase + ' dropdown-toggle" data-toggle="dropdown"' + u + ' role="button"><span class="filter-option pull-left"><\/span>&nbsp;<span class="bs-caret">' + this.options.template.caret + '<\/span><\/button><div class="dropdown-menu open" role="combobox">' + f + e + o + '<ul class="dropdown-menu inner" role="listbox" aria-expanded="false"><\/ul>' + s + "<\/div><\/div>";
                return n(h)
            },
            createView: function() {
                var n = this.createDropdown()
                  , t = this.createLi();
                return n.find("ul")[0].innerHTML = t,
                n
            },
            reloadLi: function() {
                var n = this.createLi();
                this.$menuInner[0].innerHTML = n
            },
            createLi: function() {
                var t = this, i = [], o = 0, s = document.createElement("option"), u = -1, e = function(n, t, i, r) {
                    return "<li" + ("undefined" != typeof i && "" !== i ? ' class="' + i + '"' : "") + ("undefined" != typeof t && null !== t ? ' data-original-index="' + t + '"' : "") + ("undefined" != typeof r && null !== r ? 'data-optgroup="' + r + '"' : "") + ">" + n + "<\/li>"
                }, c = function(i, u, e, o) {
                    return '<a tabindex="0"' + ("undefined" != typeof u ? ' class="' + u + '"' : "") + (e ? ' style="' + e + '"' : "") + (t.options.liveSearchNormalize ? ' data-normalized-text="' + f(r(n(i).html())) + '"' : "") + ("undefined" != typeof o || null !== o ? ' data-tokens="' + o + '"' : "") + ' role="option">' + i + '<span class="' + t.options.iconBase + " " + t.options.tickIcon + ' check-mark"><\/span><\/a>'
                }, h, a, l;
                return !this.options.title || this.multiple || (u--,
                this.$element.find(".bs-title-option").length) || (h = this.$element[0],
                s.className = "bs-title-option",
                s.innerHTML = this.options.title,
                s.value = "",
                h.insertBefore(s, h.firstChild),
                a = n(h.options[h.selectedIndex]),
                void 0 === a.attr("selected") && void 0 === this.$element.data("selected") && (s.selected = !0)),
                l = this.$element.find("option"),
                l.each(function(f) {
                    var s = n(this), tt, it, w, b;
                    if (u++,
                    !s.hasClass("bs-title-option")) {
                        var a, k = this.className || "", d = r(this.style.cssText), v = s.data("content") ? s.data("content") : s.html(), g = s.data("tokens") ? s.data("tokens") : null, ft = "undefined" != typeof s.data("subtext") ? '<small class="text-muted">' + s.data("subtext") + "<\/small>" : "", y = "undefined" != typeof s.data("icon") ? '<span class="' + t.options.iconBase + " " + s.data("icon") + '"><\/span> ' : "", h = s.parent(), nt = "OPTGROUP" === h[0].tagName, ut = nt && h[0].disabled, p = this.disabled || ut;
                        if ("" !== y && p && (y = "<span>" + y + "<\/span>"),
                        t.options.hideDisabled && (p && !nt || ut))
                            return a = s.data("prevHiddenIndex"),
                            s.next().data("prevHiddenIndex", void 0 !== a ? a : f),
                            void u--;
                        if (s.data("content") || (v = y + '<span class="text">' + v + ft + "<\/span>"),
                        nt && s.data("divider") !== !0) {
                            if (t.options.hideDisabled && p && (void 0 === h.data("allOptionsDisabled") && (tt = h.children(),
                            h.data("allOptionsDisabled", tt.filter(":disabled").length === tt.length)),
                            h.data("allOptionsDisabled")))
                                return void u--;
                            if (it = " " + h[0].className || "",
                            0 === s.index()) {
                                o += 1;
                                var rt = h[0].label
                                  , et = "undefined" != typeof h.data("subtext") ? '<small class="text-muted">' + h.data("subtext") + "<\/small>" : ""
                                  , ot = h.data("icon") ? '<span class="' + t.options.iconBase + " " + h.data("icon") + '"><\/span> ' : "";
                                rt = ot + '<span class="text">' + r(rt) + et + "<\/span>";
                                0 !== f && i.length > 0 && (u++,
                                i.push(e("", null, "divider", o + "div")));
                                u++;
                                i.push(e(rt, null, "dropdown-header" + it, o))
                            }
                            if (t.options.hideDisabled && p)
                                return void u--;
                            i.push(e(c(v, "opt " + k + it, d, g), f, "", o))
                        } else
                            s.data("divider") === !0 ? i.push(e("", f, "divider")) : s.data("hidden") === !0 ? (a = s.data("prevHiddenIndex"),
                            s.next().data("prevHiddenIndex", void 0 !== a ? a : f),
                            i.push(e(c(v, k, d, g), f, "hidden is-hidden"))) : (w = this.previousElementSibling && "OPTGROUP" === this.previousElementSibling.tagName,
                            !w && t.options.hideDisabled && (a = s.data("prevHiddenIndex"),
                            void 0 !== a) && (b = l.eq(a)[0].previousElementSibling,
                            b && "OPTGROUP" === b.tagName && !b.disabled && (w = !0)),
                            w && (u++,
                            i.push(e("", null, "divider", o + "div"))),
                            i.push(e(c(v, k, d, g), f)));
                        t.liObj[f] = u
                    }
                }),
                this.multiple || 0 !== this.$element.find("option:selected").length || this.options.title || this.$element.find("option").eq(0).prop("selected", !0).attr("selected", "selected"),
                i.join("")
            },
            findLis: function() {
                return null == this.$lis && (this.$lis = this.$menu.find("li")),
                this.$lis
            },
            render: function(t) {
                var s, i = this, e = this.$element.find("option"), r, u, f, o, h;
                t !== !1 && e.each(function(n) {
                    var t = i.findLis().eq(i.liObj[n]);
                    i.setDisabled(n, this.disabled || "OPTGROUP" === this.parentNode.tagName && this.parentNode.disabled, t);
                    i.setSelected(n, this.selected, t)
                });
                this.togglePlaceholder();
                this.tabIndex();
                r = e.map(function() {
                    if (this.selected) {
                        if (i.options.hideDisabled && (this.disabled || "OPTGROUP" === this.parentNode.tagName && this.parentNode.disabled))
                            return;
                        var r, t = n(this), u = t.data("icon") && i.options.showIcon ? '<i class="' + i.options.iconBase + " " + t.data("icon") + '"><\/i> ' : "";
                        return r = i.options.showSubtext && t.data("subtext") && !i.multiple ? ' <small class="text-muted">' + t.data("subtext") + "<\/small>" : "",
                        "undefined" != typeof t.attr("title") ? t.attr("title") : t.data("content") && i.options.showContent ? t.data("content").toString() : u + t.html() + r
                    }
                }).toArray();
                u = this.multiple ? r.join(this.options.multipleSeparator) : r[0];
                this.multiple && this.options.selectedTextFormat.indexOf("count") > -1 && (f = this.options.selectedTextFormat.split(">"),
                (f.length > 1 && r.length > f[1] || 1 == f.length && r.length >= 2) && (s = this.options.hideDisabled ? ", [disabled]" : "",
                o = e.not('[data-divider="true"], [data-hidden="true"]' + s).length,
                h = "function" == typeof this.options.countSelectedText ? this.options.countSelectedText(r.length, o) : this.options.countSelectedText,
                u = h.replace("{0}", r.length.toString()).replace("{1}", o.toString())));
                void 0 == this.options.title && (this.options.title = this.$element.attr("title"));
                "static" == this.options.selectedTextFormat && (u = this.options.title);
                u || (u = "undefined" != typeof this.options.title ? this.options.title : this.options.noneSelectedText);
                this.$button.attr("title", c(n.trim(u.replace(/<[^>]*>?/g, ""))));
                this.$button.children(".filter-option").html(u);
                this.$element.trigger("rendered.bs.select")
            },
            setStyle: function(n, t) {
                this.$element.attr("class") && this.$newElement.addClass(this.$element.attr("class").replace(/selectpicker|mobile-device|bs-select-hidden|validate\[.*\]/gi, ""));
                var i = n ? n : this.options.style;
                "add" == t ? this.$button.addClass(i) : "remove" == t ? this.$button.removeClass(i) : (this.$button.removeClass(this.options.style),
                this.$button.addClass(i))
            },
            liHeight: function(t) {
                var y;
                if (t || this.options.size !== !1 && !this.sizeInfo) {
                    var e = document.createElement("div")
                      , u = document.createElement("div")
                      , o = document.createElement("ul")
                      , l = document.createElement("li")
                      , w = document.createElement("li")
                      , a = document.createElement("a")
                      , v = document.createElement("span")
                      , s = this.options.header && this.$menu.find(".popover-title").length > 0 ? this.$menu.find(".popover-title")[0].cloneNode(!0) : null
                      , f = this.options.liveSearch ? document.createElement("div") : null
                      , h = this.options.actionsBox && this.multiple && this.$menu.find(".bs-actionsbox").length > 0 ? this.$menu.find(".bs-actionsbox")[0].cloneNode(!0) : null
                      , c = this.options.doneButton && this.multiple && this.$menu.find(".bs-donebutton").length > 0 ? this.$menu.find(".bs-donebutton")[0].cloneNode(!0) : null;
                    (v.className = "text",
                    e.className = this.$menu[0].parentNode.className + " open",
                    u.className = "dropdown-menu open",
                    o.className = "dropdown-menu inner",
                    l.className = "divider",
                    v.appendChild(document.createTextNode("Inner text")),
                    a.appendChild(v),
                    w.appendChild(a),
                    o.appendChild(w),
                    o.appendChild(l),
                    s && u.appendChild(s),
                    f) && (y = document.createElement("input"),
                    f.className = "bs-searchbox",
                    y.className = "form-control",
                    f.appendChild(y),
                    u.appendChild(f));
                    h && u.appendChild(h);
                    u.appendChild(o);
                    c && u.appendChild(c);
                    e.appendChild(u);
                    document.body.appendChild(e);
                    var b = a.offsetHeight
                      , k = s ? s.offsetHeight : 0
                      , d = f ? f.offsetHeight : 0
                      , g = h ? h.offsetHeight : 0
                      , nt = c ? c.offsetHeight : 0
                      , tt = n(l).outerHeight(!0)
                      , i = "function" == typeof getComputedStyle && getComputedStyle(u)
                      , r = i ? null : n(u)
                      , p = {
                        vert: parseInt(i ? i.paddingTop : r.css("paddingTop")) + parseInt(i ? i.paddingBottom : r.css("paddingBottom")) + parseInt(i ? i.borderTopWidth : r.css("borderTopWidth")) + parseInt(i ? i.borderBottomWidth : r.css("borderBottomWidth")),
                        horiz: parseInt(i ? i.paddingLeft : r.css("paddingLeft")) + parseInt(i ? i.paddingRight : r.css("paddingRight")) + parseInt(i ? i.borderLeftWidth : r.css("borderLeftWidth")) + parseInt(i ? i.borderRightWidth : r.css("borderRightWidth"))
                    }
                      , it = {
                        vert: p.vert + parseInt(i ? i.marginTop : r.css("marginTop")) + parseInt(i ? i.marginBottom : r.css("marginBottom")) + 2,
                        horiz: p.horiz + parseInt(i ? i.marginLeft : r.css("marginLeft")) + parseInt(i ? i.marginRight : r.css("marginRight")) + 2
                    };
                    document.body.removeChild(e);
                    this.sizeInfo = {
                        liHeight: b,
                        headerHeight: k,
                        searchHeight: d,
                        actionsHeight: g,
                        doneButtonHeight: nt,
                        dividerHeight: tt,
                        menuPadding: p,
                        menuExtras: it
                    }
                }
            },
            setSize: function() {
                var l, rt, ut;
                if (this.findLis(),
                this.liHeight(),
                this.options.header && this.$menu.css("padding-top", 0),
                this.options.size !== !1) {
                    var r, k, f, a, e, s, h, v, i = this, t = this.$menu, d = this.$menuInner, o = n(window), ft = this.$newElement[0].offsetHeight, g = this.$newElement[0].offsetWidth, nt = this.sizeInfo.liHeight, y = this.sizeInfo.headerHeight, p = this.sizeInfo.searchHeight, w = this.sizeInfo.actionsHeight, b = this.sizeInfo.doneButtonHeight, et = this.sizeInfo.dividerHeight, c = this.sizeInfo.menuPadding, u = this.sizeInfo.menuExtras, tt = this.options.hideDisabled ? ".disabled" : "", it = function() {
                        var t, f = i.$newElement.offset(), u = n(i.options.container), r;
                        i.options.container && !u.is("body") ? (t = u.offset(),
                        t.top += parseInt(u.css("borderTopWidth")),
                        t.left += parseInt(u.css("borderLeftWidth"))) : t = {
                            top: 0,
                            left: 0
                        };
                        r = i.options.windowPadding;
                        e = f.top - t.top - o.scrollTop();
                        s = o.height() - e - ft - t.top - r[2];
                        h = f.left - t.left - o.scrollLeft();
                        v = o.width() - h - g - t.left - r[1];
                        e -= r[0];
                        h -= r[3]
                    };
                    (it(),
                    "auto" === this.options.size) ? (l = function() {
                        var o, tt = function(t, i) {
                            return function(r) {
                                return i ? r.classList ? r.classList.contains(t) : n(r).hasClass(t) : !(r.classList ? r.classList.contains(t) : n(r).hasClass(t))
                            }
                        }, rt = i.$menuInner[0].getElementsByTagName("li"), l = Array.prototype.filter ? Array.prototype.filter.call(rt, tt("hidden", !1)) : i.$lis.not(".hidden"), ut = Array.prototype.filter ? Array.prototype.filter.call(l, tt("dropdown-header", !0)) : l.filter(".dropdown-header");
                        it();
                        r = s - u.vert;
                        k = v - u.horiz;
                        i.options.container ? (t.data("height") || t.data("height", t.height()),
                        f = t.data("height"),
                        t.data("width") || t.data("width", t.width()),
                        a = t.data("width")) : (f = t.height(),
                        a = t.width());
                        i.options.dropupAuto && i.$newElement.toggleClass("dropup", e > s && r - u.vert < f);
                        i.$newElement.hasClass("dropup") && (r = e - u.vert);
                        "auto" === i.options.dropdownAlignRight && t.toggleClass("dropdown-menu-right", h > v && k - u.horiz < a - g);
                        o = l.length + ut.length > 3 ? 3 * nt + u.vert - 2 : 0;
                        t.css({
                            "max-height": r + "px",
                            overflow: "hidden",
                            "min-height": o + y + p + w + b + "px"
                        });
                        d.css({
                            "max-height": r - y - p - w - b - c.vert + "px",
                            "overflow-y": "auto",
                            "min-height": Math.max(o - c.vert, 0) + "px"
                        })
                    }
                    ,
                    l(),
                    this.$searchbox.off("input.getSize propertychange.getSize").on("input.getSize propertychange.getSize", l),
                    o.off("resize.getSize scroll.getSize").on("resize.getSize scroll.getSize", l)) : this.options.size && "auto" != this.options.size && this.$lis.not(tt).length > this.options.size && (rt = this.$lis.not(".divider").not(tt).children().slice(0, this.options.size).last().parent().index(),
                    ut = this.$lis.slice(0, rt + 1).filter(".divider").length,
                    r = nt * this.options.size + ut * et + c.vert,
                    i.options.container ? (t.data("height") || t.data("height", t.height()),
                    f = t.data("height")) : f = t.height(),
                    i.options.dropupAuto && this.$newElement.toggleClass("dropup", e > s && r - u.vert < f),
                    t.css({
                        "max-height": r + y + p + w + b + "px",
                        overflow: "hidden",
                        "min-height": ""
                    }),
                    d.css({
                        "max-height": r - c.vert + "px",
                        "overflow-y": "auto",
                        "min-height": ""
                    }))
                }
            },
            setWidth: function() {
                if ("auto" === this.options.width) {
                    this.$menu.css("min-width", "0");
                    var n = this.$menu.parent().clone().appendTo("body")
                      , t = this.options.container ? this.$newElement.clone().appendTo("body") : n
                      , i = n.children(".dropdown-menu").outerWidth()
                      , r = t.css("width", "auto").children("button").outerWidth();
                    n.remove();
                    t.remove();
                    this.$newElement.css("width", Math.max(i, r) + "px")
                } else
                    "fit" === this.options.width ? (this.$menu.css("min-width", ""),
                    this.$newElement.css("width", "").addClass("fit-width")) : this.options.width ? (this.$menu.css("min-width", ""),
                    this.$newElement.css("width", this.options.width)) : (this.$menu.css("min-width", ""),
                    this.$newElement.css("width", ""));
                this.$newElement.hasClass("fit-width") && "fit" !== this.options.width && this.$newElement.removeClass("fit-width")
            },
            selectPosition: function() {
                this.$bsContainer = n('<div class="bs-container" />');
                var u, i, f, t = this, r = n(this.options.container), e = function(n) {
                    t.$bsContainer.addClass(n.attr("class").replace(/form-control|fit-width/gi, "")).toggleClass("dropup", n.hasClass("dropup"));
                    u = n.offset();
                    r.is("body") ? i = {
                        top: 0,
                        left: 0
                    } : (i = r.offset(),
                    i.top += parseInt(r.css("borderTopWidth")) - r.scrollTop(),
                    i.left += parseInt(r.css("borderLeftWidth")) - r.scrollLeft());
                    f = n.hasClass("dropup") ? 0 : n[0].offsetHeight;
                    t.$bsContainer.css({
                        top: u.top - i.top + f,
                        left: u.left - i.left,
                        width: n[0].offsetWidth
                    })
                };
                this.$button.on("click", function() {
                    var i = n(this);
                    t.isDisabled() || (e(t.$newElement),
                    t.$bsContainer.appendTo(t.options.container).toggleClass("open", !i.hasClass("open")).append(t.$menu))
                });
                n(window).on("resize scroll", function() {
                    e(t.$newElement)
                });
                this.$element.on("hide.bs.select", function() {
                    t.$menu.data("height", t.$menu.height());
                    t.$bsContainer.detach()
                })
            },
            setSelected: function(n, t, i) {
                i || (this.togglePlaceholder(),
                i = this.findLis().eq(this.liObj[n]));
                i.toggleClass("selected", t).find("a").attr("aria-selected", t)
            },
            setDisabled: function(n, t, i) {
                i || (i = this.findLis().eq(this.liObj[n]));
                t ? i.addClass("disabled").children("a").attr("href", "#").attr("tabindex", -1).attr("aria-disabled", !0) : i.removeClass("disabled").children("a").removeAttr("href").attr("tabindex", 0).attr("aria-disabled", !1)
            },
            isDisabled: function() {
                return this.$element[0].disabled
            },
            checkDisabled: function() {
                var n = this;
                this.isDisabled() ? (this.$newElement.addClass("disabled"),
                this.$button.addClass("disabled").attr("tabindex", -1).attr("aria-disabled", !0)) : (this.$button.hasClass("disabled") && (this.$newElement.removeClass("disabled"),
                this.$button.removeClass("disabled").attr("aria-disabled", !1)),
                this.$button.attr("tabindex") != -1 || this.$element.data("tabindex") || this.$button.removeAttr("tabindex"));
                this.$button.click(function() {
                    return !n.isDisabled()
                })
            },
            togglePlaceholder: function() {
                var n = this.$element.val();
                this.$button.toggleClass("bs-placeholder", null === n || "" === n || n.constructor === Array && 0 === n.length)
            },
            tabIndex: function() {
                this.$element.data("tabindex") !== this.$element.attr("tabindex") && this.$element.attr("tabindex") !== -98 && "-98" !== this.$element.attr("tabindex") && (this.$element.data("tabindex", this.$element.attr("tabindex")),
                this.$button.attr("tabindex", this.$element.data("tabindex")));
                this.$element.attr("tabindex", -98)
            },
            clickListener: function() {
                var t = this
                  , i = n(document);
                i.data("spaceSelect", !1);
                this.$button.on("keyup", function(n) {
                    /(32)/.test(n.keyCode.toString(10)) && i.data("spaceSelect") && (n.preventDefault(),
                    i.data("spaceSelect", !1))
                });
                this.$button.on("click", function() {
                    t.setSize()
                });
                this.$element.on("shown.bs.select", function() {
                    var i, n;
                    if (t.options.liveSearch || t.multiple) {
                        if (!t.multiple) {
                            if (i = t.liObj[t.$element[0].selectedIndex],
                            "number" != typeof i || t.options.size === !1)
                                return;
                            n = t.$lis.eq(i)[0].offsetTop - t.$menuInner[0].offsetTop;
                            n = n - t.$menuInner[0].offsetHeight / 2 + t.sizeInfo.liHeight / 2;
                            t.$menuInner[0].scrollTop = n
                        }
                    } else
                        t.$menuInner.find(".selected a").focus()
                });
                this.$menuInner.on("click", "li a", function(i) {
                    var h = n(this), o = h.parent().data("originalIndex"), nt = t.$element.val(), tt = t.$element.prop("selectedIndex"), a = !0, p, w, g;
                    if (t.multiple && 1 !== t.options.maxOptions && i.stopPropagation(),
                    i.preventDefault(),
                    !t.isDisabled() && !h.parent().hasClass("disabled")) {
                        var c = t.$element.find("option")
                          , e = c.eq(o)
                          , v = e.prop("selected")
                          , y = e.parent("optgroup")
                          , r = t.options.maxOptions
                          , f = y.data("maxOptions") || !1;
                        if (t.multiple) {
                            if ((e.prop("selected", !v),
                            t.setSelected(o, !v),
                            h.blur(),
                            r !== !1 || f !== !1) && (p = r < c.filter(":selected").length,
                            w = f < y.find("option:selected").length,
                            r && p || f && w))
                                if (r && 1 == r)
                                    c.prop("selected", !1),
                                    e.prop("selected", !0),
                                    t.$menuInner.find(".selected").removeClass("selected"),
                                    t.setSelected(o, !0);
                                else if (f && 1 == f)
                                    y.find("option:selected").prop("selected", !1),
                                    e.prop("selected", !0),
                                    g = h.parent().data("optgroup"),
                                    t.$menuInner.find('[data-optgroup="' + g + '"]').removeClass("selected"),
                                    t.setSelected(o, !0);
                                else {
                                    var b = "string" == typeof t.options.maxOptionsText ? [t.options.maxOptionsText, t.options.maxOptionsText] : t.options.maxOptionsText
                                      , s = "function" == typeof b ? b(r, f) : b
                                      , k = s[0].replace("{n}", r)
                                      , d = s[1].replace("{n}", f)
                                      , l = n('<div class="notify"><\/div>');
                                    s[2] && (k = k.replace("{var}", s[2][r > 1 ? 0 : 1]),
                                    d = d.replace("{var}", s[2][f > 1 ? 0 : 1]));
                                    e.prop("selected", !1);
                                    t.$menu.append(l);
                                    r && p && (l.append(n("<div>" + k + "<\/div>")),
                                    a = !1,
                                    t.$element.trigger("maxReached.bs.select"));
                                    f && w && (l.append(n("<div>" + d + "<\/div>")),
                                    a = !1,
                                    t.$element.trigger("maxReachedGrp.bs.select"));
                                    setTimeout(function() {
                                        t.setSelected(o, !1)
                                    }, 10);
                                    l.delay(750).fadeOut(300, function() {
                                        n(this).remove()
                                    })
                                }
                        } else
                            c.prop("selected", !1),
                            e.prop("selected", !0),
                            t.$menuInner.find(".selected").removeClass("selected").find("a").attr("aria-selected", !1),
                            t.setSelected(o, !0);
                        !t.multiple || t.multiple && 1 === t.options.maxOptions ? t.$button.focus() : t.options.liveSearch && t.$searchbox.focus();
                        a && (nt != t.$element.val() && t.multiple || tt != t.$element.prop("selectedIndex") && !t.multiple) && (u = [o, e.prop("selected"), v],
                        t.$element.triggerNative("change"))
                    }
                });
                this.$menu.on("click", "li.disabled a, .popover-title, .popover-title :not(.close)", function(i) {
                    i.currentTarget == this && (i.preventDefault(),
                    i.stopPropagation(),
                    t.options.liveSearch && !n(i.target).hasClass("close") ? t.$searchbox.focus() : t.$button.focus())
                });
                this.$menuInner.on("click", ".divider, .dropdown-header", function(n) {
                    n.preventDefault();
                    n.stopPropagation();
                    t.options.liveSearch ? t.$searchbox.focus() : t.$button.focus()
                });
                this.$menu.on("click", ".popover-title .close", function() {
                    t.$button.click()
                });
                this.$searchbox.on("click", function(n) {
                    n.stopPropagation()
                });
                this.$menu.on("click", ".actions-btn", function(i) {
                    t.options.liveSearch ? t.$searchbox.focus() : t.$button.focus();
                    i.preventDefault();
                    i.stopPropagation();
                    n(this).hasClass("bs-select-all") ? t.selectAll() : t.deselectAll()
                });
                this.$element.change(function() {
                    t.render(!1);
                    t.$element.trigger("changed.bs.select", u);
                    u = null
                })
            },
            liveSearchListener: function() {
                var t = this
                  , i = n('<li class="no-results"><\/li>');
                this.$button.on("click.dropdown.data-api", function() {
                    t.$menuInner.find(".active").removeClass("active");
                    t.$searchbox.val() && (t.$searchbox.val(""),
                    t.$lis.not(".is-hidden").removeClass("hidden"),
                    i.parent().length && i.remove());
                    t.multiple || t.$menuInner.find(".selected").addClass("active");
                    setTimeout(function() {
                        t.$searchbox.focus()
                    }, 10)
                });
                this.$searchbox.on("click.dropdown.data-api focus.dropdown.data-api touchend.dropdown.data-api", function(n) {
                    n.stopPropagation()
                });
                this.$searchbox.on("input propertychange", function() {
                    var o, e, u, s;
                    (t.$lis.not(".is-hidden").removeClass("hidden"),
                    t.$lis.filter(".active").removeClass("active"),
                    i.remove(),
                    t.$searchbox.val()) && (e = t.$lis.not(".is-hidden, .divider, .dropdown-header"),
                    (o = t.options.liveSearchNormalize ? e.not(":a" + t._searchStyle() + '("' + f(t.$searchbox.val()) + '")') : e.not(":" + t._searchStyle() + '("' + t.$searchbox.val() + '")'),
                    o.length === e.length) ? (i.html(t.options.noneResultsText.replace("{0}", '"' + r(t.$searchbox.val()) + '"')),
                    t.$menuInner.append(i),
                    t.$lis.addClass("hidden")) : (o.addClass("hidden"),
                    s = t.$lis.not(".hidden"),
                    s.each(function(t) {
                        var i = n(this);
                        i.hasClass("divider") ? void 0 === u ? i.addClass("hidden") : (u && u.addClass("hidden"),
                        u = i) : i.hasClass("dropdown-header") && s.eq(t + 1).data("optgroup") !== i.data("optgroup") ? i.addClass("hidden") : u = null
                    }),
                    u && u.addClass("hidden"),
                    e.not(".hidden").first().addClass("active"),
                    t.$menuInner.scrollTop(0)))
                })
            },
            _searchStyle: function() {
                return {
                    begins: "ibegins",
                    startsWith: "ibegins"
                }[this.options.liveSearchStyle] || "icontains"
            },
            val: function(n) {
                return "undefined" != typeof n ? (this.$element.val(n),
                this.render(),
                this.$element) : this.$element.val()
            },
            changeAll: function(t) {
                var r, f;
                if (this.multiple) {
                    "undefined" == typeof t && (t = !0);
                    this.findLis();
                    var e = this.$element.find("option")
                      , i = this.$lis.not(".divider, .dropdown-header, .disabled, .hidden")
                      , o = i.length
                      , u = [];
                    if (t) {
                        if (i.filter(".selected").length === i.length)
                            return
                    } else if (0 === i.filter(".selected").length)
                        return;
                    for (i.toggleClass("selected", t),
                    r = 0; r < o; r++)
                        f = i[r].getAttribute("data-original-index"),
                        u[u.length] = e.eq(f)[0];
                    n(u).prop("selected", t);
                    this.render(!1);
                    this.togglePlaceholder();
                    this.$element.triggerNative("change")
                }
            },
            selectAll: function() {
                return this.changeAll(!0)
            },
            deselectAll: function() {
                return this.changeAll(!1)
            },
            toggle: function(n) {
                n = n || window.event;
                n && n.stopPropagation();
                this.$button.trigger("click")
            },
            keydown: function(t) {
                var r, u, h, e, o = n(this), y = o.is("input") ? o.parent().parent() : o.parent(), i = y.data("this"), l = ":not(.disabled, .hidden, .dropdown-header, .divider)", a = {
                    32: " ",
                    48: "0",
                    49: "1",
                    50: "2",
                    51: "3",
                    52: "4",
                    53: "5",
                    54: "6",
                    55: "7",
                    56: "8",
                    57: "9",
                    59: ";",
                    65: "a",
                    66: "b",
                    67: "c",
                    68: "d",
                    69: "e",
                    70: "f",
                    71: "g",
                    72: "h",
                    73: "i",
                    74: "j",
                    75: "k",
                    76: "l",
                    77: "m",
                    78: "n",
                    79: "o",
                    80: "p",
                    81: "q",
                    82: "r",
                    83: "s",
                    84: "t",
                    85: "u",
                    86: "v",
                    87: "w",
                    88: "x",
                    89: "y",
                    90: "z",
                    96: "0",
                    97: "1",
                    98: "2",
                    99: "3",
                    100: "4",
                    101: "5",
                    102: "6",
                    103: "7",
                    104: "8",
                    105: "9"
                }, f, v, s, c;
                if (e = i.$newElement.hasClass("open"),
                !e && (t.keyCode >= 48 && t.keyCode <= 57 || t.keyCode >= 96 && t.keyCode <= 105 || t.keyCode >= 65 && t.keyCode <= 90))
                    return i.options.container ? i.$button.trigger("click") : (i.setSize(),
                    i.$menu.parent().addClass("open"),
                    e = !0),
                    void i.$searchbox.focus();
                if (i.options.liveSearch && /(^9$|27)/.test(t.keyCode.toString(10)) && e && (t.preventDefault(),
                t.stopPropagation(),
                i.$menuInner.click(),
                i.$button.focus()),
                /(38|40)/.test(t.keyCode.toString(10))) {
                    if (r = i.$lis.filter(l),
                    !r.length)
                        return;
                    u = i.options.liveSearch ? r.index(r.filter(".active")) : r.index(r.find("a").filter(":focus").parent());
                    h = i.$menuInner.data("prevIndex");
                    38 == t.keyCode ? (!i.options.liveSearch && u != h || u == -1 || u--,
                    u < 0 && (u += r.length)) : 40 == t.keyCode && ((i.options.liveSearch || u == h) && u++,
                    u %= r.length);
                    i.$menuInner.data("prevIndex", u);
                    i.options.liveSearch ? (t.preventDefault(),
                    o.hasClass("dropdown-toggle") || (r.removeClass("active").eq(u).addClass("active").children("a").focus(),
                    o.focus())) : r.eq(u).children("a").focus()
                } else
                    o.is("input") || (s = [],
                    r = i.$lis.filter(l),
                    r.each(function(i) {
                        n.trim(n(this).children("a").text().toLowerCase()).substring(0, 1) == a[t.keyCode] && s.push(i)
                    }),
                    f = n(document).data("keycount"),
                    f++,
                    n(document).data("keycount", f),
                    v = n.trim(n(":focus").text().toLowerCase()).substring(0, 1),
                    v != a[t.keyCode] ? (f = 1,
                    n(document).data("keycount", f)) : f >= s.length && (n(document).data("keycount", 0),
                    f > s.length && (f = 1)),
                    r.eq(s[f - 1]).children("a").focus());
                (/(13|32)/.test(t.keyCode.toString(10)) || /(^9$)/.test(t.keyCode.toString(10)) && i.options.selectOnTab) && e && ((/(32)/.test(t.keyCode.toString(10)) || t.preventDefault(),
                i.options.liveSearch) ? /(32)/.test(t.keyCode.toString(10)) || (i.$menuInner.find(".active a").click(),
                o.focus()) : (c = n(":focus"),
                c.click(),
                c.focus(),
                t.preventDefault(),
                n(document).data("spaceSelect", !0)),
                n(document).data("keycount", 0));
                (/(^9$|27)/.test(t.keyCode.toString(10)) && e && (i.multiple || i.options.liveSearch) || /(27)/.test(t.keyCode.toString(10)) && !e) && (i.$menu.parent().removeClass("open"),
                i.options.container && i.$newElement.removeClass("open"),
                i.$button.focus())
            },
            mobile: function() {
                this.$element.addClass("mobile-device")
            },
            refresh: function() {
                this.$lis = null;
                this.liObj = {};
                this.reloadLi();
                this.render();
                this.checkDisabled();
                this.liHeight(!0);
                this.setStyle();
                this.setWidth();
                this.$lis && this.$searchbox.trigger("propertychange");
                this.$element.trigger("refreshed.bs.select")
            },
            hide: function() {
                this.$newElement.hide()
            },
            show: function() {
                this.$newElement.show()
            },
            remove: function() {
                this.$newElement.remove();
                this.$element.remove()
            },
            destroy: function() {
                this.$newElement.before(this.$element).remove();
                this.$bsContainer ? this.$bsContainer.remove() : this.$menu.remove();
                this.$element.off(".bs.select").removeData("selectpicker").removeClass("bs-select-hidden selectpicker")
            }
        };
        h = n.fn.selectpicker;
        n.fn.selectpicker = e;
        n.fn.selectpicker.Constructor = t;
        n.fn.selectpicker.noConflict = function() {
            return n.fn.selectpicker = h,
            this
        }
        ;
        n(document).data("keycount", 0).on("keydown.bs.select", '.bootstrap-select [data-toggle=dropdown], .bootstrap-select [role="listbox"], .bs-searchbox input', t.prototype.keydown).on("focusin.modal", '.bootstrap-select [data-toggle=dropdown], .bootstrap-select [role="listbox"], .bs-searchbox input', function(n) {
            n.stopPropagation()
        });
        n(window).on("load.bs.select.data-api", function() {
            n(".selectpicker").each(function() {
                var t = n(this);
                e.call(t, t.data())
            })
        })
    }(n)
})
