/*!
* ui-select
* http://github.com/angular-ui/ui-select
* Version: 0.11.2 - 2015-03-17T04:08:46.474Z
* License: MIT
*/
! function() {
"use strict";
var e = {
TAB: 9,
ENTER: 13,
ESC: 27,
SPACE: 32,
LEFT: 37,
UP: 38,
RIGHT: 39,
DOWN: 40,
SHIFT: 16,
CTRL: 17,
ALT: 18,
PAGE_UP: 33,
PAGE_DOWN: 34,
HOME: 36,
END: 35,
BACKSPACE: 8,
DELETE: 46,
COMMAND: 91,
MAP: { 91: "COMMAND", 8: "BACKSPACE", 9: "TAB", 13: "ENTER", 16: "SHIFT", 17: "CTRL", 18: "ALT", 19: "PAUSEBREAK", 20: "CAPSLOCK", 27: "ESC", 32: "SPACE", 33: "PAGE_UP", 34: "PAGE_DOWN", 35: "END", 36: "HOME", 37: "LEFT", 38: "UP", 39: "RIGHT", 40: "DOWN", 43: "+", 44: "PRINTSCREEN", 45: "INSERT", 46: "DELETE", 48: "0", 49: "1", 50: "2", 51: "3", 52: "4", 53: "5", 54: "6", 55: "7", 56: "8", 57: "9", 59: ";", 61: "=", 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", 106: "*", 107: "+", 109: "-", 110: ".", 111: "/", 112: "F1", 113: "F2", 114: "F3", 115: "F4", 116: "F5", 117: "F6", 118: "F7", 119: "F8", 120: "F9", 121: "F10", 122: "F11", 123: "F12", 144: "NUMLOCK", 145: "SCROLLLOCK", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", 221: "]", 222: "'" },
isControl: function(t) {
var c = t.which;
switch (c) {
case e.COMMAND:
case e.SHIFT:
case e.CTRL:
case e.ALT:
return !0
}
return t.metaKey ? !0 : !1
},
isFunctionKey: function(e) { return e = e.which ? e.which : e, e >= 112 && 123 >= e },
isVerticalMovement: function(t) { return ~[e.UP, e.DOWN].indexOf(t) },
isHorizontalMovement: function(t) { return ~[e.LEFT, e.RIGHT, e.BACKSPACE, e.DELETE].indexOf(t) }
};
void 0 === angular.element.prototype.querySelectorAll && (angular.element.prototype.querySelectorAll = function(e) { return angular.element(this[0].querySelectorAll(e)) }), void 0 === angular.element.prototype.closest && (angular.element.prototype.closest = function(e) {
for (var t = this[0], c = t.matches || t.webkitMatchesSelector || t.mozMatchesSelector || t.msMatchesSelector; t;) {
if (c.bind(t)(e)) return t;
t = t.parentElement
}
return !1
});
var t = 0,
c = angular.module("ui.select", []).constant("uiSelectConfig", { theme: "bootstrap", searchEnabled: !0, sortable: !1, placeholder: "", refreshDelay: 1e3, closeOnSelect: !0, generateId: function() { return t++ }, appendToBody: !1 }).service("uiSelectMinErr", function() {
var e = angular.$$minErr("ui.select");
return function() {
var t = e.apply(this, arguments),
c = t.message.replace(new RegExp("\nhttp://errors.angularjs.org/.*"), "");
return new Error(c)
}
}).directive("uisTranscludeAppend", function() { return { link: function(e, t, c, i, s) { s(e, function(e) { t.append(e) }) } } }).filter("highlight", function() {
function e(e) { return e.replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1") }
return function(t, c) { return c && t ? t.replace(new RegExp(e(c), "gi"), '$&') : t }
}).factory("uisOffset", ["$document", "$window", function(e, t) { return function(c) { var i = c[0].getBoundingClientRect(); return { width: i.width || c.prop("offsetWidth"), height: i.height || c.prop("offsetHeight"), top: i.top + (t.pageYOffset || e[0].documentElement.scrollTop), left: i.left + (t.pageXOffset || e[0].documentElement.scrollLeft) } } }]);
c.directive("uiSelectChoices", ["uiSelectConfig", "uisRepeatParser", "uiSelectMinErr", "$compile", function(e, t, c, i) {
return {
restrict: "EA",
require: "^uiSelect",
replace: !0,
transclude: !0,
templateUrl: function(t) { var c = t.parent().attr("theme") || e.theme; return c + "/choices.tpl.html" },
compile: function(s, l) {
if (!l.repeat) throw c("repeat", "Expected 'repeat' expression.");
return function(s, l, n, a, r) {
var o = n.groupBy;
if (a.parseRepeatAttr(n.repeat, o), a.disableChoiceExpression = n.uiDisableChoice, a.onHighlightCallback = n.onHighlight, o) {
var u = l.querySelectorAll(".ui-select-choices-group");
if (1 !== u.length) throw c("rows", "Expected 1 .ui-select-choices-group but got '{0}'.", u.length);
u.attr("ng-repeat", t.getGroupNgRepeatExpression())
}
var d = l.querySelectorAll(".ui-select-choices-row");
if (1 !== d.length) throw c("rows", "Expected 1 .ui-select-choices-row but got '{0}'.", d.length);
d.attr("ng-repeat", t.getNgRepeatExpression(a.parserResult.itemName, "$select.items", a.parserResult.trackByExp, o)).attr("ng-if", "$select.open").attr("ng-mouseenter", "$select.setActiveItem(" + a.parserResult.itemName + ")").attr("ng-click", "$select.select(" + a.parserResult.itemName + ",false,$event)");
var p = l.querySelectorAll(".ui-select-choices-row-inner");
if (1 !== p.length) throw c("rows", "Expected 1 .ui-select-choices-row-inner but got '{0}'.", p.length);
p.attr("uis-transclude-append", ""), i(l, r)(s), s.$watch("$select.search", function(e) { e && !a.open && a.multiple && a.activate(!1, !0), a.activeIndex = a.tagging.isActivated ? -1 : 0, a.refresh(n.refresh) }), n.$observe("refreshDelay", function() {
var t = s.$eval(n.refreshDelay);
a.refreshDelay = void 0 !== t ? t : e.refreshDelay
})
}
}
}
}]), c.controller("uiSelectCtrl", ["$scope", "$element", "$timeout", "$filter", "uisRepeatParser", "uiSelectMinErr", "uiSelectConfig", function(t, c, i, s, l, n, a) {
function r() {
(d.resetSearchInput || void 0 === d.resetSearchInput && a.resetSearchInput) && (d.search = p, d.selected && d.items.length && !d.multiple && (d.activeIndex = d.items.indexOf(d.selected)))
}
function o(t) {
var c = !0;
switch (t) {
case e.DOWN:
!d.open && d.multiple ? d.activate(!1, !0) : d.activeIndex < d.items.length - 1 && d.activeIndex++;
break;
case e.UP:
!d.open && d.multiple ? d.activate(!1, !0) : (d.activeIndex > 0 || 0 === d.search.length && d.tagging.isActivated && d.activeIndex > -1) && d.activeIndex--;
break;
case e.TAB:
(!d.multiple || d.open) && d.select(d.items[d.activeIndex], !0);
break;
case e.ENTER:
d.open && d.activeIndex >= 0 ? d.select(d.items[d.activeIndex]) : d.activate(!1, !0);
break;
case e.ESC:
d.close();
break;
default:
c = !1
}
return c
}
function u() {
var e = c.querySelectorAll(".ui-select-choices-content"),
t = e.querySelectorAll(".ui-select-choices-row");
if (t.length < 1) throw n("choices", "Expected multiple .ui-select-choices-row but got '{0}'.", t.length);
if (!(d.activeIndex < 0)) {
var i = t[d.activeIndex],
s = i.offsetTop + i.clientHeight - e[0].scrollTop,
l = e[0].offsetHeight;
s > l ? e[0].scrollTop += s - l : s < i.clientHeight && (d.isGrouped && 0 === d.activeIndex ? e[0].scrollTop = 0 : e[0].scrollTop -= i.clientHeight - s)
}
}
var d = this,
p = "";
if (d.placeholder = a.placeholder, d.searchEnabled = a.searchEnabled, d.sortable = a.sortable, d.refreshDelay = a.refreshDelay, d.removeSelected = !1, d.closeOnSelect = !0, d.search = p, d.activeIndex = 0, d.items = [], d.open = !1, d.focus = !1, d.disabled = !1, d.selected = void 0, d.focusser = void 0, d.resetSearchInput = !0, d.multiple = void 0, d.disableChoiceExpression = void 0, d.tagging = { isActivated: !1, fct: void 0 }, d.taggingTokens = { isActivated: !1, tokens: void 0 }, d.lockChoiceExpression = void 0, d.clickTriggeredSelect = !1, d.$filter = s, d.searchInput = c.querySelectorAll("input.ui-select-search"), 1 !== d.searchInput.length) throw n("searchInput", "Expected 1 input.ui-select-search but got '{0}'.", d.searchInput.length);
d.isEmpty = function() { return angular.isUndefined(d.selected) || null === d.selected || "" === d.selected }, d.activate = function(e, c) { d.disabled || d.open || (c || r(), t.$broadcast("uis:activate"), d.open = !0, d.activeIndex = d.activeIndex >= d.items.length ? 0 : d.activeIndex, -1 === d.activeIndex && d.taggingLabel !== !1 && (d.activeIndex = 0), i(function() { d.search = e || d.search, d.searchInput[0].focus() })) }, d.findGroupByName = function(e) { return d.groups && d.groups.filter(function(t) { return t.name === e })[0] }, d.parseRepeatAttr = function(e, c) {
function i(e) {
d.groups = [], angular.forEach(e, function(e) {
var i = t.$eval(c),
s = angular.isFunction(i) ? i(e) : e[i],
l = d.findGroupByName(s);
l ? l.items.push(e) : d.groups.push({ name: s, items: [e] })
}), d.items = [], d.groups.forEach(function(e) { d.items = d.items.concat(e.items) })
}
function s(e) { d.items = e }
d.setItemsFn = c ? i : s, d.parserResult = l.parse(e), d.isGrouped = !!c, d.itemProperty = d.parserResult.itemName, d.refreshItems = function(e) {
e = e || d.parserResult.source(t);
var c = d.selected;
if (angular.isArray(c) && !c.length || !d.removeSelected) d.setItemsFn(e);
else if (void 0 !== e) {
var i = e.filter(function(e) { return c.indexOf(e) < 0 });
d.setItemsFn(i)
}
}, t.$watchCollection(d.parserResult.source, function(e) {
if (void 0 === e || null === e) d.items = [];
else {
if (!angular.isArray(e)) throw n("items", "Expected an array but got '{0}'.", e);
d.refreshItems(e), d.ngModel.$modelValue = null
}
})
};
var h;
d.refresh = function(e) { void 0 !== e && (h && i.cancel(h), h = i(function() { t.$eval(e) }, d.refreshDelay)) }, d.setActiveItem = function(e) { d.activeIndex = d.items.indexOf(e) }, d.isActive = function(e) {
if (!d.open) return !1;
var t = d.items.indexOf(e[d.itemProperty]),
c = t === d.activeIndex;
return !c || 0 > t && d.taggingLabel !== !1 || 0 > t && d.taggingLabel === !1 ? !1 : (c && !angular.isUndefined(d.onHighlightCallback) && e.$eval(d.onHighlightCallback), c)
}, d.isDisabled = function(e) {
if (d.open) {
var t, c = d.items.indexOf(e[d.itemProperty]),
i = !1;
return c >= 0 && !angular.isUndefined(d.disableChoiceExpression) && (t = d.items[c], i = !!e.$eval(d.disableChoiceExpression), t._uiSelectChoiceDisabled = i), i
}
}, d.select = function(e, c, s) {
if (void 0 === e || !e._uiSelectChoiceDisabled) {
if (!d.items && !d.search) return;
if (!e || !e._uiSelectChoiceDisabled) {
if (d.tagging.isActivated) {
if (d.taggingLabel === !1)
if (d.activeIndex < 0) { if (e = void 0 !== d.tagging.fct ? d.tagging.fct(d.search) : d.search, !e || angular.equals(d.items[0], e)) return } else e = d.items[d.activeIndex];
else if (0 === d.activeIndex) { if (void 0 === e) return; if (void 0 !== d.tagging.fct && "string" == typeof e) { if (e = d.tagging.fct(d.search), !e) return } else "string" == typeof e && (e = e.replace(d.taggingLabel, "").trim()) }
if (d.selected && angular.isArray(d.selected) && d.selected.filter(function(t) { return angular.equals(t, e) }).length > 0) return d.close(c), void 0
}
t.$broadcast("uis:select", e);
var l = {};
l[d.parserResult.itemName] = e, i(function() { d.onSelectCallback(t, { $item: e, $model: d.parserResult.modelMapper(t, l) }) }), d.closeOnSelect && d.close(c), s && "click" === s.type && (d.clickTriggeredSelect = !0)
}
}
}, d.close = function(e) { d.open && (d.ngModel && d.ngModel.$setTouched && d.ngModel.$setTouched(), r(), d.open = !1, t.$broadcast("uis:close", e)) }, d.setFocus = function() { d.focus || d.focusInput[0].focus() }, d.clear = function(e) { d.select(void 0), e.stopPropagation(), d.focusser[0].focus() }, d.toggle = function(e) { d.open ? (d.close(), e.preventDefault(), e.stopPropagation()) : d.activate() }, d.isLocked = function(e, t) { var c, i = d.selected[t]; return i && !angular.isUndefined(d.lockChoiceExpression) && (c = !!e.$eval(d.lockChoiceExpression), i._uiSelectChoiceLocked = c), c };
var g = null;
d.sizeSearchInput = function() {
var e = d.searchInput[0],
c = d.searchInput.parent().parent()[0],
s = function() { return c.clientWidth * !!e.offsetParent },
l = function(t) { if (0 === t) return !1; var c = t - e.offsetLeft - 10; return 50 > c && (c = t), d.searchInput.css("width", c + "px"), !0 };
d.searchInput.css("width", "10px"), i(function() { null !== g || l(s()) || (g = t.$watch(s, function(e) { l(e) && (g(), g = null) })) })
}, d.searchInput.on("keydown", function(c) {
var s = c.which;
t.$apply(function() {
var t = !1;
if ((d.items.length > 0 || d.tagging.isActivated) && (o(s), d.taggingTokens.isActivated)) {
for (var l = 0; l < d.taggingTokens.tokens.length; l++) d.taggingTokens.tokens[l] === e.MAP[c.keyCode] && d.search.length > 0 && (t = !0);
t && i(function() {
d.searchInput.triggerHandler("tagged");
var t = d.search.replace(e.MAP[c.keyCode], "").trim();
d.tagging.fct && (t = d.tagging.fct(t)), t && d.select(t, !0)
})
}
}), e.isVerticalMovement(s) && d.items.length > 0 && u()
}), d.searchInput.on("paste", function(e) {
var t = e.originalEvent.clipboardData.getData("text/plain");
if (t && t.length > 0 && d.taggingTokens.isActivated && d.tagging.fct) {
var c = t.split(d.taggingTokens.tokens[0]);
c && c.length > 0 && (angular.forEach(c, function(e) {
var t = d.tagging.fct(e);
t && d.select(t, !0)
}), e.preventDefault(), e.stopPropagation())
}
}), d.searchInput.on("tagged", function() { i(function() { r() }) }), t.$on("$destroy", function() { d.searchInput.off("keyup keydown tagged blur paste") })
}]), c.directive("uiSelect", ["$document", "uiSelectConfig", "uiSelectMinErr", "uisOffset", "$compile", "$parse", "$timeout", function(e, t, c, i, s, l, n) {
return {
restrict: "EA",
templateUrl: function(e, c) { var i = c.theme || t.theme; return i + (angular.isDefined(c.multiple) ? "/select-multiple.tpl.html" : "/select.tpl.html") },
replace: !0,
transclude: !0,
require: ["uiSelect", "^ngModel"],
scope: !0,
controller: "uiSelectCtrl",
controllerAs: "$select",
compile: function(s, a) {
return angular.isDefined(a.multiple) ? s.append("