/*
 * angular-ui-bootstrap
 * http://angular-ui.github.io/bootstrap/

 * Version: 0.12.1 - 2015-02-20
 * License: MIT
 */
angular.module("ui.bootstrap",["ui.bootstrap.modal","ui.bootstrap.transition","ui.bootstrap.datepicker","ui.bootstrap.dateparser","ui.bootstrap.position","ui.bootstrap.typeahead","ui.bootstrap.bindHtml"]),angular.module("ui.bootstrap.modal",["ui.bootstrap.transition"]).factory("$$stackedMap",function(){return{createNew:function(){var e=[];return{add:function(t,n){e.push({key:t,value:n})},get:function(t){for(var n=0;n<e.length;n++)if(t==e[n].key)return e[n]},keys:function(){for(var t=[],n=0;n<e.length;n++)t.push(e[n].key);return t},top:function(){return e[e.length-1]},remove:function(t){for(var n=-1,a=0;a<e.length;a++)if(t==e[a].key){n=a;break}return e.splice(n,1)[0]},removeTop:function(){return e.splice(e.length-1,1)[0]},length:function(){return e.length}}}}}).directive("modalBackdrop",["$timeout",function(e){return{restrict:"EA",replace:!0,templateUrl:"template/modal/backdrop.html",link:function(t,n,a){t.backdropClass=a.backdropClass||"",t.animate=!1,e(function(){t.animate=!0})}}}]).directive("modalWindow",["$modalStack","$timeout",function(e,t){return{restrict:"EA",scope:{index:"@",animate:"="},replace:!0,transclude:!0,templateUrl:function(e,t){return t.templateUrl||"template/modal/window.html"},link:function(n,a,o){a.addClass(o.windowClass||""),n.size=o.size,t(function(){n.animate=!0,a[0].querySelectorAll("[autofocus]").length||a[0].focus()}),n.close=function(t){var n=e.getTop();n&&n.value.backdrop&&"static"!=n.value.backdrop&&t.target===t.currentTarget&&(t.preventDefault(),t.stopPropagation(),e.dismiss(n.key,"backdrop click"))}}}}]).directive("modalTransclude",function(){return{link:function(e,t,n,a,o){o(e.$parent,function(e){t.empty(),t.append(e)})}}}).factory("$modalStack",["$transition","$timeout","$document","$compile","$rootScope","$$stackedMap",function(e,t,n,a,o,r){function i(){for(var e=-1,t=f.keys(),n=0;n<t.length;n++)f.get(t[n]).value.backdrop&&(e=n);return e}function l(e){var t=n.find("body").eq(0),a=f.get(e).value;f.remove(e),s(a.modalDomEl,a.modalScope,300,function(){a.modalScope.$destroy(),t.toggleClass(p,f.length()>0),c()})}function c(){if(d&&-1==i()){var e=u;s(d,u,150,function(){e.$destroy(),e=null}),d=void 0,u=void 0}}function s(n,a,o,r){function i(){i.done||(i.done=!0,n.remove(),r&&r())}a.animate=!1;var l=e.transitionEndEventName;if(l){var c=t(i,o);n.bind(l,function(){t.cancel(c),i(),a.$apply()})}else t(i)}var d,u,p="modal-open",f=r.createNew(),m={};return o.$watch(i,function(e){u&&(u.index=e)}),n.bind("keydown",function(e){var t;27===e.which&&(t=f.top(),t&&t.value.keyboard&&(e.preventDefault(),o.$apply(function(){m.dismiss(t.key,"escape key press")})))}),m.open=function(e,t){f.add(e,{deferred:t.deferred,modalScope:t.scope,backdrop:t.backdrop,keyboard:t.keyboard});var r=n.find("body").eq(0),l=i();if(l>=0&&!d){u=o.$new(!0),u.index=l;var c=angular.element("<div modal-backdrop></div>");c.attr("backdrop-class",t.backdropClass),d=a(c)(u),r.append(d)}var s=angular.element("<div modal-window></div>");s.attr({"template-url":t.windowTemplateUrl,"window-class":t.windowClass,size:t.size,index:f.length()-1,animate:"animate"}).html(t.content);var m=a(s)(t.scope);f.top().value.modalDomEl=m,r.append(m),r.addClass(p)},m.close=function(e,t){var n=f.get(e);n&&(n.value.deferred.resolve(t),l(e))},m.dismiss=function(e,t){var n=f.get(e);n&&(n.value.deferred.reject(t),l(e))},m.dismissAll=function(e){for(var t=this.getTop();t;)this.dismiss(t.key,e),t=this.getTop()},m.getTop=function(){return f.top()},m}]).provider("$modal",function(){var e={options:{backdrop:!0,keyboard:!0},$get:["$injector","$rootScope","$q","$http","$templateCache","$controller","$modalStack",function(t,n,a,o,r,i,l){function c(e){return e.template?a.when(e.template):o.get(angular.isFunction(e.templateUrl)?e.templateUrl():e.templateUrl,{cache:r}).then(function(e){return e.data})}function s(e){var n=[];return angular.forEach(e,function(e){(angular.isFunction(e)||angular.isArray(e))&&n.push(a.when(t.invoke(e)))}),n}var d={};return d.open=function(t){var o=a.defer(),r=a.defer(),d={result:o.promise,opened:r.promise,close:function(e){l.close(d,e)},dismiss:function(e){l.dismiss(d,e)}};if(t=angular.extend({},e.options,t),t.resolve=t.resolve||{},!t.template&&!t.templateUrl)throw new Error("One of template or templateUrl options is required.");var u=a.all([c(t)].concat(s(t.resolve)));return u.then(function(e){var a=(t.scope||n).$new();a.$close=d.close,a.$dismiss=d.dismiss;var r,c={},s=1;t.controller&&(c.$scope=a,c.$modalInstance=d,angular.forEach(t.resolve,function(t,n){c[n]=e[s++]}),r=i(t.controller,c),t.controllerAs&&(a[t.controllerAs]=r)),l.open(d,{scope:a,deferred:o,content:e[0],backdrop:t.backdrop,keyboard:t.keyboard,backdropClass:t.backdropClass,windowClass:t.windowClass,windowTemplateUrl:t.windowTemplateUrl,size:t.size})},function(e){o.reject(e)}),u.then(function(){r.resolve(!0)},function(){r.reject(!1)}),d},d}]};return e}),angular.module("ui.bootstrap.transition",[]).factory("$transition",["$q","$timeout","$rootScope",function(e,t,n){function a(e){for(var t in e)if(void 0!==r.style[t])return e[t]}var o=function(a,r,i){i=i||{};var l=e.defer(),c=o[i.animation?"animationEndEventName":"transitionEndEventName"],s=function(){n.$apply(function(){a.unbind(c,s),l.resolve(a)})};return c&&a.bind(c,s),t(function(){angular.isString(r)?a.addClass(r):angular.isFunction(r)?r(a):angular.isObject(r)&&a.css(r),c||l.resolve(a)}),l.promise.cancel=function(){c&&a.unbind(c,s),l.reject("Transition cancelled")},l.promise},r=document.createElement("trans"),i={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd",transition:"transitionend"},l={WebkitTransition:"webkitAnimationEnd",MozTransition:"animationend",OTransition:"oAnimationEnd",transition:"animationend"};return o.transitionEndEventName=a(i),o.animationEndEventName=a(l),o}]),angular.module("ui.bootstrap.datepicker",["ui.bootstrap.dateparser","ui.bootstrap.position"]).constant("datepickerConfig",{formatDay:"dd",formatMonth:"MMMM",formatYear:"yyyy",formatDayHeader:"EEE",formatDayTitle:"MMMM yyyy",formatMonthTitle:"yyyy",datepickerMode:"day",minMode:"day",maxMode:"year",showWeeks:!0,startingDay:0,yearRange:20,minDate:null,maxDate:null}).controller("DatepickerController",["$scope","$attrs","$parse","$interpolate","$timeout","$log","dateFilter","datepickerConfig",function(e,t,n,a,o,r,i,l){var c=this,s={$setViewValue:angular.noop};this.modes=["day","month","year"],angular.forEach(["formatDay","formatMonth","formatYear","formatDayHeader","formatDayTitle","formatMonthTitle","minMode","maxMode","showWeeks","startingDay","yearRange"],function(n,o){c[n]=angular.isDefined(t[n])?8>o?a(t[n])(e.$parent):e.$parent.$eval(t[n]):l[n]}),angular.forEach(["minDate","maxDate"],function(a){t[a]?e.$parent.$watch(n(t[a]),function(e){c[a]=e?new Date(e):null,c.refreshView()}):c[a]=l[a]?new Date(l[a]):null}),e.datepickerMode=e.datepickerMode||l.datepickerMode,e.uniqueId="datepicker-"+e.$id+"-"+Math.floor(1e4*Math.random()),this.activeDate=angular.isDefined(t.initDate)?e.$parent.$eval(t.initDate):new Date,e.isActive=function(t){return 0===c.compare(t.date,c.activeDate)?(e.activeDateId=t.uid,!0):!1},this.init=function(e){s=e,s.$render=function(){c.render()}},this.render=function(){if(s.$modelValue){var e=new Date(s.$modelValue),t=!isNaN(e);t?this.activeDate=e:r.error('Datepicker directive: "ng-model" value must be a Date object, a number of milliseconds since 01.01.1970 or a string representing an RFC2822 or ISO 8601 date.'),s.$setValidity("date",t)}this.refreshView()},this.refreshView=function(){if(this.element){this._refreshView();var e=s.$modelValue?new Date(s.$modelValue):null;s.$setValidity("date-disabled",!e||this.element&&!this.isDisabled(e))}},this.createDateObject=function(e,t){var n=s.$modelValue?new Date(s.$modelValue):null;return{date:e,label:i(e,t),selected:n&&0===this.compare(e,n),disabled:this.isDisabled(e),current:0===this.compare(e,new Date)}},this.isDisabled=function(n){return this.minDate&&this.compare(n,this.minDate)<0||this.maxDate&&this.compare(n,this.maxDate)>0||t.dateDisabled&&e.dateDisabled({date:n,mode:e.datepickerMode})},this.split=function(e,t){for(var n=[];e.length>0;)n.push(e.splice(0,t));return n},e.select=function(t){if(e.datepickerMode===c.minMode){var n=s.$modelValue?new Date(s.$modelValue):new Date(0,0,0,0,0,0,0);n.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),s.$setViewValue(n),s.$render()}else c.activeDate=t,e.datepickerMode=c.modes[c.modes.indexOf(e.datepickerMode)-1]},e.move=function(e){var t=c.activeDate.getFullYear()+e*(c.step.years||0),n=c.activeDate.getMonth()+e*(c.step.months||0);c.activeDate.setFullYear(t,n,1),c.refreshView()},e.toggleMode=function(t){t=t||1,e.datepickerMode===c.maxMode&&1===t||e.datepickerMode===c.minMode&&-1===t||(e.datepickerMode=c.modes[c.modes.indexOf(e.datepickerMode)+t])},e.keys={13:"enter",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down"};var d=function(){o(function(){c.element[0].focus()},0,!1)};e.$on("datepicker.focus",d),e.keydown=function(t){var n=e.keys[t.which];if(n&&!t.shiftKey&&!t.altKey)if(t.preventDefault(),t.stopPropagation(),"enter"===n||"space"===n){if(c.isDisabled(c.activeDate))return;e.select(c.activeDate),d()}else!t.ctrlKey||"up"!==n&&"down"!==n?(c.handleKeyDown(n,t),c.refreshView()):(e.toggleMode("up"===n?1:-1),d())}}]).directive("datepicker",function(){return{restrict:"EA",replace:!0,templateUrl:"template/datepicker/datepicker.html",scope:{datepickerMode:"=?",dateDisabled:"&"},require:["datepicker","?^ngModel"],controller:"DatepickerController",link:function(e,t,n,a){var o=a[0],r=a[1];r&&o.init(r)}}}).directive("daypicker",["dateFilter",function(e){return{restrict:"EA",replace:!0,templateUrl:"template/datepicker/day.html",require:"^datepicker",link:function(t,n,a,o){function r(e,t){return 1!==t||e%4!==0||e%100===0&&e%400!==0?c[t]:29}function i(e,t){var n=new Array(t),a=new Date(e),o=0;for(a.setHours(12);t>o;)n[o++]=new Date(a),a.setDate(a.getDate()+1);return n}function l(e){var t=new Date(e);t.setDate(t.getDate()+4-(t.getDay()||7));var n=t.getTime();return t.setMonth(0),t.setDate(1),Math.floor(Math.round((n-t)/864e5)/7)+1}t.showWeeks=o.showWeeks,o.step={months:1},o.element=n;var c=[31,28,31,30,31,30,31,31,30,31,30,31];o._refreshView=function(){var n=o.activeDate.getFullYear(),a=o.activeDate.getMonth(),r=new Date(n,a,1),c=o.startingDay-r.getDay(),s=c>0?7-c:-c,d=new Date(r);s>0&&d.setDate(-s+1);for(var u=i(d,42),p=0;42>p;p++)u[p]=angular.extend(o.createDateObject(u[p],o.formatDay),{secondary:u[p].getMonth()!==a,uid:t.uniqueId+"-"+p});t.labels=new Array(7);for(var f=0;7>f;f++)t.labels[f]={abbr:e(u[f].date,o.formatDayHeader),full:e(u[f].date,"EEEE")};if(t.title=e(o.activeDate,o.formatDayTitle),t.rows=o.split(u,7),t.showWeeks){t.weekNumbers=[];for(var m=l(t.rows[0][0].date),v=t.rows.length;t.weekNumbers.push(m++)<v;);}},o.compare=function(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate())-new Date(t.getFullYear(),t.getMonth(),t.getDate())},o.handleKeyDown=function(e){var t=o.activeDate.getDate();if("left"===e)t-=1;else if("up"===e)t-=7;else if("right"===e)t+=1;else if("down"===e)t+=7;else if("pageup"===e||"pagedown"===e){var n=o.activeDate.getMonth()+("pageup"===e?-1:1);o.activeDate.setMonth(n,1),t=Math.min(r(o.activeDate.getFullYear(),o.activeDate.getMonth()),t)}else"home"===e?t=1:"end"===e&&(t=r(o.activeDate.getFullYear(),o.activeDate.getMonth()));o.activeDate.setDate(t)},o.refreshView()}}}]).directive("monthpicker",["dateFilter",function(e){return{restrict:"EA",replace:!0,templateUrl:"template/datepicker/month.html",require:"^datepicker",link:function(t,n,a,o){o.step={years:1},o.element=n,o._refreshView=function(){for(var n=new Array(12),a=o.activeDate.getFullYear(),r=0;12>r;r++)n[r]=angular.extend(o.createDateObject(new Date(a,r,1),o.formatMonth),{uid:t.uniqueId+"-"+r});t.title=e(o.activeDate,o.formatMonthTitle),t.rows=o.split(n,3)},o.compare=function(e,t){return new Date(e.getFullYear(),e.getMonth())-new Date(t.getFullYear(),t.getMonth())},o.handleKeyDown=function(e){var t=o.activeDate.getMonth();if("left"===e)t-=1;else if("up"===e)t-=3;else if("right"===e)t+=1;else if("down"===e)t+=3;else if("pageup"===e||"pagedown"===e){var n=o.activeDate.getFullYear()+("pageup"===e?-1:1);o.activeDate.setFullYear(n)}else"home"===e?t=0:"end"===e&&(t=11);o.activeDate.setMonth(t)},o.refreshView()}}}]).directive("yearpicker",["dateFilter",function(){return{restrict:"EA",replace:!0,templateUrl:"template/datepicker/year.html",require:"^datepicker",link:function(e,t,n,a){function o(e){return parseInt((e-1)/r,10)*r+1}var r=a.yearRange;a.step={years:r},a.element=t,a._refreshView=function(){for(var t=new Array(r),n=0,i=o(a.activeDate.getFullYear());r>n;n++)t[n]=angular.extend(a.createDateObject(new Date(i+n,0,1),a.formatYear),{uid:e.uniqueId+"-"+n});e.title=[t[0].label,t[r-1].label].join(" - "),e.rows=a.split(t,5)},a.compare=function(e,t){return e.getFullYear()-t.getFullYear()},a.handleKeyDown=function(e){var t=a.activeDate.getFullYear();"left"===e?t-=1:"up"===e?t-=5:"right"===e?t+=1:"down"===e?t+=5:"pageup"===e||"pagedown"===e?t+=("pageup"===e?-1:1)*a.step.years:"home"===e?t=o(a.activeDate.getFullYear()):"end"===e&&(t=o(a.activeDate.getFullYear())+r-1),a.activeDate.setFullYear(t)},a.refreshView()}}}]).constant("datepickerPopupConfig",{datepickerPopup:"yyyy-MM-dd",currentText:"Today",clearText:"Clear",closeText:"Done",closeOnDateSelection:!0,appendToBody:!1,showButtonBar:!0}).directive("datepickerPopup",["$compile","$parse","$document","$position","dateFilter","dateParser","datepickerPopupConfig",function(e,t,n,a,o,r,i){return{restrict:"EA",require:"ngModel",scope:{isOpen:"=?",currentText:"@",clearText:"@",closeText:"@",dateDisabled:"&"},link:function(l,c,s,d){function u(e){return e.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()})}function p(e){if(e){if(angular.isDate(e)&&!isNaN(e))return d.$setValidity("date",!0),e;if(angular.isString(e)){var t=r.parse(e,f)||new Date(e);return isNaN(t)?void d.$setValidity("date",!1):(d.$setValidity("date",!0),t)}return void d.$setValidity("date",!1)}return d.$setValidity("date",!0),null}var f,m=angular.isDefined(s.closeOnDateSelection)?l.$parent.$eval(s.closeOnDateSelection):i.closeOnDateSelection,v=angular.isDefined(s.datepickerAppendToBody)?l.$parent.$eval(s.datepickerAppendToBody):i.appendToBody;l.showButtonBar=angular.isDefined(s.showButtonBar)?l.$parent.$eval(s.showButtonBar):i.showButtonBar,l.getText=function(e){return l[e+"Text"]||i[e+"Text"]},s.$observe("datepickerPopup",function(e){f=e||i.datepickerPopup,d.$render()});var h=angular.element("<div datepicker-popup-wrap><div datepicker></div></div>");h.attr({"ng-model":"date","ng-change":"dateSelection()"});var g=angular.element(h.children()[0]);s.datepickerOptions&&angular.forEach(l.$parent.$eval(s.datepickerOptions),function(e,t){g.attr(u(t),e)}),l.watchData={},angular.forEach(["minDate","maxDate","datepickerMode"],function(e){if(s[e]){var n=t(s[e]);if(l.$parent.$watch(n,function(t){l.watchData[e]=t}),g.attr(u(e),"watchData."+e),"datepickerMode"===e){var a=n.assign;l.$watch("watchData."+e,function(e,t){e!==t&&a(l.$parent,e)})}}}),s.dateDisabled&&g.attr("date-disabled","dateDisabled({ date: date, mode: mode })"),d.$parsers.unshift(p),l.dateSelection=function(e){angular.isDefined(e)&&(l.date=e),d.$setViewValue(l.date),d.$render(),m&&(l.isOpen=!1,c[0].focus())},c.bind("input change keyup",function(){l.$apply(function(){l.date=d.$modelValue})}),d.$render=function(){var e=d.$viewValue?o(d.$viewValue,f):"";c.val(e),l.date=p(d.$modelValue)};var y=function(e){l.isOpen&&e.target!==c[0]&&l.$apply(function(){l.isOpen=!1})},$=function(e){l.keydown(e)};c.bind("keydown",$),l.keydown=function(e){27===e.which?(e.preventDefault(),e.stopPropagation(),l.close()):40!==e.which||l.isOpen||(l.isOpen=!0)},l.$watch("isOpen",function(e){e?(l.$broadcast("datepicker.focus"),l.position=v?a.offset(c):a.position(c),l.position.top=l.position.top+c.prop("offsetHeight"),n.bind("click",y)):n.unbind("click",y)}),l.select=function(e){if("today"===e){var t=new Date;angular.isDate(d.$modelValue)?(e=new Date(d.$modelValue),e.setFullYear(t.getFullYear(),t.getMonth(),t.getDate())):e=new Date(t.setHours(0,0,0,0))}l.dateSelection(e)},l.close=function(){l.isOpen=!1,c[0].focus()};var k=e(h)(l);h.remove(),v?n.find("body").append(k):c.after(k),l.$on("$destroy",function(){k.remove(),c.unbind("keydown",$),n.unbind("click",y)})}}}]).directive("datepickerPopupWrap",function(){return{restrict:"EA",replace:!0,transclude:!0,templateUrl:"template/datepicker/popup.html",link:function(e,t){t.bind("click",function(e){e.preventDefault(),e.stopPropagation()})}}}),angular.module("ui.bootstrap.dateparser",[]).service("dateParser",["$locale","orderByFilter",function(e,t){function n(e){var n=[],a=e.split("");return angular.forEach(o,function(t,o){var r=e.indexOf(o);if(r>-1){e=e.split(""),a[r]="("+t.regex+")",e[r]="$";for(var i=r+1,l=r+o.length;l>i;i++)a[i]="",e[i]="$";e=e.join(""),n.push({index:r,apply:t.apply})}}),{regex:new RegExp("^"+a.join("")+"$"),map:t(n,"index")}}function a(e,t,n){return 1===t&&n>28?29===n&&(e%4===0&&e%100!==0||e%400===0):3===t||5===t||8===t||10===t?31>n:!0}this.parsers={};var o={yyyy:{regex:"\\d{4}",apply:function(e){this.year=+e}},yy:{regex:"\\d{2}",apply:function(e){this.year=+e+2e3}},y:{regex:"\\d{1,4}",apply:function(e){this.year=+e}},MMMM:{regex:e.DATETIME_FORMATS.MONTH.join("|"),apply:function(t){this.month=e.DATETIME_FORMATS.MONTH.indexOf(t)}},MMM:{regex:e.DATETIME_FORMATS.SHORTMONTH.join("|"),apply:function(t){this.month=e.DATETIME_FORMATS.SHORTMONTH.indexOf(t)}},MM:{regex:"0[1-9]|1[0-2]",apply:function(e){this.month=e-1}},M:{regex:"[1-9]|1[0-2]",apply:function(e){this.month=e-1}},dd:{regex:"[0-2][0-9]{1}|3[0-1]{1}",apply:function(e){this.date=+e}},d:{regex:"[1-2]?[0-9]{1}|3[0-1]{1}",apply:function(e){this.date=+e}},EEEE:{regex:e.DATETIME_FORMATS.DAY.join("|")},EEE:{regex:e.DATETIME_FORMATS.SHORTDAY.join("|")}};this.parse=function(t,o){if(!angular.isString(t)||!o)return t;o=e.DATETIME_FORMATS[o]||o,this.parsers[o]||(this.parsers[o]=n(o));var r=this.parsers[o],i=r.regex,l=r.map,c=t.match(i);if(c&&c.length){for(var s,d={year:1900,month:0,date:1,hours:0},u=1,p=c.length;p>u;u++){var f=l[u-1];f.apply&&f.apply.call(d,c[u])}return a(d.year,d.month,d.date)&&(s=new Date(d.year,d.month,d.date,d.hours)),s}}}]),angular.module("ui.bootstrap.position",[]).factory("$position",["$document","$window",function(e,t){function n(e,n){return e.currentStyle?e.currentStyle[n]:t.getComputedStyle?t.getComputedStyle(e)[n]:e.style[n]}function a(e){return"static"===(n(e,"position")||"static")}var o=function(t){for(var n=e[0],o=t.offsetParent||n;o&&o!==n&&a(o);)o=o.offsetParent;return o||n};return{position:function(t){var n=this.offset(t),a={top:0,left:0},r=o(t[0]);r!=e[0]&&(a=this.offset(angular.element(r)),a.top+=r.clientTop-r.scrollTop,a.left+=r.clientLeft-r.scrollLeft);var i=t[0].getBoundingClientRect();return{width:i.width||t.prop("offsetWidth"),height:i.height||t.prop("offsetHeight"),top:n.top-a.top,left:n.left-a.left}},offset:function(n){var a=n[0].getBoundingClientRect();return{width:a.width||n.prop("offsetWidth"),height:a.height||n.prop("offsetHeight"),top:a.top+(t.pageYOffset||e[0].documentElement.scrollTop),left:a.left+(t.pageXOffset||e[0].documentElement.scrollLeft)}},positionElements:function(e,t,n,a){var o,r,i,l,c=n.split("-"),s=c[0],d=c[1]||"center";o=a?this.offset(e):this.position(e),r=t.prop("offsetWidth"),i=t.prop("offsetHeight");var u={center:function(){return o.left+o.width/2-r/2},left:function(){return o.left},right:function(){return o.left+o.width}},p={center:function(){return o.top+o.height/2-i/2},top:function(){return o.top},bottom:function(){return o.top+o.height}};switch(s){case"right":l={top:p[d](),left:u[s]()};break;case"left":l={top:p[d](),left:o.left-r};break;case"bottom":l={top:p[s](),left:u[d]()};break;default:l={top:o.top-i,left:u[d]()}}return l}}}]),angular.module("ui.bootstrap.typeahead",["ui.bootstrap.position","ui.bootstrap.bindHtml"]).factory("typeaheadParser",["$parse",function(e){var t=/^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?\s+for\s+(?:([\$\w][\$\w\d]*))\s+in\s+([\s\S]+?)$/;return{parse:function(n){var a=n.match(t);if(!a)throw new Error('Expected typeahead specification in form of "_modelValue_ (as _label_)? for _item_ in _collection_" but got "'+n+'".');return{itemName:a[3],source:e(a[4]),viewMapper:e(a[2]||a[1]),modelMapper:e(a[1])}}}}]).directive("typeahead",["$compile","$parse","$q","$timeout","$document","$position","typeaheadParser",function(e,t,n,a,o,r,i){var l=[9,13,27,38,40];return{require:"ngModel",link:function(c,s,d,u){var p,f=c.$eval(d.typeaheadMinLength)||1,m=c.$eval(d.typeaheadWaitMs)||0,v=c.$eval(d.typeaheadEditable)!==!1,h=t(d.typeaheadLoading).assign||angular.noop,g=t(d.typeaheadOnSelect),y=d.typeaheadInputFormatter?t(d.typeaheadInputFormatter):void 0,$=d.typeaheadAppendToBody?c.$eval(d.typeaheadAppendToBody):!1,k=c.$eval(d.typeaheadFocusFirst)!==!1,w=t(d.ngModel).assign,b=i.parse(d.typeahead),D=c.$new();c.$on("$destroy",function(){D.$destroy()});var M="typeahead-"+D.$id+"-"+Math.floor(1e4*Math.random());s.attr({"aria-autocomplete":"list","aria-expanded":!1,"aria-owns":M});var E=angular.element("<div typeahead-popup></div>");E.attr({id:M,matches:"matches",active:"activeIdx",select:"select(activeIdx)",query:"query",position:"position"}),angular.isDefined(d.typeaheadTemplateUrl)&&E.attr("template-url",d.typeaheadTemplateUrl);var T=function(){D.matches=[],D.activeIdx=-1,s.attr("aria-expanded",!1)},x=function(e){return M+"-option-"+e};D.$watch("activeIdx",function(e){0>e?s.removeAttr("aria-activedescendant"):s.attr("aria-activedescendant",x(e))});var A=function(e){var t={$viewValue:e};h(c,!0),n.when(b.source(c,t)).then(function(n){var a=e===u.$viewValue;if(a&&p)if(n.length>0){D.activeIdx=k?0:-1,D.matches.length=0;for(var o=0;o<n.length;o++)t[b.itemName]=n[o],D.matches.push({id:x(o),label:b.viewMapper(D,t),model:n[o]});D.query=e,D.position=$?r.offset(s):r.position(s),D.position.top=D.position.top+s.prop("offsetHeight"),s.attr("aria-expanded",!0)}else T();a&&h(c,!1)},function(){T(),h(c,!1)})};T(),D.query=void 0;var S,C=function(e){S=a(function(){A(e)},m)},O=function(){S&&a.cancel(S)};u.$parsers.unshift(function(e){return p=!0,e&&e.length>=f?m>0?(O(),C(e)):A(e):(h(c,!1),O(),T()),v?e:e?void u.$setValidity("editable",!1):(u.$setValidity("editable",!0),e)}),u.$formatters.push(function(e){var t,n,a={};return y?(a.$model=e,y(c,a)):(a[b.itemName]=e,t=b.viewMapper(c,a),a[b.itemName]=void 0,n=b.viewMapper(c,a),t!==n?t:e)}),D.select=function(e){var t,n,o={};o[b.itemName]=n=D.matches[e].model,t=b.modelMapper(c,o),w(c,t),u.$setValidity("editable",!0),g(c,{$item:n,$model:t,$label:b.viewMapper(c,o)}),T(),a(function(){s[0].focus()},0,!1)},s.bind("keydown",function(e){0!==D.matches.length&&-1!==l.indexOf(e.which)&&(-1!=D.activeIdx||13!==e.which&&9!==e.which)&&(e.preventDefault(),40===e.which?(D.activeIdx=(D.activeIdx+1)%D.matches.length,D.$digest()):38===e.which?(D.activeIdx=(D.activeIdx>0?D.activeIdx:D.matches.length)-1,D.$digest()):13===e.which||9===e.which?D.$apply(function(){D.select(D.activeIdx)}):27===e.which&&(e.stopPropagation(),T(),D.$digest()))}),s.bind("blur",function(){p=!1});var F=function(e){s[0]!==e.target&&(T(),D.$digest())};o.bind("click",F),c.$on("$destroy",function(){o.unbind("click",F),$&&U.remove()});var U=e(E)(D);$?o.find("body").append(U):s.after(U)}}}]).directive("typeaheadPopup",function(){return{restrict:"EA",scope:{matches:"=",query:"=",active:"=",position:"=",select:"&"},replace:!0,templateUrl:"template/typeahead/typeahead-popup.html",link:function(e,t,n){e.templateUrl=n.templateUrl,e.isOpen=function(){return e.matches.length>0},e.isActive=function(t){return e.active==t},e.selectActive=function(t){e.active=t},e.selectMatch=function(t){e.select({activeIdx:t})}}}}).directive("typeaheadMatch",["$http","$templateCache","$compile","$parse",function(e,t,n,a){return{restrict:"EA",scope:{index:"=",match:"=",query:"="},link:function(o,r,i){var l=a(i.templateUrl)(o.$parent)||"template/typeahead/typeahead-match.html";e.get(l,{cache:t}).success(function(e){r.replaceWith(n(e.trim())(o))})}}}]).filter("typeaheadHighlight",function(){function e(e){return e.replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")}return function(t,n){return n?(""+t).replace(new RegExp(e(n),"gi"),"<strong>$&</strong>"):t}}),angular.module("ui.bootstrap.bindHtml",[]).directive("bindHtmlUnsafe",function(){return function(e,t,n){t.addClass("ng-binding").data("$binding",n.bindHtmlUnsafe),e.$watch(n.bindHtmlUnsafe,function(e){t.html(e||"")})}});