!function(t){"undefined"==typeof t.fn.each2&&t.extend(t.fn,{each2:function(e){for(var i=t([0]),s=-1,a=this.length;++s<a&&(i.context=i[0]=this[s])&&e.call(i[0],s,i)!==!1;);return this}})}(jQuery),function(t,e){"use strict";function i(t){var e,i,s,a;if(!t||t.length<1)return t;for(e="",i=0,s=t.length;s>i;i++)a=t.charAt(i),e+=J[a]||a;return e}function s(t,e){for(var i=0,s=e.length;s>i;i+=1)if(n(t,e[i]))return i;return-1}function a(){var e=t($);e.appendTo("body");var i={width:e.width()-e[0].clientWidth,height:e.height()-e[0].clientHeight};return e.remove(),i}function n(t,i){return t===i?!0:t===e||i===e?!1:null===t||null===i?!1:t.constructor===String?t+""==i+"":i.constructor===String?i+""==t+"":!1}function o(e,i){var s,a,n;if(null===e||e.length<1)return[];for(s=e.split(i),a=0,n=s.length;n>a;a+=1)s[a]=t.trim(s[a]);return s}function r(t){return t.outerWidth(!1)-t.width()}function l(i){var s="keyup-change-value";i.on("keydown",function(){t.data(i,s)===e&&t.data(i,s,i.val())}),i.on("keyup",function(){var a=t.data(i,s);a!==e&&i.val()!==a&&(t.removeData(i,s),i.trigger("keyup-change"))})}function h(i){i.on("mousemove",function(i){var s=U;(s===e||s.x!==i.pageX||s.y!==i.pageY)&&t(i.target).trigger("mousemove-filtered",i)})}function c(t,i,s){s=s||e;var a;return function(){var e=arguments;window.clearTimeout(a),a=window.setTimeout(function(){i.apply(s,e)},t)}}function d(t){var e,i=!1;return function(){return i===!1&&(e=t(),i=!0),e}}function u(t,e){var i=c(t,function(t){e.trigger("scroll-debounced",t)});e.on("scroll",function(t){s(t.target,e.get())>=0&&i(t)})}function p(t){t[0]!==document.activeElement&&window.setTimeout(function(){var e,i=t[0],s=t.val().length;t.focus(),t.is(":visible")&&i===document.activeElement&&(i.setSelectionRange?i.setSelectionRange(s,s):i.createTextRange&&(e=i.createTextRange(),e.collapse(!1),e.select()))},0)}function f(e){e=t(e)[0];var i=0,s=0;if("selectionStart"in e)i=e.selectionStart,s=e.selectionEnd-i;else if("selection"in document){e.focus();var a=document.selection.createRange();s=document.selection.createRange().text.length,a.moveStart("character",-e.value.length),i=a.text.length-s}return{offset:i,length:s}}function m(t){t.preventDefault(),t.stopPropagation()}function g(t){t.preventDefault(),t.stopImmediatePropagation()}function v(e){if(!I){var i=e[0].currentStyle||window.getComputedStyle(e[0],null);I=t(document.createElement("div")).css({position:"absolute",left:"-10000px",top:"-10000px",display:"none",fontSize:i.fontSize,fontFamily:i.fontFamily,fontStyle:i.fontStyle,fontWeight:i.fontWeight,letterSpacing:i.letterSpacing,textTransform:i.textTransform,whiteSpace:"nowrap"}),I.attr("class","select2-sizer"),t("body").append(I)}return I.text(e.val()),I.width()}function y(e,i,s){var a,n,o=[];a=e.attr("class"),a&&(a=""+a,t(a.split(" ")).each2(function(){0===this.indexOf("select2-")&&o.push(this)})),a=i.attr("class"),a&&(a=""+a,t(a.split(" ")).each2(function(){0!==this.indexOf("select2-")&&(n=s(this),n&&o.push(this))})),e.attr("class",o.join(" "))}function b(t,e,s,a){var n=i(t.toUpperCase()).indexOf(i(e.toUpperCase())),o=e.length;return 0>n?(s.push(a(t)),void 0):(s.push(a(t.substring(0,n))),s.push("<span class='select2-match'>"),s.push(a(t.substring(n,n+o))),s.push("</span>"),s.push(a(t.substring(n+o,t.length))),void 0)}function S(t){var e={"\\":"\","&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return String(t).replace(/[&<>"'\/\\]/g,function(t){return e[t]})}function w(i){var s,a=null,n=i.quietMillis||100,o=i.url,r=this;return function(l){window.clearTimeout(s),s=window.setTimeout(function(){var s=i.data,n=o,h=i.transport||t.fn.select2.ajaxDefaults.transport,c={type:i.type||"GET",cache:i.cache||!1,jsonpCallback:i.jsonpCallback||e,dataType:i.dataType||"json"},d=t.extend({},t.fn.select2.ajaxDefaults.params,c);s=s?s.call(r,l.term,l.page,l.context):null,n="function"==typeof n?n.call(r,l.term,l.page,l.context):n,a&&a.abort(),i.params&&(t.isFunction(i.params)?t.extend(d,i.params.call(r)):t.extend(d,i.params)),t.extend(d,{url:n,dataType:i.dataType,data:s,success:function(t){var e=i.results(t,l.page);l.callback(e)}}),a=h.call(r,d)},n)}}function k(e){var i,s,a=e,n=function(t){return""+t.text};t.isArray(a)&&(s=a,a={results:s}),t.isFunction(a)===!1&&(s=a,a=function(){return s});var o=a();return o.text&&(n=o.text,t.isFunction(n)||(i=o.text,n=function(t){return t[i]})),function(e){var i,s=e.term,o={results:[]};return""===s?(e.callback(a()),void 0):(i=function(a,o){var r,l;if(a=a[0],a.children){r={};for(l in a)a.hasOwnProperty(l)&&(r[l]=a[l]);r.children=[],t(a.children).each2(function(t,e){i(e,r.children)}),(r.children.length||e.matcher(s,n(r),a))&&o.push(r)}else e.matcher(s,n(a),a)&&o.push(a)},t(a().results).each2(function(t,e){i(e,o.results)}),e.callback(o),void 0)}}function C(i){var s=t.isFunction(i);return function(a){var n=a.term,o={results:[]};t(s?i():i).each(function(){var t=this.text!==e,i=t?this.text:this;(""===n||a.matcher(n,i))&&o.results.push(t?this:{id:this,text:this})}),a.callback(o)}}function M(e,i){if(t.isFunction(e))return!0;if(!e)return!1;throw new Error(i+" must be a function or a falsy value")}function D(e){return t.isFunction(e)?e():e}function T(e){var i=0;return t.each(e,function(t,e){e.children?i+=T(e.children):i++}),i}function x(t,i,s,a){var o,r,l,h,c,d=t,u=!1;if(!a.createSearchChoice||!a.tokenSeparators||a.tokenSeparators.length<1)return e;for(;;){for(r=-1,l=0,h=a.tokenSeparators.length;h>l&&(c=a.tokenSeparators[l],r=t.indexOf(c),!(r>=0));l++);if(0>r)break;if(o=t.substring(0,r),t=t.substring(r+c.length),o.length>0&&(o=a.createSearchChoice.call(this,o,i),o!==e&&null!==o&&a.id(o)!==e&&null!==a.id(o))){for(u=!1,l=0,h=i.length;h>l;l++)if(n(a.id(o),a.id(i[l]))){u=!0;break}u||s(o)}}return d!==t?t:void 0}function P(e,i){var s=function(){};return s.prototype=new e,s.prototype.constructor=s,s.prototype.parent=e.prototype,s.prototype=t.extend(s.prototype,i),s}if(window.Select2===e){var A,E,F,L,O,I,j,N,U={x:0,y:0},A={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,isArrow:function(t){switch(t=t.which?t.which:t){case A.LEFT:case A.RIGHT:case A.UP:case A.DOWN:return!0}return!1},isControl:function(t){var e=t.which;switch(e){case A.SHIFT:case A.CTRL:case A.ALT:return!0}return t.metaKey?!0:!1},isFunctionKey:function(t){return t=t.which?t.which:t,t>=112&&123>=t}},$="<div class='select2-measure-scrollbar'></div>",J={"â’¶":"A","A":"A","À":"A","Ã":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ä€":"A","Ä‚":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ç ":"A","Ä":"A","Çž":"A","Ả":"A","Ã…":"A","Ǻ":"A","Ç":"A","È€":"A","È‚":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ä„":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ç¢":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","â’·":"B","ï¼¢":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Æ‚":"B","Æ":"B","â’¸":"C","ï¼£":"C","Ć":"C","Ĉ":"C","ÄŠ":"C","ÄŒ":"C","Ç":"C","Ḉ":"C","Ƈ":"C","È»":"C","Ꜿ":"C","â’¹":"D","D":"D","Ḋ":"D","ÄŽ":"D","Ḍ":"D","á¸":"D","Ḓ":"D","Ḏ":"D","Ä":"D","Æ‹":"D","ÆŠ":"D","Ɖ":"D","ê¹":"D","DZ":"DZ","Ç„":"DZ","Dz":"Dz","Ç…":"Dz","â’º":"E","ï¼¥":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ä’":"E","Ḕ":"E","Ḗ":"E","Ä”":"E","Ä–":"E","Ë":"E","Ẻ":"E","Äš":"E","È„":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Æ":"E","ÆŽ":"E","â’»":"F","F":"F","Ḟ":"F","Æ‘":"F","ê»":"F","â’¼":"G","G":"G","Ç´":"G","Äœ":"G","Ḡ":"G","Äž":"G","Ä ":"G","Ǧ":"G","Ä¢":"G","Ǥ":"G","Æ“":"G","êž ":"G","ê½":"G","ê¾":"G","â’½":"H","H":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Èž":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","â±µ":"H","êž":"H","â’¾":"I","I":"I","ÃŒ":"I","Ã":"I","ÃŽ":"I","Ĩ":"I","Ī":"I","Ĭ":"I","Ä°":"I","Ã":"I","Ḯ":"I","Ỉ":"I","Ç":"I","Ȉ":"I","ÈŠ":"I","Ị":"I","Ä®":"I","Ḭ":"I","Æ—":"I","â’¿":"J","J":"J","Ä´":"J","Ɉ":"J","â“€":"K","K":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","ê€":"K","ê‚":"K","ê„":"K","Ꞣ":"K","â“":"L","L":"L","Ä¿":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ä»":"L","Ḽ":"L","Ḻ":"L","Å":"L","Ƚ":"L","â±¢":"L","â± ":"L","êˆ":"L","ê†":"L","Ꞁ":"L","LJ":"LJ","Lj":"Lj","â“‚":"M","ï¼":"M","Ḿ":"M","á¹€":"M","Ṃ":"M","â±®":"M","Æœ":"M","Ⓝ":"N","ï¼®":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Å…":"N","Ṋ":"N","Ṉ":"N","È ":"N","Æ":"N","êž":"N","Ꞥ":"N","ÇŠ":"NJ","Ç‹":"Nj","â“„":"O","O":"O","Ã’":"O","Ó":"O","Ô":"O","á»’":"O","á»":"O","á»–":"O","á»”":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","ÅŒ":"O","á¹":"O","á¹’":"O","ÅŽ":"O","È®":"O","È°":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Å":"O","Ç‘":"O","ÈŒ":"O","ÈŽ":"O","Æ ":"O","Ờ":"O","Ớ":"O","á» ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","ÆŸ":"O","êŠ":"O","êŒ":"O","Æ¢":"OI","êŽ":"OO","È¢":"OU","â“…":"P","ï¼°":"P","á¹”":"P","á¹–":"P","Ƥ":"P","â±£":"P","ê":"P","ê’":"P","ê”":"P","Ⓠ":"Q","ï¼±":"Q","ê–":"Q","ê˜":"Q","ÉŠ":"Q","Ⓡ":"R","ï¼²":"R","Å”":"R","Ṙ":"R","Ř":"R","È":"R","È’":"R","Ṛ":"R","Ṝ":"R","Å–":"R","Ṟ":"R","ÉŒ":"R","Ɽ":"R","êš":"R","Ꞧ":"R","êž‚":"R","Ⓢ":"S","ï¼³":"S","ẞ":"S","Åš":"S","Ṥ":"S","Åœ":"S","á¹ ":"S","Å ":"S","Ṧ":"S","á¹¢":"S","Ṩ":"S","Ș":"S","Åž":"S","â±¾":"S","Ꞩ":"S","êž„":"S","Ⓣ":"T","ï¼´":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Èš":"T","Å¢":"T","á¹°":"T","á¹®":"T","Ŧ":"T","Ƭ":"T","Æ®":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","â“Š":"U","ï¼µ":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ãœ":"U","Ç›":"U","Ç—":"U","Ç•":"U","Ç™":"U","Ủ":"U","Å®":"U","Å°":"U","Ç“":"U","È”":"U","È–":"U","Ư":"U","Ừ":"U","Ứ":"U","á»®":"U","Ử":"U","á»°":"U","Ụ":"U","á¹²":"U","Ų":"U","Ṷ":"U","á¹´":"U","É„":"U","â“‹":"V","V":"V","á¹¼":"V","á¹¾":"V","Ʋ":"V","êž":"V","É…":"V","ê ":"VY","â“Œ":"W","ï¼·":"W","Ẁ":"W","Ẃ":"W","Å´":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","â±²":"W","â“":"X","X":"X","Ẋ":"X","Ẍ":"X","â“Ž":"Y","ï¼¹":"Y","Ỳ":"Y","Ã":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","á»´":"Y","Ƴ":"Y","ÉŽ":"Y","Ỿ":"Y","â“":"Z","Z":"Z","Ź":"Z","áº":"Z","Å»":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","ê¢":"Z","â“":"a","ï½":"a","ẚ":"a","à ":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","Ä":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","Ç¡":"a","ä":"a","ÇŸ":"a","ả":"a","Ã¥":"a","Ç»":"a","ÇŽ":"a","È":"a","ȃ":"a","ạ":"a","áº":"a","ặ":"a","á¸":"a","Ä…":"a","â±¥":"a","É":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","Ç£":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","â“‘":"b","b":"b","ḃ":"b","ḅ":"b","ḇ":"b","Æ€":"b","ƃ":"b","É“":"b","â“’":"c","c":"c","ć":"c","ĉ":"c","Ä‹":"c","Ä":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","â““":"d","d":"d","ḋ":"d","Ä":"d","á¸":"d","ḑ":"d","ḓ":"d","á¸":"d","Ä‘":"d","ÆŒ":"d","É–":"d","É—":"d","êº":"d","dz":"dz","dž":"dz","â“”":"e","ï½…":"e","è":"e","é":"e","ê":"e","á»":"e","ế":"e","á»…":"e","ể":"e","ẽ":"e","Ä“":"e","ḕ":"e","ḗ":"e","Ä•":"e","Ä—":"e","ë":"e","ẻ":"e","Ä›":"e","È…":"e","ȇ":"e","ẹ":"e","ệ":"e","È©":"e","á¸":"e","Ä™":"e","ḙ":"e","ḛ":"e","ɇ":"e","É›":"e","Ç":"e","â“•":"f","f":"f","ḟ":"f","Æ’":"f","ê¼":"f","â“–":"g","g":"g","ǵ":"g","Ä":"g","ḡ":"g","ÄŸ":"g","Ä¡":"g","ǧ":"g","Ä£":"g","Ç¥":"g","É ":"g","êž¡":"g","áµ¹":"g","ê¿":"g","â“—":"h","h":"h","Ä¥":"h","ḣ":"h","ḧ":"h","ÈŸ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","É¥":"h","Æ•":"hv","ⓘ":"i","i":"i","ì":"i","Ã":"i","î":"i","Ä©":"i","Ä«":"i","Ä":"i","ï":"i","ḯ":"i","ỉ":"i","Ç":"i","ȉ":"i","È‹":"i","ị":"i","į":"i","á¸":"i","ɨ":"i","ı":"i","â“™":"j","j":"j","ĵ":"j","Ç°":"j","ɉ":"j","â“š":"k","k":"k","ḱ":"k","Ç©":"k","ḳ":"k","Ä·":"k","ḵ":"k","Æ™":"k","ⱪ":"k","ê":"k","êƒ":"k","ê…":"k","ꞣ":"k","â“›":"l","l":"l","Å€":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","Å¿":"l","Å‚":"l","Æš":"l","É«":"l","ⱡ":"l","ê‰":"l","êž":"l","ê‡":"l","lj":"lj","â“œ":"m","ï½":"m","ḿ":"m","á¹":"m","ṃ":"m","ɱ":"m","ɯ":"m","â“":"n","n":"n","ǹ":"n","Å„":"n","ñ":"n","á¹…":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","Æž":"n","ɲ":"n","ʼn":"n","êž‘":"n","ꞥ":"n","ÇŒ":"nj","â“ž":"o","ï½":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","á»—":"o","ổ":"o","õ":"o","á¹":"o","È":"o","á¹":"o","Å":"o","ṑ":"o","ṓ":"o","Å":"o","ȯ":"o","ȱ":"o","ö":"o","È«":"o","á»":"o","Å‘":"o","Ç’":"o","È":"o","È":"o","Æ¡":"o","á»":"o","á»›":"o","ỡ":"o","ở":"o","ợ":"o","á»":"o","á»™":"o","Ç«":"o","Ç":"o","ø":"o","Ç¿":"o","É”":"o","ê‹":"o","ê":"o","ɵ":"o","Æ£":"oi","È£":"ou","ê":"oo","â“Ÿ":"p","ï½":"p","ṕ":"p","á¹—":"p","Æ¥":"p","áµ½":"p","ê‘":"p","ê“":"p","ê•":"p","â“ ":"q","q":"q","É‹":"q","ê—":"q","ê™":"q","â“¡":"r","ï½’":"r","Å•":"r","á¹™":"r","Å™":"r","È‘":"r","È“":"r","á¹›":"r","á¹":"r","Å—":"r","ṟ":"r","É":"r","ɽ":"r","ê›":"r","ꞧ":"r","ꞃ":"r","â“¢":"s","s":"s","ß":"s","Å›":"s","á¹¥":"s","Å":"s","ṡ":"s","Å¡":"s","ṧ":"s","á¹£":"s","ṩ":"s","È™":"s","ÅŸ":"s","È¿":"s","êž©":"s","êž…":"s","ẛ":"s","â“£":"t","ï½”":"t","ṫ":"t","ẗ":"t","Å¥":"t","á¹":"t","È›":"t","Å£":"t","á¹±":"t","ṯ":"t","ŧ":"t","Æ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","u":"u","ù":"u","ú":"u","û":"u","Å©":"u","á¹¹":"u","Å«":"u","á¹»":"u","Å":"u","ü":"u","Çœ":"u","ǘ":"u","Ç–":"u","Çš":"u","ủ":"u","ů":"u","ű":"u","Ç”":"u","È•":"u","È—":"u","Æ°":"u","ừ":"u","ứ":"u","ữ":"u","á»":"u","á»±":"u","ụ":"u","á¹³":"u","ų":"u","á¹·":"u","á¹µ":"u","ʉ":"u","â“¥":"v","ï½–":"v","á¹½":"v","ṿ":"v","Ê‹":"v","êŸ":"v","ÊŒ":"v","ê¡":"vy","ⓦ":"w","ï½—":"w","áº":"w","ẃ":"w","ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","â±³":"w","ⓧ":"x","x":"x","ẋ":"x","áº":"x","ⓨ":"y","ï½™":"y","ỳ":"y","ý":"y","Å·":"y","ỹ":"y","ȳ":"y","áº":"y","ÿ":"y","á»·":"y","ẙ":"y","ỵ":"y","Æ´":"y","É":"y","ỿ":"y","â“©":"z","z":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","È¥":"z","É€":"z","ⱬ":"z","ê£":"z"};j=t(document),O=function(){var t=1;return function(){return t++}}(),j.on("mousemove",function(t){U.x=t.pageX,U.y=t.pageY}),E=P(Object,{bind:function(t){var e=this;return function(){t.apply(e,arguments)}},init:function(i){var s,n,o,r,c=".select2-results";this.opts=i=this.prepareOpts(i),this.id=i.id,i.element.data("select2")!==e&&null!==i.element.data("select2")&&i.element.data("select2").destroy(),this.container=this.createContainer(),this.containerId="s2id_"+(i.element.attr("id")||"autogen"+O()),this.containerSelector="#"+this.containerId.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,"\\$1"),this.container.attr("id",this.containerId),this.body=d(function(){return i.element.closest("body")}),y(this.container,this.opts.element,this.opts.adaptContainerCssClass),this.container.attr("style",i.element.attr("style")),this.container.css(D(i.containerCss)),this.container.addClass(D(i.containerCssClass)),this.elementTabIndex=this.opts.element.attr("tabindex"),this.opts.element.data("select2",this).attr("tabindex","-1").before(this.container).on("click.select2",m),this.container.data("select2",this),this.dropdown=this.container.find(".select2-drop"),y(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass),this.dropdown.addClass(D(i.dropdownCssClass)),this.dropdown.data("select2",this),this.dropdown.on("click",m),this.results=s=this.container.find(c),this.search=n=this.container.find("input.select2-input"),this.queryCount=0,this.resultsPage=0,this.context=null,this.initContainer(),this.container.on("click",m),h(this.results),this.dropdown.on("mousemove-filtered touchstart touchmove touchend",c,this.bind(this.highlightUnderEvent)),u(80,this.results),this.dropdown.on("scroll-debounced",c,this.bind(this.loadMoreIfNeeded)),t(this.container).on("change",".select2-input",function(t){t.stopPropagation()}),t(this.dropdown).on("change",".select2-input",function(t){t.stopPropagation()}),t.fn.mousewheel&&s.mousewheel(function(t,e,i,a){var n=s.scrollTop();a>0&&0>=n-a?(s.scrollTop(0),m(t)):0>a&&s.get(0).scrollHeight-s.scrollTop()+a<=s.height()&&(s.scrollTop(s.get(0).scrollHeight-s.height()),m(t))}),l(n),n.on("keyup-change input paste",this.bind(this.updateResults)),n.on("focus",function(){n.addClass("select2-focused")}),n.on("blur",function(){n.removeClass("select2-focused")}),this.dropdown.on("mouseup",c,this.bind(function(e){t(e.target).closest(".select2-result-selectable").length>0&&(this.highlightUnderEvent(e),this.selectHighlighted(e))})),this.dropdown.on("click mouseup mousedown",function(t){t.stopPropagation()}),t.isFunction(this.opts.initSelection)&&(this.initSelection(),this.monitorSource()),null!==i.maximumInputLength&&this.search.attr("maxlength",i.maximumInputLength);var o=i.element.prop("disabled");o===e&&(o=!1),this.enable(!o);var r=i.element.prop("readonly");r===e&&(r=!1),this.readonly(r),N=N||a(),this.autofocus=i.element.prop("autofocus"),i.element.prop("autofocus",!1),this.autofocus&&this.focus(),this.nextSearchTerm=e},destroy:function(){var t=this.opts.element,i=t.data("select2");this.close(),this.propertyObserver&&(delete this.propertyObserver,this.propertyObserver=null),i!==e&&(i.container.remove(),i.dropdown.remove(),t.removeClass("select2-offscreen").removeData("select2").off(".select2").prop("autofocus",this.autofocus||!1),this.elementTabIndex?t.attr({tabindex:this.elementTabIndex}):t.removeAttr("tabindex"),t.show())},optionToData:function(t){return t.is("option")?{id:t.prop("value"),text:t.text(),element:t.get(),css:t.attr("class"),disabled:t.prop("disabled"),locked:n(t.attr("locked"),"locked")||n(t.data("locked"),!0)}:t.is("optgroup")?{text:t.attr("label"),children:[],element:t.get(),css:t.attr("class")}:void 0},prepareOpts:function(i){var s,a,r,l,h=this;if(s=i.element,"select"===s.get(0).tagName.toLowerCase()&&(this.select=a=i.element),a&&t.each(["id","multiple","ajax","query","createSearchChoice","initSelection","data","tags"],function(){if(this in i)throw new Error("Option '"+this+"' is not allowed for Select2 when attached to a <select> element.")}),i=t.extend({},{populateResults:function(s,a,n){var o,r=this.opts.id;o=function(s,a,l){var c,d,u,p,f,m,g,v,y,b;for(s=i.sortResults(s,a,n),c=0,d=s.length;d>c;c+=1)u=s[c],f=u.disabled===!0,p=!f&&r(u)!==e,m=u.children&&u.children.length>0,g=t("<li></li>"),g.addClass("select2-results-dept-"+l),g.addClass("select2-result"),g.addClass(p?"select2-result-selectable":"select2-result-unselectable"),f&&g.addClass("select2-disabled"),m&&g.addClass("select2-result-with-children"),g.addClass(h.opts.formatResultCssClass(u)),v=t(document.createElement("div")),v.addClass("select2-result-label"),b=i.formatResult(u,v,n,h.opts.escapeMarkup),b!==e&&v.html(b),g.append(v),m&&(y=t("<ul></ul>"),y.addClass("select2-result-sub"),o(u.children,y,l+1),g.append(y)),g.data("select2-data",u),a.append(g)},o(a,s,0)}},t.fn.select2.defaults,i),"function"!=typeof i.id&&(r=i.id,i.id=function(t){return t[r]}),t.isArray(i.element.data("select2Tags"))){if("tags"in i)throw"tags specified as both an attribute 'data-select2-tags' and in options of Select2 "+i.element.attr("id");i.tags=i.element.data("select2Tags")}if(a?(i.query=this.bind(function(t){var i,a,n,o={results:[],more:!1},r=t.term;n=function(e,i){var s;e.is("option")?t.matcher(r,e.text(),e)&&i.push(h.optionToData(e)):e.is("optgroup")&&(s=h.optionToData(e),e.children().each2(function(t,e){n(e,s.children)}),s.children.length>0&&i.push(s))},i=s.children(),this.getPlaceholder()!==e&&i.length>0&&(a=this.getPlaceholderOption(),a&&(i=i.not(a))),i.each2(function(t,e){n(e,o.results)}),t.callback(o)}),i.id=function(t){return t.id},i.formatResultCssClass=function(t){return t.css}):"query"in i||("ajax"in i?(l=i.element.data("ajax-url"),l&&l.length>0&&(i.ajax.url=l),i.query=w.call(i.element,i.ajax)):"data"in i?i.query=k(i.data):"tags"in i&&(i.query=C(i.tags),i.createSearchChoice===e&&(i.createSearchChoice=function(e){return{id:t.trim(e),text:t.trim(e)}}),i.initSelection===e&&(i.initSelection=function(e,s){var a=[];t(o(e.val(),i.separator)).each(function(){var e={id:this,text:this},s=i.tags;t.isFunction(s)&&(s=s()),t(s).each(function(){return n(this.id,e.id)?(e=this,!1):void 0}),a.push(e)}),s(a)}))),"function"!=typeof i.query)throw"query function not defined for Select2 "+i.element.attr("id");return i},monitorSource:function(){var t,i=this.opts.element;i.on("change.select2",this.bind(function(){this.opts.element.data("select2-change-triggered")!==!0&&this.initSelection()})),t=this.bind(function(){var t,s=i.prop("disabled");s===e&&(s=!1),this.enable(!s);var t=i.prop("readonly");t===e&&(t=!1),this.readonly(t),y(this.container,this.opts.element,this.opts.adaptContainerCssClass),this.container.addClass(D(this.opts.containerCssClass)),y(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass),this.dropdown.addClass(D(this.opts.dropdownCssClass))}),i.on("propertychange.select2 DOMAttrModified.select2",t),this.mutationCallback===e&&(this.mutationCallback=function(e){e.forEach(t)}),"undefined"!=typeof WebKitMutationObserver&&(this.propertyObserver&&(delete this.propertyObserver,this.propertyObserver=null),this.propertyObserver=new WebKitMutationObserver(this.mutationCallback),this.propertyObserver.observe(i.get(0),{attributes:!0,subtree:!1}))},triggerSelect:function(e){var i=t.Event("select2-selecting",{val:this.id(e),object:e});return this.opts.element.trigger(i),!i.isDefaultPrevented()},triggerChange:function(e){e=e||{},e=t.extend({},e,{type:"change",val:this.val()}),this.opts.element.data("select2-change-triggered",!0),this.opts.element.trigger(e),this.opts.element.data("select2-change-triggered",!1),this.opts.element.click(),this.opts.blurOnChange&&this.opts.element.blur()},isInterfaceEnabled:function(){return this.enabledInterface===!0},enableInterface:function(){var t=this._enabled&&!this._readonly,e=!t;return t===this.enabledInterface?!1:(this.container.toggleClass("select2-container-disabled",e),this.close(),this.enabledInterface=t,!0)},enable:function(t){t===e&&(t=!0),this._enabled!==t&&(this._enabled=t,this.opts.element.prop("disabled",!t),this.enableInterface())},disable:function(){this.enable(!1)},readonly:function(t){return t===e&&(t=!1),this._readonly===t?!1:(this._readonly=t,this.opts.element.prop("readonly",t),this.enableInterface(),!0)},opened:function(){return this.container.hasClass("select2-dropdown-open")},positionDropdown:function(){var e,i,s,a,n=this.dropdown,o=this.container.offset(),r=this.container.outerHeight(!1),l=this.container.outerWidth(!1),h=n.outerHeight(!1),c=t(window).scrollLeft()+t(window).width(),d=t(window).scrollTop()+t(window).height(),u=o.top+r,p=o.left,f=d>=u+h,m=o.top-h>=this.body().scrollTop(),g=n.outerWidth(!1),v=c>=p+g,y=n.hasClass("select2-drop-above");this.opts.dropdownAutoWidth?(a=t(".select2-results",n)[0],n.addClass("select2-drop-auto-width"),n.css("width",""),g=n.outerWidth(!1)+(a.scrollHeight===a.clientHeight?0:N.width),g>l?l=g:g=l,v=c>=p+g):this.container.removeClass("select2-drop-auto-width"),"static"!==this.body().css("position")&&(e=this.body().offset(),u-=e.top,p-=e.left),y?(i=!0,!m&&f&&(i=!1)):(i=!1,!f&&m&&(i=!0)),v||(p=o.left+l-g),i?(u=o.top-h,this.container.addClass("select2-drop-above"),n.addClass("select2-drop-above")):(this.container.removeClass("select2-drop-above"),n.removeClass("select2-drop-above")),s=t.extend({top:u,left:p,width:l},D(this.opts.dropdownCss)),n.css(s)},shouldOpen:function(){var e;return this.opened()?!1:this._enabled===!1||this._readonly===!0?!1:(e=t.Event("select2-opening"),this.opts.element.trigger(e),!e.isDefaultPrevented())},clearDropdownAlignmentPreference:function(){this.container.removeClass("select2-drop-above"),this.dropdown.removeClass("select2-drop-above")},open:function(){return this.shouldOpen()?(this.opening(),!0):!1},opening:function(){var e,i=this.containerId,s="scroll."+i,a="resize."+i,n="orientationchange."+i;this.container.addClass("select2-dropdown-open").addClass("select2-container-active"),this.clearDropdownAlignmentPreference(),this.dropdown[0]!==this.body().children().last()[0]&&this.dropdown.detach().appendTo(this.body()),e=t("#select2-drop-mask"),0==e.length&&(e=t(document.createElement("div")),e.attr("id","select2-drop-mask").attr("class","select2-drop-mask"),e.hide(),e.appendTo(this.body()),e.on("mousedown touchstart click",function(e){var i,s=t("#select2-drop");s.length>0&&(i=s.data("select2"),i.opts.selectOnBlur&&i.selectHighlighted({noFocus:!0}),i.close({focus:!1}),e.preventDefault(),e.stopPropagation())})),this.dropdown.prev()[0]!==e[0]&&this.dropdown.before(e),t("#select2-drop").removeAttr("id"),this.dropdown.attr("id","select2-drop"),e.show(),this.positionDropdown(),this.dropdown.show(),this.positionDropdown(),this.dropdown.addClass("select2-drop-active");var o=this;this.container.parents().add(window).each(function(){t(this).on(a+" "+s+" "+n,function(){o.positionDropdown()})})},close:function(){if(this.opened()){var e=this.containerId,i="scroll."+e,s="resize."+e,a="orientationchange."+e;this.container.parents().add(window).each(function(){t(this).off(i).off(s).off(a)}),this.clearDropdownAlignmentPreference(),t("#select2-drop-mask").hide(),this.dropdown.removeAttr("id"),this.dropdown.hide(),this.container.removeClass("select2-dropdown-open").removeClass("select2-container-active"),this.results.empty(),this.clearSearch(),this.search.removeClass("select2-active"),this.opts.element.trigger(t.Event("select2-close"))}},externalSearch:function(t){this.open(),this.search.val(t),this.updateResults(!1)},clearSearch:function(){},getMaximumSelectionSize:function(){return D(this.opts.maximumSelectionSize)},ensureHighlightVisible:function(){var e,i,s,a,n,o,r,l=this.results;if(i=this.highlight(),!(0>i)){if(0==i)return l.scrollTop(0),void 0;e=this.findHighlightableChoices().find(".select2-result-label"),s=t(e[i]),a=s.offset().top+s.outerHeight(!0),i===e.length-1&&(r=l.find("li.select2-more-results"),r.length>0&&(a=r.offset().top+r.outerHeight(!0))),n=l.offset().top+l.outerHeight(!0),a>n&&l.scrollTop(l.scrollTop()+(a-n)),o=s.offset().top-l.offset().top,0>o&&"none"!=s.css("display")&&l.scrollTop(l.scrollTop()+o)}},findHighlightableChoices:function(){return this.results.find(".select2-result-selectable:not(.select2-disabled)")},moveHighlight:function(e){for(var i=this.findHighlightableChoices(),s=this.highlight();s>-1&&s<i.length;){s+=e;var a=t(i[s]);if(a.hasClass("select2-result-selectable")&&!a.hasClass("select2-disabled")&&!a.hasClass("select2-selected")){this.highlight(s);break}}},highlight:function(e){var i,a,n=this.findHighlightableChoices();return 0===arguments.length?s(n.filter(".select2-highlighted")[0],n.get()):(e>=n.length&&(e=n.length-1),0>e&&(e=0),this.removeHighlight(),i=t(n[e]),i.addClass("select2-highlighted"),this.ensureHighlightVisible(),a=i.data("select2-data"),a&&this.opts.element.trigger({type:"select2-highlight",val:this.id(a),choice:a}),void 0)},removeHighlight:function(){this.results.find(".select2-highlighted").removeClass("select2-highlighted")},countSelectableResults:function(){return this.findHighlightableChoices().length},highlightUnderEvent:function(e){var i=t(e.target).closest(".select2-result-selectable");if(i.length>0&&!i.is(".select2-highlighted")){var s=this.findHighlightableChoices();this.highlight(s.index(i))}else 0==i.length&&this.removeHighlight()},loadMoreIfNeeded:function(){var t,e=this.results,i=e.find("li.select2-more-results"),s=this.resultsPage+1,a=this,n=this.search.val(),o=this.context;0!==i.length&&(t=i.offset().top-e.offset().top-e.height(),t<=this.opts.loadMorePadding&&(i.addClass("select2-active"),this.opts.query({element:this.opts.element,term:n,page:s,context:o,matcher:this.opts.matcher,callback:this.bind(function(t){a.opened()&&(a.opts.populateResults.call(this,e,t.results,{term:n,page:s,context:o}),a.postprocessResults(t,!1,!1),t.more===!0?(i.detach().appendTo(e).text(a.opts.formatLoadMore(s+1)),window.setTimeout(function(){a.loadMoreIfNeeded()},10)):i.remove(),a.positionDropdown(),a.resultsPage=s,a.context=t.context,this.opts.element.trigger({type:"select2-loaded",items:t}))})})))},tokenize:function(){},updateResults:function(i){function s(){h.removeClass("select2-active"),u.positionDropdown()}function a(t){c.html(t),s()}var o,r,l,h=this.search,c=this.results,d=this.opts,u=this,p=h.val(),f=t.data(this.container,"select2-last-term");if((i===!0||!f||!n(p,f))&&(t.data(this.container,"select2-last-term",p),i===!0||this.showSearchInput!==!1&&this.opened())){l=++this.queryCount;var m=this.getMaximumSelectionSize();if(m>=1&&(o=this.data(),t.isArray(o)&&o.length>=m&&M(d.formatSelectionTooBig,"formatSelectionTooBig")))return a("<li class='select2-selection-limit'>"+d.formatSelectionTooBig(m)+"</li>"),void 0;if(h.val().length<d.minimumInputLength)return M(d.formatInputTooShort,"formatInputTooShort")?a("<li class='select2-no-results'>"+d.formatInputTooShort(h.val(),d.minimumInputLength)+"</li>"):a(""),i&&this.showSearch&&this.showSearch(!0),void 0;if(d.maximumInputLength&&h.val().length>d.maximumInputLength)return M(d.formatInputTooLong,"formatInputTooLong")?a("<li class='select2-no-results'>"+d.formatInputTooLong(h.val(),d.maximumInputLength)+"</li>"):a(""),void 0;d.formatSearching&&0===this.findHighlightableChoices().length&&a("<li class='select2-searching'>"+d.formatSearching()+"</li>"),h.addClass("select2-active"),this.removeHighlight(),r=this.tokenize(),r!=e&&null!=r&&h.val(r),this.resultsPage=1,d.query({element:d.element,term:h.val(),page:this.resultsPage,context:null,matcher:d.matcher,callback:this.bind(function(o){var r;if(l==this.queryCount){if(!this.opened())return this.search.removeClass("select2-active"),void 0;if(this.context=o.context===e?null:o.context,this.opts.createSearchChoice&&""!==h.val()&&(r=this.opts.createSearchChoice.call(u,h.val(),o.results),r!==e&&null!==r&&u.id(r)!==e&&null!==u.id(r)&&0===t(o.results).filter(function(){return n(u.id(this),u.id(r))}).length&&o.results.unshift(r)),0===o.results.length&&M(d.formatNoMatches,"formatNoMatches"))return a("<li class='select2-no-results'>"+d.formatNoMatches(h.val())+"</li>"),void 0;c.empty(),u.opts.populateResults.call(this,c,o.results,{term:h.val(),page:this.resultsPage,context:null}),o.more===!0&&M(d.formatLoadMore,"formatLoadMore")&&(c.append("<li class='select2-more-results'>"+u.opts.escapeMarkup(d.formatLoadMore(this.resultsPage))+"</li>"),window.setTimeout(function(){u.loadMoreIfNeeded()},10)),this.postprocessResults(o,i),s(),this.opts.element.trigger({type:"select2-loaded",items:o})}})})}},cancel:function(){this.close()},blur:function(){this.opts.selectOnBlur&&this.selectHighlighted({noFocus:!0}),this.close(),this.container.removeClass("select2-container-active"),this.search[0]===document.activeElement&&this.search.blur(),this.clearSearch(),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus")},focusSearch:function(){p(this.search)},selectHighlighted:function(t){var e=this.highlight(),i=this.results.find(".select2-highlighted"),s=i.closest(".select2-result").data("select2-data");s?(this.highlight(e),this.onSelect(s,t)):t&&t.noFocus&&this.close()},getPlaceholder:function(){var t;return this.opts.element.attr("placeholder")||this.opts.element.attr("data-placeholder")||this.opts.element.data("placeholder")||this.opts.placeholder||((t=this.getPlaceholderOption())!==e?t.text():e)},getPlaceholderOption:function(){if(this.select){var t=this.select.children().first();if(this.opts.placeholderOption!==e)return"first"===this.opts.placeholderOption&&t||"function"==typeof this.opts.placeholderOption&&this.opts.placeholderOption(this.select);if(""===t.text()&&""===t.val())return t}},initContainerWidth:function(){function i(){var i,s,a,n,o;if("off"===this.opts.width)return null;if("element"===this.opts.width)return 0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px";if("copy"===this.opts.width||"resolve"===this.opts.width){if(i=this.opts.element.attr("style"),i!==e)for(s=i.split(";"),n=0,o=s.length;o>n;n+=1)if(a=s[n].replace(/\s/g,"").match(/[^-]width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i),null!==a&&a.length>=1)return a[1];return"resolve"===this.opts.width?(i=this.opts.element.css("width"),i.indexOf("%")>0?i:0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px"):null}return t.isFunction(this.opts.width)?this.opts.width():this.opts.width}var s=i.call(this);null!==s&&this.container.css("width",s)}}),F=P(E,{createContainer:function(){var e=t(document.createElement("div")).attr({"class":"select2-container"}).html(["<a href='javascript:void(0)' onclick='return false;' class='select2-choice' tabindex='-1'>"," <span class='select2-chosen'> </span><abbr class='select2-search-choice-close'></abbr>"," <span class='select2-arrow'><b></b></span>","</a>","<input class='select2-focusser select2-offscreen' type='text'/>","<div class='select2-drop select2-display-none'>"," <div class='select2-search'>"," <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input'/>"," </div>"," <ul class='select2-results'>"," </ul>","</div>"].join("")); return e},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.focusser.prop("disabled",!this.isInterfaceEnabled())},opening:function(){var i,s,a;this.opts.minimumResultsForSearch>=0&&this.showSearch(!0),this.parent.opening.apply(this,arguments),this.showSearchInput!==!1&&this.search.val(this.focusser.val()),this.search.focus(),i=this.search.get(0),i.createTextRange?(s=i.createTextRange(),s.collapse(!1),s.select()):i.setSelectionRange&&(a=this.search.val().length,i.setSelectionRange(a,a)),""===this.search.val()&&this.nextSearchTerm!=e&&(this.search.val(this.nextSearchTerm),this.search.select()),this.focusser.prop("disabled",!0).val(""),this.updateResults(!0),this.opts.element.trigger(t.Event("select2-open"))},close:function(t){this.opened()&&(this.parent.close.apply(this,arguments),t=t||{focus:!0},this.focusser.removeAttr("disabled"),t.focus&&this.focusser.focus())},focus:function(){this.opened()?this.close():(this.focusser.removeAttr("disabled"),this.focusser.focus())},isFocused:function(){return this.container.hasClass("select2-container-active")},cancel:function(){this.parent.cancel.apply(this,arguments),this.focusser.removeAttr("disabled"),this.focusser.focus()},destroy:function(){t("label[for='"+this.focusser.attr("id")+"']").attr("for",this.opts.element.attr("id")),this.parent.destroy.apply(this,arguments)},initContainer:function(){var e,i=this.container,s=this.dropdown;this.opts.minimumResultsForSearch<0?this.showSearch(!1):this.showSearch(!0),this.selection=e=i.find(".select2-choice"),this.focusser=i.find(".select2-focusser"),this.focusser.attr("id","s2id_autogen"+O()),t("label[for='"+this.opts.element.attr("id")+"']").attr("for",this.focusser.attr("id")),this.focusser.attr("tabindex",this.elementTabIndex),this.search.on("keydown",this.bind(function(t){if(this.isInterfaceEnabled()){if(t.which===A.PAGE_UP||t.which===A.PAGE_DOWN)return m(t),void 0;switch(t.which){case A.UP:case A.DOWN:return this.moveHighlight(t.which===A.UP?-1:1),m(t),void 0;case A.ENTER:return this.selectHighlighted(),m(t),void 0;case A.TAB:return this.selectHighlighted({noFocus:!0}),void 0;case A.ESC:return this.cancel(t),m(t),void 0}}})),this.search.on("blur",this.bind(function(){document.activeElement===this.body().get(0)&&window.setTimeout(this.bind(function(){this.search.focus()}),0)})),this.focusser.on("keydown",this.bind(function(t){if(this.isInterfaceEnabled()&&t.which!==A.TAB&&!A.isControl(t)&&!A.isFunctionKey(t)&&t.which!==A.ESC){if(this.opts.openOnEnter===!1&&t.which===A.ENTER)return m(t),void 0;if(t.which==A.DOWN||t.which==A.UP||t.which==A.ENTER&&this.opts.openOnEnter){if(t.altKey||t.ctrlKey||t.shiftKey||t.metaKey)return;return this.open(),m(t),void 0}return t.which==A.DELETE||t.which==A.BACKSPACE?(this.opts.allowClear&&this.clear(),m(t),void 0):void 0}})),l(this.focusser),this.focusser.on("keyup-change input",this.bind(function(t){if(this.opts.minimumResultsForSearch>=0){if(t.stopPropagation(),this.opened())return;this.open()}})),e.on("mousedown","abbr",this.bind(function(t){this.isInterfaceEnabled()&&(this.clear(),g(t),this.close(),this.selection.focus())})),e.on("mousedown",this.bind(function(e){this.container.hasClass("select2-container-active")||this.opts.element.trigger(t.Event("select2-focus")),this.opened()?this.close():this.isInterfaceEnabled()&&this.open(),m(e)})),s.on("mousedown",this.bind(function(){this.search.focus()})),e.on("focus",this.bind(function(t){m(t)})),this.focusser.on("focus",this.bind(function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger(t.Event("select2-focus")),this.container.addClass("select2-container-active")})).on("blur",this.bind(function(){this.opened()||(this.container.removeClass("select2-container-active"),this.opts.element.trigger(t.Event("select2-blur")))})),this.search.on("focus",this.bind(function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger(t.Event("select2-focus")),this.container.addClass("select2-container-active")})),this.initContainerWidth(),this.opts.element.addClass("select2-offscreen"),this.setPlaceholder()},clear:function(e){var i=this.selection.data("select2-data");if(i){var s=t.Event("select2-clearing");if(this.opts.element.trigger(s),s.isDefaultPrevented())return;var a=this.getPlaceholderOption();this.opts.element.val(a?a.val():""),this.selection.find(".select2-chosen").empty(),this.selection.removeData("select2-data"),this.setPlaceholder(),e!==!1&&(this.opts.element.trigger({type:"select2-removed",val:this.id(i),choice:i}),this.triggerChange({removed:i}))}},initSelection:function(){if(this.isPlaceholderOptionSelected())this.updateSelection(null),this.close(),this.setPlaceholder();else{var t=this;this.opts.initSelection.call(null,this.opts.element,function(i){i!==e&&null!==i&&(t.updateSelection(i),t.close(),t.setPlaceholder())})}},isPlaceholderOptionSelected:function(){var t;return this.getPlaceholder()?(t=this.getPlaceholderOption())!==e&&t.is(":selected")||""===this.opts.element.val()||this.opts.element.val()===e||null===this.opts.element.val():!1},prepareOpts:function(){var e=this.parent.prepareOpts.apply(this,arguments),i=this;return"select"===e.element.get(0).tagName.toLowerCase()?e.initSelection=function(t,e){var s=t.find(":selected");e(i.optionToData(s))}:"data"in e&&(e.initSelection=e.initSelection||function(i,s){var a=i.val(),o=null;e.query({matcher:function(t,i,s){var r=n(a,e.id(s));return r&&(o=s),r},callback:t.isFunction(s)?function(){s(o)}:t.noop})}),e},getPlaceholder:function(){return this.select&&this.getPlaceholderOption()===e?e:this.parent.getPlaceholder.apply(this,arguments)},setPlaceholder:function(){var t=this.getPlaceholder();if(this.isPlaceholderOptionSelected()&&t!==e){if(this.select&&this.getPlaceholderOption()===e)return;this.selection.find(".select2-chosen").html(this.opts.escapeMarkup(t)),this.selection.addClass("select2-default"),this.container.removeClass("select2-allowclear")}},postprocessResults:function(t,e,i){var s=0,a=this;if(this.findHighlightableChoices().each2(function(t,e){return n(a.id(e.data("select2-data")),a.opts.element.val())?(s=t,!1):void 0}),i!==!1&&(e===!0&&s>=0?this.highlight(s):this.highlight(0)),e===!0){var o=this.opts.minimumResultsForSearch;o>=0&&this.showSearch(T(t.results)>=o)}},showSearch:function(e){this.showSearchInput!==e&&(this.showSearchInput=e,this.dropdown.find(".select2-search").toggleClass("select2-search-hidden",!e),this.dropdown.find(".select2-search").toggleClass("select2-offscreen",!e),t(this.dropdown,this.container).toggleClass("select2-with-searchbox",e))},onSelect:function(t,e){if(this.triggerSelect(t)){var i=this.opts.element.val(),s=this.data();this.opts.element.val(this.id(t)),this.updateSelection(t),this.opts.element.trigger({type:"select2-selected",val:this.id(t),choice:t}),this.nextSearchTerm=this.opts.nextSearchTerm(t,this.search.val()),this.close(),e&&e.noFocus||this.focusser.focus(),n(i,this.id(t))||this.triggerChange({added:t,removed:s})}},updateSelection:function(t){var i,s,a=this.selection.find(".select2-chosen");this.selection.data("select2-data",t),a.empty(),null!==t&&(i=this.opts.formatSelection(t,a,this.opts.escapeMarkup)),i!==e&&a.append(i),s=this.opts.formatSelectionCssClass(t,a),s!==e&&a.addClass(s),this.selection.removeClass("select2-default"),this.opts.allowClear&&this.getPlaceholder()!==e&&this.container.addClass("select2-allowclear")},val:function(){var t,i=!1,s=null,a=this,n=this.data();if(0===arguments.length)return this.opts.element.val();if(t=arguments[0],arguments.length>1&&(i=arguments[1]),this.select)this.select.val(t).find(":selected").each2(function(t,e){return s=a.optionToData(e),!1}),this.updateSelection(s),this.setPlaceholder(),i&&this.triggerChange({added:s,removed:n});else{if(!t&&0!==t)return this.clear(i),void 0;if(this.opts.initSelection===e)throw new Error("cannot call val() if initSelection() is not defined");this.opts.element.val(t),this.opts.initSelection(this.opts.element,function(t){a.opts.element.val(t?a.id(t):""),a.updateSelection(t),a.setPlaceholder(),i&&a.triggerChange({added:t,removed:n})})}},clearSearch:function(){this.search.val(""),this.focusser.val("")},data:function(t){var i,s=!1;return 0===arguments.length?(i=this.selection.data("select2-data"),i==e&&(i=null),i):(arguments.length>1&&(s=arguments[1]),t?(i=this.data(),this.opts.element.val(t?this.id(t):""),this.updateSelection(t),s&&this.triggerChange({added:t,removed:i})):this.clear(s),void 0)}}),L=P(E,{createContainer:function(){var e=t(document.createElement("div")).attr({"class":"select2-container select2-container-multi"}).html(["<ul class='select2-choices'>"," <li class='select2-search-field'>"," <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input'>"," </li>","</ul>","<div class='select2-drop select2-drop-multi select2-display-none'>"," <ul class='select2-results'>"," </ul>","</div>"].join(""));return e},prepareOpts:function(){var e=this.parent.prepareOpts.apply(this,arguments),i=this;return"select"===e.element.get(0).tagName.toLowerCase()?e.initSelection=function(t,e){var s=[];t.find(":selected").each2(function(t,e){s.push(i.optionToData(e))}),e(s)}:"data"in e&&(e.initSelection=e.initSelection||function(i,s){var a=o(i.val(),e.separator),r=[];e.query({matcher:function(i,s,o){var l=t.grep(a,function(t){return n(t,e.id(o))}).length;return l&&r.push(o),l},callback:t.isFunction(s)?function(){for(var t=[],i=0;i<a.length;i++)for(var o=a[i],l=0;l<r.length;l++){var h=r[l];if(n(o,e.id(h))){t.push(h),r.splice(l,1);break}}s(t)}:t.noop})}),e},selectChoice:function(t){var e=this.container.find(".select2-search-choice-focus");e.length&&t&&t[0]==e[0]||(e.length&&this.opts.element.trigger("choice-deselected",e),e.removeClass("select2-search-choice-focus"),t&&t.length&&(this.close(),t.addClass("select2-search-choice-focus"),this.opts.element.trigger("choice-selected",t)))},destroy:function(){t("label[for='"+this.search.attr("id")+"']").attr("for",this.opts.element.attr("id")),this.parent.destroy.apply(this,arguments)},initContainer:function(){var e,i=".select2-choices";this.searchContainer=this.container.find(".select2-search-field"),this.selection=e=this.container.find(i);var s=this;this.selection.on("click",".select2-search-choice:not(.select2-locked)",function(){s.search[0].focus(),s.selectChoice(t(this))}),this.search.attr("id","s2id_autogen"+O()),t("label[for='"+this.opts.element.attr("id")+"']").attr("for",this.search.attr("id")),this.search.on("input paste",this.bind(function(){this.isInterfaceEnabled()&&(this.opened()||this.open())})),this.search.attr("tabindex",this.elementTabIndex),this.keydowns=0,this.search.on("keydown",this.bind(function(t){if(this.isInterfaceEnabled()){++this.keydowns;var i=e.find(".select2-search-choice-focus"),s=i.prev(".select2-search-choice:not(.select2-locked)"),a=i.next(".select2-search-choice:not(.select2-locked)"),n=f(this.search);if(i.length&&(t.which==A.LEFT||t.which==A.RIGHT||t.which==A.BACKSPACE||t.which==A.DELETE||t.which==A.ENTER)){var o=i;return t.which==A.LEFT&&s.length?o=s:t.which==A.RIGHT?o=a.length?a:null:t.which===A.BACKSPACE?(this.unselect(i.first()),this.search.width(10),o=s.length?s:a):t.which==A.DELETE?(this.unselect(i.first()),this.search.width(10),o=a.length?a:null):t.which==A.ENTER&&(o=null),this.selectChoice(o),m(t),o&&o.length||this.open(),void 0}if((t.which===A.BACKSPACE&&1==this.keydowns||t.which==A.LEFT)&&0==n.offset&&!n.length)return this.selectChoice(e.find(".select2-search-choice:not(.select2-locked)").last()),m(t),void 0;if(this.selectChoice(null),this.opened())switch(t.which){case A.UP:case A.DOWN:return this.moveHighlight(t.which===A.UP?-1:1),m(t),void 0;case A.ENTER:return this.selectHighlighted(),m(t),void 0;case A.TAB:return this.selectHighlighted({noFocus:!0}),this.close(),void 0;case A.ESC:return this.cancel(t),m(t),void 0}if(t.which!==A.TAB&&!A.isControl(t)&&!A.isFunctionKey(t)&&t.which!==A.BACKSPACE&&t.which!==A.ESC){if(t.which===A.ENTER){if(this.opts.openOnEnter===!1)return;if(t.altKey||t.ctrlKey||t.shiftKey||t.metaKey)return}this.open(),(t.which===A.PAGE_UP||t.which===A.PAGE_DOWN)&&m(t),t.which===A.ENTER&&m(t)}}})),this.search.on("keyup",this.bind(function(){this.keydowns=0,this.resizeSearch()})),this.search.on("blur",this.bind(function(e){this.container.removeClass("select2-container-active"),this.search.removeClass("select2-focused"),this.selectChoice(null),this.opened()||this.clearSearch(),e.stopImmediatePropagation(),this.opts.element.trigger(t.Event("select2-blur"))})),this.container.on("click",i,this.bind(function(e){this.isInterfaceEnabled()&&(t(e.target).closest(".select2-search-choice").length>0||(this.selectChoice(null),this.clearPlaceholder(),this.container.hasClass("select2-container-active")||this.opts.element.trigger(t.Event("select2-focus")),this.open(),this.focusSearch(),e.preventDefault()))})),this.container.on("focus",i,this.bind(function(){this.isInterfaceEnabled()&&(this.container.hasClass("select2-container-active")||this.opts.element.trigger(t.Event("select2-focus")),this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"),this.clearPlaceholder())})),this.initContainerWidth(),this.opts.element.addClass("select2-offscreen"),this.clearSearch()},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.search.prop("disabled",!this.isInterfaceEnabled())},initSelection:function(){if(""===this.opts.element.val()&&""===this.opts.element.text()&&(this.updateSelection([]),this.close(),this.clearSearch()),this.select||""!==this.opts.element.val()){var t=this;this.opts.initSelection.call(null,this.opts.element,function(i){i!==e&&null!==i&&(t.updateSelection(i),t.close(),t.clearSearch())})}},clearSearch:function(){var t=this.getPlaceholder(),i=this.getMaxSearchWidth();t!==e&&0===this.getVal().length&&this.search.hasClass("select2-focused")===!1?(this.search.val(t).addClass("select2-default"),this.search.width(i>0?i:this.container.css("width"))):this.search.val("").width(10)},clearPlaceholder:function(){this.search.hasClass("select2-default")&&this.search.val("").removeClass("select2-default")},opening:function(){this.clearPlaceholder(),this.resizeSearch(),this.parent.opening.apply(this,arguments),this.focusSearch(),this.updateResults(!0),this.search.focus(),this.opts.element.trigger(t.Event("select2-open"))},close:function(){this.opened()&&this.parent.close.apply(this,arguments)},focus:function(){this.close(),this.search.focus()},isFocused:function(){return this.search.hasClass("select2-focused")},updateSelection:function(e){var i=[],a=[],n=this;t(e).each(function(){s(n.id(this),i)<0&&(i.push(n.id(this)),a.push(this))}),e=a,this.selection.find(".select2-search-choice").remove(),t(e).each(function(){n.addSelectedChoice(this)}),n.postprocessResults()},tokenize:function(){var t=this.search.val();t=this.opts.tokenizer.call(this,t,this.data(),this.bind(this.onSelect),this.opts),null!=t&&t!=e&&(this.search.val(t),t.length>0&&this.open())},onSelect:function(t,e){this.triggerSelect(t)&&(this.addSelectedChoice(t),this.opts.element.trigger({type:"selected",val:this.id(t),choice:t}),(this.select||!this.opts.closeOnSelect)&&this.postprocessResults(t,!1,this.opts.closeOnSelect===!0),this.opts.closeOnSelect?(this.close(),this.search.width(10)):this.countSelectableResults()>0?(this.search.width(10),this.resizeSearch(),this.getMaximumSelectionSize()>0&&this.val().length>=this.getMaximumSelectionSize()&&this.updateResults(!0),this.positionDropdown()):(this.close(),this.search.width(10)),this.triggerChange({added:t}),e&&e.noFocus||this.focusSearch())},cancel:function(){this.close(),this.focusSearch()},addSelectedChoice:function(i){var s,a,n=!i.locked,o=t("<li class='select2-search-choice'> <div></div> <a href='#' onclick='return false;' class='select2-search-choice-close' tabindex='-1'></a></li>"),r=t("<li class='select2-search-choice select2-locked'><div></div></li>"),l=n?o:r,h=this.id(i),c=this.getVal();s=this.opts.formatSelection(i,l.find("div"),this.opts.escapeMarkup),s!=e&&l.find("div").replaceWith("<div>"+s+"</div>"),a=this.opts.formatSelectionCssClass(i,l.find("div")),a!=e&&l.addClass(a),n&&l.find(".select2-search-choice-close").on("mousedown",m).on("click dblclick",this.bind(function(e){this.isInterfaceEnabled()&&(t(e.target).closest(".select2-search-choice").fadeOut("fast",this.bind(function(){this.unselect(t(e.target)),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus"),this.close(),this.focusSearch()})).dequeue(),m(e))})).on("focus",this.bind(function(){this.isInterfaceEnabled()&&(this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"))})),l.data("select2-data",i),l.insertBefore(this.searchContainer),c.push(h),this.setVal(c)},unselect:function(t){var e,i,a=this.getVal();if(t=t.closest(".select2-search-choice"),0===t.length)throw"Invalid argument: "+t+". Must be .select2-search-choice";if(e=t.data("select2-data")){for(;(i=s(this.id(e),a))>=0;)a.splice(i,1),this.setVal(a),this.select&&this.postprocessResults();t.remove(),this.opts.element.trigger({type:"removed",val:this.id(e),choice:e}),this.triggerChange({removed:e})}},postprocessResults:function(t,e,i){var a=this.getVal(),n=this.results.find(".select2-result"),o=this.results.find(".select2-result-with-children"),r=this;n.each2(function(t,e){var i=r.id(e.data("select2-data"));s(i,a)>=0&&(e.addClass("select2-selected"),e.find(".select2-result-selectable").addClass("select2-selected"))}),o.each2(function(t,e){e.is(".select2-result-selectable")||0!==e.find(".select2-result-selectable:not(.select2-selected)").length||e.addClass("select2-selected")}),-1==this.highlight()&&i!==!1&&r.highlight(0),!this.opts.createSearchChoice&&!n.filter(".select2-result:not(.select2-selected)").length>0&&(!t||t&&!t.more&&0===this.results.find(".select2-no-results").length)&&M(r.opts.formatNoMatches,"formatNoMatches")&&this.results.append("<li class='select2-no-results'>"+r.opts.formatNoMatches(r.search.val())+"</li>")},getMaxSearchWidth:function(){return this.selection.width()-r(this.search)},resizeSearch:function(){var t,e,i,s,a,n=r(this.search);t=v(this.search)+10,e=this.search.offset().left,i=this.selection.width(),s=this.selection.offset().left,a=i-(e-s)-n,t>a&&(a=i-n),40>a&&(a=i-n),0>=a&&(a=t),this.search.width(Math.floor(a))},getVal:function(){var t;return this.select?(t=this.select.val(),null===t?[]:t):(t=this.opts.element.val(),o(t,this.opts.separator))},setVal:function(e){var i;this.select?this.select.val(e):(i=[],t(e).each(function(){s(this,i)<0&&i.push(this)}),this.opts.element.val(0===i.length?"":i.join(this.opts.separator)))},buildChangeDetails:function(t,e){for(var e=e.slice(0),t=t.slice(0),i=0;i<e.length;i++)for(var s=0;s<t.length;s++)n(this.opts.id(e[i]),this.opts.id(t[s]))&&(e.splice(i,1),i--,t.splice(s,1),s--);return{added:e,removed:t}},val:function(i,s){var a,n=this;if(0===arguments.length)return this.getVal();if(a=this.data(),a.length||(a=[]),!i&&0!==i)return this.opts.element.val(""),this.updateSelection([]),this.clearSearch(),s&&this.triggerChange({added:this.data(),removed:a}),void 0;if(this.setVal(i),this.select)this.opts.initSelection(this.select,this.bind(this.updateSelection)),s&&this.triggerChange(this.buildChangeDetails(a,this.data()));else{if(this.opts.initSelection===e)throw new Error("val() cannot be called if initSelection() is not defined");this.opts.initSelection(this.opts.element,function(e){var i=t.map(e,n.id);n.setVal(i),n.updateSelection(e),n.clearSearch(),s&&n.triggerChange(n.buildChangeDetails(a,this.data()))})}this.clearSearch()},onSortStart:function(){if(this.select)throw new Error("Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead.");this.search.width(0),this.searchContainer.hide()},onSortEnd:function(){var e=[],i=this;this.searchContainer.show(),this.searchContainer.appendTo(this.searchContainer.parent()),this.resizeSearch(),this.selection.find(".select2-search-choice").each(function(){e.push(i.opts.id(t(this).data("select2-data")))}),this.setVal(e),this.triggerChange()},data:function(e,i){var s,a,n=this;return 0===arguments.length?this.selection.find(".select2-search-choice").map(function(){return t(this).data("select2-data")}).get():(a=this.data(),e||(e=[]),s=t.map(e,function(t){return n.opts.id(t)}),this.setVal(s),this.updateSelection(e),this.clearSearch(),i&&this.triggerChange(this.buildChangeDetails(a,this.data())),void 0)}}),t.fn.select2=function(){var i,a,n,o,r,l=Array.prototype.slice.call(arguments,0),h=["val","destroy","opened","open","close","focus","isFocused","container","dropdown","onSortStart","onSortEnd","enable","disable","readonly","positionDropdown","data","search"],c=["opened","isFocused","container","dropdown"],d=["val","data"],u={search:"externalSearch"};return this.each(function(){if(0===l.length||"object"==typeof l[0])i=0===l.length?{}:t.extend({},l[0]),i.element=t(this),"select"===i.element.get(0).tagName.toLowerCase()?r=i.element.prop("multiple"):(r=i.multiple||!1,"tags"in i&&(i.multiple=r=!0)),a=r?new L:new F,a.init(i);else{if("string"!=typeof l[0])throw"Invalid arguments to select2 plugin: "+l;if(s(l[0],h)<0)throw"Unknown method: "+l[0];if(o=e,a=t(this).data("select2"),a===e)return;if(n=l[0],"container"===n?o=a.container:"dropdown"===n?o=a.dropdown:(u[n]&&(n=u[n]),o=a[n].apply(a,l.slice(1))),s(l[0],c)>=0||s(l[0],d)&&1==l.length)return!1}}),o===e?this:o},t.fn.select2.defaults={width:"copy",loadMorePadding:0,closeOnSelect:!0,openOnEnter:!0,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(t,e,i,s){var a=[];return b(t.text,i.term,a,s),a.join("")},formatSelection:function(t,i,s){return t?s(t.text):e},sortResults:function(t){return t},formatResultCssClass:function(){return e},formatSelectionCssClass:function(){return e},formatNoMatches:function(){return"No matches found"},formatInputTooShort:function(t,e){var i=e-t.length;return"Please enter "+i+" more character"+(1==i?"":"s")},formatInputTooLong:function(t,e){var i=t.length-e;return"Please delete "+i+" character"+(1==i?"":"s")},formatSelectionTooBig:function(t){return"You can only select "+t+" item"+(1==t?"":"s")},formatLoadMore:function(){return"Loading more results..."},formatSearching:function(){return"Searching..."},minimumResultsForSearch:0,minimumInputLength:0,maximumInputLength:null,maximumSelectionSize:0,id:function(t){return t.id},matcher:function(t,e){return i(""+e).toUpperCase().indexOf(i(""+t).toUpperCase())>=0},separator:",",tokenSeparators:[],tokenizer:x,escapeMarkup:S,blurOnChange:!1,selectOnBlur:!1,adaptContainerCssClass:function(t){return t},adaptDropdownCssClass:function(){return null},nextSearchTerm:function(){return e}},t.fn.select2.ajaxDefaults={transport:t.ajax,params:{type:"GET",cache:!1,dataType:"json"}},window.Select2={query:{ajax:w,local:k,tags:C},util:{debounce:c,markMatch:b,escapeMarkup:S,stripDiacritics:i},"class":{"abstract":E,single:F,multi:L}}}}(jQuery);