PageSourceSearch

https://www.martinwoods.me.uk/app/themes/salt-blog/assets/js/footer.js?ver=1.0

js martinwoods.me.uk collected 2026-10-04 16:03:12 UTC 312,020 bytes, 11,224 lines download raw bytes

vendor: 52,920 bytes, lines 1-1549
1//     Underscore.js 1.8.3
2//     http://underscorejs.org
3//     (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
4//     Underscore may be freely distributed under the MIT license.
5
6(function() {
7
8  // Baseline setup
9  // --------------
10
11  // Establish the root object, `window` in the browser, or `exports` on the server.
12  var root = this;
13
14  // Save the previous value of the `_` variable.
15  var previousUnderscore = root._;
16
17  // Save bytes in the minified (but not gzipped) version:
18  var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
19
20  // Create quick reference variables for speed access to core prototypes.
21  var
22    push             = ArrayProto.push,
23    slice            = ArrayProto.slice,
24    toString         = ObjProto.toString,
25    hasOwnProperty   = ObjProto.hasOwnProperty;
26
27  // All **ECMAScript 5** native function implementations that we hope to use
28  // are declared here.
29  var
30    nativeIsArray      = Array.isArray,
31    nativeKeys         = Object.keys,
32    nativeBind         = FuncProto.bind,
33    nativeCreate       = Object.create;
34
35  // Naked function reference for surrogate-prototype-swapping.
36  var Ctor = function(){};
37
38  // Create a safe reference to the Underscore object for use below.
39  var _ = function(obj) {
40    if (obj instanceof _) return obj;
41    if (!(this instanceof _)) return new _(obj);
42    this._wrapped = obj;
43  };
44
45  // Export the Underscore object for **Node.js**, with
46  // backwards-compatibility for the old `require()` API. If we're in
47  // the browser, add `_` as a global object.
48  if (typeof exports !== 'undefined') {
49    if (typeof module !== 'undefined' && module.exports) {
50      exports = module.exports = _;
51    }
52    exports._ = _;
53  } else {
54    root._ = _;
55  }
56
57  // Current version.
58  _.VERSION = '1.8.3';
59
60  // Internal function that returns an efficient (for current engines) version
61  // of the passed-in callback, to be repeatedly applied in other Underscore
62  // functions.
63  var optimizeCb = function(func, context, argCount) {
64    if (context === void 0) return func;
65    switch (argCount == null ? 3 : argCount) {
66      case 1: return function(value) {
67        return func.call(context, value);
68      };
69      case 2: return function(value, other) {
70        return func.call(context, value, other);
71      };
72      case 3: return function(value, index, collection) {
73        return func.call(context, value, index, collection);
74      };
75      case 4: return function(accumulator, value, index, collection) {
76        return func.call(context, accumulator, value, index, collection);
77      };
78    }
79    return function() {
80      return func.apply(context, arguments);
81    };
82  };
83
84  // A mostly-internal function to generate callbacks that can be applied
85  // to each element in a collection, returning the desired result — either
86  // identity, an arbitrary callback, a property matcher, or a property accessor.
87  var cb = function(value, context, argCount) {
88    if (value == null) return _.identity;
89    if (_.isFunction(value)) return optimizeCb(value, context, argCount);
90    if (_.isObject(value)) return _.matcher(value);
91    return _.property(value);
92  };
93  _.iteratee = function(value, context) {
94    return cb(value, context, Infinity);
95  };
96
97  // An internal function for creating assigner functions.
98  var createAssigner = function(keysFunc, undefinedOnly) {
99    return function(obj) {
100      var length = arguments.length;
101      if (length < 2 || obj == null) return obj;
102      for (var index = 1; index < length; index++) {
103        var source = arguments[index],
104            keys = keysFunc(source),
105            l = keys.length;
106        for (var i = 0; i < l; i++) {
107          var key = keys[i];
108          if (!undefinedOnly || obj[key] === void 0) obj[key] = source[key];
109        }
110      }
111      return obj;
112    };
113  };
114
115  // An internal function for creating a new object that inherits from another.
116  var baseCreate = function(prototype) {
117    if (!_.isObject(prototype)) return {};
118    if (nativeCreate) return nativeCreate(prototype);
119    Ctor.prototype = prototype;
120    var result = new Ctor;
121    Ctor.prototype = null;
122    return result;
123  };
124
125  var property = function(key) {
126    return function(obj) {
127      return obj == null ? void 0 : obj[key];
128    };
129  };
130
131  // Helper for collection methods to determine whether a collection
132  // should be iterated as an array or as an object
133  // Related: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
134  // Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094
135  var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1;
136  var getLength = property('length');
137  var isArrayLike = function(collection) {
138    var length = getLength(collection);
139    return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_INDEX;
140  };
141
142  // Collection Functions
143  // --------------------
144
145  // The cornerstone, an `each` implementation, aka `forEach`.
146  // Handles raw objects in addition to array-likes. Treats all
147  // sparse array-likes as if they were dense.
148  _.each = _.forEach = function(obj, iteratee, context) {
149    iteratee = optimizeCb(iteratee, context);
150    var i, length;
151    if (isArrayLike(obj)) {
152      for (i = 0, length = obj.length; i < length; i++) {
153        iteratee(obj[i], i, obj);
154      }
155    } else {
156      var keys = _.keys(obj);
157      for (i = 0, length = keys.length; i < length; i++) {
158        iteratee(obj[keys[i]], keys[i], obj);
159      }
160    }
161    return obj;
162  };
163
164  // Return the results of applying the iteratee to each element.
165  _.map = _.collect = function(obj, iteratee, context) {
166    iteratee = cb(iteratee, context);
167    var keys = !isArrayLike(obj) && _.keys(obj),
168        length = (keys || obj).length,
169        results = Array(length);
170    for (var index = 0; index < length; index++) {
171      var currentKey = keys ? keys[index] : index;
172      results[index] = iteratee(obj[currentKey], currentKey, obj);
173    }
174    return results;
175  };
176
177  // Create a reducing function iterating left or right.
178  function createReduce(dir) {
179    // Optimized iterator function as using arguments.length
180    // in the main function will deoptimize the, see #1991.
181    function iterator(obj, iteratee, memo, keys, index, length) {
182      for (; index >= 0 && index < length; index += dir) {
183        var currentKey = keys ? keys[index] : index;
184        memo = iteratee(memo, obj[currentKey], currentKey, obj);
185      }
186      return memo;
187    }
188
189    return function(obj, iteratee, memo, context) {
190      iteratee = optimizeCb(iteratee, context, 4);
191      var keys = !isArrayLike(obj) && _.keys(obj),
192          length = (keys || obj).length,
193          index = dir > 0 ? 0 : length - 1;
194      // Determine the initial value if none is provided.
195      if (arguments.length < 3) {
196        memo = obj[keys ? keys[index] : index];
197        index += dir;
198      }
199      return iterator(obj, iteratee, memo, keys, index, length);
200    };
201  }
202
203  // **Reduce** builds up a single result from a list of values, aka `inject`,
204  // or `foldl`.
205  _.reduce = _.foldl = _.inject = createReduce(1);
206
207  // The right-associative version of reduce, also known as `foldr`.
208  _.reduceRight = _.foldr = createReduce(-1);
209
210  // Return the first value which passes a truth test. Aliased as `detect`.
211  _.find = _.detect = function(obj, predicate, context) {
212    var key;
213    if (isArrayLike(obj)) {
214      key = _.findIndex(obj, predicate, context);
215    } else {
216      key = _.findKey(obj, predicate, context);
217    }
218    if (key !== void 0 && key !== -1) return obj[key];
219  };
220
221  // Return all the elements that pass a truth test.
222  // Aliased as `select`.
223  _.filter = _.select = function(obj, predicate, context) {
224    var results = [];
225    predicate = cb(predicate, context);
226    _.each(obj, function(value, index, list) {
227      if (predicate(value, index, list)) results.push(value);
228    });
229    return results;
230  };
231
232  // Return all the elements for which a truth test fails.
233  _.reject = function(obj, predicate, context) {
234    return _.filter(obj, _.negate(cb(predicate)), context);
235  };
236
237  // Determine whether all of the elements match a truth test.
238  // Aliased as `all`.
239  _.every = _.all = function(obj, predicate, context) {
240    predicate = cb(predicate, context);
241    var keys = !isArrayLike(obj) && _.keys(obj),
242        length = (keys || obj).length;
243    for (var index = 0; index < length; index++) {
244      var currentKey = keys ? keys[index] : index;
245      if (!predicate(obj[currentKey], currentKey, obj)) return false;
246    }
247    return true;
248  };
249
250  // Determine if at least one element in the object matches a truth test.
251  // Aliased as `any`.
252  _.some = _.any = function(obj, predicate, context) {
253    predicate = cb(predicate, context);
254    var keys = !isArrayLike(obj) && _.keys(obj),
255        length = (keys || obj).length;
256    for (var index = 0; index < length; index++) {
257      var currentKey = keys ? keys[index] : index;
258      if (predicate(obj[currentKey], currentKey, obj)) return true;
259    }
260    return false;
261  };
262
263  // Determine if the array or object contains a given item (using `===`).
264  // Aliased as `includes` and `include`.
265  _.contains = _.includes = _.include = function(obj, item, fromIndex, guard) {
266    if (!isArrayLike(obj)) obj = _.values(obj);
267    if (typeof fromIndex != 'number' || guard) fromIndex = 0;
268    return _.indexOf(obj, item, fromIndex) >= 0;
269  };
270
271  // Invoke a method (with arguments) on every item in a collection.
272  _.invoke = function(obj, method) {
273    var args = slice.call(arguments, 2);
274    var isFunc = _.isFunction(method);
275    return _.map(obj, function(value) {
276      var func = isFunc ? method : value[method];
277      return func == null ? func : func.apply(value, args);
278    });
279  };
280
281  // Convenience version of a common use case of `map`: fetching a property.
282  _.pluck = function(obj, key) {
283    return _.map(obj, _.property(key));
284  };
285
286  // Convenience version of a common use case of `filter`: selecting only objects
287  // containing specific `key:value` pairs.
288  _.where = function(obj, attrs) {
289    return _.filter(obj, _.matcher(attrs));
290  };
291
292  // Convenience version of a common use case of `find`: getting the first object
293  // containing specific `key:value` pairs.
294  _.findWhere = function(obj, attrs) {
295    return _.find(obj, _.matcher(attrs));
296  };
297
298  // Return the maximum element (or element-based computation).
299  _.max = function(obj, iteratee, context) {
300    var result = -Infinity, lastComputed = -Infinity,
301        value, computed;
302    if (iteratee == null && obj != null) {
303      obj = isArrayLike(obj) ? obj : _.values(obj);
304      for (var i = 0, length = obj.length; i < length; i++) {
305        value = obj[i];
306        if (value > result) {
307          result = value;
308        }
309      }
310    } else {
311      iteratee = cb(iteratee, context);
312      _.each(obj, function(value, index, list) {
313        computed = iteratee(value, index, list);
314        if (computed > lastComputed || computed === -Infinity && result === -Infinity) {
315          result = value;
316          lastComputed = computed;
317        }
318      });
319    }
320    return result;
321  };
322
323  // Return the minimum element (or element-based computation).
324  _.min = function(obj, iteratee, context) {
325    var result = Infinity, lastComputed = Infinity,
326        value, computed;
327    if (iteratee == null && obj != null) {
328      obj = isArrayLike(obj) ? obj : _.values(obj);
329      for (var i = 0, length = obj.length; i < length; i++) {
330        value = obj[i];
331        if (value < result) {
332          result = value;
333        }
334      }
335    } else {
336      iteratee = cb(iteratee, context);
337      _.each(obj, function(value, index, list) {
338        computed = iteratee(value, index, list);
339        if (computed < lastComputed || computed === Infinity && result === Infinity) {
340          result = value;
341          lastComputed = computed;
342        }
343      });
344    }
345    return result;
346  };
347
348  // Shuffle a collection, using the modern version of the
349  // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
350  _.shuffle = function(obj) {
351    var set = isArrayLike(obj) ? obj : _.values(obj);
352    var length = set.length;
353    var shuffled = Array(length);
354    for (var index = 0, rand; index < length; index++) {
355      rand = _.random(0, index);
356      if (rand !== index) shuffled[index] = shuffled[rand];
357      shuffled[rand] = set[index];
358    }
359    return shuffled;
360  };
361
362  // Sample **n** random values from a collection.
363  // If **n** is not specified, returns a single random element.
364  // The internal `guard` argument allows it to work with `map`.
365  _.sample = function(obj, n, guard) {
366    if (n == null || guard) {
367      if (!isArrayLike(obj)) obj = _.values(obj);
368      return obj[_.random(obj.length - 1)];
369    }
370    return _.shuffle(obj).slice(0, Math.max(0, n));
371  };
372
373  // Sort the object's values by a criterion produced by an iteratee.
374  _.sortBy = function(obj, iteratee, context) {
375    iteratee = cb(iteratee, context);
376    return _.pluck(_.map(obj, function(value, index, list) {
377      return {
378        value: value,
379        index: index,
380        criteria: iteratee(value, index, list)
381      };
382    }).sort(function(left, right) {
383      var a = left.criteria;
384      var b = right.criteria;
385      if (a !== b) {
386        if (a > b || a === void 0) return 1;
387        if (a < b || b === void 0) return -1;
388      }
389      return left.index - right.index;
390    }), 'value');
391  };
392
393  // An internal function used for aggregate "group by" operations.
394  var group = function(behavior) {
395    return function(obj, iteratee, context) {
396      var result = {};
397      iteratee = cb(iteratee, context);
398      _.each(obj, function(value, index) {
399        var key = iteratee(value, index, obj);
400        behavior(result, value, key);
401      });
402      return result;
403    };
404  };
405
406  // Groups the object's values by a criterion. Pass either a string attribute
407  // to group by, or a function that returns the criterion.
408  _.groupBy = group(function(result, value, key) {
409    if (_.has(result, key)) result[key].push(value); else result[key] = [value];
410  });
411
412  // Indexes the object's values by a criterion, similar to `groupBy`, but for
413  // when you know that your index values will be unique.
414  _.indexBy = group(function(result, value, key) {
415    result[key] = value;
416  });
417
418  // Counts instances of an object that group by a certain criterion. Pass
419  // either a string attribute to count by, or a function that returns the
420  // criterion.
421  _.countBy = group(function(result, value, key) {
422    if (_.has(result, key)) result[key]++; else result[key] = 1;
423  });
424
425  // Safely create a real, live array from anything iterable.
426  _.toArray = function(obj) {
427    if (!obj) return [];
428    if (_.isArray(obj)) return slice.call(obj);
429    if (isArrayLike(obj)) return _.map(obj, _.identity);
430    return _.values(obj);
431  };
432
433  // Return the number of elements in an object.
434  _.size = function(obj) {
435    if (obj == null) return 0;
436    return isArrayLike(obj) ? obj.length : _.keys(obj).length;
437  };
438
439  // Split a collection into two arrays: one whose elements all satisfy the given
440  // predicate, and one whose elements all do not satisfy the predicate.
441  _.partition = function(obj, predicate, context) {
442    predicate = cb(predicate, context);
443    var pass = [], fail = [];
444    _.each(obj, function(value, key, obj) {
445      (predicate(value, key, obj) ? pass : fail).push(value);
446    });
447    return [pass, fail];
448  };
449
450  // Array Functions
451  // ---------------
452
453  // Get the first element of an array. Passing **n** will return the first N
454  // values in the array. Aliased as `head` and `take`. The **guard** check
455  // allows it to work with `_.map`.
456  _.first = _.head = _.take = function(array, n, guard) {
457    if (array == null) return void 0;
458    if (n == null || guard) return array[0];
459    return _.initial(array, array.length - n);
460  };
461
462  // Returns everything but the last entry of the array. Especially useful on
463  // the arguments object. Passing **n** will return all the values in
464  // the array, excluding the last N.
465  _.initial = function(array, n, guard) {
466    return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n)));
467  };
468
469  // Get the last element of an array. Passing **n** will return the last N
470  // values in the array.
471  _.last = function(array, n, guard) {
472    if (array == null) return void 0;
473    if (n == null || guard) return array[array.length - 1];
474    return _.rest(array, Math.max(0, array.length - n));
475  };
476
477  // Returns everything but the first entry of the array. Aliased as `tail` and `drop`.
478  // Especially useful on the arguments object. Passing an **n** will return
479  // the rest N values in the array.
480  _.rest = _.tail = _.drop = function(array, n, guard) {
481    return slice.call(array, n == null || guard ? 1 : n);
482  };
483
484  // Trim out all falsy values from an array.
485  _.compact = function(array) {
486    return _.filter(array, _.identity);
487  };
488
489  // Internal implementation of a recursive `flatten` function.
490  var flatten = function(input, shallow, strict, startIndex) {
491    var output = [], idx = 0;
492    for (var i = startIndex || 0, length = getLength(input); i < length; i++) {
493      var value = input[i];
494      if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) {
495        //flatten current level of array or arguments object
496        if (!shallow) value = flatten(value, shallow, strict);
497        var j = 0, len = value.length;
498        output.length += len;
499        while (j < len) {
500          output[idx++] = value[j++];
501        }
502      } else if (!strict) {
503        output[idx++] = value;
504      }
505    }
506    return output;
507  };
508
509  // Flatten out an array, either recursively (by default), or just one level.
510  _.flatten = function(array, shallow) {
511    return flatten(array, shallow, false);
512  };
513
514  // Return a version of the array that does not contain the specified value(s).
515  _.without = function(array) {
516    return _.difference(array, slice.call(arguments, 1));
517  };
518
519  // Produce a duplicate-free version of the array. If the array has already
520  // been sorted, you have the option of using a faster algorithm.
521  // Aliased as `unique`.
522  _.uniq = _.unique = function(array, isSorted, iteratee, context) {
523    if (!_.isBoolean(isSorted)) {
524      context = iteratee;
525      iteratee = isSorted;
526      isSorted = false;
527    }
528    if (iteratee != null) iteratee = cb(iteratee, context);
529    var result = [];
530    var seen = [];
531    for (var i = 0, length = getLength(array); i < length; i++) {
532      var value = array[i],
533          computed = iteratee ? iteratee(value, i, array) : value;
534      if (isSorted) {
535        if (!i || seen !== computed) result.push(value);
536        seen = computed;
537      } else if (iteratee) {
538        if (!_.contains(seen, computed)) {
539          seen.push(computed);
540          result.push(value);
541        }
542      } else if (!_.contains(result, value)) {
543        result.push(value);
544      }
545    }
546    return result;
547  };
548
549  // Produce an array that contains the union: each distinct element from all of
550  // the passed-in arrays.
551  _.union = function() {
552    return _.uniq(flatten(arguments, true, true));
553  };
554
555  // Produce an array that contains every item shared between all the
556  // passed-in arrays.
557  _.intersection = function(array) {
558    var result = [];
559    var argsLength = arguments.length;
560    for (var i = 0, length = getLength(array); i < length; i++) {
561      var item = array[i];
562      if (_.contains(result, item)) continue;
563      for (var j = 1; j < argsLength; j++) {
564        if (!_.contains(arguments[j], item)) break;
565      }
566      if (j === argsLength) result.push(item);
567    }
568    return result;
569  };
570
571  // Take the difference between one array and a number of other arrays.
572  // Only the elements present in just the first array will remain.
573  _.difference = function(array) {
574    var rest = flatten(arguments, true, true, 1);
575    return _.filter(array, function(value){
576      return !_.contains(rest, value);
577    });
578  };
579
580  // Zip together multiple lists into a single array -- elements that share
581  // an index go together.
582  _.zip = function() {
583    return _.unzip(arguments);
584  };
585
586  // Complement of _.zip. Unzip accepts an array of arrays and groups
587  // each array's elements on shared indices
588  _.unzip = function(array) {
589    var length = array && _.max(array, getLength).length || 0;
590    var result = Array(length);
591
592    for (var index = 0; index < length; index++) {
593      result[index] = _.pluck(array, index);
594    }
595    return result;
596  };
597
598  // Converts lists into objects. Pass either a single array of `[key, value]`
599  // pairs, or two parallel arrays of the same length -- one of keys, and one of
600  // the corresponding values.
601  _.object = function(list, values) {
602    var result = {};
603    for (var i = 0, length = getLength(list); i < length; i++) {
604      if (values) {
605        result[list[i]] = values[i];
606      } else {
607        result[list[i][0]] = list[i][1];
608      }
609    }
610    return result;
611  };
612
613  // Generator function to create the findIndex and findLastIndex functions
614  function createPredicateIndexFinder(dir) {
615    return function(array, predicate, context) {
616      predicate = cb(predicate, context);
617      var length = getLength(array);
618      var index = dir > 0 ? 0 : length - 1;
619      for (; index >= 0 && index < length; index += dir) {
620        if (predicate(array[index], index, array)) return index;
621      }
622      return -1;
623    };
624  }
625
626  // Returns the first index on an array-like that passes a predicate test
627  _.findIndex = createPredicateIndexFinder(1);
628  _.findLastIndex = createPredicateIndexFinder(-1);
629
630  // Use a comparator function to figure out the smallest index at which
631  // an object should be inserted so as to maintain order. Uses binary search.
632  _.sortedIndex = function(array, obj, iteratee, context) {
633    iteratee = cb(iteratee, context, 1);
634    var value = iteratee(obj);
635    var low = 0, high = getLength(array);
636    while (low < high) {
637      var mid = Math.floor((low + high) / 2);
638      if (iteratee(array[mid]) < value) low = mid + 1; else high = mid;
639    }
640    return low;
641  };
642
643  // Generator function to create the indexOf and lastIndexOf functions
644  function createIndexFinder(dir, predicateFind, sortedIndex) {
645    return function(array, item, idx) {
646      var i = 0, length = getLength(array);
647      if (typeof idx == 'number') {
648        if (dir > 0) {
649            i = idx >= 0 ? idx : Math.max(idx + length, i);
650        } else {
651            length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1;
652        }
653      } else if (sortedIndex && idx && length) {
654        idx = sortedIndex(array, item);
655        return array[idx] === item ? idx : -1;
656      }
657      if (item !== item) {
658        idx = predicateFind(slice.call(array, i, length), _.isNaN);
659        return idx >= 0 ? idx + i : -1;
660      }
661      for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) {
662        if (array[idx] === item) return idx;
663      }
664      return -1;
665    };
666  }
667
668  // Return the position of the first occurrence of an item in an array,
669  // or -1 if the item is not included in the array.
670  // If the array is large and already in sort order, pass `true`
671  // for **isSorted** to use binary search.
672  _.indexOf = createIndexFinder(1, _.findIndex, _.sortedIndex);
673  _.lastIndexOf = createIndexFinder(-1, _.findLastIndex);
674
675  // Generate an integer Array containing an arithmetic progression. A port of
676  // the native Python `range()` function. See
677  // [the Python documentation](http://docs.python.org/library/functions.html#range).
678  _.range = function(start, stop, step) {
679    if (stop == null) {
680      stop = start || 0;
681      start = 0;
682    }
683    step = step || 1;
684
685    var length = Math.max(Math.ceil((stop - start) / step), 0);
686    var range = Array(length);
687
688    for (var idx = 0; idx < length; idx++, start += step) {
689      range[idx] = start;
690    }
691
692    return range;
693  };
694
695  // Function (ahem) Functions
696  // ------------------
697
698  // Determines whether to execute a function as a constructor
699  // or a normal function with the provided arguments
700  var executeBound = function(sourceFunc, boundFunc, context, callingContext, args) {
701    if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args);
702    var self = baseCreate(sourceFunc.prototype);
703    var result = sourceFunc.apply(self, args);
704    if (_.isObject(result)) return result;
705    return self;
706  };
707
708  // Create a function bound to a given object (assigning `this`, and arguments,
709  // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if
710  // available.
711  _.bind = function(func, context) {
712    if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
713    if (!_.isFunction(func)) throw new TypeError('Bind must be called on a function');
714    var args = slice.call(arguments, 2);
715    var bound = function() {
716      return executeBound(func, bound, context, this, args.concat(slice.call(arguments)));
717    };
718    return bound;
719  };
720
721  // Partially apply a function by creating a version that has had some of its
722  // arguments pre-filled, without changing its dynamic `this` context. _ acts
723  // as a placeholder, allowing any combination of arguments to be pre-filled.
724  _.partial = function(func) {
725    var boundArgs = slice.call(arguments, 1);
726    var bound = function() {
727      var position = 0, length = boundArgs.length;
728      var args = Array(length);
729      for (var i = 0; i < length; i++) {
730        args[i] = boundArgs[i] === _ ? arguments[position++] : boundArgs[i];
731      }
732      while (position < arguments.length) args.push(arguments[position++]);
733      return executeBound(func, bound, this, this, args);
734    };
735    return bound;
736  };
737
738  // Bind a number of an object's methods to that object. Remaining arguments
739  // are the method names to be bound. Useful for ensuring that all callbacks
740  // defined on an object belong to it.
741  _.bindAll = function(obj) {
742    var i, length = arguments.length, key;
743    if (length <= 1) throw new Error('bindAll must be passed function names');
744    for (i = 1; i < length; i++) {
745      key = arguments[i];
746      obj[key] = _.bind(obj[key], obj);
747    }
748    return obj;
749  };
750
751  // Memoize an expensive function by storing its results.
752  _.memoize = function(func, hasher) {
753    var memoize = function(key) {
754      var cache = memoize.cache;
755      var address = '' + (hasher ? hasher.apply(this, arguments) : key);
756      if (!_.has(cache, address)) cache[address] = func.apply(this, arguments);
757      return cache[address];
758    };
759    memoize.cache = {};
760    return memoize;
761  };
762
763  // Delays a function for the given number of milliseconds, and then calls
764  // it with the arguments supplied.
765  _.delay = function(func, wait) {
766    var args = slice.call(arguments, 2);
767    return setTimeout(function(){
768      return func.apply(null, args);
769    }, wait);
770  };
771
772  // Defers a function, scheduling it to run after the current call stack has
773  // cleared.
774  _.defer = _.partial(_.delay, _, 1);
775
776  // Returns a function, that, when invoked, will only be triggered at most once
777  // during a given window of time. Normally, the throttled function will run
778  // as much as it can, without ever going more than once per `wait` duration;
779  // but if you'd like to disable the execution on the leading edge, pass
780  // `{leading: false}`. To disable execution on the trailing edge, ditto.
781  _.throttle = function(func, wait, options) {
782    var context, args, result;
783    var timeout = null;
784    var previous = 0;
785    if (!options) options = {};
786    var later = function() {
787      previous = options.leading === false ? 0 : _.now();
788      timeout = null;
789      result = func.apply(context, args);
790      if (!timeout) context = args = null;
791    };
792    return function() {
793      var now = _.now();
794      if (!previous && options.leading === false) previous = now;
795      var remaining = wait - (now - previous);
796      context = this;
797      args = arguments;
798      if (remaining <= 0 || remaining > wait) {
799        if (timeout) {
800          clearTimeout(timeout);
801          timeout = null;
802        }
803        previous = now;
804        result = func.apply(context, args);
805        if (!timeout) context = args = null;
806      } else if (!timeout && options.trailing !== false) {
807        timeout = setTimeout(later, remaining);
808      }
809      return result;
810    };
811  };
812
813  // Returns a function, that, as long as it continues to be invoked, will not
814  // be triggered. The function will be called after it stops being called for
815  // N milliseconds. If `immediate` is passed, trigger the function on the
816  // leading edge, instead of the trailing.
817  _.debounce = function(func, wait, immediate) {
818    var timeout, args, context, timestamp, result;
819
820    var later = function() {
821      var last = _.now() - timestamp;
822
823      if (last < wait && last >= 0) {
824        timeout = setTimeout(later, wait - last);
825      } else {
826        timeout = null;
827        if (!immediate) {
828          result = func.apply(context, args);
829          if (!timeout) context = args = null;
830        }
831      }
832    };
833
834    return function() {
835      context = this;
836      args = arguments;
837      timestamp = _.now();
838      var callNow = immediate && !timeout;
839      if (!timeout) timeout = setTimeout(later, wait);
840      if (callNow) {
841        result = func.apply(context, args);
842        context = args = null;
843      }
844
845      return result;
846    };
847  };
848
849  // Returns the first function passed as an argument to the second,
850  // allowing you to adjust arguments, run code before and after, and
851  // conditionally execute the original function.
852  _.wrap = function(func, wrapper) {
853    return _.partial(wrapper, func);
854  };
855
856  // Returns a negated version of the passed-in predicate.
857  _.negate = function(predicate) {
858    return function() {
859      return !predicate.apply(this, arguments);
860    };
861  };
862
863  // Returns a function that is the composition of a list of functions, each
864  // consuming the return value of the function that follows.
865  _.compose = function() {
866    var args = arguments;
867    var start = args.length - 1;
868    return function() {
869      var i = start;
870      var result = args[start].apply(this, arguments);
871      while (i--) result = args[i].call(this, result);
872      return result;
873    };
874  };
875
876  // Returns a function that will only be executed on and after the Nth call.
877  _.after = function(times, func) {
878    return function() {
879      if (--times < 1) {
880        return func.apply(this, arguments);
881      }
882    };
883  };
884
885  // Returns a function that will only be executed up to (but not including) the Nth call.
886  _.before = function(times, func) {
887    var memo;
888    return function() {
889      if (--times > 0) {
890        memo = func.apply(this, arguments);
891      }
892      if (times <= 1) func = null;
893      return memo;
894    };
895  };
896
897  // Returns a function that will be executed at most one time, no matter how
898  // often you call it. Useful for lazy initialization.
899  _.once = _.partial(_.before, 2);
900
901  // Object Functions
902  // ----------------
903
904  // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed.
905  var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString');
906  var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString',
907                      'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];
908
909  function collectNonEnumProps(obj, keys) {
910    var nonEnumIdx = nonEnumerableProps.length;
911    var constructor = obj.constructor;
912    var proto = (_.isFunction(constructor) && constructor.prototype) || ObjProto;
913
914    // Constructor is a special case.
915    var prop = 'constructor';
916    if (_.has(obj, prop) && !_.contains(keys, prop)) keys.push(prop);
917
918    while (nonEnumIdx--) {
919      prop = nonEnumerableProps[nonEnumIdx];
920      if (prop in obj && obj[prop] !== proto[prop] && !_.contains(keys, prop)) {
921        keys.push(prop);
922      }
923    }
924  }
925
926  // Retrieve the names of an object's own properties.
927  // Delegates to **ECMAScript 5**'s native `Object.keys`
928  _.keys = function(obj) {
929    if (!_.isObject(obj)) return [];
930    if (nativeKeys) return nativeKeys(obj);
931    var keys = [];
932    for (var key in obj) if (_.has(obj, key)) keys.push(key);
933    // Ahem, IE < 9.
934    if (hasEnumBug) collectNonEnumProps(obj, keys);
935    return keys;
936  };
937
938  // Retrieve all the property names of an object.
939  _.allKeys = function(obj) {
940    if (!_.isObject(obj)) return [];
941    var keys = [];
942    for (var key in obj) keys.push(key);
943    // Ahem, IE < 9.
944    if (hasEnumBug) collectNonEnumProps(obj, keys);
945    return keys;
946  };
947
948  // Retrieve the values of an object's properties.
949  _.values = function(obj) {
950    var keys = _.keys(obj);
951    var length = keys.length;
952    var values = Array(length);
953    for (var i = 0; i < length; i++) {
954      values[i] = obj[keys[i]];
955    }
956    return values;
957  };
958
959  // Returns the results of applying the iteratee to each element of the object
960  // In contrast to _.map it returns an object
961  _.mapObject = function(obj, iteratee, context) {
962    iteratee = cb(iteratee, context);
963    var keys =  _.keys(obj),
964          length = keys.length,
965          results = {},
966          currentKey;
967      for (var index = 0; index < length; index++) {
968        currentKey = keys[index];
969        results[currentKey] = iteratee(obj[currentKey], currentKey, obj);
970      }
971      return results;
972  };
973
974  // Convert an object into a list of `[key, value]` pairs.
975  _.pairs = function(obj) {
976    var keys = _.keys(obj);
977    var length = keys.length;
978    var pairs = Array(length);
979    for (var i = 0; i < length; i++) {
980      pairs[i] = [keys[i], obj[keys[i]]];
981    }
982    return pairs;
983  };
984
985  // Invert the keys and values of an object. The values must be serializable.
986  _.invert = function(obj) {
987    var result = {};
988    var keys = _.keys(obj);
989    for (var i = 0, length = keys.length; i < length; i++) {
990      result[obj[keys[i]]] = keys[i];
991    }
992    return result;
993  };
994
995  // Return a sorted list of the function names available on the object.
996  // Aliased as `methods`
997  _.functions = _.methods = function(obj) {
998    var names = [];
999    for (var key in obj) {
1000      if (_.isFunction(obj[key])) names.push(key);
1001    }
1002    return names.sort();
1003  };
1004
1005  // Extend a given object with all the properties in passed-in object(s).
1006  _.extend = createAssigner(_.allKeys);
1007
1008  // Assigns a given object with all the own properties in the passed-in object(s)
1009  // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
1010  _.extendOwn = _.assign = createAssigner(_.keys);
1011
1012  // Returns the first key on an object that passes a predicate test
1013  _.findKey = function(obj, predicate, context) {
1014    predicate = cb(predicate, context);
1015    var keys = _.keys(obj), key;
1016    for (var i = 0, length = keys.length; i < length; i++) {
1017      key = keys[i];
1018      if (predicate(obj[key], key, obj)) return key;
1019    }
1020  };
1021
1022  // Return a copy of the object only containing the whitelisted properties.
1023  _.pick = function(object, oiteratee, context) {
1024    var result = {}, obj = object, iteratee, keys;
1025    if (obj == null) return result;
1026    if (_.isFunction(oiteratee)) {
1027      keys = _.allKeys(obj);
1028      iteratee = optimizeCb(oiteratee, context);
1029    } else {
1030      keys = flatten(arguments, false, false, 1);
1031      iteratee = function(value, key, obj) { return key in obj; };
1032      obj = Object(obj);
1033    }
1034    for (var i = 0, length = keys.length; i < length; i++) {
1035      var key = keys[i];
1036      var value = obj[key];
1037      if (iteratee(value, key, obj)) result[key] = value;
1038    }
1039    return result;
1040  };
1041
1042   // Return a copy of the object without the blacklisted properties.
1043  _.omit = function(obj, iteratee, context) {
1044    if (_.isFunction(iteratee)) {
1045      iteratee = _.negate(iteratee);
1046    } else {
1047      var keys = _.map(flatten(arguments, false, false, 1), String);
1048      iteratee = function(value, key) {
1049        return !_.contains(keys, key);
1050      };
1051    }
1052    return _.pick(obj, iteratee, context);
1053  };
1054
1055  // Fill in a given object with default properties.
1056  _.defaults = createAssigner(_.allKeys, true);
1057
1058  // Creates an object that inherits from the given prototype object.
1059  // If additional properties are provided then they will be added to the
1060  // created object.
1061  _.create = function(prototype, props) {
1062    var result = baseCreate(prototype);
1063    if (props) _.extendOwn(result, props);
1064    return result;
1065  };
1066
1067  // Create a (shallow-cloned) duplicate of an object.
1068  _.clone = function(obj) {
1069    if (!_.isObject(obj)) return obj;
1070    return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
1071  };
1072
1073  // Invokes interceptor with the obj, and then returns obj.
1074  // The primary purpose of this method is to "tap into" a method chain, in
1075  // order to perform operations on intermediate results within the chain.
1076  _.tap = function(obj, interceptor) {
1077    interceptor(obj);
1078    return obj;
1079  };
1080
1081  // Returns whether an object has a given set of `key:value` pairs.
1082  _.isMatch = function(object, attrs) {
1083    var keys = _.keys(attrs), length = keys.length;
1084    if (object == null) return !length;
1085    var obj = Object(object);
1086    for (var i = 0; i < length; i++) {
1087      var key = keys[i];
1088      if (attrs[key] !== obj[key] || !(key in obj)) return false;
1089    }
1090    return true;
1091  };
1092
1093
1094  // Internal recursive comparison function for `isEqual`.
1095  var eq = function(a, b, aStack, bStack) {
1096    // Identical objects are equal. `0 === -0`, but they aren't identical.
1097    // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
1098    if (a === b) return a !== 0 || 1 / a === 1 / b;
1099    // A strict comparison is necessary because `null == undefined`.
1100    if (a == null || b == null) return a === b;
1101    // Unwrap any wrapped objects.
1102    if (a instanceof _) a = a._wrapped;
1103    if (b instanceof _) b = b._wrapped;
1104    // Compare `[[Class]]` names.
1105    var className = toString.call(a);
1106    if (className !== toString.call(b)) return false;
1107    switch (className) {
1108      // Strings, numbers, regular expressions, dates, and booleans are compared by value.
1109      case '[object RegExp]':
1110      // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i')
1111      case '[object String]':
1112        // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
1113        // equivalent to `new String("5")`.
1114        return '' + a === '' + b;
1115      case '[object Number]':
1116        // `NaN`s are equivalent, but non-reflexive.
1117        // Object(NaN) is equivalent to NaN
1118        if (+a !== +a) return +b !== +b;
1119        // An `egal` comparison is performed for other numeric values.
1120        return +a === 0 ? 1 / +a === 1 / b : +a === +b;
1121      case '[object Date]':
1122      case '[object Boolean]':
1123        // Coerce dates and booleans to numeric primitive values. Dates are compared by their
1124        // millisecond representations. Note that invalid dates with millisecond representations
1125        // of `NaN` are not equivalent.
1126        return +a === +b;
1127    }
1128
1129    var areArrays = className === '[object Array]';
1130    if (!areArrays) {
1131      if (typeof a != 'object' || typeof b != 'object') return false;
1132
1133      // Objects with different constructors are not equivalent, but `Object`s or `Array`s
1134      // from different frames are.
1135      var aCtor = a.constructor, bCtor = b.constructor;
1136      if (aCtor !== bCtor && !(_.isFunction(aCtor) && aCtor instanceof aCtor &&
1137                               _.isFunction(bCtor) && bCtor instanceof bCtor)
1138                          && ('constructor' in a && 'constructor' in b)) {
1139        return false;
1140      }
1141    }
1142    // Assume equality for cyclic structures. The algorithm for detecting cyclic
1143    // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
1144
1145    // Initializing stack of traversed objects.
1146    // It's done here since we only need them for objects and arrays comparison.
1147    aStack = aStack || [];
1148    bStack = bStack || [];
1149    var length = aStack.length;
1150    while (length--) {
1151      // Linear search. Performance is inversely proportional to the number of
1152      // unique nested structures.
1153      if (aStack[length] === a) return bStack[length] === b;
1154    }
1155
1156    // Add the first object to the stack of traversed objects.
1157    aStack.push(a);
1158    bStack.push(b);
1159
1160    // Recursively compare objects and arrays.
1161    if (areArrays) {
1162      // Compare array lengths to determine if a deep comparison is necessary.
1163      length = a.length;
1164      if (length !== b.length) return false;
1165      // Deep compare the contents, ignoring non-numeric properties.
1166      while (length--) {
1167        if (!eq(a[length], b[length], aStack, bStack)) return false;
1168      }
1169    } else {
1170      // Deep compare objects.
1171      var keys = _.keys(a), key;
1172      length = keys.length;
1173      // Ensure that both objects contain the same number of properties before comparing deep equality.
1174      if (_.keys(b).length !== length) return false;
1175      while (length--) {
1176        // Deep compare each member
1177        key = keys[length];
1178        if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) return false;
1179      }
1180    }
1181    // Remove the first object from the stack of traversed objects.
1182    aStack.pop();
1183    bStack.pop();
1184    return true;
1185  };
1186
1187  // Perform a deep comparison to check if two objects are equal.
1188  _.isEqual = function(a, b) {
1189    return eq(a, b);
1190  };
1191
1192  // Is a given array, string, or object empty?
1193  // An "empty" object has no enumerable own-properties.
1194  _.isEmpty = function(obj) {
1195    if (obj == null) return true;
1196    if (isArrayLike(obj) && (_.isArray(obj) || _.isString(obj) || _.isArguments(obj))) return obj.length === 0;
1197    return _.keys(obj).length === 0;
1198  };
1199
1200  // Is a given value a DOM element?
1201  _.isElement = function(obj) {
1202    return !!(obj && obj.nodeType === 1);
1203  };
1204
1205  // Is a given value an array?
1206  // Delegates to ECMA5's native Array.isArray
1207  _.isArray = nativeIsArray || function(obj) {
1208    return toString.call(obj) === '[object Array]';
1209  };
1210
1211  // Is a given variable an object?
1212  _.isObject = function(obj) {
1213    var type = typeof obj;
1214    return type === 'function' || type === 'object' && !!obj;
1215  };
1216
1217  // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError.
1218  _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error'], function(name) {
1219    _['is' + name] = function(obj) {
1220      return toString.call(obj) === '[object ' + name + ']';
1221    };
1222  });
1223
1224  // Define a fallback version of the method in browsers (ahem, IE < 9), where
1225  // there isn't any inspectable "Arguments" type.
1226  if (!_.isArguments(arguments)) {
1227    _.isArguments = function(obj) {
1228      return _.has(obj, 'callee');
1229    };
1230  }
1231
1232  // Optimize `isFunction` if appropriate. Work around some typeof bugs in old v8,
1233  // IE 11 (#1621), and in Safari 8 (#1929).
1234  if (typeof /./ != 'function' && typeof Int8Array != 'object') {
1235    _.isFunction = function(obj) {
1236      return typeof obj == 'function' || false;
1237    };
1238  }
1239
1240  // Is a given object a finite number?
1241  _.isFinite = function(obj) {
1242    return isFinite(obj) && !isNaN(parseFloat(obj));
1243  };
1244
1245  // Is the given value `NaN`? (NaN is the only number which does not equal itself).
1246  _.isNaN = function(obj) {
1247    return _.isNumber(obj) && obj !== +obj;
1248  };
1249
1250  // Is a given value a boolean?
1251  _.isBoolean = function(obj) {
1252    return obj === true || obj === false || toString.call(obj) === '[object Boolean]';
1253  };
1254
1255  // Is a given value equal to null?
1256  _.isNull = function(obj) {
1257    return obj === null;
1258  };
1259
1260  // Is a given variable undefined?
1261  _.isUndefined = function(obj) {
1262    return obj === void 0;
1263  };
1264
1265  // Shortcut function for checking if an object has a given property directly
1266  // on itself (in other words, not on a prototype).
1267  _.has = function(obj, key) {
1268    return obj != null && hasOwnProperty.call(obj, key);
1269  };
1270
1271  // Utility Functions
1272  // -----------------
1273
1274  // Run Underscore.js in *noConflict* mode, returning the `_` variable to its
1275  // previous owner. Returns a reference to the Underscore object.
1276  _.noConflict = function() {
1277    root._ = previousUnderscore;
1278    return this;
1279  };
1280
1281  // Keep the identity function around for default iteratees.
1282  _.identity = function(value) {
1283    return value;
1284  };
1285
1286  // Predicate-generating functions. Often useful outside of Underscore.
1287  _.constant = function(value) {
1288    return function() {
1289      return value;
1290    };
1291  };
1292
1293  _.noop = function(){};
1294
1295  _.property = property;
1296
1297  // Generates a function for a given object that returns a given property.
1298  _.propertyOf = function(obj) {
1299    return obj == null ? function(){} : function(key) {
1300      return obj[key];
1301    };
1302  };
1303
1304  // Returns a predicate for checking whether an object has a given set of
1305  // `key:value` pairs.
1306  _.matcher = _.matches = function(attrs) {
1307    attrs = _.extendOwn({}, attrs);
1308    return function(obj) {
1309      return _.isMatch(obj, attrs);
1310    };
1311  };
1312
1313  // Run a function **n** times.
1314  _.times = function(n, iteratee, context) {
1315    var accum = Array(Math.max(0, n));
1316    iteratee = optimizeCb(iteratee, context, 1);
1317    for (var i = 0; i < n; i++) accum[i] = iteratee(i);
1318    return accum;
1319  };
1320
1321  // Return a random integer between min and max (inclusive).
1322  _.random = function(min, max) {
1323    if (max == null) {
1324      max = min;
1325      min = 0;
1326    }
1327    return min + Math.floor(Math.random() * (max - min + 1));
1328  };
1329
1330  // A (possibly faster) way to get the current timestamp as an integer.
1331  _.now = Date.now || function() {
1332    return new Date().getTime();
1333  };
1334
1335   // List of HTML entities for escaping.
1336  var escapeMap = {
1337    '&': '&amp;',
1338    '<': '&lt;',
1339    '>': '&gt;',
1340    '"': '&quot;',
1341    "'": '&#x27;',
1342    '`': '&#x60;'
1343  };
1344  var unescapeMap = _.invert(escapeMap);
1345
1346  // Functions for escaping and unescaping strings to/from HTML interpolation.
1347  var createEscaper = function(map) {
1348    var escaper = function(match) {
1349      return map[match];
1350    };
1351    // Regexes for identifying a key that needs to be escaped
1352    var source = '(?:' + _.keys(map).join('|') + ')';
1353    var testRegexp = RegExp(source);
1354    var replaceRegexp = RegExp(source, 'g');
1355    return function(string) {
1356      string = string == null ? '' : '' + string;
1357      return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
1358    };
1359  };
1360  _.escape = createEscaper(escapeMap);
1361  _.unescape = createEscaper(unescapeMap);
1362
1363  // If the value of the named `property` is a function then invoke it with the
1364  // `object` as context; otherwise, return it.
1365  _.result = function(object, property, fallback) {
1366    var value = object == null ? void 0 : object[property];
1367    if (value === void 0) {
1368      value = fallback;
1369    }
1370    return _.isFunction(value) ? value.call(object) : value;
1371  };
1372
1373  // Generate a unique integer id (unique within the entire client session).
1374  // Useful for temporary DOM ids.
1375  var idCounter = 0;
1376  _.uniqueId = function(prefix) {
1377    var id = ++idCounter + '';
1378    return prefix ? prefix + id : id;
1379  };
1380
1381  // By default, Underscore uses ERB-style template delimiters, change the
1382  // following template settings to use alternative delimiters.
1383  _.templateSettings = {
1384    evaluate    : /<%([\s\S]+?)%>/g,
1385    interpolate : /<%=([\s\S]+?)%>/g,
1386    escape      : /<%-([\s\S]+?)%>/g
1387  };
1388
1389  // When customizing `templateSettings`, if you don't want to define an
1390  // interpolation, evaluation or escaping regex, we need one that is
1391  // guaranteed not to match.
1392  var noMatch = /(.)^/;
1393
1394  // Certain characters need to be escaped so that they can be put into a
1395  // string literal.
1396  var escapes = {
1397    "'":      "'",
1398    '\\':     '\\',
1399    '\r':     'r',
1400    '\n':     'n',
1401    '\u2028': 'u2028',
1402    '\u2029': 'u2029'
1403  };
1404
1405  var escaper = /\\|'|\r|\n|\u2028|\u2029/g;
1406
1407  var escapeChar = function(match) {
1408    return '\\' + escapes[match];
1409  };
1410
1411  // JavaScript micro-templating, similar to John Resig's implementation.
1412  // Underscore templating handles arbitrary delimiters, preserves whitespace,
1413  // and correctly escapes quotes within interpolated code.
1414  // NB: `oldSettings` only exists for backwards compatibility.
1415  _.template = function(text, settings, oldSettings) {
1416    if (!settings && oldSettings) settings = oldSettings;
1417    settings = _.defaults({}, settings, _.templateSettings);
1418
1419    // Combine delimiters into one regular expression via alternation.
1420    var matcher = RegExp([
1421      (settings.escape || noMatch).source,
1422      (settings.interpolate || noMatch).source,
1423      (settings.evaluate || noMatch).source
1424    ].join('|') + '|$', 'g');
1425
1426    // Compile the template source, escaping string literals appropriately.
1427    var index = 0;
1428    var source = "__p+='";
1429    text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
1430      source += text.slice(index, offset).replace(escaper, escapeChar);
1431      index = offset + match.length;
1432
1433      if (escape) {
1434        source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
1435      } else if (interpolate) {
1436        source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
1437      } else if (evaluate) {
1438        source += "';\n" + evaluate + "\n__p+='";
1439      }
1440
1441      // Adobe VMs need the match returned to produce the correct offest.
1442      return match;
1443    });
1444    source += "';\n";
1445
1446    // If a variable is not specified, place data values in local scope.
1447    if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
1448
1449    source = "var __t,__p='',__j=Array.prototype.join," +
1450      "print=function(){__p+=__j.call(arguments,'');};\n" +
1451      source + 'return __p;\n';
1452
1453    try {
1454      var render = new Function(settings.variable || 'obj', '_', source);
1455    } catch (e) {
1456      e.source = source;
1457      throw e;
1458    }
1459
1460    var template = function(data) {
1461      return render.call(this, data, _);
1462    };
1463
1464    // Provide the compiled source as a convenience for precompilation.
1465    var argument = settings.variable || 'obj';
1466    template.source = 'function(' + argument + '){\n' + source + '}';
1467
1468    return template;
1469  };
1470
1471  // Add a "chain" function. Start chaining a wrapped Underscore object.
1472  _.chain = function(obj) {
1473    var instance = _(obj);
1474    instance._chain = true;
1475    return instance;
1476  };
1477
1478  // OOP
1479  // ---------------
1480  // If Underscore is called as a function, it returns a wrapped object that
1481  // can be used OO-style. This wrapper holds altered versions of all the
1482  // underscore functions. Wrapped objects may be chained.
1483
1484  // Helper function to continue chaining intermediate results.
1485  var result = function(instance, obj) {
1486    return instance._chain ? _(obj).chain() : obj;
1487  };
1488
1489  // Add your own custom functions to the Underscore object.
1490  _.mixin = function(obj) {
1491    _.each(_.functions(obj), function(name) {
1492      var func = _[name] = obj[name];
1493      _.prototype[name] = function() {
1494        var args = [this._wrapped];
1495        push.apply(args, arguments);
1496        return result(this, func.apply(_, args));
1497      };
1498    });
1499  };
1500
1501  // Add all of the Underscore functions to the wrapper object.
1502  _.mixin(_);
1503
1504  // Add all mutator Array functions to the wrapper.
1505  _.each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
1506    var method = ArrayProto[name];
1507    _.prototype[name] = function() {
1508      var obj = this._wrapped;
1509      method.apply(obj, arguments);
1510      if ((name === 'shift' || name === 'splice') && obj.length === 0) delete obj[0];
1511      return result(this, obj);
1512    };
1513  });
1514
1515  // Add all accessor Array functions to the wrapper.
1516  _.each(['concat', 'join', 'slice'], function(name) {
1517    var method = ArrayProto[name];
1518    _.prototype[name] = function() {
1519      return result(this, method.apply(this._wrapped, arguments));
1520    };
1521  });
1522
1523  // Extracts the result from a wrapped and chained object.
1524  _.prototype.value = function() {
1525    return this._wrapped;
1526  };
1527
1528  // Provide unwrapping proxy for some methods used in engine operations
1529  // such as arithmetic and JSON stringification.
1530  _.prototype.valueOf = _.prototype.toJSON = _.prototype.value;
1531
1532  _.prototype.toString = function() {
1533    return '' + this._wrapped;
1534  };
1535
1536  // AMD registration happens at the end for compatibility with AMD loaders
1537  // that may not enforce next-turn semantics on modules. Even though general
1538  // practice for AMD registration is to be anonymous, underscore registers
1539  // as a named module because, like jQuery, it is a base library that is
1540  // popular enough to be bundled in a third party lib, but not be part of
1541  // an AMD load request. Those cases could generate an error when an
1542  // anonymous define() is called outside of a loader request.
1543  if (typeof define === 'function' && define.amd) {
1544    define('underscore', [], function() {
1545      return _;
1546    });
1547  }
1548}.call(this));
1549
1550
1551// Skip Link Focus Fix JS
1552// ----------------------------------------------------------------------------
1553// Helps with accessibility for keyboard only users.
1554// Learn more: https://github.com/Automattic/SALT Blog/pull/136
1555// ----------------------------------------------------------------------------
1556(function() {
1557    var is_webkit = navigator.userAgent.toLowerCase().indexOf('webkit') > -1,
1558        is_opera = navigator.userAgent.toLowerCase().indexOf('opera') > -1,
1559        is_ie = navigator.userAgent.toLowerCase().indexOf('msie') > -1;
1560
1561    if ((is_webkit || is_opera || is_ie) && document.getElementById && window.addEventListener) {
1562        window.addEventListener('hashchange', function() {
1563            var id = location.hash.substring(1),
1564                element;
1565
1566            if (!(/^[A-z0-9_-]+$/.test(id))) {
1567                return;
1568            }
1569
1570            element = document.getElementById(id);
1571
1572            if (element) {
1573                if (!(/^(?:a|select|input|button|textarea)$/i.test(element.tagName))) {
1574                    element.tabIndex = -1;
1575                }
1576
1577                element.focus();
1578            }
1579        }, false);
1580
1581    }
1582})();
1583
1584
1585// Navigation JS.
1586// ----------------------------------------------------------------------------
1587// Handles toggling the navigation menu for small screens and enables tab
1588// support for dropdown menus.
1589// ----------------------------------------------------------------------------
1590(function() {
1591    var container, buttons, menu, links, subMenus;
1592
1593    container = document.getElementById('site-navigation');
1594    if (!container) {
1595        return;
1596    }
1597
1598    buttons = document.getElementsByClassName('menu-toggle');
1599    if ('undefined' === typeof buttons) {
1600        return;
1601    }
1602
1603    menu = document.getElementById('primary-menu');
1604
1605    topBar = document.getElementById('top-bar');
1606
1607    // Hide menu toggle button if menu is empty and return early.
1608    if ('undefined' === typeof menu) {
1609        buttons.style.display = 'none';
1610        return;
1611    }
1612
1613    menu.setAttribute('aria-expanded', 'false');
1614
1615    if (-1 === menu.className.indexOf('primary-menu')) {
1616        menu.className += ' primary-menu';
1617    }
1618
1619    for (var i = 0; i < buttons.length; i++) {
1620        buttons[i].onclick = function() {
1621            if (-1 !== container.className.indexOf('toggled')) {
1622                container.className = container.className.replace(' toggled', '');
1623                topBar.className = topBar.className.replace(' toggled', '');
1624                menu.setAttribute('aria-expanded', 'false');
1625
1626                for (var i = 0; i < buttons.length; i++) {
1627                    buttons[i].setAttribute('aria-expanded', 'false');
1628                }
1629            } else {
1630                container.className += ' toggled';
1631                topBar.className += ' toggled';
1632                menu.setAttribute('aria-expanded', 'true');
1633
1634                for (var i = 0; i < buttons.length; i++) {
1635                    buttons[i].setAttribute('aria-expanded', 'true');
1636                }
1637            }
1638        };
1639    };
1640
1641    // Get all the link elements within the menu.
1642    links = menu.getElementsByTagName('a');
1643    subMenus = menu.getElementsByTagName('ul');
1644
1645    // Set menu items with submenus to aria-haspopup="true".
1646    for (var i = 0, len = subMenus.length; i < len; i++) {
1647        subMenus[i].parentNode.setAttribute('aria-haspopup', 'true');
1648    }
1649
1650})();
1651
1652
1653/*
1654     _ _      _       _
1655 ___| (_) ___| | __  (_)___
1656/ __| | |/ __| |/ /  | / __|
1657\__ \ | | (__|   < _ | \__ \
1658|___/_|_|\___|_|\_(_)/ |___/
1659                   |__/
1660
1661 Version: 1.6.0
1662  Author: Ken Wheeler
1663 Website: http://kenwheeler.github.io
1664    Docs: http://kenwheeler.github.io/slick
1665    Repo: http://github.com/kenwheeler/slick
1666  Issues: http://github.com/kenwheeler/slick/issues
1667
1668 */
1669/* global window, document, define, jQuery, setInterval, clearInterval */
1670(function(factory) {
1671    'use strict';
1672    if (typeof define === 'function' && define.amd) {
1673        define(['jquery'], factory);
1674    } else if (typeof exports !== 'undefined') {
1675        module.exports = factory(require('jquery'));
1676    } else {
1677        factory(jQuery);
1678    }
1679
1680}(function($) {
1681    'use strict';
1682    var Slick = window.Slick || {};
1683
1684    Slick = (function() {
1685
1686        var instanceUid = 0;
1687
1688        function Slick(element, settings) {
1689
1690            var _ = this, dataSettings;
1691
1692            _.defaults = {
1693                accessibility: true,
1694                adaptiveHeight: false,
1695                appendArrows: $(element),
1696                appendDots: $(element),
1697                arrows: true,
1698                asNavFor: null,
1699                prevArrow: '<button type="button" data-role="none" class="slick-prev" aria-label="Previous" tabindex="0" role="button">Previous</button>',
1700                nextArrow: '<button type="button" data-role="none" class="slick-next" aria-label="Next" tabindex="0" role="button">Next</button>',
1701                autoplay: false,
1702                autoplaySpeed: 3000,
1703                centerMode: false,
1704                centerPadding: '50px',
1705                cssEase: 'ease',
1706                customPaging: function(slider, i) {
1707                    return $('<button type="button" data-role="none" role="button" tabindex="0" />').text(i + 1);
1708                },
1709                dots: false,
1710                dotsClass: 'slick-dots',
1711                draggable: true,
1712                easing: 'linear',
1713                edgeFriction: 0.35,
1714                fade: false,
1715                focusOnSelect: false,
1716                infinite: true,
1717                initialSlide: 0,
1718                lazyLoad: 'ondemand',
1719                mobileFirst: false,
1720                pauseOnHover: true,
1721                pauseOnFocus: true,
1722                pauseOnDotsHover: false,
1723                respondTo: 'window',
1724                responsive: null,
1725                rows: 1,
1726                rtl: false,
1727                slide: '',
1728                slidesPerRow: 1,
1729                slidesToShow: 1,
1730                slidesToScroll: 1,
1731                speed: 500,
1732                swipe: true,
1733                swipeToSlide: false,
1734                touchMove: true,
1735                touchThreshold: 5,
1736                useCSS: true,
1737                useTransform: true,
1738                variableWidth: false,
1739                vertical: false,
1740                verticalSwiping: false,
1741                waitForAnimate: true,
1742                zIndex: 1000
1743            };
1744
1745            _.initials = {
1746                animating: false,
1747                dragging: false,
1748                autoPlayTimer: null,
1749                currentDirection: 0,
1750                currentLeft: null,
1751                currentSlide: 0,
1752                direction: 1,
1753                $dots: null,
1754                listWidth: null,
1755                listHeight: null,
1756                loadIndex: 0,
1757                $nextArrow: null,
1758                $prevArrow: null,
1759                slideCount: null,
1760                slideWidth: null,
1761                $slideTrack: null,
1762                $slides: null,
1763                sliding: false,
1764                slideOffset: 0,
1765                swipeLeft: null
vendor: 11,177 bytes, lines 1765-2148
1765,
1766                $list: null,
1767                touchObject: {},
1768                transformsEnabled: false,
1769                unslicked: false
1770            };
1771
1772            $.extend(_, _.initials);
1773
1774            _.activeBreakpoint = null;
1775            _.animType = null;
1776            _.animProp = null;
1777            _.breakpoints = [];
1778            _.breakpointSettings = [];
1779            _.cssTransitions = false;
1780            _.focussed = false;
1781            _.interrupted = false;
1782            _.hidden = 'hidden';
1783            _.paused = true;
1784            _.positionProp = null;
1785            _.respondTo = null;
1786            _.rowCount = 1;
1787            _.shouldClick = true;
1788            _.$slider = $(element);
1789            _.$slidesCache = null;
1790            _.transformType = null;
1791            _.transitionType = null;
1792            _.visibilityChange = 'visibilitychange';
1793            _.windowWidth = 0;
1794            _.windowTimer = null;
1795
1796            dataSettings = $(element).data('slick') || {};
1797
1798            _.options = $.extend({}, _.defaults, settings, dataSettings);
1799
1800            _.currentSlide = _.options.initialSlide;
1801
1802            _.originalSettings = _.options;
1803
1804            if (typeof document.mozHidden !== 'undefined') {
1805                _.hidden = 'mozHidden';
1806                _.visibilityChange = 'mozvisibilitychange';
1807            } else if (typeof document.webkitHidden !== 'undefined') {
1808                _.hidden = 'webkitHidden';
1809                _.visibilityChange = 'webkitvisibilitychange';
1810            }
1811
1812            _.autoPlay = $.proxy(_.autoPlay, _);
1813            _.autoPlayClear = $.proxy(_.autoPlayClear, _);
1814            _.autoPlayIterator = $.proxy(_.autoPlayIterator, _);
1815            _.changeSlide = $.proxy(_.changeSlide, _);
1816            _.clickHandler = $.proxy(_.clickHandler, _);
1817            _.selectHandler = $.proxy(_.selectHandler, _);
1818            _.setPosition = $.proxy(_.setPosition, _);
1819            _.swipeHandler = $.proxy(_.swipeHandler, _);
1820            _.dragHandler = $.proxy(_.dragHandler, _);
1821            _.keyHandler = $.proxy(_.keyHandler, _);
1822
1823            _.instanceUid = instanceUid++;
1824
1825            // A simple way to check for HTML strings
1826            // Strict HTML recognition (must start with <)
1827            // Extracted from jQuery v1.11 source
1828            _.htmlExpr = /^(?:\s*(<[\w\W]+>)[^>]*)$/;
1829
1830
1831            _.registerBreakpoints();
1832            _.init(true);
1833
1834        }
1835
1836        return Slick;
1837
1838    }());
1839
1840    Slick.prototype.activateADA = function() {
1841        var _ = this;
1842
1843        _.$slideTrack.find('.slick-active').attr({
1844            'aria-hidden': 'false'
1845        }).find('a, input, button, select').attr({
1846            'tabindex': '0'
1847        });
1848
1849    };
1850
1851    Slick.prototype.addSlide = Slick.prototype.slickAdd = function(markup, index, addBefore) {
1852
1853        var _ = this;
1854
1855        if (typeof(index) === 'boolean') {
1856            addBefore = index;
1857            index = null;
1858        } else if (index < 0 || (index >= _.slideCount)) {
1859            return false;
1860        }
1861
1862        _.unload();
1863
1864        if (typeof(index) === 'number') {
1865            if (index === 0 && _.$slides.length === 0) {
1866                $(markup).appendTo(_.$slideTrack);
1867            } else if (addBefore) {
1868                $(markup).insertBefore(_.$slides.eq(index));
1869            } else {
1870                $(markup).insertAfter(_.$slides.eq(index));
1871            }
1872        } else {
1873            if (addBefore === true) {
1874                $(markup).prependTo(_.$slideTrack);
1875            } else {
1876                $(markup).appendTo(_.$slideTrack);
1877            }
1878        }
1879
1880        _.$slides = _.$slideTrack.children(this.options.slide);
1881
1882        _.$slideTrack.children(this.options.slide).detach();
1883
1884        _.$slideTrack.append(_.$slides);
1885
1886        _.$slides.each(function(index, element) {
1887            $(element).attr('data-slick-index', index);
1888        });
1889
1890        _.$slidesCache = _.$slides;
1891
1892        _.reinit();
1893
1894    };
1895
1896    Slick.prototype.animateHeight = function() {
1897        var _ = this;
1898        if (_.options.slidesToShow === 1 && _.options.adaptiveHeight === true && _.options.vertical === false) {
1899            var targetHeight = _.$slides.eq(_.currentSlide).outerHeight(true);
1900            _.$list.animate({
1901                height: targetHeight
1902            }, _.options.speed);
1903        }
1904    };
1905
1906    Slick.prototype.animateSlide = function(targetLeft, callback) {
1907
1908        var animProps = {},
1909            _ = this;
1910
1911        _.animateHeight();
1912
1913        if (_.options.rtl === true && _.options.vertical === false) {
1914            targetLeft = -targetLeft;
1915        }
1916        if (_.transformsEnabled === false) {
1917            if (_.options.vertical === false) {
1918                _.$slideTrack.animate({
1919                    left: targetLeft
1920                }, _.options.speed, _.options.easing, callback);
1921            } else {
1922                _.$slideTrack.animate({
1923                    top: targetLeft
1924                }, _.options.speed, _.options.easing, callback);
1925            }
1926
1927        } else {
1928
1929            if (_.cssTransitions === false) {
1930                if (_.options.rtl === true) {
1931                    _.currentLeft = -(_.currentLeft);
1932                }
1933                $({
1934                    animStart: _.currentLeft
1935                }).animate({
1936                    animStart: targetLeft
1937                }, {
1938                    duration: _.options.speed,
1939                    easing: _.options.easing,
1940                    step: function(now) {
1941                        now = Math.ceil(now);
1942                        if (_.options.vertical === false) {
1943                            animProps[_.animType] = 'translate(' +
1944                                now + 'px, 0px)';
1945                            _.$slideTrack.css(animProps);
1946                        } else {
1947                            animProps[_.animType] = 'translate(0px,' +
1948                                now + 'px)';
1949                            _.$slideTrack.css(animProps);
1950                        }
1951                    },
1952                    complete: function() {
1953                        if (callback) {
1954                            callback.call();
1955                        }
1956                    }
1957                });
1958
1959            } else {
1960
1961                _.applyTransition();
1962                targetLeft = Math.ceil(targetLeft);
1963
1964                if (_.options.vertical === false) {
1965                    animProps[_.animType] = 'translate3d(' + targetLeft + 'px, 0px, 0px)';
1966                } else {
1967                    animProps[_.animType] = 'translate3d(0px,' + targetLeft + 'px, 0px)';
1968                }
1969                _.$slideTrack.css(animProps);
1970
1971                if (callback) {
1972                    setTimeout(function() {
1973
1974                        _.disableTransition();
1975
1976                        callback.call();
1977                    }, _.options.speed);
1978                }
1979
1980            }
1981
1982        }
1983
1984    };
1985
1986    Slick.prototype.getNavTarget = function() {
1987
1988        var _ = this,
1989            asNavFor = _.options.asNavFor;
1990
1991        if ( asNavFor && asNavFor !== null ) {
1992            asNavFor = $(asNavFor).not(_.$slider);
1993        }
1994
1995        return asNavFor;
1996
1997    };
1998
1999    Slick.prototype.asNavFor = function(index) {
2000
2001        var _ = this,
2002            asNavFor = _.getNavTarget();
2003
2004        if ( asNavFor !== null && typeof asNavFor === 'object' ) {
2005            asNavFor.each(function() {
2006                var target = $(this).slick('getSlick');
2007                if(!target.unslicked) {
2008                    target.slideHandler(index, true);
2009                }
2010            });
2011        }
2012
2013    };
2014
2015    Slick.prototype.applyTransition = function(slide) {
2016
2017        var _ = this,
2018            transition = {};
2019
2020        if (_.options.fade === false) {
2021            transition[_.transitionType] = _.transformType + ' ' + _.options.speed + 'ms ' + _.options.cssEase;
2022        } else {
2023            transition[_.transitionType] = 'opacity ' + _.options.speed + 'ms ' + _.options.cssEase;
2024        }
2025
2026        if (_.options.fade === false) {
2027            _.$slideTrack.css(transition);
2028        } else {
2029            _.$slides.eq(slide).css(transition);
2030        }
2031
2032    };
2033
2034    Slick.prototype.autoPlay = function() {
2035
2036        var _ = this;
2037
2038        _.autoPlayClear();
2039
2040        if ( _.slideCount > _.options.slidesToShow ) {
2041            _.autoPlayTimer = setInterval( _.autoPlayIterator, _.options.autoplaySpeed );
2042        }
2043
2044    };
2045
2046    Slick.prototype.autoPlayClear = function() {
2047
2048        var _ = this;
2049
2050        if (_.autoPlayTimer) {
2051            clearInterval(_.autoPlayTimer);
2052        }
2053
2054    };
2055
2056    Slick.prototype.autoPlayIterator = function() {
2057
2058        var _ = this,
2059            slideTo = _.currentSlide + _.options.slidesToScroll;
2060
2061        if ( !_.paused && !_.interrupted && !_.focussed ) {
2062
2063            if ( _.options.infinite === false ) {
2064
2065                if ( _.direction === 1 && ( _.currentSlide + 1 ) === ( _.slideCount - 1 )) {
2066                    _.direction = 0;
2067                }
2068
2069                else if ( _.direction === 0 ) {
2070
2071                    slideTo = _.currentSlide - _.options.slidesToScroll;
2072
2073                    if ( _.currentSlide - 1 === 0 ) {
2074                        _.direction = 1;
2075                    }
2076
2077                }
2078
2079            }
2080
2081            _.slideHandler( slideTo );
2082
2083        }
2084
2085    };
2086
2087    Slick.prototype.buildArrows = function() {
2088
2089        var _ = this;
2090
2091        if (_.options.arrows === true ) {
2092
2093            _.$prevArrow = $(_.options.prevArrow).addClass('slick-arrow');
2094            _.$nextArrow = $(_.options.nextArrow).addClass('slick-arrow');
2095
2096            if( _.slideCount > _.options.slidesToShow ) {
2097
2098                _.$prevArrow.removeClass('slick-hidden').removeAttr('aria-hidden tabindex');
2099                _.$nextArrow.removeClass('slick-hidden').removeAttr('aria-hidden tabindex');
2100
2101                if (_.htmlExpr.test(_.options.prevArrow)) {
2102                    _.$prevArrow.prependTo(_.options.appendArrows);
2103                }
2104
2105                if (_.htmlExpr.test(_.options.nextArrow)) {
2106                    _.$nextArrow.appendTo(_.options.appendArrows);
2107                }
2108
2109                if (_.options.infinite !== true) {
2110                    _.$prevArrow
2111                        .addClass('slick-disabled')
2112                        .attr('aria-disabled', 'true');
2113                }
2114
2115            } else {
2116
2117                _.$prevArrow.add( _.$nextArrow )
2118
2119                    .addClass('slick-hidden')
2120                    .attr({
2121                        'aria-disabled': 'true',
2122                        'tabindex': '-1'
2123                    });
2124
2125            }
2126
2127        }
2128
2129    };
2130
2131    Slick.prototype.buildDots = function() {
2132
2133        var _ = this,
2134            i, dot;
2135
2136        if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
2137
2138            _.$slider.addClass('slick-dotted');
2139
2140            dot = $('<ul />').addClass(_.options.dotsClass);
2141
2142            for (i = 0; i <= _.getDotCount(); i += 1) {
2143                dot.append($('<li />').append(_.options.customPaging.call(this, _, i)));
2144            }
2145
2146            _.$dots = dot.appendTo(_.options.appendDots);
2147
2148            _.$dots.find('li').first().addClass('slick-active')
vendor: 18,779 bytes, lines 2148-2757
2148.attr('aria-hidden', 'false');
2149
2150        }
2151
2152    };
2153
2154    Slick.prototype.buildOut = function() {
2155
2156        var _ = this;
2157
2158        _.$slides =
2159            _.$slider
2160                .children( _.options.slide + ':not(.slick-cloned)')
2161                .addClass('slick-slide');
2162
2163        _.slideCount = _.$slides.length;
2164
2165        _.$slides.each(function(index, element) {
2166            $(element)
2167                .attr('data-slick-index', index)
2168                .data('originalStyling', $(element).attr('style') || '');
2169        });
2170
2171        _.$slider.addClass('slick-slider');
2172
2173        _.$slideTrack = (_.slideCount === 0) ?
2174            $('<div class="slick-track"/>').appendTo(_.$slider) :
2175            _.$slides.wrapAll('<div class="slick-track"/>').parent();
2176
2177        _.$list = _.$slideTrack.wrap(
2178            '<div aria-live="polite" class="slick-list"/>').parent();
2179        _.$slideTrack.css('opacity', 0);
2180
2181        if (_.options.centerMode === true || _.options.swipeToSlide === true) {
2182            _.options.slidesToScroll = 1;
2183        }
2184
2185        $('img[data-lazy]', _.$slider).not('[src]').addClass('slick-loading');
2186
2187        _.setupInfinite();
2188
2189        _.buildArrows();
2190
2191        _.buildDots();
2192
2193        _.updateDots();
2194
2195
2196        _.setSlideClasses(typeof _.currentSlide === 'number' ? _.currentSlide : 0);
2197
2198        if (_.options.draggable === true) {
2199            _.$list.addClass('draggable');
2200        }
2201
2202    };
2203
2204    Slick.prototype.buildRows = function() {
2205
2206        var _ = this, a, b, c, newSlides, numOfSlides, originalSlides,slidesPerSection;
2207
2208        newSlides = document.createDocumentFragment();
2209        originalSlides = _.$slider.children();
2210
2211        if(_.options.rows > 1) {
2212
2213            slidesPerSection = _.options.slidesPerRow * _.options.rows;
2214            numOfSlides = Math.ceil(
2215                originalSlides.length / slidesPerSection
2216            );
2217
2218            for(a = 0; a < numOfSlides; a++){
2219                var slide = document.createElement('div');
2220                for(b = 0; b < _.options.rows; b++) {
2221                    var row = document.createElement('div');
2222                    for(c = 0; c < _.options.slidesPerRow; c++) {
2223                        var target = (a * slidesPerSection + ((b * _.options.slidesPerRow) + c));
2224                        if (originalSlides.get(target)) {
2225                            row.appendChild(originalSlides.get(target));
2226                        }
2227                    }
2228                    slide.appendChild(row);
2229                }
2230                newSlides.appendChild(slide);
2231            }
2232
2233            _.$slider.empty().append(newSlides);
2234            _.$slider.children().children().children()
2235                .css({
2236                    'width':(100 / _.options.slidesPerRow) + '%',
2237                    'display': 'inline-block'
2238                });
2239
2240        }
2241
2242    };
2243
2244    Slick.prototype.checkResponsive = function(initial, forceUpdate) {
2245
2246        var _ = this,
2247            breakpoint, targetBreakpoint, respondToWidth, triggerBreakpoint = false;
2248        var sliderWidth = _.$slider.width();
2249        var windowWidth = window.innerWidth || $(window).width();
2250
2251        if (_.respondTo === 'window') {
2252            respondToWidth = windowWidth;
2253        } else if (_.respondTo === 'slider') {
2254            respondToWidth = sliderWidth;
2255        } else if (_.respondTo === 'min') {
2256            respondToWidth = Math.min(windowWidth, sliderWidth);
2257        }
2258
2259        if ( _.options.responsive &&
2260            _.options.responsive.length &&
2261            _.options.responsive !== null) {
2262
2263            targetBreakpoint = null;
2264
2265            for (breakpoint in _.breakpoints) {
2266                if (_.breakpoints.hasOwnProperty(breakpoint)) {
2267                    if (_.originalSettings.mobileFirst === false) {
2268                        if (respondToWidth < _.breakpoints[breakpoint]) {
2269                            targetBreakpoint = _.breakpoints[breakpoint];
2270                        }
2271                    } else {
2272                        if (respondToWidth > _.breakpoints[breakpoint]) {
2273                            targetBreakpoint = _.breakpoints[breakpoint];
2274                        }
2275                    }
2276                }
2277            }
2278
2279            if (targetBreakpoint !== null) {
2280                if (_.activeBreakpoint !== null) {
2281                    if (targetBreakpoint !== _.activeBreakpoint || forceUpdate) {
2282                        _.activeBreakpoint =
2283                            targetBreakpoint;
2284                        if (_.breakpointSettings[targetBreakpoint] === 'unslick') {
2285                            _.unslick(targetBreakpoint);
2286                        } else {
2287                            _.options = $.extend({}, _.originalSettings,
2288                                _.breakpointSettings[
2289                                    targetBreakpoint]);
2290                            if (initial === true) {
2291                                _.currentSlide = _.options.initialSlide;
2292                            }
2293                            _.refresh(initial);
2294                        }
2295                        triggerBreakpoint = targetBreakpoint;
2296                    }
2297                } else {
2298                    _.activeBreakpoint = targetBreakpoint;
2299                    if (_.breakpointSettings[targetBreakpoint] === 'unslick') {
2300                        _.unslick(targetBreakpoint);
2301                    } else {
2302                        _.options = $.extend({}, _.originalSettings,
2303                            _.breakpointSettings[
2304                                targetBreakpoint]);
2305                        if (initial === true) {
2306                            _.currentSlide = _.options.initialSlide;
2307                        }
2308                        _.refresh(initial);
2309                    }
2310                    triggerBreakpoint = targetBreakpoint;
2311                }
2312            } else {
2313                if (_.activeBreakpoint !== null) {
2314                    _.activeBreakpoint = null;
2315                    _.options = _.originalSettings;
2316                    if (initial === true) {
2317                        _.currentSlide = _.options.initialSlide;
2318                    }
2319                    _.refresh(initial);
2320                    triggerBreakpoint = targetBreakpoint;
2321                }
2322            }
2323
2324            // only trigger breakpoints during an actual break. not on initialize.
2325            if( !initial && triggerBreakpoint !== false ) {
2326                _.$slider.trigger('breakpoint', [_, triggerBreakpoint]);
2327            }
2328        }
2329
2330    };
2331
2332    Slick.prototype.changeSlide = function(event, dontAnimate) {
2333
2334        var _ = this,
2335            $target = $(event.currentTarget),
2336            indexOffset, slideOffset, unevenOffset;
2337
2338        // If target is a link, prevent default action.
2339        if($target.is('a')) {
2340            event.preventDefault();
2341        }
2342
2343        // If target is not the <li> element (ie: a child), find the <li>.
2344        if(!$target.is('li')) {
2345            $target = $target.closest('li');
2346        }
2347
2348        unevenOffset = (_.slideCount % _.options.slidesToScroll !== 0);
2349        indexOffset = unevenOffset ? 0 : (_.slideCount - _.currentSlide) % _.options.slidesToScroll;
2350
2351        switch (event.data.message) {
2352
2353            case 'previous':
2354                slideOffset = indexOffset === 0 ? _.options.slidesToScroll : _.options.slidesToShow - indexOffset;
2355                if (_.slideCount > _.options.slidesToShow) {
2356                    _.slideHandler(_.currentSlide - slideOffset, false, dontAnimate);
2357                }
2358                break;
2359
2360            case 'next':
2361                slideOffset = indexOffset === 0 ? _.options.slidesToScroll : indexOffset;
2362                if (_.slideCount > _.options.slidesToShow) {
2363                    _.slideHandler(_.currentSlide + slideOffset, false, dontAnimate);
2364                }
2365                break;
2366
2367            case 'index':
2368                var index = event.data.index === 0 ? 0 :
2369                    event.data.index || $target.index() * _.options.slidesToScroll;
2370
2371                _.slideHandler(_.checkNavigable(index), false, dontAnimate);
2372                $target.children().trigger('focus');
2373                break;
2374
2375            default:
2376                return;
2377        }
2378
2379    };
2380
2381    Slick.prototype.checkNavigable = function(index) {
2382
2383        var _ = this,
2384            navigables, prevNavigable;
2385
2386        navigables = _.getNavigableIndexes();
2387        prevNavigable = 0;
2388        if (index > navigables[navigables.length - 1]) {
2389            index = navigables[navigables.length - 1];
2390        } else {
2391            for (var n in navigables) {
2392                if (index < navigables[n]) {
2393                    index = prevNavigable;
2394                    break;
2395                }
2396                prevNavigable = navigables[n];
2397            }
2398        }
2399
2400        return index;
2401    };
2402
2403    Slick.prototype.cleanUpEvents = function() {
2404
2405        var _ = this;
2406
2407        if (_.options.dots && _.$dots !== null) {
2408
2409            $('li', _.$dots)
2410                .off('click.slick', _.changeSlide)
2411                .off('mouseenter.slick', $.proxy(_.interrupt, _, true))
2412                .off('mouseleave.slick', $.proxy(_.interrupt, _, false));
2413
2414        }
2415
2416        _.$slider.off('focus.slick blur.slick');
2417
2418        if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
2419            _.$prevArrow && _.$prevArrow.off('click.slick', _.changeSlide);
2420            _.$nextArrow && _.$nextArrow.off('click.slick', _.changeSlide);
2421        }
2422
2423        _.$list.off('touchstart.slick mousedown.slick', _.swipeHandler);
2424        _.$list.off('touchmove.slick mousemove.slick', _.swipeHandler);
2425        _.$list.off('touchend.slick mouseup.slick', _.swipeHandler);
2426        _.$list.off('touchcancel.slick mouseleave.slick', _.swipeHandler);
2427
2428        _.$list.off('click.slick', _.clickHandler);
2429
2430        $(document).off(_.visibilityChange, _.visibility);
2431
2432        _.cleanUpSlideEvents();
2433
2434        if (_.options.accessibility === true) {
2435            _.$list.off('keydown.slick', _.keyHandler);
2436        }
2437
2438        if (_.options.focusOnSelect === true) {
2439            $(_.$slideTrack).children().off('click.slick', _.selectHandler);
2440        }
2441
2442        $(window).off('orientationchange.slick.slick-' + _.instanceUid, _.orientationChange);
2443
2444        $(window).off('resize.slick.slick-' + _.instanceUid, _.resize);
2445
2446        $('[draggable!=true]', _.$slideTrack).off('dragstart', _.preventDefault);
2447
2448        $(window).off('load.slick.slick-' + _.instanceUid, _.setPosition);
2449        $(document).off('ready.slick.slick-' + _.instanceUid, _.setPosition);
2450
2451    };
2452
2453    Slick.prototype.cleanUpSlideEvents = function() {
2454
2455        var _ = this;
2456
2457        _.$list.off('mouseenter.slick', $.proxy(_.interrupt, _, true));
2458        _.$list.off('mouseleave.slick', $.proxy(_.interrupt, _, false));
2459
2460    };
2461
2462    Slick.prototype.cleanUpRows = function() {
2463
2464        var _ = this, originalSlides;
2465
2466        if(_.options.rows > 1) {
2467            originalSlides = _.$slides.children().children();
2468            originalSlides.removeAttr('style');
2469            _.$slider.empty().append(originalSlides);
2470        }
2471
2472    };
2473
2474    Slick.prototype.clickHandler = function(event) {
2475
2476        var _ = this;
2477
2478        if (_.shouldClick === false) {
2479            event.stopImmediatePropagation();
2480            event.stopPropagation();
2481            event.preventDefault();
2482        }
2483
2484    };
2485
2486    Slick.prototype.destroy = function(refresh) {
2487
2488        var _ = this;
2489
2490        _.autoPlayClear();
2491
2492        _.touchObject = {};
2493
2494        _.cleanUpEvents();
2495
2496        $('.slick-cloned', _.$slider).detach();
2497
2498        if (_.$dots) {
2499            _.$dots.remove();
2500        }
2501
2502
2503        if ( _.$prevArrow && _.$prevArrow.length ) {
2504
2505            _.$prevArrow
2506                .removeClass('slick-disabled slick-arrow slick-hidden')
2507                .removeAttr('aria-hidden aria-disabled tabindex')
2508                .css('display','');
2509
2510            if ( _.htmlExpr.test( _.options.prevArrow )) {
2511                _.$prevArrow.remove();
2512            }
2513        }
2514
2515        if ( _.$nextArrow && _.$nextArrow.length ) {
2516
2517            _.$nextArrow
2518                .removeClass('slick-disabled slick-arrow slick-hidden')
2519                .removeAttr('aria-hidden aria-disabled tabindex')
2520                .css('display','');
2521
2522            if ( _.htmlExpr.test( _.options.nextArrow )) {
2523                _.$nextArrow.remove();
2524            }
2525
2526        }
2527
2528
2529        if (_.$slides) {
2530
2531            _.$slides
2532                .removeClass('slick-slide slick-active slick-center slick-visible slick-current')
2533                .removeAttr('aria-hidden')
2534                .removeAttr('data-slick-index')
2535                .each(function(){
2536                    $(this).attr('style', $(this).data('originalStyling'));
2537                });
2538
2539            _.$slideTrack.children(this.options.slide).detach();
2540
2541            _.$slideTrack.detach();
2542
2543            _.$list.detach();
2544
2545            _.$slider.append(_.$slides);
2546        }
2547
2548        _.cleanUpRows();
2549
2550        _.$slider.removeClass('slick-slider');
2551        _.$slider.removeClass('slick-initialized');
2552        _.$slider.removeClass('slick-dotted');
2553
2554        _.unslicked = true;
2555
2556        if(!refresh) {
2557            _.$slider.trigger('destroy', [_]);
2558        }
2559
2560    };
2561
2562    Slick.prototype.disableTransition = function(slide) {
2563
2564        var _ = this,
2565            transition = {};
2566
2567        transition[_.transitionType] = '';
2568
2569        if (_.options.fade === false) {
2570            _.$slideTrack.css(transition);
2571        } else {
2572            _.$slides.eq(slide).css(transition);
2573        }
2574
2575    };
2576
2577    Slick.prototype.fadeSlide = function(slideIndex, callback) {
2578
2579        var _ = this;
2580
2581        if (_.cssTransitions === false) {
2582
2583            _.$slides.eq(slideIndex).css({
2584                zIndex: _.options.zIndex
2585            });
2586
2587            _.$slides.eq(slideIndex).animate({
2588                opacity: 1
2589            }, _.options.speed, _.options.easing, callback);
2590
2591        } else {
2592
2593            _.applyTransition(slideIndex);
2594
2595            _.$slides.eq(slideIndex).css({
2596                opacity: 1,
2597                zIndex: _.options.zIndex
2598            });
2599
2600            if (callback) {
2601                setTimeout(function() {
2602
2603                    _.disableTransition(slideIndex);
2604
2605                    callback.call();
2606                }, _.options.speed);
2607            }
2608
2609        }
2610
2611    };
2612
2613    Slick.prototype.fadeSlideOut = function(slideIndex) {
2614
2615        var _ = this;
2616
2617        if (_.cssTransitions === false) {
2618
2619            _.$slides.eq(slideIndex).animate({
2620                opacity: 0,
2621                zIndex: _.options.zIndex - 2
2622            }, _.options.speed, _.options.easing);
2623
2624        } else {
2625
2626            _.applyTransition(slideIndex);
2627
2628            _.$slides.eq(slideIndex).css({
2629                opacity: 0,
2630                zIndex: _.options.zIndex - 2
2631            });
2632
2633        }
2634
2635    };
2636
2637    Slick.prototype.filterSlides = Slick.prototype.slickFilter = function(filter) {
2638
2639        var _ = this;
2640
2641        if (filter !== null) {
2642
2643            _.$slidesCache = _.$slides;
2644
2645            _.unload();
2646
2647            _.$slideTrack.children(this.options.slide).detach();
2648
2649            _.$slidesCache.filter(filter).appendTo(_.$slideTrack);
2650
2651            _.reinit();
2652
2653        }
2654
2655    };
2656
2657    Slick.prototype.focusHandler = function() {
2658
2659        var _ = this;
2660
2661        _.$slider
2662            .off('focus.slick blur.slick')
2663            .on('focus.slick blur.slick',
2664                '*:not(.slick-arrow)', function(event) {
2665
2666            event.stopImmediatePropagation();
2667            var $sf = $(this);
2668
2669            setTimeout(function() {
2670
2671                if( _.options.pauseOnFocus ) {
2672                    _.focussed = $sf.is(':focus');
2673                    _.autoPlay();
2674                }
2675
2676            }, 0);
2677
2678        });
2679    };
2680
2681    Slick.prototype.getCurrent = Slick.prototype.slickCurrentSlide = function() {
2682
2683        var _ = this;
2684        return _.currentSlide;
2685
2686    };
2687
2688    Slick.prototype.getDotCount = function() {
2689
2690        var _ = this;
2691
2692        var breakPoint = 0;
2693        var counter = 0;
2694        var pagerQty = 0;
2695
2696        if (_.options.infinite === true) {
2697            while (breakPoint < _.slideCount) {
2698                ++pagerQty;
2699                breakPoint = counter + _.options.slidesToScroll;
2700                counter += _.options.slidesToScroll <= _.options.slidesToShow ? _.options.slidesToScroll : _.options.slidesToShow;
2701            }
2702        } else if (_.options.centerMode === true) {
2703            pagerQty = _.slideCount;
2704        } else if(!_.options.asNavFor) {
2705            pagerQty = 1 + Math.ceil((_.slideCount - _.options.slidesToShow) / _.options.slidesToScroll);
2706        }else {
2707            while (breakPoint < _.slideCount) {
2708                ++pagerQty;
2709                breakPoint = counter + _.options.slidesToScroll;
2710                counter += _.options.slidesToScroll <= _.options.slidesToShow ? _.options.slidesToScroll : _.options.slidesToShow;
2711            }
2712        }
2713
2714        return pagerQty - 1;
2715
2716    };
2717
2718    Slick.prototype.getLeft = function(slideIndex) {
2719
2720        var _ = this,
2721            targetLeft,
2722            verticalHeight,
2723            verticalOffset = 0,
2724            targetSlide;
2725
2726        _.slideOffset = 0;
2727        verticalHeight = _.$slides.first().outerHeight(true);
2728
2729        if (_.options.infinite === true) {
2730            if (_.slideCount > _.options.slidesToShow) {
2731                _.slideOffset = (_.slideWidth * _.options.slidesToShow) * -1;
2732                verticalOffset = (verticalHeight * _.options.slidesToShow) * -1;
2733            }
2734            if (_.slideCount % _.options.slidesToScroll !== 0) {
2735                if (slideIndex + _.options.slidesToScroll > _.slideCount && _.slideCount > _.options.slidesToShow) {
2736                    if (slideIndex > _.slideCount) {
2737                        _.slideOffset = ((_.options.slidesToShow - (slideIndex - _.slideCount)) * _.slideWidth) * -1;
2738                        verticalOffset = ((_.options.slidesToShow - (slideIndex - _.slideCount)) * verticalHeight) * -1;
2739                    } else {
2740                        _.slideOffset = ((_.slideCount % _.options.slidesToScroll) * _.slideWidth) * -1;
2741                        verticalOffset = ((_.slideCount % _.options.slidesToScroll) * verticalHeight) * -1;
2742                    }
2743                }
2744            }
2745        } else {
2746            if (slideIndex + _.options.slidesToShow > _.slideCount) {
2747                _.slideOffset = ((slideIndex + _.options.slidesToShow) - _.slideCount) * _.slideWidth;
2748                verticalOffset = ((slideIndex + _.options.slidesToShow) - _.slideCount) * verticalHeight;
2749            }
2750        }
2751
2752        if (_.slideCount <= _.options.slidesToShow) {
2753            _.slideOffset = 0;
2754            verticalOffset = 0;
2755        }
2756
2757       
vendor: 5,167 bytes, lines 2757-2930
2757 if (_.options.centerMode === true && _.options.infinite === true) {
2758            _.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2) - _.slideWidth;
2759        } else if (_.options.centerMode === true) {
2760            _.slideOffset = 0;
2761            _.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2);
2762        }
2763
2764        if (_.options.vertical === false) {
2765            targetLeft = ((slideIndex * _.slideWidth) * -1) + _.slideOffset;
2766        } else {
2767            targetLeft = ((slideIndex * verticalHeight) * -1) + verticalOffset;
2768        }
2769
2770        if (_.options.variableWidth === true) {
2771
2772            if (_.slideCount <= _.options.slidesToShow || _.options.infinite === false) {
2773                targetSlide = _.$slideTrack.children('.slick-slide').eq(slideIndex);
2774            } else {
2775                targetSlide = _.$slideTrack.children('.slick-slide').eq(slideIndex + _.options.slidesToShow);
2776            }
2777
2778            if (_.options.rtl === true) {
2779                if (targetSlide[0]) {
2780                    targetLeft = (_.$slideTrack.width() - targetSlide[0].offsetLeft - targetSlide.width()) * -1;
2781                } else {
2782                    targetLeft =  0;
2783                }
2784            } else {
2785                targetLeft = targetSlide[0] ? targetSlide[0].offsetLeft * -1 : 0;
2786            }
2787
2788            if (_.options.centerMode === true) {
2789                if (_.slideCount <= _.options.slidesToShow || _.options.infinite === false) {
2790                    targetSlide = _.$slideTrack.children('.slick-slide').eq(slideIndex);
2791                } else {
2792                    targetSlide = _.$slideTrack.children('.slick-slide').eq(slideIndex + _.options.slidesToShow + 1);
2793                }
2794
2795                if (_.options.rtl === true) {
2796                    if (targetSlide[0]) {
2797                        targetLeft = (_.$slideTrack.width() - targetSlide[0].offsetLeft - targetSlide.width()) * -1;
2798                    } else {
2799                        targetLeft =  0;
2800                    }
2801                } else {
2802                    targetLeft = targetSlide[0] ? targetSlide[0].offsetLeft * -1 : 0;
2803                }
2804
2805                targetLeft += (_.$list.width() - targetSlide.outerWidth()) / 2;
2806            }
2807        }
2808
2809        return targetLeft;
2810
2811    };
2812
2813    Slick.prototype.getOption = Slick.prototype.slickGetOption = function(option) {
2814
2815        var _ = this;
2816
2817        return _.options[option];
2818
2819    };
2820
2821    Slick.prototype.getNavigableIndexes = function() {
2822
2823        var _ = this,
2824            breakPoint = 0,
2825            counter = 0,
2826            indexes = [],
2827            max;
2828
2829        if (_.options.infinite === false) {
2830            max = _.slideCount;
2831        } else {
2832            breakPoint = _.options.slidesToScroll * -1;
2833            counter = _.options.slidesToScroll * -1;
2834            max = _.slideCount * 2;
2835        }
2836
2837        while (breakPoint < max) {
2838            indexes.push(breakPoint);
2839            breakPoint = counter + _.options.slidesToScroll;
2840            counter += _.options.slidesToScroll <= _.options.slidesToShow ? _.options.slidesToScroll : _.options.slidesToShow;
2841        }
2842
2843        return indexes;
2844
2845    };
2846
2847    Slick.prototype.getSlick = function() {
2848
2849        return this;
2850
2851    };
2852
2853    Slick.prototype.getSlideCount = function() {
2854
2855        var _ = this,
2856            slidesTraversed, swipedSlide, centerOffset;
2857
2858        centerOffset = _.options.centerMode === true ? _.slideWidth * Math.floor(_.options.slidesToShow / 2) : 0;
2859
2860        if (_.options.swipeToSlide === true) {
2861            _.$slideTrack.find('.slick-slide').each(function(index, slide) {
2862                if (slide.offsetLeft - centerOffset + ($(slide).outerWidth() / 2) > (_.swipeLeft * -1)) {
2863                    swipedSlide = slide;
2864                    return false;
2865                }
2866            });
2867
2868            slidesTraversed = Math.abs($(swipedSlide).attr('data-slick-index') - _.currentSlide) || 1;
2869
2870            return slidesTraversed;
2871
2872        } else {
2873            return _.options.slidesToScroll;
2874        }
2875
2876    };
2877
2878    Slick.prototype.goTo = Slick.prototype.slickGoTo = function(slide, dontAnimate) {
2879
2880        var _ = this;
2881
2882        _.changeSlide({
2883            data: {
2884                message: 'index',
2885                index: parseInt(slide)
2886            }
2887        }, dontAnimate);
2888
2889    };
2890
2891    Slick.prototype.init = function(creation) {
2892
2893        var _ = this;
2894
2895        if (!$(_.$slider).hasClass('slick-initialized')) {
2896
2897            $(_.$slider).addClass('slick-initialized');
2898
2899            _.buildRows();
2900            _.buildOut();
2901            _.setProps();
2902            _.startLoad();
2903            _.loadSlider();
2904            _.initializeEvents();
2905            _.updateArrows();
2906            _.updateDots();
2907            _.checkResponsive(true);
2908            _.focusHandler();
2909
2910        }
2911
2912        if (creation) {
2913            _.$slider.trigger('init', [_]);
2914        }
2915
2916        if (_.options.accessibility === true) {
2917            _.initADA();
2918        }
2919
2920        if ( _.options.autoplay ) {
2921
2922            _.paused = false;
2923            _.autoPlay();
2924
2925        }
2926
2927    };
2928
2929    Slick.prototype.initADA = function() {
2930        var _ = this
2930;
2931        _.$slides.add(_.$slideTrack.find('.slick-cloned')).attr({
2932            'aria-hidden': 'true',
2933            'tabindex': '-1'
2934        }).find('a, input, button, select').attr({
2935            'tabindex': '-1'
2936        });
2937
2938        _.$slideTrack.attr('role', 'listbox');
2939
2940        _.$slides.not(_.$slideTrack.find('.slick-cloned')).each(function(i) {
2941            $(this).attr({
2942                'role': 'option',
2943                'aria-describedby': 'slick-slide' + _.instanceUid + i + ''
2944            });
2945        });
2946
2947        if (_.$dots !== null) {
2948            _.$dots.attr('role', 'tablist').find('li').each(function(i) {
2949                $(this).attr({
2950                    'role': 'presentation',
2951                    'aria-selected': 'false',
2952                    'aria-controls': 'navigation' + _.instanceUid + i + '',
2953                    'id': 'slick-slide' + _.instanceUid + i + ''
2954                });
2955            })
2956                .first().attr('aria-selected', 'true').end()
2957                .find('button').attr('role', 'button').end()
2958                .closest('div').attr('role', 'toolbar');
2959        }
2960        _.activateADA();
2961
2962    };
2963
2964    Slick.prototype.initArrowEvents = function() {
2965
2966        var _ = this;
2967
2968        if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
2969            _.$prevArrow
2970               .off('click.slick')
2971               .on('click.slick', {
2972                    message: 'previous'
2973               }, _.changeSlide);
2974            _.$nextArrow
2975               .off('click.slick')
2976               .on('click.slick', {
2977                    message: 'next'
2978               }, _.changeSlide);
2979        }
2980
2981    };
2982
2983    Slick.prototype.initDotEvents = function() {
2984
2985        var _ = this;
2986
2987        if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
2988            $('li', _.$dots).on('click.slick', {
2989                message: 'index'
2990            }, _.changeSlide);
2991        }
2992
2993        if ( _.options.dots === true && _.options.pauseOnDotsHover === true ) {
2994
2995            $('li', _.$dots)
2996                .on('mouseenter.slick', $.proxy(_.interrupt, _, true))
2997                .on('mouseleave.slick', $.proxy(_.interrupt, _, false));
2998
2999        }
3000
3001    };
3002
3003    Slick.prototype.initSlideEvents = function() {
3004
3005        var _ = this;
3006
3007        if ( _.options.pauseOnHover ) {
3008
3009            _.$list.on('mouseenter.slick', $.proxy(_.interrupt, _, true));
3010            _.$list.on('mouseleave.slick', $.proxy(_.interrupt, _, false));
3011
3012        }
3013
3014    };
3015
3016    Slick.prototype.initializeEvents = function() {
3017
3018        var _ = this;
3019
3020        _.initArrowEvents();
3021
3022        _.initDotEvents();
3023        _.initSlideEvents();
3024
3025        _.$list.on('touchstart.slick mousedown.slick', {
3026            action: 'start'
3027        }, _.swipeHandler);
3028        _.$list.on('touchmove.slick mousemove.slick', {
3029            action: 'move'
3030        }, _.swipeHandler);
3031        _.$list.on('touchend.slick mouseup.slick', {
3032            action: 'end'
3033        }, _.swipeHandler);
vendor: 10,240 bytes, lines 3034-3411
3034        _.$list.on('touchcancel.slick mouseleave.slick', {
3035            action: 'end'
3036        }, _.swipeHandler);
3037
3038        _.$list.on('click.slick', _.clickHandler);
3039
3040        $(document).on(_.visibilityChange, $.proxy(_.visibility, _));
3041
3042        if (_.options.accessibility === true) {
3043            _.$list.on('keydown.slick', _.keyHandler);
3044        }
3045
3046        if (_.options.focusOnSelect === true) {
3047            $(_.$slideTrack).children().on('click.slick', _.selectHandler);
3048        }
3049
3050        $(window).on('orientationchange.slick.slick-' + _.instanceUid, $.proxy(_.orientationChange, _));
3051
3052        $(window).on('resize.slick.slick-' + _.instanceUid, $.proxy(_.resize, _));
3053
3054        $('[draggable!=true]', _.$slideTrack).on('dragstart', _.preventDefault);
3055
3056        $(window).on('load.slick.slick-' + _.instanceUid, _.setPosition);
3057        $(document).on('ready.slick.slick-' + _.instanceUid, _.setPosition);
3058
3059    };
3060
3061    Slick.prototype.initUI = function() {
3062
3063        var _ = this;
3064
3065        if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
3066
3067            _.$prevArrow.show();
3068            _.$nextArrow.show();
3069
3070        }
3071
3072        if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
3073
3074            _.$dots.show();
3075
3076        }
3077
3078    };
3079
3080    Slick.prototype.keyHandler = function(event) {
3081
3082        var _ = this;
3083         //Dont slide if the cursor is inside the form fields and arrow keys are pressed
3084        if(!event.target.tagName.match('TEXTAREA|INPUT|SELECT')) {
3085            if (event.keyCode === 37 && _.options.accessibility === true) {
3086                _.changeSlide({
3087                    data: {
3088                        message: _.options.rtl === true ? 'next' :  'previous'
3089                    }
3090                });
3091            } else if (event.keyCode === 39 && _.options.accessibility === true) {
3092                _.changeSlide({
3093                    data: {
3094                        message: _.options.rtl === true ? 'previous' : 'next'
3095                    }
3096                });
3097            }
3098        }
3099
3100    };
3101
3102    Slick.prototype.lazyLoad = function() {
3103
3104        var _ = this,
3105            loadRange, cloneRange, rangeStart, rangeEnd;
3106
3107        function loadImages(imagesScope) {
3108
3109            $('img[data-lazy]', imagesScope).each(function() {
3110
3111                var image = $(this),
3112                    imageSource = $(this).attr('data-lazy'),
3113                    imageToLoad = document.createElement('img');
3114
3115                imageToLoad.onload = function() {
3116
3117                    image
3118                        .animate({ opacity: 0 }, 100, function() {
3119                            image
3120                                .attr('src', imageSource)
3121                                .animate({ opacity: 1 }, 200, function() {
3122                                    image
3123                                        .removeAttr('data-lazy')
3124                                        .removeClass('slick-loading');
3125                                });
3126                            _.$slider.trigger('lazyLoaded', [_, image, imageSource]);
3127                        });
3128
3129                };
3130
3131                imageToLoad.onerror = function() {
3132
3133                    image
3134                        .removeAttr( 'data-lazy' )
3135                        .removeClass( 'slick-loading' )
3136                        .addClass( 'slick-lazyload-error' );
3137
3138                    _.$slider.trigger('lazyLoadError', [ _, image, imageSource ]);
3139
3140                };
3141
3142                imageToLoad.src = imageSource;
3143
3144            });
3145
3146        }
3147
3148        if (_.options.centerMode === true) {
3149            if (_.options.infinite === true) {
3150                rangeStart = _.currentSlide + (_.options.slidesToShow / 2 + 1);
3151                rangeEnd = rangeStart + _.options.slidesToShow + 2;
3152            } else {
3153                rangeStart = Math.max(0, _.currentSlide - (_.options.slidesToShow / 2 + 1));
3154                rangeEnd = 2 + (_.options.slidesToShow / 2 + 1) + _.currentSlide;
3155            }
3156        } else {
3157            rangeStart = _.options.infinite ? _.options.slidesToShow + _.currentSlide : _.currentSlide;
3158            rangeEnd = Math.ceil(rangeStart + _.options.slidesToShow);
3159            if (_.options.fade === true) {
3160                if (rangeStart > 0) rangeStart--;
3161                if (rangeEnd <= _.slideCount) rangeEnd++;
3162            }
3163        }
3164
3165        loadRange = _.$slider.find('.slick-slide').slice(rangeStart, rangeEnd);
3166        loadImages(loadRange);
3167
3168        if (_.slideCount <= _.options.slidesToShow) {
3169            cloneRange = _.$slider.find('.slick-slide');
3170            loadImages(cloneRange);
3171        } else
3172        if (_.currentSlide >= _.slideCount - _.options.slidesToShow) {
3173            cloneRange = _.$slider.find('.slick-cloned').slice(0, _.options.slidesToShow);
3174            loadImages(cloneRange);
3175        } else if (_.currentSlide === 0) {
3176            cloneRange = _.$slider.find('.slick-cloned').slice(_.options.slidesToShow * -1);
3177            loadImages(cloneRange);
3178        }
3179
3180    };
3181
3182    Slick.prototype.loadSlider = function() {
3183
3184        var _ = this;
3185
3186        _.setPosition();
3187
3188        _.$slideTrack.css({
3189            opacity: 1
3190        });
3191
3192        _.$slider.removeClass('slick-loading');
3193
3194        _.initUI();
3195
3196        if (_.options.lazyLoad === 'progressive') {
3197            _.progressiveLazyLoad();
3198        }
3199
3200    };
3201
3202    Slick.prototype.next = Slick.prototype.slickNext = function() {
3203
3204        var _ = this;
3205
3206        _.changeSlide({
3207            data: {
3208                message: 'next'
3209            }
3210        });
3211
3212    };
3213
3214    Slick.prototype.orientationChange = function() {
3215
3216        var _ = this;
3217
3218        _.checkResponsive();
3219        _.setPosition();
3220
3221    };
3222
3223    Slick.prototype.pause = Slick.prototype.slickPause = function() {
3224
3225        var _ = this;
3226
3227        _.autoPlayClear();
3228        _.paused = true;
3229
3230    };
3231
3232    Slick.prototype.play = Slick.prototype.slickPlay = function() {
3233
3234        var _ = this;
3235
3236        _.autoPlay();
3237        _.options.autoplay = true;
3238        _.paused = false;
3239        _.focussed = false;
3240        _.interrupted = false;
3241
3242    };
3243
3244    Slick.prototype.postSlide = function(index) {
3245
3246        var _ = this;
3247
3248        if( !_.unslicked ) {
3249
3250            _.$slider.trigger('afterChange', [_, index]);
3251
3252            _.animating = false;
3253
3254            _.setPosition();
3255
3256            _.swipeLeft = null;
3257
3258            if ( _.options.autoplay ) {
3259                _.autoPlay();
3260            }
3261
3262            if (_.options.accessibility === true) {
3263                _.initADA();
3264            }
3265
3266        }
3267
3268    };
3269
3270    Slick.prototype.prev = Slick.prototype.slickPrev = function() {
3271
3272        var _ = this;
3273
3274        _.changeSlide({
3275            data: {
3276                message: 'previous'
3277            }
3278        });
3279
3280    };
3281
3282    Slick.prototype.preventDefault = function(event) {
3283
3284        event.preventDefault();
3285
3286    };
3287
3288    Slick.prototype.progressiveLazyLoad = function( tryCount ) {
3289
3290        tryCount = tryCount || 1;
3291
3292        var _ = this,
3293            $imgsToLoad = $( 'img[data-lazy]', _.$slider ),
3294            image,
3295            imageSource,
3296            imageToLoad;
3297
3298        if ( $imgsToLoad.length ) {
3299
3300            image = $imgsToLoad.first();
3301            imageSource = image.attr('data-lazy');
3302            imageToLoad = document.createElement('img');
3303
3304            imageToLoad.onload = function() {
3305
3306                image
3307                    .attr( 'src', imageSource )
3308                    .removeAttr('data-lazy')
3309                    .removeClass('slick-loading');
3310
3311                if ( _.options.adaptiveHeight === true ) {
3312                    _.setPosition();
3313                }
3314
3315                _.$slider.trigger('lazyLoaded', [ _, image, imageSource ]);
3316                _.progressiveLazyLoad();
3317
3318            };
3319
3320            imageToLoad.onerror = function() {
3321
3322                if ( tryCount < 3 ) {
3323
3324                    /**
3325                     * try to load the image 3 times,
3326                     * leave a slight delay so we don't get
3327                     * servers blocking the request.
3328                     */
3329                    setTimeout( function() {
3330                        _.progressiveLazyLoad( tryCount + 1 );
3331                    }, 500 );
3332
3333                } else {
3334
3335                    image
3336                        .removeAttr( 'data-lazy' )
3337                        .removeClass( 'slick-loading' )
3338                        .addClass( 'slick-lazyload-error' );
3339
3340                    _.$slider.trigger('lazyLoadError', [ _, image, imageSource ]);
3341
3342                    _.progressiveLazyLoad();
3343
3344                }
3345
3346            };
3347
3348            imageToLoad.src = imageSource;
3349
3350        } else {
3351
3352            _.$slider.trigger('allImagesLoaded', [ _ ]);
3353
3354        }
3355
3356    };
3357
3358    Slick.prototype.refresh = function( initializing ) {
3359
3360        var _ = this, currentSlide, lastVisibleIndex;
3361
3362        lastVisibleIndex = _.slideCount - _.options.slidesToShow;
3363
3364        // in non-infinite sliders, we don't want to go past the
3365        // last visible index.
3366        if( !_.options.infinite && ( _.currentSlide > lastVisibleIndex )) {
3367            _.currentSlide = lastVisibleIndex;
3368        }
3369
3370        // if less slides than to show, go to start.
3371        if ( _.slideCount <= _.options.slidesToShow ) {
3372            _.currentSlide = 0;
3373
3374        }
3375
3376        currentSlide = _.currentSlide;
3377
3378        _.destroy(true);
3379
3380        $.extend(_, _.initials, { currentSlide: currentSlide });
3381
3382        _.init();
3383
3384        if( !initializing ) {
3385
3386            _.changeSlide({
3387                data: {
3388                    message: 'index',
3389                    index: currentSlide
3390                }
3391            }, false);
3392
3393        }
3394
3395    };
3396
3397    Slick.prototype.registerBreakpoints = function() {
3398
3399        var _ = this, breakpoint, currentBreakpoint, l,
3400            responsiveSettings = _.options.responsive || null;
3401
3402        if ( $.type(responsiveSettings) === 'array' && responsiveSettings.length ) {
3403
3404            _.respondTo = _.options.respondTo || 'window';
3405
3406            for ( breakpoint in responsiveSettings ) {
3407
3408                l = _.breakpoints.length-1;
3409                currentBreakpoint = responsiveSettings[breakpoint].breakpoint;
3410
3411                if (responsiveSettings.hasOwnProperty(breakpoint)) {
vendor: 12,466 bytes, lines 3411-3844
3411
3412
3413                    // loop through the breakpoints and cut out any existing
3414                    // ones with the same breakpoint number, we don't want dupes.
3415                    while( l >= 0 ) {
3416                        if( _.breakpoints[l] && _.breakpoints[l] === currentBreakpoint ) {
3417                            _.breakpoints.splice(l,1);
3418                        }
3419                        l--;
3420                    }
3421
3422                    _.breakpoints.push(currentBreakpoint);
3423                    _.breakpointSettings[currentBreakpoint] = responsiveSettings[breakpoint].settings;
3424
3425                }
3426
3427            }
3428
3429            _.breakpoints.sort(function(a, b) {
3430                return ( _.options.mobileFirst ) ? a-b : b-a;
3431            });
3432
3433        }
3434
3435    };
3436
3437    Slick.prototype.reinit = function() {
3438
3439        var _ = this;
3440
3441        _.$slides =
3442            _.$slideTrack
3443                .children(_.options.slide)
3444                .addClass('slick-slide');
3445
3446        _.slideCount = _.$slides.length;
3447
3448        if (_.currentSlide >= _.slideCount && _.currentSlide !== 0) {
3449            _.currentSlide = _.currentSlide - _.options.slidesToScroll;
3450        }
3451
3452        if (_.slideCount <= _.options.slidesToShow) {
3453            _.currentSlide = 0;
3454        }
3455
3456        _.registerBreakpoints();
3457
3458        _.setProps();
3459        _.setupInfinite();
3460        _.buildArrows();
3461        _.updateArrows();
3462        _.initArrowEvents();
3463        _.buildDots();
3464        _.updateDots();
3465        _.initDotEvents();
3466        _.cleanUpSlideEvents();
3467        _.initSlideEvents();
3468
3469        _.checkResponsive(false, true);
3470
3471        if (_.options.focusOnSelect === true) {
3472            $(_.$slideTrack).children().on('click.slick', _.selectHandler);
3473        }
3474
3475        _.setSlideClasses(typeof _.currentSlide === 'number' ? _.currentSlide : 0);
3476
3477        _.setPosition();
3478        _.focusHandler();
3479
3480        _.paused = !_.options.autoplay;
3481        _.autoPlay();
3482
3483        _.$slider.trigger('reInit', [_]);
3484
3485    };
3486
3487    Slick.prototype.resize = function() {
3488
3489        var _ = this;
3490
3491        if ($(window).width() !== _.windowWidth) {
3492            clearTimeout(_.windowDelay);
3493            _.windowDelay = window.setTimeout(function() {
3494                _.windowWidth = $(window).width();
3495                _.checkResponsive();
3496                if( !_.unslicked ) { _.setPosition(); }
3497            }, 50);
3498        }
3499    };
3500
3501    Slick.prototype.removeSlide = Slick.prototype.slickRemove = function(index, removeBefore, removeAll) {
3502
3503        var _ = this;
3504
3505        if (typeof(index) === 'boolean') {
3506            removeBefore = index;
3507            index = removeBefore === true ? 0 : _.slideCount - 1;
3508        } else {
3509            index = removeBefore === true ? --index : index;
3510        }
3511
3512        if (_.slideCount < 1 || index < 0 || index > _.slideCount - 1) {
3513            return false;
3514        }
3515
3516        _.unload();
3517
3518        if (removeAll === true) {
3519            _.$slideTrack.children().remove();
3520        } else {
3521            _.$slideTrack.children(this.options.slide).eq(index).remove();
3522        }
3523
3524        _.$slides = _.$slideTrack.children(this.options.slide);
3525
3526        _.$slideTrack.children(this.options.slide).detach();
3527
3528        _.$slideTrack.append(_.$slides);
3529
3530        _.$slidesCache = _.$slides;
3531
3532        _.reinit();
3533
3534    };
3535
3536    Slick.prototype.setCSS = function(position) {
3537
3538        var _ = this,
3539            positionProps = {},
3540            x, y;
3541
3542        if (_.options.rtl === true) {
3543            position = -position;
3544        }
3545        x = _.positionProp == 'left' ? Math.ceil(position) + 'px' : '0px';
3546        y = _.positionProp == 'top' ? Math.ceil(position) + 'px' : '0px';
3547
3548        positionProps[_.positionProp] = position;
3549
3550        if (_.transformsEnabled === false) {
3551            _.$slideTrack.css(positionProps);
3552        } else {
3553            positionProps = {};
3554            if (_.cssTransitions === false) {
3555                positionProps[_.animType] = 'translate(' + x + ', ' + y + ')';
3556                _.$slideTrack.css(positionProps);
3557            } else {
3558                positionProps[_.animType] = 'translate3d(' + x + ', ' + y + ', 0px)';
3559                _.$slideTrack.css(positionProps);
3560            }
3561        }
3562
3563    };
3564
3565    Slick.prototype.setDimensions = function() {
3566
3567        var _ = this;
3568
3569        if (_.options.vertical === false) {
3570            if (_.options.centerMode === true) {
3571                _.$list.css({
3572                    padding: ('0px ' + _.options.centerPadding)
3573                });
3574            }
3575        } else {
3576            _.$list.height(_.$slides.first().outerHeight(true) * _.options.slidesToShow);
3577            if (_.options.centerMode === true) {
3578                _.$list.css({
3579                    padding: (_.options.centerPadding + ' 0px')
3580                });
3581            }
3582        }
3583
3584        _.listWidth = _.$list.width();
3585        _.listHeight = _.$list.height();
3586
3587
3588        if (_.options.vertical === false && _.options.variableWidth === false) {
3589            _.slideWidth = Math.ceil(_.listWidth / _.options.slidesToShow);
3590            _.$slideTrack.width(Math.ceil((_.slideWidth * _.$slideTrack.children('.slick-slide').length)));
3591
3592        } else if (_.options.variableWidth === true) {
3593            _.$slideTrack.width(5000 * _.slideCount);
3594        } else {
3595            _.slideWidth = Math.ceil(_.listWidth);
3596            _.$slideTrack.height(Math.ceil((_.$slides.first().outerHeight(true) * _.$slideTrack.children('.slick-slide').length)));
3597        }
3598
3599        var offset = _.$slides.first().outerWidth(true) - _.$slides.first().width();
3600        if (_.options.variableWidth === false) _.$slideTrack.children('.slick-slide').width(_.slideWidth - offset);
3601
3602    };
3603
3604    Slick.prototype.setFade = function() {
3605
3606        var _ = this,
3607            targetLeft;
3608
3609        _.$slides.each(function(index, element) {
3610            targetLeft = (_.slideWidth * index) * -1;
3611            if (_.options.rtl === true) {
3612                $(element).css({
3613                    position: 'relative',
3614                    right: targetLeft,
3615                    top: 0,
3616                    zIndex: _.options.zIndex - 2,
3617                    opacity: 0
3618                });
3619            } else {
3620                $(element).css({
3621                    position: 'relative',
3622                    left: targetLeft,
3623                    top: 0,
3624                    zIndex: _.options.zIndex - 2,
3625                    opacity: 0
3626                });
3627            }
3628        });
3629
3630        _.$slides.eq(_.currentSlide).css({
3631            zIndex: _.options.zIndex - 1,
3632            opacity: 1
3633        });
3634
3635    };
3636
3637    Slick.prototype.setHeight = function() {
3638
3639        var _ = this;
3640
3641        if (_.options.slidesToShow === 1 && _.options.adaptiveHeight === true && _.options.vertical === false) {
3642            var targetHeight = _.$slides.eq(_.currentSlide).outerHeight(true);
3643            _.$list.css('height', targetHeight);
3644        }
3645
3646    };
3647
3648    Slick.prototype.setOption =
3649    Slick.prototype.slickSetOption = function() {
3650
3651        /**
3652         * accepts arguments in format of:
3653         *
3654         *  - for changing a single option's value:
3655         *     .slick("setOption", option, value, refresh )
3656         *
3657         *  - for changing a set of responsive options:
3658         *     .slick("setOption", 'responsive', [{}, ...], refresh )
3659         *
3660         *  - for updating multiple values at once (not responsive)
3661         *     .slick("setOption", { 'option': value, ... }, refresh )
3662         */
3663
3664        var _ = this, l, item, option, value, refresh = false, type;
3665
3666        if( $.type( arguments[0] ) === 'object' ) {
3667
3668            option =  arguments[0];
3669            refresh = arguments[1];
3670            type = 'multiple';
3671
3672        } else if ( $.type( arguments[0] ) === 'string' ) {
3673
3674            option =  arguments[0];
3675            value = arguments[1];
3676            refresh = arguments[2];
3677
3678            if ( arguments[0] === 'responsive' && $.type( arguments[1] ) === 'array' ) {
3679
3680                type = 'responsive';
3681
3682            } else if ( typeof arguments[1] !== 'undefined' ) {
3683
3684                type = 'single';
3685
3686            }
3687
3688        }
3689
3690        if ( type === 'single' ) {
3691
3692            _.options[option] = value;
3693
3694
3695        } else if ( type === 'multiple' ) {
3696
3697            $.each( option , function( opt, val ) {
3698
3699                _.options[opt] = val;
3700
3701            });
3702
3703
3704        } else if ( type === 'responsive' ) {
3705
3706            for ( item in value ) {
3707
3708                if( $.type( _.options.responsive ) !== 'array' ) {
3709
3710                    _.options.responsive = [ value[item] ];
3711
3712                } else {
3713
3714                    l = _.options.responsive.length-1;
3715
3716                    // loop through the responsive object and splice out duplicates.
3717                    while( l >= 0 ) {
3718
3719                        if( _.options.responsive[l].breakpoint === value[item].breakpoint ) {
3720
3721                            _.options.responsive.splice(l,1);
3722
3723                        }
3724
3725                        l--;
3726
3727                    }
3728
3729                    _.options.responsive.push( value[item] );
3730
3731                }
3732
3733            }
3734
3735        }
3736
3737        if ( refresh ) {
3738
3739            _.unload();
3740            _.reinit();
3741
3742        }
3743
3744    };
3745
3746    Slick.prototype.setPosition = function() {
3747
3748        var _ = this;
3749
3750        _.setDimensions();
3751
3752        _.setHeight();
3753
3754        if (_.options.fade === false) {
3755            _.setCSS(_.getLeft(_.currentSlide));
3756        } else {
3757            _.setFade();
3758        }
3759
3760        _.$slider.trigger('setPosition', [_]);
3761
3762    };
3763
3764    Slick.prototype.setProps = function() {
3765
3766        var _ = this,
3767            bodyStyle = document.body.style;
3768
3769        _.positionProp = _.options.vertical === true ? 'top' : 'left';
3770
3771        if (_.positionProp === 'top') {
3772            _.$slider.addClass('slick-vertical');
3773        } else {
3774            _.$slider.removeClass('slick-vertical');
3775        }
3776
3777        if (bodyStyle.WebkitTransition !== undefined ||
3778            bodyStyle.MozTransition !== undefined ||
3779            bodyStyle.msTransition !== undefined) {
3780            if (_.options.useCSS === true) {
3781                _.cssTransitions = true;
3782            }
3783        }
3784
3785        if ( _.options.fade ) {
3786            if ( typeof _.options.zIndex === 'number' ) {
3787                if( _.options.zIndex < 3 ) {
3788                    _.options.zIndex = 3;
3789                }
3790            } else {
3791                _.options.zIndex = _.defaults.zIndex;
3792            }
3793        }
3794
3795        if (bodyStyle.OTransform !== undefined) {
3796            _.animType = 'OTransform';
3797            _.transformType = '-o-transform';
3798            _.transitionType = 'OTransition';
3799            if (bodyStyle.perspectiveProperty === undefined && bodyStyle.webkitPerspective === undefined) _.animType = false;
3800        }
3801        if (bodyStyle.MozTransform !== undefined) {
3802            _.animType = 'MozTransform';
3803            _.transformType = '-moz-transform';
3804            _.transitionType = 'MozTransition';
3805            if (bodyStyle.perspectiveProperty === undefined && bodyStyle.MozPerspective === undefined) _.animType = false;
3806        }
3807        if (bodyStyle.webkitTransform !== undefined) {
3808            _.animType = 'webkitTransform';
3809            _.transformType = '-webkit-transform';
3810            _.transitionType = 'webkitTransition';
3811            if (bodyStyle.perspectiveProperty === undefined && bodyStyle.webkitPerspective === undefined) _.animType = false;
3812        }
3813        if (bodyStyle.msTransform !== undefined) {
3814            _.animType = 'msTransform';
3815            _.transformType = '-ms-transform';
3816            _.transitionType = 'msTransition';
3817            if (bodyStyle.msTransform === undefined) _.animType = false;
3818        }
3819        if (bodyStyle.transform !== undefined && _.animType !== false) {
3820            _.animType = 'transform';
3821            _.transformType = 'transform';
3822            _.transitionType = 'transition';
3823        }
3824        _.transformsEnabled = _.options.useTransform && (_.animType !== null && _.animType !== false);
3825    };
3826
3827
3828    Slick.prototype.setSlideClasses = function(index) {
3829
3830        var _ = this,
3831            centerOffset, allSlides, indexOffset, remainder;
3832
3833        allSlides = _.$slider
3834            .find('.slick-slide')
3835            .removeClass('slick-active slick-center slick-current')
3836            .attr('aria-hidden', 'true');
3837
3838        _.$slides
3839            .eq(index)
3840            .addClass('slick-current');
3841
3842        if (_.options.centerMode === true) {
3843
3844            
vendor: 20,792 bytes, lines 3844-4565
3844centerOffset = Math.floor(_.options.slidesToShow / 2);
3845
3846            if (_.options.infinite === true) {
3847
3848                if (index >= centerOffset && index <= (_.slideCount - 1) - centerOffset) {
3849
3850                    _.$slides
3851                        .slice(index - centerOffset, index + centerOffset + 1)
3852                        .addClass('slick-active')
3853                        .attr('aria-hidden', 'false');
3854
3855                } else {
3856
3857                    indexOffset = _.options.slidesToShow + index;
3858                    allSlides
3859                        .slice(indexOffset - centerOffset + 1, indexOffset + centerOffset + 2)
3860                        .addClass('slick-active')
3861                        .attr('aria-hidden', 'false');
3862
3863                }
3864
3865                if (index === 0) {
3866
3867                    allSlides
3868                        .eq(allSlides.length - 1 - _.options.slidesToShow)
3869                        .addClass('slick-center');
3870
3871                } else if (index === _.slideCount - 1) {
3872
3873                    allSlides
3874                        .eq(_.options.slidesToShow)
3875                        .addClass('slick-center');
3876
3877                }
3878
3879            }
3880
3881            _.$slides
3882                .eq(index)
3883                .addClass('slick-center');
3884
3885        } else {
3886
3887            if (index >= 0 && index <= (_.slideCount - _.options.slidesToShow)) {
3888
3889                _.$slides
3890                    .slice(index, index + _.options.slidesToShow)
3891                    .addClass('slick-active')
3892                    .attr('aria-hidden', 'false');
3893
3894            } else if (allSlides.length <= _.options.slidesToShow) {
3895
3896                allSlides
3897                    .addClass('slick-active')
3898                    .attr('aria-hidden', 'false');
3899
3900            } else {
3901
3902                remainder = _.slideCount % _.options.slidesToShow;
3903                indexOffset = _.options.infinite === true ? _.options.slidesToShow + index : index;
3904
3905                if (_.options.slidesToShow == _.options.slidesToScroll && (_.slideCount - index) < _.options.slidesToShow) {
3906
3907                    allSlides
3908                        .slice(indexOffset - (_.options.slidesToShow - remainder), indexOffset + remainder)
3909                        .addClass('slick-active')
3910                        .attr('aria-hidden', 'false');
3911
3912                } else {
3913
3914                    allSlides
3915                        .slice(indexOffset, indexOffset + _.options.slidesToShow)
3916                        .addClass('slick-active')
3917                        .attr('aria-hidden', 'false');
3918
3919                }
3920
3921            }
3922
3923        }
3924
3925        if (_.options.lazyLoad === 'ondemand') {
3926            _.lazyLoad();
3927        }
3928
3929    };
3930
3931    Slick.prototype.setupInfinite = function() {
3932
3933        var _ = this,
3934            i, slideIndex, infiniteCount;
3935
3936        if (_.options.fade === true) {
3937            _.options.centerMode = false;
3938        }
3939
3940        if (_.options.infinite === true && _.options.fade === false) {
3941
3942            slideIndex = null;
3943
3944            if (_.slideCount > _.options.slidesToShow) {
3945
3946                if (_.options.centerMode === true) {
3947                    infiniteCount = _.options.slidesToShow + 1;
3948                } else {
3949                    infiniteCount = _.options.slidesToShow;
3950                }
3951
3952                for (i = _.slideCount; i > (_.slideCount -
3953                        infiniteCount); i -= 1) {
3954                    slideIndex = i - 1;
3955                    $(_.$slides[slideIndex]).clone(true).attr('id', '')
3956                        .attr('data-slick-index', slideIndex - _.slideCount)
3957                        .prependTo(_.$slideTrack).addClass('slick-cloned');
3958                }
3959                for (i = 0; i < infiniteCount; i += 1) {
3960                    slideIndex = i;
3961                    $(_.$slides[slideIndex]).clone(true).attr('id', '')
3962                        .attr('data-slick-index', slideIndex + _.slideCount)
3963                        .appendTo(_.$slideTrack).addClass('slick-cloned');
3964                }
3965                _.$slideTrack.find('.slick-cloned').find('[id]').each(function() {
3966                    $(this).attr('id', '');
3967                });
3968
3969            }
3970
3971        }
3972
3973    };
3974
3975    Slick.prototype.interrupt = function( toggle ) {
3976
3977        var _ = this;
3978
3979        if( !toggle ) {
3980            _.autoPlay();
3981        }
3982        _.interrupted = toggle;
3983
3984    };
3985
3986    Slick.prototype.selectHandler = function(event) {
3987
3988        var _ = this;
3989
3990        var targetElement =
3991            $(event.target).is('.slick-slide') ?
3992                $(event.target) :
3993                $(event.target).parents('.slick-slide');
3994
3995        var index = parseInt(targetElement.attr('data-slick-index'));
3996
3997        if (!index) index = 0;
3998
3999        if (_.slideCount <= _.options.slidesToShow) {
4000
4001            _.setSlideClasses(index);
4002            _.asNavFor(index);
4003            return;
4004
4005        }
4006
4007        _.slideHandler(index);
4008
4009    };
4010
4011    Slick.prototype.slideHandler = function(index, sync, dontAnimate) {
4012
4013        var targetSlide, animSlide, oldSlide, slideLeft, targetLeft = null,
4014            _ = this, navTarget;
4015
4016        sync = sync || false;
4017
4018        if (_.animating === true && _.options.waitForAnimate === true) {
4019            return;
4020        }
4021
4022        if (_.options.fade === true && _.currentSlide === index) {
4023            return;
4024        }
4025
4026        if (_.slideCount <= _.options.slidesToShow) {
4027            return;
4028        }
4029
4030        if (sync === false) {
4031            _.asNavFor(index);
4032        }
4033
4034        targetSlide = index;
4035        targetLeft = _.getLeft(targetSlide);
4036        slideLeft = _.getLeft(_.currentSlide);
4037
4038        _.currentLeft = _.swipeLeft === null ? slideLeft : _.swipeLeft;
4039
4040        if (_.options.infinite === false && _.options.centerMode === false && (index < 0 || index > _.getDotCount() * _.options.slidesToScroll)) {
4041            if (_.options.fade === false) {
4042                targetSlide = _.currentSlide;
4043                if (dontAnimate !== true) {
4044                    _.animateSlide(slideLeft, function() {
4045                        _.postSlide(targetSlide);
4046                    });
4047                } else {
4048                    _.postSlide(targetSlide);
4049                }
4050            }
4051            return;
4052        } else if (_.options.infinite === false && _.options.centerMode === true && (index < 0 || index > (_.slideCount - _.options.slidesToScroll))) {
4053            if (_.options.fade === false) {
4054                targetSlide = _.currentSlide;
4055                if (dontAnimate !== true) {
4056                    _.animateSlide(slideLeft, function() {
4057                        _.postSlide(targetSlide);
4058                    });
4059                } else {
4060                    _.postSlide(targetSlide);
4061                }
4062            }
4063            return;
4064        }
4065
4066        if ( _.options.autoplay ) {
4067            clearInterval(_.autoPlayTimer);
4068        }
4069
4070        if (targetSlide < 0) {
4071            if (_.slideCount % _.options.slidesToScroll !== 0) {
4072                animSlide = _.slideCount - (_.slideCount % _.options.slidesToScroll);
4073            } else {
4074                animSlide = _.slideCount + targetSlide;
4075            }
4076        } else if (targetSlide >= _.slideCount) {
4077            if (_.slideCount % _.options.slidesToScroll !== 0) {
4078                animSlide = 0;
4079            } else {
4080                animSlide = targetSlide - _.slideCount;
4081            }
4082        } else {
4083            animSlide = targetSlide;
4084        }
4085
4086        _.animating = true;
4087
4088        _.$slider.trigger('beforeChange', [_, _.currentSlide, animSlide]);
4089
4090        oldSlide = _.currentSlide;
4091        _.currentSlide = animSlide;
4092
4093        _.setSlideClasses(_.currentSlide);
4094
4095        if ( _.options.asNavFor ) {
4096
4097            navTarget = _.getNavTarget();
4098            navTarget = navTarget.slick('getSlick');
4099
4100            if ( navTarget.slideCount <= navTarget.options.slidesToShow ) {
4101                navTarget.setSlideClasses(_.currentSlide);
4102            }
4103
4104        }
4105
4106        _.updateDots();
4107        _.updateArrows();
4108
4109        if (_.options.fade === true) {
4110            if (dontAnimate !== true) {
4111
4112                _.fadeSlideOut(oldSlide);
4113
4114                _.fadeSlide(animSlide, function() {
4115                    _.postSlide(animSlide);
4116                });
4117
4118            } else {
4119                _.postSlide(animSlide);
4120            }
4121            _.animateHeight();
4122            return;
4123        }
4124
4125        if (dontAnimate !== true) {
4126            _.animateSlide(targetLeft, function() {
4127                _.postSlide(animSlide);
4128            });
4129        } else {
4130            _.postSlide(animSlide);
4131        }
4132
4133    };
4134
4135    Slick.prototype.startLoad = function() {
4136
4137        var _ = this;
4138
4139        if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
4140
4141            _.$prevArrow.hide();
4142            _.$nextArrow.hide();
4143
4144        }
4145
4146        if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
4147
4148            _.$dots.hide();
4149
4150        }
4151
4152        _.$slider.addClass('slick-loading');
4153
4154    };
4155
4156    Slick.prototype.swipeDirection = function() {
4157
4158        var xDist, yDist, r, swipeAngle, _ = this;
4159
4160        xDist = _.touchObject.startX - _.touchObject.curX;
4161        yDist = _.touchObject.startY - _.touchObject.curY;
4162        r = Math.atan2(yDist, xDist);
4163
4164        swipeAngle = Math.round(r * 180 / Math.PI);
4165        if (swipeAngle < 0) {
4166            swipeAngle = 360 - Math.abs(swipeAngle);
4167        }
4168
4169        if ((swipeAngle <= 45) && (swipeAngle >= 0)) {
4170            return (_.options.rtl === false ? 'left' : 'right');
4171        }
4172        if ((swipeAngle <= 360) && (swipeAngle >= 315)) {
4173            return (_.options.rtl === false ? 'left' : 'right');
4174        }
4175        if ((swipeAngle >= 135) && (swipeAngle <= 225)) {
4176            return (_.options.rtl === false ? 'right' : 'left');
4177        }
4178        if (_.options.verticalSwiping === true) {
4179            if ((swipeAngle >= 35) && (swipeAngle <= 135)) {
4180                return 'down';
4181            } else {
4182                return 'up';
4183            }
4184        }
4185
4186        return 'vertical';
4187
4188    };
4189
4190    Slick.prototype.swipeEnd = function(event) {
4191
4192        var _ = this,
4193            slideCount,
4194            direction;
4195
4196        _.dragging = false;
4197        _.interrupted = false;
4198        _.shouldClick = ( _.touchObject.swipeLength > 10 ) ? false : true;
4199
4200        if ( _.touchObject.curX === undefined ) {
4201            return false;
4202        }
4203
4204        if ( _.touchObject.edgeHit === true ) {
4205            _.$slider.trigger('edge', [_, _.swipeDirection() ]);
4206        }
4207
4208        if ( _.touchObject.swipeLength >= _.touchObject.minSwipe ) {
4209
4210            direction = _.swipeDirection();
4211
4212            switch ( direction ) {
4213
4214                case 'left':
4215                case 'down':
4216
4217                    slideCount =
4218                        _.options.swipeToSlide ?
4219                            _.checkNavigable( _.currentSlide + _.getSlideCount() ) :
4220                            _.currentSlide + _.getSlideCount();
4221
4222                    _.currentDirection = 0;
4223
4224                    break;
4225
4226                case 'right':
4227                case 'up':
4228
4229                    slideCount =
4230                        _.options.swipeToSlide ?
4231                            _.checkNavigable( _.currentSlide - _.getSlideCount() ) :
4232                            _.currentSlide - _.getSlideCount();
4233
4234                    _.currentDirection = 1;
4235
4236                    break;
4237
4238                default:
4239
4240
4241            }
4242
4243            if( direction != 'vertical' ) {
4244
4245                _.slideHandler( slideCount );
4246                _.touchObject = {};
4247                _.$slider.trigger('swipe', [_, direction ]);
4248
4249            }
4250
4251        } else {
4252
4253            if ( _.touchObject.startX !== _.touchObject.curX ) {
4254
4255                _.slideHandler( _.currentSlide );
4256                _.touchObject = {};
4257
4258            }
4259
4260        }
4261
4262    };
4263
4264    Slick.prototype.swipeHandler = function(event) {
4265
4266        var _ = this;
4267
4268        if ((_.options.swipe === false) || ('ontouchend' in document && _.options.swipe === false)) {
4269            return;
4270        } else if (_.options.draggable === false && event.type.indexOf('mouse') !== -1) {
4271            return;
4272        }
4273
4274        _.touchObject.fingerCount = event.originalEvent && event.originalEvent.touches !== undefined ?
4275            event.originalEvent.touches.length : 1;
4276
4277        _.touchObject.minSwipe = _.listWidth / _.options
4278            .touchThreshold;
4279
4280        if (_.options.verticalSwiping === true) {
4281            _.touchObject.minSwipe = _.listHeight / _.options
4282                .touchThreshold;
4283        }
4284
4285        switch (event.data.action) {
4286
4287            case 'start':
4288                _.swipeStart(event);
4289                break;
4290
4291            case 'move':
4292                _.swipeMove(event);
4293                break;
4294
4295            case 'end':
4296                _.swipeEnd(event);
4297                break;
4298
4299        }
4300
4301    };
4302
4303    Slick.prototype.swipeMove = function(event) {
4304
4305        var _ = this,
4306            edgeWasHit = false,
4307            curLeft, swipeDirection, swipeLength, positionOffset, touches;
4308
4309        touches = event.originalEvent !== undefined ? event.originalEvent.touches : null;
4310
4311        if (!_.dragging || touches && touches.length !== 1) {
4312            return false;
4313        }
4314
4315        curLeft = _.getLeft(_.currentSlide);
4316
4317        _.touchObject.curX = touches !== undefined ? touches[0].pageX : event.clientX;
4318        _.touchObject.curY = touches !== undefined ? touches[0].pageY : event.clientY;
4319
4320        _.touchObject.swipeLength = Math.round(Math.sqrt(
4321            Math.pow(_.touchObject.curX - _.touchObject.startX, 2)));
4322
4323        if (_.options.verticalSwiping === true) {
4324            _.touchObject.swipeLength = Math.round(Math.sqrt(
4325                Math.pow(_.touchObject.curY - _.touchObject.startY, 2)));
4326        }
4327
4328        swipeDirection = _.swipeDirection();
4329
4330        if (swipeDirection === 'vertical') {
4331            return;
4332        }
4333
4334        if (event.originalEvent !== undefined && _.touchObject.swipeLength > 4) {
4335            event.preventDefault();
4336        }
4337
4338        positionOffset = (_.options.rtl === false ? 1 : -1) * (_.touchObject.curX > _.touchObject.startX ? 1 : -1);
4339        if (_.options.verticalSwiping === true) {
4340            positionOffset = _.touchObject.curY > _.touchObject.startY ? 1 : -1;
4341        }
4342
4343
4344        swipeLength = _.touchObject.swipeLength;
4345
4346        _.touchObject.edgeHit = false;
4347
4348        if (_.options.infinite === false) {
4349            if ((_.currentSlide === 0 && swipeDirection === 'right') || (_.currentSlide >= _.getDotCount() && swipeDirection === 'left')) {
4350                swipeLength = _.touchObject.swipeLength * _.options.edgeFriction;
4351                _.touchObject.edgeHit = true;
4352            }
4353        }
4354
4355        if (_.options.vertical === false) {
4356            _.swipeLeft = curLeft + swipeLength * positionOffset;
4357        } else {
4358            _.swipeLeft = curLeft + (swipeLength * (_.$list.height() / _.listWidth)) * positionOffset;
4359        }
4360        if (_.options.verticalSwiping === true) {
4361            _.swipeLeft = curLeft + swipeLength * positionOffset;
4362        }
4363
4364        if (_.options.fade === true || _.options.touchMove === false) {
4365            return false;
4366        }
4367
4368        if (_.animating === true) {
4369            _.swipeLeft = null;
4370            return false;
4371        }
4372
4373        _.setCSS(_.swipeLeft);
4374
4375    };
4376
4377    Slick.prototype.swipeStart = function(event) {
4378
4379        var _ = this,
4380            touches;
4381
4382        _.interrupted = true;
4383
4384        if (_.touchObject.fingerCount !== 1 || _.slideCount <= _.options.slidesToShow) {
4385            _.touchObject = {};
4386            return false;
4387        }
4388
4389        if (event.originalEvent !== undefined && event.originalEvent.touches !== undefined) {
4390            touches = event.originalEvent.touches[0];
4391        }
4392
4393        _.touchObject.startX = _.touchObject.curX = touches !== undefined ? touches.pageX : event.clientX;
4394        _.touchObject.startY = _.touchObject.curY = touches !== undefined ? touches.pageY : event.clientY;
4395
4396        _.dragging = true;
4397
4398    };
4399
4400    Slick.prototype.unfilterSlides = Slick.prototype.slickUnfilter = function() {
4401
4402        var _ = this;
4403
4404        if (_.$slidesCache !== null) {
4405
4406            _.unload();
4407
4408            _.$slideTrack.children(this.options.slide).detach();
4409
4410            _.$slidesCache.appendTo(_.$slideTrack);
4411
4412            _.reinit();
4413
4414        }
4415
4416    };
4417
4418    Slick.prototype.unload = function() {
4419
4420        var _ = this;
4421
4422        $('.slick-cloned', _.$slider).remove();
4423
4424        if (_.$dots) {
4425            _.$dots.remove();
4426        }
4427
4428        if (_.$prevArrow && _.htmlExpr.test(_.options.prevArrow)) {
4429            _.$prevArrow.remove();
4430        }
4431
4432        if (_.$nextArrow && _.htmlExpr.test(_.options.nextArrow)) {
4433            _.$nextArrow.remove();
4434        }
4435
4436        _.$slides
4437            .removeClass('slick-slide slick-active slick-visible slick-current')
4438            .attr('aria-hidden', 'true')
4439            .css('width', '');
4440
4441    };
4442
4443    Slick.prototype.unslick = function(fromBreakpoint) {
4444
4445        var _ = this;
4446        _.$slider.trigger('unslick', [_, fromBreakpoint]);
4447        _.destroy();
4448
4449    };
4450
4451    Slick.prototype.updateArrows = function() {
4452
4453        var _ = this,
4454            centerOffset;
4455
4456        centerOffset = Math.floor(_.options.slidesToShow / 2);
4457
4458        if ( _.options.arrows === true &&
4459            _.slideCount > _.options.slidesToShow &&
4460            !_.options.infinite ) {
4461
4462            _.$prevArrow.removeClass('slick-disabled').attr('aria-disabled', 'false');
4463            _.$nextArrow.removeClass('slick-disabled').attr('aria-disabled', 'false');
4464
4465            if (_.currentSlide === 0) {
4466
4467                _.$prevArrow.addClass('slick-disabled').attr('aria-disabled', 'true');
4468                _.$nextArrow.removeClass('slick-disabled').attr('aria-disabled', 'false');
4469
4470            } else if (_.currentSlide >= _.slideCount - _.options.slidesToShow && _.options.centerMode === false) {
4471
4472                _.$nextArrow.addClass('slick-disabled').attr('aria-disabled', 'true');
4473                _.$prevArrow.removeClass('slick-disabled').attr('aria-disabled', 'false');
4474
4475            } else if (_.currentSlide >= _.slideCount - 1 && _.options.centerMode === true) {
4476
4477                _.$nextArrow.addClass('slick-disabled').attr('aria-disabled', 'true');
4478                _.$prevArrow.removeClass('slick-disabled').attr('aria-disabled', 'false');
4479
4480            }
4481
4482        }
4483
4484    };
4485
4486    Slick.prototype.updateDots = function() {
4487
4488        var _ = this;
4489
4490        if (_.$dots !== null) {
4491
4492            _.$dots
4493                .find('li')
4494                .removeClass('slick-active')
4495                .attr('aria-hidden', 'true');
4496
4497            _.$dots
4498                .find('li')
4499                .eq(Math.floor(_.currentSlide / _.options.slidesToScroll))
4500                .addClass('slick-active')
4501                .attr('aria-hidden', 'false');
4502
4503        }
4504
4505    };
4506
4507    Slick.prototype.visibility = function() {
4508
4509        var _ = this;
4510
4511        if ( _.options.autoplay ) {
4512
4513            if ( document[_.hidden] ) {
4514
4515                _.interrupted = true;
4516
4517            } else {
4518
4519                _.interrupted = false;
4520
4521            }
4522
4523        }
4524
4525    };
4526
4527    $.fn.slick = function() {
4528        var _ = this,
4529            opt = arguments[0],
4530            args = Array.prototype.slice.call(arguments, 1),
4531            l = _.length,
4532            i,
4533            ret;
4534        for (i = 0; i < l; i++) {
4535            if (typeof opt == 'object' || typeof opt == 'undefined')
4536                _[i].slick = new Slick(_[i], opt);
4537            else
4538                ret = _[i].slick[opt].apply(_[i].slick, args);
4539            if (typeof ret != 'undefined') return ret;
4540        }
4541        return _;
4542    };
4543
4544}));
4545
4546
4547// The MIT License (MIT)
4548
4549// Copyright (c) 2015 BG Stock - html5backgroundvideos.com
4550
4551// Permission is hereby granted, free of charge, to any person obtaining a copy
4552// of this software and associated documentation files (the "Software"), to deal
4553// in the Software without restriction, including without limitation the rights
4554// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4555// copies of the Software, and to permit persons to whom the Software is
4556// furnished to do so, subject to the following conditions:
4557
4558// The above copyright notice and this permission notice shall be included in all
4559// copies or substantial portions of the Software.
4560
4561// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4562// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4563// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4564// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4565// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4566// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4567// SOFTWARE.
4568
4569(function($) {
4570
4571	// Add js class to html
4572	$('html').addClass('js');
4573
4574	// Add IE8 shim for Date.now()
4575	if (!Date.now) {
4576		Date.now = function() { return new Date().getTime(); }
4577	}
4578
4579	// Return current time in seconds
4580	function currentTime() {
4581		return Math.floor(Date.now() / 1000);
4582	}
4583
4584	// The plugin
4585	$.fn.bgVideo = function( options ) {
4586
4587		// @bool iOS
4588		var iOS = /iPad|iPhone|iPod/.test(navigator.platform) || /iPad|iPhone|iPod/.test(navigator.userAgent);
4589
4590		// Settings
4591		var settings = $.extend({}, $.fn.bgVideo.defaults, options );
4592
4593		// Do the things
4594		return this.each(function() {
4595
4596			// Set some handy variables
4597			var $video = $(this); // jQuery Object
4598			var video = $video[0]; // DOM node
4599			var $container = $video.parent();
4600			var $pauseplay = $('<button class="jquery-background-video-pauseplay pause"><span>Pause</span></button>');
4601			var start_time; // We'll set this when it starts playing
4602
4603
4604			// Check for any data attributes that will override the settings for this particular element
4605			var el_settings = $.extend({}, settings);
4606			var data_attrs = $video.data();
4607			$.each( data_attrs, function( data_name, data_val ) {
4608				if( data_name.indexOf('bgvideo') === 0 ) {
4609					// It's a match! Strip the bgvideo prefix and lowercase the first letter
4610					data_name = data_name.replace('bgvideo', '');
4611					data_name = data_name.charAt(0).toLowerCase() + data_name.slice(1);
4612					// Then set the setting
4613					el_settings[data_name] = data_val;
4614				}
4615			});
4616
4617			
4618			// Attach to playing event
4619			$video.on('playing', function(){
4620				start_time = currentTime();
4621				$video.addClass('is-playing is-visible');
4622				$pauseplay.removeClass('play').addClass('pause').find('span').text('Pause');
4623				$.fn.bgVideo.fitVideo( $video );
4624			});
4625
4626
4627			// If the video is already playing before js loads
4628			if( video.currentTime > 0 ) {
4629				$video.addClass('is-playing is-visible');
4630			}
4631
4632
4633			// Attach to pause event
4634			$video.on('pause', function(){
4635				$video.removeClass('is-playing');
4636				$pauseplay.removeClass('pause').addClass('play').find('span').text('Play');
4637				if(el_settings.fadeOnPause) {
4638					$video.removeClass('is-visible');
4639				}
4640			});
4641
4642
4643			// Set default styles
4644			$container.css({
4645				'position': 'relative',
4646				'overflow': 'hidden',
4647				'background-size': 'cover',
4648				'background-position': 'center center',
4649				'background-repeat': 'no-repeat',
4650				'background-image': 'url(' + $video.attr('poster') + ')'
4651			});
4652			$video.css({
4653				'min-width': 'auto',
4654				'min-height': 'auto',
4655				'width': '100%',
4656				'height': 'auto',
4657				'position': 'absolute',
4658				'left': '50%',
4659				'top': '50%',
4660				'transform': 'translate(-50%,-50%)'
4661			});
4662			if( el_settings.fullScreen ) {
4663				$container.css({
4664					'position': 'fixed',
4665					'top': '0',
4666					'bottom': '0',
4667					'left': '0',
4668					'right': '0',
4669					'height': 'auto',
4670					'margin': '0',
4671					'z-index': '-1'
4672				});
4673			}
4674
4675
4676			// Fade in video by setting the transition duration
4677			$video.css('transition-duration', el_settings.fadeIn + 'ms');
4678
4679
4680			// Remove on iOS
4681			if( iOS ) {
4682				// Unset sources to prevent them from continuing to download
4683				$video.attr('src', '');
4684				$video.find('source').attr('src', '');
4685				$video.remove();
4686			}
4687
4688
4689			// Mimic background-size: cover with video element
4690			$.fn.bgVideo.fitVideo( $video );
4691			$(window).resize(function(){
4692				$.fn.bgVideo.fitVideo( $video );
4693			});
4694
4695
4696			// Pause after X seconds
4697			el_settings.pauseAfter = parseInt( el_settings.pauseAfter, 10 );
4698			if( el_settings.pauseAfter > 0 ) {
4699				$video.on('timeupdate', function(){
4700					var now = currentTime();
4701					if( now > start_time + el_settings.pauseAfter ) {
4702						video.pause();
4703						if( el_settings.fadeOnEnd ) {
4704							$video.removeClass('is-visible');
4705						}
4706					}
4707				});
4708			}
4709
4710
4711			// Play / pause button
4712			if( el_settings.showPausePlay ) {
4713				// Append pauseplay element created earlier
4714				$container.append($pauseplay);
4715				// Position element
4716				$pauseplay.css({
4717					'left':   'auto',
4718					'right':  'auto',
4719					'top':    'auto',
4720					'bottom': 'auto'
4721				});
4722				$pauseplay.css(el_settings.pausePlayXPos, el_settings.pausePlayXOffset);
4723				$pauseplay.css(el_settings.pausePlayYPos, el_settings.pausePlayYOffset);
4724				if( el_settings.pausePlayXPos === 'center' ) {
4725					$pauseplay.css({
4726						'left':        '50%',
4727						'margin-left': '-10px'
4728					});
4729				}
4730				if( el_settings.pausePlayYPos === 'center' ) {
4731					$pauseplay.css({
4732						'top':        '50%',
4733						'margin-top': '-10px'
4734					});
4735				}
4736				// Add functionality
4737				$pauseplay.on('click', function(){
4738					if(video.paused) {
4739						video.play();
4740					} else {
4741						video.pause();
4742					}
4743				});
4744			}
4745
4746
4747		});
4748
4749
4750	};
4751
4752
4753	// Default settings
4754	$.fn.bgVideo.defaults = {
4755		fullScreen: false, // Sets the video to be fixed to the full window
4756		fadeIn: 500, // Milliseconds to fade video in/out (0 for no fade)
4757		pauseAfter: 120, // Seconds to play before pausing (0 for forever)
4758		fadeOnPause: false, // For all (including manual) pauses
4759		fadeOnEnd: true, // When we've reached the pauseAfter time
4760		showPausePlay: true, // Show pause/play button
4761		pausePlayXPos: 'right', // left|right|center
4762		pausePlayYPos: 'top', // top|bottom|center
4763		pausePlayXOffset: '15px', // pixels or percent from side - ignored if positioned center
4764		pausePlayYOffset: '15px' // pixels or percent from top/bottom - ignored if positioned center
4765	};
4766
4767
4768	// Fit video
4769	$.fn.bgVideo.fitVideo = function( $video ) {
4770
4771		var $container = $video.parent(),
4772			container_height = $container.outerHeight(),
4773			container_width = $container.outerWidth();
4774
4775		// Do this again every time the screen size changes
4776		$video.css({
4777			'height': 'auto',
4778			'width': container_width + 'px'
4779		});
4780
4781		var video_height = $video.height();
4782
4783		if( container_height > video_height ) {
4784			//console.log('Container height > video height');
4785			$video.css({
4786				'height': container_height + 'px',
4787				'width': 'auto'
4788			});
4789		}
4790
4791	};
4792
4793
4794	// Auto run based on data attributes
4795	$(document).ready(function(){
4796		$('[data-bgvideo]').bgVideo();
4797	});
4798
4799
4800}(jQuery));
4801
4802/**
4803* jquery-match-height 0.7.0 by @liabru
4804* http://brm.io/jquery-match-height/
4805* License: MIT
4806*/
4807
4808;(function(factory) { // eslint-disable-line no-extra-semi
4809    'use strict';
4810    if (typeof define === 'function' && define.amd) {
4811        // AMD
4812        define(['jquery'], factory);
4813    } else if (typeof module !== 'undefined' && module.exports) {
4814        // CommonJS
4815        module.exports = factory(require('jquery'));
4816    } else {
4817        // Global
4818        factory(jQuery);
4819    }
4820})(function($) {
4821    /*
4822    *  internal
4823    */
4824
4825    var _previousResizeWidth = -1,
4826        _updateTimeout = -1;
4827
4828    /*
4829    *  _parse
4830    *  value parse utility function
4831    */
4832
4833    var _parse = function(value) {
4834        // parse value and convert NaN to 0
4835        return parseFloat(value) || 0;
4836    };
4837
4838    /*
4839    *  _rows
4840    *  utility function returns array of jQuery selections representing each row
4841    *  (as displayed after float wrapping applied by browser)
4842    */
4843
4844    var _rows = function(elements) {
4845        var tolerance = 1,
4846            $elements = $(elements),
4847            lastTop = null,
4848            rows = [];
4849
4850        // group elements by their top position
4851        $elements.each(function(){
4852            var $that = $(this),
4853                top = $that.offset().top - _parse($that.css('margin-top')),
4854                lastRow = rows.length > 0 ? rows[rows.length - 1] : null;
4855
4856            if (lastRow === null) {
4857                // first item on the row, so just push it
4858                rows.push($that);
4859            } else {
4860                // if the row top is the same, add to the row group
4861                if (Math.floor(Math.abs(lastTop - top)) <= tolerance) {
4862                    rows[rows.length - 1] = lastRow.add($that);
4863                } else {
4864                    // otherwise start a new row group
4865                    rows.push($that);
4866                }
4867            }
4868
4869            // keep track of the last row top
4870            lastTop = top;
4871        });
4872
4873        return rows;
4874    };
4875
4876    /*
4877    *  _parseOptions
4878    *  handle plugin options
4879    */
4880
4881    var _parseOptions = function(options) {
4882        var opts = {
4883            byRow: true,
4884            property: 'height',
4885            target: null,
4886            remove: false
4887        };
4888
4889        if (typeof options === 'object') {
4890            return $.extend(opts, options);
4891        }
4892
4893        if (typeof options === 'boolean') {
4894            opts.byRow = options;
4895        } else if (options === 'remove') {
4896            opts.remove = true;
4897        }
4898
4899        return opts;
4900    };
4901
4902    /*
4903    *  matchHeight
4904    *  plugin definition
4905    */
4906
4907    var matchHeight = $.fn.matchHeight = function(options) {
4908        var opts = _parseOptions(options);
4909
4910        // handle remove
4911        if (opts.remove) {
4912            var that = this;
4913
4914            // remove fixed height from all selected elements
4915            this.css(opts.property, '');
4916
4917            // remove selected elements from all groups
4918            $.each(matchHeight._groups, function(key, group) {
4919                group.elements = group.elements.not(that);
4920            });
4921
4922            // TODO: cleanup empty groups
4923
4924            return this;
4925        }
4926
4927        if (this.length <= 1 && !opts.target) {
4928            return this;
4929        }
4930
4931        // keep track of this group so we can re-apply later on load and resize events
4932        matchHeight._groups.push({
4933            elements: this,
4934            options: opts
4935        });
4936
4937        // match each element's height to the tallest element in the selection
4938        matchHeight._apply(this, opts);
4939
4940        return this;
4941    };
4942
4943    /*
4944    *  plugin global options
4945    */
4946
4947    matchHeight.version = '0.7.0';
4948    matchHeight._groups = [];
4949    matchHeight._throttle = 80;
4950    matchHeight._maintainScroll = false;
4951    matchHeight._beforeUpdate = null;
4952    matchHeight._afterUpdate = null;
4953    matchHeight._rows = _rows;
4954    matchHeight._parse = _parse;
4955    matchHeight._parseOptions = _parseOptions;
4956
4957    /*
4958    *  matchHeight._apply
4959    *  apply matchHeight to given elements
4960    */
4961
4962    matchHeight._apply = function(elements, options) {
4963        var opts = _parseOptions(options),
4964            $elements = $(elements),
4965            rows = [$elements];
4966
4967        // take note of scroll position
4968        var scrollTop = $(window).scrollTop(),
4969            htmlHeight = $('html').outerHeight(true);
4970
4971        // get hidden parents
4972        var $hiddenParents = $elements.parents().filter(':hidden');
4973
4974        // cache the original inline style
4975        $hiddenParents.each(function() {
4976            var $that = $(this);
4977            $that.data('style-cache', $that.attr('style'));
4978        });
4979
4980        // temporarily must force hidden parents visible
4981        $hiddenParents.css('display', 'block');
4982
4983        // get rows if using byRow, otherwise assume one row
4984        if (opts.byRow && !opts.target) {
4985
4986            // must first force an arbitrary equal height so floating elements break evenly
4987            $elements.each(function() {
4988                var $that = $(this),
4989                    display = $that.css('display');
4990
4991                // temporarily force a usable display value
4992                if (display !== 'inline-block' && display !== 'flex' && display !== 'inline-flex') {
4993                    display = 'block';
4994                }
4995
4996                // cache the original inline style
4997                $that.data('style-cache', $that.attr('style'));
4998
4999                $that.css({
5000                    'display': display,
5001                    'padding-top': '0',
5002                    'padding-bottom': '0',
5003                    'margin-top': '0',
5004                    'margin-bottom': '0',
5005                    'border-top-width': '0',
5006                    'border-bottom-width': '0',
5007                    'height': '100px',
5008                    'overflow': 'hidden'
5009                });
5010            });
5011
5012            // get the array of rows (based on element top position)
5013            rows = _rows($elements);
5014
5015            // revert original inline styles
5016            $elements.each(function() {
5017                var $that = $(this);
5018                $that.attr('style', $that.data('style-cache') || '');
5019            });
5020        }
5021
5022        $.each(rows, function(key, row) {
5023            var $row = $(row),
5024                targetHeight = 0;
5025
5026            if (!opts.target) {
5027                // skip apply to rows with only one item
5028                if (opts.byRow && $row.length <= 1) {
5029                    $row.css(opts.property, '');
5030                    return;
5031                }
5032
5033                // iterate the row and find the max height
5034                $row.each(function(){
5035                    var $that = $(this),
5036                        style = $that.attr('style'),
5037                        display = $that.css('display');
5038
5039                    // temporarily force a usable display value
5040                    if (display !== 'inline-block' && display !== 'flex' && display !== 'inline-flex') {
5041                        display = 'block';
5042                    }
5043
5044                    // ensure we get the correct actual height (and not a previously set height value)
5045                    var css = { 'display': display };
5046                    css[opts.property] = '';
5047                    $that.css(css);
5048
5049                    // find the max height (including padding, but not margin)
5050                    if ($that.outerHeight(false) > targetHeight) {
5051                        targetHeight = $that.outerHeight(false);
5052                    }
5053
5054                    // revert styles
5055                    if (style) {
5056                        $that.attr('style', style);
5057                    } else {
5058                        $that.css('display', '');
5059                    }
5060                });
5061            } else {
5062                // if target set, use the height of the target element
5063                targetHeight = opts.target.outerHeight(false);
5064            }
5065
5066            // iterate the row and apply the height to all elements
5067            $row.each(function(){
5068                var $that = $(this),
5069                    verticalPadding = 0;
5070
5071                // don't apply to a target
5072                if (opts.target && $that.is(opts.target)) {
5073                    return;
5074                }
5075
5076                // handle padding and border correctly (required when not using border-box)
5077                if ($that.css('box-sizing') !== 'border-box') {
5078                    verticalPadding += _parse($that.css('border-top-width')) + _parse($that.css('border-bottom-width'));
5079                    verticalPadding += _parse($that.css('padding-top')) + _parse($that.css('padding-bottom'));
5080                }
5081
5082                // set the height (accounting for padding and border)
5083                $that.css(opts.property, (targetHeight - verticalPadding) + 'px');
5084            });
5085        });
5086
5087        // revert hidden parents
5088        $hiddenParents.each(function() {
5089            var $that = $(this);
5090            $that.attr('style', $that.data('style-cache') || null);
5091        });
5092
5093        // restore scroll position if enabled
5094        if (matchHeight._maintainScroll) {
5095            $(window).scrollTop((scrollTop / htmlHeight) * $('html').outerHeight(true));
5096        }
5097
5098        return this;
5099    };
5100
5101    /*
5102    *  matchHeight._applyDataApi
5103    *  applies matchHeight to all elements with a data-match-height attribute
5104    */
5105
5106    matchHeight._applyDataApi = function() {
5107        var groups = {};
5108
5109        // generate groups by their groupId set by elements using data-match-height
5110        $('[data-match-height], [data-mh]').each(function() {
5111            var $this = $(this),
5112                groupId = $this.attr('data-mh') || $this.attr('data-match-height');
5113
5114            if (groupId in groups) {
5115                groups[groupId] = groups[groupId].add($this);
5116            } else {
5117                groups[groupId] = $this;
5118            }
5119        });
5120
5121        // apply matchHeight to each group
5122        $.each(groups, function() {
5123            this.matchHeight(true);
5124        });
5125    };
5126
5127    /*
5128    *  matchHeight._update
5129    *  updates matchHeight on all current groups with their correct options
5130    */
5131
5132    var _update = function(event) {
5133        if (matchHeight._beforeUpdate) {
5134            matchHeight._beforeUpdate(event, matchHeight._groups);
5135        }
5136
5137        $.each(matchHeight._groups, function() {
5138            matchHeight._apply(this.elements, this.options);
5139        });
5140
5141        if (matchHeight._afterUpdate) {
5142            matchHeight._afterUpdate(event, matchHeight._groups);
5143        }
5144    };
5145
5146    matchHeight._update = function(throttle, event) {
5147        // prevent update if fired from a resize event
5148        // where the viewport width hasn't actually changed
5149        // fixes an event looping bug in IE8
5150        if (event && event.type === 'resize') {
5151            var windowWidth = $(window).width();
5152            if (windowWidth === _previousResizeWidth) {
5153                return;
5154            }
5155            _previousResizeWidth = windowWidth;
5156        }
5157
5158        // throttle updates
5159        if (!throttle) {
5160            _update(event);
5161        } else if (_updateTimeout === -1) {
5162            _updateTimeout = setTimeout(function() {
5163                _update(event);
5164                _updateTimeout = -1;
5165            }, matchHeight._throttle);
5166        }
5167    };
5168
5169    /*
5170    *  bind events
5171    */
5172
5173    // apply on DOM ready event
5174    $(matchHeight._applyDataApi);
5175
5176    // update heights on load and resize events
5177    $(window).bind('load', function(event) {
5178        matchHeight._update(false, event);
5179    });
5180
5181    // throttled update heights on resize events
5182    $(window).bind('resize orientationchange', function(event) {
5183        matchHeight._update(true, event);
5184    });
5185
5186});
5187
5188
5189/*!
5190 * Select2 4.0.3
5191 * https://select2.github.io
5192 *
5193 * Released under the MIT license
5194 * https://github.com/select2/select2/blob/master/LICENSE.md
5195 */
5196(function (factory) {
5197  if (typeof define === 'function' && define.amd) {
5198    // AMD. Register as an anonymous module.
5199    define(['jquery'], factory);
5200  } else if (typeof exports === 'object') {
5201    // Node/CommonJS
5202    factory(require('jquery'));
5203  } else {
5204    // Browser globals
5205    factory(jQuery);
5206  }
5207}(function (jQuery) {
5208  // This is needed so we can catch the AMD loader configuration and use it
5209  // The inner file should be wrapped (by `banner.start.js`) in a function that
5210  // returns the AMD loader references.
5211  var S2 =
5212(function () {
5213  // Restore the Select2 AMD loader so it can be used
5214  // Needed mostly in the language files, where the loader is not inserted
5215  if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) {
5216    var S2 = jQuery.fn.select2.amd;
5217  }
5218var S2;(function () { if (!S2 || !S2.requirejs) {
5219if (!S2) { S2 = {}; } else { require = S2; }
5220/**
5221 * @license almond 0.3.1 Copyright (c) 2011-2014, The Dojo Foundation All Rights Reserved.
5222 * Available via the MIT or new BSD license.
5223 * see: http://github.com/jrburke/almond for details
5224 */
5225//Going sloppy to avoid 'use strict' string cost, but strict practices should
5226//be followed.
5227/*jslint sloppy: true */
5228/*global setTimeout: false */
5229
5230var requirejs, require, define;
5231(function (undef) {
5232    var main, req, makeMap, handlers,
5233        defined = {},
5234        waiting = {},
5235        config = {},
5236        defining = {},
5237        hasOwn = Object.prototype.hasOwnProperty,
5238        aps = [].slice,
5239        jsSuffixRegExp = /\.js$/;
5240
5241    function hasProp(obj, prop) {
5242        return hasOwn.call(obj, prop);
5243    }
5244
5245    /**
5246     * Given a relative module name, like ./something, normalize it to
5247     * a real name that can be mapped to a path.
5248     * @param {String} name the relative name
5249     * @param {String} baseName a real name that the name arg is relative
5250     * to.
5251     * @returns {String} normalized name
5252     */
5253    function normalize(name, baseName) {
5254        var nameParts, nameSegment, mapValue, foundMap, lastIndex,
5255            foundI, foundStarMap, starI, i, j, part,
5256            baseParts = baseName && baseName.split("/"),
5257            map = config.map,
5258            starMap = (map && map['*']) || {};
5259
5260        //Adjust any relative paths.
5261        if (name && name.charAt(0) === ".") {
5262            //If have a base name, try to normalize against it,
5263            //otherwise, assume it is a top-level require that will
5264            //be relative to baseUrl in the end.
5265            if (baseName) {
5266                name = name.split('/');
5267                lastIndex = name.length - 1;
5268
5269                // Node .js allowance:
5270                if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
5271                    name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
5272                }
5273
5274                //Lop off the last part of baseParts, so that . matches the
5275                //"directory" and not name of the baseName's module. For instance,
5276                //baseName of "one/two/three", maps to "one/two/three.js", but we
5277                //want the directory, "one/two" for this normalization.
5278                name = baseParts.slice(0, baseParts.length - 1).concat(name);
5279
5280                //start trimDots
5281                for (i = 0; i < name.length; i += 1) {
5282                    part = name[i];
5283                    if (part === ".") {
5284                        name.splice(i, 1);
5285                        i -= 1;
5286                    } else if (part === "..") {
5287                        if (i === 1 && (name[2] === '..' || name[0] === '..')) {
5288                            //End of the line. Keep at least one non-dot
5289                            //path segment at the front so it can be mapped
5290                            //correctly to disk. Otherwise, there is likely
5291                            //no path mapping for a path starting with '..'.
5292                            //This can still fail, but catches the most reasonable
5293                            //uses of ..
5294                            break;
5295                        } else if (i > 0) {
5296                            name.splice(i - 1, 2);
5297                            i -= 2;
5298                        }
5299                    }
5300                }
5301                //end trimDots
5302
5303                name = name.join("/");
5304            } else if (name.indexOf('./') === 0) {
5305                // No baseName, so this is ID is resolved relative
5306                // to baseUrl, pull off the leading dot.
5307                name = name.substring(2);
5308            }
5309        }
5310
5311        //Apply map config if available.
5312        if ((baseParts || starMap) && map) {
vendor: 8,788 bytes, lines 5313-5564
5313            nameParts = name.split('/');
5314
5315            for (i = nameParts.length; i > 0; i -= 1) {
5316                nameSegment = nameParts.slice(0, i).join("/");
5317
5318                if (baseParts) {
5319                    //Find the longest baseName segment match in the config.
5320                    //So, do joins on the biggest to smallest lengths of baseParts.
5321                    for (j = baseParts.length; j > 0; j -= 1) {
5322                        mapValue = map[baseParts.slice(0, j).join('/')];
5323
5324                        //baseName segment has  config, find if it has one for
5325                        //this name.
5326                        if (mapValue) {
5327                            mapValue = mapValue[nameSegment];
5328                            if (mapValue) {
5329                                //Match, update name to the new value.
5330                                foundMap = mapValue;
5331                                foundI = i;
5332                                break;
5333                            }
5334                        }
5335                    }
5336                }
5337
5338                if (foundMap) {
5339                    break;
5340                }
5341
5342                //Check for a star map match, but just hold on to it,
5343                //if there is a shorter segment match later in a matching
5344                //config, then favor over this star map.
5345                if (!foundStarMap && starMap && starMap[nameSegment]) {
5346                    foundStarMap = starMap[nameSegment];
5347                    starI = i;
5348                }
5349            }
5350
5351            if (!foundMap && foundStarMap) {
5352                foundMap = foundStarMap;
5353                foundI = starI;
5354            }
5355
5356            if (foundMap) {
5357                nameParts.splice(0, foundI, foundMap);
5358                name = nameParts.join('/');
5359            }
5360        }
5361
5362        return name;
5363    }
5364
5365    function makeRequire(relName, forceSync) {
5366        return function () {
5367            //A version of a require function that passes a moduleName
5368            //value for items that may need to
5369            //look up paths relative to the moduleName
5370            var args = aps.call(arguments, 0);
5371
5372            //If first arg is not require('string'), and there is only
5373            //one arg, it is the array form without a callback. Insert
5374            //a null so that the following concat is correct.
5375            if (typeof args[0] !== 'string' && args.length === 1) {
5376                args.push(null);
5377            }
5378            return req.apply(undef, args.concat([relName, forceSync]));
5379        };
5380    }
5381
5382    function makeNormalize(relName) {
5383        return function (name) {
5384            return normalize(name, relName);
5385        };
5386    }
5387
5388    function makeLoad(depName) {
5389        return function (value) {
5390            defined[depName] = value;
5391        };
5392    }
5393
5394    function callDep(name) {
5395        if (hasProp(waiting, name)) {
5396            var args = waiting[name];
5397            delete waiting[name];
5398            defining[name] = true;
5399            main.apply(undef, args);
5400        }
5401
5402        if (!hasProp(defined, name) && !hasProp(defining, name)) {
5403            throw new Error('No ' + name);
5404        }
5405        return defined[name];
5406    }
5407
5408    //Turns a plugin!resource to [plugin, resource]
5409    //with the plugin being undefined if the name
5410    //did not have a plugin prefix.
5411    function splitPrefix(name) {
5412        var prefix,
5413            index = name ? name.indexOf('!') : -1;
5414        if (index > -1) {
5415            prefix = name.substring(0, index);
5416            name = name.substring(index + 1, name.length);
5417        }
5418        return [prefix, name];
5419    }
5420
5421    /**
5422     * Makes a name map, normalizing the name, and using a plugin
5423     * for normalization if necessary. Grabs a ref to plugin
5424     * too, as an optimization.
5425     */
5426    makeMap = function (name, relName) {
5427        var plugin,
5428            parts = splitPrefix(name),
5429            prefix = parts[0];
5430
5431        name = parts[1];
5432
5433        if (prefix) {
5434            prefix = normalize(prefix, relName);
5435            plugin = callDep(prefix);
5436        }
5437
5438        //Normalize according
5439        if (prefix) {
5440            if (plugin && plugin.normalize) {
5441                name = plugin.normalize(name, makeNormalize(relName));
5442            } else {
5443                name = normalize(name, relName);
5444            }
5445        } else {
5446            name = normalize(name, relName);
5447            parts = splitPrefix(name);
5448            prefix = parts[0];
5449            name = parts[1];
5450            if (prefix) {
5451                plugin = callDep(prefix);
5452            }
5453        }
5454
5455        //Using ridiculous property names for space reasons
5456        return {
5457            f: prefix ? prefix + '!' + name : name, //fullName
5458            n: name,
5459            pr: prefix,
5460            p: plugin
5461        };
5462    };
5463
5464    function makeConfig(name) {
5465        return function () {
5466            return (config && config.config && config.config[name]) || {};
5467        };
5468    }
5469
5470    handlers = {
5471        require: function (name) {
5472            return makeRequire(name);
5473        },
5474        exports: function (name) {
5475            var e = defined[name];
5476            if (typeof e !== 'undefined') {
5477                return e;
5478            } else {
5479                return (defined[name] = {});
5480            }
5481        },
5482        module: function (name) {
5483            return {
5484                id: name,
5485                uri: '',
5486                exports: defined[name],
5487                config: makeConfig(name)
5488            };
5489        }
5490    };
5491
5492    main = function (name, deps, callback, relName) {
5493        var cjsModule, depName, ret, map, i,
5494            args = [],
5495            callbackType = typeof callback,
5496            usingExports;
5497
5498        //Use name if no relName
5499        relName = relName || name;
5500
5501        //Call the callback to define the module, if necessary.
5502        if (callbackType === 'undefined' || callbackType === 'function') {
5503            //Pull out the defined dependencies and pass the ordered
5504            //values to the callback.
5505            //Default to [require, exports, module] if no deps
5506            deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
5507            for (i = 0; i < deps.length; i += 1) {
5508                map = makeMap(deps[i], relName);
5509                depName = map.f;
5510
5511                //Fast path CommonJS standard dependencies.
5512                if (depName === "require") {
5513                    args[i] = handlers.require(name);
5514                } else if (depName === "exports") {
5515                    //CommonJS module spec 1.1
5516                    args[i] = handlers.exports(name);
5517                    usingExports = true;
5518                } else if (depName === "module") {
5519                    //CommonJS module spec 1.1
5520                    cjsModule = args[i] = handlers.module(name);
5521                } else if (hasProp(defined, depName) ||
5522                           hasProp(waiting, depName) ||
5523                           hasProp(defining, depName)) {
5524                    args[i] = callDep(depName);
5525                } else if (map.p) {
5526                    map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});
5527                    args[i] = defined[depName];
5528                } else {
5529                    throw new Error(name + ' missing ' + depName);
5530                }
5531            }
5532
5533            ret = callback ? callback.apply(defined[name], args) : undefined;
5534
5535            if (name) {
5536                //If setting exports via "module" is in play,
5537                //favor that over return value and exports. After that,
5538                //favor a non-undefined return value over exports use.
5539                if (cjsModule && cjsModule.exports !== undef &&
5540                        cjsModule.exports !== defined[name]) {
5541                    defined[name] = cjsModule.exports;
5542                } else if (ret !== undef || !usingExports) {
5543                    //Use the return value from the function.
5544                    defined[name] = ret;
5545                }
5546            }
5547        } else if (name) {
5548            //May just be an object definition for the module. Only
5549            //worry about defining if have a module name.
5550            defined[name] = callback;
5551        }
5552    };
5553
5554    requirejs = require = req = function (deps, callback, relName, forceSync, alt) {
5555        if (typeof deps === "string") {
5556            if (handlers[deps]) {
5557                //callback in this case is really relName
5558                return handlers[deps](callback);
5559            }
5560            //Just return the module wanted. In this scenario, the
5561            //deps arg is the module name, and second arg (if passed)
5562            //is just the relName.
5563            //Normalize module name, if it contains . or ..
5564            return callDep(makeMap(deps, callback
vendor: 9,807 bytes, lines 5564-5945
5564).f);
5565        } else if (!deps.splice) {
5566            //deps is a config object, not an array.
5567            config = deps;
5568            if (config.deps) {
5569                req(config.deps, config.callback);
5570            }
5571            if (!callback) {
5572                return;
5573            }
5574
5575            if (callback.splice) {
5576                //callback is an array, which means it is a dependency list.
5577                //Adjust args if there are dependencies
5578                deps = callback;
5579                callback = relName;
5580                relName = null;
5581            } else {
5582                deps = undef;
5583            }
5584        }
5585
5586        //Support require(['a'])
5587        callback = callback || function () {};
5588
5589        //If relName is a function, it is an errback handler,
5590        //so remove it.
5591        if (typeof relName === 'function') {
5592            relName = forceSync;
5593            forceSync = alt;
5594        }
5595
5596        //Simulate async callback;
5597        if (forceSync) {
5598            main(undef, deps, callback, relName);
5599        } else {
5600            //Using a non-zero value because of concern for what old browsers
5601            //do, and latest browsers "upgrade" to 4 if lower value is used:
5602            //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout:
5603            //If want a value immediately, use require('id') instead -- something
5604            //that works in almond on the global level, but not guaranteed and
5605            //unlikely to work in other AMD implementations.
5606            setTimeout(function () {
5607                main(undef, deps, callback, relName);
5608            }, 4);
5609        }
5610
5611        return req;
5612    };
5613
5614    /**
5615     * Just drops the config on the floor, but returns req in case
5616     * the config return value is used.
5617     */
5618    req.config = function (cfg) {
5619        return req(cfg);
5620    };
5621
5622    /**
5623     * Expose module registry for debugging and tooling
5624     */
5625    requirejs._defined = defined;
5626
5627    define = function (name, deps, callback) {
5628        if (typeof name !== 'string') {
5629            throw new Error('See almond README: incorrect module build, no module name');
5630        }
5631
5632        //This module may not have dependencies
5633        if (!deps.splice) {
5634            //deps is not an array, so probably means
5635            //an object literal or factory function for
5636            //the value. Adjust args.
5637            callback = deps;
5638            deps = [];
5639        }
5640
5641        if (!hasProp(defined, name) && !hasProp(waiting, name)) {
5642            waiting[name] = [name, deps, callback];
5643        }
5644    };
5645
5646    define.amd = {
5647        jQuery: true
5648    };
5649}());
5650
5651S2.requirejs = requirejs;S2.require = require;S2.define = define;
5652}
5653}());
5654S2.define("almond", function(){});
5655
5656/* global jQuery:false, $:false */
5657S2.define('jquery',[],function () {
5658  var _$ = jQuery || $;
5659
5660  if (_$ == null && console && console.error) {
5661    console.error(
5662      'Select2: An instance of jQuery or a jQuery-compatible library was not ' +
5663      'found. Make sure that you are including jQuery before Select2 on your ' +
5664      'web page.'
5665    );
5666  }
5667
5668  return _$;
5669});
5670
5671S2.define('select2/utils',[
5672  'jquery'
5673], function ($) {
5674  var Utils = {};
5675
5676  Utils.Extend = function (ChildClass, SuperClass) {
5677    var __hasProp = {}.hasOwnProperty;
5678
5679    function BaseConstructor () {
5680      this.constructor = ChildClass;
5681    }
5682
5683    for (var key in SuperClass) {
5684      if (__hasProp.call(SuperClass, key)) {
5685        ChildClass[key] = SuperClass[key];
5686      }
5687    }
5688
5689    BaseConstructor.prototype = SuperClass.prototype;
5690    ChildClass.prototype = new BaseConstructor();
5691    ChildClass.__super__ = SuperClass.prototype;
5692
5693    return ChildClass;
5694  };
5695
5696  function getMethods (theClass) {
5697    var proto = theClass.prototype;
5698
5699    var methods = [];
5700
5701    for (var methodName in proto) {
5702      var m = proto[methodName];
5703
5704      if (typeof m !== 'function') {
5705        continue;
5706      }
5707
5708      if (methodName === 'constructor') {
5709        continue;
5710      }
5711
5712      methods.push(methodName);
5713    }
5714
5715    return methods;
5716  }
5717
5718  Utils.Decorate = function (SuperClass, DecoratorClass) {
5719    var decoratedMethods = getMethods(DecoratorClass);
5720    var superMethods = getMethods(SuperClass);
5721
5722    function DecoratedClass () {
5723      var unshift = Array.prototype.unshift;
5724
5725      var argCount = DecoratorClass.prototype.constructor.length;
5726
5727      var calledConstructor = SuperClass.prototype.constructor;
5728
5729      if (argCount > 0) {
5730        unshift.call(arguments, SuperClass.prototype.constructor);
5731
5732        calledConstructor = DecoratorClass.prototype.constructor;
5733      }
5734
5735      calledConstructor.apply(this, arguments);
5736    }
5737
5738    DecoratorClass.displayName = SuperClass.displayName;
5739
5740    function ctr () {
5741      this.constructor = DecoratedClass;
5742    }
5743
5744    DecoratedClass.prototype = new ctr();
5745
5746    for (var m = 0; m < superMethods.length; m++) {
5747        var superMethod = superMethods[m];
5748
5749        DecoratedClass.prototype[superMethod] =
5750          SuperClass.prototype[superMethod];
5751    }
5752
5753    var calledMethod = function (methodName) {
5754      // Stub out the original method if it's not decorating an actual method
5755      var originalMethod = function () {};
5756
5757      if (methodName in DecoratedClass.prototype) {
5758        originalMethod = DecoratedClass.prototype[methodName];
5759      }
5760
5761      var decoratedMethod = DecoratorClass.prototype[methodName];
5762
5763      return function () {
5764        var unshift = Array.prototype.unshift;
5765
5766        unshift.call(arguments, originalMethod);
5767
5768        return decoratedMethod.apply(this, arguments);
5769      };
5770    };
5771
5772    for (var d = 0; d < decoratedMethods.length; d++) {
5773      var decoratedMethod = decoratedMethods[d];
5774
5775      DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod);
5776    }
5777
5778    return DecoratedClass;
5779  };
5780
5781  var Observable = function () {
5782    this.listeners = {};
5783  };
5784
5785  Observable.prototype.on = function (event, callback) {
5786    this.listeners = this.listeners || {};
5787
5788    if (event in this.listeners) {
5789      this.listeners[event].push(callback);
5790    } else {
5791      this.listeners[event] = [callback];
5792    }
5793  };
5794
5795  Observable.prototype.trigger = function (event) {
5796    var slice = Array.prototype.slice;
5797    var params = slice.call(arguments, 1);
5798
5799    this.listeners = this.listeners || {};
5800
5801    // Params should always come in as an array
5802    if (params == null) {
5803      params = [];
5804    }
5805
5806    // If there are no arguments to the event, use a temporary object
5807    if (params.length === 0) {
5808      params.push({});
5809    }
5810
5811    // Set the `_type` of the first object to the event
5812    params[0]._type = event;
5813
5814    if (event in this.listeners) {
5815      this.invoke(this.listeners[event], slice.call(arguments, 1));
5816    }
5817
5818    if ('*' in this.listeners) {
5819      this.invoke(this.listeners['*'], arguments);
5820    }
5821  };
5822
5823  Observable.prototype.invoke = function (listeners, params) {
5824    for (var i = 0, len = listeners.length; i < len; i++) {
5825      listeners[i].apply(this, params);
5826    }
5827  };
5828
5829  Utils.Observable = Observable;
5830
5831  Utils.generateChars = function (length) {
5832    var chars = '';
5833
5834    for (var i = 0; i < length; i++) {
5835      var randomChar = Math.floor(Math.random() * 36);
5836      chars += randomChar.toString(36);
5837    }
5838
5839    return chars;
5840  };
5841
5842  Utils.bind = function (func, context) {
5843    return function () {
5844      func.apply(context, arguments);
5845    };
5846  };
5847
5848  Utils._convertData = function (data) {
5849    for (var originalKey in data) {
5850      var keys = originalKey.split('-');
5851
5852      var dataLevel = data;
5853
5854      if (keys.length === 1) {
5855        continue;
5856      }
5857
5858      for (var k = 0; k < keys.length; k++) {
5859        var key = keys[k];
5860
5861        // Lowercase the first letter
5862        // By default, dash-separated becomes camelCase
5863        key = key.substring(0, 1).toLowerCase() + key.substring(1);
5864
5865        if (!(key in dataLevel)) {
5866          dataLevel[key] = {};
5867        }
5868
5869        if (k == keys.length - 1) {
5870          dataLevel[key] = data[originalKey];
5871        }
5872
5873        dataLevel = dataLevel[key];
5874      }
5875
5876      delete data[originalKey];
5877    }
5878
5879    return data;
5880  };
5881
5882  Utils.hasScroll = function (index, el) {
5883    // Adapted from the function created by @ShadowScripter
5884    // and adapted by @BillBarry on the Stack Exchange Code Review website.
5885    // The original code can be found at
5886    // http://codereview.stackexchange.com/q/13338
5887    // and was designed to be used with the Sizzle selector engine.
5888
5889    var $el = $(el);
5890    var overflowX = el.style.overflowX;
5891    var overflowY = el.style.overflowY;
5892
5893    //Check both x and y declarations
5894    if (overflowX === overflowY &&
5895        (overflowY === 'hidden' || overflowY === 'visible')) {
5896      return false;
5897    }
5898
5899    if (overflowX === 'scroll' || overflowY === 'scroll') {
5900      return true;
5901    }
5902
5903    return ($el.innerHeight() < el.scrollHeight ||
5904      $el.innerWidth() < el.scrollWidth);
5905  };
5906
5907  Utils.escapeMarkup = function (markup) {
5908    var replaceMap = {
5909      '\\': '&#92;',
5910      '&': '&amp;',
5911      '<': '&lt;',
5912      '>': '&gt;',
5913      '"': '&quot;',
5914      '\'': '&#39;',
5915      '/': '&#47;'
5916    };
5917
5918    // Do not try to escape the markup if it's not a string
5919    if (typeof markup !== 'string') {
5920      return markup;
5921    }
5922
5923    return String(markup).replace(/[&<>"'\/\\]/g, function (match) {
5924      return replaceMap[match];
5925    });
5926  };
5927
5928  // Append an array of jQuery nodes to a given element.
5929  Utils.appendMany = function ($element, $nodes) {
5930    // jQuery 1.7.x does not support $.fn.append() with an array
5931    // Fall back to a jQuery object collection using $.fn.add()
5932    if ($.fn.jquery.substr(0, 3) === '1.7') {
5933      var $jqNodes = $();
5934
5935      $.map($nodes, function (node) {
5936        $jqNodes = $jqNodes.add(node);
5937      });
5938
5939      $nodes = $jqNodes;
5940    }
5941
5942    $element.append($nodes);
5943  };
5944
5945  
vendor: 28,897 bytes, lines 5945-7103
5945return Utils;
5946});
5947
5948S2.define('select2/results',[
5949  'jquery',
5950  './utils'
5951], function ($, Utils) {
5952  function Results ($element, options, dataAdapter) {
5953    this.$element = $element;
5954    this.data = dataAdapter;
5955    this.options = options;
5956
5957    Results.__super__.constructor.call(this);
5958  }
5959
5960  Utils.Extend(Results, Utils.Observable);
5961
5962  Results.prototype.render = function () {
5963    var $results = $(
5964      '<ul class="select2-results__options" role="tree"></ul>'
5965    );
5966
5967    if (this.options.get('multiple')) {
5968      $results.attr('aria-multiselectable', 'true');
5969    }
5970
5971    this.$results = $results;
5972
5973    return $results;
5974  };
5975
5976  Results.prototype.clear = function () {
5977    this.$results.empty();
5978  };
5979
5980  Results.prototype.displayMessage = function (params) {
5981    var escapeMarkup = this.options.get('escapeMarkup');
5982
5983    this.clear();
5984    this.hideLoading();
5985
5986    var $message = $(
5987      '<li role="treeitem" aria-live="assertive"' +
5988      ' class="select2-results__option"></li>'
5989    );
5990
5991    var message = this.options.get('translations').get(params.message);
5992
5993    $message.append(
5994      escapeMarkup(
5995        message(params.args)
5996      )
5997    );
5998
5999    $message[0].className += ' select2-results__message';
6000
6001    this.$results.append($message);
6002  };
6003
6004  Results.prototype.hideMessages = function () {
6005    this.$results.find('.select2-results__message').remove();
6006  };
6007
6008  Results.prototype.append = function (data) {
6009    this.hideLoading();
6010
6011    var $options = [];
6012
6013    if (data.results == null || data.results.length === 0) {
6014      if (this.$results.children().length === 0) {
6015        this.trigger('results:message', {
6016          message: 'noResults'
6017        });
6018      }
6019
6020      return;
6021    }
6022
6023    data.results = this.sort(data.results);
6024
6025    for (var d = 0; d < data.results.length; d++) {
6026      var item = data.results[d];
6027
6028      var $option = this.option(item);
6029
6030      $options.push($option);
6031    }
6032
6033    this.$results.append($options);
6034  };
6035
6036  Results.prototype.position = function ($results, $dropdown) {
6037    var $resultsContainer = $dropdown.find('.select2-results');
6038    $resultsContainer.append($results);
6039  };
6040
6041  Results.prototype.sort = function (data) {
6042    var sorter = this.options.get('sorter');
6043
6044    return sorter(data);
6045  };
6046
6047  Results.prototype.highlightFirstItem = function () {
6048    var $options = this.$results
6049      .find('.select2-results__option[aria-selected]');
6050
6051    var $selected = $options.filter('[aria-selected=true]');
6052
6053    // Check if there are any selected options
6054    if ($selected.length > 0) {
6055      // If there are selected options, highlight the first
6056      $selected.first().trigger('mouseenter');
6057    } else {
6058      // If there are no selected options, highlight the first option
6059      // in the dropdown
6060      $options.first().trigger('mouseenter');
6061    }
6062
6063    this.ensureHighlightVisible();
6064  };
6065
6066  Results.prototype.setClasses = function () {
6067    var self = this;
6068
6069    this.data.current(function (selected) {
6070      var selectedIds = $.map(selected, function (s) {
6071        return s.id.toString();
6072      });
6073
6074      var $options = self.$results
6075        .find('.select2-results__option[aria-selected]');
6076
6077      $options.each(function () {
6078        var $option = $(this);
6079
6080        var item = $.data(this, 'data');
6081
6082        // id needs to be converted to a string when comparing
6083        var id = '' + item.id;
6084
6085        if ((item.element != null && item.element.selected) ||
6086            (item.element == null && $.inArray(id, selectedIds) > -1)) {
6087          $option.attr('aria-selected', 'true');
6088        } else {
6089          $option.attr('aria-selected', 'false');
6090        }
6091      });
6092
6093    });
6094  };
6095
6096  Results.prototype.showLoading = function (params) {
6097    this.hideLoading();
6098
6099    var loadingMore = this.options.get('translations').get('searching');
6100
6101    var loading = {
6102      disabled: true,
6103      loading: true,
6104      text: loadingMore(params)
6105    };
6106    var $loading = this.option(loading);
6107    $loading.className += ' loading-results';
6108
6109    this.$results.prepend($loading);
6110  };
6111
6112  Results.prototype.hideLoading = function () {
6113    this.$results.find('.loading-results').remove();
6114  };
6115
6116  Results.prototype.option = function (data) {
6117    var option = document.createElement('li');
6118    option.className = 'select2-results__option';
6119
6120    var attrs = {
6121      'role': 'treeitem',
6122      'aria-selected': 'false'
6123    };
6124
6125    if (data.disabled) {
6126      delete attrs['aria-selected'];
6127      attrs['aria-disabled'] = 'true';
6128    }
6129
6130    if (data.id == null) {
6131      delete attrs['aria-selected'];
6132    }
6133
6134    if (data._resultId != null) {
6135      option.id = data._resultId;
6136    }
6137
6138    if (data.title) {
6139      option.title = data.title;
6140    }
6141
6142    if (data.children) {
6143      attrs.role = 'group';
6144      attrs['aria-label'] = data.text;
6145      delete attrs['aria-selected'];
6146    }
6147
6148    for (var attr in attrs) {
6149      var val = attrs[attr];
6150
6151      option.setAttribute(attr, val);
6152    }
6153
6154    if (data.children) {
6155      var $option = $(option);
6156
6157      var label = document.createElement('strong');
6158      label.className = 'select2-results__group';
6159
6160      var $label = $(label);
6161      this.template(data, label);
6162
6163      var $children = [];
6164
6165      for (var c = 0; c < data.children.length; c++) {
6166        var child = data.children[c];
6167
6168        var $child = this.option(child);
6169
6170        $children.push($child);
6171      }
6172
6173      var $childrenContainer = $('<ul></ul>', {
6174        'class': 'select2-results__options select2-results__options--nested'
6175      });
6176
6177      $childrenContainer.append($children);
6178
6179      $option.append(label);
6180      $option.append($childrenContainer);
6181    } else {
6182      this.template(data, option);
6183    }
6184
6185    $.data(option, 'data', data);
6186
6187    return option;
6188  };
6189
6190  Results.prototype.bind = function (container, $container) {
6191    var self = this;
6192
6193    var id = container.id + '-results';
6194
6195    this.$results.attr('id', id);
6196
6197    container.on('results:all', function (params) {
6198      self.clear();
6199      self.append(params.data);
6200
6201      if (container.isOpen()) {
6202        self.setClasses();
6203        self.highlightFirstItem();
6204      }
6205    });
6206
6207    container.on('results:append', function (params) {
6208      self.append(params.data);
6209
6210      if (container.isOpen()) {
6211        self.setClasses();
6212      }
6213    });
6214
6215    container.on('query', function (params) {
6216      self.hideMessages();
6217      self.showLoading(params);
6218    });
6219
6220    container.on('select', function () {
6221      if (!container.isOpen()) {
6222        return;
6223      }
6224
6225      self.setClasses();
6226      self.highlightFirstItem();
6227    });
6228
6229    container.on('unselect', function () {
6230      if (!container.isOpen()) {
6231        return;
6232      }
6233
6234      self.setClasses();
6235      self.highlightFirstItem();
6236    });
6237
6238    container.on('open', function () {
6239      // When the dropdown is open, aria-expended="true"
6240      self.$results.attr('aria-expanded', 'true');
6241      self.$results.attr('aria-hidden', 'false');
6242
6243      self.setClasses();
6244      self.ensureHighlightVisible();
6245    });
6246
6247    container.on('close', function () {
6248      // When the dropdown is closed, aria-expended="false"
6249      self.$results.attr('aria-expanded', 'false');
6250      self.$results.attr('aria-hidden', 'true');
6251      self.$results.removeAttr('aria-activedescendant');
6252    });
6253
6254    container.on('results:toggle', function () {
6255      var $highlighted = self.getHighlightedResults();
6256
6257      if ($highlighted.length === 0) {
6258        return;
6259      }
6260
6261      $highlighted.trigger('mouseup');
6262    });
6263
6264    container.on('results:select', function () {
6265      var $highlighted = self.getHighlightedResults();
6266
6267      if ($highlighted.length === 0) {
6268        return;
6269      }
6270
6271      var data = $highlighted.data('data');
6272
6273      if ($highlighted.attr('aria-selected') == 'true') {
6274        self.trigger('close', {});
6275      } else {
6276        self.trigger('select', {
6277          data: data
6278        });
6279      }
6280    });
6281
6282    container.on('results:previous', function () {
6283      var $highlighted = self.getHighlightedResults();
6284
6285      var $options = self.$results.find('[aria-selected]');
6286
6287      var currentIndex = $options.index($highlighted);
6288
6289      // If we are already at te top, don't move further
6290      if (currentIndex === 0) {
6291        return;
6292      }
6293
6294      var nextIndex = currentIndex - 1;
6295
6296      // If none are highlighted, highlight the first
6297      if ($highlighted.length === 0) {
6298        nextIndex = 0;
6299      }
6300
6301      var $next = $options.eq(nextIndex);
6302
6303      $next.trigger('mouseenter');
6304
6305      var currentOffset = self.$results.offset().top;
6306      var nextTop = $next.offset().top;
6307      var nextOffset = self.$results.scrollTop() + (nextTop - currentOffset);
6308
6309      if (nextIndex === 0) {
6310        self.$results.scrollTop(0);
6311      } else if (nextTop - currentOffset < 0) {
6312        self.$results.scrollTop(nextOffset);
6313      }
6314    });
6315
6316    container.on('results:next', function () {
6317      var $highlighted = self.getHighlightedResults();
6318
6319      var $options = self.$results.find('[aria-selected]');
6320
6321      var currentIndex = $options.index($highlighted);
6322
6323      var nextIndex = currentIndex + 1;
6324
6325      // If we are at the last option, stay there
6326      if (nextIndex >= $options.length) {
6327        return;
6328      }
6329
6330      var $next = $options.eq(nextIndex);
6331
6332      $next.trigger('mouseenter');
6333
6334      var currentOffset = self.$results.offset().top +
6335        self.$results.outerHeight(false);
6336      var nextBottom = $next.offset().top + $next.outerHeight(false);
6337      var nextOffset = self.$results.scrollTop() + nextBottom - currentOffset;
6338
6339      if (nextIndex === 0) {
6340        self.$results.scrollTop(0);
6341      } else if (nextBottom > currentOffset) {
6342        self.$results.scrollTop(nextOffset);
6343      }
6344    });
6345
6346    container.on('results:focus', function (params) {
6347      params.element.addClass('select2-results__option--highlighted');
6348    });
6349
6350    container.on('results:message', function (params) {
6351      self.displayMessage(params);
6352    });
6353
6354    if ($.fn.mousewheel) {
6355      this.$results.on('mousewheel', function (e) {
6356        var top = self.$results.scrollTop();
6357
6358        var bottom = self.$results.get(0).scrollHeight - top + e.deltaY;
6359
6360        var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0;
6361        var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height();
6362
6363        if (isAtTop) {
6364          self.$results.scrollTop(0);
6365
6366          e.preventDefault();
6367          e.stopPropagation();
6368        } else if (isAtBottom) {
6369          self.$results.scrollTop(
6370            self.$results.get(0).scrollHeight - self.$results.height()
6371          );
6372
6373          e.preventDefault();
6374          e.stopPropagation();
6375        }
6376      });
6377    }
6378
6379    this.$results.on('mouseup', '.select2-results__option[aria-selected]',
6380      function (evt) {
6381      var $this = $(this);
6382
6383      var data = $this.data('data');
6384
6385      if ($this.attr('aria-selected') === 'true') {
6386        if (self.options.get('multiple')) {
6387          self.trigger('unselect', {
6388            originalEvent: evt,
6389            data: data
6390          });
6391        } else {
6392          self.trigger('close', {});
6393        }
6394
6395        return;
6396      }
6397
6398      self.trigger('select', {
6399        originalEvent: evt,
6400        data: data
6401      });
6402    });
6403
6404    this.$results.on('mouseenter', '.select2-results__option[aria-selected]',
6405      function (evt) {
6406      var data = $(this).data('data');
6407
6408      self.getHighlightedResults()
6409          .removeClass('select2-results__option--highlighted');
6410
6411      self.trigger('results:focus', {
6412        data: data,
6413        element: $(this)
6414      });
6415    });
6416  };
6417
6418  Results.prototype.getHighlightedResults = function () {
6419    var $highlighted = this.$results
6420    .find('.select2-results__option--highlighted');
6421
6422    return $highlighted;
6423  };
6424
6425  Results.prototype.destroy = function () {
6426    this.$results.remove();
6427  };
6428
6429  Results.prototype.ensureHighlightVisible = function () {
6430    var $highlighted = this.getHighlightedResults();
6431
6432    if ($highlighted.length === 0) {
6433      return;
6434    }
6435
6436    var $options = this.$results.find('[aria-selected]');
6437
6438    var currentIndex = $options.index($highlighted);
6439
6440    var currentOffset = this.$results.offset().top;
6441    var nextTop = $highlighted.offset().top;
6442    var nextOffset = this.$results.scrollTop() + (nextTop - currentOffset);
6443
6444    var offsetDelta = nextTop - currentOffset;
6445    nextOffset -= $highlighted.outerHeight(false) * 2;
6446
6447    if (currentIndex <= 2) {
6448      this.$results.scrollTop(0);
6449    } else if (offsetDelta > this.$results.outerHeight() || offsetDelta < 0) {
6450      this.$results.scrollTop(nextOffset);
6451    }
6452  };
6453
6454  Results.prototype.template = function (result, container) {
6455    var template = this.options.get('templateResult');
6456    var escapeMarkup = this.options.get('escapeMarkup');
6457
6458    var content = template(result, container);
6459
6460    if (content == null) {
6461      container.style.display = 'none';
6462    } else if (typeof content === 'string') {
6463      container.innerHTML = escapeMarkup(content);
6464    } else {
6465      $(container).append(content);
6466    }
6467  };
6468
6469  return Results;
6470});
6471
6472S2.define('select2/keys',[
6473
6474], function () {
6475  var KEYS = {
6476    BACKSPACE: 8,
6477    TAB: 9,
6478    ENTER: 13,
6479    SHIFT: 16,
6480    CTRL: 17,
6481    ALT: 18,
6482    ESC: 27,
6483    SPACE: 32,
6484    PAGE_UP: 33,
6485    PAGE_DOWN: 34,
6486    END: 35,
6487    HOME: 36,
6488    LEFT: 37,
6489    UP: 38,
6490    RIGHT: 39,
6491    DOWN: 40,
6492    DELETE: 46
6493  };
6494
6495  return KEYS;
6496});
6497
6498S2.define('select2/selection/base',[
6499  'jquery',
6500  '../utils',
6501  '../keys'
6502], function ($, Utils, KEYS) {
6503  function BaseSelection ($element, options) {
6504    this.$element = $element;
6505    this.options = options;
6506
6507    BaseSelection.__super__.constructor.call(this);
6508  }
6509
6510  Utils.Extend(BaseSelection, Utils.Observable);
6511
6512  BaseSelection.prototype.render = function () {
6513    var $selection = $(
6514      '<span class="select2-selection" role="combobox" ' +
6515      ' aria-haspopup="true" aria-expanded="false">' +
6516      '</span>'
6517    );
6518
6519    this._tabindex = 0;
6520
6521    if (this.$element.data('old-tabindex') != null) {
6522      this._tabindex = this.$element.data('old-tabindex');
6523    } else if (this.$element.attr('tabindex') != null) {
6524      this._tabindex = this.$element.attr('tabindex');
6525    }
6526
6527    $selection.attr('title', this.$element.attr('title'));
6528    $selection.attr('tabindex', this._tabindex);
6529
6530    this.$selection = $selection;
6531
6532    return $selection;
6533  };
6534
6535  BaseSelection.prototype.bind = function (container, $container) {
6536    var self = this;
6537
6538    var id = container.id + '-container';
6539    var resultsId = container.id + '-results';
6540
6541    this.container = container;
6542
6543    this.$selection.on('focus', function (evt) {
6544      self.trigger('focus', evt);
6545    });
6546
6547    this.$selection.on('blur', function (evt) {
6548      self._handleBlur(evt);
6549    });
6550
6551    this.$selection.on('keydown', function (evt) {
6552      self.trigger('keypress', evt);
6553
6554      if (evt.which === KEYS.SPACE) {
6555        evt.preventDefault();
6556      }
6557    });
6558
6559    container.on('results:focus', function (params) {
6560      self.$selection.attr('aria-activedescendant', params.data._resultId);
6561    });
6562
6563    container.on('selection:update', function (params) {
6564      self.update(params.data);
6565    });
6566
6567    container.on('open', function () {
6568      // When the dropdown is open, aria-expanded="true"
6569      self.$selection.attr('aria-expanded', 'true');
6570      self.$selection.attr('aria-owns', resultsId);
6571
6572      self._attachCloseHandler(container);
6573    });
6574
6575    container.on('close', function () {
6576      // When the dropdown is closed, aria-expanded="false"
6577      self.$selection.attr('aria-expanded', 'false');
6578      self.$selection.removeAttr('aria-activedescendant');
6579      self.$selection.removeAttr('aria-owns');
6580
6581      self.$selection.focus();
6582
6583      self._detachCloseHandler(container);
6584    });
6585
6586    container.on('enable', function () {
6587      self.$selection.attr('tabindex', self._tabindex);
6588    });
6589
6590    container.on('disable', function () {
6591      self.$selection.attr('tabindex', '-1');
6592    });
6593  };
6594
6595  BaseSelection.prototype._handleBlur = function (evt) {
6596    var self = this;
6597
6598    // This needs to be delayed as the active element is the body when the tab
6599    // key is pressed, possibly along with others.
6600    window.setTimeout(function () {
6601      // Don't trigger `blur` if the focus is still in the selection
6602      if (
6603        (document.activeElement == self.$selection[0]) ||
6604        ($.contains(self.$selection[0], document.activeElement))
6605      ) {
6606        return;
6607      }
6608
6609      self.trigger('blur', evt);
6610    }, 1);
6611  };
6612
6613  BaseSelection.prototype._attachCloseHandler = function (container) {
6614    var self = this;
6615
6616    $(document.body).on('mousedown.select2.' + container.id, function (e) {
6617      var $target = $(e.target);
6618
6619      var $select = $target.closest('.select2');
6620
6621      var $all = $('.select2.select2-container--open');
6622
6623      $all.each(function () {
6624        var $this = $(this);
6625
6626        if (this == $select[0]) {
6627          return;
6628        }
6629
6630        var $element = $this.data('element');
6631
6632        $element.select2('close');
6633      });
6634    });
6635  };
6636
6637  BaseSelection.prototype._detachCloseHandler = function (container) {
6638    $(document.body).off('mousedown.select2.' + container.id);
6639  };
6640
6641  BaseSelection.prototype.position = function ($selection, $container) {
6642    var $selectionContainer = $container.find('.selection');
6643    $selectionContainer.append($selection);
6644  };
6645
6646  BaseSelection.prototype.destroy = function () {
6647    this._detachCloseHandler(this.container);
6648  };
6649
6650  BaseSelection.prototype.update = function (data) {
6651    throw new Error('The `update` method must be defined in child classes.');
6652  };
6653
6654  return BaseSelection;
6655});
6656
6657S2.define('select2/selection/single',[
6658  'jquery',
6659  './base',
6660  '../utils',
6661  '../keys'
6662], function ($, BaseSelection, Utils, KEYS) {
6663  function SingleSelection () {
6664    SingleSelection.__super__.constructor.apply(this, arguments);
6665  }
6666
6667  Utils.Extend(SingleSelection, BaseSelection);
6668
6669  SingleSelection.prototype.render = function () {
6670    var $selection = SingleSelection.__super__.render.call(this);
6671
6672    $selection.addClass('select2-selection--single');
6673
6674    $selection.html(
6675      '<span class="select2-selection__rendered"></span>' +
6676      '<span class="select2-selection__arrow" role="presentation">' +
6677        '<b role="presentation"></b>' +
6678      '</span>'
6679    );
6680
6681    return $selection;
6682  };
6683
6684  SingleSelection.prototype.bind = function (container, $container) {
6685    var self = this;
6686
6687    SingleSelection.__super__.bind.apply(this, arguments);
6688
6689    var id = container.id + '-container';
6690
6691    this.$selection.find('.select2-selection__rendered').attr('id', id);
6692    this.$selection.attr('aria-labelledby', id);
6693
6694    this.$selection.on('mousedown', function (evt) {
6695      // Only respond to left clicks
6696      if (evt.which !== 1) {
6697        return;
6698      }
6699
6700      self.trigger('toggle', {
6701        originalEvent: evt
6702      });
6703    });
6704
6705    this.$selection.on('focus', function (evt) {
6706      // User focuses on the container
6707    });
6708
6709    this.$selection.on('blur', function (evt) {
6710      // User exits the container
6711    });
6712
6713    container.on('focus', function (evt) {
6714      if (!container.isOpen()) {
6715        self.$selection.focus();
6716      }
6717    });
6718
6719    container.on('selection:update', function (params) {
6720      self.update(params.data);
6721    });
6722  };
6723
6724  SingleSelection.prototype.clear = function () {
6725    this.$selection.find('.select2-selection__rendered').empty();
6726  };
6727
6728  SingleSelection.prototype.display = function (data, container) {
6729    var template = this.options.get('templateSelection');
6730    var escapeMarkup = this.options.get('escapeMarkup');
6731
6732    return escapeMarkup(template(data, container));
6733  };
6734
6735  SingleSelection.prototype.selectionContainer = function () {
6736    return $('<span></span>');
6737  };
6738
6739  SingleSelection.prototype.update = function (data) {
6740    if (data.length === 0) {
6741      this.clear();
6742      return;
6743    }
6744
6745    var selection = data[0];
6746
6747    var $rendered = this.$selection.find('.select2-selection__rendered');
6748    var formatted = this.display(selection, $rendered);
6749
6750    $rendered.empty().append(formatted);
6751    $rendered.prop('title', selection.title || selection.text);
6752  };
6753
6754  return SingleSelection;
6755});
6756
6757S2.define('select2/selection/multiple',[
6758  'jquery',
6759  './base',
6760  '../utils'
6761], function ($, BaseSelection, Utils) {
6762  function MultipleSelection ($element, options) {
6763    MultipleSelection.__super__.constructor.apply(this, arguments);
6764  }
6765
6766  Utils.Extend(MultipleSelection, BaseSelection);
6767
6768  MultipleSelection.prototype.render = function () {
6769    var $selection = MultipleSelection.__super__.render.call(this);
6770
6771    $selection.addClass('select2-selection--multiple');
6772
6773    $selection.html(
6774      '<ul class="select2-selection__rendered"></ul>'
6775    );
6776
6777    return $selection;
6778  };
6779
6780  MultipleSelection.prototype.bind = function (container, $container) {
6781    var self = this;
6782
6783    MultipleSelection.__super__.bind.apply(this, arguments);
6784
6785    this.$selection.on('click', function (evt) {
6786      self.trigger('toggle', {
6787        originalEvent: evt
6788      });
6789    });
6790
6791    this.$selection.on(
6792      'click',
6793      '.select2-selection__choice__remove',
6794      function (evt) {
6795        // Ignore the event if it is disabled
6796        if (self.options.get('disabled')) {
6797          return;
6798        }
6799
6800        var $remove = $(this);
6801        var $selection = $remove.parent();
6802
6803        var data = $selection.data('data');
6804
6805        self.trigger('unselect', {
6806          originalEvent: evt,
6807          data: data
6808        });
6809      }
6810    );
6811  };
6812
6813  MultipleSelection.prototype.clear = function () {
6814    this.$selection.find('.select2-selection__rendered').empty();
6815  };
6816
6817  MultipleSelection.prototype.display = function (data, container) {
6818    var template = this.options.get('templateSelection');
6819    var escapeMarkup = this.options.get('escapeMarkup');
6820
6821    return escapeMarkup(template(data, container));
6822  };
6823
6824  MultipleSelection.prototype.selectionContainer = function () {
6825    var $container = $(
6826      '<li class="select2-selection__choice">' +
6827        '<span class="select2-selection__choice__remove" role="presentation">' +
6828          '&times;' +
6829        '</span>' +
6830      '</li>'
6831    );
6832
6833    return $container;
6834  };
6835
6836  MultipleSelection.prototype.update = function (data) {
6837    this.clear();
6838
6839    if (data.length === 0) {
6840      return;
6841    }
6842
6843    var $selections = [];
6844
6845    for (var d = 0; d < data.length; d++) {
6846      var selection = data[d];
6847
6848      var $selection = this.selectionContainer();
6849      var formatted = this.display(selection, $selection);
6850
6851      $selection.append(formatted);
6852      $selection.prop('title', selection.title || selection.text);
6853
6854      $selection.data('data', selection);
6855
6856      $selections.push($selection);
6857    }
6858
6859    var $rendered = this.$selection.find('.select2-selection__rendered');
6860
6861    Utils.appendMany($rendered, $selections);
6862  };
6863
6864  return MultipleSelection;
6865});
6866
6867S2.define('select2/selection/placeholder',[
6868  '../utils'
6869], function (Utils) {
6870  function Placeholder (decorated, $element, options) {
6871    this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
6872
6873    decorated.call(this, $element, options);
6874  }
6875
6876  Placeholder.prototype.normalizePlaceholder = function (_, placeholder) {
6877    if (typeof placeholder === 'string') {
6878      placeholder = {
6879        id: '',
6880        text: placeholder
6881      };
6882    }
6883
6884    return placeholder;
6885  };
6886
6887  Placeholder.prototype.createPlaceholder = function (decorated, placeholder) {
6888    var $placeholder = this.selectionContainer();
6889
6890    $placeholder.html(this.display(placeholder));
6891    $placeholder.addClass('select2-selection__placeholder')
6892                .removeClass('select2-selection__choice');
6893
6894    return $placeholder;
6895  };
6896
6897  Placeholder.prototype.update = function (decorated, data) {
6898    var singlePlaceholder = (
6899      data.length == 1 && data[0].id != this.placeholder.id
6900    );
6901    var multipleSelections = data.length > 1;
6902
6903    if (multipleSelections || singlePlaceholder) {
6904      return decorated.call(this, data);
6905    }
6906
6907    this.clear();
6908
6909    var $placeholder = this.createPlaceholder(this.placeholder);
6910
6911    this.$selection.find('.select2-selection__rendered').append($placeholder);
6912  };
6913
6914  return Placeholder;
6915});
6916
6917S2.define('select2/selection/allowClear',[
6918  'jquery',
6919  '../keys'
6920], function ($, KEYS) {
6921  function AllowClear () { }
6922
6923  AllowClear.prototype.bind = function (decorated, container, $container) {
6924    var self = this;
6925
6926    decorated.call(this, container, $container);
6927
6928    if (this.placeholder == null) {
6929      if (this.options.get('debug') && window.console && console.error) {
6930        console.error(
6931          'Select2: The `allowClear` option should be used in combination ' +
6932          'with the `placeholder` option.'
6933        );
6934      }
6935    }
6936
6937    this.$selection.on('mousedown', '.select2-selection__clear',
6938      function (evt) {
6939        self._handleClear(evt);
6940    });
6941
6942    container.on('keypress', function (evt) {
6943      self._handleKeyboardClear(evt, container);
6944    });
6945  };
6946
6947  AllowClear.prototype._handleClear = function (_, evt) {
6948    // Ignore the event if it is disabled
6949    if (this.options.get('disabled')) {
6950      return;
6951    }
6952
6953    var $clear = this.$selection.find('.select2-selection__clear');
6954
6955    // Ignore the event if nothing has been selected
6956    if ($clear.length === 0) {
6957      return;
6958    }
6959
6960    evt.stopPropagation();
6961
6962    var data = $clear.data('data');
6963
6964    for (var d = 0; d < data.length; d++) {
6965      var unselectData = {
6966        data: data[d]
6967      };
6968
6969      // Trigger the `unselect` event, so people can prevent it from being
6970      // cleared.
6971      this.trigger('unselect', unselectData);
6972
6973      // If the event was prevented, don't clear it out.
6974      if (unselectData.prevented) {
6975        return;
6976      }
6977    }
6978
6979    this.$element.val(this.placeholder.id).trigger('change');
6980
6981    this.trigger('toggle', {});
6982  };
6983
6984  AllowClear.prototype._handleKeyboardClear = function (_, evt, container) {
6985    if (container.isOpen()) {
6986      return;
6987    }
6988
6989    if (evt.which == KEYS.DELETE || evt.which == KEYS.BACKSPACE) {
6990      this._handleClear(evt);
6991    }
6992  };
6993
6994  AllowClear.prototype.update = function (decorated, data) {
6995    decorated.call(this, data);
6996
6997    if (this.$selection.find('.select2-selection__placeholder').length > 0 ||
6998        data.length === 0) {
6999      return;
7000    }
7001
7002    var $remove = $(
7003      '<span class="select2-selection__clear">' +
7004        '&times;' +
7005      '</span>'
7006    );
7007    $remove.data('data', data);
7008
7009    this.$selection.find('.select2-selection__rendered').prepend($remove);
7010  };
7011
7012  return AllowClear;
7013});
7014
7015S2.define('select2/selection/search',[
7016  'jquery',
7017  '../utils',
7018  '../keys'
7019], function ($, Utils, KEYS) {
7020  function Search (decorated, $element, options) {
7021    decorated.call(this, $element, options);
7022  }
7023
7024  Search.prototype.render = function (decorated) {
7025    var $search = $(
7026      '<li class="select2-search select2-search--inline">' +
7027        '<input class="select2-search__field" type="search" tabindex="-1"' +
7028        ' autocomplete="off" autocorrect="off" autocapitalize="off"' +
7029        ' spellcheck="false" role="textbox" aria-autocomplete="list" />' +
7030      '</li>'
7031    );
7032
7033    this.$searchContainer = $search;
7034    this.$search = $search.find('input');
7035
7036    var $rendered = decorated.call(this);
7037
7038    this._transferTabIndex();
7039
7040    return $rendered;
7041  };
7042
7043  Search.prototype.bind = function (decorated, container, $container) {
7044    var self = this;
7045
7046    decorated.call(this, container, $container);
7047
7048    container.on('open', function () {
7049      self.$search.trigger('focus');
7050    });
7051
7052    container.on('close', function () {
7053      self.$search.val('');
7054      self.$search.removeAttr('aria-activedescendant');
7055      self.$search.trigger('focus');
7056    });
7057
7058    container.on('enable', function () {
7059      self.$search.prop('disabled', false);
7060
7061      self._transferTabIndex();
7062    });
7063
7064    container.on('disable', function () {
7065      self.$search.prop('disabled', true);
7066    });
7067
7068    container.on('focus', function (evt) {
7069      self.$search.trigger('focus');
7070    });
7071
7072    container.on('results:focus', function (params) {
7073      self.$search.attr('aria-activedescendant', params.id);
7074    });
7075
7076    this.$selection.on('focusin', '.select2-search--inline', function (evt) {
7077      self.trigger('focus', evt);
7078    });
7079
7080    this.$selection.on('focusout', '.select2-search--inline', function (evt) {
7081      self._handleBlur(evt);
7082    });
7083
7084    this.$selection.on('keydown', '.select2-search--inline', function (evt) {
7085      evt.stopPropagation();
7086
7087      self.trigger('keypress', evt);
7088
7089      self._keyUpPrevented = evt.isDefaultPrevented();
7090
7091      var key = evt.which;
7092
7093      if (key === KEYS.BACKSPACE && self.$search.val() === '') {
7094        var $previousChoice = self.$searchContainer
7095          .prev('.select2-selection__choice');
7096
7097        if ($previousChoice.length > 0) {
7098          var item = $previousChoice.data('data');
7099
7100          self.searchRemoveChoice(item);
7101
7102          evt.preventDefault();
7103        }
vendor: 22,668 bytes, lines 7103-8195
7103
7104      }
7105    });
7106
7107    // Try to detect the IE version should the `documentMode` property that
7108    // is stored on the document. This is only implemented in IE and is
7109    // slightly cleaner than doing a user agent check.
7110    // This property is not available in Edge, but Edge also doesn't have
7111    // this bug.
7112    var msie = document.documentMode;
7113    var disableInputEvents = msie && msie <= 11;
7114
7115    // Workaround for browsers which do not support the `input` event
7116    // This will prevent double-triggering of events for browsers which support
7117    // both the `keyup` and `input` events.
7118    this.$selection.on(
7119      'input.searchcheck',
7120      '.select2-search--inline',
7121      function (evt) {
7122        // IE will trigger the `input` event when a placeholder is used on a
7123        // search box. To get around this issue, we are forced to ignore all
7124        // `input` events in IE and keep using `keyup`.
7125        if (disableInputEvents) {
7126          self.$selection.off('input.search input.searchcheck');
7127          return;
7128        }
7129
7130        // Unbind the duplicated `keyup` event
7131        self.$selection.off('keyup.search');
7132      }
7133    );
7134
7135    this.$selection.on(
7136      'keyup.search input.search',
7137      '.select2-search--inline',
7138      function (evt) {
7139        // IE will trigger the `input` event when a placeholder is used on a
7140        // search box. To get around this issue, we are forced to ignore all
7141        // `input` events in IE and keep using `keyup`.
7142        if (disableInputEvents && evt.type === 'input') {
7143          self.$selection.off('input.search input.searchcheck');
7144          return;
7145        }
7146
7147        var key = evt.which;
7148
7149        // We can freely ignore events from modifier keys
7150        if (key == KEYS.SHIFT || key == KEYS.CTRL || key == KEYS.ALT) {
7151          return;
7152        }
7153
7154        // Tabbing will be handled during the `keydown` phase
7155        if (key == KEYS.TAB) {
7156          return;
7157        }
7158
7159        self.handleSearch(evt);
7160      }
7161    );
7162  };
7163
7164  /**
7165   * This method will transfer the tabindex attribute from the rendered
7166   * selection to the search box. This allows for the search box to be used as
7167   * the primary focus instead of the selection container.
7168   *
7169   * @private
7170   */
7171  Search.prototype._transferTabIndex = function (decorated) {
7172    this.$search.attr('tabindex', this.$selection.attr('tabindex'));
7173    this.$selection.attr('tabindex', '-1');
7174  };
7175
7176  Search.prototype.createPlaceholder = function (decorated, placeholder) {
7177    this.$search.attr('placeholder', placeholder.text);
7178  };
7179
7180  Search.prototype.update = function (decorated, data) {
7181    var searchHadFocus = this.$search[0] == document.activeElement;
7182
7183    this.$search.attr('placeholder', '');
7184
7185    decorated.call(this, data);
7186
7187    this.$selection.find('.select2-selection__rendered')
7188                   .append(this.$searchContainer);
7189
7190    this.resizeSearch();
7191    if (searchHadFocus) {
7192      this.$search.focus();
7193    }
7194  };
7195
7196  Search.prototype.handleSearch = function () {
7197    this.resizeSearch();
7198
7199    if (!this._keyUpPrevented) {
7200      var input = this.$search.val();
7201
7202      this.trigger('query', {
7203        term: input
7204      });
7205    }
7206
7207    this._keyUpPrevented = false;
7208  };
7209
7210  Search.prototype.searchRemoveChoice = function (decorated, item) {
7211    this.trigger('unselect', {
7212      data: item
7213    });
7214
7215    this.$search.val(item.text);
7216    this.handleSearch();
7217  };
7218
7219  Search.prototype.resizeSearch = function () {
7220    this.$search.css('width', '25px');
7221
7222    var width = '';
7223
7224    if (this.$search.attr('placeholder') !== '') {
7225      width = this.$selection.find('.select2-selection__rendered').innerWidth();
7226    } else {
7227      var minimumWidth = this.$search.val().length + 1;
7228
7229      width = (minimumWidth * 0.75) + 'em';
7230    }
7231
7232    this.$search.css('width', width);
7233  };
7234
7235  return Search;
7236});
7237
7238S2.define('select2/selection/eventRelay',[
7239  'jquery'
7240], function ($) {
7241  function EventRelay () { }
7242
7243  EventRelay.prototype.bind = function (decorated, container, $container) {
7244    var self = this;
7245    var relayEvents = [
7246      'open', 'opening',
7247      'close', 'closing',
7248      'select', 'selecting',
7249      'unselect', 'unselecting'
7250    ];
7251
7252    var preventableEvents = ['opening', 'closing', 'selecting', 'unselecting'];
7253
7254    decorated.call(this, container, $container);
7255
7256    container.on('*', function (name, params) {
7257      // Ignore events that should not be relayed
7258      if ($.inArray(name, relayEvents) === -1) {
7259        return;
7260      }
7261
7262      // The parameters should always be an object
7263      params = params || {};
7264
7265      // Generate the jQuery event for the Select2 event
7266      var evt = $.Event('select2:' + name, {
7267        params: params
7268      });
7269
7270      self.$element.trigger(evt);
7271
7272      // Only handle preventable events if it was one
7273      if ($.inArray(name, preventableEvents) === -1) {
7274        return;
7275      }
7276
7277      params.prevented = evt.isDefaultPrevented();
7278    });
7279  };
7280
7281  return EventRelay;
7282});
7283
7284S2.define('select2/translation',[
7285  'jquery',
7286  'require'
7287], function ($, require) {
7288  function Translation (dict) {
7289    this.dict = dict || {};
7290  }
7291
7292  Translation.prototype.all = function () {
7293    return this.dict;
7294  };
7295
7296  Translation.prototype.get = function (key) {
7297    return this.dict[key];
7298  };
7299
7300  Translation.prototype.extend = function (translation) {
7301    this.dict = $.extend({}, translation.all(), this.dict);
7302  };
7303
7304  // Static functions
7305
7306  Translation._cache = {};
7307
7308  Translation.loadPath = function (path) {
7309    if (!(path in Translation._cache)) {
7310      var translations = require(path);
7311
7312      Translation._cache[path] = translations;
7313    }
7314
7315    return new Translation(Translation._cache[path]);
7316  };
7317
7318  return Translation;
7319});
7320
7321S2.define('select2/diacritics',[
7322
7323], function () {
7324  var diacritics = {
7325    '\u24B6': 'A',
7326    '\uFF21': 'A',
7327    '\u00C0': 'A',
7328    '\u00C1': 'A',
7329    '\u00C2': 'A',
7330    '\u1EA6': 'A',
7331    '\u1EA4': 'A',
7332    '\u1EAA': 'A',
7333    '\u1EA8': 'A',
7334    '\u00C3': 'A',
7335    '\u0100': 'A',
7336    '\u0102': 'A',
7337    '\u1EB0': 'A',
7338    '\u1EAE': 'A',
7339    '\u1EB4': 'A',
7340    '\u1EB2': 'A',
7341    '\u0226': 'A',
7342    '\u01E0': 'A',
7343    '\u00C4': 'A',
7344    '\u01DE': 'A',
7345    '\u1EA2': 'A',
7346    '\u00C5': 'A',
7347    '\u01FA': 'A',
7348    '\u01CD': 'A',
7349    '\u0200': 'A',
7350    '\u0202': 'A',
7351    '\u1EA0': 'A',
7352    '\u1EAC': 'A',
7353    '\u1EB6': 'A',
7354    '\u1E00': 'A',
7355    '\u0104': 'A',
7356    '\u023A': 'A',
7357    '\u2C6F': 'A',
7358    '\uA732': 'AA',
7359    '\u00C6': 'AE',
7360    '\u01FC': 'AE',
7361    '\u01E2': 'AE',
7362    '\uA734': 'AO',
7363    '\uA736': 'AU',
7364    '\uA738': 'AV',
7365    '\uA73A': 'AV',
7366    '\uA73C': 'AY',
7367    '\u24B7': 'B',
7368    '\uFF22': 'B',
7369    '\u1E02': 'B',
7370    '\u1E04': 'B',
7371    '\u1E06': 'B',
7372    '\u0243': 'B',
7373    '\u0182': 'B',
7374    '\u0181': 'B',
7375    '\u24B8': 'C',
7376    '\uFF23': 'C',
7377    '\u0106': 'C',
7378    '\u0108': 'C',
7379    '\u010A': 'C',
7380    '\u010C': 'C',
7381    '\u00C7': 'C',
7382    '\u1E08': 'C',
7383    '\u0187': 'C',
7384    '\u023B': 'C',
7385    '\uA73E': 'C',
7386    '\u24B9': 'D',
7387    '\uFF24': 'D',
7388    '\u1E0A': 'D',
7389    '\u010E': 'D',
7390    '\u1E0C': 'D',
7391    '\u1E10': 'D',
7392    '\u1E12': 'D',
7393    '\u1E0E': 'D',
7394    '\u0110': 'D',
7395    '\u018B': 'D',
7396    '\u018A': 'D',
7397    '\u0189': 'D',
7398    '\uA779': 'D',
7399    '\u01F1': 'DZ',
7400    '\u01C4': 'DZ',
7401    '\u01F2': 'Dz',
7402    '\u01C5': 'Dz',
7403    '\u24BA': 'E',
7404    '\uFF25': 'E',
7405    '\u00C8': 'E',
7406    '\u00C9': 'E',
7407    '\u00CA': 'E',
7408    '\u1EC0': 'E',
7409    '\u1EBE': 'E',
7410    '\u1EC4': 'E',
7411    '\u1EC2': 'E',
7412    '\u1EBC': 'E',
7413    '\u0112': 'E',
7414    '\u1E14': 'E',
7415    '\u1E16': 'E',
7416    '\u0114': 'E',
7417    '\u0116': 'E',
7418    '\u00CB': 'E',
7419    '\u1EBA': 'E',
7420    '\u011A': 'E',
7421    '\u0204': 'E',
7422    '\u0206': 'E',
7423    '\u1EB8': 'E',
7424    '\u1EC6': 'E',
7425    '\u0228': 'E',
7426    '\u1E1C': 'E',
7427    '\u0118': 'E',
7428    '\u1E18': 'E',
7429    '\u1E1A': 'E',
7430    '\u0190': 'E',
7431    '\u018E': 'E',
7432    '\u24BB': 'F',
7433    '\uFF26': 'F',
7434    '\u1E1E': 'F',
7435    '\u0191': 'F',
7436    '\uA77B': 'F',
7437    '\u24BC': 'G',
7438    '\uFF27': 'G',
7439    '\u01F4': 'G',
7440    '\u011C': 'G',
7441    '\u1E20': 'G',
7442    '\u011E': 'G',
7443    '\u0120': 'G',
7444    '\u01E6': 'G',
7445    '\u0122': 'G',
7446    '\u01E4': 'G',
7447    '\u0193': 'G',
7448    '\uA7A0': 'G',
7449    '\uA77D': 'G',
7450    '\uA77E': 'G',
7451    '\u24BD': 'H',
7452    '\uFF28': 'H',
7453    '\u0124': 'H',
7454    '\u1E22': 'H',
7455    '\u1E26': 'H',
7456    '\u021E': 'H',
7457    '\u1E24': 'H',
7458    '\u1E28': 'H',
7459    '\u1E2A': 'H',
7460    '\u0126': 'H',
7461    '\u2C67': 'H',
7462    '\u2C75': 'H',
7463    '\uA78D': 'H',
7464    '\u24BE': 'I',
7465    '\uFF29': 'I',
7466    '\u00CC': 'I',
7467    '\u00CD': 'I',
7468    '\u00CE': 'I',
7469    '\u0128': 'I',
7470    '\u012A': 'I',
7471    '\u012C': 'I',
7472    '\u0130': 'I',
7473    '\u00CF': 'I',
7474    '\u1E2E': 'I',
7475    '\u1EC8': 'I',
7476    '\u01CF': 'I',
7477    '\u0208': 'I',
7478    '\u020A': 'I',
7479    '\u1ECA': 'I',
7480    '\u012E': 'I',
7481    '\u1E2C': 'I',
7482    '\u0197': 'I',
7483    '\u24BF': 'J',
7484    '\uFF2A': 'J',
7485    '\u0134': 'J',
7486    '\u0248': 'J',
7487    '\u24C0': 'K',
7488    '\uFF2B': 'K',
7489    '\u1E30': 'K',
7490    '\u01E8': 'K',
7491    '\u1E32': 'K',
7492    '\u0136': 'K',
7493    '\u1E34': 'K',
7494    '\u0198': 'K',
7495    '\u2C69': 'K',
7496    '\uA740': 'K',
7497    '\uA742': 'K',
7498    '\uA744': 'K',
7499    '\uA7A2': 'K',
7500    '\u24C1': 'L',
7501    '\uFF2C': 'L',
7502    '\u013F': 'L',
7503    '\u0139': 'L',
7504    '\u013D': 'L',
7505    '\u1E36': 'L',
7506    '\u1E38': 'L',
7507    '\u013B': 'L',
7508    '\u1E3C': 'L',
7509    '\u1E3A': 'L',
7510    '\u0141': 'L',
7511    '\u023D': 'L',
7512    '\u2C62': 'L',
7513    '\u2C60': 'L',
7514    '\uA748': 'L',
7515    '\uA746': 'L',
7516    '\uA780': 'L',
7517    '\u01C7': 'LJ',
7518    '\u01C8': 'Lj',
7519    '\u24C2': 'M',
7520    '\uFF2D': 'M',
7521    '\u1E3E': 'M',
7522    '\u1E40': 'M',
7523    '\u1E42': 'M',
7524    '\u2C6E': 'M',
7525    '\u019C': 'M',
7526    '\u24C3': 'N',
7527    '\uFF2E': 'N',
7528    '\u01F8': 'N',
7529    '\u0143': 'N',
7530    '\u00D1': 'N',
7531    '\u1E44': 'N',
7532    '\u0147': 'N',
7533    '\u1E46': 'N',
7534    '\u0145': 'N',
7535    '\u1E4A': 'N',
7536    '\u1E48': 'N',
7537    '\u0220': 'N',
7538    '\u019D': 'N',
7539    '\uA790': 'N',
7540    '\uA7A4': 'N',
7541    '\u01CA': 'NJ',
7542    '\u01CB': 'Nj',
7543    '\u24C4': 'O',
7544    '\uFF2F': 'O',
7545    '\u00D2': 'O',
7546    '\u00D3': 'O',
7547    '\u00D4': 'O',
7548    '\u1ED2': 'O',
7549    '\u1ED0': 'O',
7550    '\u1ED6': 'O',
7551    '\u1ED4': 'O',
7552    '\u00D5': 'O',
7553    '\u1E4C': 'O',
7554    '\u022C': 'O',
7555    '\u1E4E': 'O',
7556    '\u014C': 'O',
7557    '\u1E50': 'O',
7558    '\u1E52': 'O',
7559    '\u014E': 'O',
7560    '\u022E': 'O',
7561    '\u0230': 'O',
7562    '\u00D6': 'O',
7563    '\u022A': 'O',
7564    '\u1ECE': 'O',
7565    '\u0150': 'O',
7566    '\u01D1': 'O',
7567    '\u020C': 'O',
7568    '\u020E': 'O',
7569    '\u01A0': 'O',
7570    '\u1EDC': 'O',
7571    '\u1EDA': 'O',
7572    '\u1EE0': 'O',
7573    '\u1EDE': 'O',
7574    '\u1EE2': 'O',
7575    '\u1ECC': 'O',
7576    '\u1ED8': 'O',
7577    '\u01EA': 'O',
7578    '\u01EC': 'O',
7579    '\u00D8': 'O',
7580    '\u01FE': 'O',
7581    '\u0186': 'O',
7582    '\u019F': 'O',
7583    '\uA74A': 'O',
7584    '\uA74C': 'O',
7585    '\u01A2': 'OI',
7586    '\uA74E': 'OO',
7587    '\u0222': 'OU',
7588    '\u24C5': 'P',
7589    '\uFF30': 'P',
7590    '\u1E54': 'P',
7591    '\u1E56': 'P',
7592    '\u01A4': 'P',
7593    '\u2C63': 'P',
7594    '\uA750': 'P',
7595    '\uA752': 'P',
7596    '\uA754': 'P',
7597    '\u24C6': 'Q',
7598    '\uFF31': 'Q',
7599    '\uA756': 'Q',
7600    '\uA758': 'Q',
7601    '\u024A': 'Q',
7602    '\u24C7': 'R',
7603    '\uFF32': 'R',
7604    '\u0154': 'R',
7605    '\u1E58': 'R',
7606    '\u0158': 'R',
7607    '\u0210': 'R',
7608    '\u0212': 'R',
7609    '\u1E5A': 'R',
7610    '\u1E5C': 'R',
7611    '\u0156': 'R',
7612    '\u1E5E': 'R',
7613    '\u024C': 'R',
7614    '\u2C64': 'R',
7615    '\uA75A': 'R',
7616    '\uA7A6': 'R',
7617    '\uA782': 'R',
7618    '\u24C8': 'S',
7619    '\uFF33': 'S',
7620    '\u1E9E': 'S',
7621    '\u015A': 'S',
7622    '\u1E64': 'S',
7623    '\u015C': 'S',
7624    '\u1E60': 'S',
7625    '\u0160': 'S',
7626    '\u1E66': 'S',
7627    '\u1E62': 'S',
7628    '\u1E68': 'S',
7629    '\u0218': 'S',
7630    '\u015E': 'S',
7631    '\u2C7E': 'S',
7632    '\uA7A8': 'S',
7633    '\uA784': 'S',
7634    '\u24C9': 'T',
7635    '\uFF34': 'T',
7636    '\u1E6A': 'T',
7637    '\u0164': 'T',
7638    '\u1E6C': 'T',
7639    '\u021A': 'T',
7640    '\u0162': 'T',
7641    '\u1E70': 'T',
7642    '\u1E6E': 'T',
7643    '\u0166': 'T',
7644    '\u01AC': 'T',
7645    '\u01AE': 'T',
7646    '\u023E': 'T',
7647    '\uA786': 'T',
7648    '\uA728': 'TZ',
7649    '\u24CA': 'U',
7650    '\uFF35': 'U',
7651    '\u00D9': 'U',
7652    '\u00DA': 'U',
7653    '\u00DB': 'U',
7654    '\u0168': 'U',
7655    '\u1E78': 'U',
7656    '\u016A': 'U',
7657    '\u1E7A': 'U',
7658    '\u016C': 'U',
7659    '\u00DC': 'U',
7660    '\u01DB': 'U',
7661    '\u01D7': 'U',
7662    '\u01D5': 'U',
7663    '\u01D9': 'U',
7664    '\u1EE6': 'U',
7665    '\u016E': 'U',
7666    '\u0170': 'U',
7667    '\u01D3': 'U',
7668    '\u0214': 'U',
7669    '\u0216': 'U',
7670    '\u01AF': 'U',
7671    '\u1EEA': 'U',
7672    '\u1EE8': 'U',
7673    '\u1EEE': 'U',
7674    '\u1EEC': 'U',
7675    '\u1EF0': 'U',
7676    '\u1EE4': 'U',
7677    '\u1E72': 'U',
7678    '\u0172': 'U',
7679    '\u1E76': 'U',
7680    '\u1E74': 'U',
7681    '\u0244': 'U',
7682    '\u24CB': 'V',
7683    '\uFF36': 'V',
7684    '\u1E7C': 'V',
7685    '\u1E7E': 'V',
7686    '\u01B2': 'V',
7687    '\uA75E': 'V',
7688    '\u0245': 'V',
7689    '\uA760': 'VY',
7690    '\u24CC': 'W',
7691    '\uFF37': 'W',
7692    '\u1E80': 'W',
7693    '\u1E82': 'W',
7694    '\u0174': 'W',
7695    '\u1E86': 'W',
7696    '\u1E84': 'W',
7697    '\u1E88': 'W',
7698    '\u2C72': 'W',
7699    '\u24CD': 'X',
7700    '\uFF38': 'X',
7701    '\u1E8A': 'X',
7702    '\u1E8C': 'X',
7703    '\u24CE': 'Y',
7704    '\uFF39': 'Y',
7705    '\u1EF2': 'Y',
7706    '\u00DD': 'Y',
7707    '\u0176': 'Y',
7708    '\u1EF8': 'Y',
7709    '\u0232': 'Y',
7710    '\u1E8E': 'Y',
7711    '\u0178': 'Y',
7712    '\u1EF6': 'Y',
7713    '\u1EF4': 'Y',
7714    '\u01B3': 'Y',
7715    '\u024E': 'Y',
7716    '\u1EFE': 'Y',
7717    '\u24CF': 'Z',
7718    '\uFF3A': 'Z',
7719    '\u0179': 'Z',
7720    '\u1E90': 'Z',
7721    '\u017B': 'Z',
7722    '\u017D': 'Z',
7723    '\u1E92': 'Z',
7724    '\u1E94': 'Z',
7725    '\u01B5': 'Z',
7726    '\u0224': 'Z',
7727    '\u2C7F': 'Z',
7728    '\u2C6B': 'Z',
7729    '\uA762': 'Z',
7730    '\u24D0': 'a',
7731    '\uFF41': 'a',
7732    '\u1E9A': 'a',
7733    '\u00E0': 'a',
7734    '\u00E1': 'a',
7735    '\u00E2': 'a',
7736    '\u1EA7': 'a',
7737    '\u1EA5': 'a',
7738    '\u1EAB': 'a',
7739    '\u1EA9': 'a',
7740    '\u00E3': 'a',
7741    '\u0101': 'a',
7742    '\u0103': 'a',
7743    '\u1EB1': 'a',
7744    '\u1EAF': 'a',
7745    '\u1EB5': 'a',
7746    '\u1EB3': 'a',
7747    '\u0227': 'a',
7748    '\u01E1': 'a',
7749    '\u00E4': 'a',
7750    '\u01DF': 'a',
7751    '\u1EA3': 'a',
7752    '\u00E5': 'a',
7753    '\u01FB': 'a',
7754    '\u01CE': 'a',
7755    '\u0201': 'a',
7756    '\u0203': 'a',
7757    '\u1EA1': 'a',
7758    '\u1EAD': 'a',
7759    '\u1EB7': 'a',
7760    '\u1E01': 'a',
7761    '\u0105': 'a',
7762    '\u2C65': 'a',
7763    '\u0250': 'a',
7764    '\uA733': 'aa',
7765    '\u00E6': 'ae',
7766    '\u01FD': 'ae',
7767    '\u01E3': 'ae',
7768    '\uA735': 'ao',
7769    '\uA737': 'au',
7770    '\uA739': 'av',
7771    '\uA73B': 'av',
7772    '\uA73D': 'ay',
7773    '\u24D1': 'b',
7774    '\uFF42': 'b',
7775    '\u1E03': 'b',
7776    '\u1E05': 'b',
7777    '\u1E07': 'b',
7778    '\u0180': 'b',
7779    '\u0183': 'b',
7780    '\u0253': 'b',
7781    '\u24D2': 'c',
7782    '\uFF43': 'c',
7783    '\u0107': 'c',
7784    '\u0109': 'c',
7785    '\u010B': 'c',
7786    '\u010D': 'c',
7787    '\u00E7': 'c',
7788    '\u1E09': 'c',
7789    '\u0188': 'c',
7790    '\u023C': 'c',
7791    '\uA73F': 'c',
7792    '\u2184': 'c',
7793    '\u24D3': 'd',
7794    '\uFF44': 'd',
7795    '\u1E0B': 'd',
7796    '\u010F': 'd',
7797    '\u1E0D': 'd',
7798    '\u1E11': 'd',
7799    '\u1E13': 'd',
7800    '\u1E0F': 'd',
7801    '\u0111': 'd',
7802    '\u018C': 'd',
7803    '\u0256': 'd',
7804    '\u0257': 'd',
7805    '\uA77A': 'd',
7806    '\u01F3': 'dz',
7807    '\u01C6': 'dz',
7808    '\u24D4': 'e',
7809    '\uFF45': 'e',
7810    '\u00E8': 'e',
7811    '\u00E9': 'e',
7812    '\u00EA': 'e',
7813    '\u1EC1': 'e',
7814    '\u1EBF': 'e',
7815    '\u1EC5': 'e',
7816    '\u1EC3': 'e',
7817    '\u1EBD': 'e',
7818    '\u0113': 'e',
7819    '\u1E15': 'e',
7820    '\u1E17': 'e',
7821    '\u0115': 'e',
7822    '\u0117': 'e',
7823    '\u00EB': 'e',
7824    '\u1EBB': 'e',
7825    '\u011B': 'e',
7826    '\u0205': 'e',
7827    '\u0207': 'e',
7828    '\u1EB9': 'e',
7829    '\u1EC7': 'e',
7830    '\u0229': 'e',
7831    '\u1E1D': 'e',
7832    '\u0119': 'e',
7833    '\u1E19': 'e',
7834    '\u1E1B': 'e',
7835    '\u0247': 'e',
7836    '\u025B': 'e',
7837    '\u01DD': 'e',
7838    '\u24D5': 'f',
7839    '\uFF46': 'f',
7840    '\u1E1F': 'f',
7841    '\u0192': 'f',
7842    '\uA77C': 'f',
7843    '\u24D6': 'g',
7844    '\uFF47': 'g',
7845    '\u01F5': 'g',
7846    '\u011D': 'g',
7847    '\u1E21': 'g',
7848    '\u011F': 'g',
7849    '\u0121': 'g',
7850    '\u01E7': 'g',
7851    '\u0123': 'g',
7852    '\u01E5': 'g',
7853    '\u0260': 'g',
7854    '\uA7A1': 'g',
7855    '\u1D79': 'g',
7856    '\uA77F': 'g',
7857    '\u24D7': 'h',
7858    '\uFF48': 'h',
7859    '\u0125': 'h',
7860    '\u1E23': 'h',
7861    '\u1E27': 'h',
7862    '\u021F': 'h',
7863    '\u1E25': 'h',
7864    '\u1E29': 'h',
7865    '\u1E2B': 'h',
7866    '\u1E96': 'h',
7867    '\u0127': 'h',
7868    '\u2C68': 'h',
7869    '\u2C76': 'h',
7870    '\u0265': 'h',
7871    '\u0195': 'hv',
7872    '\u24D8': 'i',
7873    '\uFF49': 'i',
7874    '\u00EC': 'i',
7875    '\u00ED': 'i',
7876    '\u00EE': 'i',
7877    '\u0129': 'i',
7878    '\u012B': 'i',
7879    '\u012D': 'i',
7880    '\u00EF': 'i',
7881    '\u1E2F': 'i',
7882    '\u1EC9': 'i',
7883    '\u01D0': 'i',
7884    '\u0209': 'i',
7885    '\u020B': 'i',
7886    '\u1ECB': 'i',
7887    '\u012F': 'i',
7888    '\u1E2D': 'i',
7889    '\u0268': 'i',
7890    '\u0131': 'i',
7891    '\u24D9': 'j',
7892    '\uFF4A': 'j',
7893    '\u0135': 'j',
7894    '\u01F0': 'j',
7895    '\u0249': 'j',
7896    '\u24DA': 'k',
7897    '\uFF4B': 'k',
7898    '\u1E31': 'k',
7899    '\u01E9': 'k',
7900    '\u1E33': 'k',
7901    '\u0137': 'k',
7902    '\u1E35': 'k',
7903    '\u0199': 'k',
7904    '\u2C6A': 'k',
7905    '\uA741': 'k',
7906    '\uA743': 'k',
7907    '\uA745': 'k',
7908    '\uA7A3': 'k',
7909    '\u24DB': 'l',
7910    '\uFF4C': 'l',
7911    '\u0140': 'l',
7912    '\u013A': 'l',
7913    '\u013E': 'l',
7914    '\u1E37': 'l',
7915    '\u1E39': 'l',
7916    '\u013C': 'l',
7917    '\u1E3D': 'l',
7918    '\u1E3B': 'l',
7919    '\u017F': 'l',
7920    '\u0142': 'l',
7921    '\u019A': 'l',
7922    '\u026B': 'l',
7923    '\u2C61': 'l',
7924    '\uA749': 'l',
7925    '\uA781': 'l',
7926    '\uA747': 'l',
7927    '\u01C9': 'lj',
7928    '\u24DC': 'm',
7929    '\uFF4D': 'm',
7930    '\u1E3F': 'm',
7931    '\u1E41': 'm',
7932    '\u1E43': 'm',
7933    '\u0271': 'm',
7934    '\u026F': 'm',
7935    '\u24DD': 'n',
7936    '\uFF4E': 'n',
7937    '\u01F9': 'n',
7938    '\u0144': 'n',
7939    '\u00F1': 'n',
7940    '\u1E45': 'n',
7941    '\u0148': 'n',
7942    '\u1E47': 'n',
7943    '\u0146': 'n',
7944    '\u1E4B': 'n',
7945    '\u1E49': 'n',
7946    '\u019E': 'n',
7947    '\u0272': 'n',
7948    '\u0149': 'n',
7949    '\uA791': 'n',
7950    '\uA7A5': 'n',
7951    '\u01CC': 'nj',
7952    '\u24DE': 'o',
7953    '\uFF4F': 'o',
7954    '\u00F2': 'o',
7955    '\u00F3': 'o',
7956    '\u00F4': 'o',
7957    '\u1ED3': 'o',
7958    '\u1ED1': 'o',
7959    '\u1ED7': 'o',
7960    '\u1ED5': 'o',
7961    '\u00F5': 'o',
7962    '\u1E4D': 'o',
7963    '\u022D': 'o',
7964    '\u1E4F': 'o',
7965    '\u014D': 'o',
7966    '\u1E51': 'o',
7967    '\u1E53': 'o',
7968    '\u014F': 'o',
7969    '\u022F': 'o',
7970    '\u0231': 'o',
7971    '\u00F6': 'o',
7972    '\u022B': 'o',
7973    '\u1ECF': 'o',
7974    '\u0151': 'o',
7975    '\u01D2': 'o',
7976    '\u020D': 'o',
7977    '\u020F': 'o',
7978    '\u01A1': 'o',
7979    '\u1EDD': 'o',
7980    '\u1EDB': 'o',
7981    '\u1EE1': 'o',
7982    '\u1EDF': 'o',
7983    '\u1EE3': 'o',
7984    '\u1ECD': 'o',
7985    '\u1ED9': 'o',
7986    '\u01EB': 'o',
7987    '\u01ED': 'o',
7988    '\u00F8': 'o',
7989    '\u01FF': 'o',
7990    '\u0254': 'o',
7991    '\uA74B': 'o',
7992    '\uA74D': 'o',
7993    '\u0275': 'o',
7994    '\u01A3': 'oi',
7995    '\u0223': 'ou',
7996    '\uA74F': 'oo',
7997    '\u24DF': 'p',
7998    '\uFF50': 'p',
7999    '\u1E55': 'p',
8000    '\u1E57': 'p',
8001    '\u01A5': 'p',
8002    '\u1D7D': 'p',
8003    '\uA751': 'p',
8004    '\uA753': 'p',
8005    '\uA755': 'p',
8006    '\u24E0': 'q',
8007    '\uFF51': 'q',
8008    '\u024B': 'q',
8009    '\uA757': 'q',
8010    '\uA759': 'q',
8011    '\u24E1': 'r',
8012    '\uFF52': 'r',
8013    '\u0155': 'r',
8014    '\u1E59': 'r',
8015    '\u0159': 'r',
8016    '\u0211': 'r',
8017    '\u0213': 'r',
8018    '\u1E5B': 'r',
8019    '\u1E5D': 'r',
8020    '\u0157': 'r',
8021    '\u1E5F': 'r',
8022    '\u024D': 'r',
8023    '\u027D': 'r',
8024    '\uA75B': 'r',
8025    '\uA7A7': 'r',
8026    '\uA783': 'r',
8027    '\u24E2': 's',
8028    '\uFF53': 's',
8029    '\u00DF': 's',
8030    '\u015B': 's',
8031    '\u1E65': 's',
8032    '\u015D': 's',
8033    '\u1E61': 's',
8034    '\u0161': 's',
8035    '\u1E67': 's',
8036    '\u1E63': 's',
8037    '\u1E69': 's',
8038    '\u0219': 's',
8039    '\u015F': 's',
8040    '\u023F': 's',
8041    '\uA7A9': 's',
8042    '\uA785': 's',
8043    '\u1E9B': 's',
8044    '\u24E3': 't',
8045    '\uFF54': 't',
8046    '\u1E6B': 't',
8047    '\u1E97': 't',
8048    '\u0165': 't',
8049    '\u1E6D': 't',
8050    '\u021B': 't',
8051    '\u0163': 't',
8052    '\u1E71': 't',
8053    '\u1E6F': 't',
8054    '\u0167': 't',
8055    '\u01AD': 't',
8056    '\u0288': 't',
8057    '\u2C66': 't',
8058    '\uA787': 't',
8059    '\uA729': 'tz',
8060    '\u24E4': 'u',
8061    '\uFF55': 'u',
8062    '\u00F9': 'u',
8063    '\u00FA': 'u',
8064    '\u00FB': 'u',
8065    '\u0169': 'u',
8066    '\u1E79': 'u',
8067    '\u016B': 'u',
8068    '\u1E7B': 'u',
8069    '\u016D': 'u',
8070    '\u00FC': 'u',
8071    '\u01DC': 'u',
8072    '\u01D8': 'u',
8073    '\u01D6': 'u',
8074    '\u01DA': 'u',
8075    '\u1EE7': 'u',
8076    '\u016F': 'u',
8077    '\u0171': 'u',
8078    '\u01D4': 'u',
8079    '\u0215': 'u',
8080    '\u0217': 'u',
8081    '\u01B0': 'u',
8082    '\u1EEB': 'u',
8083    '\u1EE9': 'u',
8084    '\u1EEF': 'u',
8085    '\u1EED': 'u',
8086    '\u1EF1': 'u',
8087    '\u1EE5': 'u',
8088    '\u1E73': 'u',
8089    '\u0173': 'u',
8090    '\u1E77': 'u',
8091    '\u1E75': 'u',
8092    '\u0289': 'u',
8093    '\u24E5': 'v',
8094    '\uFF56': 'v',
8095    '\u1E7D': 'v',
8096    '\u1E7F': 'v',
8097    '\u028B': 'v',
8098    '\uA75F': 'v',
8099    '\u028C': 'v',
8100    '\uA761': 'vy',
8101    '\u24E6': 'w',
8102    '\uFF57': 'w',
8103    '\u1E81': 'w',
8104    '\u1E83': 'w',
8105    '\u0175': 'w',
8106    '\u1E87': 'w',
8107    '\u1E85': 'w',
8108    '\u1E98': 'w',
8109    '\u1E89': 'w',
8110    '\u2C73': 'w',
8111    '\u24E7': 'x',
8112    '\uFF58': 'x',
8113    '\u1E8B': 'x',
8114    '\u1E8D': 'x',
8115    '\u24E8': 'y',
8116    '\uFF59': 'y',
8117    '\u1EF3': 'y',
8118    '\u00FD': 'y',
8119    '\u0177': 'y',
8120    '\u1EF9': 'y',
8121    '\u0233': 'y',
8122    '\u1E8F': 'y',
8123    '\u00FF': 'y',
8124    '\u1EF7': 'y',
8125    '\u1E99': 'y',
8126    '\u1EF5': 'y',
8127    '\u01B4': 'y',
8128    '\u024F': 'y',
8129    '\u1EFF': 'y',
8130    '\u24E9': 'z',
8131    '\uFF5A': 'z',
8132    '\u017A': 'z',
8133    '\u1E91': 'z',
8134    '\u017C': 'z',
8135    '\u017E': 'z',
8136    '\u1E93': 'z',
8137    '\u1E95': 'z',
8138    '\u01B6': 'z',
8139    '\u0225': 'z',
8140    '\u0240': 'z',
8141    '\u2C6C': 'z',
8142    '\uA763': 'z',
8143    '\u0386': '\u0391',
8144    '\u0388': '\u0395',
8145    '\u0389': '\u0397',
8146    '\u038A': '\u0399',
8147    '\u03AA': '\u0399',
8148    '\u038C': '\u039F',
8149    '\u038E': '\u03A5',
8150    '\u03AB': '\u03A5',
8151    '\u038F': '\u03A9',
8152    '\u03AC': '\u03B1',
8153    '\u03AD': '\u03B5',
8154    '\u03AE': '\u03B7',
8155    '\u03AF': '\u03B9',
8156    '\u03CA': '\u03B9',
8157    '\u0390': '\u03B9',
8158    '\u03CC': '\u03BF',
8159    '\u03CD': '\u03C5',
8160    '\u03CB': '\u03C5',
8161    '\u03B0': '\u03C5',
8162    '\u03C9': '\u03C9',
8163    '\u03C2': '\u03C3'
8164  };
8165
8166  return diacritics;
8167});
8168
8169S2.define('select2/data/base',[
8170  '../utils'
8171], function (Utils) {
8172  function BaseAdapter ($element, options) {
8173    BaseAdapter.__super__.constructor.call(this);
8174  }
8175
8176  Utils.Extend(BaseAdapter, Utils.Observable);
8177
8178  BaseAdapter.prototype.current = function (callback) {
8179    throw new Error('The `current` method must be defined in child classes.');
8180  };
8181
8182  BaseAdapter.prototype.query = function (params, callback) {
8183    throw new Error('The `query` method must be defined in child classes.');
8184  };
8185
8186  BaseAdapter.prototype.bind = function (container, $container) {
8187    // Can be implemented in subclasses
8188  };
8189
8190  BaseAdapter.prototype.destroy = function () {
8191    // Can be implemented in subclasses
8192  };
8193
8194  BaseAdapter.prototype.generateResultId = function (container, data) {
8195    var id = 
vendor: 25,079 bytes, lines 8195-9289
8195container.id + '-result-';
8196
8197    id += Utils.generateChars(4);
8198
8199    if (data.id != null) {
8200      id += '-' + data.id.toString();
8201    } else {
8202      id += '-' + Utils.generateChars(4);
8203    }
8204    return id;
8205  };
8206
8207  return BaseAdapter;
8208});
8209
8210S2.define('select2/data/select',[
8211  './base',
8212  '../utils',
8213  'jquery'
8214], function (BaseAdapter, Utils, $) {
8215  function SelectAdapter ($element, options) {
8216    this.$element = $element;
8217    this.options = options;
8218
8219    SelectAdapter.__super__.constructor.call(this);
8220  }
8221
8222  Utils.Extend(SelectAdapter, BaseAdapter);
8223
8224  SelectAdapter.prototype.current = function (callback) {
8225    var data = [];
8226    var self = this;
8227
8228    this.$element.find(':selected').each(function () {
8229      var $option = $(this);
8230
8231      var option = self.item($option);
8232
8233      data.push(option);
8234    });
8235
8236    callback(data);
8237  };
8238
8239  SelectAdapter.prototype.select = function (data) {
8240    var self = this;
8241
8242    data.selected = true;
8243
8244    // If data.element is a DOM node, use it instead
8245    if ($(data.element).is('option')) {
8246      data.element.selected = true;
8247
8248      this.$element.trigger('change');
8249
8250      return;
8251    }
8252
8253    if (this.$element.prop('multiple')) {
8254      this.current(function (currentData) {
8255        var val = [];
8256
8257        data = [data];
8258        data.push.apply(data, currentData);
8259
8260        for (var d = 0; d < data.length; d++) {
8261          var id = data[d].id;
8262
8263          if ($.inArray(id, val) === -1) {
8264            val.push(id);
8265          }
8266        }
8267
8268        self.$element.val(val);
8269        self.$element.trigger('change');
8270      });
8271    } else {
8272      var val = data.id;
8273
8274      this.$element.val(val);
8275      this.$element.trigger('change');
8276    }
8277  };
8278
8279  SelectAdapter.prototype.unselect = function (data) {
8280    var self = this;
8281
8282    if (!this.$element.prop('multiple')) {
8283      return;
8284    }
8285
8286    data.selected = false;
8287
8288    if ($(data.element).is('option')) {
8289      data.element.selected = false;
8290
8291      this.$element.trigger('change');
8292
8293      return;
8294    }
8295
8296    this.current(function (currentData) {
8297      var val = [];
8298
8299      for (var d = 0; d < currentData.length; d++) {
8300        var id = currentData[d].id;
8301
8302        if (id !== data.id && $.inArray(id, val) === -1) {
8303          val.push(id);
8304        }
8305      }
8306
8307      self.$element.val(val);
8308
8309      self.$element.trigger('change');
8310    });
8311  };
8312
8313  SelectAdapter.prototype.bind = function (container, $container) {
8314    var self = this;
8315
8316    this.container = container;
8317
8318    container.on('select', function (params) {
8319      self.select(params.data);
8320    });
8321
8322    container.on('unselect', function (params) {
8323      self.unselect(params.data);
8324    });
8325  };
8326
8327  SelectAdapter.prototype.destroy = function () {
8328    // Remove anything added to child elements
8329    this.$element.find('*').each(function () {
8330      // Remove any custom data set by Select2
8331      $.removeData(this, 'data');
8332    });
8333  };
8334
8335  SelectAdapter.prototype.query = function (params, callback) {
8336    var data = [];
8337    var self = this;
8338
8339    var $options = this.$element.children();
8340
8341    $options.each(function () {
8342      var $option = $(this);
8343
8344      if (!$option.is('option') && !$option.is('optgroup')) {
8345        return;
8346      }
8347
8348      var option = self.item($option);
8349
8350      var matches = self.matches(params, option);
8351
8352      if (matches !== null) {
8353        data.push(matches);
8354      }
8355    });
8356
8357    callback({
8358      results: data
8359    });
8360  };
8361
8362  SelectAdapter.prototype.addOptions = function ($options) {
8363    Utils.appendMany(this.$element, $options);
8364  };
8365
8366  SelectAdapter.prototype.option = function (data) {
8367    var option;
8368
8369    if (data.children) {
8370      option = document.createElement('optgroup');
8371      option.label = data.text;
8372    } else {
8373      option = document.createElement('option');
8374
8375      if (option.textContent !== undefined) {
8376        option.textContent = data.text;
8377      } else {
8378        option.innerText = data.text;
8379      }
8380    }
8381
8382    if (data.id) {
8383      option.value = data.id;
8384    }
8385
8386    if (data.disabled) {
8387      option.disabled = true;
8388    }
8389
8390    if (data.selected) {
8391      option.selected = true;
8392    }
8393
8394    if (data.title) {
8395      option.title = data.title;
8396    }
8397
8398    var $option = $(option);
8399
8400    var normalizedData = this._normalizeItem(data);
8401    normalizedData.element = option;
8402
8403    // Override the option's data with the combined data
8404    $.data(option, 'data', normalizedData);
8405
8406    return $option;
8407  };
8408
8409  SelectAdapter.prototype.item = function ($option) {
8410    var data = {};
8411
8412    data = $.data($option[0], 'data');
8413
8414    if (data != null) {
8415      return data;
8416    }
8417
8418    if ($option.is('option')) {
8419      data = {
8420        id: $option.val(),
8421        text: $option.text(),
8422        disabled: $option.prop('disabled'),
8423        selected: $option.prop('selected'),
8424        title: $option.prop('title')
8425      };
8426    } else if ($option.is('optgroup')) {
8427      data = {
8428        text: $option.prop('label'),
8429        children: [],
8430        title: $option.prop('title')
8431      };
8432
8433      var $children = $option.children('option');
8434      var children = [];
8435
8436      for (var c = 0; c < $children.length; c++) {
8437        var $child = $($children[c]);
8438
8439        var child = this.item($child);
8440
8441        children.push(child);
8442      }
8443
8444      data.children = children;
8445    }
8446
8447    data = this._normalizeItem(data);
8448    data.element = $option[0];
8449
8450    $.data($option[0], 'data', data);
8451
8452    return data;
8453  };
8454
8455  SelectAdapter.prototype._normalizeItem = function (item) {
8456    if (!$.isPlainObject(item)) {
8457      item = {
8458        id: item,
8459        text: item
8460      };
8461    }
8462
8463    item = $.extend({}, {
8464      text: ''
8465    }, item);
8466
8467    var defaults = {
8468      selected: false,
8469      disabled: false
8470    };
8471
8472    if (item.id != null) {
8473      item.id = item.id.toString();
8474    }
8475
8476    if (item.text != null) {
8477      item.text = item.text.toString();
8478    }
8479
8480    if (item._resultId == null && item.id && this.container != null) {
8481      item._resultId = this.generateResultId(this.container, item);
8482    }
8483
8484    return $.extend({}, defaults, item);
8485  };
8486
8487  SelectAdapter.prototype.matches = function (params, data) {
8488    var matcher = this.options.get('matcher');
8489
8490    return matcher(params, data);
8491  };
8492
8493  return SelectAdapter;
8494});
8495
8496S2.define('select2/data/array',[
8497  './select',
8498  '../utils',
8499  'jquery'
8500], function (SelectAdapter, Utils, $) {
8501  function ArrayAdapter ($element, options) {
8502    var data = options.get('data') || [];
8503
8504    ArrayAdapter.__super__.constructor.call(this, $element, options);
8505
8506    this.addOptions(this.convertToOptions(data));
8507  }
8508
8509  Utils.Extend(ArrayAdapter, SelectAdapter);
8510
8511  ArrayAdapter.prototype.select = function (data) {
8512    var $option = this.$element.find('option').filter(function (i, elm) {
8513      return elm.value == data.id.toString();
8514    });
8515
8516    if ($option.length === 0) {
8517      $option = this.option(data);
8518
8519      this.addOptions($option);
8520    }
8521
8522    ArrayAdapter.__super__.select.call(this, data);
8523  };
8524
8525  ArrayAdapter.prototype.convertToOptions = function (data) {
8526    var self = this;
8527
8528    var $existing = this.$element.find('option');
8529    var existingIds = $existing.map(function () {
8530      return self.item($(this)).id;
8531    }).get();
8532
8533    var $options = [];
8534
8535    // Filter out all items except for the one passed in the argument
8536    function onlyItem (item) {
8537      return function () {
8538        return $(this).val() == item.id;
8539      };
8540    }
8541
8542    for (var d = 0; d < data.length; d++) {
8543      var item = this._normalizeItem(data[d]);
8544
8545      // Skip items which were pre-loaded, only merge the data
8546      if ($.inArray(item.id, existingIds) >= 0) {
8547        var $existingOption = $existing.filter(onlyItem(item));
8548
8549        var existingData = this.item($existingOption);
8550        var newData = $.extend(true, {}, item, existingData);
8551
8552        var $newOption = this.option(newData);
8553
8554        $existingOption.replaceWith($newOption);
8555
8556        continue;
8557      }
8558
8559      var $option = this.option(item);
8560
8561      if (item.children) {
8562        var $children = this.convertToOptions(item.children);
8563
8564        Utils.appendMany($option, $children);
8565      }
8566
8567      $options.push($option);
8568    }
8569
8570    return $options;
8571  };
8572
8573  return ArrayAdapter;
8574});
8575
8576S2.define('select2/data/ajax',[
8577  './array',
8578  '../utils',
8579  'jquery'
8580], function (ArrayAdapter, Utils, $) {
8581  function AjaxAdapter ($element, options) {
8582    this.ajaxOptions = this._applyDefaults(options.get('ajax'));
8583
8584    if (this.ajaxOptions.processResults != null) {
8585      this.processResults = this.ajaxOptions.processResults;
8586    }
8587
8588    AjaxAdapter.__super__.constructor.call(this, $element, options);
8589  }
8590
8591  Utils.Extend(AjaxAdapter, ArrayAdapter);
8592
8593  AjaxAdapter.prototype._applyDefaults = function (options) {
8594    var defaults = {
8595      data: function (params) {
8596        return $.extend({}, params, {
8597          q: params.term
8598        });
8599      },
8600      transport: function (params, success, failure) {
8601        var $request = $.ajax(params);
8602
8603        $request.then(success);
8604        $request.fail(failure);
8605
8606        return $request;
8607      }
8608    };
8609
8610    return $.extend({}, defaults, options, true);
8611  };
8612
8613  AjaxAdapter.prototype.processResults = function (results) {
8614    return results;
8615  };
8616
8617  AjaxAdapter.prototype.query = function (params, callback) {
8618    var matches = [];
8619    var self = this;
8620
8621    if (this._request != null) {
8622      // JSONP requests cannot always be aborted
8623      if ($.isFunction(this._request.abort)) {
8624        this._request.abort();
8625      }
8626
8627      this._request = null;
8628    }
8629
8630    var options = $.extend({
8631      type: 'GET'
8632    }, this.ajaxOptions);
8633
8634    if (typeof options.url === 'function') {
8635      options.url = options.url.call(this.$element, params);
8636    }
8637
8638    if (typeof options.data === 'function') {
8639      options.data = options.data.call(this.$element, params);
8640    }
8641
8642    function request () {
8643      var $request = options.transport(options, function (data) {
8644        var results = self.processResults(data, params);
8645
8646        if (self.options.get('debug') && window.console && console.error) {
8647          // Check to make sure that the response included a `results` key.
8648          if (!results || !results.results || !$.isArray(results.results)) {
8649            console.error(
8650              'Select2: The AJAX results did not return an array in the ' +
8651              '`results` key of the response.'
8652            );
8653          }
8654        }
8655
8656        callback(results);
8657      }, function () {
8658        // Attempt to detect if a request was aborted
8659        // Only works if the transport exposes a status property
8660        if ($request.status && $request.status === '0') {
8661          return;
8662        }
8663
8664        self.trigger('results:message', {
8665          message: 'errorLoading'
8666        });
8667      });
8668
8669      self._request = $request;
8670    }
8671
8672    if (this.ajaxOptions.delay && params.term != null) {
8673      if (this._queryTimeout) {
8674        window.clearTimeout(this._queryTimeout);
8675      }
8676
8677      this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay);
8678    } else {
8679      request();
8680    }
8681  };
8682
8683  return AjaxAdapter;
8684});
8685
8686S2.define('select2/data/tags',[
8687  'jquery'
8688], function ($) {
8689  function Tags (decorated, $element, options) {
8690    var tags = options.get('tags');
8691
8692    var createTag = options.get('createTag');
8693
8694    if (createTag !== undefined) {
8695      this.createTag = createTag;
8696    }
8697
8698    var insertTag = options.get('insertTag');
8699
8700    if (insertTag !== undefined) {
8701        this.insertTag = insertTag;
8702    }
8703
8704    decorated.call(this, $element, options);
8705
8706    if ($.isArray(tags)) {
8707      for (var t = 0; t < tags.length; t++) {
8708        var tag = tags[t];
8709        var item = this._normalizeItem(tag);
8710
8711        var $option = this.option(item);
8712
8713        this.$element.append($option);
8714      }
8715    }
8716  }
8717
8718  Tags.prototype.query = function (decorated, params, callback) {
8719    var self = this;
8720
8721    this._removeOldTags();
8722
8723    if (params.term == null || params.page != null) {
8724      decorated.call(this, params, callback);
8725      return;
8726    }
8727
8728    function wrapper (obj, child) {
8729      var data = obj.results;
8730
8731      for (var i = 0; i < data.length; i++) {
8732        var option = data[i];
8733
8734        var checkChildren = (
8735          option.children != null &&
8736          !wrapper({
8737            results: option.children
8738          }, true)
8739        );
8740
8741        var checkText = option.text === params.term;
8742
8743        if (checkText || checkChildren) {
8744          if (child) {
8745            return false;
8746          }
8747
8748          obj.data = data;
8749          callback(obj);
8750
8751          return;
8752        }
8753      }
8754
8755      if (child) {
8756        return true;
8757      }
8758
8759      var tag = self.createTag(params);
8760
8761      if (tag != null) {
8762        var $option = self.option(tag);
8763        $option.attr('data-select2-tag', true);
8764
8765        self.addOptions([$option]);
8766
8767        self.insertTag(data, tag);
8768      }
8769
8770      obj.results = data;
8771
8772      callback(obj);
8773    }
8774
8775    decorated.call(this, params, wrapper);
8776  };
8777
8778  Tags.prototype.createTag = function (decorated, params) {
8779    var term = $.trim(params.term);
8780
8781    if (term === '') {
8782      return null;
8783    }
8784
8785    return {
8786      id: term,
8787      text: term
8788    };
8789  };
8790
8791  Tags.prototype.insertTag = function (_, data, tag) {
8792    data.unshift(tag);
8793  };
8794
8795  Tags.prototype._removeOldTags = function (_) {
8796    var tag = this._lastTag;
8797
8798    var $options = this.$element.find('option[data-select2-tag]');
8799
8800    $options.each(function () {
8801      if (this.selected) {
8802        return;
8803      }
8804
8805      $(this).remove();
8806    });
8807  };
8808
8809  return Tags;
8810});
8811
8812S2.define('select2/data/tokenizer',[
8813  'jquery'
8814], function ($) {
8815  function Tokenizer (decorated, $element, options) {
8816    var tokenizer = options.get('tokenizer');
8817
8818    if (tokenizer !== undefined) {
8819      this.tokenizer = tokenizer;
8820    }
8821
8822    decorated.call(this, $element, options);
8823  }
8824
8825  Tokenizer.prototype.bind = function (decorated, container, $container) {
8826    decorated.call(this, container, $container);
8827
8828    this.$search =  container.dropdown.$search || container.selection.$search ||
8829      $container.find('.select2-search__field');
8830  };
8831
8832  Tokenizer.prototype.query = function (decorated, params, callback) {
8833    var self = this;
8834
8835    function createAndSelect (data) {
8836      // Normalize the data object so we can use it for checks
8837      var item = self._normalizeItem(data);
8838
8839      // Check if the data object already exists as a tag
8840      // Select it if it doesn't
8841      var $existingOptions = self.$element.find('option').filter(function () {
8842        return $(this).val() === item.id;
8843      });
8844
8845      // If an existing option wasn't found for it, create the option
8846      if (!$existingOptions.length) {
8847        var $option = self.option(item);
8848        $option.attr('data-select2-tag', true);
8849
8850        self._removeOldTags();
8851        self.addOptions([$option]);
8852      }
8853
8854      // Select the item, now that we know there is an option for it
8855      select(item);
8856    }
8857
8858    function select (data) {
8859      self.trigger('select', {
8860        data: data
8861      });
8862    }
8863
8864    params.term = params.term || '';
8865
8866    var tokenData = this.tokenizer(params, this.options, createAndSelect);
8867
8868    if (tokenData.term !== params.term) {
8869      // Replace the search term if we have the search box
8870      if (this.$search.length) {
8871        this.$search.val(tokenData.term);
8872        this.$search.focus();
8873      }
8874
8875      params.term = tokenData.term;
8876    }
8877
8878    decorated.call(this, params, callback);
8879  };
8880
8881  Tokenizer.prototype.tokenizer = function (_, params, options, callback) {
8882    var separators = options.get('tokenSeparators') || [];
8883    var term = params.term;
8884    var i = 0;
8885
8886    var createTag = this.createTag || function (params) {
8887      return {
8888        id: params.term,
8889        text: params.term
8890      };
8891    };
8892
8893    while (i < term.length) {
8894      var termChar = term[i];
8895
8896      if ($.inArray(termChar, separators) === -1) {
8897        i++;
8898
8899        continue;
8900      }
8901
8902      var part = term.substr(0, i);
8903      var partParams = $.extend({}, params, {
8904        term: part
8905      });
8906
8907      var data = createTag(partParams);
8908
8909      if (data == null) {
8910        i++;
8911        continue;
8912      }
8913
8914      callback(data);
8915
8916      // Reset the term to not include the tokenized portion
8917      term = term.substr(i + 1) || '';
8918      i = 0;
8919    }
8920
8921    return {
8922      term: term
8923    };
8924  };
8925
8926  return Tokenizer;
8927});
8928
8929S2.define('select2/data/minimumInputLength',[
8930
8931], function () {
8932  function MinimumInputLength (decorated, $e, options) {
8933    this.minimumInputLength = options.get('minimumInputLength');
8934
8935    decorated.call(this, $e, options);
8936  }
8937
8938  MinimumInputLength.prototype.query = function (decorated, params, callback) {
8939    params.term = params.term || '';
8940
8941    if (params.term.length < this.minimumInputLength) {
8942      this.trigger('results:message', {
8943        message: 'inputTooShort',
8944        args: {
8945          minimum: this.minimumInputLength,
8946          input: params.term,
8947          params: params
8948        }
8949      });
8950
8951      return;
8952    }
8953
8954    decorated.call(this, params, callback);
8955  };
8956
8957  return MinimumInputLength;
8958});
8959
8960S2.define('select2/data/maximumInputLength',[
8961
8962], function () {
8963  function MaximumInputLength (decorated, $e, options) {
8964    this.maximumInputLength = options.get('maximumInputLength');
8965
8966    decorated.call(this, $e, options);
8967  }
8968
8969  MaximumInputLength.prototype.query = function (decorated, params, callback) {
8970    params.term = params.term || '';
8971
8972    if (this.maximumInputLength > 0 &&
8973        params.term.length > this.maximumInputLength) {
8974      this.trigger('results:message', {
8975        message: 'inputTooLong',
8976        args: {
8977          maximum: this.maximumInputLength,
8978          input: params.term,
8979          params: params
8980        }
8981      });
8982
8983      return;
8984    }
8985
8986    decorated.call(this, params, callback);
8987  };
8988
8989  return MaximumInputLength;
8990});
8991
8992S2.define('select2/data/maximumSelectionLength',[
8993
8994], function (){
8995  function MaximumSelectionLength (decorated, $e, options) {
8996    this.maximumSelectionLength = options.get('maximumSelectionLength');
8997
8998    decorated.call(this, $e, options);
8999  }
9000
9001  MaximumSelectionLength.prototype.query =
9002    function (decorated, params, callback) {
9003      var self = this;
9004
9005      this.current(function (currentData) {
9006        var count = currentData != null ? currentData.length : 0;
9007        if (self.maximumSelectionLength > 0 &&
9008          count >= self.maximumSelectionLength) {
9009          self.trigger('results:message', {
9010            message: 'maximumSelected',
9011            args: {
9012              maximum: self.maximumSelectionLength
9013            }
9014          });
9015          return;
9016        }
9017        decorated.call(self, params, callback);
9018      });
9019  };
9020
9021  return MaximumSelectionLength;
9022});
9023
9024S2.define('select2/dropdown',[
9025  'jquery',
9026  './utils'
9027], function ($, Utils) {
9028  function Dropdown ($element, options) {
9029    this.$element = $element;
9030    this.options = options;
9031
9032    Dropdown.__super__.constructor.call(this);
9033  }
9034
9035  Utils.Extend(Dropdown, Utils.Observable);
9036
9037  Dropdown.prototype.render = function () {
9038    var $dropdown = $(
9039      '<span class="select2-dropdown">' +
9040        '<span class="select2-results"></span>' +
9041      '</span>'
9042    );
9043
9044    $dropdown.attr('dir', this.options.get('dir'));
9045
9046    this.$dropdown = $dropdown;
9047
9048    return $dropdown;
9049  };
9050
9051  Dropdown.prototype.bind = function () {
9052    // Should be implemented in subclasses
9053  };
9054
9055  Dropdown.prototype.position = function ($dropdown, $container) {
9056    // Should be implmented in subclasses
9057  };
9058
9059  Dropdown.prototype.destroy = function () {
9060    // Remove the dropdown from the DOM
9061    this.$dropdown.remove();
9062  };
9063
9064  return Dropdown;
9065});
9066
9067S2.define('select2/dropdown/search',[
9068  'jquery',
9069  '../utils'
9070], function ($, Utils) {
9071  function Search () { }
9072
9073  Search.prototype.render = function (decorated) {
9074    var $rendered = decorated.call(this);
9075
9076    var $search = $(
9077      '<span class="select2-search select2-search--dropdown">' +
9078        '<input class="select2-search__field" type="search" tabindex="-1"' +
9079        ' autocomplete="off" autocorrect="off" autocapitalize="off"' +
9080        ' spellcheck="false" role="textbox" />' +
9081      '</span>'
9082    );
9083
9084    this.$searchContainer = $search;
9085    this.$search = $search.find('input');
9086
9087    $rendered.prepend($search);
9088
9089    return $rendered;
9090  };
9091
9092  Search.prototype.bind = function (decorated, container, $container) {
9093    var self = this;
9094
9095    decorated.call(this, container, $container);
9096
9097    this.$search.on('keydown', function (evt) {
9098      self.trigger('keypress', evt);
9099
9100      self._keyUpPrevented = evt.isDefaultPrevented();
9101    });
9102
9103    // Workaround for browsers which do not support the `input` event
9104    // This will prevent double-triggering of events for browsers which support
9105    // both the `keyup` and `input` events.
9106    this.$search.on('input', function (evt) {
9107      // Unbind the duplicated `keyup` event
9108      $(this).off('keyup');
9109    });
9110
9111    this.$search.on('keyup input', function (evt) {
9112      self.handleSearch(evt);
9113    });
9114
9115    container.on('open', function () {
9116      self.$search.attr('tabindex', 0);
9117
9118      self.$search.focus();
9119
9120      window.setTimeout(function () {
9121        self.$search.focus();
9122      }, 0);
9123    });
9124
9125    container.on('close', function () {
9126      self.$search.attr('tabindex', -1);
9127
9128      self.$search.val('');
9129    });
9130
9131    container.on('focus', function () {
9132      if (container.isOpen()) {
9133        self.$search.focus();
9134      }
9135    });
9136
9137    container.on('results:all', function (params) {
9138      if (params.query.term == null || params.query.term === '') {
9139        var showSearch = self.showSearch(params);
9140
9141        if (showSearch) {
9142          self.$searchContainer.removeClass('select2-search--hide');
9143        } else {
9144          self.$searchContainer.addClass('select2-search--hide');
9145        }
9146      }
9147    });
9148  };
9149
9150  Search.prototype.handleSearch = function (evt) {
9151    if (!this._keyUpPrevented) {
9152      var input = this.$search.val();
9153
9154      this.trigger('query', {
9155        term: input
9156      });
9157    }
9158
9159    this._keyUpPrevented = false;
9160  };
9161
9162  Search.prototype.showSearch = function (_, params) {
9163    return true;
9164  };
9165
9166  return Search;
9167});
9168
9169S2.define('select2/dropdown/hidePlaceholder',[
9170
9171], function () {
9172  function HidePlaceholder (decorated, $element, options, dataAdapter) {
9173    this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
9174
9175    decorated.call(this, $element, options, dataAdapter);
9176  }
9177
9178  HidePlaceholder.prototype.append = function (decorated, data) {
9179    data.results = this.removePlaceholder(data.results);
9180
9181    decorated.call(this, data);
9182  };
9183
9184  HidePlaceholder.prototype.normalizePlaceholder = function (_, placeholder) {
9185    if (typeof placeholder === 'string') {
9186      placeholder = {
9187        id: '',
9188        text: placeholder
9189      };
9190    }
9191
9192    return placeholder;
9193  };
9194
9195  HidePlaceholder.prototype.removePlaceholder = function (_, data) {
9196    var modifiedData = data.slice(0);
9197
9198    for (var d = data.length - 1; d >= 0; d--) {
9199      var item = data[d];
9200
9201      if (this.placeholder.id === item.id) {
9202        modifiedData.splice(d, 1);
9203      }
9204    }
9205
9206    return modifiedData;
9207  };
9208
9209  return HidePlaceholder;
9210});
9211
9212S2.define('select2/dropdown/infiniteScroll',[
9213  'jquery'
9214], function ($) {
9215  function InfiniteScroll (decorated, $element, options, dataAdapter) {
9216    this.lastParams = {};
9217
9218    decorated.call(this, $element, options, dataAdapter);
9219
9220    this.$loadingMore = this.createLoadingMore();
9221    this.loading = false;
9222  }
9223
9224  InfiniteScroll.prototype.append = function (decorated, data) {
9225    this.$loadingMore.remove();
9226    this.loading = false;
9227
9228    decorated.call(this, data);
9229
9230    if (this.showLoadingMore(data)) {
9231      this.$results.append(this.$loadingMore);
9232    }
9233  };
9234
9235  InfiniteScroll.prototype.bind = function (decorated, container, $container) {
9236    var self = this;
9237
9238    decorated.call(this, container, $container);
9239
9240    container.on('query', function (params) {
9241      self.lastParams = params;
9242      self.loading = true;
9243    });
9244
9245    container.on('query:append', function (params) {
9246      self.lastParams = params;
9247      self.loading = true;
9248    });
9249
9250    this.$results.on('scroll', function () {
9251      var isLoadMoreVisible = $.contains(
9252        document.documentElement,
9253        self.$loadingMore[0]
9254      );
9255
9256      if (self.loading || !isLoadMoreVisible) {
9257        return;
9258      }
9259
9260      var currentOffset = self.$results.offset().top +
9261        self.$results.outerHeight(false);
9262      var loadingMoreOffset = self.$loadingMore.offset().top +
9263        self.$loadingMore.outerHeight(false);
9264
9265      if (currentOffset + 50 >= loadingMoreOffset) {
9266        self.loadMore();
9267      }
9268    });
9269  };
9270
9271  InfiniteScroll.prototype.loadMore = function () {
9272    this.loading = true;
9273
9274    var params = $.extend({}, {page: 1}, this.lastParams);
9275
9276    params.page++;
9277
9278    this.trigger('query:append', params);
9279  };
9280
9281  InfiniteScroll.prototype.showLoadingMore = function (_, data) {
9282    return data.pagination && data.pagination.more;
9283  };
9284
9285  InfiniteScroll.prototype.createLoadingMore = function () {
9286    var $option = $(
9287      '<li ' +
9288      'class="select2-results__option select2-results__option--load-more"' +
9289      'role="treeitem
vendor: 32,229 bytes, lines 9289-10535
9289" aria-disabled="true"></li>'
9290    );
9291
9292    var message = this.options.get('translations').get('loadingMore');
9293
9294    $option.html(message(this.lastParams));
9295
9296    return $option;
9297  };
9298
9299  return InfiniteScroll;
9300});
9301
9302S2.define('select2/dropdown/attachBody',[
9303  'jquery',
9304  '../utils'
9305], function ($, Utils) {
9306  function AttachBody (decorated, $element, options) {
9307    this.$dropdownParent = options.get('dropdownParent') || $(document.body);
9308
9309    decorated.call(this, $element, options);
9310  }
9311
9312  AttachBody.prototype.bind = function (decorated, container, $container) {
9313    var self = this;
9314
9315    var setupResultsEvents = false;
9316
9317    decorated.call(this, container, $container);
9318
9319    container.on('open', function () {
9320      self._showDropdown();
9321      self._attachPositioningHandler(container);
9322
9323      if (!setupResultsEvents) {
9324        setupResultsEvents = true;
9325
9326        container.on('results:all', function () {
9327          self._positionDropdown();
9328          self._resizeDropdown();
9329        });
9330
9331        container.on('results:append', function () {
9332          self._positionDropdown();
9333          self._resizeDropdown();
9334        });
9335      }
9336    });
9337
9338    container.on('close', function () {
9339      self._hideDropdown();
9340      self._detachPositioningHandler(container);
9341    });
9342
9343    this.$dropdownContainer.on('mousedown', function (evt) {
9344      evt.stopPropagation();
9345    });
9346  };
9347
9348  AttachBody.prototype.destroy = function (decorated) {
9349    decorated.call(this);
9350
9351    this.$dropdownContainer.remove();
9352  };
9353
9354  AttachBody.prototype.position = function (decorated, $dropdown, $container) {
9355    // Clone all of the container classes
9356    $dropdown.attr('class', $container.attr('class'));
9357
9358    $dropdown.removeClass('select2');
9359    $dropdown.addClass('select2-container--open');
9360
9361    $dropdown.css({
9362      position: 'absolute',
9363      top: -999999
9364    });
9365
9366    this.$container = $container;
9367  };
9368
9369  AttachBody.prototype.render = function (decorated) {
9370    var $container = $('<span></span>');
9371
9372    var $dropdown = decorated.call(this);
9373    $container.append($dropdown);
9374
9375    this.$dropdownContainer = $container;
9376
9377    return $container;
9378  };
9379
9380  AttachBody.prototype._hideDropdown = function (decorated) {
9381    this.$dropdownContainer.detach();
9382  };
9383
9384  AttachBody.prototype._attachPositioningHandler =
9385      function (decorated, container) {
9386    var self = this;
9387
9388    var scrollEvent = 'scroll.select2.' + container.id;
9389    var resizeEvent = 'resize.select2.' + container.id;
9390    var orientationEvent = 'orientationchange.select2.' + container.id;
9391
9392    var $watchers = this.$container.parents().filter(Utils.hasScroll);
9393    $watchers.each(function () {
9394      $(this).data('select2-scroll-position', {
9395        x: $(this).scrollLeft(),
9396        y: $(this).scrollTop()
9397      });
9398    });
9399
9400    $watchers.on(scrollEvent, function (ev) {
9401      var position = $(this).data('select2-scroll-position');
9402      $(this).scrollTop(position.y);
9403    });
9404
9405    $(window).on(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent,
9406      function (e) {
9407      self._positionDropdown();
9408      self._resizeDropdown();
9409    });
9410  };
9411
9412  AttachBody.prototype._detachPositioningHandler =
9413      function (decorated, container) {
9414    var scrollEvent = 'scroll.select2.' + container.id;
9415    var resizeEvent = 'resize.select2.' + container.id;
9416    var orientationEvent = 'orientationchange.select2.' + container.id;
9417
9418    var $watchers = this.$container.parents().filter(Utils.hasScroll);
9419    $watchers.off(scrollEvent);
9420
9421    $(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent);
9422  };
9423
9424  AttachBody.prototype._positionDropdown = function () {
9425    var $window = $(window);
9426
9427    var isCurrentlyAbove = this.$dropdown.hasClass('select2-dropdown--above');
9428    var isCurrentlyBelow = this.$dropdown.hasClass('select2-dropdown--below');
9429
9430    var newDirection = null;
9431
9432    var offset = this.$container.offset();
9433
9434    offset.bottom = offset.top + this.$container.outerHeight(false);
9435
9436    var container = {
9437      height: this.$container.outerHeight(false)
9438    };
9439
9440    container.top = offset.top;
9441    container.bottom = offset.top + container.height;
9442
9443    var dropdown = {
9444      height: this.$dropdown.outerHeight(false)
9445    };
9446
9447    var viewport = {
9448      top: $window.scrollTop(),
9449      bottom: $window.scrollTop() + $window.height()
9450    };
9451
9452    var enoughRoomAbove = viewport.top < (offset.top - dropdown.height);
9453    var enoughRoomBelow = viewport.bottom > (offset.bottom + dropdown.height);
9454
9455    var css = {
9456      left: offset.left,
9457      top: container.bottom
9458    };
9459
9460    // Determine what the parent element is to use for calciulating the offset
9461    var $offsetParent = this.$dropdownParent;
9462
9463    // For statically positoned elements, we need to get the element
9464    // that is determining the offset
9465    if ($offsetParent.css('position') === 'static') {
9466      $offsetParent = $offsetParent.offsetParent();
9467    }
9468
9469    var parentOffset = $offsetParent.offset();
9470
9471    css.top -= parentOffset.top;
9472    css.left -= parentOffset.left;
9473
9474    if (!isCurrentlyAbove && !isCurrentlyBelow) {
9475      newDirection = 'below';
9476    }
9477
9478    if (!enoughRoomBelow && enoughRoomAbove && !isCurrentlyAbove) {
9479      newDirection = 'above';
9480    } else if (!enoughRoomAbove && enoughRoomBelow && isCurrentlyAbove) {
9481      newDirection = 'below';
9482    }
9483
9484    if (newDirection == 'above' ||
9485      (isCurrentlyAbove && newDirection !== 'below')) {
9486      css.top = container.top - parentOffset.top - dropdown.height;
9487    }
9488
9489    if (newDirection != null) {
9490      this.$dropdown
9491        .removeClass('select2-dropdown--below select2-dropdown--above')
9492        .addClass('select2-dropdown--' + newDirection);
9493      this.$container
9494        .removeClass('select2-container--below select2-container--above')
9495        .addClass('select2-container--' + newDirection);
9496    }
9497
9498    this.$dropdownContainer.css(css);
9499  };
9500
9501  AttachBody.prototype._resizeDropdown = function () {
9502    var css = {
9503      width: this.$container.outerWidth(false) + 'px'
9504    };
9505
9506    if (this.options.get('dropdownAutoWidth')) {
9507      css.minWidth = css.width;
9508      css.position = 'relative';
9509      css.width = 'auto';
9510    }
9511
9512    this.$dropdown.css(css);
9513  };
9514
9515  AttachBody.prototype._showDropdown = function (decorated) {
9516    this.$dropdownContainer.appendTo(this.$dropdownParent);
9517
9518    this._positionDropdown();
9519    this._resizeDropdown();
9520  };
9521
9522  return AttachBody;
9523});
9524
9525S2.define('select2/dropdown/minimumResultsForSearch',[
9526
9527], function () {
9528  function countResults (data) {
9529    var count = 0;
9530
9531    for (var d = 0; d < data.length; d++) {
9532      var item = data[d];
9533
9534      if (item.children) {
9535        count += countResults(item.children);
9536      } else {
9537        count++;
9538      }
9539    }
9540
9541    return count;
9542  }
9543
9544  function MinimumResultsForSearch (decorated, $element, options, dataAdapter) {
9545    this.minimumResultsForSearch = options.get('minimumResultsForSearch');
9546
9547    if (this.minimumResultsForSearch < 0) {
9548      this.minimumResultsForSearch = Infinity;
9549    }
9550
9551    decorated.call(this, $element, options, dataAdapter);
9552  }
9553
9554  MinimumResultsForSearch.prototype.showSearch = function (decorated, params) {
9555    if (countResults(params.data.results) < this.minimumResultsForSearch) {
9556      return false;
9557    }
9558
9559    return decorated.call(this, params);
9560  };
9561
9562  return MinimumResultsForSearch;
9563});
9564
9565S2.define('select2/dropdown/selectOnClose',[
9566
9567], function () {
9568  function SelectOnClose () { }
9569
9570  SelectOnClose.prototype.bind = function (decorated, container, $container) {
9571    var self = this;
9572
9573    decorated.call(this, container, $container);
9574
9575    container.on('close', function (params) {
9576      self._handleSelectOnClose(params);
9577    });
9578  };
9579
9580  SelectOnClose.prototype._handleSelectOnClose = function (_, params) {
9581    if (params && params.originalSelect2Event != null) {
9582      var event = params.originalSelect2Event;
9583
9584      // Don't select an item if the close event was triggered from a select or
9585      // unselect event
9586      if (event._type === 'select' || event._type === 'unselect') {
9587        return;
9588      }
9589    }
9590
9591    var $highlightedResults = this.getHighlightedResults();
9592
9593    // Only select highlighted results
9594    if ($highlightedResults.length < 1) {
9595      return;
9596    }
9597
9598    var data = $highlightedResults.data('data');
9599
9600    // Don't re-select already selected resulte
9601    if (
9602      (data.element != null && data.element.selected) ||
9603      (data.element == null && data.selected)
9604    ) {
9605      return;
9606    }
9607
9608    this.trigger('select', {
9609        data: data
9610    });
9611  };
9612
9613  return SelectOnClose;
9614});
9615
9616S2.define('select2/dropdown/closeOnSelect',[
9617
9618], function () {
9619  function CloseOnSelect () { }
9620
9621  CloseOnSelect.prototype.bind = function (decorated, container, $container) {
9622    var self = this;
9623
9624    decorated.call(this, container, $container);
9625
9626    container.on('select', function (evt) {
9627      self._selectTriggered(evt);
9628    });
9629
9630    container.on('unselect', function (evt) {
9631      self._selectTriggered(evt);
9632    });
9633  };
9634
9635  CloseOnSelect.prototype._selectTriggered = function (_, evt) {
9636    var originalEvent = evt.originalEvent;
9637
9638    // Don't close if the control key is being held
9639    if (originalEvent && originalEvent.ctrlKey) {
9640      return;
9641    }
9642
9643    this.trigger('close', {
9644      originalEvent: originalEvent,
9645      originalSelect2Event: evt
9646    });
9647  };
9648
9649  return CloseOnSelect;
9650});
9651
9652S2.define('select2/i18n/en',[],function () {
9653  // English
9654  return {
9655    errorLoading: function () {
9656      return 'The results could not be loaded.';
9657    },
9658    inputTooLong: function (args) {
9659      var overChars = args.input.length - args.maximum;
9660
9661      var message = 'Please delete ' + overChars + ' character';
9662
9663      if (overChars != 1) {
9664        message += 's';
9665      }
9666
9667      return message;
9668    },
9669    inputTooShort: function (args) {
9670      var remainingChars = args.minimum - args.input.length;
9671
9672      var message = 'Please enter ' + remainingChars + ' or more characters';
9673
9674      return message;
9675    },
9676    loadingMore: function () {
9677      return 'Loading more results…';
9678    },
9679    maximumSelected: function (args) {
9680      var message = 'You can only select ' + args.maximum + ' item';
9681
9682      if (args.maximum != 1) {
9683        message += 's';
9684      }
9685
9686      return message;
9687    },
9688    noResults: function () {
9689      return 'No results found';
9690    },
9691    searching: function () {
9692      return 'Searching…';
9693    }
9694  };
9695});
9696
9697S2.define('select2/defaults',[
9698  'jquery',
9699  'require',
9700
9701  './results',
9702
9703  './selection/single',
9704  './selection/multiple',
9705  './selection/placeholder',
9706  './selection/allowClear',
9707  './selection/search',
9708  './selection/eventRelay',
9709
9710  './utils',
9711  './translation',
9712  './diacritics',
9713
9714  './data/select',
9715  './data/array',
9716  './data/ajax',
9717  './data/tags',
9718  './data/tokenizer',
9719  './data/minimumInputLength',
9720  './data/maximumInputLength',
9721  './data/maximumSelectionLength',
9722
9723  './dropdown',
9724  './dropdown/search',
9725  './dropdown/hidePlaceholder',
9726  './dropdown/infiniteScroll',
9727  './dropdown/attachBody',
9728  './dropdown/minimumResultsForSearch',
9729  './dropdown/selectOnClose',
9730  './dropdown/closeOnSelect',
9731
9732  './i18n/en'
9733], function ($, require,
9734
9735             ResultsList,
9736
9737             SingleSelection, MultipleSelection, Placeholder, AllowClear,
9738             SelectionSearch, EventRelay,
9739
9740             Utils, Translation, DIACRITICS,
9741
9742             SelectData, ArrayData, AjaxData, Tags, Tokenizer,
9743             MinimumInputLength, MaximumInputLength, MaximumSelectionLength,
9744
9745             Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll,
9746             AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect,
9747
9748             EnglishTranslation) {
9749  function Defaults () {
9750    this.reset();
9751  }
9752
9753  Defaults.prototype.apply = function (options) {
9754    options = $.extend(true, {}, this.defaults, options);
9755
9756    if (options.dataAdapter == null) {
9757      if (options.ajax != null) {
9758        options.dataAdapter = AjaxData;
9759      } else if (options.data != null) {
9760        options.dataAdapter = ArrayData;
9761      } else {
9762        options.dataAdapter = SelectData;
9763      }
9764
9765      if (options.minimumInputLength > 0) {
9766        options.dataAdapter = Utils.Decorate(
9767          options.dataAdapter,
9768          MinimumInputLength
9769        );
9770      }
9771
9772      if (options.maximumInputLength > 0) {
9773        options.dataAdapter = Utils.Decorate(
9774          options.dataAdapter,
9775          MaximumInputLength
9776        );
9777      }
9778
9779      if (options.maximumSelectionLength > 0) {
9780        options.dataAdapter = Utils.Decorate(
9781          options.dataAdapter,
9782          MaximumSelectionLength
9783        );
9784      }
9785
9786      if (options.tags) {
9787        options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags);
9788      }
9789
9790      if (options.tokenSeparators != null || options.tokenizer != null) {
9791        options.dataAdapter = Utils.Decorate(
9792          options.dataAdapter,
9793          Tokenizer
9794        );
9795      }
9796
9797      if (options.query != null) {
9798        var Query = require(options.amdBase + 'compat/query');
9799
9800        options.dataAdapter = Utils.Decorate(
9801          options.dataAdapter,
9802          Query
9803        );
9804      }
9805
9806      if (options.initSelection != null) {
9807        var InitSelection = require(options.amdBase + 'compat/initSelection');
9808
9809        options.dataAdapter = Utils.Decorate(
9810          options.dataAdapter,
9811          InitSelection
9812        );
9813      }
9814    }
9815
9816    if (options.resultsAdapter == null) {
9817      options.resultsAdapter = ResultsList;
9818
9819      if (options.ajax != null) {
9820        options.resultsAdapter = Utils.Decorate(
9821          options.resultsAdapter,
9822          InfiniteScroll
9823        );
9824      }
9825
9826      if (options.placeholder != null) {
9827        options.resultsAdapter = Utils.Decorate(
9828          options.resultsAdapter,
9829          HidePlaceholder
9830        );
9831      }
9832
9833      if (options.selectOnClose) {
9834        options.resultsAdapter = Utils.Decorate(
9835          options.resultsAdapter,
9836          SelectOnClose
9837        );
9838      }
9839    }
9840
9841    if (options.dropdownAdapter == null) {
9842      if (options.multiple) {
9843        options.dropdownAdapter = Dropdown;
9844      } else {
9845        var SearchableDropdown = Utils.Decorate(Dropdown, DropdownSearch);
9846
9847        options.dropdownAdapter = SearchableDropdown;
9848      }
9849
9850      if (options.minimumResultsForSearch !== 0) {
9851        options.dropdownAdapter = Utils.Decorate(
9852          options.dropdownAdapter,
9853          MinimumResultsForSearch
9854        );
9855      }
9856
9857      if (options.closeOnSelect) {
9858        options.dropdownAdapter = Utils.Decorate(
9859          options.dropdownAdapter,
9860          CloseOnSelect
9861        );
9862      }
9863
9864      if (
9865        options.dropdownCssClass != null ||
9866        options.dropdownCss != null ||
9867        options.adaptDropdownCssClass != null
9868      ) {
9869        var DropdownCSS = require(options.amdBase + 'compat/dropdownCss');
9870
9871        options.dropdownAdapter = Utils.Decorate(
9872          options.dropdownAdapter,
9873          DropdownCSS
9874        );
9875      }
9876
9877      options.dropdownAdapter = Utils.Decorate(
9878        options.dropdownAdapter,
9879        AttachBody
9880      );
9881    }
9882
9883    if (options.selectionAdapter == null) {
9884      if (options.multiple) {
9885        options.selectionAdapter = MultipleSelection;
9886      } else {
9887        options.selectionAdapter = SingleSelection;
9888      }
9889
9890      // Add the placeholder mixin if a placeholder was specified
9891      if (options.placeholder != null) {
9892        options.selectionAdapter = Utils.Decorate(
9893          options.selectionAdapter,
9894          Placeholder
9895        );
9896      }
9897
9898      if (options.allowClear) {
9899        options.selectionAdapter = Utils.Decorate(
9900          options.selectionAdapter,
9901          AllowClear
9902        );
9903      }
9904
9905      if (options.multiple) {
9906        options.selectionAdapter = Utils.Decorate(
9907          options.selectionAdapter,
9908          SelectionSearch
9909        );
9910      }
9911
9912      if (
9913        options.containerCssClass != null ||
9914        options.containerCss != null ||
9915        options.adaptContainerCssClass != null
9916      ) {
9917        var ContainerCSS = require(options.amdBase + 'compat/containerCss');
9918
9919        options.selectionAdapter = Utils.Decorate(
9920          options.selectionAdapter,
9921          ContainerCSS
9922        );
9923      }
9924
9925      options.selectionAdapter = Utils.Decorate(
9926        options.selectionAdapter,
9927        EventRelay
9928      );
9929    }
9930
9931    if (typeof options.language === 'string') {
9932      // Check if the language is specified with a region
9933      if (options.language.indexOf('-') > 0) {
9934        // Extract the region information if it is included
9935        var languageParts = options.language.split('-');
9936        var baseLanguage = languageParts[0];
9937
9938        options.language = [options.language, baseLanguage];
9939      } else {
9940        options.language = [options.language];
9941      }
9942    }
9943
9944    if ($.isArray(options.language)) {
9945      var languages = new Translation();
9946      options.language.push('en');
9947
9948      var languageNames = options.language;
9949
9950      for (var l = 0; l < languageNames.length; l++) {
9951        var name = languageNames[l];
9952        var language = {};
9953
9954        try {
9955          // Try to load it with the original name
9956          language = Translation.loadPath(name);
9957        } catch (e) {
9958          try {
9959            // If we couldn't load it, check if it wasn't the full path
9960            name = this.defaults.amdLanguageBase + name;
9961            language = Translation.loadPath(name);
9962          } catch (ex) {
9963            // The translation could not be loaded at all. Sometimes this is
9964            // because of a configuration problem, other times this can be
9965            // because of how Select2 helps load all possible translation files.
9966            if (options.debug && window.console && console.warn) {
9967              console.warn(
9968                'Select2: The language file for "' + name + '" could not be ' +
9969                'automatically loaded. A fallback will be used instead.'
9970              );
9971            }
9972
9973            continue;
9974          }
9975        }
9976
9977        languages.extend(language);
9978      }
9979
9980      options.translations = languages;
9981    } else {
9982      var baseTranslation = Translation.loadPath(
9983        this.defaults.amdLanguageBase + 'en'
9984      );
9985      var customTranslation = new Translation(options.language);
9986
9987      customTranslation.extend(baseTranslation);
9988
9989      options.translations = customTranslation;
9990    }
9991
9992    return options;
9993  };
9994
9995  Defaults.prototype.reset = function () {
9996    function stripDiacritics (text) {
9997      // Used 'uni range + named function' from http://jsperf.com/diacritics/18
9998      function match(a) {
9999        return DIACRITICS[a] || a;
10000      }
10001
10002      return text.replace(/[^\u0000-\u007E]/g, match);
10003    }
10004
10005    function matcher (params, data) {
10006      // Always return the object if there is nothing to compare
10007      if ($.trim(params.term) === '') {
10008        return data;
10009      }
10010
10011      // Do a recursive check for options with children
10012      if (data.children && data.children.length > 0) {
10013        // Clone the data object if there are children
10014        // This is required as we modify the object to remove any non-matches
10015        var match = $.extend(true, {}, data);
10016
10017        // Check each child of the option
10018        for (var c = data.children.length - 1; c >= 0; c--) {
10019          var child = data.children[c];
10020
10021          var matches = matcher(params, child);
10022
10023          // If there wasn't a match, remove the object in the array
10024          if (matches == null) {
10025            match.children.splice(c, 1);
10026          }
10027        }
10028
10029        // If any children matched, return the new object
10030        if (match.children.length > 0) {
10031          return match;
10032        }
10033
10034        // If there were no matching children, check just the plain object
10035        return matcher(params, match);
10036      }
10037
10038      var original = stripDiacritics(data.text).toUpperCase();
10039      var term = stripDiacritics(params.term).toUpperCase();
10040
10041      // Check if the text contains the term
10042      if (original.indexOf(term) > -1) {
10043        return data;
10044      }
10045
10046      // If it doesn't contain the term, don't return anything
10047      return null;
10048    }
10049
10050    this.defaults = {
10051      amdBase: './',
10052      amdLanguageBase: './i18n/',
10053      closeOnSelect: true,
10054      debug: false,
10055      dropdownAutoWidth: false,
10056      escapeMarkup: Utils.escapeMarkup,
10057      language: EnglishTranslation,
10058      matcher: matcher,
10059      minimumInputLength: 0,
10060      maximumInputLength: 0,
10061      maximumSelectionLength: 0,
10062      minimumResultsForSearch: 0,
10063      selectOnClose: false,
10064      sorter: function (data) {
10065        return data;
10066      },
10067      templateResult: function (result) {
10068        return result.text;
10069      },
10070      templateSelection: function (selection) {
10071        return selection.text;
10072      },
10073      theme: 'default',
10074      width: 'resolve'
10075    };
10076  };
10077
10078  Defaults.prototype.set = function (key, value) {
10079    var camelKey = $.camelCase(key);
10080
10081    var data = {};
10082    data[camelKey] = value;
10083
10084    var convertedData = Utils._convertData(data);
10085
10086    $.extend(this.defaults, convertedData);
10087  };
10088
10089  var defaults = new Defaults();
10090
10091  return defaults;
10092});
10093
10094S2.define('select2/options',[
10095  'require',
10096  'jquery',
10097  './defaults',
10098  './utils'
10099], function (require, $, Defaults, Utils) {
10100  function Options (options, $element) {
10101    this.options = options;
10102
10103    if ($element != null) {
10104      this.fromElement($element);
10105    }
10106
10107    this.options = Defaults.apply(this.options);
10108
10109    if ($element && $element.is('input')) {
10110      var InputCompat = require(this.get('amdBase') + 'compat/inputData');
10111
10112      this.options.dataAdapter = Utils.Decorate(
10113        this.options.dataAdapter,
10114        InputCompat
10115      );
10116    }
10117  }
10118
10119  Options.prototype.fromElement = function ($e) {
10120    var excludedData = ['select2'];
10121
10122    if (this.options.multiple == null) {
10123      this.options.multiple = $e.prop('multiple');
10124    }
10125
10126    if (this.options.disabled == null) {
10127      this.options.disabled = $e.prop('disabled');
10128    }
10129
10130    if (this.options.language == null) {
10131      if ($e.prop('lang')) {
10132        this.options.language = $e.prop('lang').toLowerCase();
10133      } else if ($e.closest('[lang]').prop('lang')) {
10134        this.options.language = $e.closest('[lang]').prop('lang');
10135      }
10136    }
10137
10138    if (this.options.dir == null) {
10139      if ($e.prop('dir')) {
10140        this.options.dir = $e.prop('dir');
10141      } else if ($e.closest('[dir]').prop('dir')) {
10142        this.options.dir = $e.closest('[dir]').prop('dir');
10143      } else {
10144        this.options.dir = 'ltr';
10145      }
10146    }
10147
10148    $e.prop('disabled', this.options.disabled);
10149    $e.prop('multiple', this.options.multiple);
10150
10151    if ($e.data('select2Tags')) {
10152      if (this.options.debug && window.console && console.warn) {
10153        console.warn(
10154          'Select2: The `data-select2-tags` attribute has been changed to ' +
10155          'use the `data-data` and `data-tags="true"` attributes and will be ' +
10156          'removed in future versions of Select2.'
10157        );
10158      }
10159
10160      $e.data('data', $e.data('select2Tags'));
10161      $e.data('tags', true);
10162    }
10163
10164    if ($e.data('ajaxUrl')) {
10165      if (this.options.debug && window.console && console.warn) {
10166        console.warn(
10167          'Select2: The `data-ajax-url` attribute has been changed to ' +
10168          '`data-ajax--url` and support for the old attribute will be removed' +
10169          ' in future versions of Select2.'
10170        );
10171      }
10172
10173      $e.attr('ajax--url', $e.data('ajaxUrl'));
10174      $e.data('ajax--url', $e.data('ajaxUrl'));
10175    }
10176
10177    var dataset = {};
10178
10179    // Prefer the element's `dataset` attribute if it exists
10180    // jQuery 1.x does not correctly handle data attributes with multiple dashes
10181    if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) {
10182      dataset = $.extend(true, {}, $e[0].dataset, $e.data());
10183    } else {
10184      dataset = $e.data();
10185    }
10186
10187    var data = $.extend(true, {}, dataset);
10188
10189    data = Utils._convertData(data);
10190
10191    for (var key in data) {
10192      if ($.inArray(key, excludedData) > -1) {
10193        continue;
10194      }
10195
10196      if ($.isPlainObject(this.options[key])) {
10197        $.extend(this.options[key], data[key]);
10198      } else {
10199        this.options[key] = data[key];
10200      }
10201    }
10202
10203    return this;
10204  };
10205
10206  Options.prototype.get = function (key) {
10207    return this.options[key];
10208  };
10209
10210  Options.prototype.set = function (key, val) {
10211    this.options[key] = val;
10212  };
10213
10214  return Options;
10215});
10216
10217S2.define('select2/core',[
10218  'jquery',
10219  './options',
10220  './utils',
10221  './keys'
10222], function ($, Options, Utils, KEYS) {
10223  var Select2 = function ($element, options) {
10224    if ($element.data('select2') != null) {
10225      $element.data('select2').destroy();
10226    }
10227
10228    this.$element = $element;
10229
10230    this.id = this._generateId($element);
10231
10232    options = options || {};
10233
10234    this.options = new Options(options, $element);
10235
10236    Select2.__super__.constructor.call(this);
10237
10238    // Set up the tabindex
10239
10240    var tabindex = $element.attr('tabindex') || 0;
10241    $element.data('old-tabindex', tabindex);
10242    $element.attr('tabindex', '-1');
10243
10244    // Set up containers and adapters
10245
10246    var DataAdapter = this.options.get('dataAdapter');
10247    this.dataAdapter = new DataAdapter($element, this.options);
10248
10249    var $container = this.render();
10250
10251    this._placeContainer($container);
10252
10253    var SelectionAdapter = this.options.get('selectionAdapter');
10254    this.selection = new SelectionAdapter($element, this.options);
10255    this.$selection = this.selection.render();
10256
10257    this.selection.position(this.$selection, $container);
10258
10259    var DropdownAdapter = this.options.get('dropdownAdapter');
10260    this.dropdown = new DropdownAdapter($element, this.options);
10261    this.$dropdown = this.dropdown.render();
10262
10263    this.dropdown.position(this.$dropdown, $container);
10264
10265    var ResultsAdapter = this.options.get('resultsAdapter');
10266    this.results = new ResultsAdapter($element, this.options, this.dataAdapter);
10267    this.$results = this.results.render();
10268
10269    this.results.position(this.$results, this.$dropdown);
10270
10271    // Bind events
10272
10273    var self = this;
10274
10275    // Bind the container to all of the adapters
10276    this._bindAdapters();
10277
10278    // Register any DOM event handlers
10279    this._registerDomEvents();
10280
10281    // Register any internal event handlers
10282    this._registerDataEvents();
10283    this._registerSelectionEvents();
10284    this._registerDropdownEvents();
10285    this._registerResultsEvents();
10286    this._registerEvents();
10287
10288    // Set the initial state
10289    this.dataAdapter.current(function (initialData) {
10290      self.trigger('selection:update', {
10291        data: initialData
10292      });
10293    });
10294
10295    // Hide the original select
10296    $element.addClass('select2-hidden-accessible');
10297    $element.attr('aria-hidden', 'true');
10298
10299    // Synchronize any monitored attributes
10300    this._syncAttributes();
10301
10302    $element.data('select2', this);
10303  };
10304
10305  Utils.Extend(Select2, Utils.Observable);
10306
10307  Select2.prototype._generateId = function ($element) {
10308    var id = '';
10309
10310    if ($element.attr('id') != null) {
10311      id = $element.attr('id');
10312    } else if ($element.attr('name') != null) {
10313      id = $element.attr('name') + '-' + Utils.generateChars(2);
10314    } else {
10315      id = Utils.generateChars(4);
10316    }
10317
10318    id = id.replace(/(:|\.|\[|\]|,)/g, '');
10319    id = 'select2-' + id;
10320
10321    return id;
10322  };
10323
10324  Select2.prototype._placeContainer = function ($container) {
10325    $container.insertAfter(this.$element);
10326
10327    var width = this._resolveWidth(this.$element, this.options.get('width'));
10328
10329    if (width != null) {
10330      $container.css('width', width);
10331    }
10332  };
10333
10334  Select2.prototype._resolveWidth = function ($element, method) {
10335    var WIDTH = /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;
10336
10337    if (method == 'resolve') {
10338      var styleWidth = this._resolveWidth($element, 'style');
10339
10340      if (styleWidth != null) {
10341        return styleWidth;
10342      }
10343
10344      return this._resolveWidth($element, 'element');
10345    }
10346
10347    if (method == 'element') {
10348      var elementWidth = $element.outerWidth(false);
10349
10350      if (elementWidth <= 0) {
10351        return 'auto';
10352      }
10353
10354      return elementWidth + 'px';
10355    }
10356
10357    if (method == 'style') {
10358      var style = $element.attr('style');
10359
10360      if (typeof(style) !== 'string') {
10361        return null;
10362      }
10363
10364      var attrs = style.split(';');
10365
10366      for (var i = 0, l = attrs.length; i < l; i = i + 1) {
10367        var attr = attrs[i].replace(/\s/g, '');
10368        var matches = attr.match(WIDTH);
10369
10370        if (matches !== null && matches.length >= 1) {
10371          return matches[1];
10372        }
10373      }
10374
10375      return null;
10376    }
10377
10378    return method;
10379  };
10380
10381  Select2.prototype._bindAdapters = function () {
10382    this.dataAdapter.bind(this, this.$container);
10383    this.selection.bind(this, this.$container);
10384
10385    this.dropdown.bind(this, this.$container);
10386    this.results.bind(this, this.$container);
10387  };
10388
10389  Select2.prototype._registerDomEvents = function () {
10390    var self = this;
10391
10392    this.$element.on('change.select2', function () {
10393      self.dataAdapter.current(function (data) {
10394        self.trigger('selection:update', {
10395          data: data
10396        });
10397      });
10398    });
10399
10400    this.$element.on('focus.select2', function (evt) {
10401      self.trigger('focus', evt);
10402    });
10403
10404    this._syncA = Utils.bind(this._syncAttributes, this);
10405    this._syncS = Utils.bind(this._syncSubtree, this);
10406
10407    if (this.$element[0].attachEvent) {
10408      this.$element[0].attachEvent('onpropertychange', this._syncA);
10409    }
10410
10411    var observer = window.MutationObserver ||
10412      window.WebKitMutationObserver ||
10413      window.MozMutationObserver
10414    ;
10415
10416    if (observer != null) {
10417      this._observer = new observer(function (mutations) {
10418        $.each(mutations, self._syncA);
10419        $.each(mutations, self._syncS);
10420      });
10421      this._observer.observe(this.$element[0], {
10422        attributes: true,
10423        childList: true,
10424        subtree: false
10425      });
10426    } else if (this.$element[0].addEventListener) {
10427      this.$element[0].addEventListener(
10428        'DOMAttrModified',
10429        self._syncA,
10430        false
10431      );
10432      this.$element[0].addEventListener(
10433        'DOMNodeInserted',
10434        self._syncS,
10435        false
10436      );
10437      this.$element[0].addEventListener(
10438        'DOMNodeRemoved',
10439        self._syncS,
10440        false
10441      );
10442    }
10443  };
10444
10445  Select2.prototype._registerDataEvents = function () {
10446    var self = this;
10447
10448    this.dataAdapter.on('*', function (name, params) {
10449      self.trigger(name, params);
10450    });
10451  };
10452
10453  Select2.prototype._registerSelectionEvents = function () {
10454    var self = this;
10455    var nonRelayEvents = ['toggle', 'focus'];
10456
10457    this.selection.on('toggle', function () {
10458      self.toggleDropdown();
10459    });
10460
10461    this.selection.on('focus', function (params) {
10462      self.focus(params);
10463    });
10464
10465    this.selection.on('*', function (name, params) {
10466      if ($.inArray(name, nonRelayEvents) !== -1) {
10467        return;
10468      }
10469
10470      self.trigger(name, params);
10471    });
10472  };
10473
10474  Select2.prototype._registerDropdownEvents = function () {
10475    var self = this;
10476
10477    this.dropdown.on('*', function (name, params) {
10478      self.trigger(name, params);
10479    });
10480  };
10481
10482  Select2.prototype._registerResultsEvents = function () {
10483    var self = this;
10484
10485    this.results.on('*', function (name, params) {
10486      self.trigger(name, params);
10487    });
10488  };
10489
10490  Select2.prototype._registerEvents = function () {
10491    var self = this;
10492
10493    this.on('open', function () {
10494      self.$container.addClass('select2-container--open');
10495    });
10496
10497    this.on('close', function () {
10498      self.$container.removeClass('select2-container--open');
10499    });
10500
10501    this.on('enable', function () {
10502      self.$container.removeClass('select2-container--disabled');
10503    });
10504
10505    this.on('disable', function () {
10506      self.$container.addClass('select2-container--disabled');
10507    });
10508
10509    this.on('blur', function () {
10510      self.$container.removeClass('select2-container--focus');
10511    });
10512
10513    this.on('query', function (params) {
10514      if (!self.isOpen()) {
10515        self.trigger('open', {});
10516      }
10517
10518      this.dataAdapter.query(params, function (data) {
10519        self.trigger('results:all', {
10520          data: data,
10521          query: params
10522        });
10523      });
10524    });
10525
10526    this.on('query:append', function (params) {
10527      this.dataAdapter.query(params, function (data) {
10528        self.trigger('results:append', {
10529          data: data,
10530          query: params
10531        });
10532      });
10533    });
10534
10535    this.on('
vendor: 1,349 bytes, lines 10535-10587
10535keypress', function (evt) {
10536      var key = evt.which;
10537
10538      if (self.isOpen()) {
10539        if (key === KEYS.ESC || key === KEYS.TAB ||
10540            (key === KEYS.UP && evt.altKey)) {
10541          self.close();
10542
10543          evt.preventDefault();
10544        } else if (key === KEYS.ENTER) {
10545          self.trigger('results:select', {});
10546
10547          evt.preventDefault();
10548        } else if ((key === KEYS.SPACE && evt.ctrlKey)) {
10549          self.trigger('results:toggle', {});
10550
10551          evt.preventDefault();
10552        } else if (key === KEYS.UP) {
10553          self.trigger('results:previous', {});
10554
10555          evt.preventDefault();
10556        } else if (key === KEYS.DOWN) {
10557          self.trigger('results:next', {});
10558
10559          evt.preventDefault();
10560        }
10561      } else {
10562        if (key === KEYS.ENTER || key === KEYS.SPACE ||
10563            (key === KEYS.DOWN && evt.altKey)) {
10564          self.open();
10565
10566          evt.preventDefault();
10567        }
10568      }
10569    });
10570  };
10571
10572  Select2.prototype._syncAttributes = function () {
10573    this.options.set('disabled', this.$element.prop('disabled'));
10574
10575    if (this.options.get('disabled')) {
10576      if (this.isOpen()) {
10577        this.close();
10578      }
10579
10580      this.trigger('disable', {});
10581    } else {
10582      this.trigger('enable', {});
10583    }
10584  };
10585
10586  Select2.prototype._syncSubtree = function (evt, mutations) {
10587    var changed = false;
vendor: 9,610 bytes, lines 10588-10958
10588    var self = this;
10589
10590    // Ignore any mutation events raised for elements that aren't options or
10591    // optgroups. This handles the case when the select element is destroyed
10592    if (
10593      evt && evt.target && (
10594        evt.target.nodeName !== 'OPTION' && evt.target.nodeName !== 'OPTGROUP'
10595      )
10596    ) {
10597      return;
10598    }
10599
10600    if (!mutations) {
10601      // If mutation events aren't supported, then we can only assume that the
10602      // change affected the selections
10603      changed = true;
10604    } else if (mutations.addedNodes && mutations.addedNodes.length > 0) {
10605      for (var n = 0; n < mutations.addedNodes.length; n++) {
10606        var node = mutations.addedNodes[n];
10607
10608        if (node.selected) {
10609          changed = true;
10610        }
10611      }
10612    } else if (mutations.removedNodes && mutations.removedNodes.length > 0) {
10613      changed = true;
10614    }
10615
10616    // Only re-pull the data if we think there is a change
10617    if (changed) {
10618      this.dataAdapter.current(function (currentData) {
10619        self.trigger('selection:update', {
10620          data: currentData
10621        });
10622      });
10623    }
10624  };
10625
10626  /**
10627   * Override the trigger method to automatically trigger pre-events when
10628   * there are events that can be prevented.
10629   */
10630  Select2.prototype.trigger = function (name, args) {
10631    var actualTrigger = Select2.__super__.trigger;
10632    var preTriggerMap = {
10633      'open': 'opening',
10634      'close': 'closing',
10635      'select': 'selecting',
10636      'unselect': 'unselecting'
10637    };
10638
10639    if (args === undefined) {
10640      args = {};
10641    }
10642
10643    if (name in preTriggerMap) {
10644      var preTriggerName = preTriggerMap[name];
10645      var preTriggerArgs = {
10646        prevented: false,
10647        name: name,
10648        args: args
10649      };
10650
10651      actualTrigger.call(this, preTriggerName, preTriggerArgs);
10652
10653      if (preTriggerArgs.prevented) {
10654        args.prevented = true;
10655
10656        return;
10657      }
10658    }
10659
10660    actualTrigger.call(this, name, args);
10661  };
10662
10663  Select2.prototype.toggleDropdown = function () {
10664    if (this.options.get('disabled')) {
10665      return;
10666    }
10667
10668    if (this.isOpen()) {
10669      this.close();
10670    } else {
10671      this.open();
10672    }
10673  };
10674
10675  Select2.prototype.open = function () {
10676    if (this.isOpen()) {
10677      return;
10678    }
10679
10680    this.trigger('query', {});
10681  };
10682
10683  Select2.prototype.close = function () {
10684    if (!this.isOpen()) {
10685      return;
10686    }
10687
10688    this.trigger('close', {});
10689  };
10690
10691  Select2.prototype.isOpen = function () {
10692    return this.$container.hasClass('select2-container--open');
10693  };
10694
10695  Select2.prototype.hasFocus = function () {
10696    return this.$container.hasClass('select2-container--focus');
10697  };
10698
10699  Select2.prototype.focus = function (data) {
10700    // No need to re-trigger focus events if we are already focused
10701    if (this.hasFocus()) {
10702      return;
10703    }
10704
10705    this.$container.addClass('select2-container--focus');
10706    this.trigger('focus', {});
10707  };
10708
10709  Select2.prototype.enable = function (args) {
10710    if (this.options.get('debug') && window.console && console.warn) {
10711      console.warn(
10712        'Select2: The `select2("enable")` method has been deprecated and will' +
10713        ' be removed in later Select2 versions. Use $element.prop("disabled")' +
10714        ' instead.'
10715      );
10716    }
10717
10718    if (args == null || args.length === 0) {
10719      args = [true];
10720    }
10721
10722    var disabled = !args[0];
10723
10724    this.$element.prop('disabled', disabled);
10725  };
10726
10727  Select2.prototype.data = function () {
10728    if (this.options.get('debug') &&
10729        arguments.length > 0 && window.console && console.warn) {
10730      console.warn(
10731        'Select2: Data can no longer be set using `select2("data")`. You ' +
10732        'should consider setting the value instead using `$element.val()`.'
10733      );
10734    }
10735
10736    var data = [];
10737
10738    this.dataAdapter.current(function (currentData) {
10739      data = currentData;
10740    });
10741
10742    return data;
10743  };
10744
10745  Select2.prototype.val = function (args) {
10746    if (this.options.get('debug') && window.console && console.warn) {
10747      console.warn(
10748        'Select2: The `select2("val")` method has been deprecated and will be' +
10749        ' removed in later Select2 versions. Use $element.val() instead.'
10750      );
10751    }
10752
10753    if (args == null || args.length === 0) {
10754      return this.$element.val();
10755    }
10756
10757    var newVal = args[0];
10758
10759    if ($.isArray(newVal)) {
10760      newVal = $.map(newVal, function (obj) {
10761        return obj.toString();
10762      });
10763    }
10764
10765    this.$element.val(newVal).trigger('change');
10766  };
10767
10768  Select2.prototype.destroy = function () {
10769    this.$container.remove();
10770
10771    if (this.$element[0].detachEvent) {
10772      this.$element[0].detachEvent('onpropertychange', this._syncA);
10773    }
10774
10775    if (this._observer != null) {
10776      this._observer.disconnect();
10777      this._observer = null;
10778    } else if (this.$element[0].removeEventListener) {
10779      this.$element[0]
10780        .removeEventListener('DOMAttrModified', this._syncA, false);
10781      this.$element[0]
10782        .removeEventListener('DOMNodeInserted', this._syncS, false);
10783      this.$element[0]
10784        .removeEventListener('DOMNodeRemoved', this._syncS, false);
10785    }
10786
10787    this._syncA = null;
10788    this._syncS = null;
10789
10790    this.$element.off('.select2');
10791    this.$element.attr('tabindex', this.$element.data('old-tabindex'));
10792
10793    this.$element.removeClass('select2-hidden-accessible');
10794    this.$element.attr('aria-hidden', 'false');
10795    this.$element.removeData('select2');
10796
10797    this.dataAdapter.destroy();
10798    this.selection.destroy();
10799    this.dropdown.destroy();
10800    this.results.destroy();
10801
10802    this.dataAdapter = null;
10803    this.selection = null;
10804    this.dropdown = null;
10805    this.results = null;
10806  };
10807
10808  Select2.prototype.render = function () {
10809    var $container = $(
10810      '<span class="select2 select2-container">' +
10811        '<span class="selection"></span>' +
10812        '<span class="dropdown-wrapper" aria-hidden="true"></span>' +
10813      '</span>'
10814    );
10815
10816    $container.attr('dir', this.options.get('dir'));
10817
10818    this.$container = $container;
10819
10820    this.$container.addClass('select2-container--' + this.options.get('theme'));
10821
10822    $container.data('element', this.$element);
10823
10824    return $container;
10825  };
10826
10827  return Select2;
10828});
10829
10830S2.define('jquery-mousewheel',[
10831  'jquery'
10832], function ($) {
10833  // Used to shim jQuery.mousewheel for non-full builds.
10834  return $;
10835});
10836
10837S2.define('jquery.select2',[
10838  'jquery',
10839  'jquery-mousewheel',
10840
10841  './select2/core',
10842  './select2/defaults'
10843], function ($, _, Select2, Defaults) {
10844  if ($.fn.select2 == null) {
10845    // All methods that should return the element
10846    var thisMethods = ['open', 'close', 'destroy'];
10847
10848    $.fn.select2 = function (options) {
10849      options = options || {};
10850
10851      if (typeof options === 'object') {
10852        this.each(function () {
10853          var instanceOptions = $.extend(true, {}, options);
10854
10855          var instance = new Select2($(this), instanceOptions);
10856        });
10857
10858        return this;
10859      } else if (typeof options === 'string') {
10860        var ret;
10861        var args = Array.prototype.slice.call(arguments, 1);
10862
10863        this.each(function () {
10864          var instance = $(this).data('select2');
10865
10866          if (instance == null && window.console && console.error) {
10867            console.error(
10868              'The select2(\'' + options + '\') method was called on an ' +
10869              'element that is not using Select2.'
10870            );
10871          }
10872
10873          ret = instance[options].apply(instance, args);
10874        });
10875
10876        // Check if we should be returning `this`
10877        if ($.inArray(options, thisMethods) > -1) {
10878          return this;
10879        }
10880
10881        return ret;
10882      } else {
10883        throw new Error('Invalid arguments for Select2: ' + options);
10884      }
10885    };
10886  }
10887
10888  if ($.fn.select2.defaults == null) {
10889    $.fn.select2.defaults = Defaults;
10890  }
10891
10892  return Select2;
10893});
10894
10895  // Return the AMD loader configuration so it can be used outside of this file
10896  return {
10897    define: S2.define,
10898    require: S2.require
10899  };
10900}());
10901
10902  // Autoload the jQuery bindings
10903  // We know that all of the modules exist above this, so we're safe
10904  var select2 = S2.require('jquery.select2');
10905
10906  // Hold the AMD module references on the jQuery function that was just loaded
10907  // This allows Select2 to use the internal loader outside of this file, such
10908  // as in the language files.
10909  jQuery.fn.select2.amd = S2;
10910
10911  // Return the Select2 instance for anyone who is importing it.
10912  return select2;
10913}));
10914
10915
10916// Custom JS for the Footer.
10917// ----------------------------------------------------------------------------
10918
10919// Document Ready.
10920// -------------------------------------
10921jQuery(function($) {
10922
10923    // Initialize Foundation JS if it has
10924    // been included in the document.
10925    // -------------------------------------
10926    if (window.Foundation !== undefined) {
10927        $(document).foundation();
10928    }
10929
10930    // Initialise matchHeight.
10931    // -------------------------------------
10932    $('.article-card .entry-title').matchHeight({
10933        property: 'min-height'
10934    });
10935
10936    $('.article-card .entry-summary').matchHeight({
10937        property: 'min-height'
10938    });
10939
10940    $('.article-card .featured').matchHeight({
10941        property: 'min-height'
10942    });
10943
10944    $('.author-profile-headshot, .author-profile-content').matchHeight({
10945        property: 'min-height'
10946    });
10947
10948    $('.testimonials-headshot, .testimonials-content').matchHeight({
10949        property: 'min-height'
10950    });
10951
10952    // Initialise Slick Carousels.
10953    // -------------------------------------
10954    function slickInit(target, autoplay, autoplaySpeed, speed, fade, arrows, dots, show, prev, next) {
10955        $(target).slick({
10956            accessibility: true,
10957            arrows: arrows,
10958            autoplay: autoplay,
10959            autoplaySpeed: autoplaySpeed,
10960            cssEase: 'ease-in-out',
10961            dots: dots,
10962            fade: fade,
10963            prevArrow: prev,
10964            nextArrow: next,
10965            slidesToShow: show,
10966            speed: speed
10967        });
10968    }
10969
10970    // Slick: Client Testimonials.
10971    // -------------------------------------
10972    var clientTestimonials = $('#testimonials-carousel .inner');
10973
10974    if (clientTestimonials.length > 0) {
10975        slickInit(clientTestimonials, true, 6000, 750, true, true, true, 1, '#testimonials-carousel-prev', '#testimonials-carousel-next');
10976    }
10977
10978    // Slick: Clients Grid
10979    // -------------------------------------
10980    if (Modernizr.mq('screen and (max-width: 767px)')) {
10981        var clientsGrid = $('#clients-grid .inner');
10982
10983        if (clientsGrid.length > 0) {
10984            slickInit(clientsGrid, true, 3000, 750, true, true, false, 1, '#clients-grid-prev', '#clients-grid-next');
10985        }
10986    }
10987
10988    // Slick: Areas of Expertise Menu
10989    // -------------------------------------
10990    if (Modernizr.mq('screen and (max-width: 767px)')) {
10991        var areasExpertise = $('#expertise-nav-menu');
10992
10993        if (areasExpertise.length > 0) {
10994            slickInit(areasExpertise, true, 3000, 500, true, false, true, 1);
10995        }
10996    }
10997
10998    // Toggle search.
10999    // -------------------------------------
11000    var searchToggle = $('#search-toggle');
11001    var searchTarget = $('#search');
11002
11003    searchToggle.on('click', function(e) {
11004        searchTarget.fadeToggle();
11005
11006        var expanded = $(this).attr('aria-expanded');
11007
11008        if (expanded === 'true') {
11009            $(this).attr('aria-expanded', 'false');
11010            searchTarget.toggleClass('active');
11011            searchToggle.focus();
11012        } else {
11013            $(this).attr('aria-expanded', 'true');
11014            searchTarget.toggleClass('active');
11015            searchTarget.focus();
11016        }
11017    });
11018
11019    // Close search on click outside.
11020    // -------------------------------------
11021    $(document).click(function(event) {
11022
11023        var eventTarget  = event.target;
11024        var toggleTarget = '#search-toggle';
11025        var searchTarget = '#search';
11026
11027        if ( $(eventTarget).closest(toggleTarget).length === 0 && $(eventTarget).closest(searchTarget).length === 0 ) {
11028            $(searchTarget).fadeOut();
11029            $(toggleTarget).attr('aria-expanded', 'false');
11030        }
11031    });
11032
11033    // $(document).click(function(event) {
11034
11035    //     var eventTarget  = event.target;
11036    //     var toggleTarget = '.site-product-search-toggle';
11037    //     var searchTarget = '.site-product-search .product-search';
11038
11039    //     if ( $(eventTarget).closest(toggleTarget).length === 0 && $(eventTarget).closest(searchTarget).length === 0 ) {
11040    //     }
11041    // });
11042
11043    // Form ratings.
11044    // -------------------------------------
11045    var labels = $('.section-leave-testimonial .wpcf7-radio').find('label');
11046
11047    $('.section-leave-testimonial input[type="radio"]').change(function() {
11048
11049        var currentRating = $(this).val();
11050
11051        labels.removeClass('solid');
11052
11053        labels.each(function(i, el) {
11054            var tmpRating = $(labels[i]).find('input').val();
11055
11056            if (tmpRating <= currentRating) {
11057                $(labels[i]).addClass('solid');
11058            }
11059        });
11060
11061    });
11062
11063    // Archive widget dropdown
11064    // -------------------------------------
11065    $('.widget_archive select').select2({
11066        minimumResultsForSearch: Infinity
11067    });
11068
11069    // Add toggles for footer widgets,
11070    // progressively enchanced for JS.
11071    // -------------------------------------
11072
11073    $('.footer-sidebar .widget_nav_menu h4, .footer-sidebar .widget_recent_entries h4').each(function(index, el) {
11074
11075        var toggleText = $(this).text();
11076        var toggleIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256"><path d="M38.399 76.8c1.637 0 3.274.625 4.524 1.875l85.075 85.076 85.075-85.076c2.5-2.5 6.55-2.5 9.05 0s2.5 6.55 0 9.05l-89.6 89.601c-2.5 2.5-6.551 2.5-9.051 0l-89.6-89.601c-2.5-2.5-2.5-6.55 0-9.05 1.252-1.25 2.89-1.875 4.527-1.875z"/></svg>';
11077        var toggleMarkup = '<button type="button" class="footer-widget-toggle" aria-expanded="false">' + toggleText + ' ' + toggleIcon + '</button>';
11078
11079        $(this).after(toggleMarkup);
11080    });
11081
11082    $('.footer-widget-toggle').on('click', function(e) {
11083
11084        $(this).closest('.footer-sidebar').find('ul').slideUp();
11085
11086        var expanded = $(this).attr('aria-expanded');
11087
11088        if (expanded === 'true') {
11089            $(this).attr('aria-expanded', 'false');
11090            $(this).parent().find('ul').slideToggle('slow');
11091            $(this).focus();
11092        } else {
11093            $(this).closest('.footer-sidebar').find('.footer-widget-toggle').attr('aria-expanded', 'false');
11094            $(this).attr('aria-expanded', 'true');
11095            $(this).parent().find('ul').slideToggle('slow').focus();
11096        }
11097
11098    });
11099
11100    // Handle mobile menu behaviour where
11101    // menu items with a sub-menu expand and
11102    // collapse.
11103    // -------------------------------------
11104    $('.primary-menu > .menu-item-has-children > a').attr('aria-expanded', 'false');
11105
11106    if (Modernizr.mq('screen and (max-width: 1079px)')) {
11107
11108        // Add the parent link to the sub-menu.
11109        $('.primary-menu .menu-item-has-children > a').each(function(i, el) {
11110            $(el).clone().prependTo($(el).siblings('ul')).wrap('<li class="parent-item" />');
11111        });
11112
11113        var navIcon = '<svg class="indicator" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256"><path d="M38.399 76.8c1.637 0 3.274.625 4.524 1.875l85.075 85.076 85.075-85.076c2.5-2.5 6.55-2.5 9.05 0s2.5 6.55 0 9.05l-89.6 89.601c-2.5 2.5-6.551 2.5-9.051 0l-89.6-89.601c-2.5-2.5-2.5-6.55 0-9.05 1.252-1.25 2.89-1.875 4.527-1.875z"/></svg>';
11114        $('.primary-menu .menu-item-has-children > a').append(navIcon);
11115
11116        // Top level menu items.
11117        $('.primary-menu > .menu-item-has-children > a').on('click', function(e) {
11118
11119            e.preventDefault();
11120
11121            var expanded = $(this).attr('aria-expanded');
11122
11123            if (expanded === 'true') {
11124                $(this).attr('aria-expanded', 'false');
11125                $(this).closest('.primary-menu').find('.sub-menu').slideUp();
11126                $(this).focus();
11127            } else {
11128                $(this).closest('.primary-menu').find('.menu-item-has-children > a').attr('aria-expanded', 'false');
11129                $(this).closest('.primary-menu').find('.sub-menu').slideUp();
11130                $(this).attr('aria-expanded', 'true');
11131                $(this).parent().find('> .sub-menu').slideDown().focus();
11132            }
11133
11134            $('html, body').stop().animate({
11135                'scrollTop': $(this).offset().top,
11136            }, 500, 'swing');
11137        });
11138
11139        // Sub-menu items.
11140        $('.primary-menu .menu-item-has-children .menu-item-has-children > a').on('click', function(e) {
11141            e.preventDefault();
11142
11143            var expanded = $(this).attr('aria-expanded');
11144
11145            if (expanded === 'true') {
11146                $(this).attr('aria-expanded', 'false');
11147                $(this).parent().find('.sub-menu').slideUp();
11148                $(this).focus();
11149            } else {
11150                $(this).attr('aria-expanded', 'true');
11151                $(this).parent().find('.sub-menu').slideDown().focus();
11152            }
11153
11154        });
11155    }
11156}(jQuery));
11157
11158// Window Load.
11159// -------------------------------------
11160jQuery(window).load(function($) {
11161
11162
11163    if (Modernizr.mq('screen and (max-width: 1024px)')) {
11164
11165        $(".faux-background-video-wrapper").on( 'click', function() {
11166            $("#home-hero-header-bg-video")[0].play();
11167            console.log('Video is now playing...');
11168        });
11169        $(".faux-background-video-wrapper").click();
11170
11171    }
11172
11173    setTimeout(function() {
11174
11175        // Google Maps on contact template.
11176        // -------------------------------------
11177        function init_map(target, lat, lng, iconSrc) {
11178
11179            var map_styles = [{
11180                featureType: "poi",
11181                elementType: "labels",
11182                stylers: [
11183                    { visibility: "off" }
11184                ]
11185            }];
11186
11187            var map_options = {
11188                zoom: 17,
11189                scrollwheel: false,
11190                center: new google.maps.LatLng(lat, lng),
11191                clickableIcons: false,
11192                disableDefaultUI: true,
11193                styles: map_styles
11194            };
11195
11196            map = new google.maps.Map(document.getElementById(target), map_options);
11197
11198            marker = new google.maps.Marker({
11199                position: new google.maps.LatLng(lat, lng),
11200                map: map,
11201                icon: iconSrc,
11202                clickable: false
11203            });
11204        }
11205
11206        $('.contact-office-map-canvas').each(function(index, el) {
11207
11208            var target = $(this).attr('id');
11209            var lat = $(this).attr('data-lat');
11210            var lng = $(this).attr('data-lng');
11211            var icon = $(this).attr('data-icon-src');
11212
11213            google.maps.event.addDomListener(window, 'load', init_map(target, lat, lng, icon));
11214        });
11215
11216    }, 1500);
11217
11218}(jQuery));
11219
11220// Window Resize.
11221// -------------------------------------
11222jQuery(window).resize(function($) {
11223
11224});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.