/*!
 * Angular Material Design
 * https://github.com/angular/material
 * @license MIT
 * v1.1.0-rc4-master-3e15998
 */
function SelectDirective(e,t,n,r,i,a){function l(i,l){var o=angular.element("<md-select-value><span></span></md-select-value>");if(o.append('<span class="_md-select-icon" aria-hidden="true"></span>'),o.addClass("_md-select-value"),o[0].hasAttribute("id")||o.attr("id","select_value_label_"+t.nextUid()),i.find("md-content").length||i.append(angular.element("<md-content>").append(i.contents())),l.mdOnOpen&&(i.find("md-content").prepend(angular.element('<div> <md-progress-circular md-mode="indeterminate" ng-if="!$$loadingAsyncDone" md-diameter="25px"></md-progress-circular></div>')),i.find("md-option").attr("ng-show","$$loadingAsyncDone")),l.name){var d=angular.element('<select class="_md-visually-hidden">');d.attr({name:"."+l.name,"ng-model":l.ngModel,"aria-hidden":"true",tabindex:"-1"});var c=i.find("md-option");angular.forEach(c,function(e){var t=angular.element("<option>"+e.innerHTML+"</option>");e.hasAttribute("ng-value")?t.attr("ng-value",e.getAttribute("ng-value")):e.hasAttribute("value")&&t.attr("value",e.getAttribute("value")),d.append(t)}),i.parent().append(d)}var s=t.parseAttributeBoolean(l.multiple),u=s?"multiple":"",p='<div class="_md-select-menu-container" aria-hidden="true"><md-select-menu {0}>{1}</md-select-menu></div>';return p=t.supplant(p,[u,i.html()]),i.empty().append(o),i.append(p),l.tabindex||l.$set("tabindex",0),function(i,l,o,d){function c(){var e=l.attr("aria-label")||l.attr("placeholder");!e&&y&&y.label&&(e=y.label.text()),b=e,r.expect(l,"aria-label",e)}function u(){x&&(O=O||x.find("md-select-menu").controller("mdSelectMenu"),C.setLabelText(O.selectedLabels()))}function p(){if(b){var e=O.selectedLabels({mode:"aria"});l.attr("aria-label",e.length?b+": "+e:b)}}function f(){y&&y.setHasValue(O.selectedLabels().length>0||(l[0].validity||{}).badInput)}function m(){if(x=angular.element(l[0].querySelector("._md-select-menu-container")),D=i,o.mdContainerClass){var e=x[0].getAttribute("class")+" "+o.mdContainerClass;x[0].setAttribute("class",e)}O=x.find("md-select-menu").controller("mdSelectMenu"),O.init(E,o.ngModel),l.on("$destroy",function(){x.remove()})}function h(e){var t=[32,13,38,40];if(-1!=t.indexOf(e.keyCode))e.preventDefault(),g(e);else if(e.keyCode<=90&&e.keyCode>=31){e.preventDefault();var n=O.optNodeForKeyboardSearch(e);if(!n)return;var r=angular.element(n).controller("mdOption");O.isMultiple||O.deselect(Object.keys(O.selected)[0]),O.select(r.hashKey,r.value),O.refreshViewValue()}}function g(){D.isOpen=!0,l.attr("aria-expanded","true"),e.show({scope:D,preserveScope:!0,skipCompile:!0,element:x,target:l[0],selectCtrl:C,preserveElement:!0,hasBackdrop:!0,loadingAsync:o.mdOnOpen?i.$eval(o.mdOnOpen)||!0:!1})["finally"](function(){D.isOpen=!1,l.focus(),l.attr("aria-expanded","false"),E.$setTouched()})}var v,b,$=!0,y=d[0],C=d[1],E=d[2],k=d[3],M=l.find("md-select-value"),S=angular.isDefined(o.readonly);if(y){var w=y.isErrorGetter||function(){return E.$invalid&&E.$touched};if(y.input&&l.find("md-select-header").find("input")[0]!==y.input[0])throw new Error("<md-input-container> can only have *one* child <input>, <textarea> or <select> element!");y.input=l,y.label||r.expect(l,"aria-label",l.attr("placeholder")),i.$watch(w,y.setInvalid)}var x,D,O;if(m(),n(l),o.name&&k){var A=l.parent()[0].querySelector('select[name=".'+o.name+'"]');t.nextTick(function(){var e=angular.element(A).controller("ngModel");e&&k.$removeControl(e)})}k&&angular.isDefined(o.multiple)&&t.nextTick(function(){var e=E.$modelValue||E.$viewValue;e&&k.$setPristine()});var _=E.$render;E.$render=function(){_(),u(),p(),f()},o.$observe("placeholder",E.$render),C.setLabelText=function(e){if(C.setIsPlaceholder(!e),o.mdSelectedText)e=a(o.mdSelectedText)(i);else{var t=o.placeholder||(y&&y.label?y.label.text():"");e=e||t||""}var n=M.children().eq(0);n.html(e)},C.setIsPlaceholder=function(e){e?(M.addClass("_md-select-placeholder"),y&&y.label&&y.label.addClass("_md-placeholder")):(M.removeClass("_md-select-placeholder"),y&&y.label&&y.label.removeClass("_md-placeholder"))},S||(l.on("focus",function(e){y&&y.element.hasClass("md-input-has-value")&&y.setFocused(!0)}),l.on("blur",function(e){$&&($=!1,D.isOpen&&e.stopImmediatePropagation()),D.isOpen||(y&&y.setFocused(!1),f())})),C.triggerClose=function(){a(o.mdOnClose)(i)},i.$$postDigest(function(){c(),u(),p()}),i.$watch(function(){return O.selectedLabels()},u);var T;o.$observe("ngMultiple",function(e){T&&T();var t=a(e);T=i.$watch(function(){return t(i)},function(e,t){void 0===e&&void 0===t||(e?l.attr("multiple","multiple"):l.removeAttr("multiple"),l.attr("aria-multiselectable",e?"true":"false"),x&&(O.setMultiple(e),_=E.$render,E.$render=function(){_(),u(),p(),f()},E.$render()))})}),o.$observe("disabled",function(e){angular.isString(e)&&(e=!0),void 0!==v&&v===e||(v=e,e?l.attr({"aria-disabled":"true"}).removeAttr("tabindex").off("click",g).off("keydown",h):l.attr({tabindex:o.tabindex,"aria-disabled":"false"}).on("click",g).on("keydown",h))}),o.hasOwnProperty("disabled")||o.hasOwnProperty("ngDisabled")||(l.attr({"aria-disabled":"false"}),l.on("click",g),l.on("keydown",h));var R={role:"listbox","aria-expanded":"false","aria-multiselectable":s&&!o.ngMultiple?"true":"false"};l[0].hasAttribute("id")||(R.id="select_"+t.nextUid());var I="select_container_"+t.nextUid();x.attr("id",I),R["aria-owns"]=I,l.attr(R),i.$on("$destroy",function(){e.destroy()["finally"](function(){y&&(y.setFocused(!1),y.setHasValue(!1),y.input=null),E.$setTouched()})})}}return{restrict:"E",require:["^?mdInputContainer","mdSelect","ngModel","?^form"],compile:l,controller:function(){}}}function SelectMenuDirective(e,t,n){function r(e,r,i,a){function l(e){13!=e.keyCode&&32!=e.keyCode||o(e)}function o(n){var r=t.getClosest(n.target,"md-option"),i=r&&angular.element(r).data("$mdOptionController");if(r&&i){if(r.hasAttribute("disabled"))return n.stopImmediatePropagation(),!1;var a=d.hashGetter(i.value),l=angular.isDefined(d.selected[a]);e.$apply(function(){d.isMultiple?l?d.deselect(a):d.select(a,i.value):l||(d.deselect(Object.keys(d.selected)[0]),d.select(a,i.value)),d.refreshViewValue()})}}var d=a[0];r.addClass("_md"),n(r),r.on("click",o),r.on("keypress",l)}function i(n,r,i){function a(){var e=o.ngModel.$modelValue||o.ngModel.$viewValue||[];if(angular.isArray(e)){var t=Object.keys(o.selected),n=e.map(o.hashGetter),r=t.filter(function(e){return-1===n.indexOf(e)});r.forEach(o.deselect),n.forEach(function(t,n){o.select(t,e[n])})}}function l(){var e=o.ngModel.$viewValue||o.ngModel.$modelValue;Object.keys(o.selected).forEach(o.deselect),o.select(o.hashGetter(e),e)}var o=this;o.isMultiple=angular.isDefined(r.multiple),o.selected={},o.options={},n.$watchCollection(function(){return o.options},function(){o.ngModel.$render()});var d,c;o.setMultiple=function(e){function t(e,t){return angular.isArray(e||t||[])}var r=o.ngModel;c=c||r.$isEmpty,o.isMultiple=e,d&&d(),o.isMultiple?(r.$validators["md-multiple"]=t,r.$render=a,n.$watchCollection(o.modelBinding,function(e){t(e)&&a(e),o.ngModel.$setPristine()}),r.$isEmpty=function(e){return!e||0===e.length}):(delete r.$validators["md-multiple"],r.$render=l)};var s,u,p,f="",m=300;o.optNodeForKeyboardSearch=function(e){s&&clearTimeout(s),s=setTimeout(function(){s=void 0,f="",p=void 0,u=void 0},m),f+=String.fromCharCode(e.keyCode);var t=new RegExp("^"+f,"i");u||(u=i.find("md-option"),p=new Array(u.length),angular.forEach(u,function(e,t){p[t]=e.textContent.trim()}));for(var n=0;n<p.length;++n)if(t.test(p[n]))return u[n]},o.init=function(t,r){if(o.ngModel=t,o.modelBinding=r,t.$options&&t.$options.trackBy){var i={},a=e(t.$options.trackBy);o.hashGetter=function(e,t){return i.$value=e,a(t||n,i)}}else o.hashGetter=function(e){return angular.isObject(e)?"object_"+(e.$$mdSelectId||(e.$$mdSelectId=++selectNextId)):e};o.setMultiple(o.isMultiple)},o.selectedLabels=function(e){e=e||{};var n=e.mode||"html",r=t.nodesToArray(i[0].querySelectorAll("md-option[selected]"));if(r.length){var a;return"html"==n?a=function(e){var t=e.innerHTML,n=e.querySelector(".md-ripple-container");return n?t.replace(n.outerHTML,""):t}:"aria"==n&&(a=function(e){return e.hasAttribute("aria-label")?e.getAttribute("aria-label"):e.textContent}),r.map(a).join(", ")}return""},o.select=function(e,t){var n=o.options[e];n&&n.setSelected(!0),o.selected[e]=t},o.deselect=function(e){var t=o.options[e];t&&t.setSelected(!1),delete o.selected[e]},o.addOption=function(e,t){if(angular.isDefined(o.options[e]))throw new Error('Duplicate md-option values are not allowed in a select. Duplicate value "'+t.value+'" found.');o.options[e]=t,angular.isDefined(o.selected[e])&&(o.select(e,t.value),o.refreshViewValue())},o.removeOption=function(e){delete o.options[e]},o.refreshViewValue=function(){var e,t=[];for(var n in o.selected)(e=o.options[n])?t.push(e.value):t.push(o.selected[n]);var r=o.ngModel.$options&&o.ngModel.$options.trackBy,i=o.isMultiple?t:t[0],a=o.ngModel.$modelValue;(r?angular.equals(a,i):a==i)||(o.ngModel.$setViewValue(i),o.ngModel.$render())}}return i.$inject=["$scope","$attrs","$element"],{restrict:"E",require:["mdSelectMenu"],scope:!1,controller:i,link:{pre:r}}}function OptionDirective(e,t){function n(e,t){return e.append(angular.element('<div class="_md-text">').append(e.contents())),e.attr("tabindex",t.tabindex||"0"),r}function r(n,r,i,a){function l(e,t,r){if(!c.hashGetter)return void(r||n.$$postDigest(function(){l(e,t,!0)}));var i=c.hashGetter(t,n),a=c.hashGetter(e,n);d.hashKey=a,d.value=e,c.removeOption(i,d),c.addOption(a,d)}function o(){var e={role:"option","aria-selected":"false"};r[0].hasAttribute("id")||(e.id="select_option_"+t.nextUid()),r.attr(e)}var d=a[0],c=a[1];c.isMultiple&&(r.addClass("_md-checkbox-enabled"),r.prepend(CHECKBOX_SELECTION_INDICATOR.clone())),angular.isDefined(i.ngValue)?n.$watch(i.ngValue,l):angular.isDefined(i.value)?l(i.value):n.$watch(function(){return r.text().trim()},l),i.$observe("disabled",function(e){e?r.attr("tabindex","-1"):r.attr("tabindex","0")}),n.$$postDigest(function(){i.$observe("selected",function(e){angular.isDefined(e)&&("string"==typeof e&&(e=!0),e?(c.isMultiple||c.deselect(Object.keys(c.selected)[0]),c.select(d.hashKey,d.value)):c.deselect(d.hashKey),c.refreshViewValue())})}),e.attach(n,r),o(),n.$on("$destroy",function(){c.removeOption(d.hashKey,d)})}function i(e){this.selected=!1,this.setSelected=function(t){t&&!this.selected?e.attr({selected:"selected","aria-selected":"true"}):!t&&this.selected&&(e.removeAttr("selected"),e.attr("aria-selected","false")),this.selected=t}}return i.$inject=["$element"],{restrict:"E",require:["mdOption","^^mdSelectMenu"],controller:i,compile:n}}function OptgroupDirective(){function e(e,t){function n(){return e.parent().find("md-select-header").length}function r(){var n=e.find("label");n.length||(n=angular.element("<label>"),e.prepend(n)),n.addClass("_md-container-ignore"),t.label&&n.text(t.label)}n()||r()}return{restrict:"E",compile:e}}function SelectHeaderDirective(){return{restrict:"E"}}function SelectProvider(e){function t(e,t,l,o,d,c,s,u,p){function f(e,t,n){function r(){return s(t,{addClass:"_md-leave"}).start()}function i(){t.removeClass("_md-active"),t.attr("aria-hidden","true"),t[0].style.display="none",h(n),!n.$destroy&&n.restoreFocus&&n.target.focus()}return n=n||{},n.cleanupInteraction(),n.cleanupResizing(),n.hideBackdrop(),n.$destroy===!0?i():r().then(i)}function m(n,r,i){function a(e,t,n){return n.parent.append(t),d(function(e,n){try{s(t,{removeClass:"_md-leave",duration:0}).start().then(f).then(e)}catch(r){n(r)}})}function f(){return d(function(e){if(i.isRemoved)return d.reject(!1);var t=g(n,r,i);t.container.element.css(b.toCss(t.container.styles)),t.dropDown.element.css(b.toCss(t.dropDown.styles)),c(function(){r.addClass("_md-active"),t.dropDown.element.css(b.toCss({transform:""})),h(i.focusedNode),e()})})}function m(e,t,n){return n.disableParentScroll&&!l.getClosest(n.target,"MD-DIALOG")?n.restoreScroll=l.disableScrollAround(n.element,n.parent):n.disableParentScroll=!1,n.hasBackdrop&&(n.backdrop=l.createBackdrop(e,"_md-select-backdrop _md-click-catcher"),u.enter(n.backdrop,p[0].body,null,{duration:0})),function(){n.backdrop&&n.backdrop.remove(),n.disableParentScroll&&n.restoreScroll(),delete n.restoreScroll}}function h(e){e&&!e.hasAttribute("disabled")&&e.focus()}function $(e,t){var n=r.find("md-select-menu");if(!t.target)throw new Error(l.supplant(v,[t.target]));angular.extend(t,{isRemoved:!1,target:angular.element(t.target),parent:angular.element(t.parent),selectEl:n,contentEl:r.find("md-content"),optionNodes:n[0].getElementsByTagName("md-option")})}function y(){var e=function(e,t,n){return function(){if(!n.isRemoved){var r=g(e,t,n),i=r.container,a=r.dropDown;i.element.css(b.toCss(i.styles)),a.element.css(b.toCss(a.styles))}}}(n,r,i),t=angular.element(o);return t.on("resize",e),t.on("orientationchange",e),function(){t.off("resize",e),t.off("orientationchange",e)}}function C(){i.loadingAsync&&!i.isRemoved&&(n.$$loadingAsyncDone=!1,d.when(i.loadingAsync).then(function(){n.$$loadingAsyncDone=!0,delete i.loadingAsync}).then(function(){c(f)}))}function E(){function n(t){t.preventDefault(),t.stopPropagation(),i.restoreFocus=!1,l.nextTick(e.hide,!0)}function a(n){var r=t.KEY_CODE;switch(n.preventDefault(),n.stopPropagation(),n.keyCode){case r.UP_ARROW:return c();case r.DOWN_ARROW:return d();case r.SPACE:case r.ENTER:var a=l.getClosest(n.target,"md-option");a&&(u.triggerHandler({type:"click",target:a}),n.preventDefault()),s(n);break;case r.TAB:case r.ESCAPE:n.stopPropagation(),n.preventDefault(),i.restoreFocus=!0,l.nextTick(e.hide,!0);break;default:if(n.keyCode>=31&&n.keyCode<=90){var o=u.controller("mdSelectMenu").optNodeForKeyboardSearch(n);i.focusedNode=o||i.focusedNode,o&&o.focus()}}}function o(e){var t,n=l.nodesToArray(i.optionNodes),r=n.indexOf(i.focusedNode);do-1===r?r=0:"next"===e&&r<n.length-1?r++:"prev"===e&&r>0&&r--,t=n[r],t.hasAttribute("disabled")&&(t=void 0);while(!t&&r<n.length-1&&r>0);t&&t.focus(),i.focusedNode=t}function d(){o("next")}function c(){o("prev")}function s(t){function n(){var e=!1;if(t&&t.currentTarget.children.length>0){var n=t.currentTarget.children[0],r=n.scrollHeight>n.clientHeight;if(r&&n.children.length>0){var i=t.pageX-t.currentTarget.getBoundingClientRect().left;i>n.querySelector("md-option").offsetWidth&&(e=!0)}}return e}if(!(t&&"click"==t.type&&t.currentTarget!=u[0]||n())){var r=l.getClosest(t.target,"md-option");r&&r.hasAttribute&&!r.hasAttribute("disabled")&&(t.preventDefault(),t.stopPropagation(),p.isMultiple||(i.restoreFocus=!0,l.nextTick(function(){e.hide(p.ngModel.$viewValue)},!0)))}}if(!i.isRemoved){var u=i.selectEl,p=u.controller("mdSelectMenu")||{};return r.addClass("_md-clickable"),i.backdrop&&i.backdrop.on("click",n),u.on("keydown",a),u.on("click",s),function(){i.backdrop&&i.backdrop.off("click",n),u.off("keydown",a),u.off("click",s),r.removeClass("_md-clickable"),i.isRemoved=!0}}}return C(),$(n,i),i.hideBackdrop=m(n,r,i),a(n,r,i).then(function(e){return r.attr("aria-hidden","false"),i.alreadyOpen=!0,i.cleanupInteraction=E(),i.cleanupResizing=y(),e},i.hideBackdrop)}function h(e){var t=e.selectCtrl;if(t){var n=e.selectEl.controller("mdSelectMenu");t.setLabelText(n?n.selectedLabels():""),t.triggerClose()}}function g(e,t,d){var c,s=t[0],u=d.target[0].children[0],f=p[0].body,m=d.selectEl[0],h=d.contentEl[0],g=f.getBoundingClientRect(),v=u.getBoundingClientRect(),b=!1,$={left:g.left+SELECT_EDGE_MARGIN,top:SELECT_EDGE_MARGIN,bottom:g.height-SELECT_EDGE_MARGIN,right:g.width-SELECT_EDGE_MARGIN-(l.floatingScrollbars()?16:0)},y={top:v.top-$.top,left:v.left-$.left,right:$.right-(v.left+v.width),bottom:$.bottom-(v.top+v.height)},C=g.width-2*SELECT_EDGE_MARGIN,E=m.querySelector("md-option[selected]"),k=m.getElementsByTagName("md-option"),M=m.getElementsByTagName("md-optgroup"),S=a(t,h),w=n(d.loadingAsync);c=w?h.firstElementChild||h:E?E:M.length?M[0]:k.length?k[0]:h.firstElementChild||h,h.offsetWidth>C?h.style["max-width"]=C+"px":h.style.maxWidth=null,b&&(h.style["min-width"]=v.width+"px"),S&&m.classList.add("_md-overflow");var x=c;"MD-OPTGROUP"===(x.tagName||"").toUpperCase()&&(x=k[0]||h.firstElementChild||h,c=x),d.focusedNode=x,s.style.display="block";var D=m.getBoundingClientRect(),O=i(c);if(c){var A=o.getComputedStyle(c);O.paddingLeft=parseInt(A.paddingLeft,10)||0,O.paddingRight=parseInt(A.paddingRight,10)||0}if(S){var _=h.offsetHeight/2;h.scrollTop=O.top+O.height/2-_,y.top<_?h.scrollTop=Math.min(O.top,h.scrollTop+_-y.top):y.bottom<_&&(h.scrollTop=Math.max(O.top+O.height-D.height,h.scrollTop-_+y.bottom))}var T,R,I,N;b?(T=v.left,R=v.top+v.height,I="50% 0",R+D.height>$.bottom&&(R=v.top-D.height,I="50% 100%")):(T=v.left+O.left-O.paddingLeft+2,R=Math.floor(v.top+v.height/2-O.height/2-O.top+h.scrollTop)+2,I=O.left+v.width/2+"px "+(O.top+O.height/2-h.scrollTop)+"px 0px",N=Math.min(v.width+O.paddingLeft+O.paddingRight,C));var L=s.getBoundingClientRect(),B=Math.round(100*Math.min(v.width/D.width,1))/100,P=Math.round(100*Math.min(v.height/D.height,1))/100;return{container:{element:angular.element(s),styles:{left:Math.floor(r($.left,T,$.right-L.width)),top:Math.floor(r($.top,R,$.bottom-L.height)),"min-width":N}},dropDown:{element:angular.element(m),styles:{transformOrigin:I,transform:d.alreadyOpen?"":l.supplant("scale({0},{1})",[B,P])}}}}var v="$mdSelect.show() expected a target element in options.target but got '{0}'!",b=l.dom.animator;return{parent:"body",themable:!0,onShow:m,onRemove:f,hasBackdrop:!0,disableParentScroll:!0}}function n(e){return e&&angular.isFunction(e.then)}function r(e,t,n){return Math.max(e,Math.min(t,n))}function i(e){return e?{left:e.offsetLeft,top:e.offsetTop,width:e.offsetWidth,height:e.offsetHeight}:{left:0,top:0,width:0,height:0}}function a(e,t){var n=!1;try{var r=e[0].style.display;e[0].style.display="block",n=t.scrollHeight>t.offsetHeight,e[0].style.display=r}finally{}return n}return t.$inject=["$mdSelect","$mdConstant","$mdUtil","$window","$q","$$rAF","$animateCss","$animate","$document"],e("$mdSelect").setDefaults({methods:["target"],options:t})}goog.provide("ng.material.components.select"),goog.require("ng.material.components.backdrop"),goog.require("ng.material.core");var SELECT_EDGE_MARGIN=8,selectNextId=0,CHECKBOX_SELECTION_INDICATOR=angular.element('<div class="_md-container"><div class="_md-icon"></div></div>');angular.module("material.components.select",["material.core","material.components.backdrop"]).directive("mdSelect",SelectDirective).directive("mdSelectMenu",SelectMenuDirective).directive("mdOption",OptionDirective).directive("mdOptgroup",OptgroupDirective).directive("mdSelectHeader",SelectHeaderDirective).provider("$mdSelect",SelectProvider),SelectDirective.$inject=["$mdSelect","$mdUtil","$mdTheming","$mdAria","$compile","$parse"],SelectMenuDirective.$inject=["$parse","$mdUtil","$mdTheming"],OptionDirective.$inject=["$mdButtonInkRipple","$mdUtil"],SelectProvider.$inject=["$$interimElementProvider"],ng.material.components.select=angular.module("material.components.select");