%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/985914/root/data/old/home/stash/stash-home/tmp/webresources/
Upload File :
Create Path :
Current File : //proc/985914/root/data/old/home/stash/stash-home/tmp/webresources/27.cachedfile

;/* module-key = 'com.atlassian.auiplugin:aui-select2', location = 'js-vendor/jquery/plugins/jquery.select2.js' */
(function(A){if(typeof A.fn.each2=="undefined"){A.extend(A.fn,{each2:function(E){var C=A([0]),D=-1,B=this.length;while(++D<B&&(C.context=C[0]=this[D])&&E.call(C[0],D,C)!==false){}return this}})}})(jQuery);(function(d,M){if(window.Select2!==M){return }var k,n,X,C,A,P,O={x:0,y:0},V,W,k={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(o){o=o.which?o.which:o;switch(o){case k.LEFT:case k.RIGHT:case k.UP:case k.DOWN:return true}return false},isControl:function(p){var o=p.which;switch(o){case k.SHIFT:case k.CTRL:case k.ALT:return true}if(p.metaKey){return true}return false},isFunctionKey:function(o){o=o.which?o.which:o;return o>=112&&o<=123}},b="<div class='select2-measure-scrollbar'></div>",D={"\u24B6":"A","\uFF21":"A","\u00C0":"A","\u00C1":"A","\u00C2":"A","\u1EA6":"A","\u1EA4":"A","\u1EAA":"A","\u1EA8":"A","\u00C3":"A","\u0100":"A","\u0102":"A","\u1EB0":"A","\u1EAE":"A","\u1EB4":"A","\u1EB2":"A","\u0226":"A","\u01E0":"A","\u00C4":"A","\u01DE":"A","\u1EA2":"A","\u00C5":"A","\u01FA":"A","\u01CD":"A","\u0200":"A","\u0202":"A","\u1EA0":"A","\u1EAC":"A","\u1EB6":"A","\u1E00":"A","\u0104":"A","\u023A":"A","\u2C6F":"A","\uA732":"AA","\u00C6":"AE","\u01FC":"AE","\u01E2":"AE","\uA734":"AO","\uA736":"AU","\uA738":"AV","\uA73A":"AV","\uA73C":"AY","\u24B7":"B","\uFF22":"B","\u1E02":"B","\u1E04":"B","\u1E06":"B","\u0243":"B","\u0182":"B","\u0181":"B","\u24B8":"C","\uFF23":"C","\u0106":"C","\u0108":"C","\u010A":"C","\u010C":"C","\u00C7":"C","\u1E08":"C","\u0187":"C","\u023B":"C","\uA73E":"C","\u24B9":"D","\uFF24":"D","\u1E0A":"D","\u010E":"D","\u1E0C":"D","\u1E10":"D","\u1E12":"D","\u1E0E":"D","\u0110":"D","\u018B":"D","\u018A":"D","\u0189":"D","\uA779":"D","\u01F1":"DZ","\u01C4":"DZ","\u01F2":"Dz","\u01C5":"Dz","\u24BA":"E","\uFF25":"E","\u00C8":"E","\u00C9":"E","\u00CA":"E","\u1EC0":"E","\u1EBE":"E","\u1EC4":"E","\u1EC2":"E","\u1EBC":"E","\u0112":"E","\u1E14":"E","\u1E16":"E","\u0114":"E","\u0116":"E","\u00CB":"E","\u1EBA":"E","\u011A":"E","\u0204":"E","\u0206":"E","\u1EB8":"E","\u1EC6":"E","\u0228":"E","\u1E1C":"E","\u0118":"E","\u1E18":"E","\u1E1A":"E","\u0190":"E","\u018E":"E","\u24BB":"F","\uFF26":"F","\u1E1E":"F","\u0191":"F","\uA77B":"F","\u24BC":"G","\uFF27":"G","\u01F4":"G","\u011C":"G","\u1E20":"G","\u011E":"G","\u0120":"G","\u01E6":"G","\u0122":"G","\u01E4":"G","\u0193":"G","\uA7A0":"G","\uA77D":"G","\uA77E":"G","\u24BD":"H","\uFF28":"H","\u0124":"H","\u1E22":"H","\u1E26":"H","\u021E":"H","\u1E24":"H","\u1E28":"H","\u1E2A":"H","\u0126":"H","\u2C67":"H","\u2C75":"H","\uA78D":"H","\u24BE":"I","\uFF29":"I","\u00CC":"I","\u00CD":"I","\u00CE":"I","\u0128":"I","\u012A":"I","\u012C":"I","\u0130":"I","\u00CF":"I","\u1E2E":"I","\u1EC8":"I","\u01CF":"I","\u0208":"I","\u020A":"I","\u1ECA":"I","\u012E":"I","\u1E2C":"I","\u0197":"I","\u24BF":"J","\uFF2A":"J","\u0134":"J","\u0248":"J","\u24C0":"K","\uFF2B":"K","\u1E30":"K","\u01E8":"K","\u1E32":"K","\u0136":"K","\u1E34":"K","\u0198":"K","\u2C69":"K","\uA740":"K","\uA742":"K","\uA744":"K","\uA7A2":"K","\u24C1":"L","\uFF2C":"L","\u013F":"L","\u0139":"L","\u013D":"L","\u1E36":"L","\u1E38":"L","\u013B":"L","\u1E3C":"L","\u1E3A":"L","\u0141":"L","\u023D":"L","\u2C62":"L","\u2C60":"L","\uA748":"L","\uA746":"L","\uA780":"L","\u01C7":"LJ","\u01C8":"Lj","\u24C2":"M","\uFF2D":"M","\u1E3E":"M","\u1E40":"M","\u1E42":"M","\u2C6E":"M","\u019C":"M","\u24C3":"N","\uFF2E":"N","\u01F8":"N","\u0143":"N","\u00D1":"N","\u1E44":"N","\u0147":"N","\u1E46":"N","\u0145":"N","\u1E4A":"N","\u1E48":"N","\u0220":"N","\u019D":"N","\uA790":"N","\uA7A4":"N","\u01CA":"NJ","\u01CB":"Nj","\u24C4":"O","\uFF2F":"O","\u00D2":"O","\u00D3":"O","\u00D4":"O","\u1ED2":"O","\u1ED0":"O","\u1ED6":"O","\u1ED4":"O","\u00D5":"O","\u1E4C":"O","\u022C":"O","\u1E4E":"O","\u014C":"O","\u1E50":"O","\u1E52":"O","\u014E":"O","\u022E":"O","\u0230":"O","\u00D6":"O","\u022A":"O","\u1ECE":"O","\u0150":"O","\u01D1":"O","\u020C":"O","\u020E":"O","\u01A0":"O","\u1EDC":"O","\u1EDA":"O","\u1EE0":"O","\u1EDE":"O","\u1EE2":"O","\u1ECC":"O","\u1ED8":"O","\u01EA":"O","\u01EC":"O","\u00D8":"O","\u01FE":"O","\u0186":"O","\u019F":"O","\uA74A":"O","\uA74C":"O","\u01A2":"OI","\uA74E":"OO","\u0222":"OU","\u24C5":"P","\uFF30":"P","\u1E54":"P","\u1E56":"P","\u01A4":"P","\u2C63":"P","\uA750":"P","\uA752":"P","\uA754":"P","\u24C6":"Q","\uFF31":"Q","\uA756":"Q","\uA758":"Q","\u024A":"Q","\u24C7":"R","\uFF32":"R","\u0154":"R","\u1E58":"R","\u0158":"R","\u0210":"R","\u0212":"R","\u1E5A":"R","\u1E5C":"R","\u0156":"R","\u1E5E":"R","\u024C":"R","\u2C64":"R","\uA75A":"R","\uA7A6":"R","\uA782":"R","\u24C8":"S","\uFF33":"S","\u1E9E":"S","\u015A":"S","\u1E64":"S","\u015C":"S","\u1E60":"S","\u0160":"S","\u1E66":"S","\u1E62":"S","\u1E68":"S","\u0218":"S","\u015E":"S","\u2C7E":"S","\uA7A8":"S","\uA784":"S","\u24C9":"T","\uFF34":"T","\u1E6A":"T","\u0164":"T","\u1E6C":"T","\u021A":"T","\u0162":"T","\u1E70":"T","\u1E6E":"T","\u0166":"T","\u01AC":"T","\u01AE":"T","\u023E":"T","\uA786":"T","\uA728":"TZ","\u24CA":"U","\uFF35":"U","\u00D9":"U","\u00DA":"U","\u00DB":"U","\u0168":"U","\u1E78":"U","\u016A":"U","\u1E7A":"U","\u016C":"U","\u00DC":"U","\u01DB":"U","\u01D7":"U","\u01D5":"U","\u01D9":"U","\u1EE6":"U","\u016E":"U","\u0170":"U","\u01D3":"U","\u0214":"U","\u0216":"U","\u01AF":"U","\u1EEA":"U","\u1EE8":"U","\u1EEE":"U","\u1EEC":"U","\u1EF0":"U","\u1EE4":"U","\u1E72":"U","\u0172":"U","\u1E76":"U","\u1E74":"U","\u0244":"U","\u24CB":"V","\uFF36":"V","\u1E7C":"V","\u1E7E":"V","\u01B2":"V","\uA75E":"V","\u0245":"V","\uA760":"VY","\u24CC":"W","\uFF37":"W","\u1E80":"W","\u1E82":"W","\u0174":"W","\u1E86":"W","\u1E84":"W","\u1E88":"W","\u2C72":"W","\u24CD":"X","\uFF38":"X","\u1E8A":"X","\u1E8C":"X","\u24CE":"Y","\uFF39":"Y","\u1EF2":"Y","\u00DD":"Y","\u0176":"Y","\u1EF8":"Y","\u0232":"Y","\u1E8E":"Y","\u0178":"Y","\u1EF6":"Y","\u1EF4":"Y","\u01B3":"Y","\u024E":"Y","\u1EFE":"Y","\u24CF":"Z","\uFF3A":"Z","\u0179":"Z","\u1E90":"Z","\u017B":"Z","\u017D":"Z","\u1E92":"Z","\u1E94":"Z","\u01B5":"Z","\u0224":"Z","\u2C7F":"Z","\u2C6B":"Z","\uA762":"Z","\u24D0":"a","\uFF41":"a","\u1E9A":"a","\u00E0":"a","\u00E1":"a","\u00E2":"a","\u1EA7":"a","\u1EA5":"a","\u1EAB":"a","\u1EA9":"a","\u00E3":"a","\u0101":"a","\u0103":"a","\u1EB1":"a","\u1EAF":"a","\u1EB5":"a","\u1EB3":"a","\u0227":"a","\u01E1":"a","\u00E4":"a","\u01DF":"a","\u1EA3":"a","\u00E5":"a","\u01FB":"a","\u01CE":"a","\u0201":"a","\u0203":"a","\u1EA1":"a","\u1EAD":"a","\u1EB7":"a","\u1E01":"a","\u0105":"a","\u2C65":"a","\u0250":"a","\uA733":"aa","\u00E6":"ae","\u01FD":"ae","\u01E3":"ae","\uA735":"ao","\uA737":"au","\uA739":"av","\uA73B":"av","\uA73D":"ay","\u24D1":"b","\uFF42":"b","\u1E03":"b","\u1E05":"b","\u1E07":"b","\u0180":"b","\u0183":"b","\u0253":"b","\u24D2":"c","\uFF43":"c","\u0107":"c","\u0109":"c","\u010B":"c","\u010D":"c","\u00E7":"c","\u1E09":"c","\u0188":"c","\u023C":"c","\uA73F":"c","\u2184":"c","\u24D3":"d","\uFF44":"d","\u1E0B":"d","\u010F":"d","\u1E0D":"d","\u1E11":"d","\u1E13":"d","\u1E0F":"d","\u0111":"d","\u018C":"d","\u0256":"d","\u0257":"d","\uA77A":"d","\u01F3":"dz","\u01C6":"dz","\u24D4":"e","\uFF45":"e","\u00E8":"e","\u00E9":"e","\u00EA":"e","\u1EC1":"e","\u1EBF":"e","\u1EC5":"e","\u1EC3":"e","\u1EBD":"e","\u0113":"e","\u1E15":"e","\u1E17":"e","\u0115":"e","\u0117":"e","\u00EB":"e","\u1EBB":"e","\u011B":"e","\u0205":"e","\u0207":"e","\u1EB9":"e","\u1EC7":"e","\u0229":"e","\u1E1D":"e","\u0119":"e","\u1E19":"e","\u1E1B":"e","\u0247":"e","\u025B":"e","\u01DD":"e","\u24D5":"f","\uFF46":"f","\u1E1F":"f","\u0192":"f","\uA77C":"f","\u24D6":"g","\uFF47":"g","\u01F5":"g","\u011D":"g","\u1E21":"g","\u011F":"g","\u0121":"g","\u01E7":"g","\u0123":"g","\u01E5":"g","\u0260":"g","\uA7A1":"g","\u1D79":"g","\uA77F":"g","\u24D7":"h","\uFF48":"h","\u0125":"h","\u1E23":"h","\u1E27":"h","\u021F":"h","\u1E25":"h","\u1E29":"h","\u1E2B":"h","\u1E96":"h","\u0127":"h","\u2C68":"h","\u2C76":"h","\u0265":"h","\u0195":"hv","\u24D8":"i","\uFF49":"i","\u00EC":"i","\u00ED":"i","\u00EE":"i","\u0129":"i","\u012B":"i","\u012D":"i","\u00EF":"i","\u1E2F":"i","\u1EC9":"i","\u01D0":"i","\u0209":"i","\u020B":"i","\u1ECB":"i","\u012F":"i","\u1E2D":"i","\u0268":"i","\u0131":"i","\u24D9":"j","\uFF4A":"j","\u0135":"j","\u01F0":"j","\u0249":"j","\u24DA":"k","\uFF4B":"k","\u1E31":"k","\u01E9":"k","\u1E33":"k","\u0137":"k","\u1E35":"k","\u0199":"k","\u2C6A":"k","\uA741":"k","\uA743":"k","\uA745":"k","\uA7A3":"k","\u24DB":"l","\uFF4C":"l","\u0140":"l","\u013A":"l","\u013E":"l","\u1E37":"l","\u1E39":"l","\u013C":"l","\u1E3D":"l","\u1E3B":"l","\u017F":"l","\u0142":"l","\u019A":"l","\u026B":"l","\u2C61":"l","\uA749":"l","\uA781":"l","\uA747":"l","\u01C9":"lj","\u24DC":"m","\uFF4D":"m","\u1E3F":"m","\u1E41":"m","\u1E43":"m","\u0271":"m","\u026F":"m","\u24DD":"n","\uFF4E":"n","\u01F9":"n","\u0144":"n","\u00F1":"n","\u1E45":"n","\u0148":"n","\u1E47":"n","\u0146":"n","\u1E4B":"n","\u1E49":"n","\u019E":"n","\u0272":"n","\u0149":"n","\uA791":"n","\uA7A5":"n","\u01CC":"nj","\u24DE":"o","\uFF4F":"o","\u00F2":"o","\u00F3":"o","\u00F4":"o","\u1ED3":"o","\u1ED1":"o","\u1ED7":"o","\u1ED5":"o","\u00F5":"o","\u1E4D":"o","\u022D":"o","\u1E4F":"o","\u014D":"o","\u1E51":"o","\u1E53":"o","\u014F":"o","\u022F":"o","\u0231":"o","\u00F6":"o","\u022B":"o","\u1ECF":"o","\u0151":"o","\u01D2":"o","\u020D":"o","\u020F":"o","\u01A1":"o","\u1EDD":"o","\u1EDB":"o","\u1EE1":"o","\u1EDF":"o","\u1EE3":"o","\u1ECD":"o","\u1ED9":"o","\u01EB":"o","\u01ED":"o","\u00F8":"o","\u01FF":"o","\u0254":"o","\uA74B":"o","\uA74D":"o","\u0275":"o","\u01A3":"oi","\u0223":"ou","\uA74F":"oo","\u24DF":"p","\uFF50":"p","\u1E55":"p","\u1E57":"p","\u01A5":"p","\u1D7D":"p","\uA751":"p","\uA753":"p","\uA755":"p","\u24E0":"q","\uFF51":"q","\u024B":"q","\uA757":"q","\uA759":"q","\u24E1":"r","\uFF52":"r","\u0155":"r","\u1E59":"r","\u0159":"r","\u0211":"r","\u0213":"r","\u1E5B":"r","\u1E5D":"r","\u0157":"r","\u1E5F":"r","\u024D":"r","\u027D":"r","\uA75B":"r","\uA7A7":"r","\uA783":"r","\u24E2":"s","\uFF53":"s","\u00DF":"s","\u015B":"s","\u1E65":"s","\u015D":"s","\u1E61":"s","\u0161":"s","\u1E67":"s","\u1E63":"s","\u1E69":"s","\u0219":"s","\u015F":"s","\u023F":"s","\uA7A9":"s","\uA785":"s","\u1E9B":"s","\u24E3":"t","\uFF54":"t","\u1E6B":"t","\u1E97":"t","\u0165":"t","\u1E6D":"t","\u021B":"t","\u0163":"t","\u1E71":"t","\u1E6F":"t","\u0167":"t","\u01AD":"t","\u0288":"t","\u2C66":"t","\uA787":"t","\uA729":"tz","\u24E4":"u","\uFF55":"u","\u00F9":"u","\u00FA":"u","\u00FB":"u","\u0169":"u","\u1E79":"u","\u016B":"u","\u1E7B":"u","\u016D":"u","\u00FC":"u","\u01DC":"u","\u01D8":"u","\u01D6":"u","\u01DA":"u","\u1EE7":"u","\u016F":"u","\u0171":"u","\u01D4":"u","\u0215":"u","\u0217":"u","\u01B0":"u","\u1EEB":"u","\u1EE9":"u","\u1EEF":"u","\u1EED":"u","\u1EF1":"u","\u1EE5":"u","\u1E73":"u","\u0173":"u","\u1E77":"u","\u1E75":"u","\u0289":"u","\u24E5":"v","\uFF56":"v","\u1E7D":"v","\u1E7F":"v","\u028B":"v","\uA75F":"v","\u028C":"v","\uA761":"vy","\u24E6":"w","\uFF57":"w","\u1E81":"w","\u1E83":"w","\u0175":"w","\u1E87":"w","\u1E85":"w","\u1E98":"w","\u1E89":"w","\u2C73":"w","\u24E7":"x","\uFF58":"x","\u1E8B":"x","\u1E8D":"x","\u24E8":"y","\uFF59":"y","\u1EF3":"y","\u00FD":"y","\u0177":"y","\u1EF9":"y","\u0233":"y","\u1E8F":"y","\u00FF":"y","\u1EF7":"y","\u1E99":"y","\u1EF5":"y","\u01B4":"y","\u024F":"y","\u1EFF":"y","\u24E9":"z","\uFF5A":"z","\u017A":"z","\u1E91":"z","\u017C":"z","\u017E":"z","\u1E93":"z","\u1E95":"z","\u01B6":"z","\u0225":"z","\u0240":"z","\u2C6C":"z","\uA763":"z"};V=d(document);A=(function(){var o=1;return function(){return o++}}());function E(r){var p,q,o,s;if(!r||r.length<1){return r}p="";for(q=0,o=r.length;q<o;q++){s=r.charAt(q);p+=D[s]||s}return p}function Q(q,r){var p=0,o=r.length;for(;p<o;p=p+1){if(T(q,r[p])){return p}}return -1}function m(){var o=d(b);o.appendTo("body");var p={width:o.width()-o[0].clientWidth,height:o.height()-o[0].clientHeight};o.remove();return p}function T(p,o){if(p===o){return true}if(p===M||o===M){return false}if(p===null||o===null){return false}if(p.constructor===String){return p+""===o+""}if(o.constructor===String){return o+""===p+""}return false}function I(p,r){var s,q,o;if(p===null||p.length<1){return[]}s=p.split(r);for(q=0,o=s.length;q<o;q=q+1){s[q]=d.trim(s[q])}return s}function H(o){return o.outerWidth(false)-o.width()}function f(p){var o="keyup-change-value";p.on("keydown",function(){if(d.data(p,o)===M){d.data(p,o,p.val())}});p.on("keyup",function(){var q=d.data(p,o);if(q!==M&&p.val()!==q){d.removeData(p,o);p.trigger("keyup-change")}})}V.on("mousemove",function(o){O.x=o.pageX;O.y=o.pageY});function j(o){o.on("mousemove",function(q){var p=O;if(p===M||p.x!==q.pageX||p.y!==q.pageY){d(q.target).trigger("mousemove-filtered",q)}})}function K(r,p,o){o=o||M;var q;return function(){var s=arguments;window.clearTimeout(q);q=window.setTimeout(function(){p.apply(o,s)},r)}}function S(q){var o=false,p;return function(){if(o===false){p=q();o=true}return p}}function L(o,q){var p=K(o,function(r){q.trigger("scroll-debounced",r)});q.on("scroll",function(r){if(Q(r.target,q.get())>=0){p(r)}})}function i(o){if(o[0]===document.activeElement){return }window.setTimeout(function(){var q=o[0],r=o.val().length,p;o.focus();if(o.is(":visible")&&q===document.activeElement){if(q.setSelectionRange){q.setSelectionRange(r,r)}else{if(q.createTextRange){p=q.createTextRange();p.collapse(false);p.select()}}}},0)}function F(o){o=d(o)[0];var r=0;var p=0;if("selectionStart" in o){r=o.selectionStart;p=o.selectionEnd-r}else{if("selection" in document){o.focus();var q=document.selection.createRange();p=document.selection.createRange().text.length;q.moveStart("character",-o.value.length);r=q.text.length-p}}return{offset:r,length:p}}function a(o){o.preventDefault();o.stopPropagation()}function B(o){o.preventDefault();o.stopImmediatePropagation()}function N(p){if(!P){var o=p[0].currentStyle||window.getComputedStyle(p[0],null);P=d(document.createElement("div")).css({position:"absolute",left:"-10000px",top:"-10000px",display:"none",fontSize:o.fontSize,fontFamily:o.fontFamily,fontStyle:o.fontStyle,fontWeight:o.fontWeight,letterSpacing:o.letterSpacing,textTransform:o.textTransform,whiteSpace:"nowrap"});P.attr("class","select2-sizer");d("body").append(P)}P.text(p.val());return P.width()}function J(p,t,o){var r,s=[],q;r=p.attr("class");if(r){r=""+r;d(r.split(" ")).each2(function(){if(this.indexOf("select2-")===0){s.push(this)}})}r=t.attr("class");if(r){r=""+r;d(r.split(" ")).each2(function(){if(this.indexOf("select2-")!==0){q=o(this);if(q){s.push(q)}}})}p.attr("class",s.join(" "))}function U(t,s,q,o){var r=E(t.toUpperCase()).indexOf(E(s.toUpperCase())),p=s.length;if(r<0){q.push(o(t));return }q.push(o(t.substring(0,r)));q.push("<span class='select2-match'>");q.push(o(t.substring(r,r+p)));q.push("</span>");q.push(o(t.substring(r+p,t.length)))}function g(o){var p={"\\":"&#92;","&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#47;"};return String(o).replace(/[&<>"'\/\\]/g,function(q){return p[q]})}function e(p){var s,q=null,t=p.quietMillis||100,r=p.url,o=this;return function(u){window.clearTimeout(s);s=window.setTimeout(function(){var x=p.data,w=r,z=p.transport||d.fn.select2.ajaxDefaults.transport,v={type:p.type||"GET",cache:p.cache||false,jsonpCallback:p.jsonpCallback||M,dataType:p.dataType||"json"},y=d.extend({},d.fn.select2.ajaxDefaults.params,v);x=x?x.call(o,u.term,u.page,u.context):null;w=(typeof w==="function")?w.call(o,u.term,u.page,u.context):w;if(q){q.abort()}if(p.params){if(d.isFunction(p.params)){d.extend(y,p.params.call(o))}else{d.extend(y,p.params)}}d.extend(y,{url:w,dataType:p.dataType,data:x,success:function(AB){var AA=p.results(AB,u.page);u.callback(AA)}});q=z.call(o,y)},t)}}function h(p){var s=p,r,q,t=function(u){return""+u.text};if(d.isArray(s)){q=s;s={results:q}}if(d.isFunction(s)===false){q=s;s=function(){return q}}var o=s();if(o.text){t=o.text;if(!d.isFunction(t)){r=o.text;t=function(u){return u[r]}}}return function(w){var v=w.term,u={results:[]},x;if(v===""){w.callback(s());return }x=function(z,AB){var AA,y;z=z[0];if(z.children){AA={};for(y in z){if(z.hasOwnProperty(y)){AA[y]=z[y]}}AA.children=[];d(z.children).each2(function(AC,AD){x(AD,AA.children)});if(AA.children.length||w.matcher(v,t(AA),z)){AB.push(AA)}}else{if(w.matcher(v,t(z),z)){AB.push(z)}}};d(s().results).each2(function(z,y){x(y,u.results)});w.callback(u)}}function Z(p){var o=d.isFunction(p);return function(s){var r=s.term,q={results:[]};d(o?p():p).each(function(){var t=this.text!==M,u=t?this.text:this;if(r===""||s.matcher(r,u)){q.results.push(t?this:{id:this,text:this})}});s.callback(q)}}function Y(o,p){if(d.isFunction(o)){return true}if(!o){return false}throw new Error(p+" must be a function or a falsy value")}function c(o){return d.isFunction(o)?o():o}function R(o){var p=0;d.each(o,function(q,r){if(r.children){p+=R(r.children)}else{p++}});return p}function G(w,x,u,o){var p=w,y=false,r,v,s,q,t;if(!o.createSearchChoice||!o.tokenSeparators||o.tokenSeparators.length<1){return M}while(true){v=-1;for(s=0,q=o.tokenSeparators.length;s<q;s++){t=o.tokenSeparators[s];v=w.indexOf(t);if(v>=0){break}}if(v<0){break}r=w.substring(0,v);w=w.substring(v+t.length);if(r.length>0){r=o.createSearchChoice.call(this,r,x);if(r!==M&&r!==null&&o.id(r)!==M&&o.id(r)!==null){y=false;for(s=0,q=x.length;s<q;s++){if(T(o.id(r),o.id(x[s]))){y=true;break}}if(!y){u(r)}}}}if(p!==w){return w}}function l(o,p){var q=function(){};q.prototype=new o;q.prototype.constructor=q;q.prototype.parent=o.prototype;q.prototype=d.extend(q.prototype,p);return q}n=l(Object,{bind:function(p){var o=this;return function(){p.apply(o,arguments)}},init:function(s){var q,p,t=".select2-results";this.opts=s=this.prepareOpts(s);this.id=s.id;if(s.element.data("select2")!==M&&s.element.data("select2")!==null){s.element.data("select2").destroy()}this.container=this.createContainer();this.containerId="s2id_"+(s.element.attr("id")||"autogen"+A());this.containerSelector="#"+this.containerId.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,"\\$1");this.container.attr("id",this.containerId);this.body=S(function(){return s.element.closest("body")});J(this.container,this.opts.element,this.opts.adaptContainerCssClass);this.container.attr("style",s.element.attr("style"));this.container.css(c(s.containerCss));this.container.addClass(c(s.containerCssClass));this.elementTabIndex=this.opts.element.attr("tabindex");this.opts.element.data("select2",this).attr("tabindex","-1").before(this.container).on("click.select2",a);this.container.data("select2",this);this.dropdown=this.container.find(".select2-drop");J(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass);this.dropdown.addClass(c(s.dropdownCssClass));this.dropdown.data("select2",this);this.dropdown.on("click",a);this.results=q=this.container.find(t);this.search=p=this.container.find("input.select2-input");this.queryCount=0;this.resultsPage=0;this.context=null;this.initContainer();this.container.on("click",a);j(this.results);this.dropdown.on("mousemove-filtered touchstart touchmove touchend",t,this.bind(this.highlightUnderEvent));L(80,this.results);this.dropdown.on("scroll-debounced",t,this.bind(this.loadMoreIfNeeded));d(this.container).on("change",".select2-input",function(u){u.stopPropagation()});d(this.dropdown).on("change",".select2-input",function(u){u.stopPropagation()});if(d.fn.mousewheel){q.mousewheel(function(x,y,v,u){var w=q.scrollTop();if(u>0&&w-u<=0){q.scrollTop(0);a(x)}else{if(u<0&&q.get(0).scrollHeight-q.scrollTop()+u<=q.height()){q.scrollTop(q.get(0).scrollHeight-q.height());a(x)}}})}f(p);p.on("keyup-change input paste",this.bind(this.updateResults));p.on("focus",function(){p.addClass("select2-focused")});p.on("blur",function(){p.removeClass("select2-focused")});this.dropdown.on("mouseup",t,this.bind(function(u){if(d(u.target).closest(".select2-result-selectable").length>0){this.highlightUnderEvent(u);this.selectHighlighted(u)}}));this.dropdown.on("click mouseup mousedown",function(u){u.stopPropagation()});if(d.isFunction(this.opts.initSelection)){this.initSelection();this.monitorSource()}if(s.maximumInputLength!==null){this.search.attr("maxlength",s.maximumInputLength)}var r=s.element.prop("disabled");if(r===M){r=false}this.enable(!r);var o=s.element.prop("readonly");if(o===M){o=false}this.readonly(o);W=W||m();this.autofocus=s.element.prop("autofocus");s.element.prop("autofocus",false);if(this.autofocus){this.focus()}this.nextSearchTerm=M},destroy:function(){var p=this.opts.element,o=p.data("select2");this.close();if(this.propertyObserver){delete this.propertyObserver;this.propertyObserver=null}if(o!==M){o.container.remove();o.dropdown.remove();p.removeClass("select2-offscreen").removeData("select2").off(".select2").prop("autofocus",this.autofocus||false);if(this.elementTabIndex){p.attr({tabindex:this.elementTabIndex})}else{p.removeAttr("tabindex")}p.show()}},optionToData:function(o){if(o.is("option")){return{id:o.prop("value"),text:o.text(),element:o.get(),css:o.attr("class"),disabled:o.prop("disabled"),locked:T(o.attr("locked"),"locked")||T(o.data("locked"),true)}}else{if(o.is("optgroup")){return{text:o.attr("label"),children:[],element:o.get(),css:o.attr("class")}}}},prepareOpts:function(t){var r,p,o,s,q=this;r=t.element;if(r.get(0).tagName.toLowerCase()==="select"){this.select=p=t.element}if(p){d.each(["id","multiple","ajax","query","createSearchChoice","initSelection","data","tags"],function(){if(this in t){throw new Error("Option '"+this+"' is not allowed for Select2 when attached to a <select> element.")}})}t=d.extend({},{populateResults:function(u,v,x){var w,y=this.opts.id;w=function(AF,z,AE){var AG,AB,AL,AI,AC,AK,AA,AJ,AH,AD;AF=t.sortResults(AF,z,x);for(AG=0,AB=AF.length;AG<AB;AG=AG+1){AL=AF[AG];AC=(AL.disabled===true);AI=(!AC)&&(y(AL)!==M);AK=AL.children&&AL.children.length>0;AA=d("<li></li>");AA.addClass("select2-results-dept-"+AE);AA.addClass("select2-result");AA.addClass(AI?"select2-result-selectable":"select2-result-unselectable");if(AC){AA.addClass("select2-disabled")}if(AK){AA.addClass("select2-result-with-children")}AA.addClass(q.opts.formatResultCssClass(AL));AJ=d(document.createElement("div"));AJ.addClass("select2-result-label");AD=t.formatResult(AL,AJ,x,q.opts.escapeMarkup);if(AD!==M){AJ.html(AD)}AA.append(AJ);if(AK){AH=d("<ul></ul>");AH.addClass("select2-result-sub");w(AL.children,AH,AE+1);AA.append(AH)}AA.data("select2-data",AL);z.append(AA)}};w(v,u,0)}},d.fn.select2.defaults,t);if(typeof (t.id)!=="function"){o=t.id;t.id=function(u){return u[o]}}if(d.isArray(t.element.data("select2Tags"))){if("tags" in t){throw"tags specified as both an attribute 'data-select2-tags' and in options of Select2 "+t.element.attr("id")}t.tags=t.element.data("select2Tags")}if(p){t.query=this.bind(function(y){var x={results:[],more:false},w=y.term,v,u,z;z=function(AA,AC){var AB;if(AA.is("option")){if(y.matcher(w,AA.text(),AA)){AC.push(q.optionToData(AA))}}else{if(AA.is("optgroup")){AB=q.optionToData(AA);AA.children().each2(function(AD,AE){z(AE,AB.children)});if(AB.children.length>0){AC.push(AB)}}}};v=r.children();if(this.getPlaceholder()!==M&&v.length>0){u=this.getPlaceholderOption();if(u){v=v.not(u)}}v.each2(function(AA,AB){z(AB,x.results)});y.callback(x)});t.id=function(u){return u.id};t.formatResultCssClass=function(u){return u.css}}else{if(!("query" in t)){if("ajax" in t){s=t.element.data("ajax-url");if(s&&s.length>0){t.ajax.url=s}t.query=e.call(t.element,t.ajax)}else{if("data" in t){t.query=h(t.data)}else{if("tags" in t){t.query=Z(t.tags);if(t.createSearchChoice===M){t.createSearchChoice=function(u){return{id:d.trim(u),text:d.trim(u)}}}if(t.initSelection===M){t.initSelection=function(u,w){var v=[];d(I(u.val(),t.separator)).each(function(){var y={id:this,text:this},x=t.tags;if(d.isFunction(x)){x=x()}d(x).each(function(){if(T(this.id,y.id)){y=this;return false}});v.push(y)});w(v)}}}}}}}if(typeof (t.query)!=="function"){throw"query function not defined for Select2 "+t.element.attr("id")}return t},monitorSource:function(){var p=this.opts.element,q,o;p.on("change.select2",this.bind(function(r){if(this.opts.element.data("select2-change-triggered")!==true){this.initSelection()}}));q=this.bind(function(){var s=p.prop("disabled");if(s===M){s=false}this.enable(!s);var r=p.prop("readonly");if(r===M){r=false}this.readonly(r);J(this.container,this.opts.element,this.opts.adaptContainerCssClass);this.container.addClass(c(this.opts.containerCssClass));J(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass);this.dropdown.addClass(c(this.opts.dropdownCssClass))});p.on("propertychange.select2",q);if(this.mutationCallback===M){this.mutationCallback=function(r){r.forEach(q)}}o=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;if(o!==M){if(this.propertyObserver){delete this.propertyObserver;this.propertyObserver=null}this.propertyObserver=new o(this.mutationCallback);this.propertyObserver.observe(p.get(0),{attributes:true,subtree:false})}},triggerSelect:function(p){var o=d.Event("select2-selecting",{val:this.id(p),object:p});this.opts.element.trigger(o);return !o.isDefaultPrevented()},triggerChange:function(o){o=o||{};o=d.extend({},o,{type:"change",val:this.val()});this.opts.element.data("select2-change-triggered",true);this.opts.element.trigger(o);this.opts.element.data("select2-change-triggered",false);this.opts.element.click();if(this.opts.blurOnChange){this.opts.element.blur()}},isInterfaceEnabled:function(){return this.enabledInterface===true},enableInterface:function(){var o=this._enabled&&!this._readonly,p=!o;if(o===this.enabledInterface){return false}this.container.toggleClass("select2-container-disabled",p);this.close();this.enabledInterface=o;return true},enable:function(o){if(o===M){o=true}if(this._enabled===o){return }this._enabled=o;this.opts.element.prop("disabled",!o);this.enableInterface()},disable:function(){this.enable(false)},readonly:function(o){if(o===M){o=false}if(this._readonly===o){return false}this._readonly=o;this.opts.element.prop("readonly",o);this.enableInterface();return true},opened:function(){return this.container.hasClass("select2-dropdown-open")},positionDropdown:function(){var q=this.dropdown,t=this.container.offset(),AC=this.container.outerHeight(false),AD=this.container.outerWidth(false),y=q.outerHeight(false),AA=d(window),AH=AA.width(),w=AA.height(),p=AA.scrollLeft()+AH,AG=AA.scrollTop()+w,r=t.top+AC,AE=t.left,o=r+y<=AG,v=(t.top-y)>=this.body().scrollTop(),z=q.outerWidth(false),AJ=AE+z<=p,AI=q.hasClass("select2-drop-above"),u,AF,s,x,AB;if(AI){AF=true;if(!v&&o){s=true;AF=false}}else{AF=false;if(!o&&v){s=true;AF=true}}if(s){q.hide();t=this.container.offset();AC=this.container.outerHeight(false);AD=this.container.outerWidth(false);y=q.outerHeight(false);p=AA.scrollLeft()+AH;AG=AA.scrollTop()+w;r=t.top+AC;AE=t.left;z=q.outerWidth(false);AJ=AE+z<=p;q.show()}if(this.opts.dropdownAutoWidth){AB=d(".select2-results",q)[0];q.addClass("select2-drop-auto-width");q.css("width","");z=q.outerWidth(false)+(AB.scrollHeight===AB.clientHeight?0:W.width);z>AD?AD=z:z=AD;AJ=AE+z<=p}else{this.container.removeClass("select2-drop-auto-width")}if(this.body().css("position")!=="static"){u=this.body().offset();r-=u.top;AE-=u.left}if(!AJ){AE=t.left+AD-z}x={left:AE,width:AD};if(AF){x.bottom=w-t.top;x.top="auto";this.container.addClass("select2-drop-above");q.addClass("select2-drop-above")}else{x.top=r;x.bottom="auto";this.container.removeClass("select2-drop-above");q.removeClass("select2-drop-above")}x=d.extend(x,c(this.opts.dropdownCss));q.css(x)},shouldOpen:function(){var o;if(this.opened()){return false}if(this._enabled===false||this._readonly===true){return false}o=d.Event("select2-opening");this.opts.element.trigger(o);return !o.isDefaultPrevented()},clearDropdownAlignmentPreference:function(){this.container.removeClass("select2-drop-above");this.dropdown.removeClass("select2-drop-above")},open:function(){if(!this.shouldOpen()){return false}this.opening();return true},opening:function(){var t=this.containerId,o="scroll."+t,r="resize."+t,q="orientationchange."+t,p;this.container.addClass("select2-dropdown-open").addClass("select2-container-active");this.clearDropdownAlignmentPreference();if(this.dropdown[0]!==this.body().children().last()[0]){this.dropdown.detach().appendTo(this.body())}p=d("#select2-drop-mask");if(p.length==0){p=d(document.createElement("div"));p.attr("id","select2-drop-mask").attr("class","select2-drop-mask");p.hide();p.appendTo(this.body());p.on("mousedown touchstart click",function(v){var w=d("#select2-drop"),u;if(w.length>0){u=w.data("select2");if(u.opts.selectOnBlur){u.selectHighlighted({noFocus:true})}u.close({focus:true});v.preventDefault();v.stopPropagation()}})}if(this.dropdown.prev()[0]!==p[0]){this.dropdown.before(p)}d("#select2-drop").removeAttr("id");this.dropdown.attr("id","select2-drop");p.show();this.positionDropdown();this.dropdown.show();this.positionDropdown();this.dropdown.addClass("select2-drop-active");var s=this;this.container.parents().add(window).each(function(){d(this).on(r+" "+o+" "+q,function(u){s.positionDropdown()})})},close:function(){if(!this.opened()){return }var r=this.containerId,o="scroll."+r,q="resize."+r,p="orientationchange."+r;this.container.parents().add(window).each(function(){d(this).off(o).off(q).off(p)});this.clearDropdownAlignmentPreference();d("#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(d.Event("select2-close"))},externalSearch:function(o){this.open();this.search.val(o);this.updateResults(false)},clearSearch:function(){},getMaximumSelectionSize:function(){return c(this.opts.maximumSelectionSize)},ensureHighlightVisible:function(){var r=this.results,q,o,v,u,s,t,p;o=this.highlight();if(o<0){return }if(o==0){r.scrollTop(0);return }q=this.findHighlightableChoices().find(".select2-result-label");v=d(q[o]);u=v.offset().top+v.outerHeight(true);if(o===q.length-1){p=r.find("li.select2-more-results");if(p.length>0){u=p.offset().top+p.outerHeight(true)}}s=r.offset().top+r.outerHeight(true);if(u>s){r.scrollTop(r.scrollTop()+(u-s))}t=v.offset().top-r.offset().top;if(t<0&&v.css("display")!="none"){r.scrollTop(r.scrollTop()+t)}},findHighlightableChoices:function(){return this.results.find(".select2-result-selectable:not(.select2-disabled, .select2-selected)")},moveHighlight:function(r){var q=this.findHighlightableChoices(),p=this.highlight();while(p>-1&&p<q.length){p+=r;var o=d(q[p]);if(o.hasClass("select2-result-selectable")&&!o.hasClass("select2-disabled")&&!o.hasClass("select2-selected")){this.highlight(p);break}}},highlight:function(p){var r=this.findHighlightableChoices(),o,q;if(arguments.length===0){return Q(r.filter(".select2-highlighted")[0],r.get())}if(p>=r.length){p=r.length-1}if(p<0){p=0}this.removeHighlight();o=d(r[p]);o.addClass("select2-highlighted");this.ensureHighlightVisible();q=o.data("select2-data");if(q){this.opts.element.trigger({type:"select2-highlight",val:this.id(q),choice:q})}},removeHighlight:function(){this.results.find(".select2-highlighted").removeClass("select2-highlighted")},countSelectableResults:function(){return this.findHighlightableChoices().length},highlightUnderEvent:function(p){var o=d(p.target).closest(".select2-result-selectable");if(o.length>0&&!o.is(".select2-highlighted")){var q=this.findHighlightableChoices();this.highlight(q.index(o))}else{if(o.length==0){this.removeHighlight()}}},loadMoreIfNeeded:function(){var s=this.results,r=s.find("li.select2-more-results"),u,t=this.resultsPage+1,o=this,q=this.search.val(),p=this.context;if(r.length===0){return }u=r.offset().top-s.offset().top-s.height();if(u<=this.opts.loadMorePadding){r.addClass("select2-active");this.opts.query({element:this.opts.element,term:q,page:t,context:p,matcher:this.opts.matcher,callback:this.bind(function(v){if(!o.opened()){return }o.opts.populateResults.call(this,s,v.results,{term:q,page:t,context:p});o.postprocessResults(v,false,false);if(v.more===true){r.detach().appendTo(s).text(o.opts.formatLoadMore(t+1));window.setTimeout(function(){o.loadMoreIfNeeded()},10)}else{r.remove()}o.positionDropdown();o.resultsPage=t;o.context=v.context;this.opts.element.trigger({type:"select2-loaded",items:v})})})}},tokenize:function(){},updateResults:function(w){var AA=this.search,u=this.results,o=this.opts,t,z=this,x,s=AA.val(),q=d.data(this.container,"select2-last-term"),y;if(w!==true&&q&&T(s,q)){return }d.data(this.container,"select2-last-term",s);if(w!==true&&(this.showSearchInput===false||!this.opened())){return }function v(){AA.removeClass("select2-active");z.positionDropdown()}function p(AB){u.html(AB);v()}y=++this.queryCount;var r=this.getMaximumSelectionSize();if(r>=1){t=this.data();if(d.isArray(t)&&t.length>=r&&Y(o.formatSelectionTooBig,"formatSelectionTooBig")){p("<li class='select2-selection-limit'>"+o.formatSelectionTooBig(r)+"</li>");return }}if(AA.val().length<o.minimumInputLength){if(Y(o.formatInputTooShort,"formatInputTooShort")){p("<li class='select2-no-results'>"+o.formatInputTooShort(AA.val(),o.minimumInputLength)+"</li>")}else{p("")}if(w&&this.showSearch){this.showSearch(true)}return }if(o.maximumInputLength&&AA.val().length>o.maximumInputLength){if(Y(o.formatInputTooLong,"formatInputTooLong")){p("<li class='select2-no-results'>"+o.formatInputTooLong(AA.val(),o.maximumInputLength)+"</li>")}else{p("")}return }if(o.formatSearching&&this.findHighlightableChoices().length===0){p("<li class='select2-searching'>"+o.formatSearching()+"</li>")}AA.addClass("select2-active");this.removeHighlight();x=this.tokenize();if(x!=M&&x!=null){AA.val(x)}this.resultsPage=1;o.query({element:o.element,term:AA.val(),page:this.resultsPage,context:null,matcher:o.matcher,callback:this.bind(function(AC){var AB;if(y!=this.queryCount){return }if(!this.opened()){this.search.removeClass("select2-active");return }this.context=(AC.context===M)?null:AC.context;if(this.opts.createSearchChoice&&AA.val()!==""){AB=this.opts.createSearchChoice.call(z,AA.val(),AC.results);if(AB!==M&&AB!==null&&z.id(AB)!==M&&z.id(AB)!==null){if(d(AC.results).filter(function(){return T(z.id(this),z.id(AB))}).length===0){AC.results.unshift(AB)}}}if(AC.results.length===0&&Y(o.formatNoMatches,"formatNoMatches")){p("<li class='select2-no-results'>"+o.formatNoMatches(AA.val())+"</li>");return }u.empty();z.opts.populateResults.call(this,u,AC.results,{term:AA.val(),page:this.resultsPage,context:null});if(AC.more===true&&Y(o.formatLoadMore,"formatLoadMore")){u.append("<li class='select2-more-results'>"+z.opts.escapeMarkup(o.formatLoadMore(this.resultsPage))+"</li>");window.setTimeout(function(){z.loadMoreIfNeeded()},10)}this.postprocessResults(AC,w);v();this.opts.element.trigger({type:"select2-loaded",items:AC})})})},cancel:function(){this.close()},blur:function(){if(this.opts.selectOnBlur){this.selectHighlighted({noFocus:true})}this.close();this.container.removeClass("select2-container-active");if(this.search[0]===document.activeElement){this.search.blur()}this.clearSearch();this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus")},focusSearch:function(){i(this.search)},selectHighlighted:function(p){var o=this.highlight(),q=this.results.find(".select2-highlighted"),r=q.closest(".select2-result").data("select2-data");if(r){this.highlight(o);this.onSelect(r,p)}else{if(p&&p.noFocus){this.close()}}},getPlaceholder:function(){var o;return this.opts.element.attr("placeholder")||this.opts.element.attr("data-placeholder")||this.opts.element.data("placeholder")||this.opts.placeholder||((o=this.getPlaceholderOption())!==M?o.text():M)},getPlaceholderOption:function(){if(this.select){var o=this.select.children("option").first();if(this.opts.placeholderOption!==M){return(this.opts.placeholderOption==="first"&&o)||(typeof this.opts.placeholderOption==="function"&&this.opts.placeholderOption(this.select))}else{if(o.text()===""&&o.val()===""){return o}}}},initContainerWidth:function(){function p(){var u,s,v,t,r,q;if(this.opts.width==="off"){return null}else{if(this.opts.width==="element"){return this.opts.element.outerWidth(false)===0?"auto":this.opts.element.outerWidth(false)+"px"}else{if(this.opts.width==="copy"||this.opts.width==="resolve"){u=this.opts.element.attr("style");if(u!==M){s=u.split(";");for(t=0,r=s.length;t<r;t=t+1){q=s[t].replace(/\s/g,"");v=q.match(/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i);if(v!==null&&v.length>=1){return v[1]}}}if(this.opts.width==="resolve"){u=this.opts.element.css("width");if(u.indexOf("%")>0){return u}return(this.opts.element.outerWidth(false)===0?"auto":this.opts.element.outerWidth(false)+"px")}return null}else{if(d.isFunction(this.opts.width)){return this.opts.width()}else{return this.opts.width}}}}}var o=p.call(this);if(o!==null){this.container.css("width",o)}}});X=l(n,{createContainer:function(){var o=d(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'>&nbsp;</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 o},enableInterface:function(){if(this.parent.enableInterface.apply(this,arguments)){this.focusser.prop("disabled",!this.isInterfaceEnabled())}},opening:function(){var q,p,o;if(this.opts.minimumResultsForSearch>=0){this.showSearch(true)}this.parent.opening.apply(this,arguments);if(this.showSearchInput!==false){this.search.val(this.focusser.val())}this.search.focus();q=this.search.get(0);if(q.createTextRange){p=q.createTextRange();p.collapse(false);p.select()}else{if(q.setSelectionRange){o=this.search.val().length;q.setSelectionRange(o,o)}}if(this.search.val()===""){if(this.nextSearchTerm!=M){this.search.val(this.nextSearchTerm);this.search.select()}}this.focusser.prop("disabled",true).val("");this.updateResults(true);this.opts.element.trigger(d.Event("select2-open"))},close:function(o){if(!this.opened()){return }this.parent.close.apply(this,arguments);o=o||{focus:true};this.focusser.removeAttr("disabled");if(o.focus){this.focusser.focus()}},focus:function(){if(this.opened()){this.close()}else{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(){d("label[for='"+this.focusser.attr("id")+"']").attr("for",this.opts.element.attr("id"));this.parent.destroy.apply(this,arguments)},initContainer:function(){var p,o=this.container,q=this.dropdown;if(this.opts.minimumResultsForSearch<0){this.showSearch(false)}else{this.showSearch(true)}this.selection=p=o.find(".select2-choice");this.focusser=o.find(".select2-focusser");this.focusser.attr("id","s2id_autogen"+A());d("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(r){if(!this.isInterfaceEnabled()){return }if(r.which===k.PAGE_UP||r.which===k.PAGE_DOWN){a(r);return }switch(r.which){case k.UP:case k.DOWN:this.moveHighlight((r.which===k.UP)?-1:1);a(r);return ;case k.ENTER:this.selectHighlighted();a(r);return ;case k.TAB:this.selectHighlighted({noFocus:true});return ;case k.ESC:this.cancel(r);a(r);return }}));this.search.on("blur",this.bind(function(r){if(document.activeElement===this.body().get(0)){window.setTimeout(this.bind(function(){this.search.focus()}),0)}}));this.focusser.on("keydown",this.bind(function(r){if(!this.isInterfaceEnabled()){return }if(r.which===k.TAB||k.isControl(r)||k.isFunctionKey(r)||r.which===k.ESC){return }if(this.opts.openOnEnter===false&&r.which===k.ENTER){a(r);return }if(r.which==k.DOWN||r.which==k.UP||(r.which==k.ENTER&&this.opts.openOnEnter)){if(r.altKey||r.ctrlKey||r.shiftKey||r.metaKey){return }this.open();a(r);return }if(r.which==k.DELETE||r.which==k.BACKSPACE){if(this.opts.allowClear){this.clear()}a(r);return }}));f(this.focusser);this.focusser.on("keyup-change input",this.bind(function(r){if(this.opts.minimumResultsForSearch>=0){r.stopPropagation();if(this.opened()){return }this.open()}}));p.on("mousedown","abbr",this.bind(function(r){if(!this.isInterfaceEnabled()){return }this.clear();B(r);this.close();this.selection.focus()}));p.on("mousedown",this.bind(function(r){if(!this.container.hasClass("select2-container-active")){this.opts.element.trigger(d.Event("select2-focus"))}if(this.opened()){this.close()}else{if(this.isInterfaceEnabled()){this.open()}}a(r)}));q.on("mousedown",this.bind(function(){this.search.focus()}));p.on("focus",this.bind(function(r){a(r)}));this.focusser.on("focus",this.bind(function(){if(!this.container.hasClass("select2-container-active")){this.opts.element.trigger(d.Event("select2-focus"))}this.container.addClass("select2-container-active")})).on("blur",this.bind(function(){if(!this.opened()){this.container.removeClass("select2-container-active");this.opts.element.trigger(d.Event("select2-blur"))}}));this.search.on("focus",this.bind(function(){if(!this.container.hasClass("select2-container-active")){this.opts.element.trigger(d.Event("select2-focus"))}this.container.addClass("select2-container-active")}));this.initContainerWidth();this.opts.element.addClass("select2-offscreen");this.setPlaceholder()},clear:function(q){var r=this.selection.data("select2-data");if(r){var p=d.Event("select2-clearing");this.opts.element.trigger(p);if(p.isDefaultPrevented()){return }var o=this.getPlaceholderOption();this.opts.element.val(o?o.val():"");this.selection.find(".select2-chosen").empty();this.selection.removeData("select2-data");this.setPlaceholder();if(q!==false){this.opts.element.trigger({type:"select2-removed",val:this.id(r),choice:r});this.triggerChange({removed:r})}}},initSelection:function(){var p;if(this.isPlaceholderOptionSelected()){this.updateSelection(null);this.close();this.setPlaceholder()}else{var o=this;this.opts.initSelection.call(null,this.opts.element,function(q){if(q!==M&&q!==null){o.updateSelection(q);o.close();o.setPlaceholder()}})}},isPlaceholderOptionSelected:function(){var o;if(!this.getPlaceholder()){return false}return((o=this.getPlaceholderOption())!==M&&o.prop("selected"))||(this.opts.element.val()==="")||(this.opts.element.val()===M)||(this.opts.element.val()===null)},prepareOpts:function(){var p=this.parent.prepareOpts.apply(this,arguments),o=this;if(p.element.get(0).tagName.toLowerCase()==="select"){p.initSelection=function(q,s){var r=q.find("option").filter(function(){return this.selected});s(o.optionToData(r))}}else{if("data" in p){p.initSelection=p.initSelection||function(r,t){var s=r.val();var q=null;p.query({matcher:function(u,x,v){var w=T(s,p.id(v));if(w){q=v}return w},callback:!d.isFunction(t)?d.noop:function(){t(q)}})}}}return p},getPlaceholder:function(){if(this.select){if(this.getPlaceholderOption()===M){return M}}return this.parent.getPlaceholder.apply(this,arguments)},setPlaceholder:function(){var o=this.getPlaceholder();if(this.isPlaceholderOptionSelected()&&o!==M){if(this.select&&this.getPlaceholderOption()===M){return }this.selection.find(".select2-chosen").html(this.opts.escapeMarkup(o));this.selection.addClass("select2-default");this.container.removeClass("select2-allowclear")}},postprocessResults:function(t,p,s){var r=0,o=this,u=true;this.findHighlightableChoices().each2(function(v,w){if(T(o.id(w.data("select2-data")),o.opts.element.val())){r=v;return false}});if(s!==false){if(p===true&&r>=0){this.highlight(r)}else{this.highlight(0)}}if(p===true){var q=this.opts.minimumResultsForSearch;if(q>=0){this.showSearch(R(t.results)>=q)}}},showSearch:function(o){if(this.showSearchInput===o){return }this.showSearchInput=o;this.dropdown.find(".select2-search").toggleClass("select2-search-hidden",!o);this.dropdown.find(".select2-search").toggleClass("select2-offscreen",!o);d(this.dropdown,this.container).toggleClass("select2-with-searchbox",o)},onSelect:function(q,p){if(!this.triggerSelect(q)){return }var o=this.opts.element.val(),r=this.data();this.opts.element.val(this.id(q));this.updateSelection(q);this.opts.element.trigger({type:"select2-selected",val:this.id(q),choice:q});this.nextSearchTerm=this.opts.nextSearchTerm(q,this.search.val());this.close();if(!p||!p.noFocus){this.focusser.focus()}if(!T(o,this.id(q))){this.triggerChange({added:q,removed:r})}},updateSelection:function(r){var p=this.selection.find(".select2-chosen"),q,o;this.selection.data("select2-data",r);p.empty();if(r!==null){q=this.opts.formatSelection(r,p,this.opts.escapeMarkup)}if(q!==M){p.append(q)}o=this.opts.formatSelectionCssClass(r,p);if(o!==M){p.addClass(o)}this.selection.removeClass("select2-default");if(this.opts.allowClear&&this.getPlaceholder()!==M){this.container.addClass("select2-allowclear")}},val:function(){var s,p=false,q=null,o=this,r=this.data();if(arguments.length===0){return this.opts.element.val()}s=arguments[0];if(arguments.length>1){p=arguments[1]}if(this.select){this.select.val(s).find("option").filter(function(){return this.selected}).each2(function(t,u){q=o.optionToData(u);return false});this.updateSelection(q);this.setPlaceholder();if(p){this.triggerChange({added:q,removed:r})}}else{if(!s&&s!==0){this.clear(p);return }if(this.opts.initSelection===M){throw new Error("cannot call val() if initSelection() is not defined")}this.opts.element.val(s);this.opts.initSelection(this.opts.element,function(t){o.opts.element.val(!t?"":o.id(t));o.updateSelection(t);o.setPlaceholder();if(p){o.triggerChange({added:t,removed:r})}})}},clearSearch:function(){this.search.val("");this.focusser.val("")},data:function(q){var p,o=false;if(arguments.length===0){p=this.selection.data("select2-data");if(p==M){p=null}return p}else{if(arguments.length>1){o=arguments[1]}if(!q){this.clear(o)}else{p=this.data();this.opts.element.val(!q?"":this.id(q));this.updateSelection(q);if(o){this.triggerChange({added:q,removed:p})}}}}});C=l(n,{createContainer:function(){var o=d(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 o},prepareOpts:function(){var p=this.parent.prepareOpts.apply(this,arguments),o=this;if(p.element.get(0).tagName.toLowerCase()==="select"){p.initSelection=function(q,s){var r=[];q.find("option").filter(function(){return this.selected}).each2(function(t,u){r.push(o.optionToData(u))});s(r)}}else{if("data" in p){p.initSelection=p.initSelection||function(q,t){var r=I(q.val(),p.separator);var s=[];p.query({matcher:function(u,x,v){var w=d.grep(r,function(y){return T(y,p.id(v))}).length;if(w){s.push(v)}return w},callback:!d.isFunction(t)?d.noop:function(){var u=[];for(var x=0;x<r.length;x++){var y=r[x];for(var w=0;w<s.length;w++){var v=s[w];if(T(y,p.id(v))){u.push(v);s.splice(w,1);break}}}t(u)}})}}}return p},selectChoice:function(o){var p=this.container.find(".select2-search-choice-focus");if(p.length&&o&&o[0]==p[0]){}else{if(p.length){this.opts.element.trigger("choice-deselected",p)}p.removeClass("select2-search-choice-focus");if(o&&o.length){this.close();o.addClass("select2-search-choice-focus");this.opts.element.trigger("choice-selected",o)}}},destroy:function(){d("label[for='"+this.search.attr("id")+"']").attr("for",this.opts.element.attr("id"));this.parent.destroy.apply(this,arguments)},initContainer:function(){var o=".select2-choices",p;this.searchContainer=this.container.find(".select2-search-field");this.selection=p=this.container.find(o);var q=this;this.selection.on("click",".select2-search-choice:not(.select2-locked)",function(r){q.search[0].focus();q.selectChoice(d(this))});this.search.attr("id","s2id_autogen"+A());d("label[for='"+this.opts.element.attr("id")+"']").attr("for",this.search.attr("id"));this.search.on("input paste",this.bind(function(){if(!this.isInterfaceEnabled()){return }if(!this.opened()){this.open()}}));this.search.attr("tabindex",this.elementTabIndex);this.keydowns=0;this.search.on("keydown",this.bind(function(v){if(!this.isInterfaceEnabled()){return }++this.keydowns;var t=p.find(".select2-search-choice-focus");var u=t.prev(".select2-search-choice:not(.select2-locked)");var s=t.next(".select2-search-choice:not(.select2-locked)");var w=F(this.search);if(t.length&&(v.which==k.LEFT||v.which==k.RIGHT||v.which==k.BACKSPACE||v.which==k.DELETE||v.which==k.ENTER)){var r=t;if(v.which==k.LEFT&&u.length){r=u}else{if(v.which==k.RIGHT){r=s.length?s:null}else{if(v.which===k.BACKSPACE){this.unselect(t.first());this.search.width(10);r=u.length?u:s}else{if(v.which==k.DELETE){this.unselect(t.first());this.search.width(10);r=s.length?s:null}else{if(v.which==k.ENTER){r=null}}}}}this.selectChoice(r);a(v);if(!r||!r.length){this.open()}return }else{if(((v.which===k.BACKSPACE&&this.keydowns==1)||v.which==k.LEFT)&&(w.offset==0&&!w.length)){this.selectChoice(p.find(".select2-search-choice:not(.select2-locked)").last());a(v);return }else{this.selectChoice(null)}}if(this.opened()){switch(v.which){case k.UP:case k.DOWN:this.moveHighlight((v.which===k.UP)?-1:1);a(v);return ;case k.ENTER:this.selectHighlighted();a(v);return ;case k.TAB:this.selectHighlighted({noFocus:true});this.close();return ;case k.ESC:this.cancel(v);a(v);return }}if(v.which===k.TAB||k.isControl(v)||k.isFunctionKey(v)||v.which===k.BACKSPACE||v.which===k.ESC){return }if(v.which===k.ENTER){if(this.opts.openOnEnter===false){return }else{if(v.altKey||v.ctrlKey||v.shiftKey||v.metaKey){return }}}this.open();if(v.which===k.PAGE_UP||v.which===k.PAGE_DOWN){a(v)}if(v.which===k.ENTER){a(v)}}));this.search.on("keyup",this.bind(function(r){this.keydowns=0;this.resizeSearch()}));this.search.on("blur",this.bind(function(r){this.container.removeClass("select2-container-active");this.search.removeClass("select2-focused");this.selectChoice(null);if(!this.opened()){this.clearSearch()}r.stopImmediatePropagation();this.opts.element.trigger(d.Event("select2-blur"))}));this.container.on("click",o,this.bind(function(r){if(!this.isInterfaceEnabled()){return }if(d(r.target).closest(".select2-search-choice").length>0){return }this.selectChoice(null);this.clearPlaceholder();if(!this.container.hasClass("select2-container-active")){this.opts.element.trigger(d.Event("select2-focus"))}this.open();this.focusSearch();r.preventDefault()}));this.container.on("focus",o,this.bind(function(){if(!this.isInterfaceEnabled()){return }if(!this.container.hasClass("select2-container-active")){this.opts.element.trigger(d.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(){if(this.parent.enableInterface.apply(this,arguments)){this.search.prop("disabled",!this.isInterfaceEnabled())}},initSelection:function(){var p;if(this.opts.element.val()===""&&this.opts.element.text()===""){this.updateSelection([]);this.close();this.clearSearch()}if(this.select||this.opts.element.val()!==""){var o=this;this.opts.initSelection.call(null,this.opts.element,function(q){if(q!==M&&q!==null){o.updateSelection(q);o.close();o.clearSearch()}})}},clearSearch:function(){var p=this.getPlaceholder(),o=this.getMaxSearchWidth();if(p!==M&&this.getVal().length===0&&this.search.hasClass("select2-focused")===false){this.search.val(p).addClass("select2-default");this.search.width(o>0?o:this.container.css("width"))}else{this.search.val("").width(10)}},clearPlaceholder:function(){if(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(true);this.search.focus();this.opts.element.trigger(d.Event("select2-open"))},close:function(){if(!this.opened()){return }this.parent.close.apply(this,arguments)},focus:function(){this.close();this.search.focus()},isFocused:function(){return this.search.hasClass("select2-focused")},updateSelection:function(r){var q=[],p=[],o=this;d(r).each(function(){if(Q(o.id(this),q)<0){q.push(o.id(this));p.push(this)}});r=p;this.selection.find(".select2-search-choice").remove();d(r).each(function(){o.addSelectedChoice(this)});o.postprocessResults()},tokenize:function(){var o=this.search.val();o=this.opts.tokenizer.call(this,o,this.data(),this.bind(this.onSelect),this.opts);if(o!=null&&o!=M){this.search.val(o);if(o.length>0){this.open()}}},onSelect:function(p,o){if(!this.triggerSelect(p)){return }this.addSelectedChoice(p);this.opts.element.trigger({type:"selected",val:this.id(p),choice:p});if(this.select||!this.opts.closeOnSelect){this.postprocessResults(p,false,this.opts.closeOnSelect===true)}if(this.opts.closeOnSelect){this.close();this.search.width(10)}else{if(this.countSelectableResults()>0){this.search.width(10);this.resizeSearch();if(this.getMaximumSelectionSize()>0&&this.val().length>=this.getMaximumSelectionSize()){this.updateResults(true)}this.positionDropdown()}else{this.close();this.search.width(10)}}this.triggerChange({added:p});if(!o||!o.noFocus){this.focusSearch()}},cancel:function(){this.close();this.focusSearch()},addSelectedChoice:function(s){var u=!s.locked,q=d("<li class='select2-search-choice'>    <div></div>    <a href='#' onclick='return false;' class='select2-search-choice-close' tabindex='-1'></a></li>"),v=d("<li class='select2-search-choice select2-locked'><div></div></li>");var r=u?q:v,o=this.id(s),p=this.getVal(),t,w;t=this.opts.formatSelection(s,r.find("div"),this.opts.escapeMarkup);if(t!=M){r.find("div").replaceWith("<div>"+t+"</div>")}w=this.opts.formatSelectionCssClass(s,r.find("div"));if(w!=M){r.addClass(w)}if(u){r.find(".select2-search-choice-close").on("mousedown",a).on("click dblclick",this.bind(function(x){if(!this.isInterfaceEnabled()){return }d(x.target).closest(".select2-search-choice").fadeOut("fast",this.bind(function(){this.unselect(d(x.target));this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");this.close();this.focusSearch()})).dequeue();a(x)})).on("focus",this.bind(function(){if(!this.isInterfaceEnabled()){return }this.container.addClass("select2-container-active");this.dropdown.addClass("select2-drop-active")}))}r.data("select2-data",s);r.insertBefore(this.searchContainer);p.push(o);this.setVal(p)},unselect:function(q){var s=this.getVal(),r,p;q=q.closest(".select2-search-choice");if(q.length===0){throw"Invalid argument: "+q+". Must be .select2-search-choice"}r=q.data("select2-data");if(!r){return }while((p=Q(this.id(r),s))>=0){s.splice(p,1);this.setVal(s);if(this.select){this.postprocessResults()}}var o=d.Event("select2-removing");o.val=this.id(r);o.choice=r;this.opts.element.trigger(o);if(o.isDefaultPrevented()){return }q.remove();this.opts.element.trigger({type:"select2-removed",val:this.id(r),choice:r});this.triggerChange({removed:r})},postprocessResults:function(s,p,r){var t=this.getVal(),u=this.results.find(".select2-result"),q=this.results.find(".select2-result-with-children"),o=this;u.each2(function(w,v){var x=o.id(v.data("select2-data"));if(Q(x,t)>=0){v.addClass("select2-selected");v.find(".select2-result-selectable").addClass("select2-selected")}});q.each2(function(w,v){if(!v.is(".select2-result-selectable")&&v.find(".select2-result-selectable:not(.select2-selected)").length===0){v.addClass("select2-selected")}});if(this.highlight()==-1&&r!==false){o.highlight(0)}if(!this.opts.createSearchChoice&&!u.filter(".select2-result:not(.select2-selected)").length>0){if(!s||s&&!s.more&&this.results.find(".select2-no-results").length===0){if(Y(o.opts.formatNoMatches,"formatNoMatches")){this.results.append("<li class='select2-no-results'>"+o.opts.formatNoMatches(o.search.val())+"</li>")}}}},getMaxSearchWidth:function(){return this.selection.width()-H(this.search)},resizeSearch:function(){var t,r,q,o,p,s=H(this.search);t=N(this.search)+10;r=this.search.offset().left;q=this.selection.width();o=this.selection.offset().left;p=q-(r-o)-s;if(p<t){p=q-s}if(p<40){p=q-s}if(p<=0){p=t}this.search.width(Math.floor(p))},getVal:function(){var o;if(this.select){o=this.select.val();return o===null?[]:o}else{o=this.opts.element.val();return I(o,this.opts.separator)}},setVal:function(p){var o;if(this.select){this.select.val(p)}else{o=[];d(p).each(function(){if(Q(this,o)<0){o.push(this)}});this.opts.element.val(o.length===0?"":o.join(this.opts.separator))}},buildChangeDetails:function(o,r){var r=r.slice(0),o=o.slice(0);for(var q=0;q<r.length;q++){for(var p=0;p<o.length;p++){if(T(this.opts.id(r[q]),this.opts.id(o[p]))){r.splice(q,1);if(q>0){q--}o.splice(p,1);p--}}}return{added:r,removed:o}},val:function(r,p){var q,o=this;if(arguments.length===0){return this.getVal()}q=this.data();if(!q.length){q=[]}if(!r&&r!==0){this.opts.element.val("");this.updateSelection([]);this.clearSearch();if(p){this.triggerChange({added:this.data(),removed:q})}return }this.setVal(r);if(this.select){this.opts.initSelection(this.select,this.bind(this.updateSelection));if(p){this.triggerChange(this.buildChangeDetails(q,this.data()))}}else{if(this.opts.initSelection===M){throw new Error("val() cannot be called if initSelection() is not defined")}this.opts.initSelection(this.opts.element,function(t){var s=d.map(t,o.id);o.setVal(s);o.updateSelection(t);o.clearSearch();if(p){o.triggerChange(o.buildChangeDetails(q,o.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 p=[],o=this;this.searchContainer.show();this.searchContainer.appendTo(this.searchContainer.parent());this.resizeSearch();this.selection.find(".select2-search-choice").each(function(){p.push(o.opts.id(d(this).data("select2-data")))});this.setVal(p);this.triggerChange()},data:function(q,r){var p=this,s,o;if(arguments.length===0){return this.selection.find(".select2-search-choice").map(function(){return d(this).data("select2-data")}).get()}else{o=this.data();if(!q){q=[]}s=d.map(q,function(t){return p.opts.id(t)});this.setVal(s);this.updateSelection(q);this.clearSearch();if(r){this.triggerChange(this.buildChangeDetails(o,this.data()))}}}});d.fn.select2=function(){var t=Array.prototype.slice.call(arguments,0),p,s,o,v,x,w=["val","destroy","opened","open","close","focus","isFocused","container","dropdown","onSortStart","onSortEnd","enable","disable","readonly","positionDropdown","data","search"],u=["opened","isFocused","container","dropdown"],q=["val","data"],r={search:"externalSearch"};this.each(function(){if(t.length===0||typeof (t[0])==="object"){p=t.length===0?{}:d.extend({},t[0]);p.element=d(this);if(p.element.get(0).tagName.toLowerCase()==="select"){x=p.element.prop("multiple")}else{x=p.multiple||false;if("tags" in p){p.multiple=x=true}}s=x?new C():new X();s.init(p)}else{if(typeof (t[0])==="string"){if(Q(t[0],w)<0){throw"Unknown method: "+t[0]}v=M;s=d(this).data("select2");if(s===M){return }o=t[0];if(o==="container"){v=s.container}else{if(o==="dropdown"){v=s.dropdown}else{if(r[o]){o=r[o]}v=s[o].apply(s,t.slice(1))}}if(Q(t[0],u)>=0||(Q(t[0],q)&&t.length==1)){return false}}else{throw"Invalid arguments to select2 plugin: "+t}}});return(v===M)?this:v};d.fn.select2.defaults={width:"copy",loadMorePadding:0,closeOnSelect:true,openOnEnter:true,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(p,q,s,o){var r=[];U(p.text,s.term,r,o);return r.join("")},formatSelection:function(q,p,o){return q?o(q.text):M},sortResults:function(p,o,q){return p},formatResultCssClass:function(o){return M},formatSelectionCssClass:function(p,o){return M},formatNoMatches:function(){return"No matches found"},formatInputTooShort:function(o,p){var q=p-o.length;return"Please enter "+q+" more character"+(q==1?"":"s")},formatInputTooLong:function(p,o){var q=p.length-o;return"Please delete "+q+" character"+(q==1?"":"s")},formatSelectionTooBig:function(o){return"You can only select "+o+" item"+(o==1?"":"s")},formatLoadMore:function(o){return"Loading more results..."},formatSearching:function(){return"Searching..."},minimumResultsForSearch:0,minimumInputLength:0,maximumInputLength:null,maximumSelectionSize:0,id:function(o){return o.id},matcher:function(o,p){return E(""+p).toUpperCase().indexOf(E(""+o).toUpperCase())>=0},separator:",",tokenSeparators:[],tokenizer:G,escapeMarkup:g,blurOnChange:false,selectOnBlur:false,adaptContainerCssClass:function(o){return o},adaptDropdownCssClass:function(o){return null},nextSearchTerm:function(o,p){return M}};d.fn.select2.ajaxDefaults={transport:d.ajax,params:{type:"GET",cache:false,dataType:"json"}};window.Select2={query:{ajax:e,local:h,tags:Z},util:{debounce:K,markMatch:U,escapeMarkup:g,stripDiacritics:E},"class":{"abstract":n,single:X,multi:C}}}(jQuery));;
;/* module-key = 'com.atlassian.auiplugin:aui-select2', location = 'js/aui-select2.js' */
(function(C){var E=C.fn.select2;var D="aui-select2-container";var B="aui-select2-drop aui-dropdown2 aui-style-default";var A="aui-has-avatar";C.fn.auiSelect2=function(I){var H;if(C.isPlainObject(I)){var F=C.extend({},I);var G=F.hasAvatar?" "+A:"";F.containerCssClass=D+G+(F.containerCssClass?" "+F.containerCssClass:"");F.dropdownCssClass=B+G+(F.dropdownCssClass?" "+F.dropdownCssClass:"");H=Array.prototype.slice.call(arguments,1);H.unshift(F)}else{if(!arguments.length){H=[{containerCssClass:D,dropdownCssClass:B}]}else{H=arguments}}return E.apply(this,H)}})(AJS.$);;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:locale', location = '/static/feature/locale/locale.soy' */
// This file was automatically generated from locale.soy.
// Please don't edit this file by hand.

/**
 * @fileoverview Templates in namespace stash.feature.locale.
 */

if (typeof stash == 'undefined') { var stash = {}; }
if (typeof stash.feature == 'undefined') { stash.feature = {}; }
if (typeof stash.feature.locale == 'undefined') { stash.feature.locale = {}; }


stash.feature.locale.field = function(opt_data, opt_ignored) {
  var param6 = '<select name="locale" id="locale">';
  var languageList8 = opt_data.languages;
  var languageListLen8 = languageList8.length;
  for (var languageIndex8 = 0; languageIndex8 < languageListLen8; languageIndex8++) {
    var languageData8 = languageList8[languageIndex8];
    param6 += '<option value="' + soy.$$escapeHtml(languageData8.locale) + '" ' + soy.$$escapeHtml(languageData8.selected ? 'selected' : '') + '>' + soy.$$escapeHtml(languageData8.name) + '</option>';
  }
  param6 += '</select>';
  var output = '' + widget.aui.form.field({id: 'locale', labelContent: '' + soy.$$escapeHtml("Language"), input: param6, descriptionContent: '' + ((! opt_data.hideMore) ? soy.$$filterNoAutoescape(AJS.format("Find more language packs on the {0}Atlassian Marketplace{1}",'<a href=' + require('stash/api/util/navbuilder').addons().requests().category('Language Packs').build() + '>','</a>')) : ''), errors: opt_data.errors ? opt_data.errors.locale : null});
  output += '<script>jQuery(\'#locale\').auiSelect2({minimumResultsForSearch: 20})<\/script>';
  return output;
};
if (goog.DEBUG) {
  stash.feature.locale.field.soyTemplateName = 'stash.feature.locale.field';
}
;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:canvas-cropper', location = '/static/widget/canvas-cropper/canvas-cropper.js' */
define("widget/canvas-cropper",["jquery","util/feature-detect"],function(C,A){function B(E,D){if(!B.isSupported()){throw new Error("This browser doesn't support CanvasCropper.")}return this.init.apply(this,arguments)}B.isSupported=A.canvas;B.prototype.defaults={outputFormat:"image/png",backgroundFillColor:undefined};B.prototype.init=function(E,D,F){this.width=E;this.height=D||E;this.options=C.extend({},this.defaults,F);this.canvas=C("<canvas/>").attr("width",this.width).attr("height",this.height)[0];return this};B.prototype.cropToDataURI=function(H,G,F,E,D){return this.crop(H,G,F,E,D).getDataURI(this.options.outputFormat)};B.prototype.crop=function(G,F,E,N,O){var D=this.canvas.getContext("2d"),L=0,J=0,K=this.width,H=this.height;D.clearRect(L,J,K,H);if(this.options.backgroundFillColor){D.fillStyle=this.options.backgroundFillColor;D.fillRect(L,J,K,H)}if(F<0){L=Math.round((Math.abs(F)/N)*K);F=0}if(E<0){J=Math.round((Math.abs(E)/O)*H);E=0}if(F+N>G.naturalWidth){var M=G.naturalWidth-F;K*=M/N;N=M}if(E+O>G.naturalHeight){var I=G.naturalHeight-E;H*=I/O;O=I}D.drawImage(G,F,E,N,O,L,J,K,H);return this};B.prototype.getDataURI=function(D){if(D){return this.canvas.toDataURL(D)}else{return null}};return B});;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:user-media', location = '/static/util/user-media.js' */
define("util/user-media",[],function(){var A=(navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia);return A?A.bind(navigator):undefined});;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:moustash', location = '/static/feature/moustash/moustash.js' */
define("feature/moustash",["aui","jquery","lodash","exports"],function(H,C,J,B){var G=false;var L;var D={MIN_CANVAS_WIDTH:0.1,M_F_WIDTH:0.9,M_F_HEIGHT:0.2,M_F_LEFT:0.05,M_F_TOP:0.675};function E(){var M="com.atlassian.stash.stash-web-plugin:face-detection";return WRM.require("wr!"+M)}function A(){var M=C.Deferred();L=new Image();L.onload=function(){M.resolve()};L.src=H.contextPath()+"/s/1/_/download/resources/com.atlassian.stash.stash-web-plugin:moustash/moustash.png";return M}function K(){return C.when(E(),A()).done(function(){G=true})}function F(){return G}function I(P){if(!F()){throw new Error("Face-detection resources not loaded yet")}var O=require("lib/ccv/ccv");var Q=require("lib/ccv/face-cascade");var M=O.detect_objects({canvas:P,cascade:Q,interval:5,min_neighbors:1});var N=P.getContext("2d");J.each(M,J.bind(function(U){if(U.width/P.width>D.MIN_CANVAS_WIDTH){var V=U.y+U.height*D.M_F_TOP;var S=U.x+U.width*D.M_F_LEFT;var T=U.width*D.M_F_WIDTH;var R=U.height*D.M_F_HEIGHT;N.drawImage(L,S,V,T,R)}}))}B.loadResources=J.once(K);B.isReady=F;B.addToFaces=I});;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:webcam-capture', location = '/static/widget/webcam-capture/webcam-capture.js' */
define("widget/webcam-capture",["aui","jquery","lodash","util/feature-detect","util/user-media","feature/moustash"],function(C,G,D,A,F,E){function B(I,H){D.bindAll(this,"start","_setVideoSize","_capture","_takePhoto","_onKeypress","_onTakePhotoClicked","_onUserMediaSuccess","_onUserMediaError");this.opts=D.extend({},B.defaults,H);this.$container=I;this.video=I.find("video")[0];this.$takePhoto=I.find(".take-photo");this.$countdown=I.find(".countdown");this.$videoPlaceholder=I.find(".video-placeholder");this.width=this.opts.width;this.snapSound=new Audio();G(this.video).toggleClass("mirror",this.opts.mirror).on("canplay",this._setVideoSize);this.$takePhoto.on("click",this._onTakePhotoClicked).tooltip({gravity:"w",fade:true});this.$container.find(".retry-webcam").on("click",function(){this.$container.find(".no-access").addClass("hidden");this.$container.find(".grant-access").removeClass("hidden");setTimeout(this.start,50);return false}.bind(this))}B.isSupported=D.once(function(){return A.getUserMedia()&&A.canvas()&&A.video()});B.defaults={countdown:false,mirror:true,width:640,onCapture:G.noop};B.prototype.start=function(){this.snapSound.src=C.contextPath()+"/s/1/_/download/resources/com.atlassian.stash.stash-web-plugin:webcam-capture/camera-snap.wav";if(!this.stream){F({video:true,audio:false},this._onUserMediaSuccess,this._onUserMediaError)}else{this.video.play();this.isStreaming=true;this.$takePhoto.focus()}};B.prototype.pause=function(){if(this.isStreaming){this.video.pause();this.isStreaming=false}};B.prototype.stop=function(){if(this.stream){this.pause();this.video.src=null;this.stream.stop();this.stream=null;G(document).off("keypress",this._onKeypress)}this.$takePhoto.tipsy("hide");this.$container.removeClass("streaming")};B.prototype._onUserMediaSuccess=function(H){this.stream=H;this.video.src=window.URL.createObjectURL(H);this.video.play();this.isStreaming=true;E.loadResources();this.$container.addClass("streaming");this.$takePhoto.focus();G(document).on("keypress",this._onKeypress)};B.prototype._onUserMediaError=function(){this.$videoPlaceholder.find(".no-access").removeClass("hidden");this.$videoPlaceholder.find(".grant-access").addClass("hidden")};B.prototype._onKeypress=function(H){if(String.fromCharCode(H.which).toLowerCase()==="m"){this._takePhoto(true)}};B.prototype._onTakePhotoClicked=function(){this._takePhoto(false)};B.prototype._takePhoto=function(I){var H=this;if(this.isStreaming&&!this.$takePhoto.is(":disabled")){if(this.opts.countdown){this.$takePhoto.prop("disabled",true);this._doCountdown().always(function(){H.$takePhoto.prop("disabled",false);H.$countdown.addClass("hidden")}).done(function(){H._capture(I)})}else{this._capture(I)}}};B.prototype._setVideoSize=function(){this.height=this.video.videoWidth?this.video.videoHeight/(this.video.videoWidth/this.width):this.width*(240/320);this.video.setAttribute("width",this.width);this.video.setAttribute("height",this.height)};B.prototype._doCountdown=function(){var H=this;var J=3;var K=G.Deferred();this.$countdown.removeClass("hidden");function I(){if(H.isStreaming){if(J){H.$countdown.text(J--);setTimeout(I,1000)}else{K.resolve()}}else{K.reject()}}I();return K};B.prototype._capture=function(J){this._setVideoSize();var I=G("<canvas/>").attr("width",this.width).attr("height",this.height)[0];var H=I.getContext("2d");this.snapSound.play();var L=G('<div class="flasher"/>');C.LayerManager.global.push(L);L.on("animationend webkitAnimationEnd MSAnimationEnd oanimationend",function(){C.LayerManager.global.popUntil(L);L.remove()}).appendTo("body");H.drawImage(this.video,0,0,this.width,this.height);if(J&&E.isReady()){E.addToFaces(I)}if(this.opts.mirror){I=this._mirrorCanvas(I)}var K=I.toDataURL("image/png");this.opts.onCapture(K);this.$takePhoto.tipsy("hide")};B.prototype._mirrorCanvas=function(J){var I=G("<canvas/>").attr("width",this.width).attr("height",this.height)[0];var H=I.getContext("2d");H.translate(this.width,0);H.scale(-1,1);H.drawImage(J,0,0);return I};return B});;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:webcam-capture', location = '/static/widget/webcam-capture/webcam-capture.soy' */
// This file was automatically generated from webcam-capture.soy.
// Please don't edit this file by hand.

/**
 * @fileoverview Templates in namespace stash.widget.
 */

if (typeof stash == 'undefined') { var stash = {}; }
if (typeof stash.widget == 'undefined') { stash.widget = {}; }


stash.widget.webcamCapture = function(opt_data, opt_ignored) {
  return '<div class="webcam-capture"><div class="video-container"><video class="video"></video><div class="countdown hidden"></div></div><div class="video-placeholder"><div class="grant-access"><span class="placeholder-icon"></span><div class="message">' + soy.$$escapeHtml("Grant access to your webcam, usually located at the top of this window.") + '</div></div>' + aui.message.warning({extraClasses: 'no-access hidden', titleContent: "We were unable to access your webcam", content: '' + soy.$$filterNoAutoescape(AJS.format("Make sure it is connected. You may also need to grant access to it by clicking on the webcam icon in your browser\x27\x27s address bar. {0}Retry{1}",'<a class="retry-webcam" href="#">','</a>'))}) + '</div><div class="webcam-buttons">' + aui.buttons.button({text: '', iconClass: 'icon-take-photo', iconType: 'aui', extraClasses: 'take-photo', extraAttributes: {type: 'button', title: "Need a disguise? Press \x27m\x27"}}) + '</div></div>';
};
if (goog.DEBUG) {
  stash.widget.webcamCapture.soyTemplateName = 'stash.widget.webcamCapture';
}
;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:client-file-handlers', location = '/static/widget/client-file-handlers/client-file-handler.js' */
define("widget/client-file-handlers/client-file-handler",["jquery","lodash","util/events"],function(D,B,C){function A(E){return this.init(E)}C.addLocalEventMixin(A.prototype);A.typeFilters={all:/.*/,application:/^application\/.*/i,audio:/^audio\/.*/i,image:/^image\/.*/i,imageWeb:/^image\/(jpeg|png|gif)$/i,text:/^text\/.*/i,video:/^video\/.*/i};A.prototype.defaults={fileTypeFilter:A.typeFilters.all,fileCountLimit:Infinity,fileSizeLimit:10*1024*1024,onSuccess:D.noop,onError:D.noop};A.prototype.init=function(E){this.options=D.extend({},this.defaults,E);if(E&&!E.fileSizeLimit){this.options.fileSizeLimit=this.defaults.fileSizeLimit}if(E&&!E.fileCountLimit){this.options.fileCountLimit=this.defaults.fileCountLimit}B.bindAll(this,"handleFiles","filterFiles");return this};A.prototype.handleFiles=function(G,F){this.trigger("filesSelected",G);var E=this.filterFiles(G);if(E.valid.length>0){B.isFunction(this.options.onSuccess)&&this.options.onSuccess(E.valid);this.trigger("validFiles",E.valid)}else{B.isFunction(this.options.onError)&&this.options.onError(E.invalid)}if(B.keys(E.invalid).length){this.trigger("invalidFiles",E.invalid)}};A.prototype.filterFiles=function(G){var H=B.isRegExp(this.options.fileTypeFilter)?this.options.fileTypeFilter:this.defaults.fileTypeFilter;var F=this.options.fileSizeLimit;var E=B.reduce(G,function(I,J){if(!H.test(J.type)){I.invalid.byType=I.invalid.byType?I.invalid.byType.concat(J):[J]}else{if(J.size>F){I.invalid.bySize=I.invalid.bySize?I.invalid.bySize.concat(J):[J]}else{I.valid.push(J)}}return I},{valid:[],invalid:{}});if(E.valid.length>this.options.fileCountLimit){E.invalid.byCount=E.valid.slice(this.options.fileCountLimit);E.valid=E.valid.slice(0,this.options.fileCountLimit)}return E};return A});;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:client-file-handlers', location = '/static/widget/client-file-handlers/client-file-uploader.js' */
define("widget/client-file-handlers/client-file-uploader",["jquery","lodash","util/ajax","util/feature-detect","widget/client-file-handlers/client-file-handler"],function(F,D,E,B,A){function C(G){if(!C.isSupported()){throw new Error("ClientFileUploader requires FormData support")}this.init.apply(this,arguments)}C.isSupported=B.formData;C.typeFilters=A.typeFilters;F.extend(C.prototype,A.prototype);C.prototype.defaults=F.extend({},A.prototype.defaults,{url:undefined,fieldName:"file",fileSizeLimit:undefined});C.prototype.init=function(G){D.bindAll(this,"uploadFiles");A.prototype.init.call(this,G);this.uploads=[];this.on("validFiles",this.uploadFiles)};C.prototype.uploadFiles=function(H){var G=this;D.forEach(H,function(J){var K=new FormData();var I=F.Deferred();K.append(G.options.fieldName,J,J.name);var L=E.ajax({url:G.options.url,type:"POST",data:K,xhr:function(){var N=F.ajaxSettings.xhr();var M=N.upload?N.upload:N;M.addEventListener("progress",function(O){if(O.lengthComputable){I.notify(Math.max(0,Math.min(100,100*O.loaded/O.total)))}});return N},statusCode:{500:false},processData:false,contentType:false}).done(function(){I.notify(100);I.resolveWith(this,arguments)}).fail(function(){I.rejectWith(this,arguments)}).always(function(){G.uploads=D.without(G.uploads,L)});I.promise(L);G.uploads.push(L);G.trigger("uploadStarted",L,J)})};C.prototype.destroy=function(){D.invoke(this.uploads,"abort");this.uploads=[]};return C});;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:client-file-handlers', location = '/static/widget/client-file-handlers/client-file-reader.js' */
define("widget/client-file-handlers/client-file-reader",["jquery","lodash","util/feature-detect","widget/client-file-handlers/client-file-handler"],function(F,E,C,B){var D={ArrayBuffer:"readAsArrayBuffer",BinaryString:"readAsBinaryString",DataURL:"readAsDataURL",Text:"readAsText"};function A(G){if(!A.isSupported()){throw new Error("ClientFileReader requires FileReaderAPI support")}return this.init(G)}A.isSupported=C.fileReader;F.extend(A.prototype,B.prototype);A.readMethods={ArrayBuffer:"ArrayBuffer",BinaryString:"BinaryString",DataURL:"DataURL",Text:"Text"};A.typeFilters=B.typeFilters;A.prototype.defaults=F.extend({},B.prototype.defaults,{readMethod:A.readMethods.DataURL,onRead:F.noop});A.prototype.init=function(G){E.bindAll(this,"onSuccess","readFile");B.prototype.init.call(this,G);this.options.onSuccess=this.onSuccess;return this};A.prototype.onSuccess=function(H){var G=E.has(D,this.options.readMethod)?D[this.options.readMethod]:undefined;if(G){E.each(H,E.bind(function(J){var I=new FileReader();I.onload=E.bind(this.readFile,this,J);I[G](J)},this))}};A.prototype.readFile=function(G,H){E.isFunction(this.options.onRead)&&this.options.onRead(H.target.result,G)};return A});;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:client-file-handlers', location = '/static/widget/client-file-handlers/client-file-iframe-uploader.js' */
define("widget/client-file-handlers/client-file-iframe-uploader",["jquery","lodash","util/deprecation","widget/client-file-handlers/client-file-handler"],function(F,C,E,B){var A=E.getMessageLogger("widget/client-file-handlers/client-file-iframe-uploader",null,"3.7","4.0");function D(G){A();return this.init(G)}F.extend(D.prototype,B.prototype);D.prototype.defaults=F.extend({},B.prototype.defaults,{uploadURL:"",uploadFieldName:"file",onUpload:F.noop,responseHandler:function(H,I){var G;try{G=JSON.parse(F(H).html())}catch(J){I.reject()}if(G){I.resolve(G)}else{I.reject()}}});D.prototype.states={IN_PROGRESS:"IN_PROGRESS",IDLE:"IDLE"};D.prototype.init=function(G){C.bindAll(this,"createHiddenIframe","onIframeLoad","handleFiles","setStateInProgress","setStateIdle","cancelUpload");this.options=F.extend({},this.defaults,G);this.$uploadIframe=this.createHiddenIframe();if(this.options.cancelTrigger){this.$cancelTrigger=F(this.options.cancelTrigger);this.$cancelTrigger.click(C.bind(function(){this.cancelUpload()},this))}this.state=this.states.IDLE;return this};D.prototype.createHiddenIframe=function(){return F("<iframe>").attr("name","hidden-upload-iframe").hide().appendTo(document.body).on("load",this.onIframeLoad)};D.prototype.onIframeLoad=function(G){if(this.state===this.states.IN_PROGRESS){this.requestPromise.done(this.options.onUpload).fail(this.options.onError);this.options.responseHandler(G.target.contentDocument.body,this.requestPromise)}};D.prototype.handleFiles=function(I,G){if(this.state===this.states.IN_PROGRESS){this.cancelUpload()}if(!this.$fileSourceElem){this.$fileSourceElem=F(G);this.$fileSourceElem.attr("name",this.options.uploadFieldName);if(!this.$fileSourceElem.prop("form")){this.$fileSourceElem.wrap("<form>")}var J=F(this.$fileSourceElem.prop("form"));J.addClass("hidden-upload-form").attr("action",this.options.uploadURL).attr("method","post").attr("enctype","multipart/form-data").attr("encoding","multipart/form-data").attr("target",this.$uploadIframe.attr("name"));this.$spinner=F('<div class="spinner"></div>').insertBefore(this.$fileSourceElem);if(F.isPlainObject(this.options.extraData)){C.each(this.options.extraData,function(L,K){F('<input type="hidden">').attr("name",K).val(L).appendTo(J)})}}var H=F(this.$fileSourceElem.prop("form"));if(this.options.xsrfToken&&this.options.xsrfToken.name&&this.options.xsrfToken.value){H.append("<input type='hidden' name='"+this.options.xsrfToken.name+"' value='"+this.options.xsrfToken.value+"'/>")}H.submit();this.requestPromise=F.Deferred();this.requestPromise.always(this.setStateIdle);this.setStateInProgress()};D.prototype.setStateInProgress=function(){this.state=this.states.IN_PROGRESS;if(this.$spinner){this.$spinner.spin()}if(this.$fileSourceElem){this.$fileSourceElem.attr("disabled","disabled")}};D.prototype.setStateIdle=function(){this.state=this.states.IDLE;if(this.$spinner){this.$spinner.spinStop()}if(this.$fileSourceElem){this.$fileSourceElem.removeAttr("disabled")}this.requestPromise=null};D.prototype.cancelUpload=function(){this.$uploadIframe.remove();this.setStateIdle();this.$uploadIframe=this.createHiddenIframe()};return D});;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:drag-drop-file-target', location = '/static/widget/drag-drop-file-target/drag-drop-file-target.js' */
define("widget/drag-drop-file-target",["jquery","lodash","util/events"],function(D,A,B){function C(E,F){return this.init.apply(this,arguments)}C.prototype.getDefaults=function(){return{activeDropTargetClass:"active-drop-target",uploadPrompt:"Drag a file here to upload",clientFileHandler:null}};C.prototype.init=function(E,F){A.bindAll(this,"onDragOver","onDragEnd","onDrop");this.$target=D(E);this.options=D.extend({},this.getDefaults(),F);this.$target.attr("data-upload-prompt",this.options.uploadPrompt);this._destroyables=[];this._destroyables.push(B.chainWith(this.$target).on("dragover",this.onDragOver).on("dragleave",this.onDragEnd).on("dragend",this.onDragEnd).on("drop",this.onDrop))};C.prototype.onDragOver=function(E){E.preventDefault();this.$target.addClass(this.options.activeDropTargetClass)};C.prototype.onDragEnd=function(E){E.preventDefault();this.$target.removeClass(this.options.activeDropTargetClass)};C.prototype.onDrop=function(E){E.preventDefault();E.originalEvent.preventDefault();this.$target.removeClass(this.options.activeDropTargetClass);if(this.options.clientFileHandler){this.options.clientFileHandler.handleFiles(E.originalEvent.dataTransfer.files,E.originalEvent.target)}};C.prototype.destroy=function(){this.$target.removeAttr("data-upload-prompt");this.$target.removeClass(this.options.activeDropTargetClass);A.invoke(this._destroyables,"destroy")};return C});;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:upload-interceptor', location = '/static/widget/upload-interceptor/upload-interceptor.js' */
define("widget/upload-interceptor",["jquery","lodash","util/events"],function(D,A,B){function C(E,F){this.init.apply(this,arguments)}C.prototype.init=function(E,F){A.bindAll(this,"onSelectFile");this.$el=D(E);this.clientFileHandler=F;this._destroyables=[];this._destroyables.push(B.chainWith(this.$el).on("change",this.onSelectFile))};C.prototype.onSelectFile=function(F){var E=F.target;if((E.value!==""||(E.files&&E.files.length))&&this.clientFileHandler){this.clientFileHandler.handleFiles(E.files,E);D(E).wrap("<form>").parent("form").trigger("reset").end().unwrap()}};C.prototype.destroy=function(){A.invoke(this._destroyables,"destroy")};return C});;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:faux-upload-field', location = '/static/widget/faux-upload-field/faux-upload-field.js' */
define("widget/faux-upload-field",["jquery","lodash","util/dom-event","util/events","util/navigator","widget/client-file-handlers/client-file-handler","widget/upload-interceptor"],function(H,D,G,E,C,A,F){function B(I,J){this.init.apply(this,arguments)}B.prototype.defaults={clientFileHandler:null,accept:null,allowMultiple:false};B.prototype.init=function(J,K){this.$el=H(J);this._destroyables=[];switch(K.accept){case A.typeFilters.audio:K.accept="audio/*";break;case A.typeFilters.image:K.accept="image/*";break;case A.typeFilters.imageWeb:K.accept="image/jpeg, image/gif, image/png";break;case A.typeFilters.video:K.accept="video/*";break}this.options=H.extend({},this.defaults,K);var I=D.uniqueId("faux-upload-field-");var L=H(stash.widget.fauxUploadField.uploadField({id:I,accept:this.options.accept,allowMultiple:this.options.allowMultiple})).hide().insertAfter(this.$el);this.$el.tooltip({gravity:H.fn.tipsy.autoNS});if(this.$el.is("label")){this.$el.attr("for",I)}else{if(C.isIE()){this.$el.hide();L.show()}else{this._destroyables.push(E.chainWith(this.$el).on("click",G.preventDefault(L.click.bind(L))))}}if(this.options.clientFileHandler){this._destroyables.push(new F(L,this.options.clientFileHandler))}};B.prototype.destroy=function(){D.invoke(this._destroyables,"destroy")};return B});;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:faux-upload-field', location = '/static/widget/faux-upload-field/faux-upload-field.soy' */
// This file was automatically generated from faux-upload-field.soy.
// Please don't edit this file by hand.

/**
 * @fileoverview Templates in namespace stash.widget.fauxUploadField.
 */

if (typeof stash == 'undefined') { var stash = {}; }
if (typeof stash.widget == 'undefined') { stash.widget = {}; }
if (typeof stash.widget.fauxUploadField == 'undefined') { stash.widget.fauxUploadField = {}; }


stash.widget.fauxUploadField.uploadField = function(opt_data, opt_ignored) {
  opt_data = opt_data || {};
  return '<input type="file" ' + ((opt_data.id) ? ' id="' + soy.$$escapeHtml(opt_data.id) + '"' : '') + 'class="faux-upload-field ' + ((opt_data.extraClasses) ? soy.$$escapeHtml(opt_data.extraClasses) : '') + '"' + ((opt_data.accept) ? ' accept="' + soy.$$escapeHtml(opt_data.accept) + '"' : '') + ((opt_data.allowMultiple) ? ' multiple' : '') + '/>';
};
if (goog.DEBUG) {
  stash.widget.fauxUploadField.uploadField.soyTemplateName = 'stash.widget.fauxUploadField.uploadField';
}


stash.widget.fauxUploadField.labelButton = function(opt_data, opt_ignored) {
  return '' + aui.buttons.button({tagName: 'label', extraClasses: 'faux-upload-label-button ' + opt_data.extraClasses, text: opt_data.text});
};
if (goog.DEBUG) {
  stash.widget.fauxUploadField.labelButton.soyTemplateName = 'stash.widget.fauxUploadField.labelButton';
}
;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:fd-slider', location = '/static/bower/fd-slider/js/fd-slider.js' */
/* Unobtrusive Slider Control / HTML5 Input Range polyfill - MIT/GPL2 @freqdec */
var fdSlider=(function(){var sliders={},uniqueid=0,mouseWheelEnabled=true,fullARIA=true,describedBy="fd-slider-describedby",varSetRules={onfocus:true,onvalue:true},noRangeBar=false,html5Animation="jump",isOpera=Object.prototype.toString.call(window.opera)==="[object Opera]",fpRegExp=/^([\-]{0,1}[0-9]+(\.[0-9]+){0,1})$/,stepRegExp=/^([0-9]+(\.[0-9]+){0,1})$/;var parseJSON=function(str){if(typeof str!=="string"||str===""){return{}}try{if(typeof JSON==="object"&&typeof (JSON.parse)==="function"){return JSON.parse(str)}else{if(/mousewheelenabled|fullaria|describedby|norangebar|html5animation|varsetrules/.test(str.toLowerCase())){var f=Function(["var document,top,self,window,parent,Number,Date,Object,Function,","Array,String,Math,RegExp,Image,ActiveXObject;","return (",str.replace(/<\!--.+-->/gim,"").replace(/\bfunction\b/g,"function-"),");"].join(""));return f()}}}catch(e){}return{err:"Could not parse the JSON object"}};var affectJSON=function(json){if(typeof json!=="object"){return }for(var key in json){value=json[key];switch(key.toLowerCase()){case"mousewheelenabled":mouseWheelEnabled=!!value;break;case"fullaria":fullARIA=!!value;break;case"describedby":describedBy=String(value);break;case"norangebar":noRangeBar=!!value;break;case"html5animation":html5Animation=String(value).search(/^(jump|tween|timed)$/i)!=-1?String(value).toLowerCase():"jump";break;case"varsetrules":if("onfocus" in value){varSetRules.onfocus=!!value.onfocus}if("onvalue" in value){varSetRules.onvalue=!!value.onvalue}break}}};var addEvent=function(obj,type,fn){if(obj.addEventListener){obj.addEventListener(type,fn,true)}else{if(obj.attachEvent){obj.attachEvent("on"+type,fn)}}};var removeEvent=function(obj,type,fn){try{if(obj.removeEventListener){obj.removeEventListener(type,fn,true)}else{if(obj.detachEvent){obj.detachEvent("on"+type,fn)}}}catch(err){}};var stopEvent=function(e){e=e||window.event;if(e.stopPropagation){e.stopPropagation();e.preventDefault();
/*@cc_on@*/
/*@if(@_win32)
        e.cancelBubble = true;
        e.returnValue = false;
        /*@end@*/
}return false};var preventDefault=function(e){e=e||window.event;if(e.preventDefault){e.preventDefault();return }e.returnValue=false};var addClass=function(e,c){if(new RegExp("(^|\\s)"+c+"(\\s|$)").test(e.className)){return }e.className+=(e.className?" ":"")+c};var removeClass=function(e,c){e.className=!c?"":e.className.replace(new RegExp("(^|\\s)"+c+"(\\s|$)")," ").replace(/^\s\s*/,"").replace(/\s\s*$/,"")};var getValueSet=function(){var obj={};for(var id in sliders){obj[id]=sliders[id].getValueSet()}return obj};var setValueSet=function(sliderId,tf){sliders[sliderId].setValueSet(!!tf)};var sliderExists=function(slider){return !!(slider in sliders&&sliders.hasOwnProperty(slider))};var createSlider=function(options){if(!options||!options.inp||!options.inp.tagName||options.inp.tagName.search(/^input|select/i)==-1){return false}options.html5Shim=false;if(options.inp.tagName.toLowerCase()=="select"){if(options.inp.options.length<2){return false}options.min=0;options.max=options.inp.options.length-1;options.step=1;options.precision=0;options.scale=false;options.forceValue=true}else{if(String(options.inp.type).search(/^(text|range)$/i)==-1){return false}options.min=options.min&&String(options.min).search(fpRegExp)!=-1?+options.min:0;options.max=options.max&&String(options.max).search(fpRegExp)!=-1?+options.max:100;options.step=options.step&&String(options.step).search(stepRegExp)!=-1?options.step:1;options.precision=options.precision&&String(options.precision).search(/^[0-9]+$/)!=-1?options.precision:(String(options.step).search(/\.([0-9]+)$/)!=-1?String(options.step).match(/\.([0-9]+)$/)[1].length:0);options.scale=options.scale||false;options.forceValue=("forceValue" in options)?!!options.forceValue:false;options.userSnap=("userSnap" in options)?!!options.userSnap:false}options.ariaFormat=("ariaFormat" in options)&&typeof options.ariaFormat=="function"?options.ariaFormat:false;options.maxStep=options.maxStep&&String(options.maxStep).search(stepRegExp)!=-1?+options.maxStep:+options.step*2;options.classNames=options.classNames||"";options.callbacks=options.callbacks||false;destroySingleSlider(options.inp.id);sliders[options.inp.id]=new fdRange(options);return true};var getAttribute=function(elem,att){return elem.getAttribute(att)||""};var init=function(){var inputs=document.getElementsByTagName("input"),options;for(var i=0,inp;inp=inputs[i];i++){if(inp.tagName.toLowerCase()=="input"&&inp.type.toLowerCase()=="text"&&(getAttribute(inp,"min")&&getAttribute(inp,"min").search(fpRegExp)!=-1||getAttribute(inp,"max")&&getAttribute(inp,"max").search(fpRegExp)!=-1||getAttribute(inp,"step")&&getAttribute(inp,"step").search(/^(any|([0-9]+(\.[0-9]+){0,1}))$/i)!=-1)){if(inp.id&&document.getElementById("fd-slider-"+inp.id)){continue}else{if(inp.id&&!document.getElementById("fd-slider-"+inp.id)){destroySingleSlider(inp.id)}}if(!inp.id){inp.id="fd-slider-form-elem-"+uniqueid++}options={inp:inp,callbacks:[],animation:html5Animation,vertical:getAttribute(inp,"data-fd-slider-vertical")?true:(inp.offsetHeight>inp.offsetWidth),classNames:getAttribute(inp,"data-fd-slider-vertical"),html5Shim:true};if(options.vertical&&!getAttribute(inp,"data-fd-slider-vertical")){options.inpHeight=inp.offsetHeight}options.min=getAttribute(inp,"min")||0;options.max=getAttribute(inp,"max")||100;options.step=getAttribute(inp,"step").search(/^any$/i)!=-1?options.max-options.min:getAttribute(inp,"step").search(stepRegExp)!=-1?inp.getAttribute("step"):1;options.precision=String(options.step).search(/\.([0-9]+)$/)!=-1?String(options.step).match(/\.([0-9]+)$/)[1].length:0;options.maxStep=options.step*2;destroySingleSlider(options.inp.id);sliders[options.inp.id]=new fdRange(options)}}return true};var destroySingleSlider=function(id){if(id in sliders&&sliders.hasOwnProperty(id)){sliders[id].destroy();delete sliders[id];return true}return false};var destroyAllsliders=function(e){for(var slider in sliders){if(sliders.hasOwnProperty(slider)){sliders[slider].destroy()}}sliders=[]};var unload=function(e){destroyAllsliders();sliders=null};var resize=function(e){for(var slider in sliders){if(sliders.hasOwnProperty(slider)){sliders[slider].onResize()}}};var onDomReady=function(){removeOnLoadEvent();init()};var removeOnLoadEvent=function(){removeEvent(window,"load",init)};function fdRange(options){var inp=options.inp,disabled=false,tagName=inp.tagName.toLowerCase(),min=+options.min,max=+options.max,rMin=+options.min,rMax=+options.max,range=Math.abs(max-min),step=tagName=="select"?1:+options.step,maxStep=options.maxStep?+options.maxStep:step*2,precision=options.precision||0,steps=Math.ceil(range/step),scale=options.scale||false,hideInput=!!options.hideInput,animation=options.animation||"",vertical=!!options.vertical,callbacks=options.callbacks||{},classNames=options.classNames||"",html5Shim=!!options.html5Shim,defaultVal=max<min?min:min+((max-min)/2),resetDef=tagName=="select"?inp.selectedIndex:inp.defaultValue||defaultVal,forceValue=html5Shim||!!options.forceValue,inpHeight=html5Shim&&vertical&&("inpHeight" in options)?options.inpHeight:false,ariaFormat=!html5Shim&&options.ariaFormat?options.ariaFormat:false,userSnap=!html5Shim&&!(tagName=="select")&&("userSnap" in options)?!!options.userSnap:false,userInput=false,timer=null,kbEnabled=true,initialVal=tagName=="select"?inp.selectedIndex:inp.value,sliderH=0,sliderW=0,tweenX=0,tweenB=0,tweenC=0,tweenD=0,frame=0,x=0,y=0,rMaxPx=0,rMinPx=0,handlePos=0,destPos=0,mousePos=0,stepPx=0,userSet=false,touchEvents=false,outerWrapper,innerWrapper,ieBlur,handle,rangeBar,bar;if(tagName=="input"&&forceValue&&!inp.defaultValue){inp.defaultValue=getWorkingValueFromInput()}if(max<min){step=-Math.abs(step);maxStep=-Math.abs(maxStep)}if(scale){scale[100]=max}function valueSet(tf){tf=!!tf;if(tf!=userSet){userSet=tf;valueToPixels(getWorkingValueFromInput())}}function disableSlider(noCallback){if(disabled&&!noCallback){return }try{setTabIndex(handle,-1);removeEvent(handle,"focus",onFocus);removeEvent(handle,"blur",onBlur);if(!isOpera){removeEvent(handle,"keydown",onKeyDown);removeEvent(handle,"keypress",onKeyPress)}else{removeEvent(handle,"keypress",onKeyDown)}removeEvent(outerWrapper,"mouseover",onMouseOver);removeEvent(outerWrapper,"mouseout",onMouseOut);removeEvent(outerWrapper,"mousedown",onMouseDown);removeEvent(outerWrapper,"touchstart",onMouseDown);if(mouseWheelEnabled){if(window.addEventListener&&!window.devicePixelRatio){window.removeEventListener("DOMMouseScroll",trackMouseWheel,false)}else{removeEvent(document,"mousewheel",trackMouseWheel);removeEvent(window,"mousewheel",trackMouseWheel)}}}catch(err){}removeClass(innerWrapper,"fd-slider-focused");removeClass(innerWrapper,"fd-slider-active");addClass(innerWrapper,"fd-slider-disabled");outerWrapper.setAttribute("aria-disabled",true);inp.disabled=disabled=true;clearTimeout(timer);if(!noCallback){callback("disable")}}function enableSlider(noCallback){if(!disabled&&!noCallback){return }setTabIndex(handle,0);addEvent(handle,"focus",onFocus);addEvent(handle,"blur",onBlur);if(!isOpera){addEvent(handle,"keydown",onKeyDown);addEvent(handle,"keypress",onKeyPress)}else{addEvent(handle,"keypress",onKeyDown)}addEvent(outerWrapper,"touchstart",onMouseDown);addEvent(outerWrapper,"mousedown",onMouseDown);addEvent(outerWrapper,"mouseover",onMouseOver);addEvent(outerWrapper,"mouseout",onMouseOut);removeClass(innerWrapper,"fd-slider-disabled");outerWrapper.setAttribute("aria-disabled",false);inp.disabled=disabled=touchEvents=false;if(!noCallback){callback("enable")}}function destroySlider(){clearTimeout(timer);ieBlur=bar=handle=outerWrapper=innerWrapper=timer=null;callback("destroy");callbacks=null}function redraw(){locate();try{var sW=outerWrapper.offsetWidth,sH=outerWrapper.offsetHeight,hW=handle.offsetWidth,hH=handle.offsetHeight,bH=bar.offsetHeight,bW=bar.offsetWidth,mPx=vertical?sH-hH:sW-hW;stepPx=mPx/steps;rMinPx=Math.max(scale?percentToPixels(valueToPercent(rMin)):Math.abs((rMin-min)/step)*stepPx,0);rMaxPx=Math.min(scale?percentToPixels(valueToPercent(rMax)):Math.abs((rMax-min)/step)*stepPx,Math.floor(vertical?sH-hH:sW-hW));sliderW=sW;sliderH=sH;valueToPixels(forceValue?getWorkingValueFromInput():(tagName=="select"?inp.selectedIndex:parseFloat(inp.value)),false)}catch(err){}callback("redraw")}function callback(type){if(!html5Shim){if(callbacks.hasOwnProperty(type)){var cbObj={userSet:userSet,disabled:disabled,elem:inp,value:tagName=="select"?inp.options[inp.selectedIndex].value:inp.value};for(var i=0,func;func=callbacks[type][i];i++){func.call(inp,cbObj)}}}else{if(type.match(/^(blur|focus|change)$/i)){var e;if(typeof (document.createEvent)!="undefined"){e=document.createEvent("HTMLEvents");e.initEvent(type,true,true);inp.dispatchEvent(e)}else{if(typeof (document.createEventObject)!="undefined"){try{e=document.createEventObject();inp.fireEvent("on"+type.toLowerCase(),e)}catch(err){}}}}}}function onFocus(e){addClass(innerWrapper,"fd-slider-focused");if(varSetRules.onfocus){userSet=true;valueToPixels(getWorkingValueFromInput())}if(mouseWheelEnabled){addEvent(window,"DOMMouseScroll",trackMouseWheel);addEvent(document,"mousewheel",trackMouseWheel);if(!isOpera){addEvent(window,"mousewheel",trackMouseWheel)}}callback("focus");return true}function onBlur(e){removeClass(innerWrapper,"fd-slider-focused");if(mouseWheelEnabled){removeEvent(document,"mousewheel",trackMouseWheel);removeEvent(window,"DOMMouseScroll",trackMouseWheel);if(!isOpera){removeEvent(window,"mousewheel",trackMouseWheel)}}kbEnabled=true;callback("blur")}function trackMouseWheel(e){if(!kbEnabled){return }e=e||window.event;var delta=0,value;if(e.wheelDelta){delta=e.wheelDelta/120;if(isOpera&&window.opera.version()<9.2){delta=-delta}}else{if(e.detail){delta=-e.detail/3}}if(vertical){delta=-delta}if(delta){value=getWorkingValueFromInput();value+=(delta<0)?-step:step;userSet=true;valueToPixels(getValidValue(value))}preventDefault(e)}function onKeyPress(e){e=e||window.event;if((e.keyCode>=33&&e.keyCode<=40)||!kbEnabled||e.keyCode==45||e.keyCode==46){return stopEvent(e)}return true}function onKeyDown(e){if(!kbEnabled){return true}e=e||window.event;var kc=e.keyCode!==null?e.keyCode:e.charCode,value;if(kc<33||(kc>40&&(kc!=45&&kc!=46))){return true}value=getWorkingValueFromInput();if(kc==37||kc==40||kc==46||kc==34){value-=(e.ctrlKey||kc==34?+maxStep:+step)}else{if(kc==39||kc==38||kc==45||kc==33){value+=(e.ctrlKey||kc==33?+maxStep:+step)}else{if(kc==35){value=rMax}else{if(kc==36){value=rMin}}}}userSet=true;valueToPixels(getValidValue(value));callback("update");preventDefault(e)}function onMouseOver(e){addClass(innerWrapper,"fd-slider-hover")}function onMouseOut(e){removeClass(innerWrapper,"fd-slider-hover")}function onMouseDown(e){e=e||window.event;preventDefault(e);var targ;if(e.target){targ=e.target}else{if(e.srcElement){targ=e.srcElement}}if(targ&&targ.nodeType==3){targ=targ.parentNode}if(e.touches){if(e.targetTouches&&e.targetTouches.length!=1){return false}e=e.touches[0];touchEvents=true}clearTimeout(timer);timer=null;kbEnabled=false;userSet=true;if(targ.className.search("fd-slider-handle")!=-1){mousePos=vertical?e.clientY:e.clientX;handlePos=parseInt(vertical?handle.offsetTop:handle.offsetLeft)||0;trackMouse(e);if(!touchEvents){addEvent(document,"mousemove",trackMouse);addEvent(document,"mouseup",stopDrag)}else{addEvent(document,"touchmove",trackMouse);addEvent(document,"touchend",stopDrag);removeEvent(outerWrapper,"mousedown",onMouseDown)}addClass(innerWrapper,"fd-slider-active");addClass(document.body,"fd-slider-drag-"+(vertical?"vertical":"horizontal"));callback("dragstart")}else{locate();var posx=0;if(e.pageX||e.pageY){posx=vertical?e.pageY:e.pageX}else{if(e.clientX||e.clientY){posx=vertical?e.clientY+document.body.scrollTop+document.documentElement.scrollTop:e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft}}posx-=vertical?y+Math.round(handle.offsetHeight/2):x+Math.round(handle.offsetWidth/2);posx=snapToPxValue(posx);if(animation=="tween"){addClass(innerWrapper,"fd-slider-active");tweenTo(posx)}else{if(animation=="timed"){addClass(innerWrapper,"fd-slider-active");addEvent(document,touchEvents?"touchend":"mouseup",onDocMouseUp);destPos=posx;onTimer()}else{pixelsToValue(posx)}}}return false}function onDocMouseUp(e){e=e||window.event;preventDefault(e);removeEvent(document,touchEvents?"touchend":"mouseup",onDocMouseUp);removeClass(innerWrapper,"fd-slider-active");clearTimeout(timer);timer=null;kbEnabled=true;return false}function stopDrag(e){e=e||window.event;preventDefault(e);if(touchEvents){removeEvent(document,"touchmove",trackMouse);removeEvent(document,"touchend",stopDrag)}else{removeEvent(document,"mousemove",trackMouse);removeEvent(document,"mouseup",stopDrag)}kbEnabled=true;removeClass(document.body,"fd-slider-drag-"+(vertical?"vertical":"horizontal"));removeClass(innerWrapper,"fd-slider-active");callback("dragend");return false}function trackMouse(e){e=e||window.event;preventDefault(e);if(e.touches){if(e.targetTouches&&e.targetTouches.length!=1){return false}e=e.touches[0]}pixelsToValue(snapToPxValue(handlePos+(vertical?e.clientY-mousePos:e.clientX-mousePos)));return false}function increment(inc){var value=getWorkingValueFromInput();userSet=true;value+=inc*step;valueToPixels(getValidValue(value))}function locate(){var curleft=0,curtop=0,obj=outerWrapper;try{do{curleft+=obj.offsetLeft;curtop+=obj.offsetTop}while(obj=obj.offsetParent)}catch(err){}x=curleft;y=curtop}function onTimer(){var xtmp=parseInt(vertical?handle.offsetTop:handle.offsetLeft,10);xtmp=Math.round((destPos<xtmp)?Math.max(destPos,Math.floor(xtmp-stepPx)):Math.min(destPos,Math.ceil(xtmp+stepPx)));pixelsToValue(snapToPxValue(xtmp));if(xtmp!=destPos){timer=setTimeout(onTimer,steps>20?50:100)}else{kbEnabled=true;removeClass(innerWrapper,"fd-slider-active");callback("finalise")}}var tween=function(){frame++;var c=tweenC,d=20,t=frame,b=tweenB,x=Math.ceil((t==d)?b+c:c*(-Math.pow(2,-10*t/d)+1)+b);pixelsToValue(t==d?tweenX:x);if(t!=d){callback("move");timer=setTimeout(tween,20)}else{clearTimeout(timer);timer=null;kbEnabled=true;removeClass(innerWrapper,"fd-slider-focused");removeClass(innerWrapper,"fd-slider-active");callback("finalise")}};function tweenTo(tx){kbEnabled=false;tweenX=parseInt(tx,10);tweenB=parseInt(vertical?handle.offsetTop:handle.offsetLeft,10);tweenC=tweenX-tweenB;tweenD=20;frame=0;if(!timer){timer=setTimeout(tween,20)}}function checkValue(value){if(isNaN(value)||value===""||typeof value=="undefined"){userSet=false;return defaultVal}else{if(value<Math.min(rMin,rMax)){userSet=false;return Math.min(rMin,rMax)}else{if(value>Math.max(rMin,rMax)){userSet=false;return Math.max(rMin,rMax)}}}userSet=true;return value}function getWorkingValueFromInput(){return getValidValue(tagName=="input"?parseFloat(inp.value):inp.selectedIndex)}function getValidValue(value){return(isNaN(value)||value===""||typeof value=="undefined")?defaultVal:Math.min(Math.max(value,Math.min(rMin,rMax)),Math.max(rMin,rMax))}function pixelsToValue(px){var val=getValidValue(scale?percentToValue(pixelsToPercent(px)):vertical?max-(Math.round(px/stepPx)*step):min+(Math.round(px/stepPx)*step));handle.style[vertical?"top":"left"]=(px||0)+"px";redrawRange();setInputValue((tagName=="select"||step==1)?Math.round(val):val)}function valueToPixels(val,updateInputValue){var clearVal=false,value;if((typeof val==="undefined"||isNaN(val)||val==="")&&tagName=="input"&&!forceValue){value=defaultVal;clearVal=true;userSet=false}else{value=checkValue(val)}handle.style[vertical?"top":"left"]=(scale?percentToPixels(valueToPercent(value)):vertical?Math.round(((max-value)/step)*stepPx):Math.round(((value-min)/step)*stepPx))+"px";redrawRange();if(typeof updateInputValue!==false){setInputValue(clearVal?"":value)}}function snapToPxValue(px){if(scale){return Math.max(Math.min(rMaxPx,px),rMinPx)}else{var rem=px%stepPx;if(rem&&rem>=(stepPx/2)){px+=(stepPx-rem)}else{px-=rem}if(px<Math.min(Math.abs(rMinPx),Math.abs(rMaxPx))){px=Math.min(Math.abs(rMinPx),Math.abs(rMaxPx))}else{if(px>Math.max(Math.abs(rMinPx),Math.abs(rMaxPx))){px=Math.max(Math.abs(rMinPx),Math.abs(rMaxPx))}}return Math.min(Math.max(px,0),rMaxPx)}}function percentToValue(pct){var st=0,fr=min,value;for(var s in scale){if(!scale.hasOwnProperty(s)){continue}if(pct>=st&&pct<=+s){value=fr+((pct-st)*(+scale[s]-fr))/(+s-st)}st=+s;fr=+scale[s]}return value}function valueToPercent(value){var st=0,fr=min,pct=0;for(var s in scale){if(!scale.hasOwnProperty(s)){continue}if(value>=fr&&value<=+scale[s]){pct=st+(value-fr)*(+s-st)/(+scale[s]-fr)}st=+s;fr=+scale[s]}return pct}function percentToPixels(percent){return((outerWrapper[vertical?"offsetHeight":"offsetWidth"]-handle[vertical?"offsetHeight":"offsetWidth"])/100)*percent}function pixelsToPercent(pixels){return pixels/((outerWrapper[vertical?"offsetHeight":"offsetWidth"]-outerWrapper[handle?"offsetHeight":"offsetWidth"])/100)}function setInputValue(val){callback("update");if(!userSet){addClass(innerWrapper,"fd-slider-no-value")}else{removeClass(innerWrapper,"fd-slider-no-value")}if(tagName=="select"){try{val=parseInt(val,10);if(inp.selectedIndex===val){updateAriaValues();return }inp.options[val].selected=true}catch(err){}}else{if(val!==""&&!userInput){val=(min+(Math.round((val-min)/step)*step)).toFixed(precision)}if(inp.value===val){updateAriaValues();return }inp.value=val}updateAriaValues();callback("change")}function checkInputValue(value){return !(isNaN(value)||value===""||value<Math.min(rMin,rMax)||value>Math.max(rMin,rMax))}function setSliderRange(newMin,newMax){if(rMin>rMax){newMin=Math.min(min,Math.max(newMin,newMax));newMax=Math.max(max,Math.min(newMin,newMax));rMin=Math.max(newMin,newMax);rMax=Math.min(newMin,newMax)}else{newMin=Math.max(min,Math.min(newMin,newMax));newMax=Math.min(max,Math.max(newMin,newMax));rMin=Math.min(newMin,newMax);rMax=Math.max(newMin,newMax)}if(defaultVal<Math.min(rMin,rMax)){defaultVal=Math.min(rMin,rMax)}else{if(defaultVal>Math.max(rMin,rMax)){defaultVal=Math.max(rMin,rMax)}}handle.setAttribute("aria-valuemin",rMin);handle.setAttribute("aria-valuemax",rMax);checkValue(tagName=="input"?parseFloat(inp.value):inp.selectedIndex);redraw()}function redrawRange(){if(noRangeBar){return }if(vertical){rangeBar.style.height=Math.max(1,(bar.offsetHeight-handle.offsetTop))+"px"}else{rangeBar.style.width=Math.max(1,handle.offsetLeft)+"px"}}function findLabel(){var label=false,labelList=document.getElementsByTagName("label");for(var i=0,lbl;lbl=labelList[i];i++){if((lbl.htmlFor&&lbl.htmlFor==inp.id)||(lbl.getAttribute("for")==inp.id)){label=lbl;break}}if(label&&!label.id){label.id=inp.id+"_label"}return label}function updateAriaValues(){var val=tagName=="select"?inp.options[inp.selectedIndex].value:inp.value,valTxt=ariaFormat?ariaFormat(val):tagName=="select"?(inp.options[inp.selectedIndex].text?inp.options[inp.selectedIndex].text:val):val;handle.setAttribute("aria-valuenow",val);handle.setAttribute("aria-valuetext",valTxt)}function onInputChange(e){userSet=true;userInput=userSnap;valueToPixels(tagName=="input"?parseFloat(inp.value):inp.selectedIndex);updateAriaValues();userInput=false}function onReset(e){if(tagName=="input"){inp.value=inp.defaultValue}else{inp.selectedIndex=resetDef}checkValue(tagName=="select"?inp.options[inp.selectedIndex].value:inp.value);redraw();updateAriaValues()}function valueSet(tf){userSet=!!tf}function setTabIndex(e,i){e.setAttribute(!
/*@cc_on!@*/
false?"tabIndex":"tabindex",i);e.tabIndex=i}(function(){if(html5Shim||hideInput){addClass(inp,"fd-form-element-hidden")}else{addEvent(inp,"change",onInputChange)}if(html5Shim){inp.stepUp=function(n){increment(n||1)};inp.stepDown=function(n){increment(n||-1)}}outerWrapper=document.createElement("span");outerWrapper.className="fd-slider"+(vertical?"-vertical ":" ")+classNames;outerWrapper.id="fd-slider-"+inp.id;if(vertical&&inpHeight){outerWrapper.style.height=inpHeight+"px"}innerWrapper=document.createElement("span");innerWrapper.className="fd-slider-wrapper"+(!html5Shim?" fd-slider-no-value":"");ieBlur=document.createElement("span");ieBlur.className="fd-slider-inner";bar=document.createElement("span");bar.className="fd-slider-bar";if(fullARIA){handle=document.createElement("span")}else{handle=document.createElement("a");handle.setAttribute("href","#");addEvent(handle,"click",stopEvent)}setTabIndex(handle,0);handle.className="fd-slider-handle";handle.appendChild(document.createTextNode(String.fromCharCode(160)));innerWrapper.appendChild(ieBlur);if(!noRangeBar){rangeBar=document.createElement("span");rangeBar.className="fd-slider-range";innerWrapper.appendChild(rangeBar)}innerWrapper.appendChild(bar);innerWrapper.appendChild(handle);outerWrapper.appendChild(innerWrapper);inp.parentNode.insertBefore(outerWrapper,inp);if(isOpera||
/*@cc_on!@*/
!true){handle.unselectable="on";bar.unselectable="on";ieBlur.unselectable="on";outerWrapper.unselectable="on";innerWrapper.unselectable="on";if(!noRangeBar){rangeBar.unselectable="on"}}outerWrapper.setAttribute("role","application");handle.setAttribute("role","slider");handle.setAttribute("aria-valuemin",tagName=="select"?inp.options[0].value:min);handle.setAttribute("aria-valuemax",tagName=="select"?inp.options[inp.options.length-1].value:max);var lbl=findLabel();if(lbl){handle.setAttribute("aria-labelledby",lbl.id);handle.id="fd-slider-handle-"+inp.id;
/*@cc_on@*/
/*@if(@_win32)
                lbl.setAttribute("htmlFor", handle.id);
                @else @*/
lbl.setAttribute("for",handle.id);
/*@end@*/
}if(document.getElementById(describedBy)){handle.setAttribute("aria-describedby",describedBy)}if(inp.getAttribute("disabled")==true||inp.getAttribute("disabled")=="disabled"){disableSlider(true)}else{enableSlider(true)}if(varSetRules.onvalue){userSet=true;checkValue(tagName=="input"?parseFloat(inp.value):inp.selectedIndex)}if(inp.form){addEvent(inp.form,"reset",onReset)}updateAriaValues();callback("create");redraw()})();return{onResize:function(e){if(outerWrapper.offsetHeight!=sliderH||outerWrapper.offsetWidth!=sliderW){redraw()}},destroy:function(){destroySlider()},reset:function(){valueToPixels(tagName=="input"?parseFloat(inp.value):inp.selectedIndex)},stepUp:function(n){increment(Math.abs(n)||1)},stepDown:function(n){increment(-Math.abs(n)||-1)},increment:function(n){increment(n)},disable:function(){disableSlider()},enable:function(){enableSlider()},setRange:function(mi,mx){setSliderRange(mi,mx)},getValueSet:function(){return !!userSet},setValueSet:function(tf){valueSet(tf)},checkValue:function(){if(varSetRules.onvalue){userSet=true;checkValue(tagName=="input"?parseFloat(inp.value):inp.selectedIndex)}updateAriaValues();redraw()}}}addEvent(window,"load",init);addEvent(window,"load",function(){setTimeout(function(){var slider;for(slider in sliders){sliders[slider].checkValue()}},0)});addEvent(window,"resize",resize);addEvent(window,"unload",unload);(function(){var scriptFiles=document.getElementsByTagName("script"),scriptInner=String(scriptFiles[scriptFiles.length-1].innerHTML).replace(/[\n\r\s\t]+/g," ").replace(/^\s+/,"").replace(/\s+$/,""),json=parseJSON(scriptInner);if(typeof json==="object"&&!("err" in json)){affectJSON(json)}})();
/*@cc_on@*/
/*@if (@_jscript_version < 9)
    addClass(document.documentElement, "oldie");
    /*@end@*/
return{rescanDocument:init,createSlider:function(opts){return createSlider(opts)},onDomReady:function(){onDomReady()},destroyAll:function(){destroyAllsliders()},destroySlider:function(id){return destroySingleSlider(id)},redrawAll:function(){resize()},addEvent:addEvent,removeEvent:removeEvent,stopEvent:stopEvent,increment:function(id,numSteps){if(!sliderExists(id)){return false}sliders[id].increment(numSteps)},stepUp:function(id,n){if(!sliderExists(id)){return false}sliders[id].stepUp(Math.abs(n)||1)},stepDown:function(id,n){if(!sliderExists(id)){return false}sliders[id].stepDown(-Math.abs(n)||-1)},setRange:function(id,newMin,newMax){if(!sliderExists(id)){return false}sliders[id].setRange(newMin,newMax)},updateSlider:function(id){if(!sliderExists(id)){return false}sliders[id].onResize();sliders[id].reset()},disable:function(id){if(!sliderExists(id)){return false}sliders[id].disable()},enable:function(id){if(!sliderExists(id)){return false}sliders[id].enable()},getValueSet:function(){return getValueSet()},setValueSet:function(a,tf){if(!sliderExists(id)){return false}setValueSet(a,tf)},setGlobalVariables:function(json){affectJSON(json)},removeOnload:function(){removeOnLoadEvent()}}})();;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:fd-slider', location = '/static/lib/fdslider-AMD.js' */
define("fd-slider",["util/deprecation"],function(B){var A=window.fdSlider.updateSlider;var C=window.fdSlider.onDomReady;B.obj(window.fdSlider,"fdSlider",null,"3.7","4.0");window.fdSlider._deprecatedUpdateSlider=A;window.fdSlider._deprecatedOnDomReady=C;return window.fdSlider});;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:image-explorer', location = '/static/widget/image-explorer/image-explorer.js' */
define("widget/image-explorer",["aui","fd-slider","jquery","lodash"],function(A,D,C,B){function E(G,F){this.init.apply(this,arguments)}E.scaleModes={fill:"fill",contain:"contain",containAndFill:"containAndFill"};E.zoomModes={localZoom:"localZoom",imageZoom:"imageZoom"};E.maskShapes={CIRCLE:"circle",SQUARE:"square",ROUNDED_SQUARE:"rounded-square"};E.prototype.defaults={initialScaleMode:E.scaleModes.containAndFill,zoomMode:E.zoomModes.localZoom,emptyClass:"empty",scaleMax:1};E.prototype.init=function(G,F){this.$container=G;this.$imageView=this.$container.find(".image-explorer-image-view");this.$sourceImage=this.$container.find(".image-explorer-source");this.$mask=this.$container.find(".image-explorer-mask");this.$dragDelegate=this.$container.find(".image-explorer-drag-delegate");this.$scaleSlider=this.$container.find(".image-explorer-scale-slider");this.options=C.extend({},this.defaults,F);this.imageProperties={};B.bindAll(this,"getImageSrc","setImageSrc","initImage","initDragDelegate","initScaleSlider","setInitialScale","getFillScale","getContainedScale","getCircularContainedScale","sliderValToScale","scaleToSliderVal","updateImageScale","resetImagePosition","resetScaleSlider","toggleEmpty","get$ImageView","get$SourceImage","get$Mask","get$DragDelegate","getMaskedImageProperties","showError","clearError","hasValidImage","_resetFromError","_removeError");this.toggleEmpty(true);if(this.$sourceImage[0].naturalWidth){this.toggleEmpty(false);this.initImage({target:this.$sourceImage[0]})}this.$sourceImage.on("load",this.initImage);this.initDragDelegate();this.initScaleSlider()};E.prototype.getImageSrc=function(){return(this.$sourceImage)?this.$sourceImage.attr("src"):undefined};E.prototype.setImageSrc=function(F){if(this.$sourceImage){this.$sourceImage.attr("src","");if(F){this.$sourceImage.attr("src",F)}else{this.toggleEmpty(true)}}};E.prototype.initImage=function(G){var F=G.target;this.imageProperties.naturalWidth=F.naturalWidth;this.imageProperties.naturalHeight=F.naturalHeight;this._removeError();this.toggleEmpty(false);this.setInitialScale()};E.prototype.initDragDelegate=function(){var F;this.$dragDelegate.draggable({start:B.bind(function(){F=this.$sourceImage.offset()},this),drag:B.bind(function(H,G){this.$sourceImage.offset({top:F.top+G.position.top-G.originalPosition.top,left:F.left+G.position.left-G.originalPosition.left})},this),revert:true,revertDuration:0})};E.prototype.initScaleSlider=function(){this.$scaleSlider.on("change input",B.bind(function(F){var G=this.sliderValToScale(F.target.value);this.updateImageScale(G)},this))};E.prototype.setInitialScale=function(){var J=this.$mask.width(),H=this.$mask.height(),G=this.imageProperties.naturalWidth,I=this.imageProperties.naturalHeight,F=1;this.minScale=1;switch(this.options.initialScaleMode){case E.scaleModes.fill:this.minScale=F=this.getFillScale(G,I,J,H);break;case E.scaleModes.contain:if(this.$mask.hasClass("circle-mask")){this.minScale=F=this.getCircularContainedScale(G,I,J/2)}else{this.minScale=F=this.getContainedScale(G,I,J,H)}break;case E.scaleModes.containAndFill:if(this.$mask.hasClass("circle-mask")){this.minScale=this.getCircularContainedScale(G,I,J/2)}else{this.minScale=this.getContainedScale(G,I,J,H)}F=this.getFillScale(G,I,J,H);break}this.maxScale=Math.max(F,this.options.scaleMax);this.resetScaleSlider(this.scaleToSliderVal(F));this.updateImageScale(F,E.zoomModes.imageZoom);this.resetImagePosition()};E.prototype.getFillScale=function(H,F,G,K){var J=G/H,I=K/F;return Math.max(J,I)};E.prototype.getContainedScale=function(H,F,G,K){var J=G/H,I=K/F;return Math.min(J,I)};E.prototype.getCircularContainedScale=function(G,F,J){var I=Math.atan(F/G),H=Math.cos(I)*J*2;return H/G};E.prototype.sliderValToScale=function(I){var F=this.$scaleSlider.attr("max");var H=this.$scaleSlider.attr("min");var G=I/(F-H);return this.minScale+(G*(this.maxScale-this.minScale))};E.prototype.scaleToSliderVal=function(G){var F=(G-this.minScale)/(this.maxScale-this.minScale);return F*(this.$scaleSlider.attr("max")-this.$scaleSlider.attr("min"))};E.prototype.updateImageScale=function(L,N){var K=Math.round(L*this.imageProperties.naturalWidth),F=Math.round(L*this.imageProperties.naturalHeight),H,G;N=N||this.options.zoomMode;switch(N){case E.zoomModes.imageZoom:H=-1*K/2;G=-1*F/2;break;case E.zoomModes.localZoom:var J=this.$sourceImage.width(),T=this.$sourceImage.height(),P=parseInt(this.$sourceImage.css("margin-left"),10),I=parseInt(this.$sourceImage.css("margin-top"),10),S=this.$sourceImage.position(),R=this.$imageView.width()/2,Q=this.$imageView.height()/2,O=R-S.left-P,M=Q-S.top-I,V=(O/J)*K,U=(M/T)*F;H=R-S.left-V;G=Q-S.top-U;break}this.$sourceImage.width(K).height(F).css({"margin-left":Math.round(H)+"px","margin-top":Math.round(G)+"px"})};E.prototype.resetImagePosition=function(){this.$sourceImage.css({top:"50%",left:"50%"})};E.prototype.resetScaleSlider=function(F){this.$scaleSlider.val(F).removeClass("disabled").removeAttr("disabled");var G=this.$scaleSlider.attr("id");D._deprecatedUpdateSlider(G)};E.prototype.toggleEmpty=function(F){this.$container.toggleClass(this.options.emptyClass,F)};E.prototype.get$ImageView=function(){return this.$imageView};E.prototype.get$SourceImage=function(){return this.$sourceImage};E.prototype.get$Mask=function(){return this.$mask};E.prototype.get$DragDelegate=function(){return this.$dragDelegate};E.prototype.getMaskedImageProperties=function(){var H=this.$sourceImage.width()/this.imageProperties.naturalWidth,G=this.$sourceImage.height()/this.imageProperties.naturalHeight,F=this.$mask.position(),I=this.$sourceImage.position();F.top+=parseInt(this.$mask.css("margin-top"),10);F.left+=parseInt(this.$mask.css("margin-left"),10);I.top+=parseInt(this.$sourceImage.css("margin-top"),10);I.left+=parseInt(this.$sourceImage.css("margin-left"),10);return{maskedAreaImageX:Math.round((F.left-I.left)/H),maskedAreaImageY:Math.round((F.top-I.top)/G),maskedAreaWidth:Math.round(this.$mask.width()/H),maskedAreaHeight:Math.round(this.$mask.height()/G)}};E.prototype.showError=function(H,G){this._removeError();this.toggleEmpty(true);this.$container.addClass("error");var F=C(aui.message.error({titleContent:A.escapeHtml(H),content:G||"",isCloseable:true}));F.appendTo(this.$imageView).css({"margin-top":-1*F.outerHeight()/2});F.on("messageClose",this._resetFromError);A.messages.setup()};E.prototype.clearError=function(){this._removeError();this._resetFromError()};E.prototype.hasValidImage=function(){return !!(this.getImageSrc()&&this.$sourceImage.prop("naturalWidth"))};E.prototype._resetFromError=function(){var F=this.hasValidImage();this.toggleEmpty(!F);this.$container.removeClass("error");B.isFunction(this.options.onErrorReset)&&this.options.onErrorReset(F?this.getImageSrc():undefined)};E.prototype._removeError=function(){this.$imageView.find(".aui-message-error").remove()};return E});;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:image-explorer', location = '/static/widget/image-explorer/image-explorer.soy' */
// This file was automatically generated from image-explorer.soy.
// Please don't edit this file by hand.

/**
 * @fileoverview Templates in namespace stash.widget.
 */

if (typeof stash == 'undefined') { var stash = {}; }
if (typeof stash.widget == 'undefined') { stash.widget = {}; }


stash.widget.imageExplorer = function(opt_data, opt_ignored) {
  opt_data = opt_data || {};
  return '<div class="image-explorer-container ' + ((! opt_data.imageSrc) ? 'empty' : '') + '"><div class="image-explorer-image-view" tabindex="0"><img class="image-explorer-source" ' + ((opt_data.imageSrc) ? 'src="' + soy.$$escapeHtml(opt_data.imageSrc) + '"' : '') + ' alt="' + soy.$$escapeHtml("Uploaded image") + '" /><div class="image-explorer-mask ' + soy.$$escapeHtml(opt_data.maskShape ? opt_data.maskShape : 'square') + '-mask"></div><div class="image-explorer-drag-delegate"></div></div><div class="image-explorer-scale-slider-wrapper"><input class="image-explorer-scale-slider ' + ((! opt_data.imageSrc) ? 'disabled' : '') + '" type="range" min="0" max="100" step="1" value="0" ' + ((! opt_data.imageSrc) ? 'disabled' : '') + '/></div></div>';
};
if (goog.DEBUG) {
  stash.widget.imageExplorer.soyTemplateName = 'stash.widget.imageExplorer';
}
;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:paste-image-target', location = '/static/widget/paste-image-target/paste-image-target.js' */
define("widget/paste-image-target",["jquery","lodash","util/events","util/function","widget/client-file-handlers/client-file-handler"],function(F,B,C,D,A){function E(G,H){this.init.apply(this,arguments)}E.prototype.init=function(G,H){B.bindAll(this,"handlePaste","processClipboardItem");this.$el=F(G);this.clientFileHandler=H;this._destroyables=[];this._destroyables.push(C.chainWith(this.$el).on("paste",this.handlePaste))};E.prototype.handlePaste=function(J){var I=A.typeFilters.image;var G=J.originalEvent;var H=G.clipboardData&&G.clipboardData.items;if(this.clientFileHandler&&H&&H.length===1){B.toArray(H).filter(B.compose(I.test.bind(I),D.dot("type"))).forEach(this.processClipboardItem)}};E.prototype.processClipboardItem=function(H){var G=H.getAsFile();G.name="upload."+B.last(G.type.split("/"));this.clientFileHandler.handleFiles([G],this.$el)};E.prototype.destroy=function(){B.invoke(this._destroyables,"destroy")};return E});;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:image-upload-and-crop', location = '/static/widget/image-upload-and-crop/image-upload-and-crop.soy' */
// This file was automatically generated from image-upload-and-crop.soy.
// Please don't edit this file by hand.

/**
 * @fileoverview Templates in namespace stash.widget.
 */

if (typeof stash == 'undefined') { var stash = {}; }
if (typeof stash.widget == 'undefined') { stash.widget = {}; }


stash.widget.imageUploadAndCrop = function(opt_data, opt_ignored) {
  opt_data = opt_data || {};
  return '<div class="image-upload-and-crop-container">' + stash.widget.imageExplorer(opt_data) + ((opt_data.enableWebcam) ? stash.widget.webcamCapture(null) : '') + '<form class="aui">' + aui.buttons.buttons({extraClasses: 'input-buttons', content: '' + stash.widget.fauxUploadField.labelButton({text: "Upload an image", extraClasses: 'image-select-button'}) + ((opt_data.enableWebcam) ? aui.buttons.button({text: "Take a photo", extraClasses: 'use-webcam', extraAttributes: {type: 'button', title: "Use your webcam to take a photo"}}) : '')}) + ((opt_data.enableWebcam) ? aui.buttons.button({text: "Re-take photo", extraClasses: 'use-webcam retake-photo hidden', extraAttributes: {type: 'button'}}) : '') + ((opt_data.fallbackDescription) ? '<div class="description fallback">' + soy.$$escapeHtml(opt_data.fallbackDescription) + '</div>' : '') + '</form></div>';
};
if (goog.DEBUG) {
  stash.widget.imageUploadAndCrop.soyTemplateName = 'stash.widget.imageUploadAndCrop';
}
;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:image-upload-and-crop', location = '/static/widget/image-upload-and-crop/image-upload-and-crop.js' */
define("widget/image-upload-and-crop",["aui","jquery","lodash","util/text","widget/canvas-cropper","widget/client-file-handlers/client-file-iframe-uploader","widget/client-file-handlers/client-file-reader","widget/drag-drop-file-target","widget/faux-upload-field","widget/image-explorer","widget/paste-image-target","widget/webcam-capture"],function(H,E,K,C,A,L,I,J,D,M,F,G){function B(O,N){if(!B.isSupported()){throw new Error("This browser doesn't support ImageUploadAndCrop.")}this.init.apply(this,arguments)}B.isSupported=function(){return A.isSupported()};B.maskShapes=M.maskShapes;B.prototype.defaults={HiDPIMultiplier:2,dragDropUploadPrompt:"Drag and drop image here",onImageUpload:E.noop,onImageUploadError:E.noop,onImageClear:E.noop,onCrop:E.noop,outputFormat:"image/png",fallbackUploadOptions:{},initialScaleMode:M.scaleModes.containAndFill,scaleMax:1,fileSizeLimit:5*1024*1024,maxImageDimension:2000,pasteUpload:true};B.prototype.init=function(Q,O){this.options=E.extend({},this.defaults,O);this.$container=Q;K.bindAll(this,"crop","resetState","_onFileProcessed","setImageSrc","validateImageResolution","_onFilesError","_onFileError","_resetFileUploadField","_onErrorReset");this.imageExplorer=new M(this.$container.find(".image-explorer-container"),{initialScaleMode:this.options.initialScaleMode,scaleMax:this.options.scaleMax,onErrorReset:this._onErrorReset});if(I.isSupported()){this.clientFileReader=new I({onRead:this._onFileProcessed,onError:this._onFilesError,fileTypeFilter:I.typeFilters.imageWeb,fileCountLimit:1,fileSizeLimit:this.options.fileSizeLimit});this.dragDropFileTarget=new J(this.imageExplorer.get$ImageView(),{uploadPrompt:this.options.dragDropUploadPrompt,clientFileHandler:this.clientFileReader});if(this.options.pasteUpload){this.pasteImageTarget=new F(this.imageExplorer.get$ImageView(),this.clientFileReader)}}else{this.$container.addClass("filereader-unsupported");var N=E.extend({onUpload:this._onFileProcessed,onError:this._onFileError},this.options.fallbackUploadOptions);this.clientFileReader=new L(N)}this.fauxUploadField=new D(this.$container.find(".image-select-button"),{clientFileHandler:this.clientFileReader,accept:I.typeFilters.imageWeb});var P=this.imageExplorer.get$Mask();this.canvasCroppper=new A(P.width()*this.options.HiDPIMultiplier,P.height()*this.options.HiDPIMultiplier,{outputFormat:this.options.outputFormat});this.options.cropButton&&E(this.options.cropButton).click(this.crop);if(this.$container.find(".webcam-capture").length){if(G.isSupported()){this.webcamCapture=this.initWebcamUpload()}else{this.$container.find(".use-webcam").prop("disabled",true).attr("title","This is not supported for this browser. Try using the latest version of Chrome or Firefox.")}}};B.prototype.initWebcamUpload=function(){var N=this;var P=this.$container.find(".use-webcam");var O=new G(this.$container.find(".webcam-capture"),{countdown:true,mirror:true,width:640,onCapture:function(Q){O.pause();N.setImageSrc(Q);N.$container.removeClass("webcam-mode");N.$container.find(".retake-photo").removeClass("hidden").focus()}});P.on("click",function(){N.$container.addClass("webcam-mode");N.setImageSrc("");O.start()});return O};B.prototype._resetWebcamUpload=function(){if(this.webcamCapture){this.webcamCapture.stop();this.$container.removeClass("webcam-mode");this.$container.find(".retake-photo").addClass("hidden")}};B.prototype.crop=function(){var O=this.imageExplorer.getMaskedImageProperties();var N=this.canvasCroppper.cropToDataURI(this.imageExplorer.get$SourceImage()[0],O.maskedAreaImageX,O.maskedAreaImageY,O.maskedAreaWidth,O.maskedAreaHeight);K.isFunction(this.options.onCrop)&&this.options.onCrop(N)};B.prototype.resetState=function(){this.imageExplorer.clearError();this._resetFileUploadField();this._resetWebcamUpload();this.setImageSrc("")};B.prototype._onFileProcessed=function(O){if(O){if(!isNaN(this.options.maxImageDimension)){var N=this.validateImageResolution(O);N.done(K.bind(function(Q,P){this.setImageSrc(O)},this)).fail(K.bind(function(Q,P){this._onFileError(H.format("The selected image size is {0}px * {1}px. The maximum allowed image size is {2}px * {2}px",Q,P,this.options.maxImageDimension))},this))}else{this.setImageSrc(O)}}else{this._onFileError()}};B.prototype.setImageSrc=function(N){this.$container.find(".input-buttons").toggleClass("hidden",!!N);this.imageExplorer.setImageSrc(N);if(N){this.options.onImageUpload(N)}else{this.options.onImageClear()}this._resetFileUploadField()};B.prototype.validateImageResolution=function(Q){var N=E.Deferred(),P=new Image(),O=this;P.onload=function(){if(this.naturalWidth>O.options.maxImageDimension||this.naturalHeight>O.options.maxImageDimension){N.reject(this.naturalWidth,this.naturalHeight)}else{N.resolve(this.naturalWidth,this.naturalHeight)}};P.src=Q;return N};B.prototype._onFilesError=function(O){if(O&&O.bySize&&O.bySize.length){var N=K.first(O.bySize);this._onFileError(H.escapeHtml(H.format("File \u0022{0}\u0022 is {1} which is larger than the maximum allowed size of {2}",C.abbreviateText(N.name,50),C.formatSizeInBytes(N.size),C.formatSizeInBytes(this.options.fileSizeLimit))))}else{this._onFileError()}};B.prototype._onFileError=function(N){var P="There was an error uploading your image",O=N||"Please check that your file is a valid image (JPG, GIF or PNG) and try again.";this.imageExplorer.showError(P,O);this._resetFileUploadField();K.isFunction(this.options.onImageUploadError)&&this.options.onImageUploadError(N)};B.prototype._resetFileUploadField=function(){var N=this.$container.find("#image-upload-and-crop-upload-field").prop("form");N&&N.reset()};B.prototype._onErrorReset=function(N){if(N){K.isFunction(this.options.onImageUpload)&&this.options.onImageUpload(N)}};return B});;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:avatar-picker-dialog', location = '/static/widget/avatar-picker-dialog/avatar-picker-dialog.soy' */
// This file was automatically generated from avatar-picker-dialog.soy.
// Please don't edit this file by hand.

/**
 * @fileoverview Templates in namespace stash.widget.
 */

if (typeof stash == 'undefined') { var stash = {}; }
if (typeof stash.widget == 'undefined') { stash.widget = {}; }


stash.widget.avatarPickerDialog = function(opt_data, opt_ignored) {
  return '' + aui.dialog.dialog2({id: opt_data.id, size: 'small', titleText: opt_data.title, modal: true, content: '' + stash.widget.imageUploadAndCrop(opt_data), footerActionContent: '' + aui.buttons.button({text: opt_data.doneButtonText, type: 'primary', extraClasses: 'avatar-picker-save'}) + aui.buttons.button({text: "Cancel", type: 'link', extraClasses: 'avatar-picker-cancel'})});
};
if (goog.DEBUG) {
  stash.widget.avatarPickerDialog.soyTemplateName = 'stash.widget.avatarPickerDialog';
}
;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:avatar-picker-dialog', location = '/static/widget/avatar-picker-dialog/avatar-picker-dialog.js' */
define("widget/avatar-picker-dialog",["aui","jquery","lodash","stash/api/util/navbuilder","util/text","widget/image-upload-and-crop"],function(A,D,B,G,C,F){function E(H){if(!E.isSupported()){throw new Error("This browser doesn't support AvatarPickerDialog.")}return this.init(H)}E.isSupported=function(){return F.isSupported()};E.maskShapes=F.maskShapes;E.prototype.defaults={dialogTitle:"Upload an avatar",dialogId:"avatar-picker-dialog",dialogDoneButtonText:"Done",imageSrc:null,maskShape:null,fallbackDescription:"Up to 1MB in size",onCrop:D.noop,trigger:null};E.prototype.init=function(H){B.bindAll(this,"initDialog","_enableDoneButton","_disableDoneButton","_toggleDoneButtonEnabled","chooseAvatar","hide","show");this.options=D.extend(true,{},this.defaults,H);this.initDialog();this._toggleDoneButtonEnabled(false);this.imageUploadAndCrop=new F(this.dialog.$el.find(".image-upload-and-crop-container"),{HiDPIMultiplier:1,onCrop:this.options.onCrop,onImageUpload:this._enableDoneButton,onImageUploadError:this._disableDoneButton,onImageClear:this._disableDoneButton,fallbackUploadOptions:{uploadURL:G.tmp().avatars().build(),uploadFieldName:"avatar",responseHandler:function(M,N){var L=D(M),K=L.find("#json-response");if(K.length){var J;try{J=JSON.parse(K.html())}catch(O){N.reject()}if(J&&J.url){N.resolve(J.url)}else{N.reject()}}else{var I=L.find(".error-image + h2").text();I=I.replace(/; nested exception.*$/,".").replace(/(\d+) bytes/,function(P,Q){return C.formatSizeInBytes(Q)});N.reject(I)}},cancelTrigger:this.$doneButton.add(this.$cancelButton),xsrfToken:this.options.xsrfToken}});if(this.options.trigger){this.$trigger=D(this.options.trigger);this.$trigger.click(B.bind(function(I){I.preventDefault();this.show()},this))}return this};E.prototype.initDialog=function(){this.dialog=A.dialog2(stash.widget.avatarPickerDialog({id:this.options.dialogId,title:this.options.dialogTitle,doneButtonText:this.options.dialogDoneButtonText,imageSrc:this.options.imageSrc,maskShape:this.options.maskShape,fallbackDescription:this.options.fallbackDescription,enableWebcam:this.options.enableWebcam}));this.dialog.$el.appendTo("body");this.$doneButton=this.dialog.$el.find(".avatar-picker-save").on("click",this.chooseAvatar);this.$cancelButton=this.dialog.$el.find(".avatar-picker-cancel").on("click",this.hide)};E.prototype._enableDoneButton=function(){this._toggleDoneButtonEnabled(true)};E.prototype._disableDoneButton=function(){this._toggleDoneButtonEnabled(false)};E.prototype._toggleDoneButtonEnabled=function(H){if(H==null){H=this.$doneButton.attr("disabled")!=null}if(H){this.$doneButton.removeAttr("disabled")}else{this.$doneButton.attr("disabled","disabled")}};E.prototype.chooseAvatar=function(){this.imageUploadAndCrop.crop();this.hide()};E.prototype.hide=function(){this.dialog.hide();this.imageUploadAndCrop.resetState()};E.prototype.show=function(){this.dialog.show()};return E});;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:submit-spinner', location = '/static/widget/submit-spinner/submit-spinner.js' */
define("widget/submit-spinner",["jquery"],function(B){function A(D,C){if(!(this instanceof A)){return new A(D)}this.$button=B(D);this.$spinner=B('<div class="submit-spinner invisible" />');if(C==="before"){this.$spinner.insertBefore(this.$button)}else{this.$spinner.insertAfter(this.$button)}}A.prototype.show=function(){this.$spinner.removeClass("invisible");this.$spinner.spin();return this};A.prototype.hide=function(){this.$spinner.addClass("invisible");this.$spinner.spinStop();return this};A.prototype.remove=function(){this.$spinner.remove();return this};return A});;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:confirm-dialog', location = '/static/widget/confirm-dialog.js' */
define("widget/confirm-dialog",["aui","jquery","lodash","util/ajax","widget/submit-spinner"],function(B,F,C,E,D){function A(H,G){this.dialogOptions=F.extend({},A.dialogDefaults,H);this.ajaxOptions=G||{};this._selectors=[];this._okCallbacks=F.Callbacks();this._cancelCallback=F.Callbacks();this._detachers=F.Callbacks();this._attached=false}A.prototype.getConfirmButton=function(){return F("#"+this.dialogOptions.id+" ."+this.dialogOptions.confirmButtonClass)};A.prototype.getButtons=function(){var H=this.getConfirmButton(),G=this.dialogOptions.id;C.each(this._selectors,function(I){H=H.add(F("#"+G+" "+I))});return H};A.prototype.setButtonsDisabled=function(G){this.getButtons().each(function(){var H=F(this);H.prop("disabled",G).toggleClass("disabled",G);if(G){H.attr("aria-disabled","true")}else{H.removeAttr("aria-disabled")}})};A.prototype.destroy=function(){this._detachers.fire();this._detachers=null};A.prototype.attachTo=function(G,N,H){var Q=this,I=this.dialogOptions,K=this.ajaxOptions,L=this._okCallbacks,J=this._cancelCallback;H=H||document;var P=F(H);this._selectors.push(G);var O=function(){Q.setButtonsDisabled(false)};P.on("hideLayer",O);var M=function(U){U.preventDefault();var S=F(this);if(!S.is(":disabled")){var R=function(V){Q.setButtonsDisabled(false);V.remove()},T=new B.Dialog({width:I.width,height:I.height,id:I.id,focusSelector:I.focusSelector,closeOnOutsideClick:false,keypressListener:function(V){V.stopImmediatePropagation();if(V.keyCode===B.keyCode.ENTER){V.preventDefault();Q.getConfirmButton().click()}else{if(V.keyCode===B.keyCode.ESCAPE){V.preventDefault();R(T)}}}});T.addHeader(I.titleText,I.titleClass);T.addPanel("",I.panelContent,I.panelClass);T.addButton(I.submitText,function(V){Q.setButtonsDisabled(true);var X=null;var W=new D(Q.getConfirmButton(),"before");if(Q.dialogOptions.submitToHref){W.show();if(S[0].tagName==="A"){X=E.rest(F.extend({url:S.attr("href")},K)).always(function(){W.hide();R(V)})}else{S.closest("form")[0].submit()}}L.fire(X,S,function(){R(V)},V,W)},"button "+(I.confirmButtonClass||""));T.addCancel("Cancel",function(V){R(V);J.fire(S)});if(N){N(this,T,Q)}T.show();Q._attached=true}};P.on("click",G,M);this._detachers.add(function(){P.off("hideLayer",O);P.off("click",G,M)})};A.prototype.addConfirmListener=function(G){this._okCallbacks.add(G)};A.prototype.addCancelListener=function(G){this._cancelCallback.add(G)};A.dialogDefaults={id:undefined,titleText:"Confirm",titleClass:"confirm-header",confirmButtonClass:"confirm-button",panelContent:"<p>"+"Are you sure you want to do that?"+"</p>",panelClass:"panel-body",submitText:"Confirm",submitToHref:true,height:230,width:433,focusSelector:".confirm-button"};return A});;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:paragraph', location = '/static/widget/paragraph.soy' */
// This file was automatically generated from paragraph.soy.
// Please don't edit this file by hand.

/**
 * @fileoverview Templates in namespace stash.widget.
 */

if (typeof stash == 'undefined') { var stash = {}; }
if (typeof stash.widget == 'undefined') { stash.widget = {}; }


stash.widget.paragraph = function(opt_data, opt_ignored) {
  return '<p' + ((opt_data.extraClasses) ? ' class="' + soy.$$escapeHtml(opt_data.extraClasses) + '"' : '') + '>' + soy.$$escapeHtml(opt_data.text) + '</p>';
};
if (goog.DEBUG) {
  stash.widget.paragraph.soyTemplateName = 'stash.widget.paragraph';
}
;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:user-avatar-form', location = '/static/widget/user-avatar-form/user-avatar-form.soy' */
// This file was automatically generated from user-avatar-form.soy.
// Please don't edit this file by hand.

/**
 * @fileoverview Templates in namespace stash.widget.
 */

if (typeof stash == 'undefined') { var stash = {}; }
if (typeof stash.widget == 'undefined') { stash.widget = {}; }


stash.widget.userAvatarForm = function(opt_data, opt_ignored) {
  var output = '<div class="user-avatar-form">' + stash.widget.avatar({person: opt_data.user, size: 'xxxlarge'}) + ((opt_data.withPicker) ? stash.buttons.button({buttonText: "Change avatar", extraClasses: 'avatar-picker-trigger', title: "Change avatar"}) : '');
  var webPanelList13 = WebFragments.getWebPanels('stash.web.user.account.avatar.caption',{accountUser: opt_data.user}).map(function(webPanel) { return soydata.VERY_UNSAFE.ordainSanitizedHtml(webPanel); });
  var webPanelListLen13 = webPanelList13.length;
  for (var webPanelIndex13 = 0; webPanelIndex13 < webPanelListLen13; webPanelIndex13++) {
    var webPanelData13 = webPanelList13[webPanelIndex13];
    output += soy.$$escapeHtml(webPanelData13);
  }
  output += '<div class="avatar-delete-overlay">' + stash.buttons.deleteButton({href: require('stash/api/util/navbuilder').rest().users(opt_data.user.slug).avatar().build(), extraClasses: 'avatar-delete-trigger', size: 'small', title: "Remove the avatar"}) + '</div></div>';
  return output;
};
if (goog.DEBUG) {
  stash.widget.userAvatarForm.soyTemplateName = 'stash.widget.userAvatarForm';
}
;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:user-avatar-form', location = '/static/widget/user-avatar-form/user-avatar-form.js' */
define("widget/user-avatar-form",["aui","jquery","lodash","stash/api/util/navbuilder","util/ajax","util/events","widget/avatar-picker-dialog","widget/confirm-dialog"],function(I,F,J,A,H,L,C,M){var K={statusCode:{400:false,401:function(P,R,O,Q,N){return N.shouldLogin},404:false,500:false}};function B(N,O,P){J.bindAll(this,"restorePreview","save","_onSuccess");this.user=O;this.$container=F(N);this.$delete=this.$container.find(".avatar-delete-trigger");this.$image=this.$container.find(".user-avatar img");this.$picker=this.$container.find(".avatar-picker-trigger");this.xsrfToken=P;this._initDialogs();this._toggleAvatarSource()}L.addLocalEventMixin(B.prototype);B.prototype.refreshAll=function(O){var N=this;F(".aui-avatar").filter(function(){return F(this).attr("data-username")===N.user.name}).find(".aui-avatar-inner > img").each(function(){var P=D(F(this).attr("src"),"s");F(this).attr("src",E(O,{s:P,t:new Date().getTime()}))})};B.prototype.restorePreview=function(){this.updatePreview(this.oldImage)};B.prototype.save=function(N){this.updatePreview(N);this.upload(N)};B.prototype.updatePreview=function(N){this.oldImage=this.$image.attr("src");this.$image.attr("src",N)};B.prototype.upload=function(N){var O=this.$image.parent();O.spin("large",{color:"#fff"});this.$picker.prop("disabled",true);H.ajax(F.extend({url:this._getUploadUrl(),data:{avatar:N},type:"POST"},K)).then(G).done(this._onSuccess).fail(this.trigger.bind(this,"avatarUploadError","The avatar could not be saved. Please consult your system administrator for more information")).fail(this.restorePreview).always(O.spinStop.bind(O)).always(this.$picker.prop.bind(this.$picker,"disabled",false))};B.prototype._initDialogs=function(){this.pickerDialog=new C({dialogTitle:"Upload a personal avatar",dialogDoneButtonText:"Save",maskShape:C.maskShapes.ROUNDED_SQUARE,trigger:this.$picker,onCrop:this.save,xsrfToken:this.xsrfToken,enableWebcam:true});this.deleteDialog=new M({id:"delete-avatar-dialog",titleClass:"warning-header",titleText:"Remove the avatar",panelContent:stash.widget.paragraph({text:"Are you sure that you want to remove the local avatar?"}),submitText:"Remove"},F.extend({type:"DELETE"},K));var N=this;this.deleteDialog.addConfirmListener(function(O){O.then(G).done(N._onSuccess).fail(N.trigger.bind(N,"avatarDeleteError","The avatar could not be removed. Please consult your system administrator for more information"))});this.deleteDialog.attachTo(null,null,this.$delete)};B.prototype._getUploadUrl=function(){var O=A.user(this.user.slug).avatar();if(this.xsrfToken){var N={};N[this.xsrfToken.name]=this.xsrfToken.value;return O.withParams(N).build()}else{return O.build()}};B.prototype._onSuccess=function(N){this.refreshAll(N);this._toggleAvatarSource();this.trigger("avatarChanged",this.user);L.trigger("stash.widget.userAvatarForm.avatarChanged",null,this.user)};B.prototype._toggleAvatarSource=function(){var N=/^https?:\/\/(www|secure)\.gravatar.com\/.+/g;var O=N.test(this.$image.attr("src"));this.$container.toggleClass("gravatar-source",O)};function G(N,P,O){return N.href||(O.status===201&&O.getResponseHeader("Location"))}function E(N,O){N=A.parse(N);J.forEach(O,function(Q,P){if(Q){N.replaceQueryParam(P,Q)}});return N}function D(N,O){return A.parse(N).getQueryParamValue(O)}return B});;
;/* module-key = 'com.atlassian.stash.stash-web-plugin:account-settings-page', location = '/static/page/users/account/account.js' */
define("page/users/account",["jquery","widget/user-avatar-form","exports"],function(D,E,B){function C(){D(".user-avatar-error").remove()}function A(F){C();D(".aui-page-panel-content > .aui-page-header").after(aui.message.error({content:F,extraClasses:"user-avatar-error"}))}B.onReady=function(G,H){var I={name:"atl_token",value:D(".account-settings input[name=atl_token]").val()};var F=new E(D(H),G,I);F.on("avatarChanged",C);F.on("avatarUploadError",A);F.on("avatarDeleteError",A)}});;

Zerion Mini Shell 1.0