text: /*
   * Toastr
   * Copyright 2012-2015
   * Authors: John Papa, Hans Fjällemark, and Tim Ferrell.
   * All Rights Reserved.
   * Use, reproduction, distribution, and modification of this code is subject to the terms and
   * conditions of the MIT license, available at http://www.opensource.org/licenses/mit-license.php
   *
   * ARIA Support: Greta Krafsig
   *
   * Project: https://github.com/CodeSeven/toastr
   */
  /* global define */
  (function (define) {
      define(['jquery'], function ($) {
          return (function () {
              var $container;
              var listener;
              var toastId = 0;
              var toastType = {
                  error: 'error',
                  info: 'info',
                  success: 'success',
                  warning: 'warning'
              };
  
              var toastr = {
                  clear: clear,
                  remove: remove,
                  error: error,
                  getContainer: getContainer,
                  info: info,
                  options: {},
                  subscribe: subscribe,
                  success: success,
                  version: '2.1.3',
                  warning: warning
              };
  
              var previousToast;
  
              return toastr;
  
              ////////////////
  
              function error(message, title, optionsOverride) {
                  return notify({
                      type: toastType.error,
                      iconClass: getOptions().iconClasses.error,
                      message: message,
                      optionsOverride: optionsOverride,
                      title: title
                  });
              }
  
              function getContainer(options, create) {
                  if (!options) { options = getOptions(); }
                  $container = $('#' + options.containerId);
                  if ($container.length) {
                      return $container;
                  }
                  if (create) {
                      $container = createContainer(options);
                  }
                  return $container;
              }
  
              function info(message, title, optionsOverride) {
                  return notify({
                      type: toastType.info,
                      iconClass: getOptions().iconClasses.info,
                      message: message,
                      optionsOverride: optionsOverride,
                      title: title
                  });
              }
  
              function subscribe(callback) {
                  listener = callback;
              }
  
              function success(message, title, optionsOverride) {
                  return notify({
                      type: toastType.success,
                      iconClass: getOptions().iconClasses.success,
                      message: message,
                      optionsOverride: optionsOverride,
                      title: title
                  });
              }
  
              function warning(message, title, optionsOverride) {
                  return notify({
                      type: toastType.warning,
                      iconClass: getOptions().iconClasses.warning,
                      message: message,
                      optionsOverride: optionsOverride,
                      title: title
                  });
              }
  
              function clear($toastElement, clearOptions) {
                  var options = getOptions();
                  if (!$container) { getContainer(options); }
                  if (!clearToast($toastElement, options, clearOptions)) {
                      clearContainer(options);
                  }
              }
  
              function remove($toastElement) {
                  var options = getOptions();
                  if (!$container) { getContainer(options); }
                  if ($toastElement && $(':focus', $toastElement).length === 0) {
                      removeToast($toastElement);
                      return;
                  }
                  if ($container.children().length) {
                      $container.remove();
                  }
              }
  
              // internal functions
  
              function clearContainer (options) {
                  var toastsToClear = $container.children();
                  for (var i = toastsToClear.length - 1; i >= 0; i--) {
                      clearToast($(toastsToClear[i]), options);
                  }
              }
  
              function clearToast ($toastElement, options, clearOptions) {
                  var force = clearOptions && clearOptions.force ? clearOptions.force : false;
                  if ($toastElement && (force || $(':focus', $toastElement).length === 0)) {
                      $toastElement[options.hideMethod]({
                          duration: options.hideDuration,
                          easing: options.hideEasing,
                          complete: function () { removeToast($toastElement); }
                      });
                      return true;
                  }
                  return false;
              }
  
              function createContainer(options) {
                  $container = $('<div/>')
                      .attr('id', options.containerId)
                      .addClass(options.positionClass);
  
                  $container.appendTo($(options.target));
                  return $container;
              }
  
              function getDefaults() {
                  return {
                      tapToDismiss: true,
                      toastClass: 'toast',
                      containerId: 'toast-container',
                      debug: false,
  
                      showMethod: 'fadeIn', //fadeIn, slideDown, and show are built into jQuery
                      showDuration: 300,
                      showEasing: 'swing', //swing and linear are built into jQuery
                      onShown: undefined,
                      hideMethod: 'fadeOut',
                      hideDuration: 1000,
                      hideEasing: 'swing',
                      onHidden: undefined,
                      closeMethod: false,
                      closeDuration: false,
                      closeEasing: false,
                      closeOnHover: true,
  
                      extendedTimeOut: 1000,
                      iconClasses: {
                          error: 'toast-error',
                          info: 'toast-info',
                          success: 'toast-success',
                          warning: 'toast-warning'
                      },
                      iconClass: 'toast-info',
                      positionClass: 'toast-top-right',
                      timeOut: 5000, // Set timeOut and extendedTimeOut to 0 to make it sticky
                      titleClass: 'toast-title',
                      messageClass: 'toast-message',
                      escapeHtml: false,
                      target: 'body',
                      closeHtml: '<button type="button">&times;</button>',
                      closeClass: 'toast-close-button',
                      newestOnTop: true,
                      preventDuplicates: false,
                      progressBar: false,
                      progressClass: 'toast-progress',
                      rtl: false
                  };
              }
  
              function publish(args) {
                  if (!listener) { return; }
                  listener(args);
              }
  
              function notify(map) {
                  var options = getOptions();
                  var iconClass = map.iconClass || options.iconClass;
  
                  if (typeof (map.optionsOverride) !== 'undefined') {
                      options = $.extend(options, map.optionsOverride);
                      iconClass = map.optionsOverride.iconClass || iconClass;
                  }
  
                  if (shouldExit(options, map)) { return; }
  
                  toastId++;
  
                  $container = getContainer(options, true);
  
                  var intervalId = null;
                  var $toastElement = $('<div/>');
                  var $titleElement = $('<div/>');
                  var $messageElement = $('<div/>');
                  var $progressElement = $('<div/>');
                  var $closeElement = $(options.closeHtml);
                  var progressBar = {
                      intervalId: null,
                      hideEta: null,
                      maxHideTime: null
                  };
                  var response = {
                      toastId: toastId,
                      state: 'visible',
                      startTime: new Date(),
                      options: options,
                      map: map
                  };
  
                  personalizeToast();
  
                  displayToast();
  
                  handleEvents();
  
                  publish(response);
  
                  if (options.debug && console) {
                      console.log(response);
                  }
  
                  return $toastElement;
  
                  function escapeHtml(source) {
                      if (source == null) {
                          source = '';
                      }
  
                      return source
                          .replace(/&/g, '&amp;')
                          .replace(/"/g, '&quot;')
                          .replace(/'/g, '&#39;')
                          .replace(/</g, '&lt;')
                          .replace(/>/g, '&gt;');
                  }
  
                  function personalizeToast() {
                      setIcon();
                      setTitle();
                      setMessage();
                      setCloseButton();
                      setProgressBar();
                      setRTL();
                      setSequence();
                      setAria();
                  }
  
                  function setAria() {
                      var ariaValue = '';
                      switch (map.iconClass) {
                          case 'toast-success':
                          case 'toast-info':
                              ariaValue =  'polite';
                              break;
                          default:
                              ariaValue = 'assertive';
                      }
                      $toastElement.attr('aria-live', ariaValue);
                  }
  
                  function handleEvents() {
                      if (options.closeOnHover) {
                          $toastElement.hover(stickAround, delayedHideToast);
                      }
  
                      if (!options.onclick && options.tapToDismiss) {
                          $toastElement.click(hideToast);
                      }
  
                      if (options.closeButton && $closeElement) {
                          $closeElement.click(function (event) {
                              if (event.stopPropagation) {
                                  event.stopPropagation();
                              } else if (event.cancelBubble !== undefined && event.cancelBubble !== true) {
                                  event.cancelBubble = true;
                              }
  
                              if (options.onCloseClick) {
                                  options.onCloseClick(event);
                              }
  
                              hideToast(true);
                          });
                      }
  
                      if (options.onclick) {
                          $toastElement.click(function (event) {
                              options.onclick(event);
                              hideToast();
                          });
                      }
                  }
  
                  function displayToast() {
                      $toastElement.hide();
  
                      $toastElement[options.showMethod](
                          {duration: options.showDuration, easing: options.showEasing, complete: options.onShown}
                      );
  
                      if (options.timeOut > 0) {
                          intervalId = setTimeout(hideToast, options.timeOut);
                          progressBar.maxHideTime = parseFloat(options.timeOut);
                          progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
                          if (options.progressBar) {
                              progressBar.intervalId = setInterval(updateProgress, 10);
                          }
                      }
                  }
  
                  function setIcon() {
                      if (map.iconClass) {
                          $toastElement.addClass(options.toastClass).addClass(iconClass);
                      }
                  }
  
                  function setSequence() {
                      if (options.newestOnTop) {
                          $container.prepend($toastElement);
                      } else {
                          $container.append($toastElement);
                      }
                  }
  
                  function setTitle() {
                      if (map.title) {
                          var suffix = map.title;
                          if (options.escapeHtml) {
                              suffix = escapeHtml(map.title);
                          }
                          $titleElement.append(suffix).addClass(options.titleClass);
                          $toastElement.append($titleElement);
                      }
                  }
  
                  function setMessage() {
                      if (map.message) {
                          var suffix = map.message;
                          if (options.escapeHtml) {
                              suffix = escapeHtml(map.message);
                          }
                          $messageElement.append(suffix).addClass(options.messageClass);
                          $toastElement.append($messageElement);
                      }
                  }
  
                  function setCloseButton() {
                      if (options.closeButton) {
                          $closeElement.addClass(options.closeClass).attr('role', 'button');
                          $toastElement.prepend($closeElement);
                      }
                  }
  
                  function setProgressBar() {
                      if (options.progressBar) {
                          $progressElement.addClass(options.progressClass);
                          $toastElement.prepend($progressElement);
                      }
                  }
  
                  function setRTL() {
                      if (options.rtl) {
                          $toastElement.addClass('rtl');
                      }
                  }
  
                  function shouldExit(options, map) {
                      if (options.preventDuplicates) {
                          if (map.message === previousToast) {
                              return true;
                          } else {
                              previousToast = map.message;
                          }
                      }
                      return false;
                  }
  
                  function hideToast(override) {
                      var method = override && options.closeMethod !== false ? options.closeMethod : options.hideMethod;
                      var duration = override && options.closeDuration !== false ?
                          options.closeDuration : options.hideDuration;
                      var easing = override && options.closeEasing !== false ? options.closeEasing : options.hideEasing;
                      if ($(':focus', $toastElement).length && !override) {
                          return;
                      }
                      clearTimeout(progressBar.intervalId);
                      return $toastElement[method]({
                          duration: duration,
                          easing: easing,
                          complete: function () {
                              removeToast($toastElement);
                              clearTimeout(intervalId);
                              if (options.onHidden && response.state !== 'hidden') {
                                  options.onHidden();
                              }
                              response.state = 'hidden';
                              response.endTime = new Date();
                              publish(response);
                          }
                      });
                  }
  
                  function delayedHideToast() {
                      if (options.timeOut > 0 || options.extendedTimeOut > 0) {
                          intervalId = setTimeout(hideToast, options.extendedTimeOut);
                          progressBar.maxHideTime = parseFloat(options.extendedTimeOut);
                          progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
                      }
                  }
  
                  function stickAround() {
                      clearTimeout(intervalId);
                      progressBar.hideEta = 0;
                      $toastElement.stop(true, true)[options.showMethod](
                          {duration: options.showDuration, easing: options.showEasing}
                      );
                  }
  
                  function updateProgress() {
                      var percentage = ((progressBar.hideEta - (new Date().getTime())) / progressBar.maxHideTime) * 100;
                      $progressElement.width(percentage + '%');
                  }
              }
  
              function getOptions() {
                  return $.extend({}, getDefaults(), toastr.options);
              }
  
              function removeToast($toastElement) {
                  if (!$container) { $container = getContainer(); }
                  if ($toastElement.is(':visible')) {
                      return;
                  }
                  $toastElement.remove();
                  $toastElement = null;
                  if ($container.children().length === 0) {
                      $container.remove();
                      previousToast = undefined;
                  }
              }
  
          })();
      });
  }(typeof define === 'function' && define.amd ? define : function (deps, factory) {
      if (typeof module !== 'undefined' && module.exports) { //Node
          module.exports = factory(require('jquery'));
      } else {
          window.toastr = factory(window.jQuery);
      }
  }));
  
  //! moment.js
  //! version : 2.11.2
  //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
  //! license : MIT
  //! momentjs.com
  !function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):a.moment=b()}(this,function(){"use strict";function a(){return Uc.apply(null,arguments)}function b(a){Uc=a}function c(a){return"[object Array]"===Object.prototype.toString.call(a)}function d(a){return a instanceof Date||"[object Date]"===Object.prototype.toString.call(a)}function e(a,b){var c,d=[];for(c=0;c<a.length;++c)d.push(b(a[c],c));return d}function f(a,b){return Object.prototype.hasOwnProperty.call(a,b)}function g(a,b){for(var c in b)f(b,c)&&(a[c]=b[c]);return f(b,"toString")&&(a.toString=b.toString),f(b,"valueOf")&&(a.valueOf=b.valueOf),a}function h(a,b,c,d){return Da(a,b,c,d,!0).utc()}function i(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function j(a){return null==a._pf&&(a._pf=i()),a._pf}function k(a){if(null==a._isValid){var b=j(a);a._isValid=!(isNaN(a._d.getTime())||!(b.overflow<0)||b.empty||b.invalidMonth||b.invalidWeekday||b.nullInput||b.invalidFormat||b.userInvalidated),a._strict&&(a._isValid=a._isValid&&0===b.charsLeftOver&&0===b.unusedTokens.length&&void 0===b.bigHour)}return a._isValid}function l(a){var b=h(NaN);return null!=a?g(j(b),a):j(b).userInvalidated=!0,b}function m(a){return void 0===a}function n(a,b){var c,d,e;if(m(b._isAMomentObject)||(a._isAMomentObject=b._isAMomentObject),m(b._i)||(a._i=b._i),m(b._f)||(a._f=b._f),m(b._l)||(a._l=b._l),m(b._strict)||(a._strict=b._strict),m(b._tzm)||(a._tzm=b._tzm),m(b._isUTC)||(a._isUTC=b._isUTC),m(b._offset)||(a._offset=b._offset),m(b._pf)||(a._pf=j(b)),m(b._locale)||(a._locale=b._locale),Wc.length>0)for(c in Wc)d=Wc[c],e=b[d],m(e)||(a[d]=e);return a}function o(b){n(this,b),this._d=new Date(null!=b._d?b._d.getTime():NaN),Xc===!1&&(Xc=!0,a.updateOffset(this),Xc=!1)}function p(a){return a instanceof o||null!=a&&null!=a._isAMomentObject}function q(a){return 0>a?Math.ceil(a):Math.floor(a)}function r(a){var b=+a,c=0;return 0!==b&&isFinite(b)&&(c=q(b)),c}function s(a,b,c){var d,e=Math.min(a.length,b.length),f=Math.abs(a.length-b.length),g=0;for(d=0;e>d;d++)(c&&a[d]!==b[d]||!c&&r(a[d])!==r(b[d]))&&g++;return g+f}function t(){}function u(a){return a?a.toLowerCase().replace("_","-"):a}function v(a){for(var b,c,d,e,f=0;f<a.length;){for(e=u(a[f]).split("-"),b=e.length,c=u(a[f+1]),c=c?c.split("-"):null;b>0;){if(d=w(e.slice(0,b).join("-")))return d;if(c&&c.length>=b&&s(e,c,!0)>=b-1)break;b--}f++}return null}function w(a){var b=null;if(!Yc[a]&&"undefined"!=typeof module&&module&&module.exports)try{b=Vc._abbr,require("./locale/"+a),x(b)}catch(c){}return Yc[a]}function x(a,b){var c;return a&&(c=m(b)?z(a):y(a,b),c&&(Vc=c)),Vc._abbr}function y(a,b){return null!==b?(b.abbr=a,Yc[a]=Yc[a]||new t,Yc[a].set(b),x(a),Yc[a]):(delete Yc[a],null)}function z(a){var b;if(a&&a._locale&&a._locale._abbr&&(a=a._locale._abbr),!a)return Vc;if(!c(a)){if(b=w(a))return b;a=[a]}return v(a)}function A(a,b){var c=a.toLowerCase();Zc[c]=Zc[c+"s"]=Zc[b]=a}function B(a){return"string"==typeof a?Zc[a]||Zc[a.toLowerCase()]:void 0}function C(a){var b,c,d={};for(c in a)f(a,c)&&(b=B(c),b&&(d[b]=a[c]));return d}function D(a){return a instanceof Function||"[object Function]"===Object.prototype.toString.call(a)}function E(b,c){return function(d){return null!=d?(G(this,b,d),a.updateOffset(this,c),this):F(this,b)}}function F(a,b){return a.isValid()?a._d["get"+(a._isUTC?"UTC":"")+b]():NaN}function G(a,b,c){a.isValid()&&a._d["set"+(a._isUTC?"UTC":"")+b](c)}function H(a,b){var c;if("object"==typeof a)for(c in a)this.set(c,a[c]);else if(a=B(a),D(this[a]))return this[a](b);return this}function I(a,b,c){var d=""+Math.abs(a),e=b-d.length,f=a>=0;return(f?c?"+":"":"-")+Math.pow(10,Math.max(0,e)).toString().substr(1)+d}function J(a,b,c,d){var e=d;"string"==typeof d&&(e=function(){return this[d]()}),a&&(bd[a]=e),b&&(bd[b[0]]=function(){return I(e.apply(this,arguments),b[1],b[2])}),c&&(bd[c]=function(){return this.localeData().ordinal(e.apply(this,arguments),a)})}function K(a){return a.match(/\[[\s\S]/)?a.replace(/^\[|\]$/g,""):a.replace(/\\/g,"")}function L(a){var b,c,d=a.match($c);for(b=0,c=d.length;c>b;b++)bd[d[b]]?d[b]=bd[d[b]]:d[b]=K(d[b]);return function(e){var f="";for(b=0;c>b;b++)f+=d[b]instanceof Function?d[b].call(e,a):d[b];return f}}function M(a,b){return a.isValid()?(b=N(b,a.localeData()),ad[b]=ad[b]||L(b),ad[b](a)):a.localeData().invalidDate()}function N(a,b){function c(a){return b.longDateFormat(a)||a}var d=5;for(_c.lastIndex=0;d>=0&&_c.test(a);)a=a.replace(_c,c),_c.lastIndex=0,d-=1;return a}function O(a,b,c){td[a]=D(b)?b:function(a,d){return a&&c?c:b}}function P(a,b){return f(td,a)?td[a](b._strict,b._locale):new RegExp(Q(a))}function Q(a){return R(a.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(a,b,c,d,e){return b||c||d||e}))}function R(a){return a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function S(a,b){var c,d=b;for("string"==typeof a&&(a=[a]),"number"==typeof b&&(d=function(a,c){c[b]=r(a)}),c=0;c<a.length;c++)ud[a[c]]=d}function T(a,b){S(a,function(a,c,d,e){d._w=d._w||{},b(a,d._w,d,e)})}function U(a,b,c){null!=b&&f(ud,a)&&ud[a](b,c._a,c,a)}function V(a,b){return new Date(Date.UTC(a,b+1,0)).getUTCDate()}function W(a,b){return c(this._months)?this._months[a.month()]:this._months[Ed.test(b)?"format":"standalone"][a.month()]}function X(a,b){return c(this._monthsShort)?this._monthsShort[a.month()]:this._monthsShort[Ed.test(b)?"format":"standalone"][a.month()]}function Y(a,b,c){var d,e,f;for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),d=0;12>d;d++){if(e=h([2e3,d]),c&&!this._longMonthsParse[d]&&(this._longMonthsParse[d]=new RegExp("^"+this.months(e,"").replace(".","")+"$","i"),this._shortMonthsParse[d]=new RegExp("^"+this.monthsShort(e,"").replace(".","")+"$","i")),c||this._monthsParse[d]||(f="^"+this.months(e,"")+"|^"+this.monthsShort(e,""),this._monthsParse[d]=new RegExp(f.replace(".",""),"i")),c&&"MMMM"===b&&this._longMonthsParse[d].test(a))return d;if(c&&"MMM"===b&&this._shortMonthsParse[d].test(a))return d;if(!c&&this._monthsParse[d].test(a))return d}}function Z(a,b){var c;return a.isValid()?"string"==typeof b&&(b=a.localeData().monthsParse(b),"number"!=typeof b)?a:(c=Math.min(a.date(),V(a.year(),b)),a._d["set"+(a._isUTC?"UTC":"")+"Month"](b,c),a):a}function $(b){return null!=b?(Z(this,b),a.updateOffset(this,!0),this):F(this,"Month")}function _(){return V(this.year(),this.month())}function aa(a){return this._monthsParseExact?(f(this,"_monthsRegex")||ca.call(this),a?this._monthsShortStrictRegex:this._monthsShortRegex):this._monthsShortStrictRegex&&a?this._monthsShortStrictRegex:this._monthsShortRegex}function ba(a){return this._monthsParseExact?(f(this,"_monthsRegex")||ca.call(this),a?this._monthsStrictRegex:this._monthsRegex):this._monthsStrictRegex&&a?this._monthsStrictRegex:this._monthsRegex}function ca(){function a(a,b){return b.length-a.length}var b,c,d=[],e=[],f=[];for(b=0;12>b;b++)c=h([2e3,b]),d.push(this.monthsShort(c,"")),e.push(this.months(c,"")),f.push(this.months(c,"")),f.push(this.monthsShort(c,""));for(d.sort(a),e.sort(a),f.sort(a),b=0;12>b;b++)d[b]=R(d[b]),e[b]=R(e[b]),f[b]=R(f[b]);this._monthsRegex=new RegExp("^("+f.join("|")+")","i"),this._monthsShortRegex=this._monthsRegex,this._monthsStrictRegex=new RegExp("^("+e.join("|")+")$","i"),this._monthsShortStrictRegex=new RegExp("^("+d.join("|")+")$","i")}function da(a){var b,c=a._a;return c&&-2===j(a).overflow&&(b=c[wd]<0||c[wd]>11?wd:c[xd]<1||c[xd]>V(c[vd],c[wd])?xd:c[yd]<0||c[yd]>24||24===c[yd]&&(0!==c[zd]||0!==c[Ad]||0!==c[Bd])?yd:c[zd]<0||c[zd]>59?zd:c[Ad]<0||c[Ad]>59?Ad:c[Bd]<0||c[Bd]>999?Bd:-1,j(a)._overflowDayOfYear&&(vd>b||b>xd)&&(b=xd),j(a)._overflowWeeks&&-1===b&&(b=Cd),j(a)._overflowWeekday&&-1===b&&(b=Dd),j(a).overflow=b),a}function ea(b){a.suppressDeprecationWarnings===!1&&"undefined"!=typeof console&&console.warn&&console.warn("Deprecation warning: "+b)}function fa(a,b){var c=!0;return g(function(){return c&&(ea(a+"\nArguments: "+Array.prototype.slice.call(arguments).join(", ")+"\n"+(new Error).stack),c=!1),b.apply(this,arguments)},b)}function ga(a,b){Jd[a]||(ea(b),Jd[a]=!0)}function ha(a){var b,c,d,e,f,g,h=a._i,i=Kd.exec(h)||Ld.exec(h);if(i){for(j(a).iso=!0,b=0,c=Nd.length;c>b;b++)if(Nd[b][1].exec(i[1])){e=Nd[b][0],d=Nd[b][2]!==!1;break}if(null==e)return void(a._isValid=!1);if(i[3]){for(b=0,c=Od.length;c>b;b++)if(Od[b][1].exec(i[3])){f=(i[2]||" ")+Od[b][0];break}if(null==f)return void(a._isValid=!1)}if(!d&&null!=f)return void(a._isValid=!1);if(i[4]){if(!Md.exec(i[4]))return void(a._isValid=!1);g="Z"}a._f=e+(f||"")+(g||""),wa(a)}else a._isValid=!1}function ia(b){var c=Pd.exec(b._i);return null!==c?void(b._d=new Date(+c[1])):(ha(b),void(b._isValid===!1&&(delete b._isValid,a.createFromInputFallback(b))))}function ja(a,b,c,d,e,f,g){var h=new Date(a,b,c,d,e,f,g);return 100>a&&a>=0&&isFinite(h.getFullYear())&&h.setFullYear(a),h}function ka(a){var b=new Date(Date.UTC.apply(null,arguments));return 100>a&&a>=0&&isFinite(b.getUTCFullYear())&&b.setUTCFullYear(a),b}function la(a){return ma(a)?366:365}function ma(a){return a%4===0&&a%100!==0||a%400===0}function na(){return ma(this.year())}function oa(a,b,c){var d=7+b-c,e=(7+ka(a,0,d).getUTCDay()-b)%7;return-e+d-1}function pa(a,b,c,d,e){var f,g,h=(7+c-d)%7,i=oa(a,d,e),j=1+7*(b-1)+h+i;return 0>=j?(f=a-1,g=la(f)+j):j>la(a)?(f=a+1,g=j-la(a)):(f=a,g=j),{year:f,dayOfYear:g}}function qa(a,b,c){var d,e,f=oa(a.year(),b,c),g=Math.floor((a.dayOfYear()-f-1)/7)+1;return 1>g?(e=a.year()-1,d=g+ra(e,b,c)):g>ra(a.year(),b,c)?(d=g-ra(a.year(),b,c),e=a.year()+1):(e=a.year(),d=g),{week:d,year:e}}function ra(a,b,c){var d=oa(a,b,c),e=oa(a+1,b,c);return(la(a)-d+e)/7}function sa(a,b,c){return null!=a?a:null!=b?b:c}function ta(b){var c=new Date(a.now());return b._useUTC?[c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()]:[c.getFullYear(),c.getMonth(),c.getDate()]}function ua(a){var b,c,d,e,f=[];if(!a._d){for(d=ta(a),a._w&&null==a._a[xd]&&null==a._a[wd]&&va(a),a._dayOfYear&&(e=sa(a._a[vd],d[vd]),a._dayOfYear>la(e)&&(j(a)._overflowDayOfYear=!0),c=ka(e,0,a._dayOfYear),a._a[wd]=c.getUTCMonth(),a._a[xd]=c.getUTCDate()),b=0;3>b&&null==a._a[b];++b)a._a[b]=f[b]=d[b];for(;7>b;b++)a._a[b]=f[b]=null==a._a[b]?2===b?1:0:a._a[b];24===a._a[yd]&&0===a._a[zd]&&0===a._a[Ad]&&0===a._a[Bd]&&(a._nextDay=!0,a._a[yd]=0),a._d=(a._useUTC?ka:ja).apply(null,f),null!=a._tzm&&a._d.setUTCMinutes(a._d.getUTCMinutes()-a._tzm),a._nextDay&&(a._a[yd]=24)}}function va(a){var b,c,d,e,f,g,h,i;b=a._w,null!=b.GG||null!=b.W||null!=b.E?(f=1,g=4,c=sa(b.GG,a._a[vd],qa(Ea(),1,4).year),d=sa(b.W,1),e=sa(b.E,1),(1>e||e>7)&&(i=!0)):(f=a._locale._week.dow,g=a._locale._week.doy,c=sa(b.gg,a._a[vd],qa(Ea(),f,g).year),d=sa(b.w,1),null!=b.d?(e=b.d,(0>e||e>6)&&(i=!0)):null!=b.e?(e=b.e+f,(b.e<0||b.e>6)&&(i=!0)):e=f),1>d||d>ra(c,f,g)?j(a)._overflowWeeks=!0:null!=i?j(a)._overflowWeekday=!0:(h=pa(c,d,e,f,g),a._a[vd]=h.year,a._dayOfYear=h.dayOfYear)}function wa(b){if(b._f===a.ISO_8601)return void ha(b);b._a=[],j(b).empty=!0;var c,d,e,f,g,h=""+b._i,i=h.length,k=0;for(e=N(b._f,b._locale).match($c)||[],c=0;c<e.length;c++)f=e[c],d=(h.match(P(f,b))||[])[0],d&&(g=h.substr(0,h.indexOf(d)),g.length>0&&j(b).unusedInput.push(g),h=h.slice(h.indexOf(d)+d.length),k+=d.length),bd[f]?(d?j(b).empty=!1:j(b).unusedTokens.push(f),U(f,d,b)):b._strict&&!d&&j(b).unusedTokens.push(f);j(b).charsLeftOver=i-k,h.length>0&&j(b).unusedInput.push(h),j(b).bigHour===!0&&b._a[yd]<=12&&b._a[yd]>0&&(j(b).bigHour=void 0),b._a[yd]=xa(b._locale,b._a[yd],b._meridiem),ua(b),da(b)}function xa(a,b,c){var d;return null==c?b:null!=a.meridiemHour?a.meridiemHour(b,c):null!=a.isPM?(d=a.isPM(c),d&&12>b&&(b+=12),d||12!==b||(b=0),b):b}function ya(a){var b,c,d,e,f;if(0===a._f.length)return j(a).invalidFormat=!0,void(a._d=new Date(NaN));for(e=0;e<a._f.length;e++)f=0,b=n({},a),null!=a._useUTC&&(b._useUTC=a._useUTC),b._f=a._f[e],wa(b),k(b)&&(f+=j(b).charsLeftOver,f+=10*j(b).unusedTokens.length,j(b).score=f,(null==d||d>f)&&(d=f,c=b));g(a,c||b)}function za(a){if(!a._d){var b=C(a._i);a._a=e([b.year,b.month,b.day||b.date,b.hour,b.minute,b.second,b.millisecond],function(a){return a&&parseInt(a,10)}),ua(a)}}function Aa(a){var b=new o(da(Ba(a)));return b._nextDay&&(b.add(1,"d"),b._nextDay=void 0),b}function Ba(a){var b=a._i,e=a._f;return a._locale=a._locale||z(a._l),null===b||void 0===e&&""===b?l({nullInput:!0}):("string"==typeof b&&(a._i=b=a._locale.preparse(b)),p(b)?new o(da(b)):(c(e)?ya(a):e?wa(a):d(b)?a._d=b:Ca(a),k(a)||(a._d=null),a))}function Ca(b){var f=b._i;void 0===f?b._d=new Date(a.now()):d(f)?b._d=new Date(+f):"string"==typeof f?ia(b):c(f)?(b._a=e(f.slice(0),function(a){return parseInt(a,10)}),ua(b)):"object"==typeof f?za(b):"number"==typeof f?b._d=new Date(f):a.createFromInputFallback(b)}function Da(a,b,c,d,e){var f={};return"boolean"==typeof c&&(d=c,c=void 0),f._isAMomentObject=!0,f._useUTC=f._isUTC=e,f._l=c,f._i=a,f._f=b,f._strict=d,Aa(f)}function Ea(a,b,c,d){return Da(a,b,c,d,!1)}function Fa(a,b){var d,e;if(1===b.length&&c(b[0])&&(b=b[0]),!b.length)return Ea();for(d=b[0],e=1;e<b.length;++e)(!b[e].isValid()||b[e][a](d))&&(d=b[e]);return d}function Ga(){var a=[].slice.call(arguments,0);return Fa("isBefore",a)}function Ha(){var a=[].slice.call(arguments,0);return Fa("isAfter",a)}function Ia(a){var b=C(a),c=b.year||0,d=b.quarter||0,e=b.month||0,f=b.week||0,g=b.day||0,h=b.hour||0,i=b.minute||0,j=b.second||0,k=b.millisecond||0;this._milliseconds=+k+1e3*j+6e4*i+36e5*h,this._days=+g+7*f,this._months=+e+3*d+12*c,this._data={},this._locale=z(),this._bubble()}function Ja(a){return a instanceof Ia}function Ka(a,b){J(a,0,0,function(){var a=this.utcOffset(),c="+";return 0>a&&(a=-a,c="-"),c+I(~~(a/60),2)+b+I(~~a%60,2)})}function La(a,b){var c=(b||"").match(a)||[],d=c[c.length-1]||[],e=(d+"").match(Ud)||["-",0,0],f=+(60*e[1])+r(e[2]);return"+"===e[0]?f:-f}function Ma(b,c){var e,f;return c._isUTC?(e=c.clone(),f=(p(b)||d(b)?+b:+Ea(b))-+e,e._d.setTime(+e._d+f),a.updateOffset(e,!1),e):Ea(b).local()}function Na(a){return 15*-Math.round(a._d.getTimezoneOffset()/15)}function Oa(b,c){var d,e=this._offset||0;return this.isValid()?null!=b?("string"==typeof b?b=La(qd,b):Math.abs(b)<16&&(b=60*b),!this._isUTC&&c&&(d=Na(this)),this._offset=b,this._isUTC=!0,null!=d&&this.add(d,"m"),e!==b&&(!c||this._changeInProgress?cb(this,Za(b-e,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,a.updateOffset(this,!0),this._changeInProgress=null)),this):this._isUTC?e:Na(this):null!=b?this:NaN}function Pa(a,b){return null!=a?("string"!=typeof a&&(a=-a),this.utcOffset(a,b),this):-this.utcOffset()}function Qa(a){return this.utcOffset(0,a)}function Ra(a){return this._isUTC&&(this.utcOffset(0,a),this._isUTC=!1,a&&this.subtract(Na(this),"m")),this}function Sa(){return this._tzm?this.utcOffset(this._tzm):"string"==typeof this._i&&this.utcOffset(La(pd,this._i)),this}function Ta(a){return this.isValid()?(a=a?Ea(a).utcOffset():0,(this.utcOffset()-a)%60===0):!1}function Ua(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function Va(){if(!m(this._isDSTShifted))return this._isDSTShifted;var a={};if(n(a,this),a=Ba(a),a._a){var b=a._isUTC?h(a._a):Ea(a._a);this._isDSTShifted=this.isValid()&&s(a._a,b.toArray())>0}else this._isDSTShifted=!1;return this._isDSTShifted}function Wa(){return this.isValid()?!this._isUTC:!1}function Xa(){return this.isValid()?this._isUTC:!1}function Ya(){return this.isValid()?this._isUTC&&0===this._offset:!1}function Za(a,b){var c,d,e,g=a,h=null;return Ja(a)?g={ms:a._milliseconds,d:a._days,M:a._months}:"number"==typeof a?(g={},b?g[b]=a:g.milliseconds=a):(h=Vd.exec(a))?(c="-"===h[1]?-1:1,g={y:0,d:r(h[xd])*c,h:r(h[yd])*c,m:r(h[zd])*c,s:r(h[Ad])*c,ms:r(h[Bd])*c}):(h=Wd.exec(a))?(c="-"===h[1]?-1:1,g={y:$a(h[2],c),M:$a(h[3],c),d:$a(h[4],c),h:$a(h[5],c),m:$a(h[6],c),s:$a(h[7],c),w:$a(h[8],c)}):null==g?g={}:"object"==typeof g&&("from"in g||"to"in g)&&(e=ab(Ea(g.from),Ea(g.to)),g={},g.ms=e.milliseconds,g.M=e.months),d=new Ia(g),Ja(a)&&f(a,"_locale")&&(d._locale=a._locale),d}function $a(a,b){var c=a&&parseFloat(a.replace(",","."));return(isNaN(c)?0:c)*b}function _a(a,b){var c={milliseconds:0,months:0};return c.months=b.month()-a.month()+12*(b.year()-a.year()),a.clone().add(c.months,"M").isAfter(b)&&--c.months,c.milliseconds=+b-+a.clone().add(c.months,"M"),c}function ab(a,b){var c;return a.isValid()&&b.isValid()?(b=Ma(b,a),a.isBefore(b)?c=_a(a,b):(c=_a(b,a),c.milliseconds=-c.milliseconds,c.months=-c.months),c):{milliseconds:0,months:0}}function bb(a,b){return function(c,d){var e,f;return null===d||isNaN(+d)||(ga(b,"moment()."+b+"(period, number) is deprecated. Please use moment()."+b+"(number, period)."),f=c,c=d,d=f),c="string"==typeof c?+c:c,e=Za(c,d),cb(this,e,a),this}}function cb(b,c,d,e){var f=c._milliseconds,g=c._days,h=c._months;b.isValid()&&(e=null==e?!0:e,f&&b._d.setTime(+b._d+f*d),g&&G(b,"Date",F(b,"Date")+g*d),h&&Z(b,F(b,"Month")+h*d),e&&a.updateOffset(b,g||h))}function db(a,b){var c=a||Ea(),d=Ma(c,this).startOf("day"),e=this.diff(d,"days",!0),f=-6>e?"sameElse":-1>e?"lastWeek":0>e?"lastDay":1>e?"sameDay":2>e?"nextDay":7>e?"nextWeek":"sameElse",g=b&&(D(b[f])?b[f]():b[f]);return this.format(g||this.localeData().calendar(f,this,Ea(c)))}function eb(){return new o(this)}function fb(a,b){var c=p(a)?a:Ea(a);return this.isValid()&&c.isValid()?(b=B(m(b)?"millisecond":b),"millisecond"===b?+this>+c:+c<+this.clone().startOf(b)):!1}function gb(a,b){var c=p(a)?a:Ea(a);return this.isValid()&&c.isValid()?(b=B(m(b)?"millisecond":b),"millisecond"===b?+c>+this:+this.clone().endOf(b)<+c):!1}function hb(a,b,c){return this.isAfter(a,c)&&this.isBefore(b,c)}function ib(a,b){var c,d=p(a)?a:Ea(a);return this.isValid()&&d.isValid()?(b=B(b||"millisecond"),"millisecond"===b?+this===+d:(c=+d,+this.clone().startOf(b)<=c&&c<=+this.clone().endOf(b))):!1}function jb(a,b){return this.isSame(a,b)||this.isAfter(a,b)}function kb(a,b){return this.isSame(a,b)||this.isBefore(a,b)}function lb(a,b,c){var d,e,f,g;return this.isValid()?(d=Ma(a,this),d.isValid()?(e=6e4*(d.utcOffset()-this.utcOffset()),b=B(b),"year"===b||"month"===b||"quarter"===b?(g=mb(this,d),"quarter"===b?g/=3:"year"===b&&(g/=12)):(f=this-d,g="second"===b?f/1e3:"minute"===b?f/6e4:"hour"===b?f/36e5:"day"===b?(f-e)/864e5:"week"===b?(f-e)/6048e5:f),c?g:q(g)):NaN):NaN}function mb(a,b){var c,d,e=12*(b.year()-a.year())+(b.month()-a.month()),f=a.clone().add(e,"months");return 0>b-f?(c=a.clone().add(e-1,"months"),d=(b-f)/(f-c)):(c=a.clone().add(e+1,"months"),d=(b-f)/(c-f)),-(e+d)}function nb(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")}function ob(){var a=this.clone().utc();return 0<a.year()&&a.year()<=9999?D(Date.prototype.toISOString)?this.toDate().toISOString():M(a,"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]"):M(a,"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]")}function pb(b){var c=M(this,b||a.defaultFormat);return this.localeData().postformat(c)}function qb(a,b){return this.isValid()&&(p(a)&&a.isValid()||Ea(a).isValid())?Za({to:this,from:a}).locale(this.locale()).humanize(!b):this.localeData().invalidDate()}function rb(a){return this.from(Ea(),a)}function sb(a,b){return this.isValid()&&(p(a)&&a.isValid()||Ea(a).isValid())?Za({from:this,to:a}).locale(this.locale()).humanize(!b):this.localeData().invalidDate()}function tb(a){return this.to(Ea(),a)}function ub(a){var b;return void 0===a?this._locale._abbr:(b=z(a),null!=b&&(this._locale=b),this)}function vb(){return this._locale}function wb(a){switch(a=B(a)){case"year":this.month(0);case"quarter":case"month":this.date(1);case"week":case"isoWeek":case"day":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return"week"===a&&this.weekday(0),"isoWeek"===a&&this.isoWeekday(1),"quarter"===a&&this.month(3*Math.floor(this.month()/3)),this}function xb(a){return a=B(a),void 0===a||"millisecond"===a?this:this.startOf(a).add(1,"isoWeek"===a?"week":a).subtract(1,"ms")}function yb(){return+this._d-6e4*(this._offset||0)}function zb(){return Math.floor(+this/1e3)}function Ab(){return this._offset?new Date(+this):this._d}function Bb(){var a=this;return[a.year(),a.month(),a.date(),a.hour(),a.minute(),a.second(),a.millisecond()]}function Cb(){var a=this;return{years:a.year(),months:a.month(),date:a.date(),hours:a.hours(),minutes:a.minutes(),seconds:a.seconds(),milliseconds:a.milliseconds()}}function Db(){return this.isValid()?this.toISOString():"null"}function Eb(){return k(this)}function Fb(){return g({},j(this))}function Gb(){return j(this).overflow}function Hb(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}function Ib(a,b){J(0,[a,a.length],0,b)}function Jb(a){return Nb.call(this,a,this.week(),this.weekday(),this.localeData()._week.dow,this.localeData()._week.doy)}function Kb(a){return Nb.call(this,a,this.isoWeek(),this.isoWeekday(),1,4)}function Lb(){return ra(this.year(),1,4)}function Mb(){var a=this.localeData()._week;return ra(this.year(),a.dow,a.doy)}function Nb(a,b,c,d,e){var f;return null==a?qa(this,d,e).year:(f=ra(a,d,e),b>f&&(b=f),Ob.call(this,a,b,c,d,e))}function Ob(a,b,c,d,e){var f=pa(a,b,c,d,e),g=ka(f.year,0,f.dayOfYear);return this.year(g.getUTCFullYear()),this.month(g.getUTCMonth()),this.date(g.getUTCDate()),this}function Pb(a){return null==a?Math.ceil((this.month()+1)/3):this.month(3*(a-1)+this.month()%3)}function Qb(a){return qa(a,this._week.dow,this._week.doy).week}function Rb(){return this._week.dow}function Sb(){return this._week.doy}function Tb(a){var b=this.localeData().week(this);return null==a?b:this.add(7*(a-b),"d")}function Ub(a){var b=qa(this,1,4).week;return null==a?b:this.add(7*(a-b),"d")}function Vb(a,b){return"string"!=typeof a?a:isNaN(a)?(a=b.weekdaysParse(a),"number"==typeof a?a:null):parseInt(a,10)}function Wb(a,b){return c(this._weekdays)?this._weekdays[a.day()]:this._weekdays[this._weekdays.isFormat.test(b)?"format":"standalone"][a.day()]}function Xb(a){return this._weekdaysShort[a.day()]}function Yb(a){return this._weekdaysMin[a.day()]}function Zb(a,b,c){var d,e,f;for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),d=0;7>d;d++){if(e=Ea([2e3,1]).day(d),c&&!this._fullWeekdaysParse[d]&&(this._fullWeekdaysParse[d]=new RegExp("^"+this.weekdays(e,"").replace(".",".?")+"$","i"),this._shortWeekdaysParse[d]=new RegExp("^"+this.weekdaysShort(e,"").replace(".",".?")+"$","i"),this._minWeekdaysParse[d]=new RegExp("^"+this.weekdaysMin(e,"").replace(".",".?")+"$","i")),this._weekdaysParse[d]||(f="^"+this.weekdays(e,"")+"|^"+this.weekdaysShort(e,"")+"|^"+this.weekdaysMin(e,""),this._weekdaysParse[d]=new RegExp(f.replace(".",""),"i")),c&&"dddd"===b&&this._fullWeekdaysParse[d].test(a))return d;if(c&&"ddd"===b&&this._shortWeekdaysParse[d].test(a))return d;if(c&&"dd"===b&&this._minWeekdaysParse[d].test(a))return d;if(!c&&this._weekdaysParse[d].test(a))return d}}function $b(a){if(!this.isValid())return null!=a?this:NaN;var b=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=a?(a=Vb(a,this.localeData()),this.add(a-b,"d")):b}function _b(a){if(!this.isValid())return null!=a?this:NaN;var b=(this.day()+7-this.localeData()._week.dow)%7;return null==a?b:this.add(a-b,"d")}function ac(a){return this.isValid()?null==a?this.day()||7:this.day(this.day()%7?a:a-7):null!=a?this:NaN}function bc(a){var b=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return null==a?b:this.add(a-b,"d")}function cc(){return this.hours()%12||12}function dc(a,b){J(a,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),b)})}function ec(a,b){return b._meridiemParse}function fc(a){return"p"===(a+"").toLowerCase().charAt(0)}function gc(a,b,c){return a>11?c?"pm":"PM":c?"am":"AM"}function hc(a,b){b[Bd]=r(1e3*("0."+a))}function ic(){return this._isUTC?"UTC":""}function jc(){return this._isUTC?"Coordinated Universal Time":""}function kc(a){return Ea(1e3*a)}function lc(){return Ea.apply(null,arguments).parseZone()}function mc(a,b,c){var d=this._calendar[a];return D(d)?d.call(b,c):d}function nc(a){var b=this._longDateFormat[a],c=this._longDateFormat[a.toUpperCase()];return b||!c?b:(this._longDateFormat[a]=c.replace(/MMMM|MM|DD|dddd/g,function(a){return a.slice(1)}),this._longDateFormat[a])}function oc(){return this._invalidDate}function pc(a){return this._ordinal.replace("%d",a)}function qc(a){return a}function rc(a,b,c,d){var e=this._relativeTime[c];return D(e)?e(a,b,c,d):e.replace(/%d/i,a)}function sc(a,b){var c=this._relativeTime[a>0?"future":"past"];return D(c)?c(b):c.replace(/%s/i,b)}function tc(a){var b,c;for(c in a)b=a[c],D(b)?this[c]=b:this["_"+c]=b;this._ordinalParseLenient=new RegExp(this._ordinalParse.source+"|"+/\d{1,2}/.source)}function uc(a,b,c,d){var e=z(),f=h().set(d,b);return e[c](f,a)}function vc(a,b,c,d,e){if("number"==typeof a&&(b=a,a=void 0),a=a||"",null!=b)return uc(a,b,c,e);var f,g=[];for(f=0;d>f;f++)g[f]=uc(a,f,c,e);return g}function wc(a,b){return vc(a,b,"months",12,"month")}function xc(a,b){return vc(a,b,"monthsShort",12,"month")}function yc(a,b){return vc(a,b,"weekdays",7,"day")}function zc(a,b){return vc(a,b,"weekdaysShort",7,"day")}function Ac(a,b){return vc(a,b,"weekdaysMin",7,"day")}function Bc(){var a=this._data;return this._milliseconds=se(this._milliseconds),this._days=se(this._days),this._months=se(this._months),a.milliseconds=se(a.milliseconds),a.seconds=se(a.seconds),a.minutes=se(a.minutes),a.hours=se(a.hours),a.months=se(a.months),a.years=se(a.years),this}function Cc(a,b,c,d){var e=Za(b,c);return a._milliseconds+=d*e._milliseconds,a._days+=d*e._days,a._months+=d*e._months,a._bubble()}function Dc(a,b){return Cc(this,a,b,1)}function Ec(a,b){return Cc(this,a,b,-1)}function Fc(a){return 0>a?Math.floor(a):Math.ceil(a)}function Gc(){var a,b,c,d,e,f=this._milliseconds,g=this._days,h=this._months,i=this._data;return f>=0&&g>=0&&h>=0||0>=f&&0>=g&&0>=h||(f+=864e5*Fc(Ic(h)+g),g=0,h=0),i.milliseconds=f%1e3,a=q(f/1e3),i.seconds=a%60,b=q(a/60),i.minutes=b%60,c=q(b/60),i.hours=c%24,g+=q(c/24),e=q(Hc(g)),h+=e,g-=Fc(Ic(e)),d=q(h/12),h%=12,i.days=g,i.months=h,i.years=d,this}function Hc(a){return 4800*a/146097}function Ic(a){return 146097*a/4800}function Jc(a){var b,c,d=this._milliseconds;if(a=B(a),"month"===a||"year"===a)return b=this._days+d/864e5,c=this._months+Hc(b),"month"===a?c:c/12;switch(b=this._days+Math.round(Ic(this._months)),a){case"week":return b/7+d/6048e5;case"day":return b+d/864e5;case"hour":return 24*b+d/36e5;case"minute":return 1440*b+d/6e4;case"second":return 86400*b+d/1e3;case"millisecond":return Math.floor(864e5*b)+d;default:throw new Error("Unknown unit "+a)}}function Kc(){return this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*r(this._months/12)}function Lc(a){return function(){return this.as(a)}}function Mc(a){return a=B(a),this[a+"s"]()}function Nc(a){return function(){return this._data[a]}}function Oc(){return q(this.days()/7)}function Pc(a,b,c,d,e){return e.relativeTime(b||1,!!c,a,d)}function Qc(a,b,c){var d=Za(a).abs(),e=Ie(d.as("s")),f=Ie(d.as("m")),g=Ie(d.as("h")),h=Ie(d.as("d")),i=Ie(d.as("M")),j=Ie(d.as("y")),k=e<Je.s&&["s",e]||1>=f&&["m"]||f<Je.m&&["mm",f]||1>=g&&["h"]||g<Je.h&&["hh",g]||1>=h&&["d"]||h<Je.d&&["dd",h]||1>=i&&["M"]||i<Je.M&&["MM",i]||1>=j&&["y"]||["yy",j];return k[2]=b,k[3]=+a>0,k[4]=c,Pc.apply(null,k)}function Rc(a,b){return void 0===Je[a]?!1:void 0===b?Je[a]:(Je[a]=b,!0)}function Sc(a){var b=this.localeData(),c=Qc(this,!a,b);return a&&(c=b.pastFuture(+this,c)),b.postformat(c)}function Tc(){var a,b,c,d=Ke(this._milliseconds)/1e3,e=Ke(this._days),f=Ke(this._months);a=q(d/60),b=q(a/60),d%=60,a%=60,c=q(f/12),f%=12;var g=c,h=f,i=e,j=b,k=a,l=d,m=this.asSeconds();return m?(0>m?"-":"")+"P"+(g?g+"Y":"")+(h?h+"M":"")+(i?i+"D":"")+(j||k||l?"T":"")+(j?j+"H":"")+(k?k+"M":"")+(l?l+"S":""):"P0D"}var Uc,Vc,Wc=a.momentProperties=[],Xc=!1,Yc={},Zc={},$c=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,_c=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,ad={},bd={},cd=/\d/,dd=/\d\d/,ed=/\d{3}/,fd=/\d{4}/,gd=/[+-]?\d{6}/,hd=/\d\d?/,id=/\d\d\d\d?/,jd=/\d\d\d\d\d\d?/,kd=/\d{1,3}/,ld=/\d{1,4}/,md=/[+-]?\d{1,6}/,nd=/\d+/,od=/[+-]?\d+/,pd=/Z|[+-]\d\d:?\d\d/gi,qd=/Z|[+-]\d\d(?::?\d\d)?/gi,rd=/[+-]?\d+(\.\d{1,3})?/,sd=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,td={},ud={},vd=0,wd=1,xd=2,yd=3,zd=4,Ad=5,Bd=6,Cd=7,Dd=8;J("M",["MM",2],"Mo",function(){return this.month()+1}),J("MMM",0,0,function(a){return this.localeData().monthsShort(this,a)}),J("MMMM",0,0,function(a){return this.localeData().months(this,a)}),A("month","M"),O("M",hd),O("MM",hd,dd),O("MMM",function(a,b){return b.monthsShortRegex(a)}),O("MMMM",function(a,b){return b.monthsRegex(a)}),S(["M","MM"],function(a,b){b[wd]=r(a)-1}),S(["MMM","MMMM"],function(a,b,c,d){var e=c._locale.monthsParse(a,d,c._strict);null!=e?b[wd]=e:j(c).invalidMonth=a});var Ed=/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/,Fd="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),Gd="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),Hd=sd,Id=sd,Jd={};a.suppressDeprecationWarnings=!1;var Kd=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?/,Ld=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?/,Md=/Z|[+-]\d\d(?::?\d\d)?/,Nd=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/]],Od=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],Pd=/^\/?Date\((\-?\d+)/i;a.createFromInputFallback=fa("moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.",function(a){a._d=new Date(a._i+(a._useUTC?" UTC":""))}),J("Y",0,0,function(){var a=this.year();return 9999>=a?""+a:"+"+a}),J(0,["YY",2],0,function(){return this.year()%100}),J(0,["YYYY",4],0,"year"),J(0,["YYYYY",5],0,"year"),J(0,["YYYYYY",6,!0],0,"year"),A("year","y"),O("Y",od),O("YY",hd,dd),O("YYYY",ld,fd),O("YYYYY",md,gd),O("YYYYYY",md,gd),S(["YYYYY","YYYYYY"],vd),S("YYYY",function(b,c){c[vd]=2===b.length?a.parseTwoDigitYear(b):r(b)}),S("YY",function(b,c){c[vd]=a.parseTwoDigitYear(b)}),S("Y",function(a,b){b[vd]=parseInt(a,10)}),a.parseTwoDigitYear=function(a){return r(a)+(r(a)>68?1900:2e3)};var Qd=E("FullYear",!1);a.ISO_8601=function(){};var Rd=fa("moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548",function(){var a=Ea.apply(null,arguments);return this.isValid()&&a.isValid()?this>a?this:a:l()}),Sd=fa("moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548",function(){var a=Ea.apply(null,arguments);return this.isValid()&&a.isValid()?a>this?this:a:l()}),Td=function(){return Date.now?Date.now():+new Date};Ka("Z",":"),Ka("ZZ",""),O("Z",qd),O("ZZ",qd),S(["Z","ZZ"],function(a,b,c){c._useUTC=!0,c._tzm=La(qd,a)});var Ud=/([\+\-]|\d\d)/gi;a.updateOffset=function(){};var Vd=/^(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?\d*)?$/,Wd=/^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/;
  Za.fn=Ia.prototype;var Xd=bb(1,"add"),Yd=bb(-1,"subtract");a.defaultFormat="YYYY-MM-DDTHH:mm:ssZ";var Zd=fa("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(a){return void 0===a?this.localeData():this.locale(a)});J(0,["gg",2],0,function(){return this.weekYear()%100}),J(0,["GG",2],0,function(){return this.isoWeekYear()%100}),Ib("gggg","weekYear"),Ib("ggggg","weekYear"),Ib("GGGG","isoWeekYear"),Ib("GGGGG","isoWeekYear"),A("weekYear","gg"),A("isoWeekYear","GG"),O("G",od),O("g",od),O("GG",hd,dd),O("gg",hd,dd),O("GGGG",ld,fd),O("gggg",ld,fd),O("GGGGG",md,gd),O("ggggg",md,gd),T(["gggg","ggggg","GGGG","GGGGG"],function(a,b,c,d){b[d.substr(0,2)]=r(a)}),T(["gg","GG"],function(b,c,d,e){c[e]=a.parseTwoDigitYear(b)}),J("Q",0,"Qo","quarter"),A("quarter","Q"),O("Q",cd),S("Q",function(a,b){b[wd]=3*(r(a)-1)}),J("w",["ww",2],"wo","week"),J("W",["WW",2],"Wo","isoWeek"),A("week","w"),A("isoWeek","W"),O("w",hd),O("ww",hd,dd),O("W",hd),O("WW",hd,dd),T(["w","ww","W","WW"],function(a,b,c,d){b[d.substr(0,1)]=r(a)});var $d={dow:0,doy:6};J("D",["DD",2],"Do","date"),A("date","D"),O("D",hd),O("DD",hd,dd),O("Do",function(a,b){return a?b._ordinalParse:b._ordinalParseLenient}),S(["D","DD"],xd),S("Do",function(a,b){b[xd]=r(a.match(hd)[0],10)});var _d=E("Date",!0);J("d",0,"do","day"),J("dd",0,0,function(a){return this.localeData().weekdaysMin(this,a)}),J("ddd",0,0,function(a){return this.localeData().weekdaysShort(this,a)}),J("dddd",0,0,function(a){return this.localeData().weekdays(this,a)}),J("e",0,0,"weekday"),J("E",0,0,"isoWeekday"),A("day","d"),A("weekday","e"),A("isoWeekday","E"),O("d",hd),O("e",hd),O("E",hd),O("dd",sd),O("ddd",sd),O("dddd",sd),T(["dd","ddd","dddd"],function(a,b,c,d){var e=c._locale.weekdaysParse(a,d,c._strict);null!=e?b.d=e:j(c).invalidWeekday=a}),T(["d","e","E"],function(a,b,c,d){b[d]=r(a)});var ae="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),be="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),ce="Su_Mo_Tu_We_Th_Fr_Sa".split("_");J("DDD",["DDDD",3],"DDDo","dayOfYear"),A("dayOfYear","DDD"),O("DDD",kd),O("DDDD",ed),S(["DDD","DDDD"],function(a,b,c){c._dayOfYear=r(a)}),J("H",["HH",2],0,"hour"),J("h",["hh",2],0,cc),J("hmm",0,0,function(){return""+cc.apply(this)+I(this.minutes(),2)}),J("hmmss",0,0,function(){return""+cc.apply(this)+I(this.minutes(),2)+I(this.seconds(),2)}),J("Hmm",0,0,function(){return""+this.hours()+I(this.minutes(),2)}),J("Hmmss",0,0,function(){return""+this.hours()+I(this.minutes(),2)+I(this.seconds(),2)}),dc("a",!0),dc("A",!1),A("hour","h"),O("a",ec),O("A",ec),O("H",hd),O("h",hd),O("HH",hd,dd),O("hh",hd,dd),O("hmm",id),O("hmmss",jd),O("Hmm",id),O("Hmmss",jd),S(["H","HH"],yd),S(["a","A"],function(a,b,c){c._isPm=c._locale.isPM(a),c._meridiem=a}),S(["h","hh"],function(a,b,c){b[yd]=r(a),j(c).bigHour=!0}),S("hmm",function(a,b,c){var d=a.length-2;b[yd]=r(a.substr(0,d)),b[zd]=r(a.substr(d)),j(c).bigHour=!0}),S("hmmss",function(a,b,c){var d=a.length-4,e=a.length-2;b[yd]=r(a.substr(0,d)),b[zd]=r(a.substr(d,2)),b[Ad]=r(a.substr(e)),j(c).bigHour=!0}),S("Hmm",function(a,b,c){var d=a.length-2;b[yd]=r(a.substr(0,d)),b[zd]=r(a.substr(d))}),S("Hmmss",function(a,b,c){var d=a.length-4,e=a.length-2;b[yd]=r(a.substr(0,d)),b[zd]=r(a.substr(d,2)),b[Ad]=r(a.substr(e))});var de=/[ap]\.?m?\.?/i,ee=E("Hours",!0);J("m",["mm",2],0,"minute"),A("minute","m"),O("m",hd),O("mm",hd,dd),S(["m","mm"],zd);var fe=E("Minutes",!1);J("s",["ss",2],0,"second"),A("second","s"),O("s",hd),O("ss",hd,dd),S(["s","ss"],Ad);var ge=E("Seconds",!1);J("S",0,0,function(){return~~(this.millisecond()/100)}),J(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),J(0,["SSS",3],0,"millisecond"),J(0,["SSSS",4],0,function(){return 10*this.millisecond()}),J(0,["SSSSS",5],0,function(){return 100*this.millisecond()}),J(0,["SSSSSS",6],0,function(){return 1e3*this.millisecond()}),J(0,["SSSSSSS",7],0,function(){return 1e4*this.millisecond()}),J(0,["SSSSSSSS",8],0,function(){return 1e5*this.millisecond()}),J(0,["SSSSSSSSS",9],0,function(){return 1e6*this.millisecond()}),A("millisecond","ms"),O("S",kd,cd),O("SS",kd,dd),O("SSS",kd,ed);var he;for(he="SSSS";he.length<=9;he+="S")O(he,nd);for(he="S";he.length<=9;he+="S")S(he,hc);var ie=E("Milliseconds",!1);J("z",0,0,"zoneAbbr"),J("zz",0,0,"zoneName");var je=o.prototype;je.add=Xd,je.calendar=db,je.clone=eb,je.diff=lb,je.endOf=xb,je.format=pb,je.from=qb,je.fromNow=rb,je.to=sb,je.toNow=tb,je.get=H,je.invalidAt=Gb,je.isAfter=fb,je.isBefore=gb,je.isBetween=hb,je.isSame=ib,je.isSameOrAfter=jb,je.isSameOrBefore=kb,je.isValid=Eb,je.lang=Zd,je.locale=ub,je.localeData=vb,je.max=Sd,je.min=Rd,je.parsingFlags=Fb,je.set=H,je.startOf=wb,je.subtract=Yd,je.toArray=Bb,je.toObject=Cb,je.toDate=Ab,je.toISOString=ob,je.toJSON=Db,je.toString=nb,je.unix=zb,je.valueOf=yb,je.creationData=Hb,je.year=Qd,je.isLeapYear=na,je.weekYear=Jb,je.isoWeekYear=Kb,je.quarter=je.quarters=Pb,je.month=$,je.daysInMonth=_,je.week=je.weeks=Tb,je.isoWeek=je.isoWeeks=Ub,je.weeksInYear=Mb,je.isoWeeksInYear=Lb,je.date=_d,je.day=je.days=$b,je.weekday=_b,je.isoWeekday=ac,je.dayOfYear=bc,je.hour=je.hours=ee,je.minute=je.minutes=fe,je.second=je.seconds=ge,je.millisecond=je.milliseconds=ie,je.utcOffset=Oa,je.utc=Qa,je.local=Ra,je.parseZone=Sa,je.hasAlignedHourOffset=Ta,je.isDST=Ua,je.isDSTShifted=Va,je.isLocal=Wa,je.isUtcOffset=Xa,je.isUtc=Ya,je.isUTC=Ya,je.zoneAbbr=ic,je.zoneName=jc,je.dates=fa("dates accessor is deprecated. Use date instead.",_d),je.months=fa("months accessor is deprecated. Use month instead",$),je.years=fa("years accessor is deprecated. Use year instead",Qd),je.zone=fa("moment().zone is deprecated, use moment().utcOffset instead. https://github.com/moment/moment/issues/1779",Pa);var ke=je,le={sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},me={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},ne="Invalid date",oe="%d",pe=/\d{1,2}/,qe={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},re=t.prototype;re._calendar=le,re.calendar=mc,re._longDateFormat=me,re.longDateFormat=nc,re._invalidDate=ne,re.invalidDate=oc,re._ordinal=oe,re.ordinal=pc,re._ordinalParse=pe,re.preparse=qc,re.postformat=qc,re._relativeTime=qe,re.relativeTime=rc,re.pastFuture=sc,re.set=tc,re.months=W,re._months=Fd,re.monthsShort=X,re._monthsShort=Gd,re.monthsParse=Y,re._monthsRegex=Id,re.monthsRegex=ba,re._monthsShortRegex=Hd,re.monthsShortRegex=aa,re.week=Qb,re._week=$d,re.firstDayOfYear=Sb,re.firstDayOfWeek=Rb,re.weekdays=Wb,re._weekdays=ae,re.weekdaysMin=Yb,re._weekdaysMin=ce,re.weekdaysShort=Xb,re._weekdaysShort=be,re.weekdaysParse=Zb,re.isPM=fc,re._meridiemParse=de,re.meridiem=gc,x("en",{ordinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(a){var b=a%10,c=1===r(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th";return a+c}}),a.lang=fa("moment.lang is deprecated. Use moment.locale instead.",x),a.langData=fa("moment.langData is deprecated. Use moment.localeData instead.",z);var se=Math.abs,te=Lc("ms"),ue=Lc("s"),ve=Lc("m"),we=Lc("h"),xe=Lc("d"),ye=Lc("w"),ze=Lc("M"),Ae=Lc("y"),Be=Nc("milliseconds"),Ce=Nc("seconds"),De=Nc("minutes"),Ee=Nc("hours"),Fe=Nc("days"),Ge=Nc("months"),He=Nc("years"),Ie=Math.round,Je={s:45,m:45,h:22,d:26,M:11},Ke=Math.abs,Le=Ia.prototype;Le.abs=Bc,Le.add=Dc,Le.subtract=Ec,Le.as=Jc,Le.asMilliseconds=te,Le.asSeconds=ue,Le.asMinutes=ve,Le.asHours=we,Le.asDays=xe,Le.asWeeks=ye,Le.asMonths=ze,Le.asYears=Ae,Le.valueOf=Kc,Le._bubble=Gc,Le.get=Mc,Le.milliseconds=Be,Le.seconds=Ce,Le.minutes=De,Le.hours=Ee,Le.days=Fe,Le.weeks=Oc,Le.months=Ge,Le.years=He,Le.humanize=Sc,Le.toISOString=Tc,Le.toString=Tc,Le.toJSON=Tc,Le.locale=ub,Le.localeData=vb,Le.toIsoString=fa("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",Tc),Le.lang=Zd,J("X",0,0,"unix"),J("x",0,0,"valueOf"),O("x",od),O("X",rd),S("X",function(a,b,c){c._d=new Date(1e3*parseFloat(a,10))}),S("x",function(a,b,c){c._d=new Date(r(a))}),a.version="2.11.2",b(Ea),a.fn=ke,a.min=Ga,a.max=Ha,a.now=Td,a.utc=h,a.unix=kc,a.months=wc,a.isDate=d,a.locale=x,a.invalid=l,a.duration=Za,a.isMoment=p,a.weekdays=yc,a.parseZone=lc,a.localeData=z,a.isDuration=Ja,a.monthsShort=xc,a.weekdaysMin=Ac,a.defineLocale=y,a.weekdaysShort=zc,a.normalizeUnits=B,a.relativeTimeThreshold=Rc,a.prototype=ke;var Me=a;return Me});
  /*!
   * Select2 4.0.3
   * https://select2.github.io
   *
   * Released under the MIT license
   * https://github.com/select2/select2/blob/master/LICENSE.md
   */
  (function (factory) {
    if (typeof define === 'function' && define.amd) {
      // AMD. Register as an anonymous module.
      define(['jquery'], factory);
    } else if (typeof exports === 'object') {
      // Node/CommonJS
      factory(require('jquery'));
    } else {
      // Browser globals
      factory(jQuery);
    }
  }(function (jQuery) {
    // This is needed so we can catch the AMD loader configuration and use it
    // The inner file should be wrapped (by `banner.start.js`) in a function that
    // returns the AMD loader references.
    var S2 =
  (function () {
    // Restore the Select2 AMD loader so it can be used
    // Needed mostly in the language files, where the loader is not inserted
    if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) {
      var S2 = jQuery.fn.select2.amd;
    }
  var S2;(function () { if (!S2 || !S2.requirejs) {
  if (!S2) { S2 = {}; } else { require = S2; }
  /**
   * @license almond 0.3.1 Copyright (c) 2011-2014, The Dojo Foundation All Rights Reserved.
   * Available via the MIT or new BSD license.
   * see: http://github.com/jrburke/almond for details
   */
  //Going sloppy to avoid 'use strict' string cost, but strict practices should
  //be followed.
  /*jslint sloppy: true */
  /*global setTimeout: false */
  
  var requirejs, require, define;
  (function (undef) {
      var main, req, makeMap, handlers,
          defined = {},
          waiting = {},
          config = {},
          defining = {},
          hasOwn = Object.prototype.hasOwnProperty,
          aps = [].slice,
          jsSuffixRegExp = /\.js$/;
  
      function hasProp(obj, prop) {
          return hasOwn.call(obj, prop);
      }
  
      /**
       * Given a relative module name, like ./something, normalize it to
       * a real name that can be mapped to a path.
       * @param {String} name the relative name
       * @param {String} baseName a real name that the name arg is relative
       * to.
       * @returns {String} normalized name
       */
      function normalize(name, baseName) {
          var nameParts, nameSegment, mapValue, foundMap, lastIndex,
              foundI, foundStarMap, starI, i, j, part,
              baseParts = baseName && baseName.split("/"),
              map = config.map,
              starMap = (map && map['*']) || {};
  
          //Adjust any relative paths.
          if (name && name.charAt(0) === ".") {
              //If have a base name, try to normalize against it,
              //otherwise, assume it is a top-level require that will
              //be relative to baseUrl in the end.
              if (baseName) {
                  name = name.split('/');
                  lastIndex = name.length - 1;
  
                  // Node .js allowance:
                  if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
                      name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
                  }
  
                  //Lop off the last part of baseParts, so that . matches the
                  //"directory" and not name of the baseName's module. For instance,
                  //baseName of "one/two/three", maps to "one/two/three.js", but we
                  //want the directory, "one/two" for this normalization.
                  name = baseParts.slice(0, baseParts.length - 1).concat(name);
  
                  //start trimDots
                  for (i = 0; i < name.length; i += 1) {
                      part = name[i];
                      if (part === ".") {
                          name.splice(i, 1);
                          i -= 1;
                      } else if (part === "..") {
                          if (i === 1 && (name[2] === '..' || name[0] === '..')) {
                              //End of the line. Keep at least one non-dot
                              //path segment at the front so it can be mapped
                              //correctly to disk. Otherwise, there is likely
                              //no path mapping for a path starting with '..'.
                              //This can still fail, but catches the most reasonable
                              //uses of ..
                              break;
                          } else if (i > 0) {
                              name.splice(i - 1, 2);
                              i -= 2;
                          }
                      }
                  }
                  //end trimDots
  
                  name = name.join("/");
              } else if (name.indexOf('./') === 0) {
                  // No baseName, so this is ID is resolved relative
                  // to baseUrl, pull off the leading dot.
                  name = name.substring(2);
              }
          }
  
          //Apply map config if available.
          if ((baseParts || starMap) && map) {
              nameParts = name.split('/');
  
              for (i = nameParts.length; i > 0; i -= 1) {
                  nameSegment = nameParts.slice(0, i).join("/");
  
                  if (baseParts) {
                      //Find the longest baseName segment match in the config.
                      //So, do joins on the biggest to smallest lengths of baseParts.
                      for (j = baseParts.length; j > 0; j -= 1) {
                          mapValue = map[baseParts.slice(0, j).join('/')];
  
                          //baseName segment has  config, find if it has one for
                          //this name.
                          if (mapValue) {
                              mapValue = mapValue[nameSegment];
                              if (mapValue) {
                                  //Match, update name to the new value.
                                  foundMap = mapValue;
                                  foundI = i;
                                  break;
                              }
                          }
                      }
                  }
  
                  if (foundMap) {
                      break;
                  }
  
                  //Check for a star map match, but just hold on to it,
                  //if there is a shorter segment match later in a matching
                  //config, then favor over this star map.
                  if (!foundStarMap && starMap && starMap[nameSegment]) {
                      foundStarMap = starMap[nameSegment];
                      starI = i;
                  }
              }
  
              if (!foundMap && foundStarMap) {
                  foundMap = foundStarMap;
                  foundI = starI;
              }
  
              if (foundMap) {
                  nameParts.splice(0, foundI, foundMap);
                  name = nameParts.join('/');
              }
          }
  
          return name;
      }
  
      function makeRequire(relName, forceSync) {
          return function () {
              //A version of a require function that passes a moduleName
              //value for items that may need to
              //look up paths relative to the moduleName
              var args = aps.call(arguments, 0);
  
              //If first arg is not require('string'), and there is only
              //one arg, it is the array form without a callback. Insert
              //a null so that the following concat is correct.
              if (typeof args[0] !== 'string' && args.length === 1) {
                  args.push(null);
              }
              return req.apply(undef, args.concat([relName, forceSync]));
          };
      }
  
      function makeNormalize(relName) {
          return function (name) {
              return normalize(name, relName);
          };
      }
  
      function makeLoad(depName) {
          return function (value) {
              defined[depName] = value;
          };
      }
  
      function callDep(name) {
          if (hasProp(waiting, name)) {
              var args = waiting[name];
              delete waiting[name];
              defining[name] = true;
              main.apply(undef, args);
          }
  
          if (!hasProp(defined, name) && !hasProp(defining, name)) {
              throw new Error('No ' + name);
          }
          return defined[name];
      }
  
      //Turns a plugin!resource to [plugin, resource]
      //with the plugin being undefined if the name
      //did not have a plugin prefix.
      function splitPrefix(name) {
          var prefix,
              index = name ? name.indexOf('!') : -1;
          if (index > -1) {
              prefix = name.substring(0, index);
              name = name.substring(index + 1, name.length);
          }
          return [prefix, name];
      }
  
      /**
       * Makes a name map, normalizing the name, and using a plugin
       * for normalization if necessary. Grabs a ref to plugin
       * too, as an optimization.
       */
      makeMap = function (name, relName) {
          var plugin,
              parts = splitPrefix(name),
              prefix = parts[0];
  
          name = parts[1];
  
          if (prefix) {
              prefix = normalize(prefix, relName);
              plugin = callDep(prefix);
          }
  
          //Normalize according
          if (prefix) {
              if (plugin && plugin.normalize) {
                  name = plugin.normalize(name, makeNormalize(relName));
              } else {
                  name = normalize(name, relName);
              }
          } else {
              name = normalize(name, relName);
              parts = splitPrefix(name);
              prefix = parts[0];
              name = parts[1];
              if (prefix) {
                  plugin = callDep(prefix);
              }
          }
  
          //Using ridiculous property names for space reasons
          return {
              f: prefix ? prefix + '!' + name : name, //fullName
              n: name,
              pr: prefix,
              p: plugin
          };
      };
  
      function makeConfig(name) {
          return function () {
              return (config && config.config && config.config[name]) || {};
          };
      }
  
      handlers = {
          require: function (name) {
              return makeRequire(name);
          },
          exports: function (name) {
              var e = defined[name];
              if (typeof e !== 'undefined') {
                  return e;
              } else {
                  return (defined[name] = {});
              }
          },
          module: function (name) {
              return {
                  id: name,
                  uri: '',
                  exports: defined[name],
                  config: makeConfig(name)
              };
          }
      };
  
      main = function (name, deps, callback, relName) {
          var cjsModule, depName, ret, map, i,
              args = [],
              callbackType = typeof callback,
              usingExports;
  
          //Use name if no relName
          relName = relName || name;
  
          //Call the callback to define the module, if necessary.
          if (callbackType === 'undefined' || callbackType === 'function') {
              //Pull out the defined dependencies and pass the ordered
              //values to the callback.
              //Default to [require, exports, module] if no deps
              deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
              for (i = 0; i < deps.length; i += 1) {
                  map = makeMap(deps[i], relName);
                  depName = map.f;
  
                  //Fast path CommonJS standard dependencies.
                  if (depName === "require") {
                      args[i] = handlers.require(name);
                  } else if (depName === "exports") {
                      //CommonJS module spec 1.1
                      args[i] = handlers.exports(name);
                      usingExports = true;
                  } else if (depName === "module") {
                      //CommonJS module spec 1.1
                      cjsModule = args[i] = handlers.module(name);
                  } else if (hasProp(defined, depName) ||
                             hasProp(waiting, depName) ||
                             hasProp(defining, depName)) {
                      args[i] = callDep(depName);
                  } else if (map.p) {
                      map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});
                      args[i] = defined[depName];
                  } else {
                      throw new Error(name + ' missing ' + depName);
                  }
              }
  
              ret = callback ? callback.apply(defined[name], args) : undefined;
  
              if (name) {
                  //If setting exports via "module" is in play,
                  //favor that over return value and exports. After that,
                  //favor a non-undefined return value over exports use.
                  if (cjsModule && cjsModule.exports !== undef &&
                          cjsModule.exports !== defined[name]) {
                      defined[name] = cjsModule.exports;
                  } else if (ret !== undef || !usingExports) {
                      //Use the return value from the function.
                      defined[name] = ret;
                  }
              }
          } else if (name) {
              //May just be an object definition for the module. Only
              //worry about defining if have a module name.
              defined[name] = callback;
          }
      };
  
      requirejs = require = req = function (deps, callback, relName, forceSync, alt) {
          if (typeof deps === "string") {
              if (handlers[deps]) {
                  //callback in this case is really relName
                  return handlers[deps](callback);
              }
              //Just return the module wanted. In this scenario, the
              //deps arg is the module name, and second arg (if passed)
              //is just the relName.
              //Normalize module name, if it contains . or ..
              return callDep(makeMap(deps, callback).f);
          } else if (!deps.splice) {
              //deps is a config object, not an array.
              config = deps;
              if (config.deps) {
                  req(config.deps, config.callback);
              }
              if (!callback) {
                  return;
              }
  
              if (callback.splice) {
                  //callback is an array, which means it is a dependency list.
                  //Adjust args if there are dependencies
                  deps = callback;
                  callback = relName;
                  relName = null;
              } else {
                  deps = undef;
              }
          }
  
          //Support require(['a'])
          callback = callback || function () {};
  
          //If relName is a function, it is an errback handler,
          //so remove it.
          if (typeof relName === 'function') {
              relName = forceSync;
              forceSync = alt;
          }
  
          //Simulate async callback;
          if (forceSync) {
              main(undef, deps, callback, relName);
          } else {
              //Using a non-zero value because of concern for what old browsers
              //do, and latest browsers "upgrade" to 4 if lower value is used:
              //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout:
              //If want a value immediately, use require('id') instead -- something
              //that works in almond on the global level, but not guaranteed and
              //unlikely to work in other AMD implementations.
              setTimeout(function () {
                  main(undef, deps, callback, relName);
              }, 4);
          }
  
          return req;
      };
  
      /**
       * Just drops the config on the floor, but returns req in case
       * the config return value is used.
       */
      req.config = function (cfg) {
          return req(cfg);
      };
  
      /**
       * Expose module registry for debugging and tooling
       */
      requirejs._defined = defined;
  
      define = function (name, deps, callback) {
          if (typeof name !== 'string') {
              throw new Error('See almond README: incorrect module build, no module name');
          }
  
          //This module may not have dependencies
          if (!deps.splice) {
              //deps is not an array, so probably means
              //an object literal or factory function for
              //the value. Adjust args.
              callback = deps;
              deps = [];
          }
  
          if (!hasProp(defined, name) && !hasProp(waiting, name)) {
              waiting[name] = [name, deps, callback];
          }
      };
  
      define.amd = {
          jQuery: true
      };
  }());
  
  S2.requirejs = requirejs;S2.require = require;S2.define = define;
  }
  }());
  S2.define("almond", function(){});
  
  /* global jQuery:false, $:false */
  S2.define('jquery',[],function () {
    var _$ = jQuery || $;
  
    if (_$ == null && console && console.error) {
      console.error(
        'Select2: An instance of jQuery or a jQuery-compatible library was not ' +
        'found. Make sure that you are including jQuery before Select2 on your ' +
        'web page.'
      );
    }
  
    return _$;
  });
  
  S2.define('select2/utils',[
    'jquery'
  ], function ($) {
    var Utils = {};
  
    Utils.Extend = function (ChildClass, SuperClass) {
      var __hasProp = {}.hasOwnProperty;
  
      function BaseConstructor () {
        this.constructor = ChildClass;
      }
  
      for (var key in SuperClass) {
        if (__hasProp.call(SuperClass, key)) {
          ChildClass[key] = SuperClass[key];
        }
      }
  
      BaseConstructor.prototype = SuperClass.prototype;
      ChildClass.prototype = new BaseConstructor();
      ChildClass.__super__ = SuperClass.prototype;
  
      return ChildClass;
    };
  
    function getMethods (theClass) {
      var proto = theClass.prototype;
  
      var methods = [];
  
      for (var methodName in proto) {
        var m = proto[methodName];
  
        if (typeof m !== 'function') {
          continue;
        }
  
        if (methodName === 'constructor') {
          continue;
        }
  
        methods.push(methodName);
      }
  
      return methods;
    }
  
    Utils.Decorate = function (SuperClass, DecoratorClass) {
      var decoratedMethods = getMethods(DecoratorClass);
      var superMethods = getMethods(SuperClass);
  
      function DecoratedClass () {
        var unshift = Array.prototype.unshift;
  
        var argCount = DecoratorClass.prototype.constructor.length;
  
        var calledConstructor = SuperClass.prototype.constructor;
  
        if (argCount > 0) {
          unshift.call(arguments, SuperClass.prototype.constructor);
  
          calledConstructor = DecoratorClass.prototype.constructor;
        }
  
        calledConstructor.apply(this, arguments);
      }
  
      DecoratorClass.displayName = SuperClass.displayName;
  
      function ctr () {
        this.constructor = DecoratedClass;
      }
  
      DecoratedClass.prototype = new ctr();
  
      for (var m = 0; m < superMethods.length; m++) {
          var superMethod = superMethods[m];
  
          DecoratedClass.prototype[superMethod] =
            SuperClass.prototype[superMethod];
      }
  
      var calledMethod = function (methodName) {
        // Stub out the original method if it's not decorating an actual method
        var originalMethod = function () {};
  
        if (methodName in DecoratedClass.prototype) {
          originalMethod = DecoratedClass.prototype[methodName];
        }
  
        var decoratedMethod = DecoratorClass.prototype[methodName];
  
        return function () {
          var unshift = Array.prototype.unshift;
  
          unshift.call(arguments, originalMethod);
  
          return decoratedMethod.apply(this, arguments);
        };
      };
  
      for (var d = 0; d < decoratedMethods.length; d++) {
        var decoratedMethod = decoratedMethods[d];
  
        DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod);
      }
  
      return DecoratedClass;
    };
  
    var Observable = function () {
      this.listeners = {};
    };
  
    Observable.prototype.on = function (event, callback) {
      this.listeners = this.listeners || {};
  
      if (event in this.listeners) {
        this.listeners[event].push(callback);
      } else {
        this.listeners[event] = [callback];
      }
    };
  
    Observable.prototype.trigger = function (event) {
      var slice = Array.prototype.slice;
      var params = slice.call(arguments, 1);
  
      this.listeners = this.listeners || {};
  
      // Params should always come in as an array
      if (params == null) {
        params = [];
      }
  
      // If there are no arguments to the event, use a temporary object
      if (params.length === 0) {
        params.push({});
      }
  
      // Set the `_type` of the first object to the event
      params[0]._type = event;
  
      if (event in this.listeners) {
        this.invoke(this.listeners[event], slice.call(arguments, 1));
      }
  
      if ('*' in this.listeners) {
        this.invoke(this.listeners['*'], arguments);
      }
    };
  
    Observable.prototype.invoke = function (listeners, params) {
      for (var i = 0, len = listeners.length; i < len; i++) {
        listeners[i].apply(this, params);
      }
    };
  
    Utils.Observable = Observable;
  
    Utils.generateChars = function (length) {
      var chars = '';
  
      for (var i = 0; i < length; i++) {
        var randomChar = Math.floor(Math.random() * 36);
        chars += randomChar.toString(36);
      }
  
      return chars;
    };
  
    Utils.bind = function (func, context) {
      return function () {
        func.apply(context, arguments);
      };
    };
  
    Utils._convertData = function (data) {
      for (var originalKey in data) {
        var keys = originalKey.split('-');
  
        var dataLevel = data;
  
        if (keys.length === 1) {
          continue;
        }
  
        for (var k = 0; k < keys.length; k++) {
          var key = keys[k];
  
          // Lowercase the first letter
          // By default, dash-separated becomes camelCase
          key = key.substring(0, 1).toLowerCase() + key.substring(1);
  
          if (!(key in dataLevel)) {
            dataLevel[key] = {};
          }
  
          if (k == keys.length - 1) {
            dataLevel[key] = data[originalKey];
          }
  
          dataLevel = dataLevel[key];
        }
  
        delete data[originalKey];
      }
  
      return data;
    };
  
    Utils.hasScroll = function (index, el) {
      // Adapted from the function created by @ShadowScripter
      // and adapted by @BillBarry on the Stack Exchange Code Review website.
      // The original code can be found at
      // http://codereview.stackexchange.com/q/13338
      // and was designed to be used with the Sizzle selector engine.
  
      var $el = $(el);
      var overflowX = el.style.overflowX;
      var overflowY = el.style.overflowY;
  
      //Check both x and y declarations
      if (overflowX === overflowY &&
          (overflowY === 'hidden' || overflowY === 'visible')) {
        return false;
      }
  
      if (overflowX === 'scroll' || overflowY === 'scroll') {
        return true;
      }
  
      return ($el.innerHeight() < el.scrollHeight ||
        $el.innerWidth() < el.scrollWidth);
    };
  
    Utils.escapeMarkup = function (markup) {
      var replaceMap = {
        '\\': '&#92;',
        '&': '&amp;',
        '<': '&lt;',
        '>': '&gt;',
        '"': '&quot;',
        '\'': '&#39;',
        '/': '&#47;'
      };
  
      // Do not try to escape the markup if it's not a string
      if (typeof markup !== 'string') {
        return markup;
      }
  
      return String(markup).replace(/[&<>"'\/\\]/g, function (match) {
        return replaceMap[match];
      });
    };
  
    // Append an array of jQuery nodes to a given element.
    Utils.appendMany = function ($element, $nodes) {
      // jQuery 1.7.x does not support $.fn.append() with an array
      // Fall back to a jQuery object collection using $.fn.add()
      if ($.fn.jquery.substr(0, 3) === '1.7') {
        var $jqNodes = $();
  
        $.map($nodes, function (node) {
          $jqNodes = $jqNodes.add(node);
        });
  
        $nodes = $jqNodes;
      }
  
      $element.append($nodes);
    };
  
    return Utils;
  });
  
  S2.define('select2/results',[
    'jquery',
    './utils'
  ], function ($, Utils) {
    function Results ($element, options, dataAdapter) {
      this.$element = $element;
      this.data = dataAdapter;
      this.options = options;
  
      Results.__super__.constructor.call(this);
    }
  
    Utils.Extend(Results, Utils.Observable);
  
    Results.prototype.render = function () {
      var $results = $(
        '<ul class="select2-results__options" role="tree"></ul>'
      );
  
      if (this.options.get('multiple')) {
        $results.attr('aria-multiselectable', 'true');
      }
  
      this.$results = $results;
  
      return $results;
    };
  
    Results.prototype.clear = function () {
      this.$results.empty();
    };
  
    Results.prototype.displayMessage = function (params) {
      var escapeMarkup = this.options.get('escapeMarkup');
  
      this.clear();
      this.hideLoading();
  
      var $message = $(
        '<li role="treeitem" aria-live="assertive"' +
        ' class="select2-results__option"></li>'
      );
  
      var message = this.options.get('translations').get(params.message);
  
      $message.append(
        escapeMarkup(
          message(params.args)
        )
      );
  
      $message[0].className += ' select2-results__message';
  
      this.$results.append($message);
    };
  
    Results.prototype.hideMessages = function () {
      this.$results.find('.select2-results__message').remove();
    };
  
    Results.prototype.append = function (data) {
      this.hideLoading();
  
      var $options = [];
  
      if (data.results == null || data.results.length === 0) {
        if (this.$results.children().length === 0) {
          this.trigger('results:message', {
            message: 'noResults'
          });
        }
  
        return;
      }
  
      data.results = this.sort(data.results);
  
      for (var d = 0; d < data.results.length; d++) {
        var item = data.results[d];
  
        var $option = this.option(item);
  
        $options.push($option);
      }
  
      this.$results.append($options);
    };
  
    Results.prototype.position = function ($results, $dropdown) {
      var $resultsContainer = $dropdown.find('.select2-results');
      $resultsContainer.append($results);
    };
  
    Results.prototype.sort = function (data) {
      var sorter = this.options.get('sorter');
  
      return sorter(data);
    };
  
    Results.prototype.highlightFirstItem = function () {
      var $options = this.$results
        .find('.select2-results__option[aria-selected]');
  
      var $selected = $options.filter('[aria-selected=true]');
  
      // Check if there are any selected options
      if ($selected.length > 0) {
        // If there are selected options, highlight the first
        $selected.first().trigger('mouseenter');
      } else {
        // If there are no selected options, highlight the first option
        // in the dropdown
        $options.first().trigger('mouseenter');
      }
  
      this.ensureHighlightVisible();
    };
  
    Results.prototype.setClasses = function () {
      var self = this;
  
      this.data.current(function (selected) {
        var selectedIds = $.map(selected, function (s) {
          return s.id.toString();
        });
  
        var $options = self.$results
          .find('.select2-results__option[aria-selected]');
  
        $options.each(function () {
          var $option = $(this);
  
          var item = $.data(this, 'data');
  
          // id needs to be converted to a string when comparing
          var id = '' + item.id;
  
          if ((item.element != null && item.element.selected) ||
              (item.element == null && $.inArray(id, selectedIds) > -1)) {
            $option.attr('aria-selected', 'true');
          } else {
            $option.attr('aria-selected', 'false');
          }
        });
  
      });
    };
  
    Results.prototype.showLoading = function (params) {
      this.hideLoading();
  
      var loadingMore = this.options.get('translations').get('searching');
  
      var loading = {
        disabled: true,
        loading: true,
        text: loadingMore(params)
      };
      var $loading = this.option(loading);
      $loading.className += ' loading-results';
  
      this.$results.prepend($loading);
    };
  
    Results.prototype.hideLoading = function () {
      this.$results.find('.loading-results').remove();
    };
  
    Results.prototype.option = function (data) {
      var option = document.createElement('li');
      option.className = 'select2-results__option';
  
      var attrs = {
        'role': 'treeitem',
        'aria-selected': 'false'
      };
  
      if (data.disabled) {
        delete attrs['aria-selected'];
        attrs['aria-disabled'] = 'true';
      }
  
      if (data.id == null) {
        delete attrs['aria-selected'];
      }
  
      if (data._resultId != null) {
        option.id = data._resultId;
      }
  
      if (data.title) {
        option.title = data.title;
      }
  
      if (data.children) {
        attrs.role = 'group';
        attrs['aria-label'] = data.text;
        delete attrs['aria-selected'];
      }
  
      for (var attr in attrs) {
        var val = attrs[attr];
  
        option.setAttribute(attr, val);
      }
  
      if (data.children) {
        var $option = $(option);
  
        var label = document.createElement('strong');
        label.className = 'select2-results__group';
  
        var $label = $(label);
        this.template(data, label);
  
        var $children = [];
  
        for (var c = 0; c < data.children.length; c++) {
          var child = data.children[c];
  
          var $child = this.option(child);
  
          $children.push($child);
        }
  
        var $childrenContainer = $('<ul></ul>', {
          'class': 'select2-results__options select2-results__options--nested'
        });
  
        $childrenContainer.append($children);
  
        $option.append(label);
        $option.append($childrenContainer);
      } else {
        this.template(data, option);
      }
  
      $.data(option, 'data', data);
  
      return option;
    };
  
    Results.prototype.bind = function (container, $container) {
      var self = this;
  
      var id = container.id + '-results';
  
      this.$results.attr('id', id);
  
      container.on('results:all', function (params) {
        self.clear();
        self.append(params.data);
  
        if (container.isOpen()) {
          self.setClasses();
          self.highlightFirstItem();
        }
      });
  
      container.on('results:append', function (params) {
        self.append(params.data);
  
        if (container.isOpen()) {
          self.setClasses();
        }
      });
  
      container.on('query', function (params) {
        self.hideMessages();
        self.showLoading(params);
      });
  
      container.on('select', function () {
        if (!container.isOpen()) {
          return;
        }
  
        self.setClasses();
        self.highlightFirstItem();
      });
  
      container.on('unselect', function () {
        if (!container.isOpen()) {
          return;
        }
  
        self.setClasses();
        self.highlightFirstItem();
      });
  
      container.on('open', function () {
        // When the dropdown is open, aria-expended="true"
        self.$results.attr('aria-expanded', 'true');
        self.$results.attr('aria-hidden', 'false');
  
        self.setClasses();
        self.ensureHighlightVisible();
      });
  
      container.on('close', function () {
        // When the dropdown is closed, aria-expended="false"
        self.$results.attr('aria-expanded', 'false');
        self.$results.attr('aria-hidden', 'true');
        self.$results.removeAttr('aria-activedescendant');
      });
  
      container.on('results:toggle', function () {
        var $highlighted = self.getHighlightedResults();
  
        if ($highlighted.length === 0) {
          return;
        }
  
        $highlighted.trigger('mouseup');
      });
  
      container.on('results:select', function () {
        var $highlighted = self.getHighlightedResults();
  
        if ($highlighted.length === 0) {
          return;
        }
  
        var data = $highlighted.data('data');
  
        if ($highlighted.attr('aria-selected') == 'true') {
          self.trigger('close', {});
        } else {
          self.trigger('select', {
            data: data
          });
        }
      });
  
      container.on('results:previous', function () {
        var $highlighted = self.getHighlightedResults();
  
        var $options = self.$results.find('[aria-selected]');
  
        var currentIndex = $options.index($highlighted);
  
        // If we are already at te top, don't move further
        if (currentIndex === 0) {
          return;
        }
  
        var nextIndex = currentIndex - 1;
  
        // If none are highlighted, highlight the first
        if ($highlighted.length === 0) {
          nextIndex = 0;
        }
  
        var $next = $options.eq(nextIndex);
  
        $next.trigger('mouseenter');
  
        var currentOffset = self.$results.offset().top;
        var nextTop = $next.offset().top;
        var nextOffset = self.$results.scrollTop() + (nextTop - currentOffset);
  
        if (nextIndex === 0) {
          self.$results.scrollTop(0);
        } else if (nextTop - currentOffset < 0) {
          self.$results.scrollTop(nextOffset);
        }
      });
  
      container.on('results:next', function () {
        var $highlighted = self.getHighlightedResults();
  
        var $options = self.$results.find('[aria-selected]');
  
        var currentIndex = $options.index($highlighted);
  
        var nextIndex = currentIndex + 1;
  
        // If we are at the last option, stay there
        if (nextIndex >= $options.length) {
          return;
        }
  
        var $next = $options.eq(nextIndex);
  
        $next.trigger('mouseenter');
  
        var currentOffset = self.$results.offset().top +
          self.$results.outerHeight(false);
        var nextBottom = $next.offset().top + $next.outerHeight(false);
        var nextOffset = self.$results.scrollTop() + nextBottom - currentOffset;
  
        if (nextIndex === 0) {
          self.$results.scrollTop(0);
        } else if (nextBottom > currentOffset) {
          self.$results.scrollTop(nextOffset);
        }
      });
  
      container.on('results:focus', function (params) {
        params.element.addClass('select2-results__option--highlighted');
      });
  
      container.on('results:message', function (params) {
        self.displayMessage(params);
      });
  
      if ($.fn.mousewheel) {
        this.$results.on('mousewheel', function (e) {
          var top = self.$results.scrollTop();
  
          var bottom = self.$results.get(0).scrollHeight - top + e.deltaY;
  
          var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0;
          var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height();
  
          if (isAtTop) {
            self.$results.scrollTop(0);
  
            e.preventDefault();
            e.stopPropagation();
          } else if (isAtBottom) {
            self.$results.scrollTop(
              self.$results.get(0).scrollHeight - self.$results.height()
            );
  
            e.preventDefault();
            e.stopPropagation();
          }
        });
      }
  
      this.$results.on('mouseup', '.select2-results__option[aria-selected]',
        function (evt) {
        var $this = $(this);
  
        var data = $this.data('data');
  
        if ($this.attr('aria-selected') === 'true') {
          if (self.options.get('multiple')) {
            self.trigger('unselect', {
              originalEvent: evt,
              data: data
            });
          } else {
            self.trigger('close', {});
          }
  
          return;
        }
  
        self.trigger('select', {
          originalEvent: evt,
          data: data
        });
      });
  
      this.$results.on('mouseenter', '.select2-results__option[aria-selected]',
        function (evt) {
        var data = $(this).data('data');
  
        self.getHighlightedResults()
            .removeClass('select2-results__option--highlighted');
  
        self.trigger('results:focus', {
          data: data,
          element: $(this)
        });
      });
    };
  
    Results.prototype.getHighlightedResults = function () {
      var $highlighted = this.$results
      .find('.select2-results__option--highlighted');
  
      return $highlighted;
    };
  
    Results.prototype.destroy = function () {
      this.$results.remove();
    };
  
    Results.prototype.ensureHighlightVisible = function () {
      var $highlighted = this.getHighlightedResults();
  
      if ($highlighted.length === 0) {
        return;
      }
  
      var $options = this.$results.find('[aria-selected]');
  
      var currentIndex = $options.index($highlighted);
  
      var currentOffset = this.$results.offset().top;
      var nextTop = $highlighted.offset().top;
      var nextOffset = this.$results.scrollTop() + (nextTop - currentOffset);
  
      var offsetDelta = nextTop - currentOffset;
      nextOffset -= $highlighted.outerHeight(false) * 2;
  
      if (currentIndex <= 2) {
        this.$results.scrollTop(0);
      } else if (offsetDelta > this.$results.outerHeight() || offsetDelta < 0) {
        this.$results.scrollTop(nextOffset);
      }
    };
  
    Results.prototype.template = function (result, container) {
      var template = this.options.get('templateResult');
      var escapeMarkup = this.options.get('escapeMarkup');
  
      var content = template(result, container);
  
      if (content == null) {
        container.style.display = 'none';
      } else if (typeof content === 'string') {
        container.innerHTML = escapeMarkup(content);
      } else {
        $(container).append(content);
      }
    };
  
    return Results;
  });
  
  S2.define('select2/keys',[
  
  ], function () {
    var KEYS = {
      BACKSPACE: 8,
      TAB: 9,
      ENTER: 13,
      SHIFT: 16,
      CTRL: 17,
      ALT: 18,
      ESC: 27,
      SPACE: 32,
      PAGE_UP: 33,
      PAGE_DOWN: 34,
      END: 35,
      HOME: 36,
      LEFT: 37,
      UP: 38,
      RIGHT: 39,
      DOWN: 40,
      DELETE: 46
    };
  
    return KEYS;
  });
  
  S2.define('select2/selection/base',[
    'jquery',
    '../utils',
    '../keys'
  ], function ($, Utils, KEYS) {
    function BaseSelection ($element, options) {
      this.$element = $element;
      this.options = options;
  
      BaseSelection.__super__.constructor.call(this);
    }
  
    Utils.Extend(BaseSelection, Utils.Observable);
  
    BaseSelection.prototype.render = function () {
      var $selection = $(
        '<span class="select2-selection" role="combobox" ' +
        ' aria-haspopup="true" aria-expanded="false">' +
        '</span>'
      );
  
      this._tabindex = 0;
  
      if (this.$element.data('old-tabindex') != null) {
        this._tabindex = this.$element.data('old-tabindex');
      } else if (this.$element.attr('tabindex') != null) {
        this._tabindex = this.$element.attr('tabindex');
      }
  
      $selection.attr('title', this.$element.attr('title'));
      $selection.attr('tabindex', this._tabindex);
  
      this.$selection = $selection;
  
      return $selection;
    };
  
    BaseSelection.prototype.bind = function (container, $container) {
      var self = this;
  
      var id = container.id + '-container';
      var resultsId = container.id + '-results';
  
      this.container = container;
  
      this.$selection.on('focus', function (evt) {
        self.trigger('focus', evt);
      });
  
      this.$selection.on('blur', function (evt) {
        self._handleBlur(evt);
      });
  
      this.$selection.on('keydown', function (evt) {
        self.trigger('keypress', evt);
  
        if (evt.which === KEYS.SPACE) {
          evt.preventDefault();
        }
      });
  
      container.on('results:focus', function (params) {
        self.$selection.attr('aria-activedescendant', params.data._resultId);
      });
  
      container.on('selection:update', function (params) {
        self.update(params.data);
      });
  
      container.on('open', function () {
        // When the dropdown is open, aria-expanded="true"
        self.$selection.attr('aria-expanded', 'true');
        self.$selection.attr('aria-owns', resultsId);
  
        self._attachCloseHandler(container);
      });
  
      container.on('close', function () {
        // When the dropdown is closed, aria-expanded="false"
        self.$selection.attr('aria-expanded', 'false');
        self.$selection.removeAttr('aria-activedescendant');
        self.$selection.removeAttr('aria-owns');
  
        self.$selection.focus();
  
        self._detachCloseHandler(container);
      });
  
      container.on('enable', function () {
        self.$selection.attr('tabindex', self._tabindex);
      });
  
      container.on('disable', function () {
        self.$selection.attr('tabindex', '-1');
      });
    };
  
    BaseSelection.prototype._handleBlur = function (evt) {
      var self = this;
  
      // This needs to be delayed as the active element is the body when the tab
      // key is pressed, possibly along with others.
      window.setTimeout(function () {
        // Don't trigger `blur` if the focus is still in the selection
        if (
          (document.activeElement == self.$selection[0]) ||
          ($.contains(self.$selection[0], document.activeElement))
        ) {
          return;
        }
  
        self.trigger('blur', evt);
      }, 1);
    };
  
    BaseSelection.prototype._attachCloseHandler = function (container) {
      var self = this;
  
      $(document.body).on('mousedown.select2.' + container.id, function (e) {
        var $target = $(e.target);
  
        var $select = $target.closest('.select2');
  
        var $all = $('.select2.select2-container--open');
  
        $all.each(function () {
          var $this = $(this);
  
          if (this == $select[0]) {
            return;
          }
  
          var $element = $this.data('element');
  
          $element.select2('close');
        });
      });
    };
  
    BaseSelection.prototype._detachCloseHandler = function (container) {
      $(document.body).off('mousedown.select2.' + container.id);
    };
  
    BaseSelection.prototype.position = function ($selection, $container) {
      var $selectionContainer = $container.find('.selection');
      $selectionContainer.append($selection);
    };
  
    BaseSelection.prototype.destroy = function () {
      this._detachCloseHandler(this.container);
    };
  
    BaseSelection.prototype.update = function (data) {
      throw new Error('The `update` method must be defined in child classes.');
    };
  
    return BaseSelection;
  });
  
  S2.define('select2/selection/single',[
    'jquery',
    './base',
    '../utils',
    '../keys'
  ], function ($, BaseSelection, Utils, KEYS) {
    function SingleSelection () {
      SingleSelection.__super__.constructor.apply(this, arguments);
    }
  
    Utils.Extend(SingleSelection, BaseSelection);
  
    SingleSelection.prototype.render = function () {
      var $selection = SingleSelection.__super__.render.call(this);
  
      $selection.addClass('select2-selection--single');
  
      $selection.html(
        '<span class="select2-selection__rendered"></span>' +
        '<span class="select2-selection__arrow" role="presentation">' +
          '<b role="presentation"></b>' +
        '</span>'
      );
  
      return $selection;
    };
  
    SingleSelection.prototype.bind = function (container, $container) {
      var self = this;
  
      SingleSelection.__super__.bind.apply(this, arguments);
  
      var id = container.id + '-container';
  
      this.$selection.find('.select2-selection__rendered').attr('id', id);
      this.$selection.attr('aria-labelledby', id);
  
      this.$selection.on('mousedown', function (evt) {
        // Only respond to left clicks
        if (evt.which !== 1) {
          return;
        }
  
        self.trigger('toggle', {
          originalEvent: evt
        });
      });
  
      this.$selection.on('focus', function (evt) {
        // User focuses on the container
      });
  
      this.$selection.on('blur', function (evt) {
        // User exits the container
      });
  
      container.on('focus', function (evt) {
        if (!container.isOpen()) {
          self.$selection.focus();
        }
      });
  
      container.on('selection:update', function (params) {
        self.update(params.data);
      });
    };
  
    SingleSelection.prototype.clear = function () {
      this.$selection.find('.select2-selection__rendered').empty();
    };
  
    SingleSelection.prototype.display = function (data, container) {
      var template = this.options.get('templateSelection');
      var escapeMarkup = this.options.get('escapeMarkup');
  
      return escapeMarkup(template(data, container));
    };
  
    SingleSelection.prototype.selectionContainer = function () {
      return $('<span></span>');
    };
  
    SingleSelection.prototype.update = function (data) {
      if (data.length === 0) {
        this.clear();
        return;
      }
  
      var selection = data[0];
  
      var $rendered = this.$selection.find('.select2-selection__rendered');
      var formatted = this.display(selection, $rendered);
  
      $rendered.empty().append(formatted);
      $rendered.prop('title', selection.title || selection.text);
    };
  
    return SingleSelection;
  });
  
  S2.define('select2/selection/multiple',[
    'jquery',
    './base',
    '../utils'
  ], function ($, BaseSelection, Utils) {
    function MultipleSelection ($element, options) {
      MultipleSelection.__super__.constructor.apply(this, arguments);
    }
  
    Utils.Extend(MultipleSelection, BaseSelection);
  
    MultipleSelection.prototype.render = function () {
      var $selection = MultipleSelection.__super__.render.call(this);
  
      $selection.addClass('select2-selection--multiple');
  
      $selection.html(
        '<ul class="select2-selection__rendered"></ul>'
      );
  
      return $selection;
    };
  
    MultipleSelection.prototype.bind = function (container, $container) {
      var self = this;
  
      MultipleSelection.__super__.bind.apply(this, arguments);
  
      this.$selection.on('click', function (evt) {
        self.trigger('toggle', {
          originalEvent: evt
        });
      });
  
      this.$selection.on(
        'click',
        '.select2-selection__choice__remove',
        function (evt) {
          // Ignore the event if it is disabled
          if (self.options.get('disabled')) {
            return;
          }
  
          var $remove = $(this);
          var $selection = $remove.parent();
  
          var data = $selection.data('data');
  
          self.trigger('unselect', {
            originalEvent: evt,
            data: data
          });
        }
      );
    };
  
    MultipleSelection.prototype.clear = function () {
      this.$selection.find('.select2-selection__rendered').empty();
    };
  
    MultipleSelection.prototype.display = function (data, container) {
      var template = this.options.get('templateSelection');
      var escapeMarkup = this.options.get('escapeMarkup');
  
      return escapeMarkup(template(data, container));
    };
  
    MultipleSelection.prototype.selectionContainer = function () {
      var $container = $(
        '<li class="select2-selection__choice">' +
          '<span class="select2-selection__choice__remove" role="presentation">' +
            '&times;' +
          '</span>' +
        '</li>'
      );
  
      return $container;
    };
  
    MultipleSelection.prototype.update = function (data) {
      this.clear();
  
      if (data.length === 0) {
        return;
      }
  
      var $selections = [];
  
      for (var d = 0; d < data.length; d++) {
        var selection = data[d];
  
        var $selection = this.selectionContainer();
        var formatted = this.display(selection, $selection);
  
        $selection.append(formatted);
        $selection.prop('title', selection.title || selection.text);
  
        $selection.data('data', selection);
  
        $selections.push($selection);
      }
  
      var $rendered = this.$selection.find('.select2-selection__rendered');
  
      Utils.appendMany($rendered, $selections);
    };
  
    return MultipleSelection;
  });
  
  S2.define('select2/selection/placeholder',[
    '../utils'
  ], function (Utils) {
    function Placeholder (decorated, $element, options) {
      this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
  
      decorated.call(this, $element, options);
    }
  
    Placeholder.prototype.normalizePlaceholder = function (_, placeholder) {
      if (typeof placeholder === 'string') {
        placeholder = {
          id: '',
          text: placeholder
        };
      }
  
      return placeholder;
    };
  
    Placeholder.prototype.createPlaceholder = function (decorated, placeholder) {
      var $placeholder = this.selectionContainer();
  
      $placeholder.html(this.display(placeholder));
      $placeholder.addClass('select2-selection__placeholder')
                  .removeClass('select2-selection__choice');
  
      return $placeholder;
    };
  
    Placeholder.prototype.update = function (decorated, data) {
      var singlePlaceholder = (
        data.length == 1 && data[0].id != this.placeholder.id
      );
      var multipleSelections = data.length > 1;
  
      if (multipleSelections || singlePlaceholder) {
        return decorated.call(this, data);
      }
  
      this.clear();
  
      var $placeholder = this.createPlaceholder(this.placeholder);
  
      this.$selection.find('.select2-selection__rendered').append($placeholder);
    };
  
    return Placeholder;
  });
  
  S2.define('select2/selection/allowClear',[
    'jquery',
    '../keys'
  ], function ($, KEYS) {
    function AllowClear () { }
  
    AllowClear.prototype.bind = function (decorated, container, $container) {
      var self = this;
  
      decorated.call(this, container, $container);
  
      if (this.placeholder == null) {
        if (this.options.get('debug') && window.console && console.error) {
          console.error(
            'Select2: The `allowClear` option should be used in combination ' +
            'with the `placeholder` option.'
          );
        }
      }
  
      this.$selection.on('mousedown', '.select2-selection__clear',
        function (evt) {
          self._handleClear(evt);
      });
  
      container.on('keypress', function (evt) {
        self._handleKeyboardClear(evt, container);
      });
    };
  
    AllowClear.prototype._handleClear = function (_, evt) {
      // Ignore the event if it is disabled
      if (this.options.get('disabled')) {
        return;
      }
  
      var $clear = this.$selection.find('.select2-selection__clear');
  
      // Ignore the event if nothing has been selected
      if ($clear.length === 0) {
        return;
      }
  
      evt.stopPropagation();
  
      var data = $clear.data('data');
  
      for (var d = 0; d < data.length; d++) {
        var unselectData = {
          data: data[d]
        };
  
        // Trigger the `unselect` event, so people can prevent it from being
        // cleared.
        this.trigger('unselect', unselectData);
  
        // If the event was prevented, don't clear it out.
        if (unselectData.prevented) {
          return;
        }
      }
  
      this.$element.val(this.placeholder.id).trigger('change');
  
      this.trigger('toggle', {});
    };
  
    AllowClear.prototype._handleKeyboardClear = function (_, evt, container) {
      if (container.isOpen()) {
        return;
      }
  
      if (evt.which == KEYS.DELETE || evt.which == KEYS.BACKSPACE) {
        this._handleClear(evt);
      }
    };
  
    AllowClear.prototype.update = function (decorated, data) {
      decorated.call(this, data);
  
      if (this.$selection.find('.select2-selection__placeholder').length > 0 ||
          data.length === 0) {
        return;
      }
  
      var $remove = $(
        '<span class="select2-selection__clear">' +
          '&times;' +
        '</span>'
      );
      $remove.data('data', data);
  
      this.$selection.find('.select2-selection__rendered').prepend($remove);
    };
  
    return AllowClear;
  });
  
  S2.define('select2/selection/search',[
    'jquery',
    '../utils',
    '../keys'
  ], function ($, Utils, KEYS) {
    function Search (decorated, $element, options) {
      decorated.call(this, $element, options);
    }
  
    Search.prototype.render = function (decorated) {
      var $search = $(
        '<li class="select2-search select2-search--inline">' +
          '<input class="select2-search__field" type="search" tabindex="-1"' +
          ' autocomplete="off" autocorrect="off" autocapitalize="off"' +
          ' spellcheck="false" role="textbox" aria-autocomplete="list" />' +
        '</li>'
      );
  
      this.$searchContainer = $search;
      this.$search = $search.find('input');
  
      var $rendered = decorated.call(this);
  
      this._transferTabIndex();
  
      return $rendered;
    };
  
    Search.prototype.bind = function (decorated, container, $container) {
      var self = this;
  
      decorated.call(this, container, $container);
  
      container.on('open', function () {
        self.$search.trigger('focus');
      });
  
      container.on('close', function () {
        self.$search.val('');
        self.$search.removeAttr('aria-activedescendant');
        self.$search.trigger('focus');
      });
  
      container.on('enable', function () {
        self.$search.prop('disabled', false);
  
        self._transferTabIndex();
      });
  
      container.on('disable', function () {
        self.$search.prop('disabled', true);
      });
  
      container.on('focus', function (evt) {
        self.$search.trigger('focus');
      });
  
      container.on('results:focus', function (params) {
        self.$search.attr('aria-activedescendant', params.id);
      });
  
      this.$selection.on('focusin', '.select2-search--inline', function (evt) {
        self.trigger('focus', evt);
      });
  
      this.$selection.on('focusout', '.select2-search--inline', function (evt) {
        self._handleBlur(evt);
      });
  
      this.$selection.on('keydown', '.select2-search--inline', function (evt) {
        evt.stopPropagation();
  
        self.trigger('keypress', evt);
  
        self._keyUpPrevented = evt.isDefaultPrevented();
  
        var key = evt.which;
  
        if (key === KEYS.BACKSPACE && self.$search.val() === '') {
          var $previousChoice = self.$searchContainer
            .prev('.select2-selection__choice');
  
          if ($previousChoice.length > 0) {
            var item = $previousChoice.data('data');
  
            self.searchRemoveChoice(item);
  
            evt.preventDefault();
          }
        }
      });
  
      // Try to detect the IE version should the `documentMode` property that
      // is stored on the document. This is only implemented in IE and is
      // slightly cleaner than doing a user agent check.
      // This property is not available in Edge, but Edge also doesn't have
      // this bug.
      var msie = document.documentMode;
      var disableInputEvents = msie && msie <= 11;
  
      // Workaround for browsers which do not support the `input` event
      // This will prevent double-triggering of events for browsers which support
      // both the `keyup` and `input` events.
      this.$selection.on(
        'input.searchcheck',
        '.select2-search--inline',
        function (evt) {
          // IE will trigger the `input` event when a placeholder is used on a
          // search box. To get around this issue, we are forced to ignore all
          // `input` events in IE and keep using `keyup`.
          if (disableInputEvents) {
            self.$selection.off('input.search input.searchcheck');
            return;
          }
  
          // Unbind the duplicated `keyup` event
          self.$selection.off('keyup.search');
        }
      );
  
      this.$selection.on(
        'keyup.search input.search',
        '.select2-search--inline',
        function (evt) {
          // IE will trigger the `input` event when a placeholder is used on a
          // search box. To get around this issue, we are forced to ignore all
          // `input` events in IE and keep using `keyup`.
          if (disableInputEvents && evt.type === 'input') {
            self.$selection.off('input.search input.searchcheck');
            return;
          }
  
          var key = evt.which;
  
          // We can freely ignore events from modifier keys
          if (key == KEYS.SHIFT || key == KEYS.CTRL || key == KEYS.ALT) {
            return;
          }
  
          // Tabbing will be handled during the `keydown` phase
          if (key == KEYS.TAB) {
            return;
          }
  
          self.handleSearch(evt);
        }
      );
    };
  
    /**
     * This method will transfer the tabindex attribute from the rendered
     * selection to the search box. This allows for the search box to be used as
     * the primary focus instead of the selection container.
     *
     * @private
     */
    Search.prototype._transferTabIndex = function (decorated) {
      this.$search.attr('tabindex', this.$selection.attr('tabindex'));
      this.$selection.attr('tabindex', '-1');
    };
  
    Search.prototype.createPlaceholder = function (decorated, placeholder) {
      this.$search.attr('placeholder', placeholder.text);
    };
  
    Search.prototype.update = function (decorated, data) {
      var searchHadFocus = this.$search[0] == document.activeElement;
  
      this.$search.attr('placeholder', '');
  
      decorated.call(this, data);
  
      this.$selection.find('.select2-selection__rendered')
                     .append(this.$searchContainer);
  
      this.resizeSearch();
      if (searchHadFocus) {
        this.$search.focus();
      }
    };
  
    Search.prototype.handleSearch = function () {
      this.resizeSearch();
  
      if (!this._keyUpPrevented) {
        var input = this.$search.val();
  
        this.trigger('query', {
          term: input
        });
      }
  
      this._keyUpPrevented = false;
    };
  
    Search.prototype.searchRemoveChoice = function (decorated, item) {
      this.trigger('unselect', {
        data: item
      });
  
      this.$search.val(item.text);
      this.handleSearch();
    };
  
    Search.prototype.resizeSearch = function () {
      this.$search.css('width', '25px');
  
      var width = '';
  
      if (this.$search.attr('placeholder') !== '') {
        width = this.$selection.find('.select2-selection__rendered').innerWidth();
      } else {
        var minimumWidth = this.$search.val().length + 1;
  
        width = (minimumWidth * 0.75) + 'em';
      }
  
      this.$search.css('width', width);
    };
  
    return Search;
  });
  
  S2.define('select2/selection/eventRelay',[
    'jquery'
  ], function ($) {
    function EventRelay () { }
  
    EventRelay.prototype.bind = function (decorated, container, $container) {
      var self = this;
      var relayEvents = [
        'open', 'opening',
        'close', 'closing',
        'select', 'selecting',
        'unselect', 'unselecting'
      ];
  
      var preventableEvents = ['opening', 'closing', 'selecting', 'unselecting'];
  
      decorated.call(this, container, $container);
  
      container.on('*', function (name, params) {
        // Ignore events that should not be relayed
        if ($.inArray(name, relayEvents) === -1) {
          return;
        }
  
        // The parameters should always be an object
        params = params || {};
  
        // Generate the jQuery event for the Select2 event
        var evt = $.Event('select2:' + name, {
          params: params
        });
  
        self.$element.trigger(evt);
  
        // Only handle preventable events if it was one
        if ($.inArray(name, preventableEvents) === -1) {
          return;
        }
  
        params.prevented = evt.isDefaultPrevented();
      });
    };
  
    return EventRelay;
  });
  
  S2.define('select2/translation',[
    'jquery',
    'require'
  ], function ($, require) {
    function Translation (dict) {
      this.dict = dict || {};
    }
  
    Translation.prototype.all = function () {
      return this.dict;
    };
  
    Translation.prototype.get = function (key) {
      return this.dict[key];
    };
  
    Translation.prototype.extend = function (translation) {
      this.dict = $.extend({}, translation.all(), this.dict);
    };
  
    // Static functions
  
    Translation._cache = {};
  
    Translation.loadPath = function (path) {
      if (!(path in Translation._cache)) {
        var translations = require(path);
  
        Translation._cache[path] = translations;
      }
  
      return new Translation(Translation._cache[path]);
    };
  
    return Translation;
  });
  
  S2.define('select2/diacritics',[
  
  ], function () {
    var diacritics = {
      '\u24B6': 'A',
      '\uFF21': 'A',
      '\u00C0': 'A',
      '\u00C1': 'A',
      '\u00C2': 'A',
      '\u1EA6': 'A',
      '\u1EA4': 'A',
      '\u1EAA': 'A',
      '\u1EA8': 'A',
      '\u00C3': 'A',
      '\u0100': 'A',
      '\u0102': 'A',
      '\u1EB0': 'A',
      '\u1EAE': 'A',
      '\u1EB4': 'A',
      '\u1EB2': 'A',
      '\u0226': 'A',
      '\u01E0': 'A',
      '\u00C4': 'A',
      '\u01DE': 'A',
      '\u1EA2': 'A',
      '\u00C5': 'A',
      '\u01FA': 'A',
      '\u01CD': 'A',
      '\u0200': 'A',
      '\u0202': 'A',
      '\u1EA0': 'A',
      '\u1EAC': 'A',
      '\u1EB6': 'A',
      '\u1E00': 'A',
      '\u0104': 'A',
      '\u023A': 'A',
      '\u2C6F': 'A',
      '\uA732': 'AA',
      '\u00C6': 'AE',
      '\u01FC': 'AE',
      '\u01E2': 'AE',
      '\uA734': 'AO',
      '\uA736': 'AU',
      '\uA738': 'AV',
      '\uA73A': 'AV',
      '\uA73C': 'AY',
      '\u24B7': 'B',
      '\uFF22': 'B',
      '\u1E02': 'B',
      '\u1E04': 'B',
      '\u1E06': 'B',
      '\u0243': 'B',
      '\u0182': 'B',
      '\u0181': 'B',
      '\u24B8': 'C',
      '\uFF23': 'C',
      '\u0106': 'C',
      '\u0108': 'C',
      '\u010A': 'C',
      '\u010C': 'C',
      '\u00C7': 'C',
      '\u1E08': 'C',
      '\u0187': 'C',
      '\u023B': 'C',
      '\uA73E': 'C',
      '\u24B9': 'D',
      '\uFF24': 'D',
      '\u1E0A': 'D',
      '\u010E': 'D',
      '\u1E0C': 'D',
      '\u1E10': 'D',
      '\u1E12': 'D',
      '\u1E0E': 'D',
      '\u0110': 'D',
      '\u018B': 'D',
      '\u018A': 'D',
      '\u0189': 'D',
      '\uA779': 'D',
      '\u01F1': 'DZ',
      '\u01C4': 'DZ',
      '\u01F2': 'Dz',
      '\u01C5': 'Dz',
      '\u24BA': 'E',
      '\uFF25': 'E',
      '\u00C8': 'E',
      '\u00C9': 'E',
      '\u00CA': 'E',
      '\u1EC0': 'E',
      '\u1EBE': 'E',
      '\u1EC4': 'E',
      '\u1EC2': 'E',
      '\u1EBC': 'E',
      '\u0112': 'E',
      '\u1E14': 'E',
      '\u1E16': 'E',
      '\u0114': 'E',
      '\u0116': 'E',
      '\u00CB': 'E',
      '\u1EBA': 'E',
      '\u011A': 'E',
      '\u0204': 'E',
      '\u0206': 'E',
      '\u1EB8': 'E',
      '\u1EC6': 'E',
      '\u0228': 'E',
      '\u1E1C': 'E',
      '\u0118': 'E',
      '\u1E18': 'E',
      '\u1E1A': 'E',
      '\u0190': 'E',
      '\u018E': 'E',
      '\u24BB': 'F',
      '\uFF26': 'F',
      '\u1E1E': 'F',
      '\u0191': 'F',
      '\uA77B': 'F',
      '\u24BC': 'G',
      '\uFF27': 'G',
      '\u01F4': 'G',
      '\u011C': 'G',
      '\u1E20': 'G',
      '\u011E': 'G',
      '\u0120': 'G',
      '\u01E6': 'G',
      '\u0122': 'G',
      '\u01E4': 'G',
      '\u0193': 'G',
      '\uA7A0': 'G',
      '\uA77D': 'G',
      '\uA77E': 'G',
      '\u24BD': 'H',
      '\uFF28': 'H',
      '\u0124': 'H',
      '\u1E22': 'H',
      '\u1E26': 'H',
      '\u021E': 'H',
      '\u1E24': 'H',
      '\u1E28': 'H',
      '\u1E2A': 'H',
      '\u0126': 'H',
      '\u2C67': 'H',
      '\u2C75': 'H',
      '\uA78D': 'H',
      '\u24BE': 'I',
      '\uFF29': 'I',
      '\u00CC': 'I',
      '\u00CD': 'I',
      '\u00CE': 'I',
      '\u0128': 'I',
      '\u012A': 'I',
      '\u012C': 'I',
      '\u0130': 'I',
      '\u00CF': 'I',
      '\u1E2E': 'I',
      '\u1EC8': 'I',
      '\u01CF': 'I',
      '\u0208': 'I',
      '\u020A': 'I',
      '\u1ECA': 'I',
      '\u012E': 'I',
      '\u1E2C': 'I',
      '\u0197': 'I',
      '\u24BF': 'J',
      '\uFF2A': 'J',
      '\u0134': 'J',
      '\u0248': 'J',
      '\u24C0': 'K',
      '\uFF2B': 'K',
      '\u1E30': 'K',
      '\u01E8': 'K',
      '\u1E32': 'K',
      '\u0136': 'K',
      '\u1E34': 'K',
      '\u0198': 'K',
      '\u2C69': 'K',
      '\uA740': 'K',
      '\uA742': 'K',
      '\uA744': 'K',
      '\uA7A2': 'K',
      '\u24C1': 'L',
      '\uFF2C': 'L',
      '\u013F': 'L',
      '\u0139': 'L',
      '\u013D': 'L',
      '\u1E36': 'L',
      '\u1E38': 'L',
      '\u013B': 'L',
      '\u1E3C': 'L',
      '\u1E3A': 'L',
      '\u0141': 'L',
      '\u023D': 'L',
      '\u2C62': 'L',
      '\u2C60': 'L',
      '\uA748': 'L',
      '\uA746': 'L',
      '\uA780': 'L',
      '\u01C7': 'LJ',
      '\u01C8': 'Lj',
      '\u24C2': 'M',
      '\uFF2D': 'M',
      '\u1E3E': 'M',
      '\u1E40': 'M',
      '\u1E42': 'M',
      '\u2C6E': 'M',
      '\u019C': 'M',
      '\u24C3': 'N',
      '\uFF2E': 'N',
      '\u01F8': 'N',
      '\u0143': 'N',
      '\u00D1': 'N',
      '\u1E44': 'N',
      '\u0147': 'N',
      '\u1E46': 'N',
      '\u0145': 'N',
      '\u1E4A': 'N',
      '\u1E48': 'N',
      '\u0220': 'N',
      '\u019D': 'N',
      '\uA790': 'N',
      '\uA7A4': 'N',
      '\u01CA': 'NJ',
      '\u01CB': 'Nj',
      '\u24C4': 'O',
      '\uFF2F': 'O',
      '\u00D2': 'O',
      '\u00D3': 'O',
      '\u00D4': 'O',
      '\u1ED2': 'O',
      '\u1ED0': 'O',
      '\u1ED6': 'O',
      '\u1ED4': 'O',
      '\u00D5': 'O',
      '\u1E4C': 'O',
      '\u022C': 'O',
      '\u1E4E': 'O',
      '\u014C': 'O',
      '\u1E50': 'O',
      '\u1E52': 'O',
      '\u014E': 'O',
      '\u022E': 'O',
      '\u0230': 'O',
      '\u00D6': 'O',
      '\u022A': 'O',
      '\u1ECE': 'O',
      '\u0150': 'O',
      '\u01D1': 'O',
      '\u020C': 'O',
      '\u020E': 'O',
      '\u01A0': 'O',
      '\u1EDC': 'O',
      '\u1EDA': 'O',
      '\u1EE0': 'O',
      '\u1EDE': 'O',
      '\u1EE2': 'O',
      '\u1ECC': 'O',
      '\u1ED8': 'O',
      '\u01EA': 'O',
      '\u01EC': 'O',
      '\u00D8': 'O',
      '\u01FE': 'O',
      '\u0186': 'O',
      '\u019F': 'O',
      '\uA74A': 'O',
      '\uA74C': 'O',
      '\u01A2': 'OI',
      '\uA74E': 'OO',
      '\u0222': 'OU',
      '\u24C5': 'P',
      '\uFF30': 'P',
      '\u1E54': 'P',
      '\u1E56': 'P',
      '\u01A4': 'P',
      '\u2C63': 'P',
      '\uA750': 'P',
      '\uA752': 'P',
      '\uA754': 'P',
      '\u24C6': 'Q',
      '\uFF31': 'Q',
      '\uA756': 'Q',
      '\uA758': 'Q',
      '\u024A': 'Q',
      '\u24C7': 'R',
      '\uFF32': 'R',
      '\u0154': 'R',
      '\u1E58': 'R',
      '\u0158': 'R',
      '\u0210': 'R',
      '\u0212': 'R',
      '\u1E5A': 'R',
      '\u1E5C': 'R',
      '\u0156': 'R',
      '\u1E5E': 'R',
      '\u024C': 'R',
      '\u2C64': 'R',
      '\uA75A': 'R',
      '\uA7A6': 'R',
      '\uA782': 'R',
      '\u24C8': 'S',
      '\uFF33': 'S',
      '\u1E9E': 'S',
      '\u015A': 'S',
      '\u1E64': 'S',
      '\u015C': 'S',
      '\u1E60': 'S',
      '\u0160': 'S',
      '\u1E66': 'S',
      '\u1E62': 'S',
      '\u1E68': 'S',
      '\u0218': 'S',
      '\u015E': 'S',
      '\u2C7E': 'S',
      '\uA7A8': 'S',
      '\uA784': 'S',
      '\u24C9': 'T',
      '\uFF34': 'T',
      '\u1E6A': 'T',
      '\u0164': 'T',
      '\u1E6C': 'T',
      '\u021A': 'T',
      '\u0162': 'T',
      '\u1E70': 'T',
      '\u1E6E': 'T',
      '\u0166': 'T',
      '\u01AC': 'T',
      '\u01AE': 'T',
      '\u023E': 'T',
      '\uA786': 'T',
      '\uA728': 'TZ',
      '\u24CA': 'U',
      '\uFF35': 'U',
      '\u00D9': 'U',
      '\u00DA': 'U',
      '\u00DB': 'U',
      '\u0168': 'U',
      '\u1E78': 'U',
      '\u016A': 'U',
      '\u1E7A': 'U',
      '\u016C': 'U',
      '\u00DC': 'U',
      '\u01DB': 'U',
      '\u01D7': 'U',
      '\u01D5': 'U',
      '\u01D9': 'U',
      '\u1EE6': 'U',
      '\u016E': 'U',
      '\u0170': 'U',
      '\u01D3': 'U',
      '\u0214': 'U',
      '\u0216': 'U',
      '\u01AF': 'U',
      '\u1EEA': 'U',
      '\u1EE8': 'U',
      '\u1EEE': 'U',
      '\u1EEC': 'U',
      '\u1EF0': 'U',
      '\u1EE4': 'U',
      '\u1E72': 'U',
      '\u0172': 'U',
      '\u1E76': 'U',
      '\u1E74': 'U',
      '\u0244': 'U',
      '\u24CB': 'V',
      '\uFF36': 'V',
      '\u1E7C': 'V',
      '\u1E7E': 'V',
      '\u01B2': 'V',
      '\uA75E': 'V',
      '\u0245': 'V',
      '\uA760': 'VY',
      '\u24CC': 'W',
      '\uFF37': 'W',
      '\u1E80': 'W',
      '\u1E82': 'W',
      '\u0174': 'W',
      '\u1E86': 'W',
      '\u1E84': 'W',
      '\u1E88': 'W',
      '\u2C72': 'W',
      '\u24CD': 'X',
      '\uFF38': 'X',
      '\u1E8A': 'X',
      '\u1E8C': 'X',
      '\u24CE': 'Y',
      '\uFF39': 'Y',
      '\u1EF2': 'Y',
      '\u00DD': 'Y',
      '\u0176': 'Y',
      '\u1EF8': 'Y',
      '\u0232': 'Y',
      '\u1E8E': 'Y',
      '\u0178': 'Y',
      '\u1EF6': 'Y',
      '\u1EF4': 'Y',
      '\u01B3': 'Y',
      '\u024E': 'Y',
      '\u1EFE': 'Y',
      '\u24CF': 'Z',
      '\uFF3A': 'Z',
      '\u0179': 'Z',
      '\u1E90': 'Z',
      '\u017B': 'Z',
      '\u017D': 'Z',
      '\u1E92': 'Z',
      '\u1E94': 'Z',
      '\u01B5': 'Z',
      '\u0224': 'Z',
      '\u2C7F': 'Z',
      '\u2C6B': 'Z',
      '\uA762': 'Z',
      '\u24D0': 'a',
      '\uFF41': 'a',
      '\u1E9A': 'a',
      '\u00E0': 'a',
      '\u00E1': 'a',
      '\u00E2': 'a',
      '\u1EA7': 'a',
      '\u1EA5': 'a',
      '\u1EAB': 'a',
      '\u1EA9': 'a',
      '\u00E3': 'a',
      '\u0101': 'a',
      '\u0103': 'a',
      '\u1EB1': 'a',
      '\u1EAF': 'a',
      '\u1EB5': 'a',
      '\u1EB3': 'a',
      '\u0227': 'a',
      '\u01E1': 'a',
      '\u00E4': 'a',
      '\u01DF': 'a',
      '\u1EA3': 'a',
      '\u00E5': 'a',
      '\u01FB': 'a',
      '\u01CE': 'a',
      '\u0201': 'a',
      '\u0203': 'a',
      '\u1EA1': 'a',
      '\u1EAD': 'a',
      '\u1EB7': 'a',
      '\u1E01': 'a',
      '\u0105': 'a',
      '\u2C65': 'a',
      '\u0250': 'a',
      '\uA733': 'aa',
      '\u00E6': 'ae',
      '\u01FD': 'ae',
      '\u01E3': 'ae',
      '\uA735': 'ao',
      '\uA737': 'au',
      '\uA739': 'av',
      '\uA73B': 'av',
      '\uA73D': 'ay',
      '\u24D1': 'b',
      '\uFF42': 'b',
      '\u1E03': 'b',
      '\u1E05': 'b',
      '\u1E07': 'b',
      '\u0180': 'b',
      '\u0183': 'b',
      '\u0253': 'b',
      '\u24D2': 'c',
      '\uFF43': 'c',
      '\u0107': 'c',
      '\u0109': 'c',
      '\u010B': 'c',
      '\u010D': 'c',
      '\u00E7': 'c',
      '\u1E09': 'c',
      '\u0188': 'c',
      '\u023C': 'c',
      '\uA73F': 'c',
      '\u2184': 'c',
      '\u24D3': 'd',
      '\uFF44': 'd',
      '\u1E0B': 'd',
      '\u010F': 'd',
      '\u1E0D': 'd',
      '\u1E11': 'd',
      '\u1E13': 'd',
      '\u1E0F': 'd',
      '\u0111': 'd',
      '\u018C': 'd',
      '\u0256': 'd',
      '\u0257': 'd',
      '\uA77A': 'd',
      '\u01F3': 'dz',
      '\u01C6': 'dz',
      '\u24D4': 'e',
      '\uFF45': 'e',
      '\u00E8': 'e',
      '\u00E9': 'e',
      '\u00EA': 'e',
      '\u1EC1': 'e',
      '\u1EBF': 'e',
      '\u1EC5': 'e',
      '\u1EC3': 'e',
      '\u1EBD': 'e',
      '\u0113': 'e',
      '\u1E15': 'e',
      '\u1E17': 'e',
      '\u0115': 'e',
      '\u0117': 'e',
      '\u00EB': 'e',
      '\u1EBB': 'e',
      '\u011B': 'e',
      '\u0205': 'e',
      '\u0207': 'e',
      '\u1EB9': 'e',
      '\u1EC7': 'e',
      '\u0229': 'e',
      '\u1E1D': 'e',
      '\u0119': 'e',
      '\u1E19': 'e',
      '\u1E1B': 'e',
      '\u0247': 'e',
      '\u025B': 'e',
      '\u01DD': 'e',
      '\u24D5': 'f',
      '\uFF46': 'f',
      '\u1E1F': 'f',
      '\u0192': 'f',
      '\uA77C': 'f',
      '\u24D6': 'g',
      '\uFF47': 'g',
      '\u01F5': 'g',
      '\u011D': 'g',
      '\u1E21': 'g',
      '\u011F': 'g',
      '\u0121': 'g',
      '\u01E7': 'g',
      '\u0123': 'g',
      '\u01E5': 'g',
      '\u0260': 'g',
      '\uA7A1': 'g',
      '\u1D79': 'g',
      '\uA77F': 'g',
      '\u24D7': 'h',
      '\uFF48': 'h',
      '\u0125': 'h',
      '\u1E23': 'h',
      '\u1E27': 'h',
      '\u021F': 'h',
      '\u1E25': 'h',
      '\u1E29': 'h',
      '\u1E2B': 'h',
      '\u1E96': 'h',
      '\u0127': 'h',
      '\u2C68': 'h',
      '\u2C76': 'h',
      '\u0265': 'h',
      '\u0195': 'hv',
      '\u24D8': 'i',
      '\uFF49': 'i',
      '\u00EC': 'i',
      '\u00ED': 'i',
      '\u00EE': 'i',
      '\u0129': 'i',
      '\u012B': 'i',
      '\u012D': 'i',
      '\u00EF': 'i',
      '\u1E2F': 'i',
      '\u1EC9': 'i',
      '\u01D0': 'i',
      '\u0209': 'i',
      '\u020B': 'i',
      '\u1ECB': 'i',
      '\u012F': 'i',
      '\u1E2D': 'i',
      '\u0268': 'i',
      '\u0131': 'i',
      '\u24D9': 'j',
      '\uFF4A': 'j',
      '\u0135': 'j',
      '\u01F0': 'j',
      '\u0249': 'j',
      '\u24DA': 'k',
      '\uFF4B': 'k',
      '\u1E31': 'k',
      '\u01E9': 'k',
      '\u1E33': 'k',
      '\u0137': 'k',
      '\u1E35': 'k',
      '\u0199': 'k',
      '\u2C6A': 'k',
      '\uA741': 'k',
      '\uA743': 'k',
      '\uA745': 'k',
      '\uA7A3': 'k',
      '\u24DB': 'l',
      '\uFF4C': 'l',
      '\u0140': 'l',
      '\u013A': 'l',
      '\u013E': 'l',
      '\u1E37': 'l',
      '\u1E39': 'l',
      '\u013C': 'l',
      '\u1E3D': 'l',
      '\u1E3B': 'l',
      '\u017F': 'l',
      '\u0142': 'l',
      '\u019A': 'l',
      '\u026B': 'l',
      '\u2C61': 'l',
      '\uA749': 'l',
      '\uA781': 'l',
      '\uA747': 'l',
      '\u01C9': 'lj',
      '\u24DC': 'm',
      '\uFF4D': 'm',
      '\u1E3F': 'm',
      '\u1E41': 'm',
      '\u1E43': 'm',
      '\u0271': 'm',
      '\u026F': 'm',
      '\u24DD': 'n',
      '\uFF4E': 'n',
      '\u01F9': 'n',
      '\u0144': 'n',
      '\u00F1': 'n',
      '\u1E45': 'n',
      '\u0148': 'n',
      '\u1E47': 'n',
      '\u0146': 'n',
      '\u1E4B': 'n',
      '\u1E49': 'n',
      '\u019E': 'n',
      '\u0272': 'n',
      '\u0149': 'n',
      '\uA791': 'n',
      '\uA7A5': 'n',
      '\u01CC': 'nj',
      '\u24DE': 'o',
      '\uFF4F': 'o',
      '\u00F2': 'o',
      '\u00F3': 'o',
      '\u00F4': 'o',
      '\u1ED3': 'o',
      '\u1ED1': 'o',
      '\u1ED7': 'o',
      '\u1ED5': 'o',
      '\u00F5': 'o',
      '\u1E4D': 'o',
      '\u022D': 'o',
      '\u1E4F': 'o',
      '\u014D': 'o',
      '\u1E51': 'o',
      '\u1E53': 'o',
      '\u014F': 'o',
      '\u022F': 'o',
      '\u0231': 'o',
      '\u00F6': 'o',
      '\u022B': 'o',
      '\u1ECF': 'o',
      '\u0151': 'o',
      '\u01D2': 'o',
      '\u020D': 'o',
      '\u020F': 'o',
      '\u01A1': 'o',
      '\u1EDD': 'o',
      '\u1EDB': 'o',
      '\u1EE1': 'o',
      '\u1EDF': 'o',
      '\u1EE3': 'o',
      '\u1ECD': 'o',
      '\u1ED9': 'o',
      '\u01EB': 'o',
      '\u01ED': 'o',
      '\u00F8': 'o',
      '\u01FF': 'o',
      '\u0254': 'o',
      '\uA74B': 'o',
      '\uA74D': 'o',
      '\u0275': 'o',
      '\u01A3': 'oi',
      '\u0223': 'ou',
      '\uA74F': 'oo',
      '\u24DF': 'p',
      '\uFF50': 'p',
      '\u1E55': 'p',
      '\u1E57': 'p',
      '\u01A5': 'p',
      '\u1D7D': 'p',
      '\uA751': 'p',
      '\uA753': 'p',
      '\uA755': 'p',
      '\u24E0': 'q',
      '\uFF51': 'q',
      '\u024B': 'q',
      '\uA757': 'q',
      '\uA759': 'q',
      '\u24E1': 'r',
      '\uFF52': 'r',
      '\u0155': 'r',
      '\u1E59': 'r',
      '\u0159': 'r',
      '\u0211': 'r',
      '\u0213': 'r',
      '\u1E5B': 'r',
      '\u1E5D': 'r',
      '\u0157': 'r',
      '\u1E5F': 'r',
      '\u024D': 'r',
      '\u027D': 'r',
      '\uA75B': 'r',
      '\uA7A7': 'r',
      '\uA783': 'r',
      '\u24E2': 's',
      '\uFF53': 's',
      '\u00DF': 's',
      '\u015B': 's',
      '\u1E65': 's',
      '\u015D': 's',
      '\u1E61': 's',
      '\u0161': 's',
      '\u1E67': 's',
      '\u1E63': 's',
      '\u1E69': 's',
      '\u0219': 's',
      '\u015F': 's',
      '\u023F': 's',
      '\uA7A9': 's',
      '\uA785': 's',
      '\u1E9B': 's',
      '\u24E3': 't',
      '\uFF54': 't',
      '\u1E6B': 't',
      '\u1E97': 't',
      '\u0165': 't',
      '\u1E6D': 't',
      '\u021B': 't',
      '\u0163': 't',
      '\u1E71': 't',
      '\u1E6F': 't',
      '\u0167': 't',
      '\u01AD': 't',
      '\u0288': 't',
      '\u2C66': 't',
      '\uA787': 't',
      '\uA729': 'tz',
      '\u24E4': 'u',
      '\uFF55': 'u',
      '\u00F9': 'u',
      '\u00FA': 'u',
      '\u00FB': 'u',
      '\u0169': 'u',
      '\u1E79': 'u',
      '\u016B': 'u',
      '\u1E7B': 'u',
      '\u016D': 'u',
      '\u00FC': 'u',
      '\u01DC': 'u',
      '\u01D8': 'u',
      '\u01D6': 'u',
      '\u01DA': 'u',
      '\u1EE7': 'u',
      '\u016F': 'u',
      '\u0171': 'u',
      '\u01D4': 'u',
      '\u0215': 'u',
      '\u0217': 'u',
      '\u01B0': 'u',
      '\u1EEB': 'u',
      '\u1EE9': 'u',
      '\u1EEF': 'u',
      '\u1EED': 'u',
      '\u1EF1': 'u',
      '\u1EE5': 'u',
      '\u1E73': 'u',
      '\u0173': 'u',
      '\u1E77': 'u',
      '\u1E75': 'u',
      '\u0289': 'u',
      '\u24E5': 'v',
      '\uFF56': 'v',
      '\u1E7D': 'v',
      '\u1E7F': 'v',
      '\u028B': 'v',
      '\uA75F': 'v',
      '\u028C': 'v',
      '\uA761': 'vy',
      '\u24E6': 'w',
      '\uFF57': 'w',
      '\u1E81': 'w',
      '\u1E83': 'w',
      '\u0175': 'w',
      '\u1E87': 'w',
      '\u1E85': 'w',
      '\u1E98': 'w',
      '\u1E89': 'w',
      '\u2C73': 'w',
      '\u24E7': 'x',
      '\uFF58': 'x',
      '\u1E8B': 'x',
      '\u1E8D': 'x',
      '\u24E8': 'y',
      '\uFF59': 'y',
      '\u1EF3': 'y',
      '\u00FD': 'y',
      '\u0177': 'y',
      '\u1EF9': 'y',
      '\u0233': 'y',
      '\u1E8F': 'y',
      '\u00FF': 'y',
      '\u1EF7': 'y',
      '\u1E99': 'y',
      '\u1EF5': 'y',
      '\u01B4': 'y',
      '\u024F': 'y',
      '\u1EFF': 'y',
      '\u24E9': 'z',
      '\uFF5A': 'z',
      '\u017A': 'z',
      '\u1E91': 'z',
      '\u017C': 'z',
      '\u017E': 'z',
      '\u1E93': 'z',
      '\u1E95': 'z',
      '\u01B6': 'z',
      '\u0225': 'z',
      '\u0240': 'z',
      '\u2C6C': 'z',
      '\uA763': 'z',
      '\u0386': '\u0391',
      '\u0388': '\u0395',
      '\u0389': '\u0397',
      '\u038A': '\u0399',
      '\u03AA': '\u0399',
      '\u038C': '\u039F',
      '\u038E': '\u03A5',
      '\u03AB': '\u03A5',
      '\u038F': '\u03A9',
      '\u03AC': '\u03B1',
      '\u03AD': '\u03B5',
      '\u03AE': '\u03B7',
      '\u03AF': '\u03B9',
      '\u03CA': '\u03B9',
      '\u0390': '\u03B9',
      '\u03CC': '\u03BF',
      '\u03CD': '\u03C5',
      '\u03CB': '\u03C5',
      '\u03B0': '\u03C5',
      '\u03C9': '\u03C9',
      '\u03C2': '\u03C3'
    };
  
    return diacritics;
  });
  
  S2.define('select2/data/base',[
    '../utils'
  ], function (Utils) {
    function BaseAdapter ($element, options) {
      BaseAdapter.__super__.constructor.call(this);
    }
  
    Utils.Extend(BaseAdapter, Utils.Observable);
  
    BaseAdapter.prototype.current = function (callback) {
      throw new Error('The `current` method must be defined in child classes.');
    };
  
    BaseAdapter.prototype.query = function (params, callback) {
      throw new Error('The `query` method must be defined in child classes.');
    };
  
    BaseAdapter.prototype.bind = function (container, $container) {
      // Can be implemented in subclasses
    };
  
    BaseAdapter.prototype.destroy = function () {
      // Can be implemented in subclasses
    };
  
    BaseAdapter.prototype.generateResultId = function (container, data) {
      var id = container.id + '-result-';
  
      id += Utils.generateChars(4);
  
      if (data.id != null) {
        id += '-' + data.id.toString();
      } else {
        id += '-' + Utils.generateChars(4);
      }
      return id;
    };
  
    return BaseAdapter;
  });
  
  S2.define('select2/data/select',[
    './base',
    '../utils',
    'jquery'
  ], function (BaseAdapter, Utils, $) {
    function SelectAdapter ($element, options) {
      this.$element = $element;
      this.options = options;
  
      SelectAdapter.__super__.constructor.call(this);
    }
  
    Utils.Extend(SelectAdapter, BaseAdapter);
  
    SelectAdapter.prototype.current = function (callback) {
      var data = [];
      var self = this;
  
      this.$element.find(':selected').each(function () {
        var $option = $(this);
  
        var option = self.item($option);
  
        data.push(option);
      });
  
      callback(data);
    };
  
    SelectAdapter.prototype.select = function (data) {
      var self = this;
  
      data.selected = true;
  
      // If data.element is a DOM node, use it instead
      if ($(data.element).is('option')) {
        data.element.selected = true;
  
        this.$element.trigger('change');
  
        return;
      }
  
      if (this.$element.prop('multiple')) {
        this.current(function (currentData) {
          var val = [];
  
          data = [data];
          data.push.apply(data, currentData);
  
          for (var d = 0; d < data.length; d++) {
            var id = data[d].id;
  
            if ($.inArray(id, val) === -1) {
              val.push(id);
            }
          }
  
          self.$element.val(val);
          self.$element.trigger('change');
        });
      } else {
        var val = data.id;
  
        this.$element.val(val);
        this.$element.trigger('change');
      }
    };
  
    SelectAdapter.prototype.unselect = function (data) {
      var self = this;
  
      if (!this.$element.prop('multiple')) {
        return;
      }
  
      data.selected = false;
  
      if ($(data.element).is('option')) {
        data.element.selected = false;
  
        this.$element.trigger('change');
  
        return;
      }
  
      this.current(function (currentData) {
        var val = [];
  
        for (var d = 0; d < currentData.length; d++) {
          var id = currentData[d].id;
  
          if (id !== data.id && $.inArray(id, val) === -1) {
            val.push(id);
          }
        }
  
        self.$element.val(val);
  
        self.$element.trigger('change');
      });
    };
  
    SelectAdapter.prototype.bind = function (container, $container) {
      var self = this;
  
      this.container = container;
  
      container.on('select', function (params) {
        self.select(params.data);
      });
  
      container.on('unselect', function (params) {
        self.unselect(params.data);
      });
    };
  
    SelectAdapter.prototype.destroy = function () {
      // Remove anything added to child elements
      this.$element.find('*').each(function () {
        // Remove any custom data set by Select2
        $.removeData(this, 'data');
      });
    };
  
    SelectAdapter.prototype.query = function (params, callback) {
      var data = [];
      var self = this;
  
      var $options = this.$element.children();
  
      $options.each(function () {
        var $option = $(this);
  
        if (!$option.is('option') && !$option.is('optgroup')) {
          return;
        }
  
        var option = self.item($option);
  
        var matches = self.matches(params, option);
  
        if (matches !== null) {
          data.push(matches);
        }
      });
  
      callback({
        results: data
      });
    };
  
    SelectAdapter.prototype.addOptions = function ($options) {
      Utils.appendMany(this.$element, $options);
    };
  
    SelectAdapter.prototype.option = function (data) {
      var option;
  
      if (data.children) {
        option = document.createElement('optgroup');
        option.label = data.text;
      } else {
        option = document.createElement('option');
  
        if (option.textContent !== undefined) {
          option.textContent = data.text;
        } else {
          option.innerText = data.text;
        }
      }
  
      if (data.id) {
        option.value = data.id;
      }
  
      if (data.disabled) {
        option.disabled = true;
      }
  
      if (data.selected) {
        option.selected = true;
      }
  
      if (data.title) {
        option.title = data.title;
      }
  
      var $option = $(option);
  
      var normalizedData = this._normalizeItem(data);
      normalizedData.element = option;
  
      // Override the option's data with the combined data
      $.data(option, 'data', normalizedData);
  
      return $option;
    };
  
    SelectAdapter.prototype.item = function ($option) {
      var data = {};
  
      data = $.data($option[0], 'data');
  
      if (data != null) {
        return data;
      }
  
      if ($option.is('option')) {
        data = {
          id: $option.val(),
          text: $option.text(),
          disabled: $option.prop('disabled'),
          selected: $option.prop('selected'),
          title: $option.prop('title')
        };
      } else if ($option.is('optgroup')) {
        data = {
          text: $option.prop('label'),
          children: [],
          title: $option.prop('title')
        };
  
        var $children = $option.children('option');
        var children = [];
  
        for (var c = 0; c < $children.length; c++) {
          var $child = $($children[c]);
  
          var child = this.item($child);
  
          children.push(child);
        }
  
        data.children = children;
      }
  
      data = this._normalizeItem(data);
      data.element = $option[0];
  
      $.data($option[0], 'data', data);
  
      return data;
    };
  
    SelectAdapter.prototype._normalizeItem = function (item) {
      if (!$.isPlainObject(item)) {
        item = {
          id: item,
          text: item
        };
      }
  
      item = $.extend({}, {
        text: ''
      }, item);
  
      var defaults = {
        selected: false,
        disabled: false
      };
  
      if (item.id != null) {
        item.id = item.id.toString();
      }
  
      if (item.text != null) {
        item.text = item.text.toString();
      }
  
      if (item._resultId == null && item.id && this.container != null) {
        item._resultId = this.generateResultId(this.container, item);
      }
  
      return $.extend({}, defaults, item);
    };
  
    SelectAdapter.prototype.matches = function (params, data) {
      var matcher = this.options.get('matcher');
  
      return matcher(params, data);
    };
  
    return SelectAdapter;
  });
  
  S2.define('select2/data/array',[
    './select',
    '../utils',
    'jquery'
  ], function (SelectAdapter, Utils, $) {
    function ArrayAdapter ($element, options) {
      var data = options.get('data') || [];
  
      ArrayAdapter.__super__.constructor.call(this, $element, options);
  
      this.addOptions(this.convertToOptions(data));
    }
  
    Utils.Extend(ArrayAdapter, SelectAdapter);
  
    ArrayAdapter.prototype.select = function (data) {
      var $option = this.$element.find('option').filter(function (i, elm) {
        return elm.value == data.id.toString();
      });
  
      if ($option.length === 0) {
        $option = this.option(data);
  
        this.addOptions($option);
      }
  
      ArrayAdapter.__super__.select.call(this, data);
    };
  
    ArrayAdapter.prototype.convertToOptions = function (data) {
      var self = this;
  
      var $existing = this.$element.find('option');
      var existingIds = $existing.map(function () {
        return self.item($(this)).id;
      }).get();
  
      var $options = [];
  
      // Filter out all items except for the one passed in the argument
      function onlyItem (item) {
        return function () {
          return $(this).val() == item.id;
        };
      }
  
      for (var d = 0; d < data.length; d++) {
        var item = this._normalizeItem(data[d]);
  
        // Skip items which were pre-loaded, only merge the data
        if ($.inArray(item.id, existingIds) >= 0) {
          var $existingOption = $existing.filter(onlyItem(item));
  
          var existingData = this.item($existingOption);
          var newData = $.extend(true, {}, item, existingData);
  
          var $newOption = this.option(newData);
  
          $existingOption.replaceWith($newOption);
  
          continue;
        }
  
        var $option = this.option(item);
  
        if (item.children) {
          var $children = this.convertToOptions(item.children);
  
          Utils.appendMany($option, $children);
        }
  
        $options.push($option);
      }
  
      return $options;
    };
  
    return ArrayAdapter;
  });
  
  S2.define('select2/data/ajax',[
    './array',
    '../utils',
    'jquery'
  ], function (ArrayAdapter, Utils, $) {
    function AjaxAdapter ($element, options) {
      this.ajaxOptions = this._applyDefaults(options.get('ajax'));
  
      if (this.ajaxOptions.processResults != null) {
        this.processResults = this.ajaxOptions.processResults;
      }
  
      AjaxAdapter.__super__.constructor.call(this, $element, options);
    }
  
    Utils.Extend(AjaxAdapter, ArrayAdapter);
  
    AjaxAdapter.prototype._applyDefaults = function (options) {
      var defaults = {
        data: function (params) {
          return $.extend({}, params, {
            q: params.term
          });
        },
        transport: function (params, success, failure) {
          var $request = $.ajax(params);
  
          $request.then(success);
          $request.fail(failure);
  
          return $request;
        }
      };
  
      return $.extend({}, defaults, options, true);
    };
  
    AjaxAdapter.prototype.processResults = function (results) {
      return results;
    };
  
    AjaxAdapter.prototype.query = function (params, callback) {
      var matches = [];
      var self = this;
  
      if (this._request != null) {
        // JSONP requests cannot always be aborted
        if ($.isFunction(this._request.abort)) {
          this._request.abort();
        }
  
        this._request = null;
      }
  
      var options = $.extend({
        type: 'GET'
      }, this.ajaxOptions);
  
      if (typeof options.url === 'function') {
        options.url = options.url.call(this.$element, params);
      }
  
      if (typeof options.data === 'function') {
        options.data = options.data.call(this.$element, params);
      }
  
      function request () {
        var $request = options.transport(options, function (data) {
          var results = self.processResults(data, params);
  
          if (self.options.get('debug') && window.console && console.error) {
            // Check to make sure that the response included a `results` key.
            if (!results || !results.results || !$.isArray(results.results)) {
              console.error(
                'Select2: The AJAX results did not return an array in the ' +
                '`results` key of the response.'
              );
            }
          }
  
          callback(results);
        }, function () {
          // Attempt to detect if a request was aborted
          // Only works if the transport exposes a status property
          if ($request.status && $request.status === '0') {
            return;
          }
  
          self.trigger('results:message', {
            message: 'errorLoading'
          });
        });
  
        self._request = $request;
      }
  
      if (this.ajaxOptions.delay && params.term != null) {
        if (this._queryTimeout) {
          window.clearTimeout(this._queryTimeout);
        }
  
        this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay);
      } else {
        request();
      }
    };
  
    return AjaxAdapter;
  });
  
  S2.define('select2/data/tags',[
    'jquery'
  ], function ($) {
    function Tags (decorated, $element, options) {
      var tags = options.get('tags');
  
      var createTag = options.get('createTag');
  
      if (createTag !== undefined) {
        this.createTag = createTag;
      }
  
      var insertTag = options.get('insertTag');
  
      if (insertTag !== undefined) {
          this.insertTag = insertTag;
      }
  
      decorated.call(this, $element, options);
  
      if ($.isArray(tags)) {
        for (var t = 0; t < tags.length; t++) {
          var tag = tags[t];
          var item = this._normalizeItem(tag);
  
          var $option = this.option(item);
  
          this.$element.append($option);
        }
      }
    }
  
    Tags.prototype.query = function (decorated, params, callback) {
      var self = this;
  
      this._removeOldTags();
  
      if (params.term == null || params.page != null) {
        decorated.call(this, params, callback);
        return;
      }
  
      function wrapper (obj, child) {
        var data = obj.results;
  
        for (var i = 0; i < data.length; i++) {
          var option = data[i];
  
          var checkChildren = (
            option.children != null &&
            !wrapper({
              results: option.children
            }, true)
          );
  
          var checkText = option.text === params.term;
  
          if (checkText || checkChildren) {
            if (child) {
              return false;
            }
  
            obj.data = data;
            callback(obj);
  
            return;
          }
        }
  
        if (child) {
          return true;
        }
  
        var tag = self.createTag(params);
  
        if (tag != null) {
          var $option = self.option(tag);
          $option.attr('data-select2-tag', true);
  
          self.addOptions([$option]);
  
          self.insertTag(data, tag);
        }
  
        obj.results = data;
  
        callback(obj);
      }
  
      decorated.call(this, params, wrapper);
    };
  
    Tags.prototype.createTag = function (decorated, params) {
      var term = $.trim(params.term);
  
      if (term === '') {
        return null;
      }
  
      return {
        id: term,
        text: term
      };
    };
  
    Tags.prototype.insertTag = function (_, data, tag) {
      data.unshift(tag);
    };
  
    Tags.prototype._removeOldTags = function (_) {
      var tag = this._lastTag;
  
      var $options = this.$element.find('option[data-select2-tag]');
  
      $options.each(function () {
        if (this.selected) {
          return;
        }
  
        $(this).remove();
      });
    };
  
    return Tags;
  });
  
  S2.define('select2/data/tokenizer',[
    'jquery'
  ], function ($) {
    function Tokenizer (decorated, $element, options) {
      var tokenizer = options.get('tokenizer');
  
      if (tokenizer !== undefined) {
        this.tokenizer = tokenizer;
      }
  
      decorated.call(this, $element, options);
    }
  
    Tokenizer.prototype.bind = function (decorated, container, $container) {
      decorated.call(this, container, $container);
  
      this.$search =  container.dropdown.$search || container.selection.$search ||
        $container.find('.select2-search__field');
    };
  
    Tokenizer.prototype.query = function (decorated, params, callback) {
      var self = this;
  
      function createAndSelect (data) {
        // Normalize the data object so we can use it for checks
        var item = self._normalizeItem(data);
  
        // Check if the data object already exists as a tag
        // Select it if it doesn't
        var $existingOptions = self.$element.find('option').filter(function () {
          return $(this).val() === item.id;
        });
  
        // If an existing option wasn't found for it, create the option
        if (!$existingOptions.length) {
          var $option = self.option(item);
          $option.attr('data-select2-tag', true);
  
          self._removeOldTags();
          self.addOptions([$option]);
        }
  
        // Select the item, now that we know there is an option for it
        select(item);
      }
  
      function select (data) {
        self.trigger('select', {
          data: data
        });
      }
  
      params.term = params.term || '';
  
      var tokenData = this.tokenizer(params, this.options, createAndSelect);
  
      if (tokenData.term !== params.term) {
        // Replace the search term if we have the search box
        if (this.$search.length) {
          this.$search.val(tokenData.term);
          this.$search.focus();
        }
  
        params.term = tokenData.term;
      }
  
      decorated.call(this, params, callback);
    };
  
    Tokenizer.prototype.tokenizer = function (_, params, options, callback) {
      var separators = options.get('tokenSeparators') || [];
      var term = params.term;
      var i = 0;
  
      var createTag = this.createTag || function (params) {
        return {
          id: params.term,
          text: params.term
        };
      };
  
      while (i < term.length) {
        var termChar = term[i];
  
        if ($.inArray(termChar, separators) === -1) {
          i++;
  
          continue;
        }
  
        var part = term.substr(0, i);
        var partParams = $.extend({}, params, {
          term: part
        });
  
        var data = createTag(partParams);
  
        if (data == null) {
          i++;
          continue;
        }
  
        callback(data);
  
        // Reset the term to not include the tokenized portion
        term = term.substr(i + 1) || '';
        i = 0;
      }
  
      return {
        term: term
      };
    };
  
    return Tokenizer;
  });
  
  S2.define('select2/data/minimumInputLength',[
  
  ], function () {
    function MinimumInputLength (decorated, $e, options) {
      this.minimumInputLength = options.get('minimumInputLength');
  
      decorated.call(this, $e, options);
    }
  
    MinimumInputLength.prototype.query = function (decorated, params, callback) {
      params.term = params.term || '';
  
      if (params.term.length < this.minimumInputLength) {
        this.trigger('results:message', {
          message: 'inputTooShort',
          args: {
            minimum: this.minimumInputLength,
            input: params.term,
            params: params
          }
        });
  
        return;
      }
  
      decorated.call(this, params, callback);
    };
  
    return MinimumInputLength;
  });
  
  S2.define('select2/data/maximumInputLength',[
  
  ], function () {
    function MaximumInputLength (decorated, $e, options) {
      this.maximumInputLength = options.get('maximumInputLength');
  
      decorated.call(this, $e, options);
    }
  
    MaximumInputLength.prototype.query = function (decorated, params, callback) {
      params.term = params.term || '';
  
      if (this.maximumInputLength > 0 &&
          params.term.length > this.maximumInputLength) {
        this.trigger('results:message', {
          message: 'inputTooLong',
          args: {
            maximum: this.maximumInputLength,
            input: params.term,
            params: params
          }
        });
  
        return;
      }
  
      decorated.call(this, params, callback);
    };
  
    return MaximumInputLength;
  });
  
  S2.define('select2/data/maximumSelectionLength',[
  
  ], function (){
    function MaximumSelectionLength (decorated, $e, options) {
      this.maximumSelectionLength = options.get('maximumSelectionLength');
  
      decorated.call(this, $e, options);
    }
  
    MaximumSelectionLength.prototype.query =
      function (decorated, params, callback) {
        var self = this;
  
        this.current(function (currentData) {
          var count = currentData != null ? currentData.length : 0;
          if (self.maximumSelectionLength > 0 &&
            count >= self.maximumSelectionLength) {
            self.trigger('results:message', {
              message: 'maximumSelected',
              args: {
                maximum: self.maximumSelectionLength
              }
            });
            return;
          }
          decorated.call(self, params, callback);
        });
    };
  
    return MaximumSelectionLength;
  });
  
  S2.define('select2/dropdown',[
    'jquery',
    './utils'
  ], function ($, Utils) {
    function Dropdown ($element, options) {
      this.$element = $element;
      this.options = options;
  
      Dropdown.__super__.constructor.call(this);
    }
  
    Utils.Extend(Dropdown, Utils.Observable);
  
    Dropdown.prototype.render = function () {
      var $dropdown = $(
        '<span class="select2-dropdown">' +
          '<span class="select2-results"></span>' +
        '</span>'
      );
  
      $dropdown.attr('dir', this.options.get('dir'));
  
      this.$dropdown = $dropdown;
  
      return $dropdown;
    };
  
    Dropdown.prototype.bind = function () {
      // Should be implemented in subclasses
    };
  
    Dropdown.prototype.position = function ($dropdown, $container) {
      // Should be implmented in subclasses
    };
  
    Dropdown.prototype.destroy = function () {
      // Remove the dropdown from the DOM
      this.$dropdown.remove();
    };
  
    return Dropdown;
  });
  
  S2.define('select2/dropdown/search',[
    'jquery',
    '../utils'
  ], function ($, Utils) {
    function Search () { }
  
    Search.prototype.render = function (decorated) {
      var $rendered = decorated.call(this);
  
      var $search = $(
        '<span class="select2-search select2-search--dropdown">' +
          '<input class="select2-search__field" type="search" tabindex="-1"' +
          ' autocomplete="off" autocorrect="off" autocapitalize="off"' +
          ' spellcheck="false" role="textbox" />' +
        '</span>'
      );
  
      this.$searchContainer = $search;
      this.$search = $search.find('input');
  
      $rendered.prepend($search);
  
      return $rendered;
    };
  
    Search.prototype.bind = function (decorated, container, $container) {
      var self = this;
  
      decorated.call(this, container, $container);
  
      this.$search.on('keydown', function (evt) {
        self.trigger('keypress', evt);
  
        self._keyUpPrevented = evt.isDefaultPrevented();
      });
  
      // Workaround for browsers which do not support the `input` event
      // This will prevent double-triggering of events for browsers which support
      // both the `keyup` and `input` events.
      this.$search.on('input', function (evt) {
        // Unbind the duplicated `keyup` event
        $(this).off('keyup');
      });
  
      this.$search.on('keyup input', function (evt) {
        self.handleSearch(evt);
      });
  
      container.on('open', function () {
        self.$search.attr('tabindex', 0);
  
        self.$search.focus();
  
        window.setTimeout(function () {
          self.$search.focus();
        }, 0);
      });
  
      container.on('close', function () {
        self.$search.attr('tabindex', -1);
  
        self.$search.val('');
      });
  
      container.on('focus', function () {
        if (container.isOpen()) {
          self.$search.focus();
        }
      });
  
      container.on('results:all', function (params) {
        if (params.query.term == null || params.query.term === '') {
          var showSearch = self.showSearch(params);
  
          if (showSearch) {
            self.$searchContainer.removeClass('select2-search--hide');
          } else {
            self.$searchContainer.addClass('select2-search--hide');
          }
        }
      });
    };
  
    Search.prototype.handleSearch = function (evt) {
      if (!this._keyUpPrevented) {
        var input = this.$search.val();
  
        this.trigger('query', {
          term: input
        });
      }
  
      this._keyUpPrevented = false;
    };
  
    Search.prototype.showSearch = function (_, params) {
      return true;
    };
  
    return Search;
  });
  
  S2.define('select2/dropdown/hidePlaceholder',[
  
  ], function () {
    function HidePlaceholder (decorated, $element, options, dataAdapter) {
      this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
  
      decorated.call(this, $element, options, dataAdapter);
    }
  
    HidePlaceholder.prototype.append = function (decorated, data) {
      data.results = this.removePlaceholder(data.results);
  
      decorated.call(this, data);
    };
  
    HidePlaceholder.prototype.normalizePlaceholder = function (_, placeholder) {
      if (typeof placeholder === 'string') {
        placeholder = {
          id: '',
          text: placeholder
        };
      }
  
      return placeholder;
    };
  
    HidePlaceholder.prototype.removePlaceholder = function (_, data) {
      var modifiedData = data.slice(0);
  
      for (var d = data.length - 1; d >= 0; d--) {
        var item = data[d];
  
        if (this.placeholder.id === item.id) {
          modifiedData.splice(d, 1);
        }
      }
  
      return modifiedData;
    };
  
    return HidePlaceholder;
  });
  
  S2.define('select2/dropdown/infiniteScroll',[
    'jquery'
  ], function ($) {
    function InfiniteScroll (decorated, $element, options, dataAdapter) {
      this.lastParams = {};
  
      decorated.call(this, $element, options, dataAdapter);
  
      this.$loadingMore = this.createLoadingMore();
      this.loading = false;
    }
  
    InfiniteScroll.prototype.append = function (decorated, data) {
      this.$loadingMore.remove();
      this.loading = false;
  
      decorated.call(this, data);
  
      if (this.showLoadingMore(data)) {
        this.$results.append(this.$loadingMore);
      }
    };
  
    InfiniteScroll.prototype.bind = function (decorated, container, $container) {
      var self = this;
  
      decorated.call(this, container, $container);
  
      container.on('query', function (params) {
        self.lastParams = params;
        self.loading = true;
      });
  
      container.on('query:append', function (params) {
        self.lastParams = params;
        self.loading = true;
      });
  
      this.$results.on('scroll', function () {
        var isLoadMoreVisible = $.contains(
          document.documentElement,
          self.$loadingMore[0]
        );
  
        if (self.loading || !isLoadMoreVisible) {
          return;
        }
  
        var currentOffset = self.$results.offset().top +
          self.$results.outerHeight(false);
        var loadingMoreOffset = self.$loadingMore.offset().top +
          self.$loadingMore.outerHeight(false);
  
        if (currentOffset + 50 >= loadingMoreOffset) {
          self.loadMore();
        }
      });
    };
  
    InfiniteScroll.prototype.loadMore = function () {
      this.loading = true;
  
      var params = $.extend({}, {page: 1}, this.lastParams);
  
      params.page++;
  
      this.trigger('query:append', params);
    };
  
    InfiniteScroll.prototype.showLoadingMore = function (_, data) {
      return data.pagination && data.pagination.more;
    };
  
    InfiniteScroll.prototype.createLoadingMore = function () {
      var $option = $(
        '<li ' +
        'class="select2-results__option select2-results__option--load-more"' +
        'role="treeitem" aria-disabled="true"></li>'
      );
  
      var message = this.options.get('translations').get('loadingMore');
  
      $option.html(message(this.lastParams));
  
      return $option;
    };
  
    return InfiniteScroll;
  });
  
  S2.define('select2/dropdown/attachBody',[
    'jquery',
    '../utils'
  ], function ($, Utils) {
    function AttachBody (decorated, $element, options) {
      this.$dropdownParent = options.get('dropdownParent') || $(document.body);
  
      decorated.call(this, $element, options);
    }
  
    AttachBody.prototype.bind = function (decorated, container, $container) {
      var self = this;
  
      var setupResultsEvents = false;
  
      decorated.call(this, container, $container);
  
      container.on('open', function () {
        self._showDropdown();
        self._attachPositioningHandler(container);
  
        if (!setupResultsEvents) {
          setupResultsEvents = true;
  
          container.on('results:all', function () {
            self._positionDropdown();
            self._resizeDropdown();
          });
  
          container.on('results:append', function () {
            self._positionDropdown();
            self._resizeDropdown();
          });
        }
      });
  
      container.on('close', function () {
        self._hideDropdown();
        self._detachPositioningHandler(container);
      });
  
      this.$dropdownContainer.on('mousedown', function (evt) {
        evt.stopPropagation();
      });
    };
  
    AttachBody.prototype.destroy = function (decorated) {
      decorated.call(this);
  
      this.$dropdownContainer.remove();
    };
  
    AttachBody.prototype.position = function (decorated, $dropdown, $container) {
      // Clone all of the container classes
      $dropdown.attr('class', $container.attr('class'));
  
      $dropdown.removeClass('select2');
      $dropdown.addClass('select2-container--open');
  
      $dropdown.css({
        position: 'absolute',
        top: -999999
      });
  
      this.$container = $container;
    };
  
    AttachBody.prototype.render = function (decorated) {
      var $container = $('<span></span>');
  
      var $dropdown = decorated.call(this);
      $container.append($dropdown);
  
      this.$dropdownContainer = $container;
  
      return $container;
    };
  
    AttachBody.prototype._hideDropdown = function (decorated) {
      this.$dropdownContainer.detach();
    };
  
    AttachBody.prototype._attachPositioningHandler =
        function (decorated, container) {
      var self = this;
  
      var scrollEvent = 'scroll.select2.' + container.id;
      var resizeEvent = 'resize.select2.' + container.id;
      var orientationEvent = 'orientationchange.select2.' + container.id;
  
      var $watchers = this.$container.parents().filter(Utils.hasScroll);
      $watchers.each(function () {
        $(this).data('select2-scroll-position', {
          x: $(this).scrollLeft(),
          y: $(this).scrollTop()
        });
      });
  
      $watchers.on(scrollEvent, function (ev) {
        var position = $(this).data('select2-scroll-position');
        $(this).scrollTop(position.y);
      });
  
      $(window).on(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent,
        function (e) {
        self._positionDropdown();
        self._resizeDropdown();
      });
    };
  
    AttachBody.prototype._detachPositioningHandler =
        function (decorated, container) {
      var scrollEvent = 'scroll.select2.' + container.id;
      var resizeEvent = 'resize.select2.' + container.id;
      var orientationEvent = 'orientationchange.select2.' + container.id;
  
      var $watchers = this.$container.parents().filter(Utils.hasScroll);
      $watchers.off(scrollEvent);
  
      $(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent);
    };
  
    AttachBody.prototype._positionDropdown = function () {
      var $window = $(window);
  
      var isCurrentlyAbove = this.$dropdown.hasClass('select2-dropdown--above');
      var isCurrentlyBelow = this.$dropdown.hasClass('select2-dropdown--below');
  
      var newDirection = null;
  
      var offset = this.$container.offset();
  
      offset.bottom = offset.top + this.$container.outerHeight(false);
  
      var container = {
        height: this.$container.outerHeight(false)
      };
  
      container.top = offset.top;
      container.bottom = offset.top + container.height;
  
      var dropdown = {
        height: this.$dropdown.outerHeight(false)
      };
  
      var viewport = {
        top: $window.scrollTop(),
        bottom: $window.scrollTop() + $window.height()
      };
  
      var enoughRoomAbove = viewport.top < (offset.top - dropdown.height);
      var enoughRoomBelow = viewport.bottom > (offset.bottom + dropdown.height);
  
      var css = {
        left: offset.left,
        top: container.bottom
      };
  
      // Determine what the parent element is to use for calciulating the offset
      var $offsetParent = this.$dropdownParent;
  
      // For statically positoned elements, we need to get the element
      // that is determining the offset
      if ($offsetParent.css('position') === 'static') {
        $offsetParent = $offsetParent.offsetParent();
      }
  
      var parentOffset = $offsetParent.offset();
  
      css.top -= parentOffset.top;
      css.left -= parentOffset.left;
  
      if (!isCurrentlyAbove && !isCurrentlyBelow) {
        newDirection = 'below';
      }
  
      if (!enoughRoomBelow && enoughRoomAbove && !isCurrentlyAbove) {
        newDirection = 'above';
      } else if (!enoughRoomAbove && enoughRoomBelow && isCurrentlyAbove) {
        newDirection = 'below';
      }
  
      if (newDirection == 'above' ||
        (isCurrentlyAbove && newDirection !== 'below')) {
        css.top = container.top - parentOffset.top - dropdown.height;
      }
  
      if (newDirection != null) {
        this.$dropdown
          .removeClass('select2-dropdown--below select2-dropdown--above')
          .addClass('select2-dropdown--' + newDirection);
        this.$container
          .removeClass('select2-container--below select2-container--above')
          .addClass('select2-container--' + newDirection);
      }
  
      this.$dropdownContainer.css(css);
    };
  
    AttachBody.prototype._resizeDropdown = function () {
      var css = {
        width: this.$container.outerWidth(false) + 'px'
      };
  
      if (this.options.get('dropdownAutoWidth')) {
        css.minWidth = css.width;
        css.position = 'relative';
        css.width = 'auto';
      }
  
      this.$dropdown.css(css);
    };
  
    AttachBody.prototype._showDropdown = function (decorated) {
      this.$dropdownContainer.appendTo(this.$dropdownParent);
  
      this._positionDropdown();
      this._resizeDropdown();
    };
  
    return AttachBody;
  });
  
  S2.define('select2/dropdown/minimumResultsForSearch',[
  
  ], function () {
    function countResults (data) {
      var count = 0;
  
      for (var d = 0; d < data.length; d++) {
        var item = data[d];
  
        if (item.children) {
          count += countResults(item.children);
        } else {
          count++;
        }
      }
  
      return count;
    }
  
    function MinimumResultsForSearch (decorated, $element, options, dataAdapter) {
      this.minimumResultsForSearch = options.get('minimumResultsForSearch');
  
      if (this.minimumResultsForSearch < 0) {
        this.minimumResultsForSearch = Infinity;
      }
  
      decorated.call(this, $element, options, dataAdapter);
    }
  
    MinimumResultsForSearch.prototype.showSearch = function (decorated, params) {
      if (countResults(params.data.results) < this.minimumResultsForSearch) {
        return false;
      }
  
      return decorated.call(this, params);
    };
  
    return MinimumResultsForSearch;
  });
  
  S2.define('select2/dropdown/selectOnClose',[
  
  ], function () {
    function SelectOnClose () { }
  
    SelectOnClose.prototype.bind = function (decorated, container, $container) {
      var self = this;
  
      decorated.call(this, container, $container);
  
      container.on('close', function (params) {
        self._handleSelectOnClose(params);
      });
    };
  
    SelectOnClose.prototype._handleSelectOnClose = function (_, params) {
      if (params && params.originalSelect2Event != null) {
        var event = params.originalSelect2Event;
  
        // Don't select an item if the close event was triggered from a select or
        // unselect event
        if (event._type === 'select' || event._type === 'unselect') {
          return;
        }
      }
  
      var $highlightedResults = this.getHighlightedResults();
  
      // Only select highlighted results
      if ($highlightedResults.length < 1) {
        return;
      }
  
      var data = $highlightedResults.data('data');
  
      // Don't re-select already selected resulte
      if (
        (data.element != null && data.element.selected) ||
        (data.element == null && data.selected)
      ) {
        return;
      }
  
      this.trigger('select', {
          data: data
      });
    };
  
    return SelectOnClose;
  });
  
  S2.define('select2/dropdown/closeOnSelect',[
  
  ], function () {
    function CloseOnSelect () { }
  
    CloseOnSelect.prototype.bind = function (decorated, container, $container) {
      var self = this;
  
      decorated.call(this, container, $container);
  
      container.on('select', function (evt) {
        self._selectTriggered(evt);
      });
  
      container.on('unselect', function (evt) {
        self._selectTriggered(evt);
      });
    };
  
    CloseOnSelect.prototype._selectTriggered = function (_, evt) {
      var originalEvent = evt.originalEvent;
  
      // Don't close if the control key is being held
      if (originalEvent && originalEvent.ctrlKey) {
        return;
      }
  
      this.trigger('close', {
        originalEvent: originalEvent,
        originalSelect2Event: evt
      });
    };
  
    return CloseOnSelect;
  });
  
  S2.define('select2/i18n/en',[],function () {
    // English
    return {
      errorLoading: function () {
        return 'The results could not be loaded.';
      },
      inputTooLong: function (args) {
        var overChars = args.input.length - args.maximum;
  
        var message = 'Please delete ' + overChars + ' character';
  
        if (overChars != 1) {
          message += 's';
        }
  
        return message;
      },
      inputTooShort: function (args) {
        var remainingChars = args.minimum - args.input.length;
  
        var message = 'Please enter ' + remainingChars + ' or more characters';
  
        return message;
      },
      loadingMore: function () {
        return 'Loading more results…';
      },
      maximumSelected: function (args) {
        var message = 'You can only select ' + args.maximum + ' item';
  
        if (args.maximum != 1) {
          message += 's';
        }
  
        return message;
      },
      noResults: function () {
        return 'No results found';
      },
      searching: function () {
        return 'Searching…';
      }
    };
  });
  
  S2.define('select2/defaults',[
    'jquery',
    'require',
  
    './results',
  
    './selection/single',
    './selection/multiple',
    './selection/placeholder',
    './selection/allowClear',
    './selection/search',
    './selection/eventRelay',
  
    './utils',
    './translation',
    './diacritics',
  
    './data/select',
    './data/array',
    './data/ajax',
    './data/tags',
    './data/tokenizer',
    './data/minimumInputLength',
    './data/maximumInputLength',
    './data/maximumSelectionLength',
  
    './dropdown',
    './dropdown/search',
    './dropdown/hidePlaceholder',
    './dropdown/infiniteScroll',
    './dropdown/attachBody',
    './dropdown/minimumResultsForSearch',
    './dropdown/selectOnClose',
    './dropdown/closeOnSelect',
  
    './i18n/en'
  ], function ($, require,
  
               ResultsList,
  
               SingleSelection, MultipleSelection, Placeholder, AllowClear,
               SelectionSearch, EventRelay,
  
               Utils, Translation, DIACRITICS,
  
               SelectData, ArrayData, AjaxData, Tags, Tokenizer,
               MinimumInputLength, MaximumInputLength, MaximumSelectionLength,
  
               Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll,
               AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect,
  
               EnglishTranslation) {
    function Defaults () {
      this.reset();
    }
  
    Defaults.prototype.apply = function (options) {
      options = $.extend(true, {}, this.defaults, options);
  
      if (options.dataAdapter == null) {
        if (options.ajax != null) {
          options.dataAdapter = AjaxData;
        } else if (options.data != null) {
          options.dataAdapter = ArrayData;
        } else {
          options.dataAdapter = SelectData;
        }
  
        if (options.minimumInputLength > 0) {
          options.dataAdapter = Utils.Decorate(
            options.dataAdapter,
            MinimumInputLength
          );
        }
  
        if (options.maximumInputLength > 0) {
          options.dataAdapter = Utils.Decorate(
            options.dataAdapter,
            MaximumInputLength
          );
        }
  
        if (options.maximumSelectionLength > 0) {
          options.dataAdapter = Utils.Decorate(
            options.dataAdapter,
            MaximumSelectionLength
          );
        }
  
        if (options.tags) {
          options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags);
        }
  
        if (options.tokenSeparators != null || options.tokenizer != null) {
          options.dataAdapter = Utils.Decorate(
            options.dataAdapter,
            Tokenizer
          );
        }
  
        if (options.query != null) {
          var Query = require(options.amdBase + 'compat/query');
  
          options.dataAdapter = Utils.Decorate(
            options.dataAdapter,
            Query
          );
        }
  
        if (options.initSelection != null) {
          var InitSelection = require(options.amdBase + 'compat/initSelection');
  
          options.dataAdapter = Utils.Decorate(
            options.dataAdapter,
            InitSelection
          );
        }
      }
  
      if (options.resultsAdapter == null) {
        options.resultsAdapter = ResultsList;
  
        if (options.ajax != null) {
          options.resultsAdapter = Utils.Decorate(
            options.resultsAdapter,
            InfiniteScroll
          );
        }
  
        if (options.placeholder != null) {
          options.resultsAdapter = Utils.Decorate(
            options.resultsAdapter,
            HidePlaceholder
          );
        }
  
        if (options.selectOnClose) {
          options.resultsAdapter = Utils.Decorate(
            options.resultsAdapter,
            SelectOnClose
          );
        }
      }
  
      if (options.dropdownAdapter == null) {
        if (options.multiple) {
          options.dropdownAdapter = Dropdown;
        } else {
          var SearchableDropdown = Utils.Decorate(Dropdown, DropdownSearch);
  
          options.dropdownAdapter = SearchableDropdown;
        }
  
        if (options.minimumResultsForSearch !== 0) {
          options.dropdownAdapter = Utils.Decorate(
            options.dropdownAdapter,
            MinimumResultsForSearch
          );
        }
  
        if (options.closeOnSelect) {
          options.dropdownAdapter = Utils.Decorate(
            options.dropdownAdapter,
            CloseOnSelect
          );
        }
  
        if (
          options.dropdownCssClass != null ||
          options.dropdownCss != null ||
          options.adaptDropdownCssClass != null
        ) {
          var DropdownCSS = require(options.amdBase + 'compat/dropdownCss');
  
          options.dropdownAdapter = Utils.Decorate(
            options.dropdownAdapter,
            DropdownCSS
          );
        }
  
        options.dropdownAdapter = Utils.Decorate(
          options.dropdownAdapter,
          AttachBody
        );
      }
  
      if (options.selectionAdapter == null) {
        if (options.multiple) {
          options.selectionAdapter = MultipleSelection;
        } else {
          options.selectionAdapter = SingleSelection;
        }
  
        // Add the placeholder mixin if a placeholder was specified
        if (options.placeholder != null) {
          options.selectionAdapter = Utils.Decorate(
            options.selectionAdapter,
            Placeholder
          );
        }
  
        if (options.allowClear) {
          options.selectionAdapter = Utils.Decorate(
            options.selectionAdapter,
            AllowClear
          );
        }
  
        if (options.multiple) {
          options.selectionAdapter = Utils.Decorate(
            options.selectionAdapter,
            SelectionSearch
          );
        }
  
        if (
          options.containerCssClass != null ||
          options.containerCss != null ||
          options.adaptContainerCssClass != null
        ) {
          var ContainerCSS = require(options.amdBase + 'compat/containerCss');
  
          options.selectionAdapter = Utils.Decorate(
            options.selectionAdapter,
            ContainerCSS
          );
        }
  
        options.selectionAdapter = Utils.Decorate(
          options.selectionAdapter,
          EventRelay
        );
      }
  
      if (typeof options.language === 'string') {
        // Check if the language is specified with a region
        if (options.language.indexOf('-') > 0) {
          // Extract the region information if it is included
          var languageParts = options.language.split('-');
          var baseLanguage = languageParts[0];
  
          options.language = [options.language, baseLanguage];
        } else {
          options.language = [options.language];
        }
      }
  
      if ($.isArray(options.language)) {
        var languages = new Translation();
        options.language.push('en');
  
        var languageNames = options.language;
  
        for (var l = 0; l < languageNames.length; l++) {
          var name = languageNames[l];
          var language = {};
  
          try {
            // Try to load it with the original name
            language = Translation.loadPath(name);
          } catch (e) {
            try {
              // If we couldn't load it, check if it wasn't the full path
              name = this.defaults.amdLanguageBase + name;
              language = Translation.loadPath(name);
            } catch (ex) {
              // The translation could not be loaded at all. Sometimes this is
              // because of a configuration problem, other times this can be
              // because of how Select2 helps load all possible translation files.
              if (options.debug && window.console && console.warn) {
                console.warn(
                  'Select2: The language file for "' + name + '" could not be ' +
                  'automatically loaded. A fallback will be used instead.'
                );
              }
  
              continue;
            }
          }
  
          languages.extend(language);
        }
  
        options.translations = languages;
      } else {
        var baseTranslation = Translation.loadPath(
          this.defaults.amdLanguageBase + 'en'
        );
        var customTranslation = new Translation(options.language);
  
        customTranslation.extend(baseTranslation);
  
        options.translations = customTranslation;
      }
  
      return options;
    };
  
    Defaults.prototype.reset = function () {
      function stripDiacritics (text) {
        // Used 'uni range + named function' from http://jsperf.com/diacritics/18
        function match(a) {
          return DIACRITICS[a] || a;
        }
  
        return text.replace(/[^\u0000-\u007E]/g, match);
      }
  
      function matcher (params, data) {
        // Always return the object if there is nothing to compare
        if ($.trim(params.term) === '') {
          return data;
        }
  
        // Do a recursive check for options with children
        if (data.children && data.children.length > 0) {
          // Clone the data object if there are children
          // This is required as we modify the object to remove any non-matches
          var match = $.extend(true, {}, data);
  
          // Check each child of the option
          for (var c = data.children.length - 1; c >= 0; c--) {
            var child = data.children[c];
  
            var matches = matcher(params, child);
  
            // If there wasn't a match, remove the object in the array
            if (matches == null) {
              match.children.splice(c, 1);
            }
          }
  
          // If any children matched, return the new object
          if (match.children.length > 0) {
            return match;
          }
  
          // If there were no matching children, check just the plain object
          return matcher(params, match);
        }
  
        var original = stripDiacritics(data.text).toUpperCase();
        var term = stripDiacritics(params.term).toUpperCase();
  
        // Check if the text contains the term
        if (original.indexOf(term) > -1) {
          return data;
        }
  
        // If it doesn't contain the term, don't return anything
        return null;
      }
  
      this.defaults = {
        amdBase: './',
        amdLanguageBase: './i18n/',
        closeOnSelect: true,
        debug: false,
        dropdownAutoWidth: false,
        escapeMarkup: Utils.escapeMarkup,
        language: EnglishTranslation,
        matcher: matcher,
        minimumInputLength: 0,
        maximumInputLength: 0,
        maximumSelectionLength: 0,
        minimumResultsForSearch: 0,
        selectOnClose: false,
        sorter: function (data) {
          return data;
        },
        templateResult: function (result) {
          return result.text;
        },
        templateSelection: function (selection) {
          return selection.text;
        },
        theme: 'default',
        width: 'resolve'
      };
    };
  
    Defaults.prototype.set = function (key, value) {
      var camelKey = $.camelCase(key);
  
      var data = {};
      data[camelKey] = value;
  
      var convertedData = Utils._convertData(data);
  
      $.extend(this.defaults, convertedData);
    };
  
    var defaults = new Defaults();
  
    return defaults;
  });
  
  S2.define('select2/options',[
    'require',
    'jquery',
    './defaults',
    './utils'
  ], function (require, $, Defaults, Utils) {
    function Options (options, $element) {
      this.options = options;
  
      if ($element != null) {
        this.fromElement($element);
      }
  
      this.options = Defaults.apply(this.options);
  
      if ($element && $element.is('input')) {
        var InputCompat = require(this.get('amdBase') + 'compat/inputData');
  
        this.options.dataAdapter = Utils.Decorate(
          this.options.dataAdapter,
          InputCompat
        );
      }
    }
  
    Options.prototype.fromElement = function ($e) {
      var excludedData = ['select2'];
  
      if (this.options.multiple == null) {
        this.options.multiple = $e.prop('multiple');
      }
  
      if (this.options.disabled == null) {
        this.options.disabled = $e.prop('disabled');
      }
  
      if (this.options.language == null) {
        if ($e.prop('lang')) {
          this.options.language = $e.prop('lang').toLowerCase();
        } else if ($e.closest('[lang]').prop('lang')) {
          this.options.language = $e.closest('[lang]').prop('lang');
        }
      }
  
      if (this.options.dir == null) {
        if ($e.prop('dir')) {
          this.options.dir = $e.prop('dir');
        } else if ($e.closest('[dir]').prop('dir')) {
          this.options.dir = $e.closest('[dir]').prop('dir');
        } else {
          this.options.dir = 'ltr';
        }
      }
  
      $e.prop('disabled', this.options.disabled);
      $e.prop('multiple', this.options.multiple);
  
      if ($e.data('select2Tags')) {
        if (this.options.debug && window.console && console.warn) {
          console.warn(
            'Select2: The `data-select2-tags` attribute has been changed to ' +
            'use the `data-data` and `data-tags="true"` attributes and will be ' +
            'removed in future versions of Select2.'
          );
        }
  
        $e.data('data', $e.data('select2Tags'));
        $e.data('tags', true);
      }
  
      if ($e.data('ajaxUrl')) {
        if (this.options.debug && window.console && console.warn) {
          console.warn(
            'Select2: The `data-ajax-url` attribute has been changed to ' +
            '`data-ajax--url` and support for the old attribute will be removed' +
            ' in future versions of Select2.'
          );
        }
  
        $e.attr('ajax--url', $e.data('ajaxUrl'));
        $e.data('ajax--url', $e.data('ajaxUrl'));
      }
  
      var dataset = {};
  
      // Prefer the element's `dataset` attribute if it exists
      // jQuery 1.x does not correctly handle data attributes with multiple dashes
      if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) {
        dataset = $.extend(true, {}, $e[0].dataset, $e.data());
      } else {
        dataset = $e.data();
      }
  
      var data = $.extend(true, {}, dataset);
  
      data = Utils._convertData(data);
  
      for (var key in data) {
        if ($.inArray(key, excludedData) > -1) {
          continue;
        }
  
        if ($.isPlainObject(this.options[key])) {
          $.extend(this.options[key], data[key]);
        } else {
          this.options[key] = data[key];
        }
      }
  
      return this;
    };
  
    Options.prototype.get = function (key) {
      return this.options[key];
    };
  
    Options.prototype.set = function (key, val) {
      this.options[key] = val;
    };
  
    return Options;
  });
  
  S2.define('select2/core',[
    'jquery',
    './options',
    './utils',
    './keys'
  ], function ($, Options, Utils, KEYS) {
    var Select2 = function ($element, options) {
      if ($element.data('select2') != null) {
        $element.data('select2').destroy();
      }
  
      this.$element = $element;
  
      this.id = this._generateId($element);
  
      options = options || {};
  
      this.options = new Options(options, $element);
  
      Select2.__super__.constructor.call(this);
  
      // Set up the tabindex
  
      var tabindex = $element.attr('tabindex') || 0;
      $element.data('old-tabindex', tabindex);
      $element.attr('tabindex', '-1');
  
      // Set up containers and adapters
  
      var DataAdapter = this.options.get('dataAdapter');
      this.dataAdapter = new DataAdapter($element, this.options);
  
      var $container = this.render();
  
      this._placeContainer($container);
  
      var SelectionAdapter = this.options.get('selectionAdapter');
      this.selection = new SelectionAdapter($element, this.options);
      this.$selection = this.selection.render();
  
      this.selection.position(this.$selection, $container);
  
      var DropdownAdapter = this.options.get('dropdownAdapter');
      this.dropdown = new DropdownAdapter($element, this.options);
      this.$dropdown = this.dropdown.render();
  
      this.dropdown.position(this.$dropdown, $container);
  
      var ResultsAdapter = this.options.get('resultsAdapter');
      this.results = new ResultsAdapter($element, this.options, this.dataAdapter);
      this.$results = this.results.render();
  
      this.results.position(this.$results, this.$dropdown);
  
      // Bind events
  
      var self = this;
  
      // Bind the container to all of the adapters
      this._bindAdapters();
  
      // Register any DOM event handlers
      this._registerDomEvents();
  
      // Register any internal event handlers
      this._registerDataEvents();
      this._registerSelectionEvents();
      this._registerDropdownEvents();
      this._registerResultsEvents();
      this._registerEvents();
  
      // Set the initial state
      this.dataAdapter.current(function (initialData) {
        self.trigger('selection:update', {
          data: initialData
        });
      });
  
      // Hide the original select
      $element.addClass('select2-hidden-accessible');
      $element.attr('aria-hidden', 'true');
  
      // Synchronize any monitored attributes
      this._syncAttributes();
  
      $element.data('select2', this);
    };
  
    Utils.Extend(Select2, Utils.Observable);
  
    Select2.prototype._generateId = function ($element) {
      var id = '';
  
      if ($element.attr('id') != null) {
        id = $element.attr('id');
      } else if ($element.attr('name') != null) {
        id = $element.attr('name') + '-' + Utils.generateChars(2);
      } else {
        id = Utils.generateChars(4);
      }
  
      id = id.replace(/(:|\.|\[|\]|,)/g, '');
      id = 'select2-' + id;
  
      return id;
    };
  
    Select2.prototype._placeContainer = function ($container) {
      $container.insertAfter(this.$element);
  
      var width = this._resolveWidth(this.$element, this.options.get('width'));
  
      if (width != null) {
        $container.css('width', width);
      }
    };
  
    Select2.prototype._resolveWidth = function ($element, method) {
      var WIDTH = /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;
  
      if (method == 'resolve') {
        var styleWidth = this._resolveWidth($element, 'style');
  
        if (styleWidth != null) {
          return styleWidth;
        }
  
        return this._resolveWidth($element, 'element');
      }
  
      if (method == 'element') {
        var elementWidth = $element.outerWidth(false);
  
        if (elementWidth <= 0) {
          return 'auto';
        }
  
        return elementWidth + 'px';
      }
  
      if (method == 'style') {
        var style = $element.attr('style');
  
        if (typeof(style) !== 'string') {
          return null;
        }
  
        var attrs = style.split(';');
  
        for (var i = 0, l = attrs.length; i < l; i = i + 1) {
          var attr = attrs[i].replace(/\s/g, '');
          var matches = attr.match(WIDTH);
  
          if (matches !== null && matches.length >= 1) {
            return matches[1];
          }
        }
  
        return null;
      }
  
      return method;
    };
  
    Select2.prototype._bindAdapters = function () {
      this.dataAdapter.bind(this, this.$container);
      this.selection.bind(this, this.$container);
  
      this.dropdown.bind(this, this.$container);
      this.results.bind(this, this.$container);
    };
  
    Select2.prototype._registerDomEvents = function () {
      var self = this;
  
      this.$element.on('change.select2', function () {
        self.dataAdapter.current(function (data) {
          self.trigger('selection:update', {
            data: data
          });
        });
      });
  
      this.$element.on('focus.select2', function (evt) {
        self.trigger('focus', evt);
      });
  
      this._syncA = Utils.bind(this._syncAttributes, this);
      this._syncS = Utils.bind(this._syncSubtree, this);
  
      if (this.$element[0].attachEvent) {
        this.$element[0].attachEvent('onpropertychange', this._syncA);
      }
  
      var observer = window.MutationObserver ||
        window.WebKitMutationObserver ||
        window.MozMutationObserver
      ;
  
      if (observer != null) {
        this._observer = new observer(function (mutations) {
          $.each(mutations, self._syncA);
          $.each(mutations, self._syncS);
        });
        this._observer.observe(this.$element[0], {
          attributes: true,
          childList: true,
          subtree: false
        });
      } else if (this.$element[0].addEventListener) {
        this.$element[0].addEventListener(
          'DOMAttrModified',
          self._syncA,
          false
        );
        this.$element[0].addEventListener(
          'DOMNodeInserted',
          self._syncS,
          false
        );
        this.$element[0].addEventListener(
          'DOMNodeRemoved',
          self._syncS,
          false
        );
      }
    };
  
    Select2.prototype._registerDataEvents = function () {
      var self = this;
  
      this.dataAdapter.on('*', function (name, params) {
        self.trigger(name, params);
      });
    };
  
    Select2.prototype._registerSelectionEvents = function () {
      var self = this;
      var nonRelayEvents = ['toggle', 'focus'];
  
      this.selection.on('toggle', function () {
        self.toggleDropdown();
      });
  
      this.selection.on('focus', function (params) {
        self.focus(params);
      });
  
      this.selection.on('*', function (name, params) {
        if ($.inArray(name, nonRelayEvents) !== -1) {
          return;
        }
  
        self.trigger(name, params);
      });
    };
  
    Select2.prototype._registerDropdownEvents = function () {
      var self = this;
  
      this.dropdown.on('*', function (name, params) {
        self.trigger(name, params);
      });
    };
  
    Select2.prototype._registerResultsEvents = function () {
      var self = this;
  
      this.results.on('*', function (name, params) {
        self.trigger(name, params);
      });
    };
  
    Select2.prototype._registerEvents = function () {
      var self = this;
  
      this.on('open', function () {
        self.$container.addClass('select2-container--open');
      });
  
      this.on('close', function () {
        self.$container.removeClass('select2-container--open');
      });
  
      this.on('enable', function () {
        self.$container.removeClass('select2-container--disabled');
      });
  
      this.on('disable', function () {
        self.$container.addClass('select2-container--disabled');
      });
  
      this.on('blur', function () {
        self.$container.removeClass('select2-container--focus');
      });
  
      this.on('query', function (params) {
        if (!self.isOpen()) {
          self.trigger('open', {});
        }
  
        this.dataAdapter.query(params, function (data) {
          self.trigger('results:all', {
            data: data,
            query: params
          });
        });
      });
  
      this.on('query:append', function (params) {
        this.dataAdapter.query(params, function (data) {
          self.trigger('results:append', {
            data: data,
            query: params
          });
        });
      });
  
      this.on('keypress', function (evt) {
        var key = evt.which;
  
        if (self.isOpen()) {
          if (key === KEYS.ESC || key === KEYS.TAB ||
              (key === KEYS.UP && evt.altKey)) {
            self.close();
  
            evt.preventDefault();
          } else if (key === KEYS.ENTER) {
            self.trigger('results:select', {});
  
            evt.preventDefault();
          } else if ((key === KEYS.SPACE && evt.ctrlKey)) {
            self.trigger('results:toggle', {});
  
            evt.preventDefault();
          } else if (key === KEYS.UP) {
            self.trigger('results:previous', {});
  
            evt.preventDefault();
          } else if (key === KEYS.DOWN) {
            self.trigger('results:next', {});
  
            evt.preventDefault();
          }
        } else {
          if (key === KEYS.ENTER || key === KEYS.SPACE ||
              (key === KEYS.DOWN && evt.altKey)) {
            self.open();
  
            evt.preventDefault();
          }
        }
      });
    };
  
    Select2.prototype._syncAttributes = function () {
      this.options.set('disabled', this.$element.prop('disabled'));
  
      if (this.options.get('disabled')) {
        if (this.isOpen()) {
          this.close();
        }
  
        this.trigger('disable', {});
      } else {
        this.trigger('enable', {});
      }
    };
  
    Select2.prototype._syncSubtree = function (evt, mutations) {
      var changed = false;
      var self = this;
  
      // Ignore any mutation events raised for elements that aren't options or
      // optgroups. This handles the case when the select element is destroyed
      if (
        evt && evt.target && (
          evt.target.nodeName !== 'OPTION' && evt.target.nodeName !== 'OPTGROUP'
        )
      ) {
        return;
      }
  
      if (!mutations) {
        // If mutation events aren't supported, then we can only assume that the
        // change affected the selections
        changed = true;
      } else if (mutations.addedNodes && mutations.addedNodes.length > 0) {
        for (var n = 0; n < mutations.addedNodes.length; n++) {
          var node = mutations.addedNodes[n];
  
          if (node.selected) {
            changed = true;
          }
        }
      } else if (mutations.removedNodes && mutations.removedNodes.length > 0) {
        changed = true;
      }
  
      // Only re-pull the data if we think there is a change
      if (changed) {
        this.dataAdapter.current(function (currentData) {
          self.trigger('selection:update', {
            data: currentData
          });
        });
      }
    };
  
    /**
     * Override the trigger method to automatically trigger pre-events when
     * there are events that can be prevented.
     */
    Select2.prototype.trigger = function (name, args) {
      var actualTrigger = Select2.__super__.trigger;
      var preTriggerMap = {
        'open': 'opening',
        'close': 'closing',
        'select': 'selecting',
        'unselect': 'unselecting'
      };
  
      if (args === undefined) {
        args = {};
      }
  
      if (name in preTriggerMap) {
        var preTriggerName = preTriggerMap[name];
        var preTriggerArgs = {
          prevented: false,
          name: name,
          args: args
        };
  
        actualTrigger.call(this, preTriggerName, preTriggerArgs);
  
        if (preTriggerArgs.prevented) {
          args.prevented = true;
  
          return;
        }
      }
  
      actualTrigger.call(this, name, args);
    };
  
    Select2.prototype.toggleDropdown = function () {
      if (this.options.get('disabled')) {
        return;
      }
  
      if (this.isOpen()) {
        this.close();
      } else {
        this.open();
      }
    };
  
    Select2.prototype.open = function () {
      if (this.isOpen()) {
        return;
      }
  
      this.trigger('query', {});
    };
  
    Select2.prototype.close = function () {
      if (!this.isOpen()) {
        return;
      }
  
      this.trigger('close', {});
    };
  
    Select2.prototype.isOpen = function () {
      return this.$container.hasClass('select2-container--open');
    };
  
    Select2.prototype.hasFocus = function () {
      return this.$container.hasClass('select2-container--focus');
    };
  
    Select2.prototype.focus = function (data) {
      // No need to re-trigger focus events if we are already focused
      if (this.hasFocus()) {
        return;
      }
  
      this.$container.addClass('select2-container--focus');
      this.trigger('focus', {});
    };
  
    Select2.prototype.enable = function (args) {
      if (this.options.get('debug') && window.console && console.warn) {
        console.warn(
          'Select2: The `select2("enable")` method has been deprecated and will' +
          ' be removed in later Select2 versions. Use $element.prop("disabled")' +
          ' instead.'
        );
      }
  
      if (args == null || args.length === 0) {
        args = [true];
      }
  
      var disabled = !args[0];
  
      this.$element.prop('disabled', disabled);
    };
  
    Select2.prototype.data = function () {
      if (this.options.get('debug') &&
          arguments.length > 0 && window.console && console.warn) {
        console.warn(
          'Select2: Data can no longer be set using `select2("data")`. You ' +
          'should consider setting the value instead using `$element.val()`.'
        );
      }
  
      var data = [];
  
      this.dataAdapter.current(function (currentData) {
        data = currentData;
      });
  
      return data;
    };
  
    Select2.prototype.val = function (args) {
      if (this.options.get('debug') && window.console && console.warn) {
        console.warn(
          'Select2: The `select2("val")` method has been deprecated and will be' +
          ' removed in later Select2 versions. Use $element.val() instead.'
        );
      }
  
      if (args == null || args.length === 0) {
        return this.$element.val();
      }
  
      var newVal = args[0];
  
      if ($.isArray(newVal)) {
        newVal = $.map(newVal, function (obj) {
          return obj.toString();
        });
      }
  
      this.$element.val(newVal).trigger('change');
    };
  
    Select2.prototype.destroy = function () {
      this.$container.remove();
  
      if (this.$element[0].detachEvent) {
        this.$element[0].detachEvent('onpropertychange', this._syncA);
      }
  
      if (this._observer != null) {
        this._observer.disconnect();
        this._observer = null;
      } else if (this.$element[0].removeEventListener) {
        this.$element[0]
          .removeEventListener('DOMAttrModified', this._syncA, false);
        this.$element[0]
          .removeEventListener('DOMNodeInserted', this._syncS, false);
        this.$element[0]
          .removeEventListener('DOMNodeRemoved', this._syncS, false);
      }
  
      this._syncA = null;
      this._syncS = null;
  
      this.$element.off('.select2');
      this.$element.attr('tabindex', this.$element.data('old-tabindex'));
  
      this.$element.removeClass('select2-hidden-accessible');
      this.$element.attr('aria-hidden', 'false');
      this.$element.removeData('select2');
  
      this.dataAdapter.destroy();
      this.selection.destroy();
      this.dropdown.destroy();
      this.results.destroy();
  
      this.dataAdapter = null;
      this.selection = null;
      this.dropdown = null;
      this.results = null;
    };
  
    Select2.prototype.render = function () {
      var $container = $(
        '<span class="select2 select2-container">' +
          '<span class="selection"></span>' +
          '<span class="dropdown-wrapper" aria-hidden="true"></span>' +
        '</span>'
      );
  
      $container.attr('dir', this.options.get('dir'));
  
      this.$container = $container;
  
      this.$container.addClass('select2-container--' + this.options.get('theme'));
  
      $container.data('element', this.$element);
  
      return $container;
    };
  
    return Select2;
  });
  
  S2.define('select2/compat/utils',[
    'jquery'
  ], function ($) {
    function syncCssClasses ($dest, $src, adapter) {
      var classes, replacements = [], adapted;
  
      classes = $.trim($dest.attr('class'));
  
      if (classes) {
        classes = '' + classes; // for IE which returns object
  
        $(classes.split(/\s+/)).each(function () {
          // Save all Select2 classes
          if (this.indexOf('select2-') === 0) {
            replacements.push(this);
          }
        });
      }
  
      classes = $.trim($src.attr('class'));
  
      if (classes) {
        classes = '' + classes; // for IE which returns object
  
        $(classes.split(/\s+/)).each(function () {
          // Only adapt non-Select2 classes
          if (this.indexOf('select2-') !== 0) {
            adapted = adapter(this);
  
            if (adapted != null) {
              replacements.push(adapted);
            }
          }
        });
      }
  
      $dest.attr('class', replacements.join(' '));
    }
  
    return {
      syncCssClasses: syncCssClasses
    };
  });
  
  S2.define('select2/compat/containerCss',[
    'jquery',
    './utils'
  ], function ($, CompatUtils) {
    // No-op CSS adapter that discards all classes by default
    function _containerAdapter (clazz) {
      return null;
    }
  
    function ContainerCSS () { }
  
    ContainerCSS.prototype.render = function (decorated) {
      var $container = decorated.call(this);
  
      var containerCssClass = this.options.get('containerCssClass') || '';
  
      if ($.isFunction(containerCssClass)) {
        containerCssClass = containerCssClass(this.$element);
      }
  
      var containerCssAdapter = this.options.get('adaptContainerCssClass');
      containerCssAdapter = containerCssAdapter || _containerAdapter;
  
      if (containerCssClass.indexOf(':all:') !== -1) {
        containerCssClass = containerCssClass.replace(':all:', '');
  
        var _cssAdapter = containerCssAdapter;
  
        containerCssAdapter = function (clazz) {
          var adapted = _cssAdapter(clazz);
  
          if (adapted != null) {
            // Append the old one along with the adapted one
            return adapted + ' ' + clazz;
          }
  
          return clazz;
        };
      }
  
      var containerCss = this.options.get('containerCss') || {};
  
      if ($.isFunction(containerCss)) {
        containerCss = containerCss(this.$element);
      }
  
      CompatUtils.syncCssClasses($container, this.$element, containerCssAdapter);
  
      $container.css(containerCss);
      $container.addClass(containerCssClass);
  
      return $container;
    };
  
    return ContainerCSS;
  });
  
  S2.define('select2/compat/dropdownCss',[
    'jquery',
    './utils'
  ], function ($, CompatUtils) {
    // No-op CSS adapter that discards all classes by default
    function _dropdownAdapter (clazz) {
      return null;
    }
  
    function DropdownCSS () { }
  
    DropdownCSS.prototype.render = function (decorated) {
      var $dropdown = decorated.call(this);
  
      var dropdownCssClass = this.options.get('dropdownCssClass') || '';
  
      if ($.isFunction(dropdownCssClass)) {
        dropdownCssClass = dropdownCssClass(this.$element);
      }
  
      var dropdownCssAdapter = this.options.get('adaptDropdownCssClass');
      dropdownCssAdapter = dropdownCssAdapter || _dropdownAdapter;
  
      if (dropdownCssClass.indexOf(':all:') !== -1) {
        dropdownCssClass = dropdownCssClass.replace(':all:', '');
  
        var _cssAdapter = dropdownCssAdapter;
  
        dropdownCssAdapter = function (clazz) {
          var adapted = _cssAdapter(clazz);
  
          if (adapted != null) {
            // Append the old one along with the adapted one
            return adapted + ' ' + clazz;
          }
  
          return clazz;
        };
      }
  
      var dropdownCss = this.options.get('dropdownCss') || {};
  
      if ($.isFunction(dropdownCss)) {
        dropdownCss = dropdownCss(this.$element);
      }
  
      CompatUtils.syncCssClasses($dropdown, this.$element, dropdownCssAdapter);
  
      $dropdown.css(dropdownCss);
      $dropdown.addClass(dropdownCssClass);
  
      return $dropdown;
    };
  
    return DropdownCSS;
  });
  
  S2.define('select2/compat/initSelection',[
    'jquery'
  ], function ($) {
    function InitSelection (decorated, $element, options) {
      if (options.get('debug') && window.console && console.warn) {
        console.warn(
          'Select2: The `initSelection` option has been deprecated in favor' +
          ' of a custom data adapter that overrides the `current` method. ' +
          'This method is now called multiple times instead of a single ' +
          'time when the instance is initialized. Support will be removed ' +
          'for the `initSelection` option in future versions of Select2'
        );
      }
  
      this.initSelection = options.get('initSelection');
      this._isInitialized = false;
  
      decorated.call(this, $element, options);
    }
  
    InitSelection.prototype.current = function (decorated, callback) {
      var self = this;
  
      if (this._isInitialized) {
        decorated.call(this, callback);
  
        return;
      }
  
      this.initSelection.call(null, this.$element, function (data) {
        self._isInitialized = true;
  
        if (!$.isArray(data)) {
          data = [data];
        }
  
        callback(data);
      });
    };
  
    return InitSelection;
  });
  
  S2.define('select2/compat/inputData',[
    'jquery'
  ], function ($) {
    function InputData (decorated, $element, options) {
      this._currentData = [];
      this._valueSeparator = options.get('valueSeparator') || ',';
  
      if ($element.prop('type') === 'hidden') {
        if (options.get('debug') && console && console.warn) {
          console.warn(
            'Select2: Using a hidden input with Select2 is no longer ' +
            'supported and may stop working in the future. It is recommended ' +
            'to use a `<select>` element instead.'
          );
        }
      }
  
      decorated.call(this, $element, options);
    }
  
    InputData.prototype.current = function (_, callback) {
      function getSelected (data, selectedIds) {
        var selected = [];
  
        if (data.selected || $.inArray(data.id, selectedIds) !== -1) {
          data.selected = true;
          selected.push(data);
        } else {
          data.selected = false;
        }
  
        if (data.children) {
          selected.push.apply(selected, getSelected(data.children, selectedIds));
        }
  
        return selected;
      }
  
      var selected = [];
  
      for (var d = 0; d < this._currentData.length; d++) {
        var data = this._currentData[d];
  
        selected.push.apply(
          selected,
          getSelected(
            data,
            this.$element.val().split(
              this._valueSeparator
            )
          )
        );
      }
  
      callback(selected);
    };
  
    InputData.prototype.select = function (_, data) {
      if (!this.options.get('multiple')) {
        this.current(function (allData) {
          $.map(allData, function (data) {
            data.selected = false;
          });
        });
  
        this.$element.val(data.id);
        this.$element.trigger('change');
      } else {
        var value = this.$element.val();
        value += this._valueSeparator + data.id;
  
        this.$element.val(value);
        this.$element.trigger('change');
      }
    };
  
    InputData.prototype.unselect = function (_, data) {
      var self = this;
  
      data.selected = false;
  
      this.current(function (allData) {
        var values = [];
  
        for (var d = 0; d < allData.length; d++) {
          var item = allData[d];
  
          if (data.id == item.id) {
            continue;
          }
  
          values.push(item.id);
        }
  
        self.$element.val(values.join(self._valueSeparator));
        self.$element.trigger('change');
      });
    };
  
    InputData.prototype.query = function (_, params, callback) {
      var results = [];
  
      for (var d = 0; d < this._currentData.length; d++) {
        var data = this._currentData[d];
  
        var matches = this.matches(params, data);
  
        if (matches !== null) {
          results.push(matches);
        }
      }
  
      callback({
        results: results
      });
    };
  
    InputData.prototype.addOptions = function (_, $options) {
      var options = $.map($options, function ($option) {
        return $.data($option[0], 'data');
      });
  
      this._currentData.push.apply(this._currentData, options);
    };
  
    return InputData;
  });
  
  S2.define('select2/compat/matcher',[
    'jquery'
  ], function ($) {
    function oldMatcher (matcher) {
      function wrappedMatcher (params, data) {
        var match = $.extend(true, {}, data);
  
        if (params.term == null || $.trim(params.term) === '') {
          return match;
        }
  
        if (data.children) {
          for (var c = data.children.length - 1; c >= 0; c--) {
            var child = data.children[c];
  
            // Check if the child object matches
            // The old matcher returned a boolean true or false
            var doesMatch = matcher(params.term, child.text, child);
  
            // If the child didn't match, pop it off
            if (!doesMatch) {
              match.children.splice(c, 1);
            }
          }
  
          if (match.children.length > 0) {
            return match;
          }
        }
  
        if (matcher(params.term, data.text, data)) {
          return match;
        }
  
        return null;
      }
  
      return wrappedMatcher;
    }
  
    return oldMatcher;
  });
  
  S2.define('select2/compat/query',[
  
  ], function () {
    function Query (decorated, $element, options) {
      if (options.get('debug') && window.console && console.warn) {
        console.warn(
          'Select2: The `query` option has been deprecated in favor of a ' +
          'custom data adapter that overrides the `query` method. Support ' +
          'will be removed for the `query` option in future versions of ' +
          'Select2.'
        );
      }
  
      decorated.call(this, $element, options);
    }
  
    Query.prototype.query = function (_, params, callback) {
      params.callback = callback;
  
      var query = this.options.get('query');
  
      query.call(null, params);
    };
  
    return Query;
  });
  
  S2.define('select2/dropdown/attachContainer',[
  
  ], function () {
    function AttachContainer (decorated, $element, options) {
      decorated.call(this, $element, options);
    }
  
    AttachContainer.prototype.position =
      function (decorated, $dropdown, $container) {
      var $dropdownContainer = $container.find('.dropdown-wrapper');
      $dropdownContainer.append($dropdown);
  
      $dropdown.addClass('select2-dropdown--below');
      $container.addClass('select2-container--below');
    };
  
    return AttachContainer;
  });
  
  S2.define('select2/dropdown/stopPropagation',[
  
  ], function () {
    function StopPropagation () { }
  
    StopPropagation.prototype.bind = function (decorated, container, $container) {
      decorated.call(this, container, $container);
  
      var stoppedEvents = [
      'blur',
      'change',
      'click',
      'dblclick',
      'focus',
      'focusin',
      'focusout',
      'input',
      'keydown',
      'keyup',
      'keypress',
      'mousedown',
      'mouseenter',
      'mouseleave',
      'mousemove',
      'mouseover',
      'mouseup',
      'search',
      'touchend',
      'touchstart'
      ];
  
      this.$dropdown.on(stoppedEvents.join(' '), function (evt) {
        evt.stopPropagation();
      });
    };
  
    return StopPropagation;
  });
  
  S2.define('select2/selection/stopPropagation',[
  
  ], function () {
    function StopPropagation () { }
  
    StopPropagation.prototype.bind = function (decorated, container, $container) {
      decorated.call(this, container, $container);
  
      var stoppedEvents = [
        'blur',
        'change',
        'click',
        'dblclick',
        'focus',
        'focusin',
        'focusout',
        'input',
        'keydown',
        'keyup',
        'keypress',
        'mousedown',
        'mouseenter',
        'mouseleave',
        'mousemove',
        'mouseover',
        'mouseup',
        'search',
        'touchend',
        'touchstart'
      ];
  
      this.$selection.on(stoppedEvents.join(' '), function (evt) {
        evt.stopPropagation();
      });
    };
  
    return StopPropagation;
  });
  
  /*!
   * jQuery Mousewheel 3.1.13
   *
   * Copyright jQuery Foundation and other contributors
   * Released under the MIT license
   * http://jquery.org/license
   */
  
  (function (factory) {
      if ( typeof S2.define === 'function' && S2.define.amd ) {
          // AMD. Register as an anonymous module.
          S2.define('jquery-mousewheel',['jquery'], factory);
      } else if (typeof exports === 'object') {
          // Node/CommonJS style for Browserify
          module.exports = factory;
      } else {
          // Browser globals
          factory(jQuery);
      }
  }(function ($) {
  
      var toFix  = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
          toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
                      ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
          slice  = Array.prototype.slice,
          nullLowestDeltaTimeout, lowestDelta;
  
      if ( $.event.fixHooks ) {
          for ( var i = toFix.length; i; ) {
              $.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks;
          }
      }
  
      var special = $.event.special.mousewheel = {
          version: '3.1.12',
  
          setup: function() {
              if ( this.addEventListener ) {
                  for ( var i = toBind.length; i; ) {
                      this.addEventListener( toBind[--i], handler, false );
                  }
              } else {
                  this.onmousewheel = handler;
              }
              // Store the line height and page height for this particular element
              $.data(this, 'mousewheel-line-height', special.getLineHeight(this));
              $.data(this, 'mousewheel-page-height', special.getPageHeight(this));
          },
  
          teardown: function() {
              if ( this.removeEventListener ) {
                  for ( var i = toBind.length; i; ) {
                      this.removeEventListener( toBind[--i], handler, false );
                  }
              } else {
                  this.onmousewheel = null;
              }
              // Clean up the data we added to the element
              $.removeData(this, 'mousewheel-line-height');
              $.removeData(this, 'mousewheel-page-height');
          },
  
          getLineHeight: function(elem) {
              var $elem = $(elem),
                  $parent = $elem['offsetParent' in $.fn ? 'offsetParent' : 'parent']();
              if (!$parent.length) {
                  $parent = $('body');
              }
              return parseInt($parent.css('fontSize'), 10) || parseInt($elem.css('fontSize'), 10) || 16;
          },
  
          getPageHeight: function(elem) {
              return $(elem).height();
          },
  
          settings: {
              adjustOldDeltas: true, // see shouldAdjustOldDeltas() below
              normalizeOffset: true  // calls getBoundingClientRect for each event
          }
      };
  
      $.fn.extend({
          mousewheel: function(fn) {
              return fn ? this.bind('mousewheel', fn) : this.trigger('mousewheel');
          },
  
          unmousewheel: function(fn) {
              return this.unbind('mousewheel', fn);
          }
      });
  
  
      function handler(event) {
          var orgEvent   = event || window.event,
              args       = slice.call(arguments, 1),
              delta      = 0,
              deltaX     = 0,
              deltaY     = 0,
              absDelta   = 0,
              offsetX    = 0,
              offsetY    = 0;
          event = $.event.fix(orgEvent);
          event.type = 'mousewheel';
  
          // Old school scrollwheel delta
          if ( 'detail'      in orgEvent ) { deltaY = orgEvent.detail * -1;      }
          if ( 'wheelDelta'  in orgEvent ) { deltaY = orgEvent.wheelDelta;       }
          if ( 'wheelDeltaY' in orgEvent ) { deltaY = orgEvent.wheelDeltaY;      }
          if ( 'wheelDeltaX' in orgEvent ) { deltaX = orgEvent.wheelDeltaX * -1; }
  
          // Firefox < 17 horizontal scrolling related to DOMMouseScroll event
          if ( 'axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
              deltaX = deltaY * -1;
              deltaY = 0;
          }
  
          // Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy
          delta = deltaY === 0 ? deltaX : deltaY;
  
          // New school wheel delta (wheel event)
          if ( 'deltaY' in orgEvent ) {
              deltaY = orgEvent.deltaY * -1;
              delta  = deltaY;
          }
          if ( 'deltaX' in orgEvent ) {
              deltaX = orgEvent.deltaX;
              if ( deltaY === 0 ) { delta  = deltaX * -1; }
          }
  
          // No change actually happened, no reason to go any further
          if ( deltaY === 0 && deltaX === 0 ) { return; }
  
          // Need to convert lines and pages to pixels if we aren't already in pixels
          // There are three delta modes:
          //   * deltaMode 0 is by pixels, nothing to do
          //   * deltaMode 1 is by lines
          //   * deltaMode 2 is by pages
          if ( orgEvent.deltaMode === 1 ) {
              var lineHeight = $.data(this, 'mousewheel-line-height');
              delta  *= lineHeight;
              deltaY *= lineHeight;
              deltaX *= lineHeight;
          } else if ( orgEvent.deltaMode === 2 ) {
              var pageHeight = $.data(this, 'mousewheel-page-height');
              delta  *= pageHeight;
              deltaY *= pageHeight;
              deltaX *= pageHeight;
          }
  
          // Store lowest absolute delta to normalize the delta values
          absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );
  
          if ( !lowestDelta || absDelta < lowestDelta ) {
              lowestDelta = absDelta;
  
              // Adjust older deltas if necessary
              if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
                  lowestDelta /= 40;
              }
          }
  
          // Adjust older deltas if necessary
          if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
              // Divide all the things by 40!
              delta  /= 40;
              deltaX /= 40;
              deltaY /= 40;
          }
  
          // Get a whole, normalized value for the deltas
          delta  = Math[ delta  >= 1 ? 'floor' : 'ceil' ](delta  / lowestDelta);
          deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);
          deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);
  
          // Normalise offsetX and offsetY properties
          if ( special.settings.normalizeOffset && this.getBoundingClientRect ) {
              var boundingRect = this.getBoundingClientRect();
              offsetX = event.clientX - boundingRect.left;
              offsetY = event.clientY - boundingRect.top;
          }
  
          // Add information to the event object
          event.deltaX = deltaX;
          event.deltaY = deltaY;
          event.deltaFactor = lowestDelta;
          event.offsetX = offsetX;
          event.offsetY = offsetY;
          // Go ahead and set deltaMode to 0 since we converted to pixels
          // Although this is a little odd since we overwrite the deltaX/Y
          // properties with normalized deltas.
          event.deltaMode = 0;
  
          // Add event and delta to the front of the arguments
          args.unshift(event, delta, deltaX, deltaY);
  
          // Clearout lowestDelta after sometime to better
          // handle multiple device types that give different
          // a different lowestDelta
          // Ex: trackpad = 3 and mouse wheel = 120
          if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }
          nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);
  
          return ($.event.dispatch || $.event.handle).apply(this, args);
      }
  
      function nullLowestDelta() {
          lowestDelta = null;
      }
  
      function shouldAdjustOldDeltas(orgEvent, absDelta) {
          // If this is an older event and the delta is divisable by 120,
          // then we are assuming that the browser is treating this as an
          // older mouse wheel event and that we should divide the deltas
          // by 40 to try and get a more usable deltaFactor.
          // Side note, this actually impacts the reported scroll distance
          // in older browsers and can cause scrolling to be slower than native.
          // Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false.
          return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0;
      }
  
  }));
  
  S2.define('jquery.select2',[
    'jquery',
    'jquery-mousewheel',
  
    './select2/core',
    './select2/defaults'
  ], function ($, _, Select2, Defaults) {
    if ($.fn.select2 == null) {
      // All methods that should return the element
      var thisMethods = ['open', 'close', 'destroy'];
  
      $.fn.select2 = function (options) {
        options = options || {};
  
        if (typeof options === 'object') {
          this.each(function () {
            var instanceOptions = $.extend(true, {}, options);
  
            var instance = new Select2($(this), instanceOptions);
          });
  
          return this;
        } else if (typeof options === 'string') {
          var ret;
          var args = Array.prototype.slice.call(arguments, 1);
  
          this.each(function () {
            var instance = $(this).data('select2');
  
            if (instance == null && window.console && console.error) {
              console.error(
                'The select2(\'' + options + '\') method was called on an ' +
                'element that is not using Select2.'
              );
            }
  
            ret = instance[options].apply(instance, args);
          });
  
          // Check if we should be returning `this`
          if ($.inArray(options, thisMethods) > -1) {
            return this;
          }
  
          return ret;
        } else {
          throw new Error('Invalid arguments for Select2: ' + options);
        }
      };
    }
  
    if ($.fn.select2.defaults == null) {
      $.fn.select2.defaults = Defaults;
    }
  
    return Select2;
  });
  
    // Return the AMD loader configuration so it can be used outside of this file
    return {
      define: S2.define,
      require: S2.require
    };
  }());
  
    // Autoload the jQuery bindings
    // We know that all of the modules exist above this, so we're safe
    var select2 = S2.require('jquery.select2');
  
    // Hold the AMD module references on the jQuery function that was just loaded
    // This allows Select2 to use the internal loader outside of this file, such
    // as in the language files.
    jQuery.fn.select2.amd = S2;
  
    // Return the Select2 instance for anyone who is importing it.
    return select2;
  }));
  
  /**
  * @license Input Mask plugin for jquery
  * http://github.com/RobinHerbots/jquery.inputmask
  * Copyright (c) 2010 - 2014 Robin Herbots
  * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
  * Version: 0.0.0
  */
  
  (function ($) {
      if ($.fn.inputmask === undefined) {
          //helper functions    
          function isInputEventSupported(eventName) {
              var el = document.createElement('input'),
              eventName = 'on' + eventName,
              isSupported = (eventName in el);
              if (!isSupported) {
                  el.setAttribute(eventName, 'return;');
                  isSupported = typeof el[eventName] == 'function';
              }
              el = null;
              return isSupported;
          }
          function resolveAlias(aliasStr, options, opts) {
              var aliasDefinition = opts.aliases[aliasStr];
              if (aliasDefinition) {
                  if (aliasDefinition.alias) resolveAlias(aliasDefinition.alias, undefined, opts); //alias is another alias
                  $.extend(true, opts, aliasDefinition);  //merge alias definition in the options
                  $.extend(true, opts, options);  //reapply extra given options
                  return true;
              }
              return false;
          }
          function generateMaskSets(opts) {
              var ms = [];
              var genmasks = []; //used to keep track of the masks that where processed, to avoid duplicates
              function getMaskTemplate(mask) {
                  if (opts.numericInput) {
                      mask = mask.split('').reverse().join('');
                  }
                  var escaped = false, outCount = 0, greedy = opts.greedy, repeat = opts.repeat;
                  if (repeat == "*") greedy = false;
                  //if (greedy == true && opts.placeholder == "") opts.placeholder = " ";
                  if (mask.length == 1 && greedy == false && repeat != 0) { opts.placeholder = ""; } //hide placeholder with single non-greedy mask
                  var singleMask = $.map(mask.split(""), function (element, index) {
                      var outElem = [];
                      if (element == opts.escapeChar) {
                          escaped = true;
                      }
                      else if ((element != opts.optionalmarker.start && element != opts.optionalmarker.end) || escaped) {
                          var maskdef = opts.definitions[element];
                          if (maskdef && !escaped) {
                              for (var i = 0; i < maskdef.cardinality; i++) {
                                  outElem.push(opts.placeholder.charAt((outCount + i) % opts.placeholder.length));
                              }
                          } else {
                              outElem.push(element);
                              escaped = false;
                          }
                          outCount += outElem.length;
                          return outElem;
                      }
                  });
  
                  //allocate repetitions
                  var repeatedMask = singleMask.slice();
                  for (var i = 1; i < repeat && greedy; i++) {
                      repeatedMask = repeatedMask.concat(singleMask.slice());
                  }
  
                  return { "mask": repeatedMask, "repeat": repeat, "greedy": greedy };
              }
              //test definition => {fn: RegExp/function, cardinality: int, optionality: bool, newBlockMarker: bool, offset: int, casing: null/upper/lower, def: definitionSymbol}
              function getTestingChain(mask) {
                  if (opts.numericInput) {
                      mask = mask.split('').reverse().join('');
                  }
                  var isOptional = false, escaped = false;
                  var newBlockMarker = false; //indicates wheter the begin/ending of a block should be indicated
  
                  return $.map(mask.split(""), function (element, index) {
                      var outElem = [];
  
                      if (element == opts.escapeChar) {
                          escaped = true;
                      } else if (element == opts.optionalmarker.start && !escaped) {
                          isOptional = true;
                          newBlockMarker = true;
                      }
                      else if (element == opts.optionalmarker.end && !escaped) {
                          isOptional = false;
                          newBlockMarker = true;
                      }
                      else {
                          var maskdef = opts.definitions[element];
                          if (maskdef && !escaped) {
                              var prevalidators = maskdef["prevalidator"], prevalidatorsL = prevalidators ? prevalidators.length : 0;
                              for (var i = 1; i < maskdef.cardinality; i++) {
                                  var prevalidator = prevalidatorsL >= i ? prevalidators[i - 1] : [], validator = prevalidator["validator"], cardinality = prevalidator["cardinality"];
                                  outElem.push({ fn: validator ? typeof validator == 'string' ? new RegExp(validator) : new function () { this.test = validator; } : new RegExp("."), cardinality: cardinality ? cardinality : 1, optionality: isOptional, newBlockMarker: isOptional == true ? newBlockMarker : false, offset: 0, casing: maskdef["casing"], def: maskdef["definitionSymbol"] || element });
                                  if (isOptional == true) //reset newBlockMarker
                                      newBlockMarker = false;
                              }
                              outElem.push({ fn: maskdef.validator ? typeof maskdef.validator == 'string' ? new RegExp(maskdef.validator) : new function () { this.test = maskdef.validator; } : new RegExp("."), cardinality: maskdef.cardinality, optionality: isOptional, newBlockMarker: newBlockMarker, offset: 0, casing: maskdef["casing"], def: maskdef["definitionSymbol"] || element });
                          } else {
                              outElem.push({ fn: null, cardinality: 0, optionality: isOptional, newBlockMarker: newBlockMarker, offset: 0, casing: null, def: element });
                              escaped = false;
                          }
                          //reset newBlockMarker
                          newBlockMarker = false;
                          return outElem;
                      }
                  });
              }
              function markOptional(maskPart) { //needed for the clearOptionalTail functionality
                  return opts.optionalmarker.start + maskPart + opts.optionalmarker.end;
              }
              function splitFirstOptionalEndPart(maskPart) {
                  var optionalStartMarkers = 0, optionalEndMarkers = 0, mpl = maskPart.length;
                  for (var i = 0; i < mpl; i++) {
                      if (maskPart.charAt(i) == opts.optionalmarker.start) {
                          optionalStartMarkers++;
                      }
                      if (maskPart.charAt(i) == opts.optionalmarker.end) {
                          optionalEndMarkers++;
                      }
                      if (optionalStartMarkers > 0 && optionalStartMarkers == optionalEndMarkers)
                          break;
                  }
                  var maskParts = [maskPart.substring(0, i)];
                  if (i < mpl) {
                      maskParts.push(maskPart.substring(i + 1, mpl));
                  }
                  return maskParts;
              }
              function splitFirstOptionalStartPart(maskPart) {
                  var mpl = maskPart.length;
                  for (var i = 0; i < mpl; i++) {
                      if (maskPart.charAt(i) == opts.optionalmarker.start) {
                          break;
                      }
                  }
                  var maskParts = [maskPart.substring(0, i)];
                  if (i < mpl) {
                      maskParts.push(maskPart.substring(i + 1, mpl));
                  }
                  return maskParts;
              }
              function generateMask(maskPrefix, maskPart, metadata) {
                  var maskParts = splitFirstOptionalEndPart(maskPart);
                  var newMask, maskTemplate;
  
                  var masks = splitFirstOptionalStartPart(maskParts[0]);
                  if (masks.length > 1) {
                      newMask = maskPrefix + masks[0] + markOptional(masks[1]) + (maskParts.length > 1 ? maskParts[1] : "");
                      if ($.inArray(newMask, genmasks) == -1 && newMask != "") {
                          genmasks.push(newMask);
                          maskTemplate = getMaskTemplate(newMask);
                          ms.push({
                              "mask": newMask,
                              "_buffer": maskTemplate["mask"],
                              "buffer": maskTemplate["mask"].slice(),
                              "tests": getTestingChain(newMask),
                              "lastValidPosition": -1,
                              "greedy": maskTemplate["greedy"],
                              "repeat": maskTemplate["repeat"],
                              "metadata": metadata
                          });
                      }
                      newMask = maskPrefix + masks[0] + (maskParts.length > 1 ? maskParts[1] : "");
                      if ($.inArray(newMask, genmasks) == -1 && newMask != "") {
                          genmasks.push(newMask);
                          maskTemplate = getMaskTemplate(newMask);
                          ms.push({
                              "mask": newMask,
                              "_buffer": maskTemplate["mask"],
                              "buffer": maskTemplate["mask"].slice(),
                              "tests": getTestingChain(newMask),
                              "lastValidPosition": -1,
                              "greedy": maskTemplate["greedy"],
                              "repeat": maskTemplate["repeat"],
                              "metadata": metadata
                          });
                      }
                      if (splitFirstOptionalStartPart(masks[1]).length > 1) { //optional contains another optional
                          generateMask(maskPrefix + masks[0], masks[1] + maskParts[1], metadata);
                      }
                      if (maskParts.length > 1 && splitFirstOptionalStartPart(maskParts[1]).length > 1) {
                          generateMask(maskPrefix + masks[0] + markOptional(masks[1]), maskParts[1], metadata);
                          generateMask(maskPrefix + masks[0], maskParts[1], metadata);
                      }
                  }
                  else {
                      newMask = maskPrefix + maskParts;
                      if ($.inArray(newMask, genmasks) == -1 && newMask != "") {
                          genmasks.push(newMask);
                          maskTemplate = getMaskTemplate(newMask);
                          ms.push({
                              "mask": newMask,
                              "_buffer": maskTemplate["mask"],
                              "buffer": maskTemplate["mask"].slice(),
                              "tests": getTestingChain(newMask),
                              "lastValidPosition": -1,
                              "greedy": maskTemplate["greedy"],
                              "repeat": maskTemplate["repeat"],
                              "metadata": metadata
                          });
                      }
                  }
  
              }
  
              if ($.isFunction(opts.mask)) { //allow mask to be a preprocessing fn - should return a valid mask
                  opts.mask = opts.mask.call(this, opts);
              }
              if ($.isArray(opts.mask)) {
                  $.each(opts.mask, function (ndx, msk) {
                      if (msk["mask"] != undefined) {
                          generateMask("", msk["mask"].toString(), msk);
                      } else
                          generateMask("", msk.toString());
                  });
              } else generateMask("", opts.mask.toString());
  
              return opts.greedy ? ms : ms.sort(function (a, b) { return a["mask"].length - b["mask"].length; });
          }
  
          var msie10 = navigator.userAgent.match(new RegExp("msie 10", "i")) !== null,
              iphone = navigator.userAgent.match(new RegExp("iphone", "i")) !== null,
              android = navigator.userAgent.match(new RegExp("android.*safari.*", "i")) !== null,
              androidchrome = navigator.userAgent.match(new RegExp("android.*chrome.*", "i")) !== null,
              pasteEvent = isInputEventSupported('paste') ? 'paste' : isInputEventSupported('input') ? 'input' : "propertychange";
  
  
          //masking scope
          //actionObj definition see below
          function maskScope(masksets, activeMasksetIndex, opts, actionObj) {
              var isRTL = false,
                  valueOnFocus = getActiveBuffer().join(''),
                  $el, chromeValueOnInput,
                  skipKeyPressEvent = false, //Safari 5.1.x - modal dialog fires keypress twice workaround
                  skipInputEvent = false, //skip when triggered from within inputmask
                  ignorable = false;
  
  
              //maskset helperfunctions
  
              function getActiveMaskSet() {
                  return masksets[activeMasksetIndex];
              }
  
              function getActiveTests() {
                  return getActiveMaskSet()['tests'];
              }
  
              function getActiveBufferTemplate() {
                  return getActiveMaskSet()['_buffer'];
              }
  
              function getActiveBuffer() {
                  return getActiveMaskSet()['buffer'];
              }
  
              function isValid(pos, c, strict) { //strict true ~ no correction or autofill
                  strict = strict === true; //always set a value to strict to prevent possible strange behavior in the extensions 
  
                  function _isValid(position, activeMaskset, c, strict) {
                      var testPos = determineTestPosition(position), loopend = c ? 1 : 0, chrs = '', buffer = activeMaskset["buffer"];
                      for (var i = activeMaskset['tests'][testPos].cardinality; i > loopend; i--) {
                          chrs += getBufferElement(buffer, testPos - (i - 1));
                      }
  
                      if (c) {
                          chrs += c;
                      }
  
                      //return is false or a json object => { pos: ??, c: ??} or true
                      return activeMaskset['tests'][testPos].fn != null ?
                          activeMaskset['tests'][testPos].fn.test(chrs, buffer, position, strict, opts)
                          : (c == getBufferElement(activeMaskset['_buffer'], position, true) || c == opts.skipOptionalPartCharacter) ?
                              { "refresh": true, c: getBufferElement(activeMaskset['_buffer'], position, true), pos: position }
                              : false;
                  }
  
                  function PostProcessResults(maskForwards, results) {
                      var hasValidActual = false;
                      $.each(results, function (ndx, rslt) {
                          hasValidActual = $.inArray(rslt["activeMasksetIndex"], maskForwards) == -1 && rslt["result"] !== false;
                          if (hasValidActual) return false;
                      });
                      if (hasValidActual) { //strip maskforwards
                          results = $.map(results, function (rslt, ndx) {
                              if ($.inArray(rslt["activeMasksetIndex"], maskForwards) == -1) {
                                  return rslt;
                              } else {
                                  masksets[rslt["activeMasksetIndex"]]["lastValidPosition"] = actualLVP;
                              }
                          });
                      } else { //keep maskforwards with the least forward
                          var lowestPos = -1, lowestIndex = -1, rsltValid;
                          $.each(results, function (ndx, rslt) {
                              if ($.inArray(rslt["activeMasksetIndex"], maskForwards) != -1 && rslt["result"] !== false & (lowestPos == -1 || lowestPos > rslt["result"]["pos"])) {
                                  lowestPos = rslt["result"]["pos"];
                                  lowestIndex = rslt["activeMasksetIndex"];
                              }
                          });
                          results = $.map(results, function (rslt, ndx) {
                              if ($.inArray(rslt["activeMasksetIndex"], maskForwards) != -1) {
                                  if (rslt["result"]["pos"] == lowestPos) {
                                      return rslt;
                                  } else if (rslt["result"] !== false) {
                                      for (var i = pos; i < lowestPos; i++) {
                                          rsltValid = _isValid(i, masksets[rslt["activeMasksetIndex"]], masksets[lowestIndex]["buffer"][i], true);
                                          if (rsltValid === false) {
                                              masksets[rslt["activeMasksetIndex"]]["lastValidPosition"] = lowestPos - 1;
                                              break;
                                          } else {
                                              setBufferElement(masksets[rslt["activeMasksetIndex"]]["buffer"], i, masksets[lowestIndex]["buffer"][i], true);
                                              masksets[rslt["activeMasksetIndex"]]["lastValidPosition"] = i;
                                          }
                                      }
                                      //also check check for the lowestpos with the new input
                                      rsltValid = _isValid(lowestPos, masksets[rslt["activeMasksetIndex"]], c, true);
                                      if (rsltValid !== false) {
                                          setBufferElement(masksets[rslt["activeMasksetIndex"]]["buffer"], lowestPos, c, true);
                                          masksets[rslt["activeMasksetIndex"]]["lastValidPosition"] = lowestPos;
                                      }
                                      //console.log("ndx " + rslt["activeMasksetIndex"] + " validate " + masksets[rslt["activeMasksetIndex"]]["buffer"].join('') + " lv " + masksets[rslt["activeMasksetIndex"]]['lastValidPosition']);
                                      return rslt;
                                  }
                              }
                          });
                      }
                      return results;
                  }
  
                  if (strict) {
                      var result = _isValid(pos, getActiveMaskSet(), c, strict); //only check validity in current mask when validating strict
                      if (result === true) {
                          result = { "pos": pos }; //always take a possible corrected maskposition into account
                      }
                      return result;
                  }
  
                  var results = [], result = false, currentActiveMasksetIndex = activeMasksetIndex,
                      actualBuffer = getActiveBuffer().slice(), actualLVP = getActiveMaskSet()["lastValidPosition"],
                      actualPrevious = seekPrevious(pos),
                      maskForwards = [];
                  $.each(masksets, function (index, value) {
                      if (typeof (value) == "object") {
                          activeMasksetIndex = index;
  
                          var maskPos = pos;
                          var lvp = getActiveMaskSet()['lastValidPosition'],
                              rsltValid;
                          if (lvp == actualLVP) {
                              if ((maskPos - actualLVP) > 1) {
                                  for (var i = lvp == -1 ? 0 : lvp; i < maskPos; i++) {
                                      rsltValid = _isValid(i, getActiveMaskSet(), actualBuffer[i], true);
                                      if (rsltValid === false) {
                                          break;
                                      } else {
                                          setBufferElement(getActiveBuffer(), i, actualBuffer[i], true);
                                          if (rsltValid === true) {
                                              rsltValid = { "pos": i }; //always take a possible corrected maskposition into account
                                          }
                                          var newValidPosition = rsltValid.pos || i;
                                          if (getActiveMaskSet()['lastValidPosition'] < newValidPosition)
                                              getActiveMaskSet()['lastValidPosition'] = newValidPosition; //set new position from isValid
                                      }
                                  }
                              }
                              //does the input match on a further position?
                              if (!isMask(maskPos) && !_isValid(maskPos, getActiveMaskSet(), c, strict)) {
                                  var maxForward = seekNext(maskPos) - maskPos;
                                  for (var fw = 0; fw < maxForward; fw++) {
                                      if (_isValid(++maskPos, getActiveMaskSet(), c, strict) !== false)
                                          break;
                                  }
                                  maskForwards.push(activeMasksetIndex);
                                  //console.log('maskforward ' + activeMasksetIndex + " pos " + pos + " maskPos " + maskPos);
                              }
                          }
  
                          if (getActiveMaskSet()['lastValidPosition'] >= actualLVP || activeMasksetIndex == currentActiveMasksetIndex) {
                              if (maskPos >= 0 && maskPos < getMaskLength()) {
                                  result = _isValid(maskPos, getActiveMaskSet(), c, strict);
                                  if (result !== false) {
                                      if (result === true) {
                                          result = { "pos": maskPos }; //always take a possible corrected maskposition into account
                                      }
                                      var newValidPosition = result.pos || maskPos;
                                      if (getActiveMaskSet()['lastValidPosition'] < newValidPosition)
                                          getActiveMaskSet()['lastValidPosition'] = newValidPosition; //set new position from isValid
                                  }
                                  //console.log("pos " + pos + " ndx " + activeMasksetIndex + " validate " + getActiveBuffer().join('') + " lv " + getActiveMaskSet()['lastValidPosition']);
                                  results.push({ "activeMasksetIndex": index, "result": result });
                              }
                          }
                      }
                  });
                  activeMasksetIndex = currentActiveMasksetIndex; //reset activeMasksetIndex
  
                  return PostProcessResults(maskForwards, results); //return results of the multiple mask validations
              }
  
              function determineActiveMasksetIndex() {
                  var currentMasksetIndex = activeMasksetIndex,
                      highestValid = { "activeMasksetIndex": 0, "lastValidPosition": -1, "next": -1 };
                  $.each(masksets, function (index, value) {
                      if (typeof (value) == "object") {
                          activeMasksetIndex = index;
                          if (getActiveMaskSet()['lastValidPosition'] > highestValid['lastValidPosition']) {
                              highestValid["activeMasksetIndex"] = index;
                              highestValid["lastValidPosition"] = getActiveMaskSet()['lastValidPosition'];
                              highestValid["next"] = seekNext(getActiveMaskSet()['lastValidPosition']);
                          } else if (getActiveMaskSet()['lastValidPosition'] == highestValid['lastValidPosition'] &&
                              (highestValid['next'] == -1 || highestValid['next'] > seekNext(getActiveMaskSet()['lastValidPosition']))) {
                              highestValid["activeMasksetIndex"] = index;
                              highestValid["lastValidPosition"] = getActiveMaskSet()['lastValidPosition'];
                              highestValid["next"] = seekNext(getActiveMaskSet()['lastValidPosition']);
                          }
                      }
                  });
  
                  activeMasksetIndex = highestValid["lastValidPosition"] != -1 && masksets[currentMasksetIndex]["lastValidPosition"] == highestValid["lastValidPosition"] ? currentMasksetIndex : highestValid["activeMasksetIndex"];
                  if (currentMasksetIndex != activeMasksetIndex) {
                      clearBuffer(getActiveBuffer(), seekNext(highestValid["lastValidPosition"]), getMaskLength());
                      getActiveMaskSet()["writeOutBuffer"] = true;
                  }
                  $el.data('_inputmask')['activeMasksetIndex'] = activeMasksetIndex; //store the activeMasksetIndex
              }
  
              function isMask(pos) {
                  var testPos = determineTestPosition(pos);
                  var test = getActiveTests()[testPos];
  
                  return test != undefined ? test.fn : false;
              }
  
              function determineTestPosition(pos) {
                  return pos % getActiveTests().length;
              }
  
              function getMaskLength() {
                  return opts.getMaskLength(getActiveBufferTemplate(), getActiveMaskSet()['greedy'], getActiveMaskSet()['repeat'], getActiveBuffer(), opts);
              }
  
              //pos: from position
  
              function seekNext(pos) {
                  var maskL = getMaskLength();
                  if (pos >= maskL) return maskL;
                  var position = pos;
                  while (++position < maskL && !isMask(position)) {
                  }
                  return position;
              }
  
              //pos: from position
  
              function seekPrevious(pos) {
                  var position = pos;
                  if (position <= 0) return 0;
  
                  while (--position > 0 && !isMask(position)) {
                  }
                  return position;
              }
  
              function setBufferElement(buffer, position, element, autoPrepare) {
                  if (autoPrepare) position = prepareBuffer(buffer, position);
  
                  var test = getActiveTests()[determineTestPosition(position)];
                  var elem = element;
                  if (elem != undefined && test != undefined) {
                      switch (test.casing) {
                          case "upper":
                              elem = element.toUpperCase();
                              break;
                          case "lower":
                              elem = element.toLowerCase();
                              break;
                      }
                  }
  
                  buffer[position] = elem;
              }
  
              function getBufferElement(buffer, position, autoPrepare) {
                  if (autoPrepare) position = prepareBuffer(buffer, position);
                  return buffer[position];
              }
  
              //needed to handle the non-greedy mask repetitions
  
              function prepareBuffer(buffer, position) {
                  var j;
                  while (buffer[position] == undefined && buffer.length < getMaskLength()) {
                      j = 0;
                      while (getActiveBufferTemplate()[j] !== undefined) { //add a new buffer
                          buffer.push(getActiveBufferTemplate()[j++]);
                      }
                  }
  
                  return position;
              }
  
              function writeBuffer(input, buffer, caretPos) {
                  input._valueSet(buffer.join(''));
                  if (caretPos != undefined) {
                      caret(input, caretPos);
                  }
              }
  
              function clearBuffer(buffer, start, end, stripNomasks) {
                  for (var i = start, maskL = getMaskLength() ; i < end && i < maskL; i++) {
                      if (stripNomasks === true) {
                          if (!isMask(i))
                              setBufferElement(buffer, i, "");
                      } else
                          setBufferElement(buffer, i, getBufferElement(getActiveBufferTemplate().slice(), i, true));
                  }
              }
  
              function setReTargetPlaceHolder(buffer, pos) {
                  var testPos = determineTestPosition(pos);
                  setBufferElement(buffer, pos, getBufferElement(getActiveBufferTemplate(), testPos));
              }
  
              function getPlaceHolder(pos) {
                  return opts.placeholder.charAt(pos % opts.placeholder.length);
              }
  
              function checkVal(input, writeOut, strict, nptvl, intelliCheck) {
                  var inputValue = nptvl != undefined ? nptvl.slice() : truncateInput(input._valueGet()).split('');
  
                  $.each(masksets, function (ndx, ms) {
                      if (typeof (ms) == "object") {
                          ms["buffer"] = ms["_buffer"].slice();
                          ms["lastValidPosition"] = -1;
                          ms["p"] = -1;
                      }
                  });
                  if (strict !== true) activeMasksetIndex = 0;
                  if (writeOut) input._valueSet(""); //initial clear
                  var ml = getMaskLength();
                  $.each(inputValue, function (ndx, charCode) {
                      if (intelliCheck === true) {
                          var p = getActiveMaskSet()["p"], lvp = p == -1 ? p : seekPrevious(p),
                              pos = lvp == -1 ? ndx : seekNext(lvp);
                          if ($.inArray(charCode, getActiveBufferTemplate().slice(lvp + 1, pos)) == -1) {
                              keypressEvent.call(input, undefined, true, charCode.charCodeAt(0), writeOut, strict, ndx);
                          }
                      } else {
                          keypressEvent.call(input, undefined, true, charCode.charCodeAt(0), writeOut, strict, ndx);
                      }
                  });
  
                  if (strict === true && getActiveMaskSet()["p"] != -1) {
                      getActiveMaskSet()["lastValidPosition"] = seekPrevious(getActiveMaskSet()["p"]);
                  }
              }
  
              function escapeRegex(str) {
                  return $.inputmask.escapeRegex.call(this, str);
              }
  
              function truncateInput(inputValue) {
                  return inputValue.replace(new RegExp("(" + escapeRegex(getActiveBufferTemplate().join('')) + ")*$"), "");
              }
  
              function clearOptionalTail(input) {
                  var buffer = getActiveBuffer(), tmpBuffer = buffer.slice(), testPos, pos;
                  for (var pos = tmpBuffer.length - 1; pos >= 0; pos--) {
                      var testPos = determineTestPosition(pos);
                      if (getActiveTests()[testPos].optionality) {
                          if (!isMask(pos) || !isValid(pos, buffer[pos], true))
                              tmpBuffer.pop();
                          else break;
                      } else break;
                  }
                  writeBuffer(input, tmpBuffer);
              }
  
              function unmaskedvalue($input, skipDatepickerCheck) {
                  if (getActiveTests() && (skipDatepickerCheck === true || !$input.hasClass('hasDatepicker'))) {
                      //checkVal(input, false, true);
                      var umValue = $.map(getActiveBuffer(), function (element, index) {
                          return isMask(index) && isValid(index, element, true) ? element : null;
                      });
                      var unmaskedValue = (isRTL ? umValue.reverse() : umValue).join('');
                      return opts.onUnMask != undefined ? opts.onUnMask.call(this, getActiveBuffer().join(''), unmaskedValue) : unmaskedValue;
                  } else {
                      return $input[0]._valueGet();
                  }
              }
  
              function TranslatePosition(pos) {
                  if (isRTL && typeof pos == 'number' && (!opts.greedy || opts.placeholder != "")) {
                      var bffrLght = getActiveBuffer().length;
                      pos = bffrLght - pos;
                  }
                  return pos;
              }
  
              function caret(input, begin, end) {
                  var npt = input.jquery && input.length > 0 ? input[0] : input, range;
                  if (typeof begin == 'number') {
                      begin = TranslatePosition(begin);
                      end = TranslatePosition(end);
                      if (!$(input).is(':visible')) {
                          return;
                      }
                      end = (typeof end == 'number') ? end : begin;
                      npt.scrollLeft = npt.scrollWidth;
                      if (opts.insertMode == false && begin == end) end++; //set visualization for insert/overwrite mode
                      if (npt.setSelectionRange) {
                          npt.selectionStart = begin;
                          npt.selectionEnd = android ? begin : end;
  
                      } else if (npt.createTextRange) {
                          range = npt.createTextRange();
                          range.collapse(true);
                          range.moveEnd('character', end);
                          range.moveStart('character', begin);
                          range.select();
                      }
                  } else {
                      if (!$(input).is(':visible')) {
                          return { "begin": 0, "end": 0 };
                      }
                      if (npt.setSelectionRange) {
                          begin = npt.selectionStart;
                          end = npt.selectionEnd;
                      } else if (document.selection && document.selection.createRange) {
                          range = document.selection.createRange();
                          begin = 0 - range.duplicate().moveStart('character', -100000);
                          end = begin + range.text.length;
                      }
                      begin = TranslatePosition(begin);
                      end = TranslatePosition(end);
                      return { "begin": begin, "end": end };
                  }
              }
  
              function isComplete(buffer) { //return true / false / undefined (repeat *)
                  if (opts.repeat == "*") return undefined;
                  var complete = false, highestValidPosition = 0, currentActiveMasksetIndex = activeMasksetIndex;
                  $.each(masksets, function (ndx, ms) {
                      if (typeof (ms) == "object") {
                          activeMasksetIndex = ndx;
                          var aml = seekPrevious(getMaskLength());
                          if (ms["lastValidPosition"] >= highestValidPosition && ms["lastValidPosition"] == aml) {
                              var msComplete = true;
                              for (var i = 0; i <= aml; i++) {
                                  var mask = isMask(i), testPos = determineTestPosition(i);
                                  if ((mask && (buffer[i] == undefined || buffer[i] == getPlaceHolder(i))) || (!mask && buffer[i] != getActiveBufferTemplate()[testPos])) {
                                      msComplete = false;
                                      break;
                                  }
                              }
                              complete = complete || msComplete;
                              if (complete) //break loop
                                  return false;
                          }
                          highestValidPosition = ms["lastValidPosition"];
                      }
                  });
                  activeMasksetIndex = currentActiveMasksetIndex; //reset activeMaskset
                  return complete;
              }
  
              function isSelection(begin, end) {
                  return isRTL ? (begin - end) > 1 || ((begin - end) == 1 && opts.insertMode) :
                      (end - begin) > 1 || ((end - begin) == 1 && opts.insertMode);
              }
  
  
              //private functions
              function installEventRuler(npt) {
                  var events = $._data(npt).events;
  
                  $.each(events, function (eventType, eventHandlers) {
                      $.each(eventHandlers, function (ndx, eventHandler) {
                          if (eventHandler.namespace == "inputmask") {
                              if (eventHandler.type != "setvalue") {
                                  var handler = eventHandler.handler;
                                  eventHandler.handler = function (e) {
                                      if (this.readOnly || this.disabled)
                                          e.preventDefault;
                                      else
                                          return handler.apply(this, arguments);
                                  };
                              }
                          }
                      });
                  });
              }
  
              function patchValueProperty(npt) {
                  var valueProperty;
                  if (Object.getOwnPropertyDescriptor)
                      valueProperty = Object.getOwnPropertyDescriptor(npt, "value");
                  if (valueProperty && valueProperty.get) {
                      if (!npt._valueGet) {
                          var valueGet = valueProperty.get;
                          var valueSet = valueProperty.set;
                          npt._valueGet = function () {
                              return isRTL ? valueGet.call(this).split('').reverse().join('') : valueGet.call(this);
                          };
                          npt._valueSet = function (value) {
                              valueSet.call(this, isRTL ? value.split('').reverse().join('') : value);
                          };
  
                          Object.defineProperty(npt, "value", {
                              get: function () {
                                  var $self = $(this), inputData = $(this).data('_inputmask'), masksets = inputData['masksets'],
                                      activeMasksetIndex = inputData['activeMasksetIndex'];
                                  return inputData && inputData['opts'].autoUnmask ? $self.inputmask('unmaskedvalue') : valueGet.call(this) != masksets[activeMasksetIndex]['_buffer'].join('') ? valueGet.call(this) : '';
                              },
                              set: function (value) {
                                  valueSet.call(this, value);
                                  $(this).triggerHandler('setvalue.inputmask');
                              }
                          });
                      }
                  } else if (document.__lookupGetter__ && npt.__lookupGetter__("value")) {
                      if (!npt._valueGet) {
                          var valueGet = npt.__lookupGetter__("value");
                          var valueSet = npt.__lookupSetter__("value");
                          npt._valueGet = function () {
                              return isRTL ? valueGet.call(this).split('').reverse().join('') : valueGet.call(this);
                          };
                          npt._valueSet = function (value) {
                              valueSet.call(this, isRTL ? value.split('').reverse().join('') : value);
                          };
  
                          npt.__defineGetter__("value", function () {
                              var $self = $(this), inputData = $(this).data('_inputmask'), masksets = inputData['masksets'],
                                  activeMasksetIndex = inputData['activeMasksetIndex'];
                              return inputData && inputData['opts'].autoUnmask ? $self.inputmask('unmaskedvalue') : valueGet.call(this) != masksets[activeMasksetIndex]['_buffer'].join('') ? valueGet.call(this) : '';
                          });
                          npt.__defineSetter__("value", function (value) {
                              valueSet.call(this, value);
                              $(this).triggerHandler('setvalue.inputmask');
                          });
                      }
                  } else {
                      if (!npt._valueGet) {
                          npt._valueGet = function () { return isRTL ? this.value.split('').reverse().join('') : this.value; };
                          npt._valueSet = function (value) { this.value = isRTL ? value.split('').reverse().join('') : value; };
                      }
                      if ($.valHooks.text == undefined || $.valHooks.text.inputmaskpatch != true) {
                          var valueGet = $.valHooks.text && $.valHooks.text.get ? $.valHooks.text.get : function (elem) { return elem.value; };
                          var valueSet = $.valHooks.text && $.valHooks.text.set ? $.valHooks.text.set : function (elem, value) {
                              elem.value = value;
                              return elem;
                          };
  
                          jQuery.extend($.valHooks, {
                              text: {
                                  get: function (elem) {
                                      var $elem = $(elem);
                                      if ($elem.data('_inputmask')) {
                                          if ($elem.data('_inputmask')['opts'].autoUnmask)
                                              return $elem.inputmask('unmaskedvalue');
                                          else {
                                              var result = valueGet(elem),
                                                  inputData = $elem.data('_inputmask'), masksets = inputData['masksets'],
                                                  activeMasksetIndex = inputData['activeMasksetIndex'];
                                              return result != masksets[activeMasksetIndex]['_buffer'].join('') ? result : '';
                                          }
                                      } else return valueGet(elem);
                                  },
                                  set: function (elem, value) {
                                      var $elem = $(elem);
                                      var result = valueSet(elem, value);
                                      if ($elem.data('_inputmask')) $elem.triggerHandler('setvalue.inputmask');
                                      return result;
                                  },
                                  inputmaskpatch: true
                              }
                          });
                      }
                  }
              }
  
              //shift chars to left from start to end and put c at end position if defined
  
              function shiftL(start, end, c, maskJumps) {
                  var buffer = getActiveBuffer();
                  if (maskJumps !== false) //jumping over nonmask position
                      while (!isMask(start) && start - 1 >= 0) start--;
                  for (var i = start; i < end && i < getMaskLength() ; i++) {
                      if (isMask(i)) {
                          setReTargetPlaceHolder(buffer, i);
                          var j = seekNext(i);
                          var p = getBufferElement(buffer, j);
                          if (p != getPlaceHolder(j)) {
                              if (j < getMaskLength() && isValid(i, p, true) !== false && getActiveTests()[determineTestPosition(i)].def == getActiveTests()[determineTestPosition(j)].def) {
                                  setBufferElement(buffer, i, p, true);
                              } else {
                                  if (isMask(i))
                                      break;
                              }
                          }
                      } else {
                          setReTargetPlaceHolder(buffer, i);
                      }
                  }
                  if (c != undefined)
                      setBufferElement(buffer, seekPrevious(end), c);
  
                  if (getActiveMaskSet()["greedy"] == false) {
                      var trbuffer = truncateInput(buffer.join('')).split('');
                      buffer.length = trbuffer.length;
                      for (var i = 0, bl = buffer.length; i < bl; i++) {
                          buffer[i] = trbuffer[i];
                      }
                      if (buffer.length == 0) getActiveMaskSet()["buffer"] = getActiveBufferTemplate().slice();
                  }
                  return start; //return the used start position
              }
  
              function shiftR(start, end, c) {
                  var buffer = getActiveBuffer();
                  if (getBufferElement(buffer, start, true) != getPlaceHolder(start)) {
                      for (var i = seekPrevious(end) ; i > start && i >= 0; i--) {
                          if (isMask(i)) {
                              var j = seekPrevious(i);
                              var t = getBufferElement(buffer, j);
                              if (t != getPlaceHolder(j)) {
                                  if (isValid(j, t, true) !== false && getActiveTests()[determineTestPosition(i)].def == getActiveTests()[determineTestPosition(j)].def) {
                                      setBufferElement(buffer, i, t, true);
                                      setReTargetPlaceHolder(buffer, j);
                                  } //else break;
                              }
                          } else
                              setReTargetPlaceHolder(buffer, i);
                      }
                  }
                  if (c != undefined && getBufferElement(buffer, start) == getPlaceHolder(start))
                      setBufferElement(buffer, start, c);
                  var lengthBefore = buffer.length;
                  if (getActiveMaskSet()["greedy"] == false) {
                      var trbuffer = truncateInput(buffer.join('')).split('');
                      buffer.length = trbuffer.length;
                      for (var i = 0, bl = buffer.length; i < bl; i++) {
                          buffer[i] = trbuffer[i];
                      }
                      if (buffer.length == 0) getActiveMaskSet()["buffer"] = getActiveBufferTemplate().slice();
                  }
                  return end - (lengthBefore - buffer.length); //return new start position
              }
  
              function HandleRemove(input, k, pos) {
                  if (opts.numericInput || isRTL) {
                      switch (k) {
                          case opts.keyCode.BACKSPACE:
                              k = opts.keyCode.DELETE;
                              break;
                          case opts.keyCode.DELETE:
                              k = opts.keyCode.BACKSPACE;
                              break;
                      }
                      if (isRTL) {
                          var pend = pos.end;
                          pos.end = pos.begin;
                          pos.begin = pend;
                      }
                  }
  
                  var isSelection = true;
                  if (pos.begin == pos.end) {
                      var posBegin = k == opts.keyCode.BACKSPACE ? pos.begin - 1 : pos.begin;
                      if (opts.isNumeric && opts.radixPoint != "" && getActiveBuffer()[posBegin] == opts.radixPoint) {
                          pos.begin = (getActiveBuffer().length - 1 == posBegin) /* radixPoint is latest? delete it */ ? pos.begin : k == opts.keyCode.BACKSPACE ? posBegin : seekNext(posBegin);
                          pos.end = pos.begin;
                      }
                      isSelection = false;
                      if (k == opts.keyCode.BACKSPACE)
                          pos.begin--;
                      else if (k == opts.keyCode.DELETE)
                          pos.end++;
                  } else if (pos.end - pos.begin == 1 && !opts.insertMode) {
                      isSelection = false;
                      if (k == opts.keyCode.BACKSPACE)
                          pos.begin--;
                  }
  
                  clearBuffer(getActiveBuffer(), pos.begin, pos.end);
  
                  var ml = getMaskLength();
                  if (opts.greedy == false) {
                      shiftL(pos.begin, ml, undefined, !isRTL && (k == opts.keyCode.BACKSPACE && !isSelection));
                  } else {
                      var newpos = pos.begin;
                      for (var i = pos.begin; i < pos.end; i++) { //seeknext to skip placeholders at start in selection
                          if (isMask(i) || !isSelection)
                              newpos = shiftL(pos.begin, ml, undefined, !isRTL && (k == opts.keyCode.BACKSPACE && !isSelection));
                      }
                      if (!isSelection) pos.begin = newpos;
                  }
                  var firstMaskPos = seekNext(-1);
                  clearBuffer(getActiveBuffer(), pos.begin, pos.end, true);
                  checkVal(input, false, masksets[1] == undefined || firstMaskPos >= pos.end, getActiveBuffer());
                  if (getActiveMaskSet()['lastValidPosition'] < firstMaskPos) {
                      getActiveMaskSet()["lastValidPosition"] = -1;
                      getActiveMaskSet()["p"] = firstMaskPos;
                  } else {
                      getActiveMaskSet()["p"] = pos.begin;
                  }
              }
  
              function keydownEvent(e) {
                  //Safari 5.1.x - modal dialog fires keypress twice workaround
                  skipKeyPressEvent = false;
                  var input = this, $input = $(input), k = e.keyCode, pos = caret(input);
  
                  //backspace, delete, and escape get special treatment
                  if (k == opts.keyCode.BACKSPACE || k == opts.keyCode.DELETE || (iphone && k == 127) || e.ctrlKey && k == 88) { //backspace/delete
                      e.preventDefault(); //stop default action but allow propagation
                      if (k == 88) valueOnFocus = getActiveBuffer().join('');
                      HandleRemove(input, k, pos);
                      determineActiveMasksetIndex();
                      writeBuffer(input, getActiveBuffer(), getActiveMaskSet()["p"]);
                      if (input._valueGet() == getActiveBufferTemplate().join(''))
                          $input.trigger('cleared');
  
                      if (opts.showTooltip) { //update tooltip
                          $input.prop("title", getActiveMaskSet()["mask"]);
                      }
                  } else if (k == opts.keyCode.END || k == opts.keyCode.PAGE_DOWN) { //when END or PAGE_DOWN pressed set position at lastmatch
                      setTimeout(function () {
                          var caretPos = seekNext(getActiveMaskSet()["lastValidPosition"]);
                          if (!opts.insertMode && caretPos == getMaskLength() && !e.shiftKey) caretPos--;
                          caret(input, e.shiftKey ? pos.begin : caretPos, caretPos);
                      }, 0);
                  } else if ((k == opts.keyCode.HOME && !e.shiftKey) || k == opts.keyCode.PAGE_UP) { //Home or page_up
                      caret(input, 0, e.shiftKey ? pos.begin : 0);
                  } else if (k == opts.keyCode.ESCAPE || (k == 90 && e.ctrlKey)) { //escape && undo
                      checkVal(input, true, false, valueOnFocus.split(''));
                      $input.click();
                  } else if (k == opts.keyCode.INSERT && !(e.shiftKey || e.ctrlKey)) { //insert
                      opts.insertMode = !opts.insertMode;
                      caret(input, !opts.insertMode && pos.begin == getMaskLength() ? pos.begin - 1 : pos.begin);
                  } else if (opts.insertMode == false && !e.shiftKey) {
                      if (k == opts.keyCode.RIGHT) {
                          setTimeout(function () {
                              var caretPos = caret(input);
                              caret(input, caretPos.begin);
                          }, 0);
                      } else if (k == opts.keyCode.LEFT) {
                          setTimeout(function () {
                              var caretPos = caret(input);
                              caret(input, caretPos.begin - 1);
                          }, 0);
                      }
                  }
  
                  var currentCaretPos = caret(input);
                  if (opts.onKeyDown.call(this, e, getActiveBuffer(), opts) === true) //extra stuff to execute on keydown
                      caret(input, currentCaretPos.begin, currentCaretPos.end);
                  ignorable = $.inArray(k, opts.ignorables) != -1;
              }
  
  
              function keypressEvent(e, checkval, k, writeOut, strict, ndx) {
                  //Safari 5.1.x - modal dialog fires keypress twice workaround
                  if (k == undefined && skipKeyPressEvent) return false;
                  skipKeyPressEvent = true;
  
                  var input = this, $input = $(input);
  
                  e = e || window.event;
                  var k = checkval ? k : (e.which || e.charCode || e.keyCode);
  
                  if (checkval !== true && (!(e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || ignorable))) {
                      return true;
                  } else {
                      if (k) {
                          //special treat the decimal separator
                          if (checkval !== true && k == 46 && e.shiftKey == false && opts.radixPoint == ",") k = 44;
  
                          var pos, results, result, c = String.fromCharCode(k);
                          if (checkval) {
                              var pcaret = strict ? ndx : getActiveMaskSet()["lastValidPosition"] + 1;
                              pos = { begin: pcaret, end: pcaret };
                          } else {
                              pos = caret(input);
                          }
  
                          //should we clear a possible selection??
                          var isSlctn = isSelection(pos.begin, pos.end), redetermineLVP = false,
                              initialIndex = activeMasksetIndex;
                          if (isSlctn) {
                              activeMasksetIndex = initialIndex;
                              $.each(masksets, function (ndx, lmnt) { //init undobuffer for recovery when not valid
                                  if (typeof (lmnt) == "object") {
                                      activeMasksetIndex = ndx;
                                      getActiveMaskSet()["undoBuffer"] = getActiveBuffer().join('');
                                  }
                              });
                              HandleRemove(input, opts.keyCode.DELETE, pos);
                              if (!opts.insertMode) { //preserve some space
                                  $.each(masksets, function (ndx, lmnt) {
                                      if (typeof (lmnt) == "object") {
                                          activeMasksetIndex = ndx;
                                          shiftR(pos.begin, getMaskLength());
                                          getActiveMaskSet()["lastValidPosition"] = seekNext(getActiveMaskSet()["lastValidPosition"]);
                                      }
                                  });
                              }
                              activeMasksetIndex = initialIndex; //restore index
                          }
  
                          var radixPosition = getActiveBuffer().join('').indexOf(opts.radixPoint);
                          if (opts.isNumeric && checkval !== true && radixPosition != -1) {
                              if (opts.greedy && pos.begin <= radixPosition) {
                                  pos.begin = seekPrevious(pos.begin);
                                  pos.end = pos.begin;
                              } else if (c == opts.radixPoint) {
                                  pos.begin = radixPosition;
                                  pos.end = pos.begin;
                              }
                          }
  
  
                          var p = pos.begin;
                          results = isValid(p, c, strict);
                          if (strict === true) results = [{ "activeMasksetIndex": activeMasksetIndex, "result": results }];
                          var minimalForwardPosition = -1;
                          $.each(results, function (index, result) {
                              activeMasksetIndex = result["activeMasksetIndex"];
                              getActiveMaskSet()["writeOutBuffer"] = true;
                              var np = result["result"];
                              if (np !== false) {
                                  var refresh = false, buffer = getActiveBuffer();
                                  if (np !== true) {
                                      refresh = np["refresh"]; //only rewrite buffer from isValid
                                      p = np.pos != undefined ? np.pos : p; //set new position from isValid
                                      c = np.c != undefined ? np.c : c; //set new char from isValid
                                  }
                                  if (refresh !== true) {
                                      if (opts.insertMode == true) {
                                          var lastUnmaskedPosition = getMaskLength();
                                          var bfrClone = buffer.slice();
                                          while (getBufferElement(bfrClone, lastUnmaskedPosition, true) != getPlaceHolder(lastUnmaskedPosition) && lastUnmaskedPosition >= p) {
                                              lastUnmaskedPosition = lastUnmaskedPosition == 0 ? -1 : seekPrevious(lastUnmaskedPosition);
                                          }
                                          if (lastUnmaskedPosition >= p) {
                                              shiftR(p, getMaskLength(), c);
                                              //shift the lvp if needed
                                              var lvp = getActiveMaskSet()["lastValidPosition"], nlvp = seekNext(lvp);
                                              if (nlvp != getMaskLength() && lvp >= p && (getBufferElement(getActiveBuffer(), nlvp, true) != getPlaceHolder(nlvp))) {
                                                  getActiveMaskSet()["lastValidPosition"] = nlvp;
                                              }
                                          } else getActiveMaskSet()["writeOutBuffer"] = false;
                                      } else setBufferElement(buffer, p, c, true);
                                      if (minimalForwardPosition == -1 || minimalForwardPosition > seekNext(p)) {
                                          minimalForwardPosition = seekNext(p);
                                      }
                                  } else if (!strict) {
                                      var nextPos = p < getMaskLength() ? p + 1 : p;
                                      if (minimalForwardPosition == -1 || minimalForwardPosition > nextPos) {
                                          minimalForwardPosition = nextPos;
                                      }
                                  }
                                  if (minimalForwardPosition > getActiveMaskSet()["p"])
                                      getActiveMaskSet()["p"] = minimalForwardPosition; //needed for checkval strict 
                              }
                          });
  
                          if (strict !== true) {
                              activeMasksetIndex = initialIndex;
                              determineActiveMasksetIndex();
                          }
                          if (writeOut !== false) {
                              $.each(results, function (ndx, rslt) {
                                  if (rslt["activeMasksetIndex"] == activeMasksetIndex) {
                                      result = rslt;
                                      return false;
                                  }
                              });
                              if (result != undefined) {
                                  var self = this;
                                  setTimeout(function () { opts.onKeyValidation.call(self, result["result"], opts); }, 0);
                                  if (getActiveMaskSet()["writeOutBuffer"] && result["result"] !== false) {
                                      var buffer = getActiveBuffer();
  
                                      var newCaretPosition;
                                      if (checkval) {
                                          newCaretPosition = undefined;
                                      } else if (opts.numericInput) {
                                          if (p > radixPosition) {
                                              newCaretPosition = seekPrevious(minimalForwardPosition);
                                          } else if (c == opts.radixPoint) {
                                              newCaretPosition = minimalForwardPosition - 1;
                                          } else newCaretPosition = seekPrevious(minimalForwardPosition - 1);
                                      } else {
                                          newCaretPosition = minimalForwardPosition;
                                      }
  
                                      writeBuffer(input, buffer, newCaretPosition);
                                      if (checkval !== true) {
                                          setTimeout(function () { //timeout needed for IE
                                              if (isComplete(buffer) === true)
                                                  $input.trigger("complete");
                                              skipInputEvent = true;
                                              $input.trigger("input");
                                          }, 0);
                                      }
                                  } else if (isSlctn) {
                                      getActiveMaskSet()["buffer"] = getActiveMaskSet()["undoBuffer"].split('');
                                  }
                              }
                          }
  
                          if (opts.showTooltip) { //update tooltip
                              $input.prop("title", getActiveMaskSet()["mask"]);
                          }
  
                          //needed for IE8 and below
                          if (e) e.preventDefault ? e.preventDefault() : e.returnValue = false;
                      }
                  }
              }
  
              function keyupEvent(e) {
                  var $input = $(this), input = this, k = e.keyCode, buffer = getActiveBuffer();
  
                  if (androidchrome && k == opts.keyCode.BACKSPACE) {
                      if (chromeValueOnInput == input._valueGet())
                          keydownEvent.call(this, e);
                  }
  
                  opts.onKeyUp.call(this, e, buffer, opts); //extra stuff to execute on keyup
                  if (k == opts.keyCode.TAB && opts.showMaskOnFocus) {
                      if ($input.hasClass('focus.inputmask') && input._valueGet().length == 0) {
                          buffer = getActiveBufferTemplate().slice();
                          writeBuffer(input, buffer);
                          caret(input, 0);
                          valueOnFocus = getActiveBuffer().join('');
                      } else {
                          writeBuffer(input, buffer);
                          if (buffer.join('') == getActiveBufferTemplate().join('') && $.inArray(opts.radixPoint, buffer) != -1) {
                              caret(input, TranslatePosition(0));
                              $input.click();
                          } else
                              caret(input, TranslatePosition(0), TranslatePosition(getMaskLength()));
                      }
                  }
              }
  
              function inputEvent(e) {
                  if (skipInputEvent === true) {
                      skipInputEvent = false;
                      return true;
                  }
                  var input = this, $input = $(input);
  
                  chromeValueOnInput = getActiveBuffer().join('');
                  checkVal(input, false, false);
                  writeBuffer(input, getActiveBuffer());
                  if (isComplete(getActiveBuffer()) === true)
                      $input.trigger("complete");
                  $input.click();
              }
  
              function mask(el) {
                  $el = $(el);
                  if ($el.is(":input")) {
                      //store tests & original buffer in the input element - used to get the unmasked value
                      $el.data('_inputmask', {
                          'masksets': masksets,
                          'activeMasksetIndex': activeMasksetIndex,
                          'opts': opts,
                          'isRTL': false
                      });
  
                      //show tooltip
                      if (opts.showTooltip) {
                          $el.prop("title", getActiveMaskSet()["mask"]);
                      }
  
                      //correct greedy setting if needed
                      getActiveMaskSet()['greedy'] = getActiveMaskSet()['greedy'] ? getActiveMaskSet()['greedy'] : getActiveMaskSet()['repeat'] == 0;
  
                      //handle maxlength attribute
                      if ($el.attr("maxLength") != null) //only when the attribute is set
                      {
                          var maxLength = $el.prop('maxLength');
                          if (maxLength > -1) { //handle *-repeat
                              $.each(masksets, function (ndx, ms) {
                                  if (typeof (ms) == "object") {
                                      if (ms["repeat"] == "*") {
                                          ms["repeat"] = maxLength;
                                      }
                                  }
                              });
                          }
                          if (getMaskLength() >= maxLength && maxLength > -1) { //FF sets no defined max length to -1 
                              if (maxLength < getActiveBufferTemplate().length) getActiveBufferTemplate().length = maxLength;
                              if (getActiveMaskSet()['greedy'] == false) {
                                  getActiveMaskSet()['repeat'] = Math.round(maxLength / getActiveBufferTemplate().length);
                              }
                              $el.prop('maxLength', getMaskLength() * 2);
                          }
                      }
  
                      patchValueProperty(el);
  
                      if (opts.numericInput) opts.isNumeric = opts.numericInput;
                      if (el.dir == "rtl" || (opts.numericInput && opts.rightAlignNumerics) || (opts.isNumeric && opts.rightAlignNumerics))
                          $el.css("text-align", "right");
  
                      if (el.dir == "rtl" || opts.numericInput) {
                          el.dir = "ltr";
                          $el.removeAttr("dir");
                          var inputData = $el.data('_inputmask');
                          inputData['isRTL'] = true;
                          $el.data('_inputmask', inputData);
                          isRTL = true;
                      }
  
                      //unbind all events - to make sure that no other mask will interfere when re-masking
                      $el.unbind(".inputmask");
                      $el.removeClass('focus.inputmask');
                      //bind events
                      $el.closest('form').bind("submit", function () { //trigger change on submit if any
                          if (valueOnFocus != getActiveBuffer().join('')) {
                              $el.change();
                          }
                      }).bind('reset', function () {
                          setTimeout(function () {
                              $el.trigger("setvalue");
                          }, 0);
                      });
                      $el.bind("mouseenter.inputmask", function () {
                          var $input = $(this), input = this;
                          if (!$input.hasClass('focus.inputmask') && opts.showMaskOnHover) {
                              if (input._valueGet() != getActiveBuffer().join('')) {
                                  writeBuffer(input, getActiveBuffer());
                              }
                          }
                      }).bind("blur.inputmask", function () {
                          var $input = $(this), input = this, nptValue = input._valueGet(), buffer = getActiveBuffer();
                          $input.removeClass('focus.inputmask');
                          if (valueOnFocus != getActiveBuffer().join('')) {
                              $input.change();
                          }
                          if (opts.clearMaskOnLostFocus && nptValue != '') {
                              if (nptValue == getActiveBufferTemplate().join(''))
                                  input._valueSet('');
                              else { //clearout optional tail of the mask
                                  clearOptionalTail(input);
                              }
                          }
                          if (isComplete(buffer) === false) {
                              $input.trigger("incomplete");
                              if (opts.clearIncomplete) {
                                  $.each(masksets, function (ndx, ms) {
                                      if (typeof (ms) == "object") {
                                          ms["buffer"] = ms["_buffer"].slice();
                                          ms["lastValidPosition"] = -1;
                                      }
                                  });
                                  activeMasksetIndex = 0;
                                  if (opts.clearMaskOnLostFocus)
                                      input._valueSet('');
                                  else {
                                      buffer = getActiveBufferTemplate().slice();
                                      writeBuffer(input, buffer);
                                  }
                              }
                          }
                      }).bind("focus.inputmask", function () {
                          var $input = $(this), input = this, nptValue = input._valueGet();
                          if (opts.showMaskOnFocus && !$input.hasClass('focus.inputmask') && (!opts.showMaskOnHover || (opts.showMaskOnHover && nptValue == ''))) {
                              if (input._valueGet() != getActiveBuffer().join('')) {
                                  writeBuffer(input, getActiveBuffer(), seekNext(getActiveMaskSet()["lastValidPosition"]));
                              }
                          }
                          $input.addClass('focus.inputmask');
                          valueOnFocus = getActiveBuffer().join('');
                      }).bind("mouseleave.inputmask", function () {
                          var $input = $(this), input = this;
                          if (opts.clearMaskOnLostFocus) {
                              if (!$input.hasClass('focus.inputmask') && input._valueGet() != $input.attr("placeholder")) {
                                  if (input._valueGet() == getActiveBufferTemplate().join('') || input._valueGet() == '')
                                      input._valueSet('');
                                  else { //clearout optional tail of the mask
                                      clearOptionalTail(input);
                                  }
                              }
                          }
                      }).bind("click.inputmask", function () {
                          var input = this;
                          setTimeout(function () {
                              var selectedCaret = caret(input), buffer = getActiveBuffer();
                              if (selectedCaret.begin == selectedCaret.end) {
                                  var clickPosition = isRTL ? TranslatePosition(selectedCaret.begin) : selectedCaret.begin,
                                      lvp = getActiveMaskSet()["lastValidPosition"],
                                      lastPosition;
                                  if (opts.isNumeric) {
                                      lastPosition = opts.skipRadixDance === false && opts.radixPoint != "" && $.inArray(opts.radixPoint, buffer) != -1 ?
                                          (opts.numericInput ? seekNext($.inArray(opts.radixPoint, buffer)) : $.inArray(opts.radixPoint, buffer)) :
                                          seekNext(lvp);
                                  } else {
                                      lastPosition = seekNext(lvp);
                                  }
                                  if (clickPosition < lastPosition) {
                                      if (isMask(clickPosition))
                                          caret(input, clickPosition);
                                      else caret(input, seekNext(clickPosition));
                                  } else
                                      caret(input, lastPosition);
                              }
                          }, 0);
                      }).bind('dblclick.inputmask', function () {
                          var input = this;
                          setTimeout(function () {
                              caret(input, 0, seekNext(getActiveMaskSet()["lastValidPosition"]));
                          }, 0);
                      }).bind(pasteEvent + ".inputmask dragdrop.inputmask drop.inputmask", function (e) {
                          if (skipInputEvent === true) {
                              skipInputEvent = false;
                              return true;
                          }
                          var input = this, $input = $(input);
  
                          //paste event for IE8 and lower I guess ;-)
                          if (e.type == "propertychange" && input._valueGet().length <= getMaskLength()) {
                              return true;
                          }
                          setTimeout(function () {
                              var pasteValue = opts.onBeforePaste != undefined ? opts.onBeforePaste.call(this, input._valueGet()) : input._valueGet();
                              checkVal(input, true, false, pasteValue.split(''), true);
                              if (isComplete(getActiveBuffer()) === true)
                                  $input.trigger("complete");
                              $input.click();
                          }, 0);
                      }).bind('setvalue.inputmask', function () {
                          var input = this;
                          checkVal(input, true);
                          valueOnFocus = getActiveBuffer().join('');
                          if (input._valueGet() == getActiveBufferTemplate().join(''))
                              input._valueSet('');
                      }).bind('complete.inputmask', opts.oncomplete
                      ).bind('incomplete.inputmask', opts.onincomplete
                      ).bind('cleared.inputmask', opts.oncleared
                      ).bind("keyup.inputmask", keyupEvent);
  
                      if (androidchrome) {
                          $el.bind("input.inputmask", inputEvent);
                      } else {
                          $el.bind("keydown.inputmask", keydownEvent
                          ).bind("keypress.inputmask", keypressEvent);
                      }
  
                      if (msie10)
                          $el.bind("input.inputmask", inputEvent);
  
                      //apply mask
                      checkVal(el, true, false);
                      valueOnFocus = getActiveBuffer().join('');
                      // Wrap document.activeElement in a try/catch block since IE9 throw "Unspecified error" if document.activeElement is undefined when we are in an IFrame.
                      var activeElement;
                      try {
                          activeElement = document.activeElement;
                      } catch (e) {
                      }
                      if (activeElement === el) { //position the caret when in focus
                          $el.addClass('focus.inputmask');
                          caret(el, seekNext(getActiveMaskSet()["lastValidPosition"]));
                      } else if (opts.clearMaskOnLostFocus) {
                          if (getActiveBuffer().join('') == getActiveBufferTemplate().join('')) {
                              el._valueSet('');
                          } else {
                              clearOptionalTail(el);
                          }
                      } else {
                          writeBuffer(el, getActiveBuffer());
                      }
  
                      installEventRuler(el);
                  }
              }
  
              //action object
              if (actionObj != undefined) {
                  switch (actionObj["action"]) {
                      case "isComplete":
                          return isComplete(actionObj["buffer"]);
                      case "unmaskedvalue":
                          isRTL = actionObj["$input"].data('_inputmask')['isRTL'];
                          return unmaskedvalue(actionObj["$input"], actionObj["skipDatepickerCheck"]);
                      case "mask":
                          mask(actionObj["el"]);
                          break;
                      case "format":
                          $el = $({});
                          $el.data('_inputmask', {
                              'masksets': masksets,
                              'activeMasksetIndex': activeMasksetIndex,
                              'opts': opts,
                              'isRTL': opts.numericInput
                          });
                          if (opts.numericInput) {
                              opts.isNumeric = opts.numericInput;
                              isRTL = true;
                          }
  
                          checkVal($el, false, false, actionObj["value"].split(''), true);
                          return getActiveBuffer().join('');
                  }
              }
          }
          $.inputmask = {
              //options default
              defaults: {
                  placeholder: "_",
                  optionalmarker: { start: "[", end: "]" },
                  quantifiermarker: { start: "{", end: "}" },
                  groupmarker: { start: "(", end: ")" },
                  escapeChar: "\\",
                  mask: null,
                  oncomplete: $.noop, //executes when the mask is complete
                  onincomplete: $.noop, //executes when the mask is incomplete and focus is lost
                  oncleared: $.noop, //executes when the mask is cleared
                  repeat: 0, //repetitions of the mask: * ~ forever, otherwise specify an integer
                  greedy: true, //true: allocated buffer for the mask and repetitions - false: allocate only if needed
                  autoUnmask: false, //automatically unmask when retrieving the value with $.fn.val or value if the browser supports __lookupGetter__ or getOwnPropertyDescriptor
                  clearMaskOnLostFocus: true,
                  insertMode: true, //insert the input or overwrite the input
                  clearIncomplete: false, //clear the incomplete input on blur
                  aliases: {}, //aliases definitions => see jquery.inputmask.extensions.js
                  onKeyUp: $.noop, //override to implement autocomplete on certain keys for example
                  onKeyDown: $.noop, //override to implement autocomplete on certain keys for example
                  onBeforePaste: undefined, //executes before masking the pasted value to allow preprocessing of the pasted value.  args => pastedValue => return processedValue
                  onUnMask: undefined, //executes after unmasking to allow postprocessing of the unmaskedvalue.  args => maskedValue, unmaskedValue
                  showMaskOnFocus: true, //show the mask-placeholder when the input has focus
                  showMaskOnHover: true, //show the mask-placeholder when hovering the empty input
                  onKeyValidation: $.noop, //executes on every key-press with the result of isValid. Params: result, opts
                  skipOptionalPartCharacter: " ", //a character which can be used to skip an optional part of a mask
                  showTooltip: false, //show the activemask as tooltip
                  numericInput: false, //numericInput input direction style (input shifts to the left while holding the caret position)
                  //numeric basic properties
                  isNumeric: false, //enable numeric features
                  radixPoint: "", //".", // | ","
                  skipRadixDance: false, //disable radixpoint caret positioning
                  rightAlignNumerics: true, //align numerics to the right
                  //numeric basic properties
                  definitions: {
                      '9': {
                          validator: "[0-9]",
                          cardinality: 1
                      },
                      'a': {
                          validator: "[A-Za-z\u0410-\u044F\u0401\u0451]",
                          cardinality: 1
                      },
                      '*': {
                          validator: "[A-Za-z\u0410-\u044F\u0401\u04510-9]",
                          cardinality: 1
                      }
                  },
                  keyCode: {
                      ALT: 18, BACKSPACE: 8, CAPS_LOCK: 20, COMMA: 188, COMMAND: 91, COMMAND_LEFT: 91, COMMAND_RIGHT: 93, CONTROL: 17, DELETE: 46, DOWN: 40, END: 35, ENTER: 13, ESCAPE: 27, HOME: 36, INSERT: 45, LEFT: 37, MENU: 93, NUMPAD_ADD: 107, NUMPAD_DECIMAL: 110, NUMPAD_DIVIDE: 111, NUMPAD_ENTER: 108,
                      NUMPAD_MULTIPLY: 106, NUMPAD_SUBTRACT: 109, PAGE_DOWN: 34, PAGE_UP: 33, PERIOD: 190, RIGHT: 39, SHIFT: 16, SPACE: 32, TAB: 9, UP: 38, WINDOWS: 91
                  },
                  //specify keycodes which should not be considered in the keypress event, otherwise the preventDefault will stop their default behavior especially in FF
                  ignorables: [8, 9, 13, 19, 27, 33, 34, 35, 36, 37, 38, 39, 40, 45, 46, 93, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123],
                  getMaskLength: function (buffer, greedy, repeat, currentBuffer, opts) {
                      var calculatedLength = buffer.length;
                      if (!greedy) {
                          if (repeat == "*") {
                              calculatedLength = currentBuffer.length + 1;
                          } else if (repeat > 1) {
                              calculatedLength += (buffer.length * (repeat - 1));
                          }
                      }
                      return calculatedLength;
                  }
              },
              escapeRegex: function (str) {
                  var specials = ['/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\'];
                  return str.replace(new RegExp('(\\' + specials.join('|\\') + ')', 'gim'), '\\$1');
              },
              format: function (value, options) {
                  var opts = $.extend(true, {}, $.inputmask.defaults, options);
                  resolveAlias(opts.alias, options, opts);
                  return maskScope(generateMaskSets(opts), 0, opts, { "action": "format", "value": value });
              }
          };
  
          $.fn.inputmask = function (fn, options) {
              var opts = $.extend(true, {}, $.inputmask.defaults, options),
                  masksets,
                  activeMasksetIndex = 0;
  
              if (typeof fn === "string") {
                  switch (fn) {
                      case "mask":
                          //resolve possible aliases given by options
                          resolveAlias(opts.alias, options, opts);
                          masksets = generateMaskSets(opts);
                          if (masksets.length == 0) { return this; }
  
                          return this.each(function () {
                              maskScope($.extend(true, {}, masksets), 0, opts, { "action": "mask", "el": this });
                          });
                      case "unmaskedvalue":
                          var $input = $(this), input = this;
                          if ($input.data('_inputmask')) {
                              masksets = $input.data('_inputmask')['masksets'];
                              activeMasksetIndex = $input.data('_inputmask')['activeMasksetIndex'];
                              opts = $input.data('_inputmask')['opts'];
                              return maskScope(masksets, activeMasksetIndex, opts, { "action": "unmaskedvalue", "$input": $input });
                          } else return $input.val();
                      case "remove":
                          return this.each(function () {
                              var $input = $(this), input = this;
                              if ($input.data('_inputmask')) {
                                  masksets = $input.data('_inputmask')['masksets'];
                                  activeMasksetIndex = $input.data('_inputmask')['activeMasksetIndex'];
                                  opts = $input.data('_inputmask')['opts'];
                                  //writeout the unmaskedvalue
                                  input._valueSet(maskScope(masksets, activeMasksetIndex, opts, { "action": "unmaskedvalue", "$input": $input, "skipDatepickerCheck": true }));
                                  //clear data
                                  $input.removeData('_inputmask');
                                  //unbind all events
                                  $input.unbind(".inputmask");
                                  $input.removeClass('focus.inputmask');
                                  //restore the value property
                                  var valueProperty;
                                  if (Object.getOwnPropertyDescriptor)
                                      valueProperty = Object.getOwnPropertyDescriptor(input, "value");
                                  if (valueProperty && valueProperty.get) {
                                      if (input._valueGet) {
                                          Object.defineProperty(input, "value", {
                                              get: input._valueGet,
                                              set: input._valueSet
                                          });
                                      }
                                  } else if (document.__lookupGetter__ && input.__lookupGetter__("value")) {
                                      if (input._valueGet) {
                                          input.__defineGetter__("value", input._valueGet);
                                          input.__defineSetter__("value", input._valueSet);
                                      }
                                  }
                                  try { //try catch needed for IE7 as it does not supports deleting fns
                                      delete input._valueGet;
                                      delete input._valueSet;
                                  } catch (e) {
                                      input._valueGet = undefined;
                                      input._valueSet = undefined;
  
                                  }
                              }
                          });
                          break;
                      case "getemptymask": //return the default (empty) mask value, usefull for setting the default value in validation
                          if (this.data('_inputmask')) {
                              masksets = this.data('_inputmask')['masksets'];
                              activeMasksetIndex = this.data('_inputmask')['activeMasksetIndex'];
                              return masksets[activeMasksetIndex]['_buffer'].join('');
                          }
                          else return "";
                      case "hasMaskedValue": //check wheter the returned value is masked or not; currently only works reliable when using jquery.val fn to retrieve the value 
                          return this.data('_inputmask') ? !this.data('_inputmask')['opts'].autoUnmask : false;
                      case "isComplete":
                          masksets = this.data('_inputmask')['masksets'];
                          activeMasksetIndex = this.data('_inputmask')['activeMasksetIndex'];
                          opts = this.data('_inputmask')['opts'];
                          return maskScope(masksets, activeMasksetIndex, opts, { "action": "isComplete", "buffer": this[0]._valueGet().split('') });
                      case "getmetadata": //return mask metadata if exists
                          if (this.data('_inputmask')) {
                              masksets = this.data('_inputmask')['masksets'];
                              activeMasksetIndex = this.data('_inputmask')['activeMasksetIndex'];
                              return masksets[activeMasksetIndex]['metadata'];
                          }
                          else return undefined;
                      default:
                          //check if the fn is an alias
                          if (!resolveAlias(fn, options, opts)) {
                              //maybe fn is a mask so we try
                              //set mask
                              opts.mask = fn;
                          }
                          masksets = generateMaskSets(opts);
                          if (masksets.length == 0) { return this; }
                          return this.each(function () {
                              maskScope($.extend(true, {}, masksets), activeMasksetIndex, opts, { "action": "mask", "el": this });
                          });
  
                          break;
                  }
              } else if (typeof fn == "object") {
                  opts = $.extend(true, {}, $.inputmask.defaults, fn);
  
                  resolveAlias(opts.alias, fn, opts); //resolve aliases
                  masksets = generateMaskSets(opts);
                  if (masksets.length == 0) { return this; }
                  return this.each(function () {
                      maskScope($.extend(true, {}, masksets), activeMasksetIndex, opts, { "action": "mask", "el": this });
                  });
              } else if (fn == undefined) {
                  //look for data-inputmask atribute - the attribute should only contain optipns
                  return this.each(function () {
                      var attrOptions = $(this).attr("data-inputmask");
                      if (attrOptions && attrOptions != "") {
                          try {
                              attrOptions = attrOptions.replace(new RegExp("'", "g"), '"');
                              var dataoptions = $.parseJSON("{" + attrOptions + "}");
                              $.extend(true, dataoptions, options);
                              opts = $.extend(true, {}, $.inputmask.defaults, dataoptions);
                              resolveAlias(opts.alias, dataoptions, opts);
                              opts.alias = undefined;
                              $(this).inputmask(opts);
                          } catch (ex) { } //need a more relax parseJSON
                      }
                  });
              }
          };
      }
  })(jQuery);
  
  /*
  Input Mask plugin extensions
  http://github.com/RobinHerbots/jquery.inputmask
  Copyright (c) 2010 - 2014 Robin Herbots
  Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
  Version: 0.0.0
  
  Optional extensions on the jquery.inputmask base
  */
  (function ($) {
      //date & time aliases
      $.extend($.inputmask.defaults.definitions, {
          'h': { //hours
              validator: "[01][0-9]|2[0-3]",
              cardinality: 2,
              prevalidator: [{ validator: "[0-2]", cardinality: 1 }]
          },
          's': { //seconds || minutes
              validator: "[0-5][0-9]",
              cardinality: 2,
              prevalidator: [{ validator: "[0-5]", cardinality: 1 }]
          },
          'd': { //basic day
              validator: "0[1-9]|[12][0-9]|3[01]",
              cardinality: 2,
              prevalidator: [{ validator: "[0-3]", cardinality: 1 }]
          },
          'm': { //basic month
              validator: "0[1-9]|1[012]",
              cardinality: 2,
              prevalidator: [{ validator: "[01]", cardinality: 1 }]
          },
          'y': { //basic year
              validator: "(19|20)\\d{2}",
              cardinality: 4,
              prevalidator: [
                          { validator: "[12]", cardinality: 1 },
                          { validator: "(19|20)", cardinality: 2 },
                          { validator: "(19|20)\\d", cardinality: 3 }
              ]
          }
      });
      $.extend($.inputmask.defaults.aliases, {
          'dd/mm/yyyy': {
              mask: "1/2/y",
              placeholder: "dd/mm/yyyy",
              regex: {
                  val1pre: new RegExp("[0-3]"), //daypre
                  val1: new RegExp("0[1-9]|[12][0-9]|3[01]"), //day
                  val2pre: function (separator) { var escapedSeparator = $.inputmask.escapeRegex.call(this, separator); return new RegExp("((0[1-9]|[12][0-9]|3[01])" + escapedSeparator + "[01])"); }, //monthpre
                  val2: function (separator) { var escapedSeparator = $.inputmask.escapeRegex.call(this, separator); return new RegExp("((0[1-9]|[12][0-9])" + escapedSeparator + "(0[1-9]|1[012]))|(30" + escapedSeparator + "(0[13-9]|1[012]))|(31" + escapedSeparator + "(0[13578]|1[02]))"); }//month
              },
              leapday: "29/02/",
              separator: '/',
              yearrange: { minyear: 1900, maxyear: 2099 },
              isInYearRange: function (chrs, minyear, maxyear) {
                  var enteredyear = parseInt(chrs.concat(minyear.toString().slice(chrs.length)));
                  var enteredyear2 = parseInt(chrs.concat(maxyear.toString().slice(chrs.length)));
                  return (enteredyear != NaN ? minyear <= enteredyear && enteredyear <= maxyear : false) ||
              		   (enteredyear2 != NaN ? minyear <= enteredyear2 && enteredyear2 <= maxyear : false);
              },
              determinebaseyear: function (minyear, maxyear, hint) {
                  var currentyear = (new Date()).getFullYear();
                  if (minyear > currentyear) return minyear;
                  if (maxyear < currentyear) {
                      var maxYearPrefix = maxyear.toString().slice(0, 2);
                      var maxYearPostfix = maxyear.toString().slice(2, 4);
                      while (maxyear < maxYearPrefix + hint) {
                          maxYearPrefix--;
                      }
                      var maxxYear = maxYearPrefix + maxYearPostfix;
                      return minyear > maxxYear ? minyear : maxxYear;
                  }
  
                  return currentyear;
              },
              onKeyUp: function (e, buffer, opts) {
                  var $input = $(this);
                  if (e.ctrlKey && e.keyCode == opts.keyCode.RIGHT) {
                      var today = new Date();
                      $input.val(today.getDate().toString() + (today.getMonth() + 1).toString() + today.getFullYear().toString());
                  }
              },
              definitions: {
                  '1': { //val1 ~ day or month
                      validator: function (chrs, buffer, pos, strict, opts) {
                          var isValid = opts.regex.val1.test(chrs);
                          if (!strict && !isValid) {
                              if (chrs.charAt(1) == opts.separator || "-./".indexOf(chrs.charAt(1)) != -1) {
                                  isValid = opts.regex.val1.test("0" + chrs.charAt(0));
                                  if (isValid) {
                                      buffer[pos - 1] = "0";
                                      return { "pos": pos, "c": chrs.charAt(0) };
                                  }
                              }
                          }
                          return isValid;
                      },
                      cardinality: 2,
                      prevalidator: [{
                          validator: function (chrs, buffer, pos, strict, opts) {
                              var isValid = opts.regex.val1pre.test(chrs);
                              if (!strict && !isValid) {
                                  isValid = opts.regex.val1.test("0" + chrs);
                                  if (isValid) {
                                      buffer[pos] = "0";
                                      pos++;
                                      return { "pos": pos };
                                  }
                              }
                              return isValid;
                          }, cardinality: 1
                      }]
                  },
                  '2': { //val2 ~ day or month
                      validator: function (chrs, buffer, pos, strict, opts) {
                          var frontValue = buffer.join('').substr(0, 3);
                          if (frontValue.indexOf(opts.placeholder[0]) != -1) frontValue = "01" + opts.separator;
                          var isValid = opts.regex.val2(opts.separator).test(frontValue + chrs);
                          if (!strict && !isValid) {
                              if (chrs.charAt(1) == opts.separator || "-./".indexOf(chrs.charAt(1)) != -1) {
                                  isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs.charAt(0));
                                  if (isValid) {
                                      buffer[pos - 1] = "0";
                                      return { "pos": pos, "c": chrs.charAt(0) };
                                  }
                              }
                          }
                          return isValid;
                      },
                      cardinality: 2,
                      prevalidator: [{
                          validator: function (chrs, buffer, pos, strict, opts) {
                              var frontValue = buffer.join('').substr(0, 3);
                              if (frontValue.indexOf(opts.placeholder[0]) != -1) frontValue = "01" + opts.separator;
                              var isValid = opts.regex.val2pre(opts.separator).test(frontValue + chrs);
                              if (!strict && !isValid) {
                                  isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs);
                                  if (isValid) {
                                      buffer[pos] = "0";
                                      pos++;
                                      return { "pos": pos };
                                  }
                              }
                              return isValid;
                          }, cardinality: 1
                      }]
                  },
                  'y': { //year
                      validator: function (chrs, buffer, pos, strict, opts) {
                          if (opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) {
                              var dayMonthValue = buffer.join('').substr(0, 6);
                              if (dayMonthValue != opts.leapday)
                                  return true;
                              else {
                                  var year = parseInt(chrs, 10);//detect leap year
                                  if (year % 4 === 0)
                                      if (year % 100 === 0)
                                          if (year % 400 === 0)
                                              return true;
                                          else return false;
                                      else return true;
                                  else return false;
                              }
                          } else return false;
                      },
                      cardinality: 4,
                      prevalidator: [
                  {
                      validator: function (chrs, buffer, pos, strict, opts) {
                          var isValid = opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
                          if (!strict && !isValid) {
                              var yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs + "0").toString().slice(0, 1);
  
                              isValid = opts.isInYearRange(yearPrefix + chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
                              if (isValid) {
                                  buffer[pos++] = yearPrefix[0];
                                  return { "pos": pos };
                              }
                              yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs + "0").toString().slice(0, 2);
  
                              isValid = opts.isInYearRange(yearPrefix + chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
                              if (isValid) {
                                  buffer[pos++] = yearPrefix[0];
                                  buffer[pos++] = yearPrefix[1];
                                  return { "pos": pos };
                              }
                          }
                          return isValid;
                      },
                      cardinality: 1
                  },
                  {
                      validator: function (chrs, buffer, pos, strict, opts) {
                          var isValid = opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
                          if (!strict && !isValid) {
                              var yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs).toString().slice(0, 2);
  
                              isValid = opts.isInYearRange(chrs[0] + yearPrefix[1] + chrs[1], opts.yearrange.minyear, opts.yearrange.maxyear);
                              if (isValid) {
                                  buffer[pos++] = yearPrefix[1];
                                  return { "pos": pos };
                              }
  
                              yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs).toString().slice(0, 2);
                              if (opts.isInYearRange(yearPrefix + chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) {
                                  var dayMonthValue = buffer.join('').substr(0, 6);
                                  if (dayMonthValue != opts.leapday)
                                      isValid = true;
                                  else {
                                      var year = parseInt(chrs, 10);//detect leap year
                                      if (year % 4 === 0)
                                          if (year % 100 === 0)
                                              if (year % 400 === 0)
                                                  isValid = true;
                                              else isValid = false;
                                          else isValid = true;
                                      else isValid = false;
                                  }
                              } else isValid = false;
                              if (isValid) {
                                  buffer[pos - 1] = yearPrefix[0];
                                  buffer[pos++] = yearPrefix[1];
                                  buffer[pos++] = chrs[0];
                                  return { "pos": pos };
                              }
                          }
                          return isValid;
                      }, cardinality: 2
                  },
                  {
                      validator: function (chrs, buffer, pos, strict, opts) {
                          return opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
                      }, cardinality: 3
                  }
                      ]
                  }
              },
              insertMode: false,
              autoUnmask: false
          },
          'mm/dd/yyyy': {
              placeholder: "mm/dd/yyyy",
              alias: "dd/mm/yyyy", //reuse functionality of dd/mm/yyyy alias
              regex: {
                  val2pre: function (separator) { var escapedSeparator = $.inputmask.escapeRegex.call(this, separator); return new RegExp("((0[13-9]|1[012])" + escapedSeparator + "[0-3])|(02" + escapedSeparator + "[0-2])"); }, //daypre
                  val2: function (separator) { var escapedSeparator = $.inputmask.escapeRegex.call(this, separator); return new RegExp("((0[1-9]|1[012])" + escapedSeparator + "(0[1-9]|[12][0-9]))|((0[13-9]|1[012])" + escapedSeparator + "30)|((0[13578]|1[02])" + escapedSeparator + "31)"); }, //day
                  val1pre: new RegExp("[01]"), //monthpre
                  val1: new RegExp("0[1-9]|1[012]") //month
              },
              leapday: "02/29/",
              onKeyUp: function (e, buffer, opts) {
                  var $input = $(this);
                  if (e.ctrlKey && e.keyCode == opts.keyCode.RIGHT) {
                      var today = new Date();
                      $input.val((today.getMonth() + 1).toString() + today.getDate().toString() + today.getFullYear().toString());
                  }
              }
          },
          'yyyy/mm/dd': {
              mask: "y/1/2",
              placeholder: "yyyy/mm/dd",
              alias: "mm/dd/yyyy",
              leapday: "/02/29",
              onKeyUp: function (e, buffer, opts) {
                  var $input = $(this);
                  if (e.ctrlKey && e.keyCode == opts.keyCode.RIGHT) {
                      var today = new Date();
                      $input.val(today.getFullYear().toString() + (today.getMonth() + 1).toString() + today.getDate().toString());
                  }
              },
              definitions: {
                  '2': { //val2 ~ day or month
                      validator: function (chrs, buffer, pos, strict, opts) {
                          var frontValue = buffer.join('').substr(5, 3);
                          if (frontValue.indexOf(opts.placeholder[5]) != -1) frontValue = "01" + opts.separator;
                          var isValid = opts.regex.val2(opts.separator).test(frontValue + chrs);
                          if (!strict && !isValid) {
                              if (chrs.charAt(1) == opts.separator || "-./".indexOf(chrs.charAt(1)) != -1) {
                                  isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs.charAt(0));
                                  if (isValid) {
                                      buffer[pos - 1] = "0";
                                      return { "pos": pos, "c": chrs.charAt(0) };
                                  }
                              }
                          }
  
                          //check leap yeap
                          if (isValid) {
                              var dayMonthValue = buffer.join('').substr(4, 4) + chrs;
                              if (dayMonthValue != opts.leapday)
                                  return true;
                              else {
                                  var year = parseInt(buffer.join('').substr(0, 4), 10);  //detect leap year
                                  if (year % 4 === 0)
                                      if (year % 100 === 0)
                                          if (year % 400 === 0)
                                              return true;
                                          else return false;
                                      else return true;
                                  else return false;
                              }
                          }
  
                          return isValid;
                      },
                      cardinality: 2,
                      prevalidator: [{
                          validator: function (chrs, buffer, pos, strict, opts) {
                              var frontValue = buffer.join('').substr(5, 3);
                              if (frontValue.indexOf(opts.placeholder[5]) != -1) frontValue = "01" + opts.separator;
                              var isValid = opts.regex.val2pre(opts.separator).test(frontValue + chrs);
                              if (!strict && !isValid) {
                                  isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs);
                                  if (isValid) {
                                      buffer[pos] = "0";
                                      pos++;
                                      return { "pos": pos };
                                  }
                              }
                              return isValid;
                          }, cardinality: 1
                      }]
                  }
              }
          },
          'dd.mm.yyyy': {
              mask: "1.2.y",
              placeholder: "dd.mm.yyyy",
              leapday: "29.02.",
              separator: '.',
              alias: "dd/mm/yyyy"
          },
          'dd-mm-yyyy': {
              mask: "1-2-y",
              placeholder: "dd-mm-yyyy",
              leapday: "29-02-",
              separator: '-',
              alias: "dd/mm/yyyy"
          },
          'mm.dd.yyyy': {
              mask: "1.2.y",
              placeholder: "mm.dd.yyyy",
              leapday: "02.29.",
              separator: '.',
              alias: "mm/dd/yyyy"
          },
          'mm-dd-yyyy': {
              mask: "1-2-y",
              placeholder: "mm-dd-yyyy",
              leapday: "02-29-",
              separator: '-',
              alias: "mm/dd/yyyy"
          },
          'yyyy.mm.dd': {
              mask: "y.1.2",
              placeholder: "yyyy.mm.dd",
              leapday: ".02.29",
              separator: '.',
              alias: "yyyy/mm/dd"
          },
          'yyyy-mm-dd': {
              mask: "y-1-2",
              placeholder: "yyyy-mm-dd",
              leapday: "-02-29",
              separator: '-',
              alias: "yyyy/mm/dd"
          },
          'datetime': {
              mask: "1/2/y h:s",
              placeholder: "dd/mm/yyyy hh:mm",
              alias: "dd/mm/yyyy",
              regex: {
                  hrspre: new RegExp("[012]"), //hours pre
                  hrs24: new RegExp("2[0-9]|1[3-9]"),
                  hrs: new RegExp("[01][0-9]|2[0-3]"), //hours
                  ampm: new RegExp("^[a|p|A|P][m|M]")
              },
              timeseparator: ':',
              hourFormat: "24", // or 12
              definitions: {
                  'h': { //hours
                      validator: function (chrs, buffer, pos, strict, opts) {
                          var isValid = opts.regex.hrs.test(chrs);
                          if (!strict && !isValid) {
                              if (chrs.charAt(1) == opts.timeseparator || "-.:".indexOf(chrs.charAt(1)) != -1) {
                                  isValid = opts.regex.hrs.test("0" + chrs.charAt(0));
                                  if (isValid) {
                                      buffer[pos - 1] = "0";
                                      buffer[pos] = chrs.charAt(0);
                                      pos++;
                                      return { "pos": pos };
                                  }
                              }
                          }
  
                          if (isValid && opts.hourFormat !== "24" && opts.regex.hrs24.test(chrs)) {
  
                              var tmp = parseInt(chrs, 10);
  
                              if (tmp == 24) {
                                  buffer[pos + 5] = "a";
                                  buffer[pos + 6] = "m";
                              } else {
                                  buffer[pos + 5] = "p";
                                  buffer[pos + 6] = "m";
                              }
  
                              tmp = tmp - 12;
  
                              if (tmp < 10) {
                                  buffer[pos] = tmp.toString();
                                  buffer[pos - 1] = "0";
                              } else {
                                  buffer[pos] = tmp.toString().charAt(1);
                                  buffer[pos - 1] = tmp.toString().charAt(0);
                              }
  
                              return { "pos": pos, "c": buffer[pos] };
                          }
  
                          return isValid;
                      },
                      cardinality: 2,
                      prevalidator: [{
                          validator: function (chrs, buffer, pos, strict, opts) {
                              var isValid = opts.regex.hrspre.test(chrs);
                              if (!strict && !isValid) {
                                  isValid = opts.regex.hrs.test("0" + chrs);
                                  if (isValid) {
                                      buffer[pos] = "0";
                                      pos++;
                                      return { "pos": pos };
                                  }
                              }
                              return isValid;
                          }, cardinality: 1
                      }]
                  },
                  't': { //am/pm
                      validator: function (chrs, buffer, pos, strict, opts) {
                          return opts.regex.ampm.test(chrs + "m");
                      },
                      casing: "lower",
                      cardinality: 1
                  }
              },
              insertMode: false,
              autoUnmask: false
          },
          'datetime12': {
              mask: "1/2/y h:s t\\m",
              placeholder: "dd/mm/yyyy hh:mm xm",
              alias: "datetime",
              hourFormat: "12"
          },
          'hh:mm t': {
              mask: "h:s t\\m",
              placeholder: "hh:mm xm",
              alias: "datetime",
              hourFormat: "12"
          },
          'h:s t': {
              mask: "h:s t\\m",
              placeholder: "hh:mm xm",
              alias: "datetime",
              hourFormat: "12"
          },
          'hh:mm:ss': {
              mask: "h:s:s",
              autoUnmask: false
          },
          'hh:mm': {
              mask: "h:s",
              autoUnmask: false
          },
          'date': {
              alias: "dd/mm/yyyy" // "mm/dd/yyyy"
          },
          'mm/yyyy': {
              mask: "1/y",
              placeholder: "mm/yyyy",
              leapday: "donotuse",
              separator: '/',
              alias: "mm/dd/yyyy"
          }
      });
  })(jQuery);
  
  /*
  Input Mask plugin extensions
  http://github.com/RobinHerbots/jquery.inputmask
  Copyright (c) 2010 - 2014 Robin Herbots
  Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
  Version: 0.0.0
  
  Optional extensions on the jquery.inputmask base
  */
  (function ($) {
      //extra definitions
      $.extend($.inputmask.defaults.definitions, {
          'A': {
              validator: "[A-Za-z]",
              cardinality: 1,
              casing: "upper" //auto uppercasing
          },
          '#': {
              validator: "[A-Za-z\u0410-\u044F\u0401\u04510-9]",
              cardinality: 1,
              casing: "upper"
          }
      });
      $.extend($.inputmask.defaults.aliases, {
          'url': {
              mask: "ir",
              placeholder: "",
              separator: "",
              defaultPrefix: "http://",
              regex: {
                  urlpre1: new RegExp("[fh]"),
                  urlpre2: new RegExp("(ft|ht)"),
                  urlpre3: new RegExp("(ftp|htt)"),
                  urlpre4: new RegExp("(ftp:|http|ftps)"),
                  urlpre5: new RegExp("(ftp:/|ftps:|http:|https)"),
                  urlpre6: new RegExp("(ftp://|ftps:/|http:/|https:)"),
                  urlpre7: new RegExp("(ftp://|ftps://|http://|https:/)"),
                  urlpre8: new RegExp("(ftp://|ftps://|http://|https://)")
              },
              definitions: {
                  'i': {
                      validator: function (chrs, buffer, pos, strict, opts) {
                          return true;
                      },
                      cardinality: 8,
                      prevalidator: (function () {
                          var result = [], prefixLimit = 8;
                          for (var i = 0; i < prefixLimit; i++) {
                              result[i] = (function () {
                                  var j = i;
                                  return {
                                      validator: function (chrs, buffer, pos, strict, opts) {
                                          if (opts.regex["urlpre" + (j + 1)]) {
                                              var tmp = chrs, k;
                                              if (((j + 1) - chrs.length) > 0) {
                                                  tmp = buffer.join('').substring(0, ((j + 1) - chrs.length)) + "" + tmp;
                                              }
                                              var isValid = opts.regex["urlpre" + (j + 1)].test(tmp);
                                              if (!strict && !isValid) {
                                                  pos = pos - j;
                                                  for (k = 0; k < opts.defaultPrefix.length; k++) {
                                                      buffer[pos] = opts.defaultPrefix[k]; pos++;
                                                  }
                                                  for (k = 0; k < tmp.length - 1; k++) {
                                                      buffer[pos] = tmp[k]; pos++;
                                                  }
                                                  return { "pos": pos };
                                              }
                                              return isValid;
                                          } else {
                                              return false;
                                          }
                                      }, cardinality: j
                                  };
                              })();
                          }
                          return result;
                      })()
                  },
                  "r": {
                      validator: ".",
                      cardinality: 50
                  }
              },
              insertMode: false,
              autoUnmask: false
          },
          "ip": { //ip-address mask
              mask: ["[[x]y]z.[[x]y]z.[[x]y]z.x[yz]", "[[x]y]z.[[x]y]z.[[x]y]z.[[x]y][z]"],
              definitions: {
                  'x': {
                      validator: "[012]",
                      cardinality: 1,
                      definitionSymbol: "i"
                  },
                  'y': {
                      validator: function (chrs, buffer, pos, strict, opts) {
                          if (pos - 1 > -1 && buffer[pos - 1] != ".")
                              chrs = buffer[pos - 1] + chrs;
                          else chrs = "0" + chrs;
                          return new RegExp("2[0-5]|[01][0-9]").test(chrs);
                      },
                      cardinality: 1,
                      definitionSymbol: "i"
                  },
                  'z': {
                      validator: function (chrs, buffer, pos, strict, opts) {
                          if (pos - 1 > -1 && buffer[pos - 1] != ".") {
                              chrs = buffer[pos - 1] + chrs;
                              if (pos - 2 > -1 && buffer[pos - 2] != ".") {
                                  chrs = buffer[pos - 2] + chrs;
                              } else chrs = "0" + chrs;
                          } else chrs = "00" + chrs;
                          return new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]").test(chrs);
                      },
                      cardinality: 1,
                      definitionSymbol: "i"
                  }
              }
          }
      });
  })(jQuery);
  
  /*
  Input Mask plugin extensions
  http://github.com/RobinHerbots/jquery.inputmask
  Copyright (c) 2010 - 2014 Robin Herbots
  Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
  Version: 0.0.0
  
  Optional extensions on the jquery.inputmask base
  */
  (function ($) {
      //number aliases
      $.extend($.inputmask.defaults.aliases, {
          'decimal': {
              mask: "~",
              placeholder: "",
              repeat: "*",
              greedy: false,
              numericInput: false,
              isNumeric: true,
              digits: "*", //number of fractionalDigits
              groupSeparator: "",//",", // | "."
              radixPoint: ".",
              groupSize: 3,
              autoGroup: false,
              allowPlus: true,
              allowMinus: true,
              //todo
              integerDigits: "*", //number of integerDigits
              defaultValue: "",
              prefix: "",
              suffix: "",
  
              //todo
              getMaskLength: function (buffer, greedy, repeat, currentBuffer, opts) { //custom getMaskLength to take the groupSeparator into account
                  var calculatedLength = buffer.length;
  
                  if (!greedy) {
                      if (repeat == "*") {
                          calculatedLength = currentBuffer.length + 1;
                      } else if (repeat > 1) {
                          calculatedLength += (buffer.length * (repeat - 1));
                      }
                  }
  
                  var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
                  var escapedRadixPoint = $.inputmask.escapeRegex.call(this, opts.radixPoint);
                  var currentBufferStr = currentBuffer.join(''), strippedBufferStr = currentBufferStr.replace(new RegExp(escapedGroupSeparator, "g"), "").replace(new RegExp(escapedRadixPoint), ""),
                  groupOffset = currentBufferStr.length - strippedBufferStr.length;
                  return calculatedLength + groupOffset;
              },
              postFormat: function (buffer, pos, reformatOnly, opts) {
                  if (opts.groupSeparator == "") return pos;
                  var cbuf = buffer.slice(),
                      radixPos = $.inArray(opts.radixPoint, buffer);
                  if (!reformatOnly) {
                      cbuf.splice(pos, 0, "?"); //set position indicator
                  }
                  var bufVal = cbuf.join('');
                  if (opts.autoGroup || (reformatOnly && bufVal.indexOf(opts.groupSeparator) != -1)) {
                      var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
                      bufVal = bufVal.replace(new RegExp(escapedGroupSeparator, "g"), '');
                      var radixSplit = bufVal.split(opts.radixPoint);
                      bufVal = radixSplit[0];
                      var reg = new RegExp('([-\+]?[\\d\?]+)([\\d\?]{' + opts.groupSize + '})');
                      while (reg.test(bufVal)) {
                          bufVal = bufVal.replace(reg, '$1' + opts.groupSeparator + '$2');
                          bufVal = bufVal.replace(opts.groupSeparator + opts.groupSeparator, opts.groupSeparator);
                      }
                      if (radixSplit.length > 1)
                          bufVal += opts.radixPoint + radixSplit[1];
                  }
                  buffer.length = bufVal.length; //align the length
                  for (var i = 0, l = bufVal.length; i < l; i++) {
                      buffer[i] = bufVal.charAt(i);
                  }
                  var newPos = $.inArray("?", buffer);
                  if (!reformatOnly) buffer.splice(newPos, 1);
  
                  return reformatOnly ? pos : newPos;
              },
              regex: {
                  number: function (opts) {
                      var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
                      var escapedRadixPoint = $.inputmask.escapeRegex.call(this, opts.radixPoint);
                      var digitExpression = isNaN(opts.digits) ? opts.digits : '{0,' + opts.digits + '}';
                      var signedExpression = opts.allowPlus || opts.allowMinus ? "[" + (opts.allowPlus ? "\+" : "") + (opts.allowMinus ? "-" : "") + "]?" : "";
                      return new RegExp("^" + signedExpression + "(\\d+|\\d{1," + opts.groupSize + "}((" + escapedGroupSeparator + "\\d{" + opts.groupSize + "})?)+)(" + escapedRadixPoint + "\\d" + digitExpression + ")?$");
                  }
              },
              onKeyDown: function (e, buffer, opts) {
                  var $input = $(this), input = this;
                  if (e.keyCode == opts.keyCode.TAB) {
                      var radixPosition = $.inArray(opts.radixPoint, buffer);
                      if (radixPosition != -1) {
                          var masksets = $input.data('_inputmask')['masksets'];
                          var activeMasksetIndex = $input.data('_inputmask')['activeMasksetIndex'];
                          for (var i = 1; i <= opts.digits && i < opts.getMaskLength(masksets[activeMasksetIndex]["_buffer"], masksets[activeMasksetIndex]["greedy"], masksets[activeMasksetIndex]["repeat"], buffer, opts) ; i++) {
                              if (buffer[radixPosition + i] == undefined || buffer[radixPosition + i] == "") buffer[radixPosition + i] = "0";
                          }
                          input._valueSet(buffer.join(''));
                      }
                  } else if (e.keyCode == opts.keyCode.DELETE || e.keyCode == opts.keyCode.BACKSPACE) {
                      opts.postFormat(buffer, 0, true, opts);
                      input._valueSet(buffer.join(''));
                      return true;
                  }
              },
              definitions: {
                  '~': { //real number
                      validator: function (chrs, buffer, pos, strict, opts) {
                          if (chrs == "") return false;
                          if (!strict && pos <= 1 && buffer[0] === '0' && new RegExp("[\\d-]").test(chrs) && buffer.join('').length == 1) { //handle first char
                              buffer[0] = "";
                              return { "pos": 0 };
                          }
  
                          var cbuf = strict ? buffer.slice(0, pos) : buffer.slice();
  
                          cbuf.splice(pos, 0, chrs);
                          var bufferStr = cbuf.join('');
  
                          //strip groupseparator
                          var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
                          bufferStr = bufferStr.replace(new RegExp(escapedGroupSeparator, "g"), '');
  
                          var isValid = opts.regex.number(opts).test(bufferStr);
                          if (!isValid) {
                              //let's help the regex a bit
                              bufferStr += "0";
                              isValid = opts.regex.number(opts).test(bufferStr);
                              if (!isValid) {
                                  //make a valid group
                                  var lastGroupSeparator = bufferStr.lastIndexOf(opts.groupSeparator);
                                  for (var i = bufferStr.length - lastGroupSeparator; i <= 3; i++) {
                                      bufferStr += "0";
                                  }
  
                                  isValid = opts.regex.number(opts).test(bufferStr);
                                  if (!isValid && !strict) {
                                      if (chrs == opts.radixPoint) {
                                          isValid = opts.regex.number(opts).test("0" + bufferStr + "0");
                                          if (isValid) {
                                              buffer[pos] = "0";
                                              pos++;
                                              return { "pos": pos };
                                          }
                                      }
                                  }
                              }
                          }
  
                          if (isValid != false && !strict && chrs != opts.radixPoint) {
                              var newPos = opts.postFormat(buffer, pos, false, opts);
                              return { "pos": newPos };
                          }
  
                          return isValid;
                      },
                      cardinality: 1,
                      prevalidator: null
                  }
              },
              insertMode: true,
              autoUnmask: false
          },
          'integer': {
              regex: {
                  number: function (opts) {
                      var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
                      var signedExpression = opts.allowPlus || opts.allowMinus ? "[" + (opts.allowPlus ? "\+" : "") + (opts.allowMinus ? "-" : "") + "]?" : "";
                      return new RegExp("^" + signedExpression + "(\\d+|\\d{1," + opts.groupSize + "}((" + escapedGroupSeparator + "\\d{" + opts.groupSize + "})?)+)$");
                  }
              },
              alias: "decimal"
          }
      });
  })(jQuery);
  
  /*
  Input Mask plugin extensions
  http://github.com/RobinHerbots/jquery.inputmask
  Copyright (c) 2010 - 2014 Robin Herbots
  Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
  Version: 0.0.0
  
  Phone extension.
  When using this extension make sure you specify the correct url to get the masks
  
   $(selector).inputmask("phone", {
                  url: "Scripts/jquery.inputmask/phone-codes/phone-codes.json", 
                  onKeyValidation: function () { //show some metadata in the console
                      console.log($(this).inputmask("getmetadata")["name_en"]);
                  } 
    });
  
  
  */
  (function ($) {
      $.extend($.inputmask.defaults.aliases, {
          'phone': {
              url: "phone-codes/phone-codes.json",
              mask: function (opts) {
                  opts.definitions = {
                      'p': {
                          validator: function () { return false; },
                          cardinality: 1
                      },
                      '#': {
                          validator: "[0-9]",
                          cardinality: 1
                      }
                  };
                  var maskList = [];
                  $.ajax({
                      url: opts.url,
                      async: false,
                      dataType: 'json',
                      success: function (response) {
                          maskList = response;
                      }
                  });
      
                  maskList.splice(0, 0, "+p(ppp)ppp-pppp");
                  return maskList;
              }
          }
      });
  })(jQuery);
  
  /*
  Input Mask plugin extensions
  http://github.com/RobinHerbots/jquery.inputmask
  Copyright (c) 2010 - 2014 Robin Herbots
  Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
  Version: 0.0.0
  
  Regex extensions on the jquery.inputmask base
  Allows for using regular expressions as a mask
  */
  (function ($) {
      $.extend($.inputmask.defaults.aliases, { // $(selector).inputmask("Regex", { regex: "[0-9]*"}
          'Regex': {
              mask: "r",
              greedy: false,
              repeat: "*",
              regex: null,
              regexTokens: null,
              //Thx to https://github.com/slevithan/regex-colorizer for the tokenizer regex
              tokenizer: /\[\^?]?(?:[^\\\]]+|\\[\S\s]?)*]?|\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9][0-9]*|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|c[A-Za-z]|[\S\s]?)|\((?:\?[:=!]?)?|(?:[?*+]|\{[0-9]+(?:,[0-9]*)?\})\??|[^.?*+^${[()|\\]+|./g,
              quantifierFilter: /[0-9]+[^,]/,
              definitions: {
                  'r': {
                      validator: function (chrs, buffer, pos, strict, opts) {
                          function regexToken() {
                              this.matches = [];
                              this.isGroup = false;
                              this.isQuantifier = false;
                              this.isLiteral = false;
                          }
                          function analyseRegex() {
                              var currentToken = new regexToken(), match, m, opengroups = [];
  
                              opts.regexTokens = [];
  
                              // The tokenizer regex does most of the tokenization grunt work
                              while (match = opts.tokenizer.exec(opts.regex)) {
                                  m = match[0];
                                  switch (m.charAt(0)) {
                                      case "[": // Character class
                                      case "\\":  // Escape or backreference
                                          if (opengroups.length > 0) {
                                              opengroups[opengroups.length - 1]["matches"].push(m);
                                          } else {
                                              currentToken.matches.push(m);
                                          }
                                          break;
                                      case "(": // Group opening
                                          if (!currentToken.isGroup && currentToken.matches.length > 0)
                                              opts.regexTokens.push(currentToken);
                                          currentToken = new regexToken();
                                          currentToken.isGroup = true;
                                          opengroups.push(currentToken);
                                          break;
                                      case ")": // Group closing
                                          var groupToken = opengroups.pop();
                                          if (opengroups.length > 0) {
                                              opengroups[opengroups.length - 1]["matches"].push(groupToken);
                                          } else {
                                              opts.regexTokens.push(groupToken);
                                              currentToken = new regexToken();
                                          }
                                          break;
                                      case "{": //Quantifier
                                          var quantifier = new regexToken();
                                          quantifier.isQuantifier = true;
                                          quantifier.matches.push(m);
                                          if (opengroups.length > 0) {
                                              opengroups[opengroups.length - 1]["matches"].push(quantifier);
                                          } else {
                                              currentToken.matches.push(quantifier);
                                          }
                                          break;
                                      default:
                                          // Vertical bar (alternator) 
                                          // ^ or $ anchor
                                          // Dot (.)
                                          // Literal character sequence
                                          var literal = new regexToken();
                                          literal.isLiteral = true;
                                          literal.matches.push(m);
                                          if (opengroups.length > 0) {
                                              opengroups[opengroups.length - 1]["matches"].push(literal);
                                          } else {
                                              currentToken.matches.push(literal);
                                          }
                                  }
                              }
  
                              if (currentToken.matches.length > 0)
                                  opts.regexTokens.push(currentToken);
                          }
                          function validateRegexToken(token, fromGroup) {
                              var isvalid = false;
                              if (fromGroup) {
                                  regexPart += "(";
                                  openGroupCount++;
                              }
                              for (var mndx = 0; mndx < token["matches"].length; mndx++) {
                                  var matchToken = token["matches"][mndx];
                                  if (matchToken["isGroup"] == true) {
                                      isvalid = validateRegexToken(matchToken, true);
                                  } else if (matchToken["isQuantifier"] == true) {
                                      matchToken = matchToken["matches"][0];
                                      var quantifierMax = opts.quantifierFilter.exec(matchToken)[0].replace("}", "");
                                      var testExp = regexPart + "{1," + quantifierMax + "}"; //relax quantifier validation
                                      for (var j = 0; j < openGroupCount; j++) {
                                          testExp += ")";
                                      }
                                      var exp = new RegExp("^(" + testExp + ")$");
                                      isvalid = exp.test(bufferStr);
                                      regexPart += matchToken;
                                  } else if (matchToken["isLiteral"] == true) {
                                      matchToken = matchToken["matches"][0];
                                      var testExp = regexPart, openGroupCloser = "";
                                      for (var j = 0; j < openGroupCount; j++) {
                                          openGroupCloser += ")";
                                      }
                                      for (var k = 0; k < matchToken.length; k++) { //relax literal validation
                                          testExp = (testExp + matchToken[k]).replace(/\|$/, "");
                                          var exp = new RegExp("^(" + testExp + openGroupCloser + ")$");
                                          isvalid = exp.test(bufferStr);
                                          if (isvalid) break;
                                      }
                                      regexPart += matchToken;
                                      //console.log(bufferStr + " " + exp + " " + isvalid);
                                  } else {
                                      regexPart += matchToken;
                                      var testExp = regexPart.replace(/\|$/, "");
                                      for (var j = 0; j < openGroupCount; j++) {
                                          testExp += ")";
                                      }
                                      var exp = new RegExp("^(" + testExp + ")$");
                                      isvalid = exp.test(bufferStr);
                                      //console.log(bufferStr + " " + exp + " " + isvalid);
                                  }
                                  if (isvalid) break;
                              }
  
                              if (fromGroup) {
                                  regexPart += ")";
                                  openGroupCount--;
                              }
  
                              return isvalid;
                          }
  
  
                          if (opts.regexTokens == null) {
                              analyseRegex();
                          }
  
                          var cbuffer = buffer.slice(), regexPart = "", isValid = false, openGroupCount = 0;
                          cbuffer.splice(pos, 0, chrs);
                          var bufferStr = cbuffer.join('');
                          for (var i = 0; i < opts.regexTokens.length; i++) {
                              var regexToken = opts.regexTokens[i];
                              isValid = validateRegexToken(regexToken, regexToken["isGroup"]);
                              if (isValid) break;
                          }
  
                          return isValid;
                      },
                      cardinality: 1
                  }
              }
          }
      });
  })(jQuery);
  
  /*
   *  jquery-maskmoney - v3.0.2
   *  jQuery plugin to mask data entry in the input text in the form of money (currency)
   *  https://github.com/plentz/jquery-maskmoney
   *
   *  Made by Diego Plentz
   *  Under MIT License (https://raw.github.com/plentz/jquery-maskmoney/master/LICENSE)
   */
  !function($){"use strict";$.browser||($.browser={},$.browser.mozilla=/mozilla/.test(navigator.userAgent.toLowerCase())&&!/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.webkit=/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.opera=/opera/.test(navigator.userAgent.toLowerCase()),$.browser.msie=/msie/.test(navigator.userAgent.toLowerCase()));var a={destroy:function(){return $(this).unbind(".maskMoney"),$.browser.msie&&(this.onpaste=null),this},mask:function(a){return this.each(function(){var b,c=$(this);return"number"==typeof a&&(c.trigger("mask"),b=$(c.val().split(/\D/)).last()[0].length,a=a.toFixed(b),c.val(a)),c.trigger("mask")})},unmasked:function(){return this.map(function(){var a,b=$(this).val()||"0",c=-1!==b.indexOf("-");return $(b.split(/\D/).reverse()).each(function(b,c){return c?(a=c,!1):void 0}),b=b.replace(/\D/g,""),b=b.replace(new RegExp(a+"$"),"."+a),c&&(b="-"+b),parseFloat(b)})},init:function(a){return a=$.extend({prefix:"",suffix:"",affixesStay:!0,thousands:",",decimal:".",precision:2,allowZero:!1,allowNegative:!1},a),this.each(function(){function b(){var a,b,c,d,e,f=s.get(0),g=0,h=0;return"number"==typeof f.selectionStart&&"number"==typeof f.selectionEnd?(g=f.selectionStart,h=f.selectionEnd):(b=document.selection.createRange(),b&&b.parentElement()===f&&(d=f.value.length,a=f.value.replace(/\r\n/g,"\n"),c=f.createTextRange(),c.moveToBookmark(b.getBookmark()),e=f.createTextRange(),e.collapse(!1),c.compareEndPoints("StartToEnd",e)>-1?g=h=d:(g=-c.moveStart("character",-d),g+=a.slice(0,g).split("\n").length-1,c.compareEndPoints("EndToEnd",e)>-1?h=d:(h=-c.moveEnd("character",-d),h+=a.slice(0,h).split("\n").length-1)))),{start:g,end:h}}function c(){var a=!(s.val().length>=s.attr("maxlength")&&s.attr("maxlength")>=0),c=b(),d=c.start,e=c.end,f=c.start!==c.end&&s.val().substring(d,e).match(/\d/)?!0:!1,g="0"===s.val().substring(0,1);return a||f||g}function d(a){s.each(function(b,c){if(c.setSelectionRange)c.focus(),c.setSelectionRange(a,a);else if(c.createTextRange){var d=c.createTextRange();d.collapse(!0),d.moveEnd("character",a),d.moveStart("character",a),d.select()}})}function e(b){var c="";return b.indexOf("-")>-1&&(b=b.replace("-",""),c="-"),c+a.prefix+b+a.suffix}function f(b){var c,d,f,g=b.indexOf("-")>-1&&a.allowNegative?"-":"",h=b.replace(/[^0-9]/g,""),i=h.slice(0,h.length-a.precision);return i=i.replace(/^0*/g,""),i=i.replace(/\B(?=(\d{3})+(?!\d))/g,a.thousands),""===i&&(i="0"),c=g+i,a.precision>0&&(d=h.slice(h.length-a.precision),f=new Array(a.precision+1-d.length).join(0),c+=a.decimal+f+d),e(c)}function g(a){var b,c=s.val().length;s.val(f(s.val())),b=s.val().length,a-=c-b,d(a)}function h(){var a=s.val();s.val(f(a))}function i(){var b=s.val();return a.allowNegative?""!==b&&"-"===b.charAt(0)?b.replace("-",""):"-"+b:b}function j(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function k(a){a=a||window.event;var d,e,f,h,k,l=a.which||a.charCode||a.keyCode;return void 0===l?!1:48>l||l>57?45===l?(s.val(i()),!1):43===l?(s.val(s.val().replace("-","")),!1):13===l||9===l?!0:!$.browser.mozilla||37!==l&&39!==l||0!==a.charCode?(j(a),!0):!0:c()?(j(a),d=String.fromCharCode(l),e=b(),f=e.start,h=e.end,k=s.val(),s.val(k.substring(0,f)+d+k.substring(h,k.length)),g(f+1),!1):!1}function l(c){c=c||window.event;var d,e,f,h,i,k=c.which||c.charCode||c.keyCode;return void 0===k?!1:(d=b(),e=d.start,f=d.end,8===k||46===k||63272===k?(j(c),h=s.val(),e===f&&(8===k?""===a.suffix?e-=1:(i=h.split("").reverse().join("").search(/\d/),e=h.length-i-1,f=e+1):f+=1),s.val(h.substring(0,e)+h.substring(f,h.length)),g(e),!1):9===k?!0:!0)}function m(){r=s.val(),h();var a,b=s.get(0);b.createTextRange&&(a=b.createTextRange(),a.collapse(!1),a.select())}function n(){setTimeout(function(){h()},0)}function o(){var b=parseFloat("0")/Math.pow(10,a.precision);return b.toFixed(a.precision).replace(new RegExp("\\.","g"),a.decimal)}function p(b){if($.browser.msie&&k(b),""===s.val()||s.val()===e(o()))a.allowZero?a.affixesStay?s.val(e(o())):s.val(o()):s.val("");else if(!a.affixesStay){var c=s.val().replace(a.prefix,"").replace(a.suffix,"");s.val(c)}s.val()!==r&&s.change()}function q(){var a,b=s.get(0);b.setSelectionRange?(a=s.val().length,b.setSelectionRange(a,a)):s.val(s.val())}var r,s=$(this);a=$.extend(a,s.data()),s.unbind(".maskMoney"),s.bind("keypress.maskMoney",k),s.bind("keydown.maskMoney",l),s.bind("blur.maskMoney",p),s.bind("focus.maskMoney",m),s.bind("click.maskMoney",q),s.bind("cut.maskMoney",n),s.bind("paste.maskMoney",n),s.bind("mask.maskMoney",h)})}};$.fn.maskMoney=function(b){return a[b]?a[b].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof b&&b?($.error("Method "+b+" does not exist on jQuery.maskMoney"),void 0):a.init.apply(this,arguments)}}(window.jQuery||window.Zepto);
  /**
  * @version: 2.1.19
  * @author: Dan Grossman http://www.dangrossman.info/
  * @copyright: Copyright (c) 2012-2015 Dan Grossman. All rights reserved.
  * @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php
  * @website: https://www.improvely.com/
  */
  
  (function(root, factory) {
  
    if (typeof define === 'function' && define.amd) {
      define(['moment', 'jquery', 'exports'], function(momentjs, $, exports) {
        root.daterangepicker = factory(root, exports, momentjs, $);
      });
  
    } else if (typeof exports !== 'undefined') {
        var momentjs = require('moment');
        var jQuery = (typeof window != 'undefined') ? window.jQuery : undefined;  //isomorphic issue
        if (!jQuery) {
            try {
                jQuery = require('jquery');
                if (!jQuery.fn) jQuery.fn = {}; //isomorphic issue
            } catch (err) {
                if (!jQuery) throw new Error('jQuery dependency not found');
            }
        }
  
      factory(root, exports, momentjs, jQuery);
  
    // Finally, as a browser global.
    } else {
      root.daterangepicker = factory(root, {}, root.moment || moment, (root.jQuery || root.Zepto || root.ender || root.$));
    }
  
  }(this || {}, function(root, daterangepicker, moment, $) { // 'this' doesn't exist on a server
  
      var DateRangePicker = function(element, options, cb) {
  
          //default settings for options
          this.parentEl = 'body';
          this.element = $(element);
          this.startDate = moment().startOf('day');
          this.endDate = moment().endOf('day');
          this.minDate = false;
          this.maxDate = false;
          this.dateLimit = false;
          this.autoApply = false;
          this.singleDatePicker = false;
          this.showDropdowns = false;
          this.showWeekNumbers = false;
          this.showISOWeekNumbers = false;
          this.timePicker = false;
          this.timePicker24Hour = false;
          this.timePickerIncrement = 1;
          this.timePickerSeconds = false;
          this.linkedCalendars = true;
          this.autoUpdateInput = true;
          this.alwaysShowCalendars = false;
          this.ranges = {};
  
          this.opens = 'right';
          if (this.element.hasClass('pull-right'))
              this.opens = 'left';
  
          this.drops = 'down';
          if (this.element.hasClass('dropup'))
              this.drops = 'up';
  
          this.buttonClasses = 'btn btn-sm';
          this.applyClass = 'btn-success';
          this.cancelClass = 'btn-default';
  
          this.locale = {
              format: 'MM/DD/YYYY',
              separator: ' - ',
              applyLabel: 'Apply',
              cancelLabel: 'Cancel',
              weekLabel: 'W',
              customRangeLabel: 'Custom Range',
              daysOfWeek: moment.weekdaysMin(),
              monthNames: moment.monthsShort(),
              firstDay: moment.localeData().firstDayOfWeek()
          };
  
          this.callback = function() { };
  
          //some state information
          this.isShowing = false;
          this.leftCalendar = {};
          this.rightCalendar = {};
  
          //custom options from user
          if (typeof options !== 'object' || options === null)
              options = {};
  
          //allow setting options with data attributes
          //data-api options will be overwritten with custom javascript options
          options = $.extend(this.element.data(), options);
  
          //html template for the picker UI
          if (typeof options.template !== 'string' && !(options.template instanceof $))
              options.template = '<div class="daterangepicker dropdown-menu">' +
                  '<div class="calendar left">' +
                      '<div class="daterangepicker_input">' +
                        '<input class="input-mini" type="text" name="daterangepicker_start" value="" />' +
                        '<i class="fa fa-calendar glyphicon glyphicon-calendar"></i>' +
                        '<div class="calendar-time">' +
                          '<div></div>' +
                          '<i class="fa fa-clock-o glyphicon glyphicon-time"></i>' +
                        '</div>' +
                      '</div>' +
                      '<div class="calendar-table"></div>' +
                  '</div>' +
                  '<div class="calendar right">' +
                      '<div class="daterangepicker_input">' +
                        '<input class="input-mini" type="text" name="daterangepicker_end" value="" />' +
                        '<i class="fa fa-calendar glyphicon glyphicon-calendar"></i>' +
                        '<div class="calendar-time">' +
                          '<div></div>' +
                          '<i class="fa fa-clock-o glyphicon glyphicon-time"></i>' +
                        '</div>' +
                      '</div>' +
                      '<div class="calendar-table"></div>' +
                  '</div>' +
                  '<div class="ranges">' +
                      '<div class="range_inputs">' +
                          '<button class="applyBtn" disabled="disabled" type="button"></button> ' +
                          '<button class="cancelBtn" type="button"></button>' +
                      '</div>' +
                  '</div>' +
              '</div>';
  
          this.parentEl = (options.parentEl && $(options.parentEl).length) ? $(options.parentEl) : $(this.parentEl);
          this.container = $(options.template).appendTo(this.parentEl);
  
          //
          // handle all the possible options overriding defaults
          //
  
          if (typeof options.locale === 'object') {
  
              if (typeof options.locale.format === 'string')
                  this.locale.format = options.locale.format;
  
              if (typeof options.locale.separator === 'string')
                  this.locale.separator = options.locale.separator;
  
              if (typeof options.locale.daysOfWeek === 'object')
                  this.locale.daysOfWeek = options.locale.daysOfWeek.slice();
  
              if (typeof options.locale.monthNames === 'object')
                this.locale.monthNames = options.locale.monthNames.slice();
  
              if (typeof options.locale.firstDay === 'number')
                this.locale.firstDay = options.locale.firstDay;
  
              if (typeof options.locale.applyLabel === 'string')
                this.locale.applyLabel = options.locale.applyLabel;
  
              if (typeof options.locale.cancelLabel === 'string')
                this.locale.cancelLabel = options.locale.cancelLabel;
  
              if (typeof options.locale.weekLabel === 'string')
                this.locale.weekLabel = options.locale.weekLabel;
  
              if (typeof options.locale.customRangeLabel === 'string')
                this.locale.customRangeLabel = options.locale.customRangeLabel;
  
          }
  
          if (typeof options.startDate === 'string')
              this.startDate = moment(options.startDate, this.locale.format);
  
          if (typeof options.endDate === 'string')
              this.endDate = moment(options.endDate, this.locale.format);
  
          if (typeof options.minDate === 'string')
              this.minDate = moment(options.minDate, this.locale.format);
  
          if (typeof options.maxDate === 'string')
              this.maxDate = moment(options.maxDate, this.locale.format);
  
          if (typeof options.startDate === 'object')
              this.startDate = moment(options.startDate);
  
          if (typeof options.endDate === 'object')
              this.endDate = moment(options.endDate);
  
          if (typeof options.minDate === 'object')
              this.minDate = moment(options.minDate);
  
          if (typeof options.maxDate === 'object')
              this.maxDate = moment(options.maxDate);
  
          // sanity check for bad options
          if (this.minDate && this.startDate.isBefore(this.minDate))
              this.startDate = this.minDate.clone();
  
          // sanity check for bad options
          if (this.maxDate && this.endDate.isAfter(this.maxDate))
              this.endDate = this.maxDate.clone();
  
          if (typeof options.applyClass === 'string')
              this.applyClass = options.applyClass;
  
          if (typeof options.cancelClass === 'string')
              this.cancelClass = options.cancelClass;
  
          if (typeof options.dateLimit === 'object')
              this.dateLimit = options.dateLimit;
  
          if (typeof options.opens === 'string')
              this.opens = options.opens;
  
          if (typeof options.drops === 'string')
              this.drops = options.drops;
  
          if (typeof options.showWeekNumbers === 'boolean')
              this.showWeekNumbers = options.showWeekNumbers;
  
          if (typeof options.showISOWeekNumbers === 'boolean')
              this.showISOWeekNumbers = options.showISOWeekNumbers;
  
          if (typeof options.buttonClasses === 'string')
              this.buttonClasses = options.buttonClasses;
  
          if (typeof options.buttonClasses === 'object')
              this.buttonClasses = options.buttonClasses.join(' ');
  
          if (typeof options.showDropdowns === 'boolean')
              this.showDropdowns = options.showDropdowns;
  
          if (typeof options.singleDatePicker === 'boolean') {
              this.singleDatePicker = options.singleDatePicker;
              if (this.singleDatePicker)
                  this.endDate = this.startDate.clone();
          }
  
          if (typeof options.timePicker === 'boolean')
              this.timePicker = options.timePicker;
  
          if (typeof options.timePickerSeconds === 'boolean')
              this.timePickerSeconds = options.timePickerSeconds;
  
          if (typeof options.timePickerIncrement === 'number')
              this.timePickerIncrement = options.timePickerIncrement;
  
          if (typeof options.timePicker24Hour === 'boolean')
              this.timePicker24Hour = options.timePicker24Hour;
  
          if (typeof options.autoApply === 'boolean')
              this.autoApply = options.autoApply;
  
          if (typeof options.autoUpdateInput === 'boolean')
              this.autoUpdateInput = options.autoUpdateInput;
  
          if (typeof options.linkedCalendars === 'boolean')
              this.linkedCalendars = options.linkedCalendars;
  
          if (typeof options.isInvalidDate === 'function')
              this.isInvalidDate = options.isInvalidDate;
  
          if (typeof options.alwaysShowCalendars === 'boolean')
              this.alwaysShowCalendars = options.alwaysShowCalendars;
  
          // update day names order to firstDay
          if (this.locale.firstDay != 0) {
              var iterator = this.locale.firstDay;
              while (iterator > 0) {
                  this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift());
                  iterator--;
              }
          }
  
          var start, end, range;
  
          //if no start/end dates set, check if an input element contains initial values
          if (typeof options.startDate === 'undefined' && typeof options.endDate === 'undefined') {
              if ($(this.element).is('input[type=text]')) {
                  var val = $(this.element).val(),
                      split = val.split(this.locale.separator);
  
                  start = end = null;
  
                  if (split.length == 2) {
                      start = moment(split[0], this.locale.format);
                      end = moment(split[1], this.locale.format);
                  } else if (this.singleDatePicker && val !== "") {
                      start = moment(val, this.locale.format);
                      end = moment(val, this.locale.format);
                  }
                  if (start !== null && end !== null) {
                      this.setStartDate(start);
                      this.setEndDate(end);
                  }
              }
          }
  
          if (typeof options.ranges === 'object') {
              for (range in options.ranges) {
  
                  if (typeof options.ranges[range][0] === 'string')
                      start = moment(options.ranges[range][0], this.locale.format);
                  else
                      start = moment(options.ranges[range][0]);
  
                  if (typeof options.ranges[range][1] === 'string')
                      end = moment(options.ranges[range][1], this.locale.format);
                  else
                      end = moment(options.ranges[range][1]);
  
                  // If the start or end date exceed those allowed by the minDate or dateLimit
                  // options, shorten the range to the allowable period.
                  if (this.minDate && start.isBefore(this.minDate))
                      start = this.minDate.clone();
  
                  var maxDate = this.maxDate;
                  if (this.dateLimit && start.clone().add(this.dateLimit).isAfter(maxDate))
                      maxDate = start.clone().add(this.dateLimit);
                  if (maxDate && end.isAfter(maxDate))
                      end = maxDate.clone();
  
                  // If the end of the range is before the minimum or the start of the range is
                  // after the maximum, don't display this range option at all.
                  if ((this.minDate && end.isBefore(this.minDate)) || (maxDate && start.isAfter(maxDate)))
                      continue;
                  
                  //Support unicode chars in the range names.
                  var elem = document.createElement('textarea');
                  elem.innerHTML = range;
                  var rangeHtml = elem.value;
  
                  this.ranges[rangeHtml] = [start, end];
              }
  
              var list = '<ul>';
              for (range in this.ranges) {
                  list += '<li>' + range + '</li>';
              }
              list += '<li>' + this.locale.customRangeLabel + '</li>';
              list += '</ul>';
              this.container.find('.ranges').prepend(list);
          }
  
          if (typeof cb === 'function') {
              this.callback = cb;
          }
  
          if (!this.timePicker) {
              this.startDate = this.startDate.startOf('day');
              this.endDate = this.endDate.endOf('day');
              this.container.find('.calendar-time').hide();
          }
  
          //can't be used together for now
          if (this.timePicker && this.autoApply)
              this.autoApply = false;
  
          if (this.autoApply && typeof options.ranges !== 'object') {
              this.container.find('.ranges').hide();
          } else if (this.autoApply) {
              this.container.find('.applyBtn, .cancelBtn').addClass('hide');
          }
  
          if (this.singleDatePicker) {
              this.container.addClass('single');
              this.container.find('.calendar.left').addClass('single');
              this.container.find('.calendar.left').show();
              this.container.find('.calendar.right').hide();
              this.container.find('.daterangepicker_input input, .daterangepicker_input i').hide();
              if (!this.timePicker) {
                  this.container.find('.ranges').hide();
              }
          }
  
          if ((typeof options.ranges === 'undefined' && !this.singleDatePicker) || this.alwaysShowCalendars) {
              this.container.addClass('show-calendar');
          }
  
          this.container.addClass('opens' + this.opens);
  
          //swap the position of the predefined ranges if opens right
          if (typeof options.ranges !== 'undefined' && this.opens == 'right') {
              var ranges = this.container.find('.ranges');
              var html = ranges.clone();
              ranges.remove();
              this.container.find('.calendar.left').parent().prepend(html);
          }
  
          //apply CSS classes and labels to buttons
          this.container.find('.applyBtn, .cancelBtn').addClass(this.buttonClasses);
          if (this.applyClass.length)
              this.container.find('.applyBtn').addClass(this.applyClass);
          if (this.cancelClass.length)
              this.container.find('.cancelBtn').addClass(this.cancelClass);
          this.container.find('.applyBtn').html(this.locale.applyLabel);
          this.container.find('.cancelBtn').html(this.locale.cancelLabel);
  
          //
          // event listeners
          //
  
          this.container.find('.calendar')
              .on('click.daterangepicker', '.prev', $.proxy(this.clickPrev, this))
              .on('click.daterangepicker', '.next', $.proxy(this.clickNext, this))
              .on('click.daterangepicker', 'td.available', $.proxy(this.clickDate, this))
              .on('mouseenter.daterangepicker', 'td.available', $.proxy(this.hoverDate, this))
              .on('mouseleave.daterangepicker', 'td.available', $.proxy(this.updateFormInputs, this))
              .on('change.daterangepicker', 'select.yearselect', $.proxy(this.monthOrYearChanged, this))
              .on('change.daterangepicker', 'select.monthselect', $.proxy(this.monthOrYearChanged, this))
              .on('change.daterangepicker', 'select.hourselect,select.minuteselect,select.secondselect,select.ampmselect', $.proxy(this.timeChanged, this))
              .on('click.daterangepicker', '.daterangepicker_input input', $.proxy(this.showCalendars, this))
              //.on('keyup.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsChanged, this))
              .on('change.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsChanged, this));
  
          this.container.find('.ranges')
              .on('click.daterangepicker', 'button.applyBtn', $.proxy(this.clickApply, this))
              .on('click.daterangepicker', 'button.cancelBtn', $.proxy(this.clickCancel, this))
              .on('click.daterangepicker', 'li', $.proxy(this.clickRange, this))
              .on('mouseenter.daterangepicker', 'li', $.proxy(this.hoverRange, this))
              .on('mouseleave.daterangepicker', 'li', $.proxy(this.updateFormInputs, this));
  
          if (this.element.is('input')) {
              this.element.on({
                  'click.daterangepicker': $.proxy(this.show, this),
                  'focus.daterangepicker': $.proxy(this.show, this),
                  'keyup.daterangepicker': $.proxy(this.elementChanged, this),
                  'keydown.daterangepicker': $.proxy(this.keydown, this)
              });
          } else {
              this.element.on('click.daterangepicker', $.proxy(this.toggle, this));
          }
  
          //
          // if attached to a text input, set the initial value
          //
  
          if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput) {
              this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
              this.element.trigger('change');
          } else if (this.element.is('input') && this.autoUpdateInput) {
              this.element.val(this.startDate.format(this.locale.format));
              this.element.trigger('change');
          }
  
      };
  
      DateRangePicker.prototype = {
  
          constructor: DateRangePicker,
  
          setStartDate: function(startDate) {
              if (typeof startDate === 'string')
                  this.startDate = moment(startDate, this.locale.format);
  
              if (typeof startDate === 'object')
                  this.startDate = moment(startDate);
  
              if (!this.timePicker)
                  this.startDate = this.startDate.startOf('day');
  
              if (this.timePicker && this.timePickerIncrement)
                  this.startDate.minute(Math.round(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
  
              if (this.minDate && this.startDate.isBefore(this.minDate))
                  this.startDate = this.minDate;
  
              if (this.maxDate && this.startDate.isAfter(this.maxDate))
                  this.startDate = this.maxDate;
  
              if (!this.isShowing)
                  this.updateElement();
  
              this.updateMonthsInView();
          },
  
          setEndDate: function(endDate) {
              if (typeof endDate === 'string')
                  this.endDate = moment(endDate, this.locale.format);
  
              if (typeof endDate === 'object')
                  this.endDate = moment(endDate);
  
              if (!this.timePicker)
                  this.endDate = this.endDate.endOf('day');
  
              if (this.timePicker && this.timePickerIncrement)
                  this.endDate.minute(Math.round(this.endDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
  
              if (this.endDate.isBefore(this.startDate))
                  this.endDate = this.startDate.clone();
  
              if (this.maxDate && this.endDate.isAfter(this.maxDate))
                  this.endDate = this.maxDate;
  
              if (this.dateLimit && this.startDate.clone().add(this.dateLimit).isBefore(this.endDate))
                  this.endDate = this.startDate.clone().add(this.dateLimit);
  
              this.previousRightTime = this.endDate.clone();
  
              if (!this.isShowing)
                  this.updateElement();
  
              this.updateMonthsInView();
          },
  
          isInvalidDate: function() {
              return false;
          },
  
          updateView: function() {
              if (this.timePicker) {
                  this.renderTimePicker('left');
                  this.renderTimePicker('right');
                  if (!this.endDate) {
                      this.container.find('.right .calendar-time select').attr('disabled', 'disabled').addClass('disabled');
                  } else {
                      this.container.find('.right .calendar-time select').removeAttr('disabled').removeClass('disabled');
                  }
              }
              if (this.endDate) {
                  this.container.find('input[name="daterangepicker_end"]').removeClass('active');
                  this.container.find('input[name="daterangepicker_start"]').addClass('active');
              } else {
                  this.container.find('input[name="daterangepicker_end"]').addClass('active');
                  this.container.find('input[name="daterangepicker_start"]').removeClass('active');
              }
              this.updateMonthsInView();
              this.updateCalendars();
              this.updateFormInputs();
          },
  
          updateMonthsInView: function() {
              if (this.endDate) {
  
                  //if both dates are visible already, do nothing
                  if (!this.singleDatePicker && this.leftCalendar.month && this.rightCalendar.month &&
                      (this.startDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.startDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM'))
                      &&
                      (this.endDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.endDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM'))
                      ) {
                      return;
                  }
  
                  this.leftCalendar.month = this.startDate.clone().date(2);
                  if (!this.linkedCalendars && (this.endDate.month() != this.startDate.month() || this.endDate.year() != this.startDate.year())) {
                      this.rightCalendar.month = this.endDate.clone().date(2);
                  } else {
                      this.rightCalendar.month = this.startDate.clone().date(2).add(1, 'month');
                  }
                  
              } else {
                  if (this.leftCalendar.month.format('YYYY-MM') != this.startDate.format('YYYY-MM') && this.rightCalendar.month.format('YYYY-MM') != this.startDate.format('YYYY-MM')) {
                      this.leftCalendar.month = this.startDate.clone().date(2);
                      this.rightCalendar.month = this.startDate.clone().date(2).add(1, 'month');
                  }
              }
          },
  
          updateCalendars: function() {
  
              if (this.timePicker) {
                  var hour, minute, second;
                  if (this.endDate) {
                      hour = parseInt(this.container.find('.left .hourselect').val(), 10);
                      minute = parseInt(this.container.find('.left .minuteselect').val(), 10);
                      second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0;
                      if (!this.timePicker24Hour) {
                          var ampm = this.container.find('.left .ampmselect').val();
                          if (ampm === 'PM' && hour < 12)
                              hour += 12;
                          if (ampm === 'AM' && hour === 12)
                              hour = 0;
                      }
                  } else {
                      hour = parseInt(this.container.find('.right .hourselect').val(), 10);
                      minute = parseInt(this.container.find('.right .minuteselect').val(), 10);
                      second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0;
                      if (!this.timePicker24Hour) {
                          var ampm = this.container.find('.right .ampmselect').val();
                          if (ampm === 'PM' && hour < 12)
                              hour += 12;
                          if (ampm === 'AM' && hour === 12)
                              hour = 0;
                      }
                  }
                  this.leftCalendar.month.hour(hour).minute(minute).second(second);
                  this.rightCalendar.month.hour(hour).minute(minute).second(second);
              }
  
              this.renderCalendar('left');
              this.renderCalendar('right');
  
              //highlight any predefined range matching the current start and end dates
              this.container.find('.ranges li').removeClass('active');
              if (this.endDate == null) return;
  
              this.calculateChosenLabel();
          },
  
          renderCalendar: function(side) {
  
              //
              // Build the matrix of dates that will populate the calendar
              //
  
              var calendar = side == 'left' ? this.leftCalendar : this.rightCalendar;
              var month = calendar.month.month();
              var year = calendar.month.year();
              var hour = calendar.month.hour();
              var minute = calendar.month.minute();
              var second = calendar.month.second();
              var daysInMonth = moment([year, month]).daysInMonth();
              var firstDay = moment([year, month, 1]);
              var lastDay = moment([year, month, daysInMonth]);
              var lastMonth = moment(firstDay).subtract(1, 'month').month();
              var lastYear = moment(firstDay).subtract(1, 'month').year();
              var daysInLastMonth = moment([lastYear, lastMonth]).daysInMonth();
              var dayOfWeek = firstDay.day();
  
              //initialize a 6 rows x 7 columns array for the calendar
              var calendar = [];
              calendar.firstDay = firstDay;
              calendar.lastDay = lastDay;
  
              for (var i = 0; i < 6; i++) {
                  calendar[i] = [];
              }
  
              //populate the calendar with date objects
              var startDay = daysInLastMonth - dayOfWeek + this.locale.firstDay + 1;
              if (startDay > daysInLastMonth)
                  startDay -= 7;
  
              if (dayOfWeek == this.locale.firstDay)
                  startDay = daysInLastMonth - 6;
  
              var curDate = moment([lastYear, lastMonth, startDay, 12, minute, second]);
  
              var col, row;
              for (var i = 0, col = 0, row = 0; i < 42; i++, col++, curDate = moment(curDate).add(24, 'hour')) {
                  if (i > 0 && col % 7 === 0) {
                      col = 0;
                      row++;
                  }
                  calendar[row][col] = curDate.clone().hour(hour).minute(minute).second(second);
                  curDate.hour(12);
  
                  if (this.minDate && calendar[row][col].format('YYYY-MM-DD') == this.minDate.format('YYYY-MM-DD') && calendar[row][col].isBefore(this.minDate) && side == 'left') {
                      calendar[row][col] = this.minDate.clone();
                  }
  
                  if (this.maxDate && calendar[row][col].format('YYYY-MM-DD') == this.maxDate.format('YYYY-MM-DD') && calendar[row][col].isAfter(this.maxDate) && side == 'right') {
                      calendar[row][col] = this.maxDate.clone();
                  }
  
              }
  
              //make the calendar object available to hoverDate/clickDate
              if (side == 'left') {
                  this.leftCalendar.calendar = calendar;
              } else {
                  this.rightCalendar.calendar = calendar;
              }
  
              //
              // Display the calendar
              //
  
              var minDate = side == 'left' ? this.minDate : this.startDate;
              var maxDate = this.maxDate;
              var selected = side == 'left' ? this.startDate : this.endDate;
  
              var html = '<table class="table-condensed">';
              html += '<thead>';
              html += '<tr>';
  
              // add empty cell for week number
              if (this.showWeekNumbers || this.showISOWeekNumbers)
                  html += '<th></th>';
  
              if ((!minDate || minDate.isBefore(calendar.firstDay)) && (!this.linkedCalendars || side == 'left')) {
                  html += '<th class="prev available"><i class="fa fa-chevron-left glyphicon glyphicon-chevron-left"></i></th>';
              } else {
                  html += '<th></th>';
              }
  
              var dateHtml = this.locale.monthNames[calendar[1][1].month()] + calendar[1][1].format(" YYYY");
  
              if (this.showDropdowns) {
                  var currentMonth = calendar[1][1].month();
                  var currentYear = calendar[1][1].year();
                  var maxYear = (maxDate && maxDate.year()) || (currentYear + 5);
                  var minYear = (minDate && minDate.year()) || (currentYear - 50);
                  var inMinYear = currentYear == minYear;
                  var inMaxYear = currentYear == maxYear;
  
                  var monthHtml = '<select class="monthselect">';
                  for (var m = 0; m < 12; m++) {
                      if ((!inMinYear || m >= minDate.month()) && (!inMaxYear || m <= maxDate.month())) {
                          monthHtml += "<option value='" + m + "'" +
                              (m === currentMonth ? " selected='selected'" : "") +
                              ">" + this.locale.monthNames[m] + "</option>";
                      } else {
                          monthHtml += "<option value='" + m + "'" +
                              (m === currentMonth ? " selected='selected'" : "") +
                              " disabled='disabled'>" + this.locale.monthNames[m] + "</option>";
                      }
                  }
                  monthHtml += "</select>";
  
                  var yearHtml = '<select class="yearselect">';
                  for (var y = minYear; y <= maxYear; y++) {
                      yearHtml += '<option value="' + y + '"' +
                          (y === currentYear ? ' selected="selected"' : '') +
                          '>' + y + '</option>';
                  }
                  yearHtml += '</select>';
  
                  dateHtml = monthHtml + yearHtml;
              }
  
              html += '<th colspan="5" class="month">' + dateHtml + '</th>';
              if ((!maxDate || maxDate.isAfter(calendar.lastDay)) && (!this.linkedCalendars || side == 'right' || this.singleDatePicker)) {
                  html += '<th class="next available"><i class="fa fa-chevron-right glyphicon glyphicon-chevron-right"></i></th>';
              } else {
                  html += '<th></th>';
              }
  
              html += '</tr>';
              html += '<tr>';
  
              // add week number label
              if (this.showWeekNumbers || this.showISOWeekNumbers)
                  html += '<th class="week">' + this.locale.weekLabel + '</th>';
  
              $.each(this.locale.daysOfWeek, function(index, dayOfWeek) {
                  html += '<th>' + dayOfWeek + '</th>';
              });
  
              html += '</tr>';
              html += '</thead>';
              html += '<tbody>';
  
              //adjust maxDate to reflect the dateLimit setting in order to
              //grey out end dates beyond the dateLimit
              if (this.endDate == null && this.dateLimit) {
                  var maxLimit = this.startDate.clone().add(this.dateLimit).endOf('day');
                  if (!maxDate || maxLimit.isBefore(maxDate)) {
                      maxDate = maxLimit;
                  }
              }
  
              for (var row = 0; row < 6; row++) {
                  html += '<tr>';
  
                  // add week number
                  if (this.showWeekNumbers)
                      html += '<td class="week">' + calendar[row][0].week() + '</td>';
                  else if (this.showISOWeekNumbers)
                      html += '<td class="week">' + calendar[row][0].isoWeek() + '</td>';
  
                  for (var col = 0; col < 7; col++) {
  
                      var classes = [];
  
                      //highlight today's date
                      if (calendar[row][col].isSame(new Date(), "day"))
                          classes.push('today');
  
                      //highlight weekends
                      if (calendar[row][col].isoWeekday() > 5)
                          classes.push('weekend');
  
                      //grey out the dates in other months displayed at beginning and end of this calendar
                      if (calendar[row][col].month() != calendar[1][1].month())
                          classes.push('off');
  
                      //don't allow selection of dates before the minimum date
                      if (this.minDate && calendar[row][col].isBefore(this.minDate, 'day'))
                          classes.push('off', 'disabled');
  
                      //don't allow selection of dates after the maximum date
                      if (maxDate && calendar[row][col].isAfter(maxDate, 'day'))
                          classes.push('off', 'disabled');
  
                      //don't allow selection of date if a custom function decides it's invalid
                      if (this.isInvalidDate(calendar[row][col]))
                          classes.push('off', 'disabled');
  
                      //highlight the currently selected start date
                      if (calendar[row][col].format('YYYY-MM-DD') == this.startDate.format('YYYY-MM-DD'))
                          classes.push('active', 'start-date');
  
                      //highlight the currently selected end date
                      if (this.endDate != null && calendar[row][col].format('YYYY-MM-DD') == this.endDate.format('YYYY-MM-DD'))
                          classes.push('active', 'end-date');
  
                      //highlight dates in-between the selected dates
                      if (this.endDate != null && calendar[row][col] > this.startDate && calendar[row][col] < this.endDate)
                          classes.push('in-range');
  
                      var cname = '', disabled = false;
                      for (var i = 0; i < classes.length; i++) {
                          cname += classes[i] + ' ';
                          if (classes[i] == 'disabled')
                              disabled = true;
                      }
                      if (!disabled)
                          cname += 'available';
  
                      html += '<td class="' + cname.replace(/^\s+|\s+$/g, '') + '" data-title="' + 'r' + row + 'c' + col + '">' + calendar[row][col].date() + '</td>';
  
                  }
                  html += '</tr>';
              }
  
              html += '</tbody>';
              html += '</table>';
  
              this.container.find('.calendar.' + side + ' .calendar-table').html(html);
  
          },
  
          renderTimePicker: function(side) {
  
              var html, selected, minDate, maxDate = this.maxDate;
  
              if (this.dateLimit && (!this.maxDate || this.startDate.clone().add(this.dateLimit).isAfter(this.maxDate)))
                  maxDate = this.startDate.clone().add(this.dateLimit);
  
              if (side == 'left') {
                  selected = this.startDate.clone();
                  minDate = this.minDate;
              } else if (side == 'right') {
                  selected = this.endDate ? this.endDate.clone() : this.previousRightTime.clone();
                  minDate = this.startDate;
  
                  //Preserve the time already selected
                  var timeSelector = this.container.find('.calendar.right .calendar-time div');
                  if (timeSelector.html() != '') {
  
                      selected.hour(timeSelector.find('.hourselect option:selected').val() || selected.hour());
                      selected.minute(timeSelector.find('.minuteselect option:selected').val() || selected.minute());
                      selected.second(timeSelector.find('.secondselect option:selected').val() || selected.second());
  
                      if (!this.timePicker24Hour) {
                          var ampm = timeSelector.find('.ampmselect option:selected').val();
                          if (ampm === 'PM' && selected.hour() < 12)
                              selected.hour(selected.hour() + 12);
                          if (ampm === 'AM' && selected.hour() === 12)
                              selected.hour(0);
                      }
  
                      if (selected.isBefore(this.startDate))
                          selected = this.startDate.clone();
  
                      if (selected.isAfter(maxDate))
                          selected = maxDate.clone();
  
                  }
              }
  
              //
              // hours
              //
  
              html = '<select class="hourselect">';
  
              var start = this.timePicker24Hour ? 0 : 1;
              var end = this.timePicker24Hour ? 23 : 12;
  
              for (var i = start; i <= end; i++) {
                  var i_in_24 = i;
                  if (!this.timePicker24Hour)
                      i_in_24 = selected.hour() >= 12 ? (i == 12 ? 12 : i + 12) : (i == 12 ? 0 : i);
  
                  var time = selected.clone().hour(i_in_24);
                  var disabled = false;
                  if (minDate && time.minute(59).isBefore(minDate))
                      disabled = true;
                  if (maxDate && time.minute(0).isAfter(maxDate))
                      disabled = true;
  
                  if (i_in_24 == selected.hour() && !disabled) {
                      html += '<option value="' + i + '" selected="selected">' + i + '</option>';
                  } else if (disabled) {
                      html += '<option value="' + i + '" disabled="disabled" class="disabled">' + i + '</option>';
                  } else {
                      html += '<option value="' + i + '">' + i + '</option>';
                  }
              }
  
              html += '</select> ';
  
              //
              // minutes
              //
  
              html += ': <select class="minuteselect">';
  
              for (var i = 0; i < 60; i += this.timePickerIncrement) {
                  var padded = i < 10 ? '0' + i : i;
                  var time = selected.clone().minute(i);
  
                  var disabled = false;
                  if (minDate && time.second(59).isBefore(minDate))
                      disabled = true;
                  if (maxDate && time.second(0).isAfter(maxDate))
                      disabled = true;
  
                  if (selected.minute() == i && !disabled) {
                      html += '<option value="' + i + '" selected="selected">' + padded + '</option>';
                  } else if (disabled) {
                      html += '<option value="' + i + '" disabled="disabled" class="disabled">' + padded + '</option>';
                  } else {
                      html += '<option value="' + i + '">' + padded + '</option>';
                  }
              }
  
              html += '</select> ';
  
              //
              // seconds
              //
  
              if (this.timePickerSeconds) {
                  html += ': <select class="secondselect">';
  
                  for (var i = 0; i < 60; i++) {
                      var padded = i < 10 ? '0' + i : i;
                      var time = selected.clone().second(i);
  
                      var disabled = false;
                      if (minDate && time.isBefore(minDate))
                          disabled = true;
                      if (maxDate && time.isAfter(maxDate))
                          disabled = true;
  
                      if (selected.second() == i && !disabled) {
                          html += '<option value="' + i + '" selected="selected">' + padded + '</option>';
                      } else if (disabled) {
                          html += '<option value="' + i + '" disabled="disabled" class="disabled">' + padded + '</option>';
                      } else {
                          html += '<option value="' + i + '">' + padded + '</option>';
                      }
                  }
  
                  html += '</select> ';
              }
  
              //
              // AM/PM
              //
  
              if (!this.timePicker24Hour) {
                  html += '<select class="ampmselect">';
  
                  var am_html = '';
                  var pm_html = '';
  
                  if (minDate && selected.clone().hour(12).minute(0).second(0).isBefore(minDate))
                      am_html = ' disabled="disabled" class="disabled"';
  
                  if (maxDate && selected.clone().hour(0).minute(0).second(0).isAfter(maxDate))
                      pm_html = ' disabled="disabled" class="disabled"';
  
                  if (selected.hour() >= 12) {
                      html += '<option value="AM"' + am_html + '>AM</option><option value="PM" selected="selected"' + pm_html + '>PM</option>';
                  } else {
                      html += '<option value="AM" selected="selected"' + am_html + '>AM</option><option value="PM"' + pm_html + '>PM</option>';
                  }
  
                  html += '</select>';
              }
  
              this.container.find('.calendar.' + side + ' .calendar-time div').html(html);
  
          },
  
          updateFormInputs: function() {
  
              //ignore mouse movements while an above-calendar text input has focus
              if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
                  return;
  
              this.container.find('input[name=daterangepicker_start]').val(this.startDate.format(this.locale.format));
              if (this.endDate)
                  this.container.find('input[name=daterangepicker_end]').val(this.endDate.format(this.locale.format));
  
              if (this.singleDatePicker || (this.endDate && (this.startDate.isBefore(this.endDate) || this.startDate.isSame(this.endDate)))) {
                  this.container.find('button.applyBtn').removeAttr('disabled');
              } else {
                  this.container.find('button.applyBtn').attr('disabled', 'disabled');
              }
  
          },
  
          move: function() {
              var parentOffset = { top: 0, left: 0 },
                  containerTop;
              var parentRightEdge = $(window).width();
              if (!this.parentEl.is('body')) {
                  parentOffset = {
                      top: this.parentEl.offset().top - this.parentEl.scrollTop(),
                      left: this.parentEl.offset().left - this.parentEl.scrollLeft()
                  };
                  parentRightEdge = this.parentEl[0].clientWidth + this.parentEl.offset().left;
              }
  
              if (this.drops == 'up')
                  containerTop = this.element.offset().top - this.container.outerHeight() - parentOffset.top;
              else
                  containerTop = this.element.offset().top + this.element.outerHeight() - parentOffset.top;
              this.container[this.drops == 'up' ? 'addClass' : 'removeClass']('dropup');
  
              if (this.opens == 'left') {
                  this.container.css({
                      top: containerTop,
                      right: parentRightEdge - this.element.offset().left - this.element.outerWidth(),
                      left: 'auto'
                  });
                  if (this.container.offset().left < 0) {
                      this.container.css({
                          right: 'auto',
                          left: 9
                      });
                  }
              } else if (this.opens == 'center') {
                  this.container.css({
                      top: containerTop,
                      left: this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2
                              - this.container.outerWidth() / 2,
                      right: 'auto'
                  });
                  if (this.container.offset().left < 0) {
                      this.container.css({
                          right: 'auto',
                          left: 9
                      });
                  }
              } else {
                  this.container.css({
                      top: containerTop,
                      left: this.element.offset().left - parentOffset.left,
                      right: 'auto'
                  });
                  if (this.container.offset().left + this.container.outerWidth() > $(window).width()) {
                      this.container.css({
                          left: 'auto',
                          right: 0
                      });
                  }
              }
          },
  
          show: function(e) {
              if (this.isShowing) return;
  
              // Create a click proxy that is private to this instance of datepicker, for unbinding
              this._outsideClickProxy = $.proxy(function(e) { this.outsideClick(e); }, this);
  
              // Bind global datepicker mousedown for hiding and
              $(document)
                .on('mousedown.daterangepicker', this._outsideClickProxy)
                // also support mobile devices
                .on('touchend.daterangepicker', this._outsideClickProxy)
                // also explicitly play nice with Bootstrap dropdowns, which stopPropagation when clicking them
                .on('click.daterangepicker', '[data-toggle=dropdown]', this._outsideClickProxy)
                // and also close when focus changes to outside the picker (eg. tabbing between controls)
                .on('focusin.daterangepicker', this._outsideClickProxy);
  
              // Reposition the picker if the window is resized while it's open
              $(window).on('resize.daterangepicker', $.proxy(function(e) { this.move(e); }, this));
  
              this.oldStartDate = this.startDate.clone();
              this.oldEndDate = this.endDate.clone();
              this.previousRightTime = this.endDate.clone();
  
              this.updateView();
              this.container.show();
              this.move();
              this.element.trigger('show.daterangepicker', this);
              this.isShowing = true;
          },
  
          hide: function(e) {
              if (!this.isShowing) return;
  
              //incomplete date selection, revert to last values
              if (!this.endDate) {
                  this.startDate = this.oldStartDate.clone();
                  this.endDate = this.oldEndDate.clone();
              }
  
              //if a new date range was selected, invoke the user callback function
              if (!this.startDate.isSame(this.oldStartDate) || !this.endDate.isSame(this.oldEndDate))
                  this.callback(this.startDate, this.endDate, this.chosenLabel);
  
              //if picker is attached to a text input, update it
              this.updateElement();
  
              $(document).off('.daterangepicker');
              $(window).off('.daterangepicker');
              this.container.hide();
              this.element.trigger('hide.daterangepicker', this);
              this.isShowing = false;
          },
  
          toggle: function(e) {
              if (this.isShowing) {
                  this.hide();
              } else {
                  this.show();
              }
          },
  
          outsideClick: function(e) {
              var target = $(e.target);
              // if the page is clicked anywhere except within the daterangerpicker/button
              // itself then call this.hide()
              if (
                  // ie modal dialog fix
                  e.type == "focusin" ||
                  target.closest(this.element).length ||
                  target.closest(this.container).length ||
                  target.closest('.calendar-table').length
                  ) return;
              this.hide();
          },
  
          showCalendars: function() {
              this.container.addClass('show-calendar');
              this.move();
              this.element.trigger('showCalendar.daterangepicker', this);
          },
  
          hideCalendars: function() {
              this.container.removeClass('show-calendar');
              this.element.trigger('hideCalendar.daterangepicker', this);
          },
  
          hoverRange: function(e) {
  
              //ignore mouse movements while an above-calendar text input has focus
              if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
                  return;
  
              var label = e.target.innerHTML;
              if (label == this.locale.customRangeLabel) {
                  this.updateView();
              } else {
                  var dates = this.ranges[label];
                  this.container.find('input[name=daterangepicker_start]').val(dates[0].format(this.locale.format));
                  this.container.find('input[name=daterangepicker_end]').val(dates[1].format(this.locale.format));
              }
              
          },
  
          clickRange: function(e) {
              var label = e.target.innerHTML;
              this.chosenLabel = label;
              if (label == this.locale.customRangeLabel) {
                  this.showCalendars();
              } else {
                  var dates = this.ranges[label];
                  this.startDate = dates[0];
                  this.endDate = dates[1];
  
                  if (!this.timePicker) {
                      this.startDate.startOf('day');
                      this.endDate.endOf('day');
                  }
  
                  if (!this.alwaysShowCalendars)
                      this.hideCalendars();
                  this.clickApply();
              }
          },
  
          clickPrev: function(e) {
              var cal = $(e.target).parents('.calendar');
              if (cal.hasClass('left')) {
                  this.leftCalendar.month.subtract(1, 'month');
                  if (this.linkedCalendars)
                      this.rightCalendar.month.subtract(1, 'month');
              } else {
                  this.rightCalendar.month.subtract(1, 'month');
              }
              this.updateCalendars();
          },
  
          clickNext: function(e) {
              var cal = $(e.target).parents('.calendar');
              if (cal.hasClass('left')) {
                  this.leftCalendar.month.add(1, 'month');
              } else {
                  this.rightCalendar.month.add(1, 'month');
                  if (this.linkedCalendars)
                      this.leftCalendar.month.add(1, 'month');
              }
              this.updateCalendars();
          },
  
          hoverDate: function(e) {
  
              //ignore mouse movements while an above-calendar text input has focus
              if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
                  return;
  
              //ignore dates that can't be selected
              if (!$(e.target).hasClass('available')) return;
  
              //have the text inputs above calendars reflect the date being hovered over
              var title = $(e.target).attr('data-title');
              var row = title.substr(1, 1);
              var col = title.substr(3, 1);
              var cal = $(e.target).parents('.calendar');
              var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col];
  
              if (this.endDate) {
                  this.container.find('input[name=daterangepicker_start]').val(date.format(this.locale.format));
              } else {
                  this.container.find('input[name=daterangepicker_end]').val(date.format(this.locale.format));
              }
  
              //highlight the dates between the start date and the date being hovered as a potential end date
              var leftCalendar = this.leftCalendar;
              var rightCalendar = this.rightCalendar;
              var startDate = this.startDate;
              if (!this.endDate) {
                  this.container.find('.calendar td').each(function(index, el) {
  
                      //skip week numbers, only look at dates
                      if ($(el).hasClass('week')) return;
  
                      var title = $(el).attr('data-title');
                      var row = title.substr(1, 1);
                      var col = title.substr(3, 1);
                      var cal = $(el).parents('.calendar');
                      var dt = cal.hasClass('left') ? leftCalendar.calendar[row][col] : rightCalendar.calendar[row][col];
  
                      if (dt.isAfter(startDate) && dt.isBefore(date)) {
                          $(el).addClass('in-range');
                      } else {
                          $(el).removeClass('in-range');
                      }
  
                  });
              }
  
          },
  
          clickDate: function(e) {
  
              if (!$(e.target).hasClass('available')) return;
  
              var title = $(e.target).attr('data-title');
              var row = title.substr(1, 1);
              var col = title.substr(3, 1);
              var cal = $(e.target).parents('.calendar');
              var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col];
  
              //
              // this function needs to do a few things:
              // * alternate between selecting a start and end date for the range,
              // * if the time picker is enabled, apply the hour/minute/second from the select boxes to the clicked date
              // * if autoapply is enabled, and an end date was chosen, apply the selection
              // * if single date picker mode, and time picker isn't enabled, apply the selection immediately
              //
  
              if (this.endDate || date.isBefore(this.startDate, 'day')) {
                  if (this.timePicker) {
                      var hour = parseInt(this.container.find('.left .hourselect').val(), 10);
                      if (!this.timePicker24Hour) {
                          var ampm = this.container.find('.left .ampmselect').val();
                          if (ampm === 'PM' && hour < 12)
                              hour += 12;
                          if (ampm === 'AM' && hour === 12)
                              hour = 0;
                      }
                      var minute = parseInt(this.container.find('.left .minuteselect').val(), 10);
                      var second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0;
                      date = date.clone().hour(hour).minute(minute).second(second);
                  }
                  this.endDate = null;
                  this.setStartDate(date.clone());
              } else if (!this.endDate && date.isBefore(this.startDate)) {
                  //special case: clicking the same date for start/end, 
                  //but the time of the end date is before the start date
                  this.setEndDate(this.startDate.clone());
              } else {
                  if (this.timePicker) {
                      var hour = parseInt(this.container.find('.right .hourselect').val(), 10);
                      if (!this.timePicker24Hour) {
                          var ampm = this.container.find('.right .ampmselect').val();
                          if (ampm === 'PM' && hour < 12)
                              hour += 12;
                          if (ampm === 'AM' && hour === 12)
                              hour = 0;
                      }
                      var minute = parseInt(this.container.find('.right .minuteselect').val(), 10);
                      var second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0;
                      date = date.clone().hour(hour).minute(minute).second(second);
                  }
                  this.setEndDate(date.clone());
                  if (this.autoApply) {
                    this.calculateChosenLabel();
                    this.clickApply();
                  }
              }
  
              if (this.singleDatePicker) {
                  this.setEndDate(this.startDate);
                  if (!this.timePicker)
                      this.clickApply();
              }
  
              this.updateView();
  
          },
  
          calculateChosenLabel: function() {
            var customRange = true;
            var i = 0;
            for (var range in this.ranges) {
                if (this.timePicker) {
                    if (this.startDate.isSame(this.ranges[range][0]) && this.endDate.isSame(this.ranges[range][1])) {
                        customRange = false;
                        this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').html();
                        break;
                    }
                } else {
                    //ignore times when comparing dates if time picker is not enabled
                    if (this.startDate.format('YYYY-MM-DD') == this.ranges[range][0].format('YYYY-MM-DD') && this.endDate.format('YYYY-MM-DD') == this.ranges[range][1].format('YYYY-MM-DD')) {
                        customRange = false;
                        this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').html();
                        break;
                    }
                }
                i++;
            }
            if (customRange) {
                this.chosenLabel = this.container.find('.ranges li:last').addClass('active').html();
                this.showCalendars();
            }
          },
  
          clickApply: function(e) {
              this.hide();
              this.element.trigger('apply.daterangepicker', this);
          },
  
          clickCancel: function(e) {
              this.startDate = this.oldStartDate;
              this.endDate = this.oldEndDate;
              this.hide();
              this.element.trigger('cancel.daterangepicker', this);
          },
  
          monthOrYearChanged: function(e) {
              var isLeft = $(e.target).closest('.calendar').hasClass('left'),
                  leftOrRight = isLeft ? 'left' : 'right',
                  cal = this.container.find('.calendar.'+leftOrRight);
  
              // Month must be Number for new moment versions
              var month = parseInt(cal.find('.monthselect').val(), 10);
              var year = cal.find('.yearselect').val();
  
              if (!isLeft) {
                  if (year < this.startDate.year() || (year == this.startDate.year() && month < this.startDate.month())) {
                      month = this.startDate.month();
                      year = this.startDate.year();
                  }
              }
  
              if (this.minDate) {
                  if (year < this.minDate.year() || (year == this.minDate.year() && month < this.minDate.month())) {
                      month = this.minDate.month();
                      year = this.minDate.year();
                  }
              }
  
              if (this.maxDate) {
                  if (year > this.maxDate.year() || (year == this.maxDate.year() && month > this.maxDate.month())) {
                      month = this.maxDate.month();
                      year = this.maxDate.year();
                  }
              }
  
              if (isLeft) {
                  this.leftCalendar.month.month(month).year(year);
                  if (this.linkedCalendars)
                      this.rightCalendar.month = this.leftCalendar.month.clone().add(1, 'month');
              } else {
                  this.rightCalendar.month.month(month).year(year);
                  if (this.linkedCalendars)
                      this.leftCalendar.month = this.rightCalendar.month.clone().subtract(1, 'month');
              }
              this.updateCalendars();
          },
  
          timeChanged: function(e) {
  
              var cal = $(e.target).closest('.calendar'),
                  isLeft = cal.hasClass('left');
  
              var hour = parseInt(cal.find('.hourselect').val(), 10);
              var minute = parseInt(cal.find('.minuteselect').val(), 10);
              var second = this.timePickerSeconds ? parseInt(cal.find('.secondselect').val(), 10) : 0;
  
              if (!this.timePicker24Hour) {
                  var ampm = cal.find('.ampmselect').val();
                  if (ampm === 'PM' && hour < 12)
                      hour += 12;
                  if (ampm === 'AM' && hour === 12)
                      hour = 0;
              }
  
              if (isLeft) {
                  var start = this.startDate.clone();
                  start.hour(hour);
                  start.minute(minute);
                  start.second(second);
                  this.setStartDate(start);
                  if (this.singleDatePicker) {
                      this.endDate = this.startDate.clone();
                  } else if (this.endDate && this.endDate.format('YYYY-MM-DD') == start.format('YYYY-MM-DD') && this.endDate.isBefore(start)) {
                      this.setEndDate(start.clone());
                  }
              } else if (this.endDate) {
                  var end = this.endDate.clone();
                  end.hour(hour);
                  end.minute(minute);
                  end.second(second);
                  this.setEndDate(end);
              }
  
              //update the calendars so all clickable dates reflect the new time component
              this.updateCalendars();
  
              //update the form inputs above the calendars with the new time
              this.updateFormInputs();
  
              //re-render the time pickers because changing one selection can affect what's enabled in another
              this.renderTimePicker('left');
              this.renderTimePicker('right');
  
          },
  
          formInputsChanged: function(e) {
              var isRight = $(e.target).closest('.calendar').hasClass('right');
              var start = moment(this.container.find('input[name="daterangepicker_start"]').val(), this.locale.format);
              var end = moment(this.container.find('input[name="daterangepicker_end"]').val(), this.locale.format);
  
              if (start.isValid() && end.isValid()) {
  
                  if (isRight && end.isBefore(start))
                      start = end.clone();
  
                  this.setStartDate(start);
                  this.setEndDate(end);
  
                  if (isRight) {
                      this.container.find('input[name="daterangepicker_start"]').val(this.startDate.format(this.locale.format));
                  } else {
                      this.container.find('input[name="daterangepicker_end"]').val(this.endDate.format(this.locale.format));
                  }
  
              }
  
              this.updateCalendars();
              if (this.timePicker) {
                  this.renderTimePicker('left');
                  this.renderTimePicker('right');
              }
          },
  
          elementChanged: function() {
              if (!this.element.is('input')) return;
              if (!this.element.val().length) return;
              if (this.element.val().length < this.locale.format.length) return;
  
              var dateString = this.element.val().split(this.locale.separator),
                  start = null,
                  end = null;
  
              if (dateString.length === 2) {
                  start = moment(dateString[0], this.locale.format);
                  end = moment(dateString[1], this.locale.format);
              }
  
              if (this.singleDatePicker || start === null || end === null) {
                  start = moment(this.element.val(), this.locale.format);
                  end = start;
              }
  
              if (!start.isValid() || !end.isValid()) return;
  
              this.setStartDate(start);
              this.setEndDate(end);
              this.updateView();
          },
  
          keydown: function(e) {
              //hide on tab or enter
              if ((e.keyCode === 9) || (e.keyCode === 13)) {
                  this.hide();
              }
          },
  
          updateElement: function() {
              if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput) {
                  this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
                  this.element.trigger('change');
              } else if (this.element.is('input') && this.autoUpdateInput) {
                  this.element.val(this.startDate.format(this.locale.format));
                  this.element.trigger('change');
              }
          },
  
          remove: function() {
              this.container.remove();
              this.element.off('.daterangepicker');
              this.element.removeData();
          }
  
      };
  
      $.fn.daterangepicker = function(options, callback) {
          this.each(function() {
              var el = $(this);
              if (el.data('daterangepicker'))
                  el.data('daterangepicker').remove();
              el.data('daterangepicker', new DateRangePicker(el, options, callback));
          });
          return this;
      };
      
      return DateRangePicker;
  
  }));
  
  /* =========================================================
   * bootstrap-datepicker.js
   * Repo: https://github.com/eternicode/bootstrap-datepicker/
   * Demo: http://eternicode.github.io/bootstrap-datepicker/
   * Docs: http://bootstrap-datepicker.readthedocs.org/
   * Forked from http://www.eyecon.ro/bootstrap-datepicker
   * =========================================================
   * Started by Stefan Petre; improvements by Andrew Rowls + contributors
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   * http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   * ========================================================= */
  
  (function($, undefined){
  
  	var $window = $(window);
  
  	function UTCDate(){
  		return new Date(Date.UTC.apply(Date, arguments));
  	}
  	function UTCToday(){
  		var today = new Date();
  		return UTCDate(today.getFullYear(), today.getMonth(), today.getDate());
  	}
  	function alias(method){
  		return function(){
  			return this[method].apply(this, arguments);
  		};
  	}
  
  	var DateArray = (function(){
  		var extras = {
  			get: function(i){
  				return this.slice(i)[0];
  			},
  			contains: function(d){
  				// Array.indexOf is not cross-browser;
  				// $.inArray doesn't work with Dates
  				var val = d && d.valueOf();
  				for (var i=0, l=this.length; i < l; i++)
  					if (this[i].valueOf() === val)
  						return i;
  				return -1;
  			},
  			remove: function(i){
  				this.splice(i,1);
  			},
  			replace: function(new_array){
  				if (!new_array)
  					return;
  				if (!$.isArray(new_array))
  					new_array = [new_array];
  				this.clear();
  				this.push.apply(this, new_array);
  			},
  			clear: function(){
  				this.splice(0);
  			},
  			copy: function(){
  				var a = new DateArray();
  				a.replace(this);
  				return a;
  			}
  		};
  
  		return function(){
  			var a = [];
  			a.push.apply(a, arguments);
  			$.extend(a, extras);
  			return a;
  		};
  	})();
  
  
  	// Picker object
  
  	var Datepicker = function(element, options){
  		this.dates = new DateArray();
  		this.viewDate = UTCToday();
  		this.focusDate = null;
  
  		this._process_options(options);
  
  		this.element = $(element);
  		this.isInline = false;
  		this.isInput = this.element.is('input');
  		this.component = this.element.is('.date') ? this.element.find('.add-on, .input-group-addon, .btn') : false;
  		this.hasInput = this.component && this.element.find('input').length;
  		if (this.component && this.component.length === 0)
  			this.component = false;
  
  		this.picker = $(DPGlobal.template);
  		this._buildEvents();
  		this._attachEvents();
  
  		if (this.isInline){
  			this.picker.addClass('datepicker-inline').appendTo(this.element);
  		}
  		else {
  			this.picker.addClass('datepicker-dropdown dropdown-menu');
  		}
  
  		if (this.o.rtl){
  			this.picker.addClass('datepicker-rtl');
  		}
  
  		this.viewMode = this.o.startView;
  
  		if (this.o.calendarWeeks)
  			this.picker.find('tfoot th.today')
  						.attr('colspan', function(i, val){
  							return parseInt(val) + 1;
  						});
  
  		this._allow_update = false;
  
  		this.setStartDate(this._o.startDate);
  		this.setEndDate(this._o.endDate);
  		this.setDaysOfWeekDisabled(this.o.daysOfWeekDisabled);
  
  		this.fillDow();
  		this.fillMonths();
  
  		this._allow_update = true;
  
  		this.update();
  		this.showMode();
  
  		if (this.isInline){
  			this.show();
  		}
  	};
  
  	Datepicker.prototype = {
  		constructor: Datepicker,
  
  		_process_options: function(opts){
  			// Store raw options for reference
  			this._o = $.extend({}, this._o, opts);
  			// Processed options
  			var o = this.o = $.extend({}, this._o);
  
  			// Check if "de-DE" style date is available, if not language should
  			// fallback to 2 letter code eg "de"
  			var lang = o.language;
  			if (!dates[lang]){
  				lang = lang.split('-')[0];
  				if (!dates[lang])
  					lang = defaults.language;
  			}
  			o.language = lang;
  
  			switch (o.startView){
  				case 2:
  				case 'decade':
  					o.startView = 2;
  					break;
  				case 1:
  				case 'year':
  					o.startView = 1;
  					break;
  				default:
  					o.startView = 0;
  			}
  
  			switch (o.minViewMode){
  				case 1:
  				case 'months':
  					o.minViewMode = 1;
  					break;
  				case 2:
  				case 'years':
  					o.minViewMode = 2;
  					break;
  				default:
  					o.minViewMode = 0;
  			}
  
  			o.startView = Math.max(o.startView, o.minViewMode);
  
  			// true, false, or Number > 0
  			if (o.multidate !== true){
  				o.multidate = Number(o.multidate) || false;
  				if (o.multidate !== false)
  					o.multidate = Math.max(0, o.multidate);
  				else
  					o.multidate = 1;
  			}
  			o.multidateSeparator = String(o.multidateSeparator);
  
  			o.weekStart %= 7;
  			o.weekEnd = ((o.weekStart + 6) % 7);
  
  			var format = DPGlobal.parseFormat(o.format);
  			if (o.startDate !== -Infinity){
  				if (!!o.startDate){
  					if (o.startDate instanceof Date)
  						o.startDate = this._local_to_utc(this._zero_time(o.startDate));
  					else
  						o.startDate = DPGlobal.parseDate(o.startDate, format, o.language);
  				}
  				else {
  					o.startDate = -Infinity;
  				}
  			}
  			if (o.endDate !== Infinity){
  				if (!!o.endDate){
  					if (o.endDate instanceof Date)
  						o.endDate = this._local_to_utc(this._zero_time(o.endDate));
  					else
  						o.endDate = DPGlobal.parseDate(o.endDate, format, o.language);
  				}
  				else {
  					o.endDate = Infinity;
  				}
  			}
  
  			o.daysOfWeekDisabled = o.daysOfWeekDisabled||[];
  			if (!$.isArray(o.daysOfWeekDisabled))
  				o.daysOfWeekDisabled = o.daysOfWeekDisabled.split(/[,\s]*/);
  			o.daysOfWeekDisabled = $.map(o.daysOfWeekDisabled, function(d){
  				return parseInt(d, 10);
  			});
  
  			var plc = String(o.orientation).toLowerCase().split(/\s+/g),
  				_plc = o.orientation.toLowerCase();
  			plc = $.grep(plc, function(word){
  				return (/^auto|left|right|top|bottom$/).test(word);
  			});
  			o.orientation = {x: 'auto', y: 'auto'};
  			if (!_plc || _plc === 'auto')
  				; // no action
  			else if (plc.length === 1){
  				switch (plc[0]){
  					case 'top':
  					case 'bottom':
  						o.orientation.y = plc[0];
  						break;
  					case 'left':
  					case 'right':
  						o.orientation.x = plc[0];
  						break;
  				}
  			}
  			else {
  				_plc = $.grep(plc, function(word){
  					return (/^left|right$/).test(word);
  				});
  				o.orientation.x = _plc[0] || 'auto';
  
  				_plc = $.grep(plc, function(word){
  					return (/^top|bottom$/).test(word);
  				});
  				o.orientation.y = _plc[0] || 'auto';
  			}
  		},
  		_events: [],
  		_secondaryEvents: [],
  		_applyEvents: function(evs){
  			for (var i=0, el, ch, ev; i < evs.length; i++){
  				el = evs[i][0];
  				if (evs[i].length === 2){
  					ch = undefined;
  					ev = evs[i][1];
  				}
  				else if (evs[i].length === 3){
  					ch = evs[i][1];
  					ev = evs[i][2];
  				}
  				el.on(ev, ch);
  			}
  		},
  		_unapplyEvents: function(evs){
  			for (var i=0, el, ev, ch; i < evs.length; i++){
  				el = evs[i][0];
  				if (evs[i].length === 2){
  					ch = undefined;
  					ev = evs[i][1];
  				}
  				else if (evs[i].length === 3){
  					ch = evs[i][1];
  					ev = evs[i][2];
  				}
  				el.off(ev, ch);
  			}
  		},
  		_buildEvents: function(){
  			if (this.isInput){ // single input
  				this._events = [
  					[this.element, {
  						focus: $.proxy(this.show, this),
  						keyup: $.proxy(function(e){
  							if ($.inArray(e.keyCode, [27,37,39,38,40,32,13,9]) === -1)
  								this.update();
  						}, this),
  						keydown: $.proxy(this.keydown, this)
  					}]
  				];
  			}
  			else if (this.component && this.hasInput){ // component: input + button
  				this._events = [
  					// For components that are not readonly, allow keyboard nav
  					[this.element.find('input'), {
  						focus: $.proxy(this.show, this),
  						keyup: $.proxy(function(e){
  							if ($.inArray(e.keyCode, [27,37,39,38,40,32,13,9]) === -1)
  								this.update();
  						}, this),
  						keydown: $.proxy(this.keydown, this)
  					}],
  					[this.component, {
  						click: $.proxy(this.show, this)
  					}]
  				];
  			}
  			else if (this.element.is('div')){  // inline datepicker
  				this.isInline = true;
  			}
  			else {
  				this._events = [
  					[this.element, {
  						click: $.proxy(this.show, this)
  					}]
  				];
  			}
  			this._events.push(
  				// Component: listen for blur on element descendants
  				[this.element, '*', {
  					blur: $.proxy(function(e){
  						this._focused_from = e.target;
  					}, this)
  				}],
  				// Input: listen for blur on element
  				[this.element, {
  					blur: $.proxy(function(e){
  						this._focused_from = e.target;
  					}, this)
  				}]
  			);
  
  			this._secondaryEvents = [
  				[this.picker, {
  					click: $.proxy(this.click, this)
  				}],
  				[$(window), {
  					resize: $.proxy(this.place, this)
  				}],
  				[$(document), {
  					'mousedown touchstart': $.proxy(function(e){
  						// Clicked outside the datepicker, hide it
  						if (!(
  							this.element.is(e.target) ||
  							this.element.find(e.target).length ||
  							this.picker.is(e.target) ||
  							this.picker.find(e.target).length
  						)){
  							this.hide();
  						}
  					}, this)
  				}]
  			];
  		},
  		_attachEvents: function(){
  			this._detachEvents();
  			this._applyEvents(this._events);
  		},
  		_detachEvents: function(){
  			this._unapplyEvents(this._events);
  		},
  		_attachSecondaryEvents: function(){
  			this._detachSecondaryEvents();
  			this._applyEvents(this._secondaryEvents);
  		},
  		_detachSecondaryEvents: function(){
  			this._unapplyEvents(this._secondaryEvents);
  		},
  		_trigger: function(event, altdate){
  			var date = altdate || this.dates.get(-1),
  				local_date = this._utc_to_local(date);
  
  			this.element.trigger({
  				type: event,
  				date: local_date,
  				dates: $.map(this.dates, this._utc_to_local),
  				format: $.proxy(function(ix, format){
  					if (arguments.length === 0){
  						ix = this.dates.length - 1;
  						format = this.o.format;
  					}
  					else if (typeof ix === 'string'){
  						format = ix;
  						ix = this.dates.length - 1;
  					}
  					format = format || this.o.format;
  					var date = this.dates.get(ix);
  					return DPGlobal.formatDate(date, format, this.o.language);
  				}, this)
  			});
  		},
  
  		show: function(){
  			if (!this.isInline)
  				this.picker.appendTo('body');
  			this.picker.show();
  			this.place();
  			this._attachSecondaryEvents();
  			this._trigger('show');
  		},
  
  		hide: function(){
  			if (this.isInline)
  				return;
  			if (!this.picker.is(':visible'))
  				return;
  			this.focusDate = null;
  			this.picker.hide().detach();
  			this._detachSecondaryEvents();
  			this.viewMode = this.o.startView;
  			this.showMode();
  
  			if (
  				this.o.forceParse &&
  				(
  					this.isInput && this.element.val() ||
  					this.hasInput && this.element.find('input').val()
  				)
  			)
  				this.setValue();
  			this._trigger('hide');
  		},
  
  		remove: function(){
  			this.hide();
  			this._detachEvents();
  			this._detachSecondaryEvents();
  			this.picker.remove();
  			delete this.element.data().datepicker;
  			if (!this.isInput){
  				delete this.element.data().date;
  			}
  		},
  
  		_utc_to_local: function(utc){
  			return utc && new Date(utc.getTime() + (utc.getTimezoneOffset()*60000));
  		},
  		_local_to_utc: function(local){
  			return local && new Date(local.getTime() - (local.getTimezoneOffset()*60000));
  		},
  		_zero_time: function(local){
  			return local && new Date(local.getFullYear(), local.getMonth(), local.getDate());
  		},
  		_zero_utc_time: function(utc){
  			return utc && new Date(Date.UTC(utc.getUTCFullYear(), utc.getUTCMonth(), utc.getUTCDate()));
  		},
  
  		getDates: function(){
  			return $.map(this.dates, this._utc_to_local);
  		},
  
  		getUTCDates: function(){
  			return $.map(this.dates, function(d){
  				return new Date(d);
  			});
  		},
  
  		getDate: function(){
  			return this._utc_to_local(this.getUTCDate());
  		},
  
  		getUTCDate: function(){
  			return new Date(this.dates.get(-1));
  		},
  
  		setDates: function(){
  			var args = $.isArray(arguments[0]) ? arguments[0] : arguments;
  			this.update.apply(this, args);
  			this._trigger('changeDate');
  			this.setValue();
  		},
  
  		setUTCDates: function(){
  			var args = $.isArray(arguments[0]) ? arguments[0] : arguments;
  			this.update.apply(this, $.map(args, this._utc_to_local));
  			this._trigger('changeDate');
  			this.setValue();
  		},
  
  		setDate: alias('setDates'),
  		setUTCDate: alias('setUTCDates'),
  
  		setValue: function(){
  			var formatted = this.getFormattedDate();
  			if (!this.isInput){
  				if (this.component){
  					this.element.find('input').val(formatted).change();
  				}
  			}
  			else {
  				this.element.val(formatted).change();
  			}
  		},
  
  		getFormattedDate: function(format){
  			if (format === undefined)
  				format = this.o.format;
  
  			var lang = this.o.language;
  			return $.map(this.dates, function(d){
  				return DPGlobal.formatDate(d, format, lang);
  			}).join(this.o.multidateSeparator);
  		},
  
  		setStartDate: function(startDate){
  			this._process_options({startDate: startDate});
  			this.update();
  			this.updateNavArrows();
  		},
  
  		setEndDate: function(endDate){
  			this._process_options({endDate: endDate});
  			this.update();
  			this.updateNavArrows();
  		},
  
  		setDaysOfWeekDisabled: function(daysOfWeekDisabled){
  			this._process_options({daysOfWeekDisabled: daysOfWeekDisabled});
  			this.update();
  			this.updateNavArrows();
  		},
  
  		place: function(){
  			if (this.isInline)
  				return;
  			var calendarWidth = this.picker.outerWidth(),
  				calendarHeight = this.picker.outerHeight(),
  				visualPadding = 10,
  				windowWidth = $window.width(),
  				windowHeight = $window.height(),
  				scrollTop = $window.scrollTop();
  
  			var zIndex = parseInt(this.element.parents().filter(function(){
  					return $(this).css('z-index') !== 'auto';
  				}).first().css('z-index'))+10;
  			var offset = this.component ? this.component.parent().offset() : this.element.offset();
  			var height = this.component ? this.component.outerHeight(true) : this.element.outerHeight(false);
  			var width = this.component ? this.component.outerWidth(true) : this.element.outerWidth(false);
  			var left = offset.left,
  				top = offset.top;
  
  			this.picker.removeClass(
  				'datepicker-orient-top datepicker-orient-bottom '+
  				'datepicker-orient-right datepicker-orient-left'
  			);
  
  			if (this.o.orientation.x !== 'auto'){
  				this.picker.addClass('datepicker-orient-' + this.o.orientation.x);
  				if (this.o.orientation.x === 'right')
  					left -= calendarWidth - width;
  			}
  			// auto x orientation is best-placement: if it crosses a window
  			// edge, fudge it sideways
  			else {
  				// Default to left
  				this.picker.addClass('datepicker-orient-left');
  				if (offset.left < 0)
  					left -= offset.left - visualPadding;
  				else if (offset.left + calendarWidth > windowWidth)
  					left = windowWidth - calendarWidth - visualPadding;
  			}
  
  			// auto y orientation is best-situation: top or bottom, no fudging,
  			// decision based on which shows more of the calendar
  			var yorient = this.o.orientation.y,
  				top_overflow, bottom_overflow;
  			if (yorient === 'auto'){
  				top_overflow = -scrollTop + offset.top - calendarHeight;
  				bottom_overflow = scrollTop + windowHeight - (offset.top + height + calendarHeight);
  				if (Math.max(top_overflow, bottom_overflow) === bottom_overflow)
  					yorient = 'top';
  				else
  					yorient = 'bottom';
  			}
  			this.picker.addClass('datepicker-orient-' + yorient);
  			if (yorient === 'top')
  				top += height;
  			else
  				top -= calendarHeight + parseInt(this.picker.css('padding-top'));
  
  			this.picker.css({
  				top: top,
  				left: left,
  				zIndex: zIndex
  			});
  		},
  
  		_allow_update: true,
  		update: function(){
  			if (!this._allow_update)
  				return;
  
  			var oldDates = this.dates.copy(),
  				dates = [],
  				fromArgs = false;
  			if (arguments.length){
  				$.each(arguments, $.proxy(function(i, date){
  					if (date instanceof Date)
  						date = this._local_to_utc(date);
  					dates.push(date);
  				}, this));
  				fromArgs = true;
  			}
  			else {
  				dates = this.isInput
  						? this.element.val()
  						: this.element.data('date') || this.element.find('input').val();
  				if (dates && this.o.multidate)
  					dates = dates.split(this.o.multidateSeparator);
  				else
  					dates = [dates];
  				delete this.element.data().date;
  			}
  
  			dates = $.map(dates, $.proxy(function(date){
  				return DPGlobal.parseDate(date, this.o.format, this.o.language);
  			}, this));
  			dates = $.grep(dates, $.proxy(function(date){
  				return (
  					date < this.o.startDate ||
  					date > this.o.endDate ||
  					!date
  				);
  			}, this), true);
  			this.dates.replace(dates);
  
  			if (this.dates.length)
  				this.viewDate = new Date(this.dates.get(-1));
  			else if (this.viewDate < this.o.startDate)
  				this.viewDate = new Date(this.o.startDate);
  			else if (this.viewDate > this.o.endDate)
  				this.viewDate = new Date(this.o.endDate);
  
  			if (fromArgs){
  				// setting date by clicking
  				this.setValue();
  			}
  			else if (dates.length){
  				// setting date by typing
  				if (String(oldDates) !== String(this.dates))
  					this._trigger('changeDate');
  			}
  			if (!this.dates.length && oldDates.length)
  				this._trigger('clearDate');
  
  			this.fill();
  		},
  
  		fillDow: function(){
  			var dowCnt = this.o.weekStart,
  				html = '<tr>';
  			if (this.o.calendarWeeks){
  				var cell = '<th class="cw">&nbsp;</th>';
  				html += cell;
  				this.picker.find('.datepicker-days thead tr:first-child').prepend(cell);
  			}
  			while (dowCnt < this.o.weekStart + 7){
  				html += '<th class="dow">'+dates[this.o.language].daysMin[(dowCnt++)%7]+'</th>';
  			}
  			html += '</tr>';
  			this.picker.find('.datepicker-days thead').append(html);
  		},
  
  		fillMonths: function(){
  			var html = '',
  			i = 0;
  			while (i < 12){
  				html += '<span class="month">'+dates[this.o.language].monthsShort[i++]+'</span>';
  			}
  			this.picker.find('.datepicker-months td').html(html);
  		},
  
  		setRange: function(range){
  			if (!range || !range.length)
  				delete this.range;
  			else
  				this.range = $.map(range, function(d){
  					return d.valueOf();
  				});
  			this.fill();
  		},
  
  		getClassNames: function(date){
  			var cls = [],
  				year = this.viewDate.getUTCFullYear(),
  				month = this.viewDate.getUTCMonth(),
  				today = new Date();
  			if (date.getUTCFullYear() < year || (date.getUTCFullYear() === year && date.getUTCMonth() < month)){
  				cls.push('old');
  			}
  			else if (date.getUTCFullYear() > year || (date.getUTCFullYear() === year && date.getUTCMonth() > month)){
  				cls.push('new');
  			}
  			if (this.focusDate && date.valueOf() === this.focusDate.valueOf())
  				cls.push('focused');
  			// Compare internal UTC date with local today, not UTC today
  			if (this.o.todayHighlight &&
  				date.getUTCFullYear() === today.getFullYear() &&
  				date.getUTCMonth() === today.getMonth() &&
  				date.getUTCDate() === today.getDate()){
  				cls.push('today');
  			}
  			if (this.dates.contains(date) !== -1)
  				cls.push('active');
  			if (date.valueOf() < this.o.startDate || date.valueOf() > this.o.endDate ||
  				$.inArray(date.getUTCDay(), this.o.daysOfWeekDisabled) !== -1){
  				cls.push('disabled');
  			}
  			if (this.range){
  				if (date > this.range[0] && date < this.range[this.range.length-1]){
  					cls.push('range');
  				}
  				if ($.inArray(date.valueOf(), this.range) !== -1){
  					cls.push('selected');
  				}
  			}
  			return cls;
  		},
  
  		fill: function(){
  			var d = new Date(this.viewDate),
  				year = d.getUTCFullYear(),
  				month = d.getUTCMonth(),
  				startYear = this.o.startDate !== -Infinity ? this.o.startDate.getUTCFullYear() : -Infinity,
  				startMonth = this.o.startDate !== -Infinity ? this.o.startDate.getUTCMonth() : -Infinity,
  				endYear = this.o.endDate !== Infinity ? this.o.endDate.getUTCFullYear() : Infinity,
  				endMonth = this.o.endDate !== Infinity ? this.o.endDate.getUTCMonth() : Infinity,
  				todaytxt = dates[this.o.language].today || dates['en'].today || '',
  				cleartxt = dates[this.o.language].clear || dates['en'].clear || '',
  				tooltip;
  			this.picker.find('.datepicker-days thead th.datepicker-switch')
  						.text(dates[this.o.language].months[month]+' '+year);
  			this.picker.find('tfoot th.today')
  						.text(todaytxt)
  						.toggle(this.o.todayBtn !== false);
  			this.picker.find('tfoot th.clear')
  						.text(cleartxt)
  						.toggle(this.o.clearBtn !== false);
  			this.updateNavArrows();
  			this.fillMonths();
  			var prevMonth = UTCDate(year, month-1, 28),
  				day = DPGlobal.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
  			prevMonth.setUTCDate(day);
  			prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.o.weekStart + 7)%7);
  			var nextMonth = new Date(prevMonth);
  			nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
  			nextMonth = nextMonth.valueOf();
  			var html = [];
  			var clsName;
  			while (prevMonth.valueOf() < nextMonth){
  				if (prevMonth.getUTCDay() === this.o.weekStart){
  					html.push('<tr>');
  					if (this.o.calendarWeeks){
  						// ISO 8601: First week contains first thursday.
  						// ISO also states week starts on Monday, but we can be more abstract here.
  						var
  							// Start of current week: based on weekstart/current date
  							ws = new Date(+prevMonth + (this.o.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
  							// Thursday of this week
  							th = new Date(Number(ws) + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
  							// First Thursday of year, year from thursday
  							yth = new Date(Number(yth = UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
  							// Calendar week: ms between thursdays, div ms per day, div 7 days
  							calWeek =  (th - yth) / 864e5 / 7 + 1;
  						html.push('<td class="cw">'+ calWeek +'</td>');
  
  					}
  				}
  				clsName = this.getClassNames(prevMonth);
  				clsName.push('day');
  
  				if (this.o.beforeShowDay !== $.noop){
  					var before = this.o.beforeShowDay(this._utc_to_local(prevMonth));
  					if (before === undefined)
  						before = {};
  					else if (typeof(before) === 'boolean')
  						before = {enabled: before};
  					else if (typeof(before) === 'string')
  						before = {classes: before};
  					if (before.enabled === false)
  						clsName.push('disabled');
  					if (before.classes)
  						clsName = clsName.concat(before.classes.split(/\s+/));
  					if (before.tooltip)
  						tooltip = before.tooltip;
  				}
  
  				clsName = $.unique(clsName);
  				html.push('<td class="'+clsName.join(' ')+'"' + (tooltip ? ' title="'+tooltip+'"' : '') + '>'+prevMonth.getUTCDate() + '</td>');
  				if (prevMonth.getUTCDay() === this.o.weekEnd){
  					html.push('</tr>');
  				}
  				prevMonth.setUTCDate(prevMonth.getUTCDate()+1);
  			}
  			this.picker.find('.datepicker-days tbody').empty().append(html.join(''));
  
  			var months = this.picker.find('.datepicker-months')
  						.find('th:eq(1)')
  							.text(year)
  							.end()
  						.find('span').removeClass('active');
  
  			$.each(this.dates, function(i, d){
  				if (d.getUTCFullYear() === year)
  					months.eq(d.getUTCMonth()).addClass('active');
  			});
  
  			if (year < startYear || year > endYear){
  				months.addClass('disabled');
  			}
  			if (year === startYear){
  				months.slice(0, startMonth).addClass('disabled');
  			}
  			if (year === endYear){
  				months.slice(endMonth+1).addClass('disabled');
  			}
  
  			html = '';
  			year = parseInt(year/10, 10) * 10;
  			var yearCont = this.picker.find('.datepicker-years')
  								.find('th:eq(1)')
  									.text(year + '-' + (year + 9))
  									.end()
  								.find('td');
  			year -= 1;
  			var years = $.map(this.dates, function(d){
  					return d.getUTCFullYear();
  				}),
  				classes;
  			for (var i = -1; i < 11; i++){
  				classes = ['year'];
  				if (i === -1)
  					classes.push('old');
  				else if (i === 10)
  					classes.push('new');
  				if ($.inArray(year, years) !== -1)
  					classes.push('active');
  				if (year < startYear || year > endYear)
  					classes.push('disabled');
  				html += '<span class="' + classes.join(' ') + '">'+year+'</span>';
  				year += 1;
  			}
  			yearCont.html(html);
  		},
  
  		updateNavArrows: function(){
  			if (!this._allow_update)
  				return;
  
  			var d = new Date(this.viewDate),
  				year = d.getUTCFullYear(),
  				month = d.getUTCMonth();
  			switch (this.viewMode){
  				case 0:
  					if (this.o.startDate !== -Infinity && year <= this.o.startDate.getUTCFullYear() && month <= this.o.startDate.getUTCMonth()){
  						this.picker.find('.prev').css({visibility: 'hidden'});
  					}
  					else {
  						this.picker.find('.prev').css({visibility: 'visible'});
  					}
  					if (this.o.endDate !== Infinity && year >= this.o.endDate.getUTCFullYear() && month >= this.o.endDate.getUTCMonth()){
  						this.picker.find('.next').css({visibility: 'hidden'});
  					}
  					else {
  						this.picker.find('.next').css({visibility: 'visible'});
  					}
  					break;
  				case 1:
  				case 2:
  					if (this.o.startDate !== -Infinity && year <= this.o.startDate.getUTCFullYear()){
  						this.picker.find('.prev').css({visibility: 'hidden'});
  					}
  					else {
  						this.picker.find('.prev').css({visibility: 'visible'});
  					}
  					if (this.o.endDate !== Infinity && year >= this.o.endDate.getUTCFullYear()){
  						this.picker.find('.next').css({visibility: 'hidden'});
  					}
  					else {
  						this.picker.find('.next').css({visibility: 'visible'});
  					}
  					break;
  			}
  		},
  
  		click: function(e){
  			e.preventDefault();
  			var target = $(e.target).closest('span, td, th'),
  				year, month, day;
  			if (target.length === 1){
  				switch (target[0].nodeName.toLowerCase()){
  					case 'th':
  						switch (target[0].className){
  							case 'datepicker-switch':
  								this.showMode(1);
  								break;
  							case 'prev':
  							case 'next':
  								var dir = DPGlobal.modes[this.viewMode].navStep * (target[0].className === 'prev' ? -1 : 1);
  								switch (this.viewMode){
  									case 0:
  										this.viewDate = this.moveMonth(this.viewDate, dir);
  										this._trigger('changeMonth', this.viewDate);
  										break;
  									case 1:
  									case 2:
  										this.viewDate = this.moveYear(this.viewDate, dir);
  										if (this.viewMode === 1)
  											this._trigger('changeYear', this.viewDate);
  										break;
  								}
  								this.fill();
  								break;
  							case 'today':
  								var date = new Date();
  								date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
  
  								this.showMode(-2);
  								var which = this.o.todayBtn === 'linked' ? null : 'view';
  								this._setDate(date, which);
  								break;
  							case 'clear':
  								var element;
  								if (this.isInput)
  									element = this.element;
  								else if (this.component)
  									element = this.element.find('input');
  								if (element)
  									element.val("").change();
  								this.update();
  								this._trigger('changeDate');
  								if (this.o.autoclose)
  									this.hide();
  								break;
  						}
  						break;
  					case 'span':
  						if (!target.is('.disabled')){
  							this.viewDate.setUTCDate(1);
  							if (target.is('.month')){
  								day = 1;
  								month = target.parent().find('span').index(target);
  								year = this.viewDate.getUTCFullYear();
  								this.viewDate.setUTCMonth(month);
  								this._trigger('changeMonth', this.viewDate);
  								if (this.o.minViewMode === 1){
  									this._setDate(UTCDate(year, month, day));
  								}
  							}
  							else {
  								day = 1;
  								month = 0;
  								year = parseInt(target.text(), 10)||0;
  								this.viewDate.setUTCFullYear(year);
  								this._trigger('changeYear', this.viewDate);
  								if (this.o.minViewMode === 2){
  									this._setDate(UTCDate(year, month, day));
  								}
  							}
  							this.showMode(-1);
  							this.fill();
  						}
  						break;
  					case 'td':
  						if (target.is('.day') && !target.is('.disabled')){
  							day = parseInt(target.text(), 10)||1;
  							year = this.viewDate.getUTCFullYear();
  							month = this.viewDate.getUTCMonth();
  							if (target.is('.old')){
  								if (month === 0){
  									month = 11;
  									year -= 1;
  								}
  								else {
  									month -= 1;
  								}
  							}
  							else if (target.is('.new')){
  								if (month === 11){
  									month = 0;
  									year += 1;
  								}
  								else {
  									month += 1;
  								}
  							}
  							this._setDate(UTCDate(year, month, day));
  						}
  						break;
  				}
  			}
  			if (this.picker.is(':visible') && this._focused_from){
  				$(this._focused_from).focus();
  			}
  			delete this._focused_from;
  		},
  
  		_toggle_multidate: function(date){
  			var ix = this.dates.contains(date);
  			if (!date){
  				this.dates.clear();
  			}
  			else if (ix !== -1){
  				this.dates.remove(ix);
  			}
  			else {
  				this.dates.push(date);
  			}
  			if (typeof this.o.multidate === 'number')
  				while (this.dates.length > this.o.multidate)
  					this.dates.remove(0);
  		},
  
  		_setDate: function(date, which){
  			if (!which || which === 'date')
  				this._toggle_multidate(date && new Date(date));
  			if (!which || which  === 'view')
  				this.viewDate = date && new Date(date);
  
  			this.fill();
  			this.setValue();
  			this._trigger('changeDate');
  			var element;
  			if (this.isInput){
  				element = this.element;
  			}
  			else if (this.component){
  				element = this.element.find('input');
  			}
  			if (element){
  				element.change();
  			}
  			if (this.o.autoclose && (!which || which === 'date')){
  				this.hide();
  			}
  		},
  
  		moveMonth: function(date, dir){
  			if (!date)
  				return undefined;
  			if (!dir)
  				return date;
  			var new_date = new Date(date.valueOf()),
  				day = new_date.getUTCDate(),
  				month = new_date.getUTCMonth(),
  				mag = Math.abs(dir),
  				new_month, test;
  			dir = dir > 0 ? 1 : -1;
  			if (mag === 1){
  				test = dir === -1
  					// If going back one month, make sure month is not current month
  					// (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
  					? function(){
  						return new_date.getUTCMonth() === month;
  					}
  					// If going forward one month, make sure month is as expected
  					// (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
  					: function(){
  						return new_date.getUTCMonth() !== new_month;
  					};
  				new_month = month + dir;
  				new_date.setUTCMonth(new_month);
  				// Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
  				if (new_month < 0 || new_month > 11)
  					new_month = (new_month + 12) % 12;
  			}
  			else {
  				// For magnitudes >1, move one month at a time...
  				for (var i=0; i < mag; i++)
  					// ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
  					new_date = this.moveMonth(new_date, dir);
  				// ...then reset the day, keeping it in the new month
  				new_month = new_date.getUTCMonth();
  				new_date.setUTCDate(day);
  				test = function(){
  					return new_month !== new_date.getUTCMonth();
  				};
  			}
  			// Common date-resetting loop -- if date is beyond end of month, make it
  			// end of month
  			while (test()){
  				new_date.setUTCDate(--day);
  				new_date.setUTCMonth(new_month);
  			}
  			return new_date;
  		},
  
  		moveYear: function(date, dir){
  			return this.moveMonth(date, dir*12);
  		},
  
  		dateWithinRange: function(date){
  			return date >= this.o.startDate && date <= this.o.endDate;
  		},
  
  		keydown: function(e){
  			if (this.picker.is(':not(:visible)')){
  				if (e.keyCode === 27) // allow escape to hide and re-show picker
  					this.show();
  				return;
  			}
  			var dateChanged = false,
  				dir, newDate, newViewDate,
  				focusDate = this.focusDate || this.viewDate;
  			switch (e.keyCode){
  				case 27: // escape
  					if (this.focusDate){
  						this.focusDate = null;
  						this.viewDate = this.dates.get(-1) || this.viewDate;
  						this.fill();
  					}
  					else
  						this.hide();
  					e.preventDefault();
  					break;
  				case 37: // left
  				case 39: // right
  					if (!this.o.keyboardNavigation)
  						break;
  					dir = e.keyCode === 37 ? -1 : 1;
  					if (e.ctrlKey){
  						newDate = this.moveYear(this.dates.get(-1) || UTCToday(), dir);
  						newViewDate = this.moveYear(focusDate, dir);
  						this._trigger('changeYear', this.viewDate);
  					}
  					else if (e.shiftKey){
  						newDate = this.moveMonth(this.dates.get(-1) || UTCToday(), dir);
  						newViewDate = this.moveMonth(focusDate, dir);
  						this._trigger('changeMonth', this.viewDate);
  					}
  					else {
  						newDate = new Date(this.dates.get(-1) || UTCToday());
  						newDate.setUTCDate(newDate.getUTCDate() + dir);
  						newViewDate = new Date(focusDate);
  						newViewDate.setUTCDate(focusDate.getUTCDate() + dir);
  					}
  					if (this.dateWithinRange(newDate)){
  						this.focusDate = this.viewDate = newViewDate;
  						this.setValue();
  						this.fill();
  						e.preventDefault();
  					}
  					break;
  				case 38: // up
  				case 40: // down
  					if (!this.o.keyboardNavigation)
  						break;
  					dir = e.keyCode === 38 ? -1 : 1;
  					if (e.ctrlKey){
  						newDate = this.moveYear(this.dates.get(-1) || UTCToday(), dir);
  						newViewDate = this.moveYear(focusDate, dir);
  						this._trigger('changeYear', this.viewDate);
  					}
  					else if (e.shiftKey){
  						newDate = this.moveMonth(this.dates.get(-1) || UTCToday(), dir);
  						newViewDate = this.moveMonth(focusDate, dir);
  						this._trigger('changeMonth', this.viewDate);
  					}
  					else {
  						newDate = new Date(this.dates.get(-1) || UTCToday());
  						newDate.setUTCDate(newDate.getUTCDate() + dir * 7);
  						newViewDate = new Date(focusDate);
  						newViewDate.setUTCDate(focusDate.getUTCDate() + dir * 7);
  					}
  					if (this.dateWithinRange(newDate)){
  						this.focusDate = this.viewDate = newViewDate;
  						this.setValue();
  						this.fill();
  						e.preventDefault();
  					}
  					break;
  				case 32: // spacebar
  					// Spacebar is used in manually typing dates in some formats.
  					// As such, its behavior should not be hijacked.
  					break;
  				case 13: // enter
  					focusDate = this.focusDate || this.dates.get(-1) || this.viewDate;
  					this._toggle_multidate(focusDate);
  					dateChanged = true;
  					this.focusDate = null;
  					this.viewDate = this.dates.get(-1) || this.viewDate;
  					this.setValue();
  					this.fill();
  					if (this.picker.is(':visible')){
  						e.preventDefault();
  						if (this.o.autoclose)
  							this.hide();
  					}
  					break;
  				case 9: // tab
  					this.focusDate = null;
  					this.viewDate = this.dates.get(-1) || this.viewDate;
  					this.fill();
  					this.hide();
  					break;
  			}
  			if (dateChanged){
  				if (this.dates.length)
  					this._trigger('changeDate');
  				else
  					this._trigger('clearDate');
  				var element;
  				if (this.isInput){
  					element = this.element;
  				}
  				else if (this.component){
  					element = this.element.find('input');
  				}
  				if (element){
  					element.change();
  				}
  			}
  		},
  
  		showMode: function(dir){
  			if (dir){
  				this.viewMode = Math.max(this.o.minViewMode, Math.min(2, this.viewMode + dir));
  			}
  			this.picker
  				.find('>div')
  				.hide()
  				.filter('.datepicker-'+DPGlobal.modes[this.viewMode].clsName)
  					.css('display', 'block');
  			this.updateNavArrows();
  		}
  	};
  
  	var DateRangePicker = function(element, options){
  		this.element = $(element);
  		this.inputs = $.map(options.inputs, function(i){
  			return i.jquery ? i[0] : i;
  		});
  		delete options.inputs;
  
  		$(this.inputs)
  			.datepicker(options)
  			.bind('changeDate', $.proxy(this.dateUpdated, this));
  
  		this.pickers = $.map(this.inputs, function(i){
  			return $(i).data('datepicker');
  		});
  		this.updateDates();
  	};
  	DateRangePicker.prototype = {
  		updateDates: function(){
  			this.dates = $.map(this.pickers, function(i){
  				return i.getUTCDate();
  			});
  			this.updateRanges();
  		},
  		updateRanges: function(){
  			var range = $.map(this.dates, function(d){
  				return d.valueOf();
  			});
  			$.each(this.pickers, function(i, p){
  				p.setRange(range);
  			});
  		},
  		dateUpdated: function(e){
  			// `this.updating` is a workaround for preventing infinite recursion
  			// between `changeDate` triggering and `setUTCDate` calling.  Until
  			// there is a better mechanism.
  			if (this.updating)
  				return;
  			this.updating = true;
  
  			var dp = $(e.target).data('datepicker'),
  				new_date = dp.getUTCDate(),
  				i = $.inArray(e.target, this.inputs),
  				l = this.inputs.length;
  			if (i === -1)
  				return;
  
  			$.each(this.pickers, function(i, p){
  				if (!p.getUTCDate())
  					p.setUTCDate(new_date);
  			});
  
  			if (new_date < this.dates[i]){
  				// Date being moved earlier/left
  				while (i >= 0 && new_date < this.dates[i]){
  					this.pickers[i--].setUTCDate(new_date);
  				}
  			}
  			else if (new_date > this.dates[i]){
  				// Date being moved later/right
  				while (i < l && new_date > this.dates[i]){
  					this.pickers[i++].setUTCDate(new_date);
  				}
  			}
  			this.updateDates();
  
  			delete this.updating;
  		},
  		remove: function(){
  			$.map(this.pickers, function(p){ p.remove(); });
  			delete this.element.data().datepicker;
  		}
  	};
  
  	function opts_from_el(el, prefix){
  		// Derive options from element data-attrs
  		var data = $(el).data(),
  			out = {}, inkey,
  			replace = new RegExp('^' + prefix.toLowerCase() + '([A-Z])');
  		prefix = new RegExp('^' + prefix.toLowerCase());
  		function re_lower(_,a){
  			return a.toLowerCase();
  		}
  		for (var key in data)
  			if (prefix.test(key)){
  				inkey = key.replace(replace, re_lower);
  				out[inkey] = data[key];
  			}
  		return out;
  	}
  
  	function opts_from_locale(lang){
  		// Derive options from locale plugins
  		var out = {};
  		// Check if "de-DE" style date is available, if not language should
  		// fallback to 2 letter code eg "de"
  		if (!dates[lang]){
  			lang = lang.split('-')[0];
  			if (!dates[lang])
  				return;
  		}
  		var d = dates[lang];
  		$.each(locale_opts, function(i,k){
  			if (k in d)
  				out[k] = d[k];
  		});
  		return out;
  	}
  
  	var old = $.fn.datepicker;
  	$.fn.datepicker = function(option){
  		var args = Array.apply(null, arguments);
  		args.shift();
  		var internal_return;
  		this.each(function(){
  			var $this = $(this),
  				data = $this.data('datepicker'),
  				options = typeof option === 'object' && option;
  			if (!data){
  				var elopts = opts_from_el(this, 'date'),
  					// Preliminary otions
  					xopts = $.extend({}, defaults, elopts, options),
  					locopts = opts_from_locale(xopts.language),
  					// Options priority: js args, data-attrs, locales, defaults
  					opts = $.extend({}, defaults, locopts, elopts, options);
  				if ($this.is('.input-daterange') || opts.inputs){
  					var ropts = {
  						inputs: opts.inputs || $this.find('input').toArray()
  					};
  					$this.data('datepicker', (data = new DateRangePicker(this, $.extend(opts, ropts))));
  				}
  				else {
  					$this.data('datepicker', (data = new Datepicker(this, opts)));
  				}
  			}
  			if (typeof option === 'string' && typeof data[option] === 'function'){
  				internal_return = data[option].apply(data, args);
  				if (internal_return !== undefined)
  					return false;
  			}
  		});
  		if (internal_return !== undefined)
  			return internal_return;
  		else
  			return this;
  	};
  
  	var defaults = $.fn.datepicker.defaults = {
  		autoclose: false,
  		beforeShowDay: $.noop,
  		calendarWeeks: false,
  		clearBtn: false,
  		daysOfWeekDisabled: [],
  		endDate: Infinity,
  		forceParse: true,
  		format: 'mm/dd/yyyy',
  		keyboardNavigation: true,
  		language: 'en',
  		minViewMode: 0,
  		multidate: false,
  		multidateSeparator: ',',
  		orientation: "auto",
  		rtl: false,
  		startDate: -Infinity,
  		startView: 0,
  		todayBtn: false,
  		todayHighlight: false,
  		weekStart: 0
  	};
  	var locale_opts = $.fn.datepicker.locale_opts = [
  		'format',
  		'rtl',
  		'weekStart'
  	];
  	$.fn.datepicker.Constructor = Datepicker;
  	var dates = $.fn.datepicker.dates = {
  		en: {
  			days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
  			daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
  			daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
  			months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
  			monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
  			today: "Today",
  			clear: "Clear"
  		}
  	};
  
  	var DPGlobal = {
  		modes: [
  			{
  				clsName: 'days',
  				navFnc: 'Month',
  				navStep: 1
  			},
  			{
  				clsName: 'months',
  				navFnc: 'FullYear',
  				navStep: 1
  			},
  			{
  				clsName: 'years',
  				navFnc: 'FullYear',
  				navStep: 10
  		}],
  		isLeapYear: function(year){
  			return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0));
  		},
  		getDaysInMonth: function(year, month){
  			return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
  		},
  		validParts: /dd?|DD?|mm?|MM?|yy(?:yy)?/g,
  		nonpunctuation: /[^ -\/:-@\[\u3400-\u9fff-`{-~\t\n\r]+/g,
  		parseFormat: function(format){
  			// IE treats \0 as a string end in inputs (truncating the value),
  			// so it's a bad format delimiter, anyway
  			var separators = format.replace(this.validParts, '\0').split('\0'),
  				parts = format.match(this.validParts);
  			if (!separators || !separators.length || !parts || parts.length === 0){
  				throw new Error("Invalid date format.");
  			}
  			return {separators: separators, parts: parts};
  		},
  		parseDate: function(date, format, language){
  			if (!date)
  				return undefined;
  			if (date instanceof Date)
  				return date;
  			if (typeof format === 'string')
  				format = DPGlobal.parseFormat(format);
  			var part_re = /([\-+]\d+)([dmwy])/,
  				parts = date.match(/([\-+]\d+)([dmwy])/g),
  				part, dir, i;
  			if (/^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/.test(date)){
  				date = new Date();
  				for (i=0; i < parts.length; i++){
  					part = part_re.exec(parts[i]);
  					dir = parseInt(part[1]);
  					switch (part[2]){
  						case 'd':
  							date.setUTCDate(date.getUTCDate() + dir);
  							break;
  						case 'm':
  							date = Datepicker.prototype.moveMonth.call(Datepicker.prototype, date, dir);
  							break;
  						case 'w':
  							date.setUTCDate(date.getUTCDate() + dir * 7);
  							break;
  						case 'y':
  							date = Datepicker.prototype.moveYear.call(Datepicker.prototype, date, dir);
  							break;
  					}
  				}
  				return UTCDate(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), 0, 0, 0);
  			}
  			parts = date && date.match(this.nonpunctuation) || [];
  			date = new Date();
  			var parsed = {},
  				setters_order = ['yyyy', 'yy', 'M', 'MM', 'm', 'mm', 'd', 'dd'],
  				setters_map = {
  					yyyy: function(d,v){
  						return d.setUTCFullYear(v);
  					},
  					yy: function(d,v){
  						return d.setUTCFullYear(2000+v);
  					},
  					m: function(d,v){
  						if (isNaN(d))
  							return d;
  						v -= 1;
  						while (v < 0) v += 12;
  						v %= 12;
  						d.setUTCMonth(v);
  						while (d.getUTCMonth() !== v)
  							d.setUTCDate(d.getUTCDate()-1);
  						return d;
  					},
  					d: function(d,v){
  						return d.setUTCDate(v);
  					}
  				},
  				val, filtered;
  			setters_map['M'] = setters_map['MM'] = setters_map['mm'] = setters_map['m'];
  			setters_map['dd'] = setters_map['d'];
  			date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
  			var fparts = format.parts.slice();
  			// Remove noop parts
  			if (parts.length !== fparts.length){
  				fparts = $(fparts).filter(function(i,p){
  					return $.inArray(p, setters_order) !== -1;
  				}).toArray();
  			}
  			// Process remainder
  			function match_part(){
  				var m = this.slice(0, parts[i].length),
  					p = parts[i].slice(0, m.length);
  				return m === p;
  			}
  			if (parts.length === fparts.length){
  				var cnt;
  				for (i=0, cnt = fparts.length; i < cnt; i++){
  					val = parseInt(parts[i], 10);
  					part = fparts[i];
  					if (isNaN(val)){
  						switch (part){
  							case 'MM':
  								filtered = $(dates[language].months).filter(match_part);
  								val = $.inArray(filtered[0], dates[language].months) + 1;
  								break;
  							case 'M':
  								filtered = $(dates[language].monthsShort).filter(match_part);
  								val = $.inArray(filtered[0], dates[language].monthsShort) + 1;
  								break;
  						}
  					}
  					parsed[part] = val;
  				}
  				var _date, s;
  				for (i=0; i < setters_order.length; i++){
  					s = setters_order[i];
  					if (s in parsed && !isNaN(parsed[s])){
  						_date = new Date(date);
  						setters_map[s](_date, parsed[s]);
  						if (!isNaN(_date))
  							date = _date;
  					}
  				}
  			}
  			return date;
  		},
  		formatDate: function(date, format, language){
  			if (!date)
  				return '';
  			if (typeof format === 'string')
  				format = DPGlobal.parseFormat(format);
  			var val = {
  				d: date.getUTCDate(),
  				D: dates[language].daysShort[date.getUTCDay()],
  				DD: dates[language].days[date.getUTCDay()],
  				m: date.getUTCMonth() + 1,
  				M: dates[language].monthsShort[date.getUTCMonth()],
  				MM: dates[language].months[date.getUTCMonth()],
  				yy: date.getUTCFullYear().toString().substring(2),
  				yyyy: date.getUTCFullYear()
  			};
  			val.dd = (val.d < 10 ? '0' : '') + val.d;
  			val.mm = (val.m < 10 ? '0' : '') + val.m;
  			date = [];
  			var seps = $.extend([], format.separators);
  			for (var i=0, cnt = format.parts.length; i <= cnt; i++){
  				if (seps.length)
  					date.push(seps.shift());
  				date.push(val[format.parts[i]]);
  			}
  			return date.join('');
  		},
  		headTemplate: '<thead>'+
  							'<tr>'+
  								'<th class="prev">&laquo;</th>'+
  								'<th colspan="5" class="datepicker-switch"></th>'+
  								'<th class="next">&raquo;</th>'+
  							'</tr>'+
  						'</thead>',
  		contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
  		footTemplate: '<tfoot>'+
  							'<tr>'+
  								'<th colspan="7" class="today"></th>'+
  							'</tr>'+
  							'<tr>'+
  								'<th colspan="7" class="clear"></th>'+
  							'</tr>'+
  						'</tfoot>'
  	};
  	DPGlobal.template = '<div class="datepicker">'+
  							'<div class="datepicker-days">'+
  								'<table class="table table-condensed">'+
  									DPGlobal.headTemplate+
  									'<tbody></tbody>'+
  									DPGlobal.footTemplate+
  								'</table>'+
  							'</div>'+
  							'<div class="datepicker-months">'+
  								'<table class="table table-condensed">'+
  									DPGlobal.headTemplate+
  									DPGlobal.contTemplate+
  									DPGlobal.footTemplate+
  								'</table>'+
  							'</div>'+
  							'<div class="datepicker-years">'+
  								'<table class="table table-condensed">'+
  									DPGlobal.headTemplate+
  									DPGlobal.contTemplate+
  									DPGlobal.footTemplate+
  								'</table>'+
  							'</div>'+
  						'</div>';
  
  	$.fn.datepicker.DPGlobal = DPGlobal;
  
  
  	/* DATEPICKER NO CONFLICT
  	* =================== */
  
  	$.fn.datepicker.noConflict = function(){
  		$.fn.datepicker = old;
  		return this;
  	};
  
  
  	/* DATEPICKER DATA-API
  	* ================== */
  
  	$(document).on(
  		'focus.datepicker.data-api click.datepicker.data-api',
  		'[data-provide="datepicker"]',
  		function(e){
  			var $this = $(this);
  			if ($this.data('datepicker'))
  				return;
  			e.preventDefault();
  			// component click requires us to explicitly show it
  			$this.datepicker('show');
  		}
  	);
  	$(function(){
  		$('[data-provide="datepicker-inline"]').datepicker();
  	});
  
  }(window.jQuery));
  
  !function(a){"use strict";"object"==typeof exports?module.exports=a(window.jQuery):"function"==typeof define&&define.amd?define(["jquery"],a):window.jQuery&&!window.jQuery.fn.colorpicker&&a(window.jQuery)}(function(a){"use strict";var b=function(b,c){this.value={h:0,s:0,b:0,a:1},this.origFormat=null,c&&a.extend(this.colors,c),b&&(void 0!==b.toLowerCase?(b+="",this.setColor(b)):void 0!==b.h&&(this.value=b))};b.prototype={constructor:b,colors:{aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32",transparent:"transparent"},_sanitizeNumber:function(a){return"number"==typeof a?a:isNaN(a)||null===a||""===a||void 0===a?1:void 0!==a.toLowerCase?parseFloat(a):1},isTransparent:function(a){return a?(a=a.toLowerCase().trim(),"transparent"===a||a.match(/#?00000000/)||a.match(/(rgba|hsla)\(0,0,0,0?\.?0\)/)):!1},rgbaIsTransparent:function(a){return 0===a.r&&0===a.g&&0===a.b&&0===a.a},setColor:function(a){a=a.toLowerCase().trim(),a&&(this.isTransparent(a)?this.value={h:0,s:0,b:0,a:0}:this.value=this.stringToHSB(a)||{h:0,s:0,b:0,a:1})},stringToHSB:function(b){b=b.toLowerCase();var c;"undefined"!=typeof this.colors[b]&&(b=this.colors[b],c="alias");var d=this,e=!1;return a.each(this.stringParsers,function(a,f){var g=f.re.exec(b),h=g&&f.parse.apply(d,[g]),i=c||f.format||"rgba";return h?(e=i.match(/hsla?/)?d.RGBtoHSB.apply(d,d.HSLtoRGB.apply(d,h)):d.RGBtoHSB.apply(d,h),d.origFormat=i,!1):!0}),e},setHue:function(a){this.value.h=1-a},setSaturation:function(a){this.value.s=a},setBrightness:function(a){this.value.b=1-a},setAlpha:function(a){this.value.a=parseInt(100*(1-a),10)/100},toRGB:function(a,b,c,d){a||(a=this.value.h,b=this.value.s,c=this.value.b),a*=360;var e,f,g,h,i;return a=a%360/60,i=c*b,h=i*(1-Math.abs(a%2-1)),e=f=g=c-i,a=~~a,e+=[i,h,0,0,h,i][a],f+=[h,i,i,h,0,0][a],g+=[0,0,h,i,i,h][a],{r:Math.round(255*e),g:Math.round(255*f),b:Math.round(255*g),a:d||this.value.a}},toHex:function(a,b,c,d){var e=this.toRGB(a,b,c,d);return this.rgbaIsTransparent(e)?"transparent":"#"+(1<<24|parseInt(e.r)<<16|parseInt(e.g)<<8|parseInt(e.b)).toString(16).substr(1)},toHSL:function(a,b,c,d){a=a||this.value.h,b=b||this.value.s,c=c||this.value.b,d=d||this.value.a;var e=a,f=(2-b)*c,g=b*c;return g/=f>0&&1>=f?f:2-f,f/=2,g>1&&(g=1),{h:isNaN(e)?0:e,s:isNaN(g)?0:g,l:isNaN(f)?0:f,a:isNaN(d)?0:d}},toAlias:function(a,b,c,d){var e=this.toHex(a,b,c,d);for(var f in this.colors)if(this.colors[f]===e)return f;return!1},RGBtoHSB:function(a,b,c,d){a/=255,b/=255,c/=255;var e,f,g,h;return g=Math.max(a,b,c),h=g-Math.min(a,b,c),e=0===h?null:g===a?(b-c)/h:g===b?(c-a)/h+2:(a-b)/h+4,e=(e+360)%6*60/360,f=0===h?0:h/g,{h:this._sanitizeNumber(e),s:f,b:g,a:this._sanitizeNumber(d)}},HueToRGB:function(a,b,c){return 0>c?c+=1:c>1&&(c-=1),1>6*c?a+(b-a)*c*6:1>2*c?b:2>3*c?a+(b-a)*(2/3-c)*6:a},HSLtoRGB:function(a,b,c,d){0>b&&(b=0);var e;e=.5>=c?c*(1+b):c+b-c*b;var f=2*c-e,g=a+1/3,h=a,i=a-1/3,j=Math.round(255*this.HueToRGB(f,e,g)),k=Math.round(255*this.HueToRGB(f,e,h)),l=Math.round(255*this.HueToRGB(f,e,i));return[j,k,l,this._sanitizeNumber(d)]},toString:function(a){a=a||"rgba";var b=!1;switch(a){case"rgb":return b=this.toRGB(),this.rgbaIsTransparent(b)?"transparent":"rgb("+b.r+","+b.g+","+b.b+")";case"rgba":return b=this.toRGB(),"rgba("+b.r+","+b.g+","+b.b+","+b.a+")";case"hsl":return b=this.toHSL(),"hsl("+Math.round(360*b.h)+","+Math.round(100*b.s)+"%,"+Math.round(100*b.l)+"%)";case"hsla":return b=this.toHSL(),"hsla("+Math.round(360*b.h)+","+Math.round(100*b.s)+"%,"+Math.round(100*b.l)+"%,"+b.a+")";case"hex":return this.toHex();case"alias":return this.toAlias()||this.toHex();default:return b}},stringParsers:[{re:/rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*?\)/,format:"rgb",parse:function(a){return[a[1],a[2],a[3],1]}},{re:/rgb\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*?\)/,format:"rgb",parse:function(a){return[2.55*a[1],2.55*a[2],2.55*a[3],1]}},{re:/rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,format:"rgba",parse:function(a){return[a[1],a[2],a[3],a[4]]}},{re:/rgba\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,format:"rgba",parse:function(a){return[2.55*a[1],2.55*a[2],2.55*a[3],a[4]]}},{re:/hsl\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*?\)/,format:"hsl",parse:function(a){return[a[1]/360,a[2]/100,a[3]/100,a[4]]}},{re:/hsla\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,format:"hsla",parse:function(a){return[a[1]/360,a[2]/100,a[3]/100,a[4]]}},{re:/#?([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/,format:"hex",parse:function(a){return[parseInt(a[1],16),parseInt(a[2],16),parseInt(a[3],16),1]}},{re:/#?([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/,format:"hex",parse:function(a){return[parseInt(a[1]+a[1],16),parseInt(a[2]+a[2],16),parseInt(a[3]+a[3],16),1]}}],colorNameToHex:function(a){return"undefined"!=typeof this.colors[a.toLowerCase()]?this.colors[a.toLowerCase()]:!1}};var c={horizontal:!1,inline:!1,color:!1,format:!1,input:"input",container:!1,component:".add-on, .input-group-addon",sliders:{saturation:{maxLeft:100,maxTop:100,callLeft:"setSaturation",callTop:"setBrightness"},hue:{maxLeft:0,maxTop:100,callLeft:!1,callTop:"setHue"},alpha:{maxLeft:0,maxTop:100,callLeft:!1,callTop:"setAlpha"}},slidersHorz:{saturation:{maxLeft:100,maxTop:100,callLeft:"setSaturation",callTop:"setBrightness"},hue:{maxLeft:100,maxTop:0,callLeft:"setHue",callTop:!1},alpha:{maxLeft:100,maxTop:0,callLeft:"setAlpha",callTop:!1}},template:'<div class="colorpicker dropdown-menu"><div class="colorpicker-saturation"><i><b></b></i></div><div class="colorpicker-hue"><i></i></div><div class="colorpicker-alpha"><i></i></div><div class="colorpicker-color"><div /></div><div class="colorpicker-selectors"></div></div>',align:"right",customClass:null,colorSelectors:null},d=function(d,e){if(this.element=a(d).addClass("colorpicker-element"),this.options=a.extend(!0,{},c,this.element.data(),e),this.component=this.options.component,this.component=this.component!==!1?this.element.find(this.component):!1,this.component&&0===this.component.length&&(this.component=!1),this.container=this.options.container===!0?this.element:this.options.container,this.container=this.container!==!1?a(this.container):!1,this.input=this.element.is("input")?this.element:this.options.input?this.element.find(this.options.input):!1,this.input&&0===this.input.length&&(this.input=!1),this.color=new b(this.options.color!==!1?this.options.color:this.getValue(),this.options.colorSelectors),this.format=this.options.format!==!1?this.options.format:this.color.origFormat,this.picker=a(this.options.template),this.options.customClass&&this.picker.addClass(this.options.customClass),this.options.inline?this.picker.addClass("colorpicker-inline colorpicker-visible"):this.picker.addClass("colorpicker-hidden"),this.options.horizontal&&this.picker.addClass("colorpicker-horizontal"),("rgba"===this.format||"hsla"===this.format||this.options.format===!1)&&this.picker.addClass("colorpicker-with-alpha"),"right"===this.options.align&&this.picker.addClass("colorpicker-right"),this.options.colorSelectors){var f=this;a.each(this.options.colorSelectors,function(b,c){var d=a("<i />").css("background-color",c).data("class",b);d.click(function(){f.setValue(a(this).css("background-color"))}),f.picker.find(".colorpicker-selectors").append(d)}),this.picker.find(".colorpicker-selectors").show()}this.picker.on("mousedown.colorpicker touchstart.colorpicker",a.proxy(this.mousedown,this)),this.picker.appendTo(this.container?this.container:a("body")),this.input!==!1&&(this.input.on({"keyup.colorpicker":a.proxy(this.keyup,this)}),this.input.on({"change.colorpicker":a.proxy(this.change,this)}),this.component===!1&&this.element.on({"focus.colorpicker":a.proxy(this.show,this)}),this.options.inline===!1&&this.element.on({"focusout.colorpicker":a.proxy(this.hide,this)})),this.component!==!1&&this.component.on({"click.colorpicker":a.proxy(this.show,this)}),this.input===!1&&this.component===!1&&this.element.on({"click.colorpicker":a.proxy(this.show,this)}),this.input!==!1&&this.component!==!1&&"color"===this.input.attr("type")&&this.input.on({"click.colorpicker":a.proxy(this.show,this),"focus.colorpicker":a.proxy(this.show,this)}),this.update(),a(a.proxy(function(){this.element.trigger("create")},this))};d.Color=b,d.prototype={constructor:d,destroy:function(){this.picker.remove(),this.element.removeData("colorpicker").off(".colorpicker"),this.input!==!1&&this.input.off(".colorpicker"),this.component!==!1&&this.component.off(".colorpicker"),this.element.removeClass("colorpicker-element"),this.element.trigger({type:"destroy"})},reposition:function(){if(this.options.inline!==!1||this.options.container)return!1;var a=this.container&&this.container[0]!==document.body?"position":"offset",b=this.component||this.element,c=b[a]();"right"===this.options.align&&(c.left-=this.picker.outerWidth()-b.outerWidth()),this.picker.css({top:c.top+b.outerHeight(),left:c.left})},show:function(b){return this.isDisabled()?!1:(this.picker.addClass("colorpicker-visible").removeClass("colorpicker-hidden"),this.reposition(),a(window).on("resize.colorpicker",a.proxy(this.reposition,this)),!b||this.hasInput()&&"color"!==this.input.attr("type")||b.stopPropagation&&b.preventDefault&&(b.stopPropagation(),b.preventDefault()),this.options.inline===!1&&a(window.document).on({"mousedown.colorpicker":a.proxy(this.hide,this)}),void this.element.trigger({type:"showPicker",color:this.color}))},hide:function(){this.picker.addClass("colorpicker-hidden").removeClass("colorpicker-visible"),a(window).off("resize.colorpicker",this.reposition),a(document).off({"mousedown.colorpicker":this.hide}),this.update(),this.element.trigger({type:"hidePicker",color:this.color})},updateData:function(a){return a=a||this.color.toString(this.format),this.element.data("color",a),a},updateInput:function(a){if(a=a||this.color.toString(this.format),this.input!==!1){if(this.options.colorSelectors){var c=new b(a,this.options.colorSelectors),d=c.toAlias();"undefined"!=typeof this.options.colorSelectors[d]&&(a=d)}this.input.prop("value",a)}return a},updatePicker:function(a){void 0!==a&&(this.color=new b(a,this.options.colorSelectors));var c=this.options.horizontal===!1?this.options.sliders:this.options.slidersHorz,d=this.picker.find("i");return 0!==d.length?(this.options.horizontal===!1?(c=this.options.sliders,d.eq(1).css("top",c.hue.maxTop*(1-this.color.value.h)).end().eq(2).css("top",c.alpha.maxTop*(1-this.color.value.a))):(c=this.options.slidersHorz,d.eq(1).css("left",c.hue.maxLeft*(1-this.color.value.h)).end().eq(2).css("left",c.alpha.maxLeft*(1-this.color.value.a))),d.eq(0).css({top:c.saturation.maxTop-this.color.value.b*c.saturation.maxTop,left:this.color.value.s*c.saturation.maxLeft}),this.picker.find(".colorpicker-saturation").css("backgroundColor",this.color.toHex(this.color.value.h,1,1,1)),this.picker.find(".colorpicker-alpha").css("backgroundColor",this.color.toHex()),this.picker.find(".colorpicker-color, .colorpicker-color div").css("backgroundColor",this.color.toString(this.format)),a):void 0},updateComponent:function(a){if(a=a||this.color.toString(this.format),this.component!==!1){var b=this.component.find("i").eq(0);b.length>0?b.css({backgroundColor:a}):this.component.css({backgroundColor:a})}return a},update:function(a){var b;return(this.getValue(!1)!==!1||a===!0)&&(b=this.updateComponent(),this.updateInput(b),this.updateData(b),this.updatePicker()),b},setValue:function(a){this.color=new b(a,this.options.colorSelectors),this.update(!0),this.element.trigger({type:"changeColor",color:this.color,value:a})},getValue:function(a){a=void 0===a?"#000000":a;var b;return b=this.hasInput()?this.input.val():this.element.data("color"),(void 0===b||""===b||null===b)&&(b=a),b},hasInput:function(){return this.input!==!1},isDisabled:function(){return this.hasInput()?this.input.prop("disabled")===!0:!1},disable:function(){return this.hasInput()?(this.input.prop("disabled",!0),this.element.trigger({type:"disable",color:this.color,value:this.getValue()}),!0):!1},enable:function(){return this.hasInput()?(this.input.prop("disabled",!1),this.element.trigger({type:"enable",color:this.color,value:this.getValue()}),!0):!1},currentSlider:null,mousePointer:{left:0,top:0},mousedown:function(b){b.pageX||b.pageY||!b.originalEvent||(b.pageX=b.originalEvent.touches[0].pageX,b.pageY=b.originalEvent.touches[0].pageY),b.stopPropagation(),b.preventDefault();var c=a(b.target),d=c.closest("div"),e=this.options.horizontal?this.options.slidersHorz:this.options.sliders;if(!d.is(".colorpicker")){if(d.is(".colorpicker-saturation"))this.currentSlider=a.extend({},e.saturation);else if(d.is(".colorpicker-hue"))this.currentSlider=a.extend({},e.hue);else{if(!d.is(".colorpicker-alpha"))return!1;this.currentSlider=a.extend({},e.alpha)}var f=d.offset();this.currentSlider.guide=d.find("i")[0].style,this.currentSlider.left=b.pageX-f.left,this.currentSlider.top=b.pageY-f.top,this.mousePointer={left:b.pageX,top:b.pageY},a(document).on({"mousemove.colorpicker":a.proxy(this.mousemove,this),"touchmove.colorpicker":a.proxy(this.mousemove,this),"mouseup.colorpicker":a.proxy(this.mouseup,this),"touchend.colorpicker":a.proxy(this.mouseup,this)}).trigger("mousemove")}return!1},mousemove:function(a){a.pageX||a.pageY||!a.originalEvent||(a.pageX=a.originalEvent.touches[0].pageX,a.pageY=a.originalEvent.touches[0].pageY),a.stopPropagation(),a.preventDefault();var b=Math.max(0,Math.min(this.currentSlider.maxLeft,this.currentSlider.left+((a.pageX||this.mousePointer.left)-this.mousePointer.left))),c=Math.max(0,Math.min(this.currentSlider.maxTop,this.currentSlider.top+((a.pageY||this.mousePointer.top)-this.mousePointer.top)));return this.currentSlider.guide.left=b+"px",this.currentSlider.guide.top=c+"px",this.currentSlider.callLeft&&this.color[this.currentSlider.callLeft].call(this.color,b/this.currentSlider.maxLeft),this.currentSlider.callTop&&this.color[this.currentSlider.callTop].call(this.color,c/this.currentSlider.maxTop),"setAlpha"===this.currentSlider.callTop&&this.options.format===!1&&(1!==this.color.value.a?(this.format="rgba",this.color.origFormat="rgba"):(this.format="hex",this.color.origFormat="hex")),this.update(!0),this.element.trigger({type:"changeColor",color:this.color}),!1},mouseup:function(b){return b.stopPropagation(),b.preventDefault(),a(document).off({"mousemove.colorpicker":this.mousemove,"touchmove.colorpicker":this.mousemove,"mouseup.colorpicker":this.mouseup,"touchend.colorpicker":this.mouseup}),!1},change:function(a){this.keyup(a)},keyup:function(a){38===a.keyCode?(this.color.value.a<1&&(this.color.value.a=Math.round(100*(this.color.value.a+.01))/100),this.update(!0)):40===a.keyCode?(this.color.value.a>0&&(this.color.value.a=Math.round(100*(this.color.value.a-.01))/100),this.update(!0)):(this.color=new b(this.input.val(),this.options.colorSelectors),this.color.origFormat&&this.options.format===!1&&(this.format=this.color.origFormat),this.getValue(!1)!==!1&&(this.updateData(),this.updateComponent(),this.updatePicker())),this.element.trigger({type:"changeColor",color:this.color,value:this.input.val()})}},a.colorpicker=d,a.fn.colorpicker=function(b){var c,e=arguments,f=this.each(function(){var f=a(this),g=f.data("colorpicker"),h="object"==typeof b?b:{};g||"string"==typeof b?"string"==typeof b&&(c=g[b].apply(g,Array.prototype.slice.call(e,1))):f.data("colorpicker",new d(this,h))});return"getValue"===b?c:f},a.fn.colorpicker.constructor=d});
  //TODO: move arrow styles and button click code into configurable items, with defaults matching the existing code
  
  /*!
  * Timepicker Component for Twitter Bootstrap
  *
  * Copyright 2013 Joris de Wit
  *
  * Contributors https://github.com/jdewit/bootstrap-timepicker/graphs/contributors
  *
  * For the full copyright and license information, please view the LICENSE
  * file that was distributed with this source code.
  */
  (function($, window, document, undefined) {
    'use strict';
  
    // TIMEPICKER PUBLIC CLASS DEFINITION
    var Timepicker = function(element, options) {
      this.widget = '';
      this.$element = $(element);
      this.defaultTime = options.defaultTime;
      this.disableFocus = options.disableFocus;
      this.isOpen = options.isOpen;
      this.minuteStep = options.minuteStep;
      this.modalBackdrop = options.modalBackdrop;
      this.secondStep = options.secondStep;
      this.showInputs = options.showInputs;
      this.showMeridian = options.showMeridian;
      this.showSeconds = options.showSeconds;
      this.template = options.template;
      this.appendWidgetTo = options.appendWidgetTo;
  	this.upArrowStyle = options.upArrowStyle;
  	this.downArrowStyle = options.downArrowStyle;
  	this.containerClass = options.containerClass;
  
      this._init();
    };
  
    Timepicker.prototype = {
  
      constructor: Timepicker,
  
      _init: function() {
        var self = this;
  
        if (this.$element.parent().hasClass('input-append') || this.$element.parent().hasClass('input-prepend')) {
  		if (this.$element.parent('.input-append, .input-prepend').find('.add-on').length) {
  			this.$element.parent('.input-append, .input-prepend').find('.add-on').on({
  			  'click.timepicker': $.proxy(this.showWidget, this)
  			});		
  		} else {
  			this.$element.closest(this.containerClass).find('.add-on').on({
  			  'click.timepicker': $.proxy(this.showWidget, this)
  			});		
  		}
  		
          this.$element.on({
            'focus.timepicker': $.proxy(this.highlightUnit, this),
            'click.timepicker': $.proxy(this.highlightUnit, this),
            'keydown.timepicker': $.proxy(this.elementKeydown, this),
            'blur.timepicker': $.proxy(this.blurElement, this)
          });
        } else {
          if (this.template) {
            this.$element.on({
              'focus.timepicker': $.proxy(this.showWidget, this),
              'click.timepicker': $.proxy(this.showWidget, this),
              'blur.timepicker': $.proxy(this.blurElement, this)
            });
          } else {
            this.$element.on({
              'focus.timepicker': $.proxy(this.highlightUnit, this),
              'click.timepicker': $.proxy(this.highlightUnit, this),
              'keydown.timepicker': $.proxy(this.elementKeydown, this),
              'blur.timepicker': $.proxy(this.blurElement, this)
            });
          }
        }
  
        if (this.template !== false) {
          this.$widget = $(this.getTemplate()).prependTo(this.$element.parents(this.appendWidgetTo)).on('click', $.proxy(this.widgetClick, this));
        } else {
          this.$widget = false;
        }
  
        if (this.showInputs && this.$widget !== false) {
          this.$widget.find('input').each(function() {
            $(this).on({
              'click.timepicker': function() { $(this).select(); },
              'keydown.timepicker': $.proxy(self.widgetKeydown, self)
            });
          });
        }
  
        this.setDefaultTime(this.defaultTime);
      },
  
      blurElement: function() {
        this.highlightedUnit = undefined;
        this.updateFromElementVal();
      },
  
      decrementHour: function() {
        if (this.showMeridian) {
          if (this.hour === 1) {
            this.hour = 12;
          } else if (this.hour === 12) {
            this.hour--;
  
            return this.toggleMeridian();
          } else if (this.hour === 0) {
            this.hour = 11;
  
            return this.toggleMeridian();
          } else {
            this.hour--;
          }
        } else {
          if (this.hour === 0) {
            this.hour = 23;
          } else {
            this.hour--;
          }
        }
        this.update();
      },
  
      decrementMinute: function(step) {
        var newVal;
  
        if (step) {
          newVal = this.minute - step;
        } else {
          newVal = this.minute - this.minuteStep;
        }
  
        if (newVal < 0) {
          this.decrementHour();
          this.minute = newVal + 60;
        } else {
          this.minute = newVal;
        }
        this.update();
      },
  
      decrementSecond: function() {
        var newVal = this.second - this.secondStep;
  
        if (newVal < 0) {
          this.decrementMinute(true);
          this.second = newVal + 60;
        } else {
          this.second = newVal;
        }
        this.update();
      },
  
      elementKeydown: function(e) {
        switch (e.keyCode) {
        case 9: //tab
          this.updateFromElementVal();
  
          switch (this.highlightedUnit) {
          case 'hour':
            e.preventDefault();
            this.highlightNextUnit();
            break;
          case 'minute':
            if (this.showMeridian || this.showSeconds) {
              e.preventDefault();
              this.highlightNextUnit();
            }
            break;
          case 'second':
            if (this.showMeridian) {
              e.preventDefault();
              this.highlightNextUnit();
            }
            break;
          }
          break;
        case 27: // escape
          this.updateFromElementVal();
          break;
        case 37: // left arrow
          e.preventDefault();
          this.highlightPrevUnit();
          this.updateFromElementVal();
          break;
        case 38: // up arrow
          e.preventDefault();
          switch (this.highlightedUnit) {
          case 'hour':
            this.incrementHour();
            this.highlightHour();
            break;
          case 'minute':
            this.incrementMinute();
            this.highlightMinute();
            break;
          case 'second':
            this.incrementSecond();
            this.highlightSecond();
            break;
          case 'meridian':
            this.toggleMeridian();
            this.highlightMeridian();
            break;
          }
          break;
        case 39: // right arrow
          e.preventDefault();
          this.updateFromElementVal();
          this.highlightNextUnit();
          break;
        case 40: // down arrow
          e.preventDefault();
          switch (this.highlightedUnit) {
          case 'hour':
            this.decrementHour();
            this.highlightHour();
            break;
          case 'minute':
            this.decrementMinute();
            this.highlightMinute();
            break;
          case 'second':
            this.decrementSecond();
            this.highlightSecond();
            break;
          case 'meridian':
            this.toggleMeridian();
            this.highlightMeridian();
            break;
          }
          break;
        }
      },
  
      formatTime: function(hour, minute, second, meridian) {
        hour = hour < 10 ? '0' + hour : hour;
        minute = minute < 10 ? '0' + minute : minute;
        second = second < 10 ? '0' + second : second;
  
        return hour + ':' + minute + (this.showSeconds ? ':' + second : '') + (this.showMeridian ? ' ' + meridian : '');
      },
  
      getCursorPosition: function() {
        var input = this.$element.get(0);
  
        if ('selectionStart' in input) {// Standard-compliant browsers
  
          return input.selectionStart;
        } else if (document.selection) {// IE fix
          input.focus();
          var sel = document.selection.createRange(),
            selLen = document.selection.createRange().text.length;
  
          sel.moveStart('character', - input.value.length);
  
          return sel.text.length - selLen;
        }
      },
  
      getTemplate: function() {
        var template,
          hourTemplate,
          minuteTemplate,
          secondTemplate,
          meridianTemplate,
          templateContent;
  
        if (this.showInputs) {
          hourTemplate = '<input type="text" name="hour" class="bootstrap-timepicker-hour form-control" maxlength="2"/>';
          minuteTemplate = '<input type="text" name="minute" class="bootstrap-timepicker-minute form-control" maxlength="2"/>';
          secondTemplate = '<input type="text" name="second" class="bootstrap-timepicker-second form-control" maxlength="2"/>';
          meridianTemplate = '<input type="text" name="meridian" class="bootstrap-timepicker-meridian form-control" maxlength="2"/>';
        } else {
          hourTemplate = '<span class="bootstrap-timepicker-hour"></span>';
          minuteTemplate = '<span class="bootstrap-timepicker-minute"></span>';
          secondTemplate = '<span class="bootstrap-timepicker-second"></span>';
          meridianTemplate = '<span class="bootstrap-timepicker-meridian"></span>';
        }
  
        templateContent = '<table>'+
           '<tr>'+
             '<td><a href="#" data-action="incrementHour"><i class="' + this.upArrowStyle + '"></i></a></td>'+
             '<td class="separator">&nbsp;</td>'+
             '<td><a href="#" data-action="incrementMinute"><i class="' + this.upArrowStyle + '"></i></a></td>'+
             (this.showSeconds ?
               '<td class="separator">&nbsp;</td>'+
               '<td><a href="#" data-action="incrementSecond"><i class="' + this.upArrowStyle + '"></i></a></td>'
             : '') +
             (this.showMeridian ?
               '<td class="separator">&nbsp;</td>'+
               '<td class="meridian-column"><a href="#" data-action="toggleMeridian"><i class="' + this.upArrowStyle + '"></i></a></td>'
             : '') +
           '</tr>'+
           '<tr>'+
             '<td>'+ hourTemplate +'</td> '+
             '<td class="separator">:</td>'+
             '<td>'+ minuteTemplate +'</td> '+
             (this.showSeconds ?
              '<td class="separator">:</td>'+
              '<td>'+ secondTemplate +'</td>'
             : '') +
             (this.showMeridian ?
              '<td class="separator">&nbsp;</td>'+
              '<td>'+ meridianTemplate +'</td>'
             : '') +
           '</tr>'+
           '<tr>'+
             '<td><a href="#" data-action="decrementHour"><i class="' + this.downArrowStyle + '"></i></a></td>'+
             '<td class="separator"></td>'+
             '<td><a href="#" data-action="decrementMinute"><i class="' + this.downArrowStyle + '"></i></a></td>'+
             (this.showSeconds ?
              '<td class="separator">&nbsp;</td>'+
              '<td><a href="#" data-action="decrementSecond"><i class="' + this.downArrowStyle + '"></i></a></td>'
             : '') +
             (this.showMeridian ?
              '<td class="separator">&nbsp;</td>'+
              '<td><a href="#" data-action="toggleMeridian"><i class="' + this.downArrowStyle + '"></i></a></td>'
             : '') +
           '</tr>'+
         '</table>';
  
        switch(this.template) {
        case 'modal':
          template = '<div class="bootstrap-timepicker-widget modal hide fade in" data-backdrop="'+ (this.modalBackdrop ? 'true' : 'false') +'">'+
            '<div class="modal-header">'+
              '<a href="#" class="close" data-dismiss="modal">×</a>'+
              '<h3>Pick a Time</h3>'+
            '</div>'+
            '<div class="modal-content">'+
              templateContent +
            '</div>'+
            '<div class="modal-footer">'+
              '<a href="#" class="btn btn-primary" data-dismiss="modal">OK</a>'+
            '</div>'+
          '</div>';
          break;
        case 'dropdown':
          template = '<div class="bootstrap-timepicker-widget dropdown-menu">'+ templateContent +'</div>';
          break;
        }
  
        return template;
      },
  
      getTime: function() {
        return this.formatTime(this.hour, this.minute, this.second, this.meridian);
      },
  
      hideWidget: function() {
        if (this.isOpen === false) {
          return;
        }
  
                          if (this.showInputs) {
                                  this.updateFromWidgetInputs();
                          }
  
        this.$element.trigger({
          'type': 'hide.timepicker',
          'time': {
            'value': this.getTime(),
            'hours': this.hour,
            'minutes': this.minute,
            'seconds': this.second,
            'meridian': this.meridian
          }
        });
  
        if (this.template === 'modal' && this.$widget.modal) {
          this.$widget.modal('hide');
        } else {
          this.$widget.removeClass('open');
        }
  
        $(document).off('mousedown.timepicker');
  
        this.isOpen = false;
      },
  
      highlightUnit: function() {
        this.position = this.getCursorPosition();
        if (this.position >= 0 && this.position <= 2) {
          this.highlightHour();
        } else if (this.position >= 3 && this.position <= 5) {
          this.highlightMinute();
        } else if (this.position >= 6 && this.position <= 8) {
          if (this.showSeconds) {
            this.highlightSecond();
          } else {
            this.highlightMeridian();
          }
        } else if (this.position >= 9 && this.position <= 11) {
          this.highlightMeridian();
        }
      },
  
      highlightNextUnit: function() {
        switch (this.highlightedUnit) {
        case 'hour':
          this.highlightMinute();
          break;
        case 'minute':
          if (this.showSeconds) {
            this.highlightSecond();
          } else if (this.showMeridian){
            this.highlightMeridian();
          } else {
            this.highlightHour();
          }
          break;
        case 'second':
          if (this.showMeridian) {
            this.highlightMeridian();
          } else {
            this.highlightHour();
          }
          break;
        case 'meridian':
          this.highlightHour();
          break;
        }
      },
  
      highlightPrevUnit: function() {
        switch (this.highlightedUnit) {
        case 'hour':
          this.highlightMeridian();
          break;
        case 'minute':
          this.highlightHour();
          break;
        case 'second':
          this.highlightMinute();
          break;
        case 'meridian':
          if (this.showSeconds) {
            this.highlightSecond();
          } else {
            this.highlightMinute();
          }
          break;
        }
      },
  
      highlightHour: function() {
        var $element = this.$element.get(0);
  
        this.highlightedUnit = 'hour';
  
                          if ($element.setSelectionRange) {
                                  setTimeout(function() {
                                          $element.setSelectionRange(0,2);
                                  }, 0);
                          }
      },
  
      highlightMinute: function() {
        var $element = this.$element.get(0);
  
        this.highlightedUnit = 'minute';
  
                          if ($element.setSelectionRange) {
                                  setTimeout(function() {
                                          $element.setSelectionRange(3,5);
                                  }, 0);
                          }
      },
  
      highlightSecond: function() {
        var $element = this.$element.get(0);
  
        this.highlightedUnit = 'second';
  
                          if ($element.setSelectionRange) {
                                  setTimeout(function() {
                                          $element.setSelectionRange(6,8);
                                  }, 0);
                          }
      },
  
      highlightMeridian: function() {
        var $element = this.$element.get(0);
  
        this.highlightedUnit = 'meridian';
  
                          if ($element.setSelectionRange) {
                                  if (this.showSeconds) {
                                          setTimeout(function() {
                                                  $element.setSelectionRange(9,11);
                                          }, 0);
                                  } else {
                                          setTimeout(function() {
                                                  $element.setSelectionRange(6,8);
                                          }, 0);
                                  }
                          }
      },
  
      incrementHour: function() {
        if (this.showMeridian) {
          if (this.hour === 11) {
            this.hour++;
            return this.toggleMeridian();
          } else if (this.hour === 12) {
            this.hour = 0;
          }
        }
        if (this.hour === 23) {
          this.hour = 0;
  
          return;
        }
        this.hour++;
        this.update();
      },
  
      incrementMinute: function(step) {
        var newVal;
  
        if (step) {
          newVal = this.minute + step;
        } else {
          newVal = this.minute + this.minuteStep - (this.minute % this.minuteStep);
        }
  
        if (newVal > 59) {
          this.incrementHour();
          this.minute = newVal - 60;
        } else {
          this.minute = newVal;
        }
        this.update();
      },
  
      incrementSecond: function() {
        var newVal = this.second + this.secondStep - (this.second % this.secondStep);
  
        if (newVal > 59) {
          this.incrementMinute(true);
          this.second = newVal - 60;
        } else {
          this.second = newVal;
        }
        this.update();
      },
  
      remove: function() {
        $('document').off('.timepicker');
        if (this.$widget) {
          this.$widget.remove();
        }
        delete this.$element.data().timepicker;
      },
  
      setDefaultTime: function(defaultTime){
        if (!this.$element.val()) {
          if (defaultTime === 'current') {
            var dTime = new Date(),
              hours = dTime.getHours(),
              minutes = Math.floor(dTime.getMinutes() / this.minuteStep) * this.minuteStep,
              seconds = Math.floor(dTime.getSeconds() / this.secondStep) * this.secondStep,
              meridian = 'AM';
  
            if (this.showMeridian) {
              if (hours === 0) {
                hours = 12;
              } else if (hours >= 12) {
                if (hours > 12) {
                  hours = hours - 12;
                }
                meridian = 'PM';
              } else {
                meridian = 'AM';
              }
            }
  
            this.hour = hours;
            this.minute = minutes;
            this.second = seconds;
            this.meridian = meridian;
  
            this.update();
  
          } else if (defaultTime === false) {
            this.hour = 0;
            this.minute = 0;
            this.second = 0;
            this.meridian = 'AM';
          } else {
            this.setTime(defaultTime);
          }
        } else {
          this.updateFromElementVal();
        }
      },
  
      setTime: function(time) {
        var arr,
          timeArray;
  
        if (this.showMeridian) {
          arr = time.split(' ');
          timeArray = arr[0].split(':');
          this.meridian = arr[1];
        } else {
          timeArray = time.split(':');
        }
  
        this.hour = parseInt(timeArray[0], 10);
        this.minute = parseInt(timeArray[1], 10);
        this.second = parseInt(timeArray[2], 10);
  
        if (isNaN(this.hour)) {
          this.hour = 0;
        }
        if (isNaN(this.minute)) {
          this.minute = 0;
        }
  
        if (this.showMeridian) {
          if (this.hour > 12) {
            this.hour = 12;
          } else if (this.hour < 1) {
            this.hour = 12;
          }
  
          if (this.meridian === 'am' || this.meridian === 'a') {
            this.meridian = 'AM';
          } else if (this.meridian === 'pm' || this.meridian === 'p') {
            this.meridian = 'PM';
          }
  
          if (this.meridian !== 'AM' && this.meridian !== 'PM') {
            this.meridian = 'AM';
          }
        } else {
          if (this.hour >= 24) {
            this.hour = 23;
          } else if (this.hour < 0) {
            this.hour = 0;
          }
        }
  
        if (this.minute < 0) {
          this.minute = 0;
        } else if (this.minute >= 60) {
          this.minute = 59;
        }
  
        if (this.showSeconds) {
          if (isNaN(this.second)) {
            this.second = 0;
          } else if (this.second < 0) {
            this.second = 0;
          } else if (this.second >= 60) {
            this.second = 59;
          }
        }
  
        this.update();
      },
  
      showWidget: function() {
        if (this.isOpen) {
          return;
        }
  
        if (this.$element.is(':disabled')) {
          return;
        }
  
        var self = this;
        $(document).on('mousedown.timepicker', function (e) {
          // Clicked outside the timepicker, hide it
          if ($(e.target).closest('.bootstrap-timepicker-widget').length === 0) {
            self.hideWidget();
          }
        });
  
        this.$element.trigger({
          'type': 'show.timepicker',
          'time': {
            'value': this.getTime(),
            'hours': this.hour,
            'minutes': this.minute,
            'seconds': this.second,
            'meridian': this.meridian
          }
        });
  
        if (this.disableFocus) {
          this.$element.blur();
        }
  
        this.updateFromElementVal();
  
        if (this.template === 'modal' && this.$widget.modal) {
          this.$widget.modal('show').on('hidden', $.proxy(this.hideWidget, this));
        } else {
          if (this.isOpen === false) {
            this.$widget.addClass('open');
          }
        }
  
        this.isOpen = true;
      },
  
      toggleMeridian: function() {
        this.meridian = this.meridian === 'AM' ? 'PM' : 'AM';
        this.update();
      },
  
      update: function() {
        this.$element.trigger({
          'type': 'changeTime.timepicker',
          'time': {
            'value': this.getTime(),
            'hours': this.hour,
            'minutes': this.minute,
            'seconds': this.second,
            'meridian': this.meridian
          }
        });
  
        this.updateElement();
        this.updateWidget();
      },
  
      updateElement: function() {
        this.$element.val(this.getTime()).change();
      },
  
      updateFromElementVal: function() {
                          var val = this.$element.val();
  
                          if (val) {
                                  this.setTime(val);
                          }
      },
  
      updateWidget: function() {
        if (this.$widget === false) {
          return;
        }
  
        var hour = this.hour < 10 ? '0' + this.hour : this.hour,
            minute = this.minute < 10 ? '0' + this.minute : this.minute,
            second = this.second < 10 ? '0' + this.second : this.second;
  
        if (this.showInputs) {
          this.$widget.find('input.bootstrap-timepicker-hour').val(hour);
          this.$widget.find('input.bootstrap-timepicker-minute').val(minute);
  
          if (this.showSeconds) {
            this.$widget.find('input.bootstrap-timepicker-second').val(second);
          }
          if (this.showMeridian) {
            this.$widget.find('input.bootstrap-timepicker-meridian').val(this.meridian);
          }
        } else {
          this.$widget.find('span.bootstrap-timepicker-hour').text(hour);
          this.$widget.find('span.bootstrap-timepicker-minute').text(minute);
  
          if (this.showSeconds) {
            this.$widget.find('span.bootstrap-timepicker-second').text(second);
          }
          if (this.showMeridian) {
            this.$widget.find('span.bootstrap-timepicker-meridian').text(this.meridian);
          }
        }
      },
  
      updateFromWidgetInputs: function() {
        if (this.$widget === false) {
          return;
        }
        var time = $('input.bootstrap-timepicker-hour', this.$widget).val() + ':' +
          $('input.bootstrap-timepicker-minute', this.$widget).val() +
          (this.showSeconds ? ':' + $('input.bootstrap-timepicker-second', this.$widget).val() : '') +
          (this.showMeridian ? ' ' + $('input.bootstrap-timepicker-meridian', this.$widget).val() : '');
  
        this.setTime(time);
      },
  
      widgetClick: function(e) {
        e.stopPropagation();
        e.preventDefault();
  
        var action = $(e.target).closest('a').data('action');
        if (action) {
          this[action]();
        }
      },
  
      widgetKeydown: function(e) {
        var $input = $(e.target).closest('input'),
            name = $input.attr('name');
  
        switch (e.keyCode) {
        case 9: //tab
          if (this.showMeridian) {
            if (name === 'meridian') {
              return this.hideWidget();
            }
          } else {
            if (this.showSeconds) {
              if (name === 'second') {
                return this.hideWidget();
              }
            } else {
              if (name === 'minute') {
                return this.hideWidget();
              }
            }
          }
  
          this.updateFromWidgetInputs();
          break;
        case 27: // escape
          this.hideWidget();
          break;
        case 38: // up arrow
          e.preventDefault();
          switch (name) {
          case 'hour':
            this.incrementHour();
            break;
          case 'minute':
            this.incrementMinute();
            break;
          case 'second':
            this.incrementSecond();
            break;
          case 'meridian':
            this.toggleMeridian();
            break;
          }
          break;
        case 40: // down arrow
          e.preventDefault();
          switch (name) {
          case 'hour':
            this.decrementHour();
            break;
          case 'minute':
            this.decrementMinute();
            break;
          case 'second':
            this.decrementSecond();
            break;
          case 'meridian':
            this.toggleMeridian();
            break;
          }
          break;
        }
      }
    };
  
  
    //TIMEPICKER PLUGIN DEFINITION
    $.fn.timepicker = function(option) {
      var args = Array.apply(null, arguments);
      args.shift();
      return this.each(function() {
        var $this = $(this),
          data = $this.data('timepicker'),
          options = typeof option === 'object' && option;
  
        if (!data) {
          $this.data('timepicker', (data = new Timepicker(this, $.extend({}, $.fn.timepicker.defaults, options, $(this).data()))));
        }
  
        if (typeof option === 'string') {
          data[option].apply(data, args);
        }
      });
    };
  
    $.fn.timepicker.defaults = {
      defaultTime: 'current',
      disableFocus: false,
      isOpen: false,
      minuteStep: 15,
      modalBackdrop: false,
      secondStep: 15,
      showSeconds: false,
      showInputs: true,
      showMeridian: true,
      template: 'dropdown',
      appendWidgetTo: '.bootstrap-timepicker',
  	upArrowStyle: 'glyphicon glyphicon-chevron-up',
  	downArrowStyle: 'glyphicon glyphicon-chevron-down',
  	containerClass: 'bootstrap-timepicker'
    };
  
    $.fn.timepicker.Constructor = Timepicker;
  
  })(jQuery, window, document);
  
  /*! Copyright (c) 2011 Piotr Rochala (http://rocha.la)
   * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
   * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
   *
   * Version: 1.3.8
   *
   */
  (function($) {
  
    $.fn.extend({
      slimScroll: function(options) {
  
        var defaults = {
  
          // width in pixels of the visible scroll area
          width : 'auto',
  
          // height in pixels of the visible scroll area
          height : '250px',
  
          // width in pixels of the scrollbar and rail
          size : '7px',
  
          // scrollbar color, accepts any hex/color value
          color: '#000',
  
          // scrollbar position - left/right
          position : 'right',
  
          // distance in pixels between the side edge and the scrollbar
          distance : '1px',
  
          // default scroll position on load - top / bottom / $('selector')
          start : 'top',
  
          // sets scrollbar opacity
          opacity : .4,
  
          // enables always-on mode for the scrollbar
          alwaysVisible : false,
  
          // check if we should hide the scrollbar when user is hovering over
          disableFadeOut : false,
  
          // sets visibility of the rail
          railVisible : false,
  
          // sets rail color
          railColor : '#333',
  
          // sets rail opacity
          railOpacity : .2,
  
          // whether  we should use jQuery UI Draggable to enable bar dragging
          railDraggable : true,
  
          // defautlt CSS class of the slimscroll rail
          railClass : 'slimScrollRail',
  
          // defautlt CSS class of the slimscroll bar
          barClass : 'slimScrollBar',
  
          // defautlt CSS class of the slimscroll wrapper
          wrapperClass : 'slimScrollDiv',
  
          // check if mousewheel should scroll the window if we reach top/bottom
          allowPageScroll : false,
  
          // scroll amount applied to each mouse wheel step
          wheelStep : 20,
  
          // scroll amount applied when user is using gestures
          touchScrollStep : 200,
  
          // sets border radius
          borderRadius: '7px',
  
          // sets border radius of the rail
          railBorderRadius : '7px'
        };
  
        var o = $.extend(defaults, options);
  
        // do it for every element that matches selector
        this.each(function(){
  
        var isOverPanel, isOverBar, isDragg, queueHide, touchDif,
          barHeight, percentScroll, lastScroll,
          divS = '<div></div>',
          minBarHeight = 30,
          releaseScroll = false;
  
          // used in event handlers and for better minification
          var me = $(this);
  
          // ensure we are not binding it again
          if (me.parent().hasClass(o.wrapperClass))
          {
              // start from last bar position
              var offset = me.scrollTop();
  
              // find bar and rail
              bar = me.siblings('.' + o.barClass);
              rail = me.siblings('.' + o.railClass);
  
              getBarHeight();
  
              // check if we should scroll existing instance
              if ($.isPlainObject(options))
              {
                // Pass height: auto to an existing slimscroll object to force a resize after contents have changed
                if ( 'height' in options && options.height == 'auto' ) {
                  me.parent().css('height', 'auto');
                  me.css('height', 'auto');
                  var height = me.parent().parent().height();
                  me.parent().css('height', height);
                  me.css('height', height);
                } else if ('height' in options) {
                  var h = options.height;
                  me.parent().css('height', h);
                  me.css('height', h);
                }
  
                if ('scrollTo' in options)
                {
                  // jump to a static point
                  offset = parseInt(o.scrollTo);
                }
                else if ('scrollBy' in options)
                {
                  // jump by value pixels
                  offset += parseInt(o.scrollBy);
                }
                else if ('destroy' in options)
                {
                  // remove slimscroll elements
                  bar.remove();
                  rail.remove();
                  me.unwrap();
                  return;
                }
  
                // scroll content by the given offset
                scrollContent(offset, false, true);
              }
  
              return;
          }
          else if ($.isPlainObject(options))
          {
              if ('destroy' in options)
              {
              	return;
              }
          }
  
          // optionally set height to the parent's height
          o.height = (o.height == 'auto') ? me.parent().height() : o.height;
  
          // wrap content
          var wrapper = $(divS)
            .addClass(o.wrapperClass)
            .css({
              position: 'relative',
              overflow: 'hidden',
              width: o.width,
              height: o.height
            });
  
          // update style for the div
          me.css({
            overflow: 'hidden',
            width: o.width,
            height: o.height
          });
  
          // create scrollbar rail
          var rail = $(divS)
            .addClass(o.railClass)
            .css({
              width: o.size,
              height: '100%',
              position: 'absolute',
              top: 0,
              display: (o.alwaysVisible && o.railVisible) ? 'block' : 'none',
              'border-radius': o.railBorderRadius,
              background: o.railColor,
              opacity: o.railOpacity,
              zIndex: 90
            });
  
          // create scrollbar
          var bar = $(divS)
            .addClass(o.barClass)
            .css({
              background: o.color,
              width: o.size,
              position: 'absolute',
              top: 0,
              opacity: o.opacity,
              display: o.alwaysVisible ? 'block' : 'none',
              'border-radius' : o.borderRadius,
              BorderRadius: o.borderRadius,
              MozBorderRadius: o.borderRadius,
              WebkitBorderRadius: o.borderRadius,
              zIndex: 99
            });
  
          // set position
          var posCss = (o.position == 'right') ? { right: o.distance } : { left: o.distance };
          rail.css(posCss);
          bar.css(posCss);
  
          // wrap it
          me.wrap(wrapper);
  
          // append to parent div
          me.parent().append(bar);
          me.parent().append(rail);
  
          // make it draggable and no longer dependent on the jqueryUI
          if (o.railDraggable){
            bar.bind("mousedown", function(e) {
              var $doc = $(document);
              isDragg = true;
              t = parseFloat(bar.css('top'));
              pageY = e.pageY;
  
              $doc.bind("mousemove.slimscroll", function(e){
                currTop = t + e.pageY - pageY;
                bar.css('top', currTop);
                scrollContent(0, bar.position().top, false);// scroll content
              });
  
              $doc.bind("mouseup.slimscroll", function(e) {
                isDragg = false;hideBar();
                $doc.unbind('.slimscroll');
              });
              return false;
            }).bind("selectstart.slimscroll", function(e){
              e.stopPropagation();
              e.preventDefault();
              return false;
            });
          }
  
          // on rail over
          rail.hover(function(){
            showBar();
          }, function(){
            hideBar();
          });
  
          // on bar over
          bar.hover(function(){
            isOverBar = true;
          }, function(){
            isOverBar = false;
          });
  
          // show on parent mouseover
          me.hover(function(){
            isOverPanel = true;
            showBar();
            hideBar();
          }, function(){
            isOverPanel = false;
            hideBar();
          });
  
          // support for mobile
          me.bind('touchstart', function(e,b){
            if (e.originalEvent.touches.length)
            {
              // record where touch started
              touchDif = e.originalEvent.touches[0].pageY;
            }
          });
  
          me.bind('touchmove', function(e){
            // prevent scrolling the page if necessary
            if(!releaseScroll)
            {
    		      e.originalEvent.preventDefault();
  		      }
            if (e.originalEvent.touches.length)
            {
              // see how far user swiped
              var diff = (touchDif - e.originalEvent.touches[0].pageY) / o.touchScrollStep;
              // scroll content
              scrollContent(diff, true);
              touchDif = e.originalEvent.touches[0].pageY;
            }
          });
  
          // set up initial height
          getBarHeight();
  
          // check start position
          if (o.start === 'bottom')
          {
            // scroll content to bottom
            bar.css({ top: me.outerHeight() - bar.outerHeight() });
            scrollContent(0, true);
          }
          else if (o.start !== 'top')
          {
            // assume jQuery selector
            scrollContent($(o.start).position().top, null, true);
  
            // make sure bar stays hidden
            if (!o.alwaysVisible) { bar.hide(); }
          }
  
          // attach scroll events
          attachWheel(this);
  
          function _onWheel(e)
          {
            // use mouse wheel only when mouse is over
            if (!isOverPanel) { return; }
  
            var e = e || window.event;
  
            var delta = 0;
            if (e.wheelDelta) { delta = -e.wheelDelta/120; }
            if (e.detail) { delta = e.detail / 3; }
  
            var target = e.target || e.srcTarget || e.srcElement;
            if ($(target).closest('.' + o.wrapperClass).is(me.parent())) {
              // scroll content
              scrollContent(delta, true);
            }
  
            // stop window scroll
            if (e.preventDefault && !releaseScroll) { e.preventDefault(); }
            if (!releaseScroll) { e.returnValue = false; }
          }
  
          function scrollContent(y, isWheel, isJump)
          {
            releaseScroll = false;
            var delta = y;
            var maxTop = me.outerHeight() - bar.outerHeight();
  
            if (isWheel)
            {
              // move bar with mouse wheel
              delta = parseInt(bar.css('top')) + y * parseInt(o.wheelStep) / 100 * bar.outerHeight();
  
              // move bar, make sure it doesn't go out
              delta = Math.min(Math.max(delta, 0), maxTop);
  
              // if scrolling down, make sure a fractional change to the
              // scroll position isn't rounded away when the scrollbar's CSS is set
              // this flooring of delta would happened automatically when
              // bar.css is set below, but we floor here for clarity
              delta = (y > 0) ? Math.ceil(delta) : Math.floor(delta);
  
              // scroll the scrollbar
              bar.css({ top: delta + 'px' });
            }
  
            // calculate actual scroll amount
            percentScroll = parseInt(bar.css('top')) / (me.outerHeight() - bar.outerHeight());
            delta = percentScroll * (me[0].scrollHeight - me.outerHeight());
  
            if (isJump)
            {
              delta = y;
              var offsetTop = delta / me[0].scrollHeight * me.outerHeight();
              offsetTop = Math.min(Math.max(offsetTop, 0), maxTop);
              bar.css({ top: offsetTop + 'px' });
            }
  
            // scroll content
            me.scrollTop(delta);
  
            // fire scrolling event
            me.trigger('slimscrolling', ~~delta);
  
            // ensure bar is visible
            showBar();
  
            // trigger hide when scroll is stopped
            hideBar();
          }
  
          function attachWheel(target)
          {
            if (window.addEventListener)
            {
              target.addEventListener('DOMMouseScroll', _onWheel, false );
              target.addEventListener('mousewheel', _onWheel, false );
            }
            else
            {
              document.attachEvent("onmousewheel", _onWheel)
            }
          }
  
          function getBarHeight()
          {
            // calculate scrollbar height and make sure it is not too small
            barHeight = Math.max((me.outerHeight() / me[0].scrollHeight) * me.outerHeight(), minBarHeight);
            bar.css({ height: barHeight + 'px' });
  
            // hide scrollbar if content is not long enough
            var display = barHeight == me.outerHeight() ? 'none' : 'block';
            bar.css({ display: display });
          }
  
          function showBar()
          {
            // recalculate bar height
            getBarHeight();
            clearTimeout(queueHide);
  
            // when bar reached top or bottom
            if (percentScroll == ~~percentScroll)
            {
              //release wheel
              releaseScroll = o.allowPageScroll;
  
              // publish approporiate event
              if (lastScroll != percentScroll)
              {
                  var msg = (~~percentScroll == 0) ? 'top' : 'bottom';
                  me.trigger('slimscroll', msg);
              }
            }
            else
            {
              releaseScroll = false;
            }
            lastScroll = percentScroll;
  
            // show only when required
            if(barHeight >= me.outerHeight()) {
              //allow window scroll
              releaseScroll = true;
              return;
            }
            bar.stop(true,true).fadeIn('fast');
            if (o.railVisible) { rail.stop(true,true).fadeIn('fast'); }
          }
  
          function hideBar()
          {
            // only hide when options allow it
            if (!o.alwaysVisible)
            {
              queueHide = setTimeout(function(){
                if (!(o.disableFadeOut && isOverPanel) && !isOverBar && !isDragg)
                {
                  bar.fadeOut('slow');
                  rail.fadeOut('slow');
                }
              }, 1000);
            }
          }
  
        });
  
        // maintain chainability
        return this;
      }
    });
  
    $.fn.extend({
      slimscroll: $.fn.slimScroll
    });
  
  })(jQuery);
  
  /*! iCheck v1.0.1 by Damir Sultanov, http://git.io/arlzeA, MIT Licensed */
  (function(h){function F(a,b,d){var c=a[0],e=/er/.test(d)?m:/bl/.test(d)?s:l,f=d==H?{checked:c[l],disabled:c[s],indeterminate:"true"==a.attr(m)||"false"==a.attr(w)}:c[e];if(/^(ch|di|in)/.test(d)&&!f)D(a,e);else if(/^(un|en|de)/.test(d)&&f)t(a,e);else if(d==H)for(e in f)f[e]?D(a,e,!0):t(a,e,!0);else if(!b||"toggle"==d){if(!b)a[p]("ifClicked");f?c[n]!==u&&t(a,e):D(a,e)}}function D(a,b,d){var c=a[0],e=a.parent(),f=b==l,A=b==m,B=b==s,K=A?w:f?E:"enabled",p=k(a,K+x(c[n])),N=k(a,b+x(c[n]));if(!0!==c[b]){if(!d&&
  b==l&&c[n]==u&&c.name){var C=a.closest("form"),r='input[name="'+c.name+'"]',r=C.length?C.find(r):h(r);r.each(function(){this!==c&&h(this).data(q)&&t(h(this),b)})}A?(c[b]=!0,c[l]&&t(a,l,"force")):(d||(c[b]=!0),f&&c[m]&&t(a,m,!1));L(a,f,b,d)}c[s]&&k(a,y,!0)&&e.find("."+I).css(y,"default");e[v](N||k(a,b)||"");B?e.attr("aria-disabled","true"):e.attr("aria-checked",A?"mixed":"true");e[z](p||k(a,K)||"")}function t(a,b,d){var c=a[0],e=a.parent(),f=b==l,h=b==m,q=b==s,p=h?w:f?E:"enabled",t=k(a,p+x(c[n])),
  u=k(a,b+x(c[n]));if(!1!==c[b]){if(h||!d||"force"==d)c[b]=!1;L(a,f,p,d)}!c[s]&&k(a,y,!0)&&e.find("."+I).css(y,"pointer");e[z](u||k(a,b)||"");q?e.attr("aria-disabled","false"):e.attr("aria-checked","false");e[v](t||k(a,p)||"")}function M(a,b){if(a.data(q)){a.parent().html(a.attr("style",a.data(q).s||""));if(b)a[p](b);a.off(".i").unwrap();h(G+'[for="'+a[0].id+'"]').add(a.closest(G)).off(".i")}}function k(a,b,d){if(a.data(q))return a.data(q).o[b+(d?"":"Class")]}function x(a){return a.charAt(0).toUpperCase()+
  a.slice(1)}function L(a,b,d,c){if(!c){if(b)a[p]("ifToggled");a[p]("ifChanged")[p]("if"+x(d))}}var q="iCheck",I=q+"-helper",u="radio",l="checked",E="un"+l,s="disabled",w="determinate",m="in"+w,H="update",n="type",v="addClass",z="removeClass",p="trigger",G="label",y="cursor",J=/ipad|iphone|ipod|android|blackberry|windows phone|opera mini|silk/i.test(navigator.userAgent);h.fn[q]=function(a,b){var d='input[type="checkbox"], input[type="'+u+'"]',c=h(),e=function(a){a.each(function(){var a=h(this);c=a.is(d)?
  c.add(a):c.add(a.find(d))})};if(/^(check|uncheck|toggle|indeterminate|determinate|disable|enable|update|destroy)$/i.test(a))return a=a.toLowerCase(),e(this),c.each(function(){var c=h(this);"destroy"==a?M(c,"ifDestroyed"):F(c,!0,a);h.isFunction(b)&&b()});if("object"!=typeof a&&a)return this;var f=h.extend({checkedClass:l,disabledClass:s,indeterminateClass:m,labelHover:!0,aria:!1},a),k=f.handle,B=f.hoverClass||"hover",x=f.focusClass||"focus",w=f.activeClass||"active",y=!!f.labelHover,C=f.labelHoverClass||
  "hover",r=(""+f.increaseArea).replace("%","")|0;if("checkbox"==k||k==u)d='input[type="'+k+'"]';-50>r&&(r=-50);e(this);return c.each(function(){var a=h(this);M(a);var c=this,b=c.id,e=-r+"%",d=100+2*r+"%",d={position:"absolute",top:e,left:e,display:"block",width:d,height:d,margin:0,padding:0,background:"#fff",border:0,opacity:0},e=J?{position:"absolute",visibility:"hidden"}:r?d:{position:"absolute",opacity:0},k="checkbox"==c[n]?f.checkboxClass||"icheckbox":f.radioClass||"i"+u,m=h(G+'[for="'+b+'"]').add(a.closest(G)),
  A=!!f.aria,E=q+"-"+Math.random().toString(36).replace("0.",""),g='<div class="'+k+'" '+(A?'role="'+c[n]+'" ':"");m.length&&A&&m.each(function(){g+='aria-labelledby="';this.id?g+=this.id:(this.id=E,g+=E);g+='"'});g=a.wrap(g+"/>")[p]("ifCreated").parent().append(f.insert);d=h('<ins class="'+I+'"/>').css(d).appendTo(g);a.data(q,{o:f,s:a.attr("style")}).css(e);f.inheritClass&&g[v](c.className||"");f.inheritID&&b&&g.attr("id",q+"-"+b);"static"==g.css("position")&&g.css("position","relative");F(a,!0,H);
  if(m.length)m.on("click.i mouseover.i mouseout.i touchbegin.i touchend.i",function(b){var d=b[n],e=h(this);if(!c[s]){if("click"==d){if(h(b.target).is("a"))return;F(a,!1,!0)}else y&&(/ut|nd/.test(d)?(g[z](B),e[z](C)):(g[v](B),e[v](C)));if(J)b.stopPropagation();else return!1}});a.on("click.i focus.i blur.i keyup.i keydown.i keypress.i",function(b){var d=b[n];b=b.keyCode;if("click"==d)return!1;if("keydown"==d&&32==b)return c[n]==u&&c[l]||(c[l]?t(a,l):D(a,l)),!1;if("keyup"==d&&c[n]==u)!c[l]&&D(a,l);else if(/us|ur/.test(d))g["blur"==
  d?z:v](x)});d.on("click mousedown mouseup mouseover mouseout touchbegin.i touchend.i",function(b){var d=b[n],e=/wn|up/.test(d)?w:B;if(!c[s]){if("click"==d)F(a,!1,!0);else{if(/wn|er|in/.test(d))g[v](e);else g[z](e+" "+w);if(m.length&&y&&e==B)m[/ut|nd/.test(d)?z:v](C)}if(J)b.stopPropagation();else return!1}})})}})(window.jQuery||window.Zepto);
  
  ;(function () {
  	'use strict';
  
  	/**
  	 * @preserve FastClick: polyfill to remove click delays on browsers with touch UIs.
  	 *
  	 * @codingstandard ftlabs-jsv2
  	 * @copyright The Financial Times Limited [All Rights Reserved]
  	 * @license MIT License (see LICENSE.txt)
  	 */
  
  	/*jslint browser:true, node:true*/
  	/*global define, Event, Node*/
  
  
  	/**
  	 * Instantiate fast-clicking listeners on the specified layer.
  	 *
  	 * @constructor
  	 * @param {Element} layer The layer to listen on
  	 * @param {Object} [options={}] The options to override the defaults
  	 */
  	function FastClick(layer, options) {
  		var oldOnClick;
  
  		options = options || {};
  
  		/**
  		 * Whether a click is currently being tracked.
  		 *
  		 * @type boolean
  		 */
  		this.trackingClick = false;
  
  
  		/**
  		 * Timestamp for when click tracking started.
  		 *
  		 * @type number
  		 */
  		this.trackingClickStart = 0;
  
  
  		/**
  		 * The element being tracked for a click.
  		 *
  		 * @type EventTarget
  		 */
  		this.targetElement = null;
  
  
  		/**
  		 * X-coordinate of touch start event.
  		 *
  		 * @type number
  		 */
  		this.touchStartX = 0;
  
  
  		/**
  		 * Y-coordinate of touch start event.
  		 *
  		 * @type number
  		 */
  		this.touchStartY = 0;
  
  
  		/**
  		 * ID of the last touch, retrieved from Touch.identifier.
  		 *
  		 * @type number
  		 */
  		this.lastTouchIdentifier = 0;
  
  
  		/**
  		 * Touchmove boundary, beyond which a click will be cancelled.
  		 *
  		 * @type number
  		 */
  		this.touchBoundary = options.touchBoundary || 10;
  
  
  		/**
  		 * The FastClick layer.
  		 *
  		 * @type Element
  		 */
  		this.layer = layer;
  
  		/**
  		 * The minimum time between tap(touchstart and touchend) events
  		 *
  		 * @type number
  		 */
  		this.tapDelay = options.tapDelay || 200;
  
  		/**
  		 * The maximum time for a tap
  		 *
  		 * @type number
  		 */
  		this.tapTimeout = options.tapTimeout || 700;
  
  		if (FastClick.notNeeded(layer)) {
  			return;
  		}
  
  		// Some old versions of Android don't have Function.prototype.bind
  		function bind(method, context) {
  			return function() { return method.apply(context, arguments); };
  		}
  
  
  		var methods = ['onMouse', 'onClick', 'onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'];
  		var context = this;
  		for (var i = 0, l = methods.length; i < l; i++) {
  			context[methods[i]] = bind(context[methods[i]], context);
  		}
  
  		// Set up event handlers as required
  		if (deviceIsAndroid) {
  			layer.addEventListener('mouseover', this.onMouse, true);
  			layer.addEventListener('mousedown', this.onMouse, true);
  			layer.addEventListener('mouseup', this.onMouse, true);
  		}
  
  		layer.addEventListener('click', this.onClick, true);
  		layer.addEventListener('touchstart', this.onTouchStart, false);
  		layer.addEventListener('touchmove', this.onTouchMove, false);
  		layer.addEventListener('touchend', this.onTouchEnd, false);
  		layer.addEventListener('touchcancel', this.onTouchCancel, false);
  
  		// Hack is required for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)
  		// which is how FastClick normally stops click events bubbling to callbacks registered on the FastClick
  		// layer when they are cancelled.
  		if (!Event.prototype.stopImmediatePropagation) {
  			layer.removeEventListener = function(type, callback, capture) {
  				var rmv = Node.prototype.removeEventListener;
  				if (type === 'click') {
  					rmv.call(layer, type, callback.hijacked || callback, capture);
  				} else {
  					rmv.call(layer, type, callback, capture);
  				}
  			};
  
  			layer.addEventListener = function(type, callback, capture) {
  				var adv = Node.prototype.addEventListener;
  				if (type === 'click') {
  					adv.call(layer, type, callback.hijacked || (callback.hijacked = function(event) {
  						if (!event.propagationStopped) {
  							callback(event);
  						}
  					}), capture);
  				} else {
  					adv.call(layer, type, callback, capture);
  				}
  			};
  		}
  
  		// If a handler is already declared in the element's onclick attribute, it will be fired before
  		// FastClick's onClick handler. Fix this by pulling out the user-defined handler function and
  		// adding it as listener.
  		if (typeof layer.onclick === 'function') {
  
  			// Android browser on at least 3.2 requires a new reference to the function in layer.onclick
  			// - the old one won't work if passed to addEventListener directly.
  			oldOnClick = layer.onclick;
  			layer.addEventListener('click', function(event) {
  				oldOnClick(event);
  			}, false);
  			layer.onclick = null;
  		}
  	}
  
  	/**
  	* Windows Phone 8.1 fakes user agent string to look like Android and iPhone.
  	*
  	* @type boolean
  	*/
  	var deviceIsWindowsPhone = navigator.userAgent.indexOf("Windows Phone") >= 0;
  
  	/**
  	 * Android requires exceptions.
  	 *
  	 * @type boolean
  	 */
  	var deviceIsAndroid = navigator.userAgent.indexOf('Android') > 0 && !deviceIsWindowsPhone;
  
  
  	/**
  	 * iOS requires exceptions.
  	 *
  	 * @type boolean
  	 */
  	var deviceIsIOS = /iP(ad|hone|od)/.test(navigator.userAgent) && !deviceIsWindowsPhone;
  
  
  	/**
  	 * iOS 4 requires an exception for select elements.
  	 *
  	 * @type boolean
  	 */
  	var deviceIsIOS4 = deviceIsIOS && (/OS 4_\d(_\d)?/).test(navigator.userAgent);
  
  
  	/**
  	 * iOS 6.0-7.* requires the target element to be manually derived
  	 *
  	 * @type boolean
  	 */
  	var deviceIsIOSWithBadTarget = deviceIsIOS && (/OS [6-7]_\d/).test(navigator.userAgent);
  
  	/**
  	 * BlackBerry requires exceptions.
  	 *
  	 * @type boolean
  	 */
  	var deviceIsBlackBerry10 = navigator.userAgent.indexOf('BB10') > 0;
  
  	/**
  	 * Determine whether a given element requires a native click.
  	 *
  	 * @param {EventTarget|Element} target Target DOM element
  	 * @returns {boolean} Returns true if the element needs a native click
  	 */
  	FastClick.prototype.needsClick = function(target) {
  		switch (target.nodeName.toLowerCase()) {
  
  		// Don't send a synthetic click to disabled inputs (issue #62)
  		case 'button':
  		case 'select':
  		case 'textarea':
  			if (target.disabled) {
  				return true;
  			}
  
  			break;
  		case 'input':
  
  			// File inputs need real clicks on iOS 6 due to a browser bug (issue #68)
  			if ((deviceIsIOS && target.type === 'file') || target.disabled) {
  				return true;
  			}
  
  			break;
  		case 'label':
  		case 'iframe': // iOS8 homescreen apps can prevent events bubbling into frames
  		case 'video':
  			return true;
  		}
  
  		return (/\bneedsclick\b/).test(target.className);
  	};
  
  
  	/**
  	 * Determine whether a given element requires a call to focus to simulate click into element.
  	 *
  	 * @param {EventTarget|Element} target Target DOM element
  	 * @returns {boolean} Returns true if the element requires a call to focus to simulate native click.
  	 */
  	FastClick.prototype.needsFocus = function(target) {
  		switch (target.nodeName.toLowerCase()) {
  		case 'textarea':
  			return true;
  		case 'select':
  			return !deviceIsAndroid;
  		case 'input':
  			switch (target.type) {
  			case 'button':
  			case 'checkbox':
  			case 'file':
  			case 'image':
  			case 'radio':
  			case 'submit':
  				return false;
  			}
  
  			// No point in attempting to focus disabled inputs
  			return !target.disabled && !target.readOnly;
  		default:
  			return (/\bneedsfocus\b/).test(target.className);
  		}
  	};
  
  
  	/**
  	 * Send a click event to the specified element.
  	 *
  	 * @param {EventTarget|Element} targetElement
  	 * @param {Event} event
  	 */
  	FastClick.prototype.sendClick = function(targetElement, event) {
  		var clickEvent, touch;
  
  		// On some Android devices activeElement needs to be blurred otherwise the synthetic click will have no effect (#24)
  		if (document.activeElement && document.activeElement !== targetElement) {
  			document.activeElement.blur();
  		}
  
  		touch = event.changedTouches[0];
  
  		// Synthesise a click event, with an extra attribute so it can be tracked
  		clickEvent = document.createEvent('MouseEvents');
  		clickEvent.initMouseEvent(this.determineEventType(targetElement), true, true, window, 1, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null);
  		clickEvent.forwardedTouchEvent = true;
  		targetElement.dispatchEvent(clickEvent);
  	};
  
  	FastClick.prototype.determineEventType = function(targetElement) {
  
  		//Issue #159: Android Chrome Select Box does not open with a synthetic click event
  		if (deviceIsAndroid && targetElement.tagName.toLowerCase() === 'select') {
  			return 'mousedown';
  		}
  
  		return 'click';
  	};
  
  
  	/**
  	 * @param {EventTarget|Element} targetElement
  	 */
  	FastClick.prototype.focus = function(targetElement) {
  		var length;
  
  		// Issue #160: on iOS 7, some input elements (e.g. date datetime month) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724.
  		if (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time' && targetElement.type !== 'month') {
  			length = targetElement.value.length;
  			targetElement.setSelectionRange(length, length);
  		} else {
  			targetElement.focus();
  		}
  	};
  
  
  	/**
  	 * Check whether the given target element is a child of a scrollable layer and if so, set a flag on it.
  	 *
  	 * @param {EventTarget|Element} targetElement
  	 */
  	FastClick.prototype.updateScrollParent = function(targetElement) {
  		var scrollParent, parentElement;
  
  		scrollParent = targetElement.fastClickScrollParent;
  
  		// Attempt to discover whether the target element is contained within a scrollable layer. Re-check if the
  		// target element was moved to another parent.
  		if (!scrollParent || !scrollParent.contains(targetElement)) {
  			parentElement = targetElement;
  			do {
  				if (parentElement.scrollHeight > parentElement.offsetHeight) {
  					scrollParent = parentElement;
  					targetElement.fastClickScrollParent = parentElement;
  					break;
  				}
  
  				parentElement = parentElement.parentElement;
  			} while (parentElement);
  		}
  
  		// Always update the scroll top tracker if possible.
  		if (scrollParent) {
  			scrollParent.fastClickLastScrollTop = scrollParent.scrollTop;
  		}
  	};
  
  
  	/**
  	 * @param {EventTarget} targetElement
  	 * @returns {Element|EventTarget}
  	 */
  	FastClick.prototype.getTargetElementFromEventTarget = function(eventTarget) {
  
  		// On some older browsers (notably Safari on iOS 4.1 - see issue #56) the event target may be a text node.
  		if (eventTarget.nodeType === Node.TEXT_NODE) {
  			return eventTarget.parentNode;
  		}
  
  		return eventTarget;
  	};
  
  
  	/**
  	 * On touch start, record the position and scroll offset.
  	 *
  	 * @param {Event} event
  	 * @returns {boolean}
  	 */
  	FastClick.prototype.onTouchStart = function(event) {
  		var targetElement, touch, selection;
  
  		// Ignore multiple touches, otherwise pinch-to-zoom is prevented if both fingers are on the FastClick element (issue #111).
  		if (event.targetTouches.length > 1) {
  			return true;
  		}
  
  		targetElement = this.getTargetElementFromEventTarget(event.target);
  		touch = event.targetTouches[0];
  
  		if (deviceIsIOS) {
  
  			// Only trusted events will deselect text on iOS (issue #49)
  			selection = window.getSelection();
  			if (selection.rangeCount && !selection.isCollapsed) {
  				return true;
  			}
  
  			if (!deviceIsIOS4) {
  
  				// Weird things happen on iOS when an alert or confirm dialog is opened from a click event callback (issue #23):
  				// when the user next taps anywhere else on the page, new touchstart and touchend events are dispatched
  				// with the same identifier as the touch event that previously triggered the click that triggered the alert.
  				// Sadly, there is an issue on iOS 4 that causes some normal touch events to have the same identifier as an
  				// immediately preceeding touch event (issue #52), so this fix is unavailable on that platform.
  				// Issue 120: touch.identifier is 0 when Chrome dev tools 'Emulate touch events' is set with an iOS device UA string,
  				// which causes all touch events to be ignored. As this block only applies to iOS, and iOS identifiers are always long,
  				// random integers, it's safe to to continue if the identifier is 0 here.
  				if (touch.identifier && touch.identifier === this.lastTouchIdentifier) {
  					event.preventDefault();
  					return false;
  				}
  
  				this.lastTouchIdentifier = touch.identifier;
  
  				// If the target element is a child of a scrollable layer (using -webkit-overflow-scrolling: touch) and:
  				// 1) the user does a fling scroll on the scrollable layer
  				// 2) the user stops the fling scroll with another tap
  				// then the event.target of the last 'touchend' event will be the element that was under the user's finger
  				// when the fling scroll was started, causing FastClick to send a click event to that layer - unless a check
  				// is made to ensure that a parent layer was not scrolled before sending a synthetic click (issue #42).
  				this.updateScrollParent(targetElement);
  			}
  		}
  
  		this.trackingClick = true;
  		this.trackingClickStart = event.timeStamp;
  		this.targetElement = targetElement;
  
  		this.touchStartX = touch.pageX;
  		this.touchStartY = touch.pageY;
  
  		// Prevent phantom clicks on fast double-tap (issue #36)
  		if ((event.timeStamp - this.lastClickTime) < this.tapDelay) {
  			event.preventDefault();
  		}
  
  		return true;
  	};
  
  
  	/**
  	 * Based on a touchmove event object, check whether the touch has moved past a boundary since it started.
  	 *
  	 * @param {Event} event
  	 * @returns {boolean}
  	 */
  	FastClick.prototype.touchHasMoved = function(event) {
  		var touch = event.changedTouches[0], boundary = this.touchBoundary;
  
  		if (Math.abs(touch.pageX - this.touchStartX) > boundary || Math.abs(touch.pageY - this.touchStartY) > boundary) {
  			return true;
  		}
  
  		return false;
  	};
  
  
  	/**
  	 * Update the last position.
  	 *
  	 * @param {Event} event
  	 * @returns {boolean}
  	 */
  	FastClick.prototype.onTouchMove = function(event) {
  		if (!this.trackingClick) {
  			return true;
  		}
  
  		// If the touch has moved, cancel the click tracking
  		if (this.targetElement !== this.getTargetElementFromEventTarget(event.target) || this.touchHasMoved(event)) {
  			this.trackingClick = false;
  			this.targetElement = null;
  		}
  
  		return true;
  	};
  
  
  	/**
  	 * Attempt to find the labelled control for the given label element.
  	 *
  	 * @param {EventTarget|HTMLLabelElement} labelElement
  	 * @returns {Element|null}
  	 */
  	FastClick.prototype.findControl = function(labelElement) {
  
  		// Fast path for newer browsers supporting the HTML5 control attribute
  		if (labelElement.control !== undefined) {
  			return labelElement.control;
  		}
  
  		// All browsers under test that support touch events also support the HTML5 htmlFor attribute
  		if (labelElement.htmlFor) {
  			return document.getElementById(labelElement.htmlFor);
  		}
  
  		// If no for attribute exists, attempt to retrieve the first labellable descendant element
  		// the list of which is defined here: http://www.w3.org/TR/html5/forms.html#category-label
  		return labelElement.querySelector('button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea');
  	};
  
  
  	/**
  	 * On touch end, determine whether to send a click event at once.
  	 *
  	 * @param {Event} event
  	 * @returns {boolean}
  	 */
  	FastClick.prototype.onTouchEnd = function(event) {
  		var forElement, trackingClickStart, targetTagName, scrollParent, touch, targetElement = this.targetElement;
  
  		if (!this.trackingClick) {
  			return true;
  		}
  
  		// Prevent phantom clicks on fast double-tap (issue #36)
  		if ((event.timeStamp - this.lastClickTime) < this.tapDelay) {
  			this.cancelNextClick = true;
  			return true;
  		}
  
  		if ((event.timeStamp - this.trackingClickStart) > this.tapTimeout) {
  			return true;
  		}
  
  		// Reset to prevent wrong click cancel on input (issue #156).
  		this.cancelNextClick = false;
  
  		this.lastClickTime = event.timeStamp;
  
  		trackingClickStart = this.trackingClickStart;
  		this.trackingClick = false;
  		this.trackingClickStart = 0;
  
  		// On some iOS devices, the targetElement supplied with the event is invalid if the layer
  		// is performing a transition or scroll, and has to be re-detected manually. Note that
  		// for this to function correctly, it must be called *after* the event target is checked!
  		// See issue #57; also filed as rdar://13048589 .
  		if (deviceIsIOSWithBadTarget) {
  			touch = event.changedTouches[0];
  
  			// In certain cases arguments of elementFromPoint can be negative, so prevent setting targetElement to null
  			targetElement = document.elementFromPoint(touch.pageX - window.pageXOffset, touch.pageY - window.pageYOffset) || targetElement;
  			targetElement.fastClickScrollParent = this.targetElement.fastClickScrollParent;
  		}
  
  		targetTagName = targetElement.tagName.toLowerCase();
  		if (targetTagName === 'label') {
  			forElement = this.findControl(targetElement);
  			if (forElement) {
  				this.focus(targetElement);
  				if (deviceIsAndroid) {
  					return false;
  				}
  
  				targetElement = forElement;
  			}
  		} else if (this.needsFocus(targetElement)) {
  
  			// Case 1: If the touch started a while ago (best guess is 100ms based on tests for issue #36) then focus will be triggered anyway. Return early and unset the target element reference so that the subsequent click will be allowed through.
  			// Case 2: Without this exception for input elements tapped when the document is contained in an iframe, then any inputted text won't be visible even though the value attribute is updated as the user types (issue #37).
  			if ((event.timeStamp - trackingClickStart) > 100 || (deviceIsIOS && window.top !== window && targetTagName === 'input')) {
  				this.targetElement = null;
  				return false;
  			}
  
  			this.focus(targetElement);
  			this.sendClick(targetElement, event);
  
  			// Select elements need the event to go through on iOS 4, otherwise the selector menu won't open.
  			// Also this breaks opening selects when VoiceOver is active on iOS6, iOS7 (and possibly others)
  			if (!deviceIsIOS || targetTagName !== 'select') {
  				this.targetElement = null;
  				event.preventDefault();
  			}
  
  			return false;
  		}
  
  		if (deviceIsIOS && !deviceIsIOS4) {
  
  			// Don't send a synthetic click event if the target element is contained within a parent layer that was scrolled
  			// and this tap is being used to stop the scrolling (usually initiated by a fling - issue #42).
  			scrollParent = targetElement.fastClickScrollParent;
  			if (scrollParent && scrollParent.fastClickLastScrollTop !== scrollParent.scrollTop) {
  				return true;
  			}
  		}
  
  		// Prevent the actual click from going though - unless the target node is marked as requiring
  		// real clicks or if it is in the whitelist in which case only non-programmatic clicks are permitted.
  		if (!this.needsClick(targetElement)) {
  			event.preventDefault();
  			this.sendClick(targetElement, event);
  		}
  
  		return false;
  	};
  
  
  	/**
  	 * On touch cancel, stop tracking the click.
  	 *
  	 * @returns {void}
  	 */
  	FastClick.prototype.onTouchCancel = function() {
  		this.trackingClick = false;
  		this.targetElement = null;
  	};
  
  
  	/**
  	 * Determine mouse events which should be permitted.
  	 *
  	 * @param {Event} event
  	 * @returns {boolean}
  	 */
  	FastClick.prototype.onMouse = function(event) {
  
  		// If a target element was never set (because a touch event was never fired) allow the event
  		if (!this.targetElement) {
  			return true;
  		}
  
  		if (event.forwardedTouchEvent) {
  			return true;
  		}
  
  		// Programmatically generated events targeting a specific element should be permitted
  		if (!event.cancelable) {
  			return true;
  		}
  
  		// Derive and check the target element to see whether the mouse event needs to be permitted;
  		// unless explicitly enabled, prevent non-touch click events from triggering actions,
  		// to prevent ghost/doubleclicks.
  		if (!this.needsClick(this.targetElement) || this.cancelNextClick) {
  
  			// Prevent any user-added listeners declared on FastClick element from being fired.
  			if (event.stopImmediatePropagation) {
  				event.stopImmediatePropagation();
  			} else {
  
  				// Part of the hack for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)
  				event.propagationStopped = true;
  			}
  
  			// Cancel the event
  			event.stopPropagation();
  			event.preventDefault();
  
  			return false;
  		}
  
  		// If the mouse event is permitted, return true for the action to go through.
  		return true;
  	};
  
  
  	/**
  	 * On actual clicks, determine whether this is a touch-generated click, a click action occurring
  	 * naturally after a delay after a touch (which needs to be cancelled to avoid duplication), or
  	 * an actual click which should be permitted.
  	 *
  	 * @param {Event} event
  	 * @returns {boolean}
  	 */
  	FastClick.prototype.onClick = function(event) {
  		var permitted;
  
  		// It's possible for another FastClick-like library delivered with third-party code to fire a click event before FastClick does (issue #44). In that case, set the click-tracking flag back to false and return early. This will cause onTouchEnd to return early.
  		if (this.trackingClick) {
  			this.targetElement = null;
  			this.trackingClick = false;
  			return true;
  		}
  
  		// Very odd behaviour on iOS (issue #18): if a submit element is present inside a form and the user hits enter in the iOS simulator or clicks the Go button on the pop-up OS keyboard the a kind of 'fake' click event will be triggered with the submit-type input element as the target.
  		if (event.target.type === 'submit' && event.detail === 0) {
  			return true;
  		}
  
  		permitted = this.onMouse(event);
  
  		// Only unset targetElement if the click is not permitted. This will ensure that the check for !targetElement in onMouse fails and the browser's click doesn't go through.
  		if (!permitted) {
  			this.targetElement = null;
  		}
  
  		// If clicks are permitted, return true for the action to go through.
  		return permitted;
  	};
  
  
  	/**
  	 * Remove all FastClick's event listeners.
  	 *
  	 * @returns {void}
  	 */
  	FastClick.prototype.destroy = function() {
  		var layer = this.layer;
  
  		if (deviceIsAndroid) {
  			layer.removeEventListener('mouseover', this.onMouse, true);
  			layer.removeEventListener('mousedown', this.onMouse, true);
  			layer.removeEventListener('mouseup', this.onMouse, true);
  		}
  
  		layer.removeEventListener('click', this.onClick, true);
  		layer.removeEventListener('touchstart', this.onTouchStart, false);
  		layer.removeEventListener('touchmove', this.onTouchMove, false);
  		layer.removeEventListener('touchend', this.onTouchEnd, false);
  		layer.removeEventListener('touchcancel', this.onTouchCancel, false);
  	};
  
  
  	/**
  	 * Check whether FastClick is needed.
  	 *
  	 * @param {Element} layer The layer to listen on
  	 */
  	FastClick.notNeeded = function(layer) {
  		var metaViewport;
  		var chromeVersion;
  		var blackberryVersion;
  		var firefoxVersion;
  
  		// Devices that don't support touch don't need FastClick
  		if (typeof window.ontouchstart === 'undefined') {
  			return true;
  		}
  
  		// Chrome version - zero for other browsers
  		chromeVersion = +(/Chrome\/([0-9]+)/.exec(navigator.userAgent) || [,0])[1];
  
  		if (chromeVersion) {
  
  			if (deviceIsAndroid) {
  				metaViewport = document.querySelector('meta[name=viewport]');
  
  				if (metaViewport) {
  					// Chrome on Android with user-scalable="no" doesn't need FastClick (issue #89)
  					if (metaViewport.content.indexOf('user-scalable=no') !== -1) {
  						return true;
  					}
  					// Chrome 32 and above with width=device-width or less don't need FastClick
  					if (chromeVersion > 31 && document.documentElement.scrollWidth <= window.outerWidth) {
  						return true;
  					}
  				}
  
  			// Chrome desktop doesn't need FastClick (issue #15)
  			} else {
  				return true;
  			}
  		}
  
  		if (deviceIsBlackBerry10) {
  			blackberryVersion = navigator.userAgent.match(/Version\/([0-9]*)\.([0-9]*)/);
  
  			// BlackBerry 10.3+ does not require Fastclick library.
  			// https://github.com/ftlabs/fastclick/issues/251
  			if (blackberryVersion[1] >= 10 && blackberryVersion[2] >= 3) {
  				metaViewport = document.querySelector('meta[name=viewport]');
  
  				if (metaViewport) {
  					// user-scalable=no eliminates click delay.
  					if (metaViewport.content.indexOf('user-scalable=no') !== -1) {
  						return true;
  					}
  					// width=device-width (or less than device-width) eliminates click delay.
  					if (document.documentElement.scrollWidth <= window.outerWidth) {
  						return true;
  					}
  				}
  			}
  		}
  
  		// IE10 with -ms-touch-action: none or manipulation, which disables double-tap-to-zoom (issue #97)
  		if (layer.style.msTouchAction === 'none' || layer.style.touchAction === 'manipulation') {
  			return true;
  		}
  
  		// Firefox version - zero for other browsers
  		firefoxVersion = +(/Firefox\/([0-9]+)/.exec(navigator.userAgent) || [,0])[1];
  
  		if (firefoxVersion >= 27) {
  			// Firefox 27+ does not have tap delay if the content is not zoomable - https://bugzilla.mozilla.org/show_bug.cgi?id=922896
  
  			metaViewport = document.querySelector('meta[name=viewport]');
  			if (metaViewport && (metaViewport.content.indexOf('user-scalable=no') !== -1 || document.documentElement.scrollWidth <= window.outerWidth)) {
  				return true;
  			}
  		}
  
  		// IE11: prefixed -ms-touch-action is no longer supported and it's recomended to use non-prefixed version
  		// http://msdn.microsoft.com/en-us/library/windows/apps/Hh767313.aspx
  		if (layer.style.touchAction === 'none' || layer.style.touchAction === 'manipulation') {
  			return true;
  		}
  
  		return false;
  	};
  
  
  	/**
  	 * Factory method for creating a FastClick object
  	 *
  	 * @param {Element} layer The layer to listen on
  	 * @param {Object} [options={}] The options to override the defaults
  	 */
  	FastClick.attach = function(layer, options) {
  		return new FastClick(layer, options);
  	};
  
  
  	if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {
  
  		// AMD. Register as an anonymous module.
  		define(function() {
  			return FastClick;
  		});
  	} else if (typeof module !== 'undefined' && module.exports) {
  		module.exports = FastClick.attach;
  		module.exports.FastClick = FastClick;
  	} else {
  		window.FastClick = FastClick;
  	}
  }());
  
  /*! bootstrap3-wysihtml5-bower 2014-09-26 */
  var wysihtml5,Base,Handlebars;Object.defineProperty&&Object.getOwnPropertyDescriptor&&Object.getOwnPropertyDescriptor(Element.prototype,"textContent")&&!Object.getOwnPropertyDescriptor(Element.prototype,"textContent").get&&!function(){var a=Object.getOwnPropertyDescriptor(Element.prototype,"innerText");Object.defineProperty(Element.prototype,"textContent",{get:function(){return a.get.call(this)},set:function(b){return a.set.call(this,b)}})}(),Array.isArray||(Array.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)}),wysihtml5={version:"0.4.15",commands:{},dom:{},quirks:{},toolbar:{},lang:{},selection:{},views:{},INVISIBLE_SPACE:"﻿",EMPTY_FUNCTION:function(){},ELEMENT_NODE:1,TEXT_NODE:3,BACKSPACE_KEY:8,ENTER_KEY:13,ESCAPE_KEY:27,SPACE_KEY:32,DELETE_KEY:46},function(a,b){"function"==typeof define&&define.amd?define(a):b.rangy=a()}(function(){function a(a,b){var c=typeof a[b];return c==x||!(c!=w||!a[b])||"unknown"==c}function b(a,b){return!(typeof a[b]!=w||!a[b])}function c(a,b){return typeof a[b]!=y}function d(a){return function(b,c){for(var d=c.length;d--;)if(!a(b,c[d]))return!1;return!0}}function e(a){return a&&D(a,C)&&F(a,B)}function f(a){return b(a,"body")?a.body:a.getElementsByTagName("body")[0]}function g(c){b(window,"console")&&a(window.console,"log")&&window.console.log(c)}function h(a,b){b?window.alert(a):g(a)}function i(a){H.initialized=!0,H.supported=!1,h("Rangy is not supported on this page in your browser. Reason: "+a,H.config.alertOnFail)}function j(a){h("Rangy warning: "+a,H.config.alertOnWarn)}function k(a){return a.message||a.description||a+""}function l(){var b,c,d,h,j,l,m,o,p;if(!H.initialized){if(c=!1,d=!1,a(document,"createRange")&&(b=document.createRange(),D(b,A)&&F(b,z)&&(c=!0)),h=f(document),!h||"body"!=h.nodeName.toLowerCase())return i("No body element found"),void 0;if(h&&a(h,"createTextRange")&&(b=h.createTextRange(),e(b)&&(d=!0)),!c&&!d)return i("Neither Range nor TextRange are available"),void 0;H.initialized=!0,H.features={implementsDomRange:c,implementsTextRange:d};for(m in G)(j=G[m])instanceof n&&j.init(j,H);for(o=0,p=s.length;p>o;++o)try{s[o](H)}catch(q){l="Rangy init listener threw an exception. Continuing. Detail: "+k(q),g(l)}}}function m(a){a=a||window,l();for(var b=0,c=t.length;c>b;++b)t[b](a)}function n(a,b,c){this.name=a,this.dependencies=b,this.initialized=!1,this.supported=!1,this.initializer=c}function o(a,b,c,d){var e=new n(b,c,function(a){if(!a.initialized){a.initialized=!0;try{d(H,a),a.supported=!0}catch(c){var e="Module '"+b+"' failed to load: "+k(c);g(e)}}});G[b]=e}function p(){}function q(){}var r,s,t,u,v,w="object",x="function",y="undefined",z=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"],A=["setStart","setStartBefore","setStartAfter","setEnd","setEndBefore","setEndAfter","collapse","selectNode","selectNodeContents","compareBoundaryPoints","deleteContents","extractContents","cloneContents","insertNode","surroundContents","cloneRange","toString","detach"],B=["boundingHeight","boundingLeft","boundingTop","boundingWidth","htmlText","text"],C=["collapse","compareEndPoints","duplicate","moveToElementText","parentElement","select","setEndPoint","getBoundingClientRect"],D=d(a),E=d(b),F=d(c),G={},H={version:"1.3alpha.20140804",initialized:!1,supported:!0,util:{isHostMethod:a,isHostObject:b,isHostProperty:c,areHostMethods:D,areHostObjects:E,areHostProperties:F,isTextRange:e,getBody:f},features:{},modules:G,config:{alertOnFail:!0,alertOnWarn:!1,preferTextRange:!1,autoInitialize:typeof rangyAutoInitialize==y?!0:rangyAutoInitialize}};return H.fail=i,H.warn=j,{}.hasOwnProperty?H.util.extend=function(a,b,c){var d,e,f;for(f in b)b.hasOwnProperty(f)&&(d=a[f],e=b[f],c&&null!==d&&"object"==typeof d&&null!==e&&"object"==typeof e&&H.util.extend(d,e,!0),a[f]=e);return b.hasOwnProperty("toString")&&(a.toString=b.toString),a}:i("hasOwnProperty not supported"),function(){var a,b,c=document.createElement("div");c.appendChild(document.createElement("span")),a=[].slice;try{1==a.call(c.childNodes,0)[0].nodeType&&(b=function(b){return a.call(b,0)})}catch(d){}b||(b=function(a){var b,c,d=[];for(b=0,c=a.length;c>b;++b)d[b]=a[b];return d}),H.util.toArray=b}(),a(document,"addEventListener")?r=function(a,b,c){a.addEventListener(b,c,!1)}:a(document,"attachEvent")?r=function(a,b,c){a.attachEvent("on"+b,c)}:i("Document does not have required addEventListener or attachEvent method"),H.util.addListener=r,s=[],H.init=l,H.addInitListener=function(a){H.initialized?a(H):s.push(a)},t=[],H.addShimListener=function(a){t.push(a)},H.shim=H.createMissingNativeApi=m,n.prototype={init:function(){var a,b,c,d,e=this.dependencies||[];for(a=0,b=e.length;b>a;++a){if(d=e[a],c=G[d],!(c&&c instanceof n))throw Error("required module '"+d+"' not found");if(c.init(),!c.supported)throw Error("required module '"+d+"' not supported")}this.initializer(this)},fail:function(a){throw this.initialized=!0,this.supported=!1,Error("Module '"+this.name+"' failed to load: "+a)},warn:function(a){H.warn("Module "+this.name+": "+a)},deprecationNotice:function(a,b){H.warn("DEPRECATED: "+a+" in module "+this.name+"is deprecated. Please use "+b+" instead")},createError:function(a){return Error("Error in Rangy "+this.name+" module: "+a)}},H.createModule=function(a){var b,c,d;2==arguments.length?(b=arguments[1],c=[]):(b=arguments[2],c=arguments[1]),d=o(!1,a,c,b),H.initialized&&d.init()},H.createCoreModule=function(a,b,c){o(!0,a,b,c)},H.RangePrototype=p,H.rangePrototype=new p,H.selectionPrototype=new q,u=!1,v=function(){u||(u=!0,!H.initialized&&H.config.autoInitialize&&l())},typeof window==y?(i("No window found"),void 0):typeof document==y?(i("No document found"),void 0):(a(document,"addEventListener")&&document.addEventListener("DOMContentLoaded",v,!1),r(window,"load",v),H.createCoreModule("DomUtil",[],function(a,b){function c(a){var b;return typeof a.namespaceURI==I||null===(b=a.namespaceURI)||"http://www.w3.org/1999/xhtml"==b}function d(a){var b=a.parentNode;return 1==b.nodeType?b:null}function e(a){for(var b=0;a=a.previousSibling;)++b;return b}function f(a){switch(a.nodeType){case 7:case 10:return 0;case 3:case 8:return a.length;default:return a.childNodes.length}}function g(a,b){var c,d=[];for(c=a;c;c=c.parentNode)d.push(c);for(c=b;c;c=c.parentNode)if(F(d,c))return c;return null}function h(a,b,c){for(var d=c?b:b.parentNode;d;){if(d===a)return!0;d=d.parentNode}return!1}function i(a,b){return h(a,b,!0)}function j(a,b,c){for(var d,e=c?a:a.parentNode;e;){if(d=e.parentNode,d===b)return e;e=d}return null}function k(a){var b=a.nodeType;return 3==b||4==b||8==b}function l(a){if(!a)return!1;var b=a.nodeType;return 3==b||8==b}function m(a,b){var c=b.nextSibling,d=b.parentNode;return c?d.insertBefore(a,c):d.appendChild(a),a}function n(a,b,c){var d,f,g=a.cloneNode(!1);if(g.deleteData(0,b),a.deleteData(b,a.length-b),m(g,a),c)for(d=0;f=c[d++];)f.node==a&&f.offset>b?(f.node=g,f.offset-=b):f.node==a.parentNode&&f.offset>e(a)&&++f.offset;return g}function o(a){if(9==a.nodeType)return a;if(typeof a.ownerDocument!=I)return a.ownerDocument;if(typeof a.document!=I)return a.document;if(a.parentNode)return o(a.parentNode);throw b.createError("getDocument: no document found for node")}function p(a){var c=o(a);if(typeof c.defaultView!=I)return c.defaultView;if(typeof c.parentWindow!=I)return c.parentWindow;throw b.createError("Cannot get a window object for node")}function q(a){if(typeof a.contentDocument!=I)return a.contentDocument;if(typeof a.contentWindow!=I)return a.contentWindow.document;throw b.createError("getIframeDocument: No Document object found for iframe element")}function r(a){if(typeof a.contentWindow!=I)return a.contentWindow;if(typeof a.contentDocument!=I)return a.contentDocument.defaultView;throw b.createError("getIframeWindow: No Window object found for iframe element")}function s(a){return a&&J.isHostMethod(a,"setTimeout")&&J.isHostObject(a,"document")}function t(a,b,c){var d;if(a?J.isHostProperty(a,"nodeType")?d=1==a.nodeType&&"iframe"==a.tagName.toLowerCase()?q(a):o(a):s(a)&&(d=a.document):d=document,!d)throw b.createError(c+"(): Parameter must be a Window object or DOM node");return d}function u(a){for(var b;b=a.parentNode;)a=b;return a}function v(a,c,d,f){var h,i,k,l,m;if(a==d)return c===f?0:f>c?-1:1;if(h=j(d,a,!0))return c<=e(h)?-1:1;if(h=j(a,d,!0))return e(h)<f?-1:1;if(i=g(a,d),!i)throw Error("comparePoints error: nodes have no common ancestor");if(k=a===i?i:j(a,i,!0),l=d===i?i:j(d,i,!0),k===l)throw b.createError("comparePoints got to case 4 and childA and childB are the same!");for(m=i.firstChild;m;){if(m===k)return-1;if(m===l)return 1;m=m.nextSibling}}function w(a){var b;try{return b=a.parentNode,!1}catch(c){return!0}}function x(a){if(!a)return"[No node]";if(G&&w(a))return"[Broken node]";if(k(a))return'"'+a.data+'"';if(1==a.nodeType){var b=a.id?' id="'+a.id+'"':"";return"<"+a.nodeName+b+">[index:"+e(a)+",length:"+a.childNodes.length+"]["+(a.innerHTML||"[innerHTML not supported]").slice(0,25)+"]"}return a.nodeName}function y(a){for(var b,c=o(a).createDocumentFragment();b=a.firstChild;)c.appendChild(b);return c}function z(a){this.root=a,this._next=a}function A(a){return new z(a)}function B(a,b){this.node=a,this.offset=b}function C(a){this.code=this[a],this.codeName=a,this.message="DOMException: "+this.codeName}var D,E,F,G,H,I="undefined",J=a.util;J.areHostMethods(document,["createDocumentFragment","createElement","createTextNode"])||b.fail("document missing a Node creation method"),J.isHostMethod(document,"getElementsByTagName")||b.fail("document missing getElementsByTagName method"),D=document.createElement("div"),J.areHostMethods(D,["insertBefore","appendChild","cloneNode"]||!J.areHostObjects(D,["previousSibling","nextSibling","childNodes","parentNode"]))||b.fail("Incomplete Element implementation"),J.isHostProperty(D,"innerHTML")||b.fail("Element is missing innerHTML property"),E=document.createTextNode("test"),J.areHostMethods(E,["splitText","deleteData","insertData","appendData","cloneNode"]||!J.areHostObjects(D,["previousSibling","nextSibling","childNodes","parentNode"])||!J.areHostProperties(E,["data"]))||b.fail("Incomplete Text Node implementation"),F=function(a,b){for(var c=a.length;c--;)if(a[c]===b)return!0;return!1},G=!1,function(){var b,c=document.createElement("b");c.innerHTML="1",b=c.firstChild,c.innerHTML="<br>",G=w(b),a.features.crashyTextNodes=G}(),typeof window.getComputedStyle!=I?H=function(a,b){return p(a).getComputedStyle(a,null)[b]}:typeof document.documentElement.currentStyle!=I?H=function(a,b){return a.currentStyle[b]}:b.fail("No means of obtaining computed style properties found"),z.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){var a,b,c=this._current=this._next;if(this._current)if(a=c.firstChild,a)this._next=a;else{for(b=null;c!==this.root&&!(b=c.nextSibling);)c=c.parentNode;this._next=b}return this._current},detach:function(){this._current=this._next=this.root=null}},B.prototype={equals:function(a){return!!a&&this.node===a.node&&this.offset==a.offset},inspect:function(){return"[DomPosition("+x(this.node)+":"+this.offset+")]"},toString:function(){return this.inspect()}},C.prototype={INDEX_SIZE_ERR:1,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INVALID_STATE_ERR:11,INVALID_NODE_TYPE_ERR:24},C.prototype.toString=function(){return this.message},a.dom={arrayContains:F,isHtmlNamespace:c,parentElement:d,getNodeIndex:e,getNodeLength:f,getCommonAncestor:g,isAncestorOf:h,isOrIsAncestorOf:i,getClosestAncestorIn:j,isCharacterDataNode:k,isTextOrCommentNode:l,insertAfter:m,splitDataNode:n,getDocument:o,getWindow:p,getIframeWindow:r,getIframeDocument:q,getBody:J.getBody,isWindow:s,getContentDocument:t,getRootContainer:u,comparePoints:v,isBrokenNode:w,inspectNode:x,getComputedStyleProperty:H,fragmentFromNodeChildren:y,createIterator:A,DomPosition:B},a.DOMException=C}),H.createCoreModule("DomRange",["DomUtil"],function(a){function b(a,b){return 3!=a.nodeType&&(gb(a,b.startContainer)||gb(a,b.endContainer))}function c(a){return a.document||hb(a.startContainer)}function d(a){return new cb(a.parentNode,fb(a))}function e(a){return new cb(a.parentNode,fb(a)+1)}function f(a,b,c){var d=11==a.nodeType?a.firstChild:a;return eb(b)?c==b.length?ab.insertAfter(a,b):b.parentNode.insertBefore(a,0==c?b:jb(b,c)):c>=b.childNodes.length?b.appendChild(a):b.insertBefore(a,b.childNodes[c]),d}function g(a,b,d){if(y(a),y(b),c(b)!=c(a))throw new db("WRONG_DOCUMENT_ERR");var e=ib(a.startContainer,a.startOffset,b.endContainer,b.endOffset),f=ib(a.endContainer,a.endOffset,b.startContainer,b.startOffset);return d?0>=e&&f>=0:0>e&&f>0}function h(a){var b,d,e,f;for(e=c(a.range).createDocumentFragment();d=a.next();){if(b=a.isPartiallySelectedSubtree(),d=d.cloneNode(!b),b&&(f=a.getSubtreeIterator(),d.appendChild(h(f)),f.detach()),10==d.nodeType)throw new db("HIERARCHY_REQUEST_ERR");e.appendChild(d)}return e}function i(a,b,c){var d,e,f,g;for(c=c||{stop:!1};f=a.next();)if(a.isPartiallySelectedSubtree()){if(b(f)===!1)return c.stop=!0,void 0;if(g=a.getSubtreeIterator(),i(g,b,c),g.detach(),c.stop)return}else for(d=ab.createIterator(f);e=d.next();)if(b(e)===!1)return c.stop=!0,void 0}function j(a){for(var b;a.next();)a.isPartiallySelectedSubtree()?(b=a.getSubtreeIterator(),j(b),b.detach()):a.remove()}function k(a){for(var b,d,e=c(a.range).createDocumentFragment();b=a.next();){if(a.isPartiallySelectedSubtree()?(b=b.cloneNode(!1),d=a.getSubtreeIterator(),b.appendChild(k(d)),d.detach()):a.remove(),10==b.nodeType)throw new db("HIERARCHY_REQUEST_ERR");e.appendChild(b)}return e}function l(a,b,c){var d,e,f=!(!b||!b.length),g=!!c;return f&&(d=RegExp("^("+b.join("|")+")$")),e=[],i(new n(a,!1),function(b){var h,i;(!f||d.test(b.nodeType))&&(!g||c(b))&&(h=a.startContainer,b==h&&eb(h)&&a.startOffset==h.length||(i=a.endContainer,b==i&&eb(i)&&0==a.endOffset||e.push(b)))}),e}function m(a){var b=void 0===a.getName?"Range":a.getName();return"["+b+"("+ab.inspectNode(a.startContainer)+":"+a.startOffset+", "+ab.inspectNode(a.endContainer)+":"+a.endOffset+")]"}function n(a,b){if(this.range=a,this.clonePartiallySelectedTextNodes=b,!a.collapsed){this.sc=a.startContainer,this.so=a.startOffset,this.ec=a.endContainer,this.eo=a.endOffset;var c=a.commonAncestorContainer;this.sc===this.ec&&eb(this.sc)?(this.isSingleCharacterDataNode=!0,this._first=this._last=this._next=this.sc):(this._first=this._next=this.sc!==c||eb(this.sc)?kb(this.sc,c,!0):this.sc.childNodes[this.so],this._last=this.ec!==c||eb(this.ec)?kb(this.ec,c,!0):this.ec.childNodes[this.eo-1])}}function o(a){return function(b,c){for(var d,e=c?b:b.parentNode;e;){if(d=e.nodeType,mb(a,d))return e;e=e.parentNode}return null}}function p(a,b){if(P(a,b))throw new db("INVALID_NODE_TYPE_ERR")}function q(a,b){if(!mb(b,a.nodeType))throw new db("INVALID_NODE_TYPE_ERR")}function r(a,b){if(0>b||b>(eb(a)?a.length:a.childNodes.length))throw new db("INDEX_SIZE_ERR")}function s(a,b){if(N(a,!0)!==N(b,!0))throw new db("WRONG_DOCUMENT_ERR")}function t(a){if(O(a,!0))throw new db("NO_MODIFICATION_ALLOWED_ERR")}function u(a,b){if(!a)throw new db(b)}function v(a){return ob&&ab.isBrokenNode(a)||!mb(J,a.nodeType)&&!N(a,!0)}function w(a,b){return b<=(eb(a)?a.length:a.childNodes.length)}function x(a){return!!a.startContainer&&!!a.endContainer&&!v(a.startContainer)&&!v(a.endContainer)&&w(a.startContainer,a.startOffset)&&w(a.endContainer,a.endOffset)}function y(a){if(!x(a))throw Error("Range error: Range is no longer valid after DOM mutation ("+a.inspect()+")")}function z(a,b){var c,d,e,f,g;y(a),c=a.startContainer,d=a.startOffset,e=a.endContainer,f=a.endOffset,g=c===e,eb(e)&&f>0&&f<e.length&&jb(e,f,b),eb(c)&&d>0&&d<c.length&&(c=jb(c,d,b),g?(f-=d,e=c):e==c.parentNode&&f>=fb(c)&&f++,d=0),a.setStartAndEnd(c,d,e,f)}function A(a){y(a);var b=a.commonAncestorContainer.parentNode.cloneNode(!1);return b.appendChild(a.cloneContents()),b.innerHTML}function B(a){a.START_TO_START=U,a.START_TO_END=V,a.END_TO_END=W,a.END_TO_START=X,a.NODE_BEFORE=Y,a.NODE_AFTER=Z,a.NODE_BEFORE_AND_AFTER=$,a.NODE_INSIDE=_}function C(a){B(a),B(a.prototype)}function D(a,b){return function(){var c,d,f,g,h,j,k;return y(this),c=this.startContainer,d=this.startOffset,f=this.commonAncestorContainer,g=new n(this,!0),c!==f&&(h=kb(c,f,!0),j=e(h),c=j.node,d=j.offset),i(g,t),g.reset(),k=a(g),g.detach(),b(this,c,d,c,d),k}}function E(c,f){function g(a,b){return function(c){q(c,I),q(nb(c),J);var f=(a?d:e)(c);(b?h:i)(this,f.node,f.offset)}}function h(a,b,c){var d=a.endContainer,e=a.endOffset;(b!==a.startContainer||c!==a.startOffset)&&((nb(b)!=nb(d)||1==ib(b,c,d,e))&&(d=b,e=c),f(a,b,c,d,e))}function i(a,b,c){var d=a.startContainer,e=a.startOffset;(b!==a.endContainer||c!==a.endOffset)&&((nb(b)!=nb(d)||-1==ib(b,c,d,e))&&(d=b,e=c),f(a,d,e,b,c))}var l=function(){};l.prototype=a.rangePrototype,c.prototype=new l,bb.extend(c.prototype,{setStart:function(a,b){p(a,!0),r(a,b),h(this,a,b)},setEnd:function(a,b){p(a,!0),r(a,b),i(this,a,b)},setStartAndEnd:function(){var a=arguments,b=a[0],c=a[1],d=b,e=c;switch(a.length){case 3:e=a[2];break;case 4:d=a[2],e=a[3]}f(this,b,c,d,e)},setBoundary:function(a,b,c){this["set"+(c?"Start":"End")](a,b)},setStartBefore:g(!0,!0),setStartAfter:g(!1,!0),setEndBefore:g(!0,!1),setEndAfter:g(!1,!1),collapse:function(a){y(this),a?f(this,this.startContainer,this.startOffset,this.startContainer,this.startOffset):f(this,this.endContainer,this.endOffset,this.endContainer,this.endOffset)},selectNodeContents:function(a){p(a,!0),f(this,a,0,a,lb(a))},selectNode:function(a){p(a,!1),q(a,I);var b=d(a),c=e(a);f(this,b.node,b.offset,c.node,c.offset)},extractContents:D(k,f),deleteContents:D(j,f),canSurroundContents:function(){var a,c;return y(this),t(this.startContainer),t(this.endContainer),a=new n(this,!0),c=a._first&&b(a._first,this)||a._last&&b(a._last,this),a.detach(),!c},splitBoundaries:function(){z(this)},splitBoundariesPreservingPositions:function(a){z(this,a)},normalizeBoundaries:function(){var a,b,c,d,e,g,h,i,j;y(this),a=this.startContainer,b=this.startOffset,c=this.endContainer,d=this.endOffset,e=function(a){var b=a.nextSibling;b&&b.nodeType==a.nodeType&&(c=a,d=a.length,a.appendData(b.data),b.parentNode.removeChild(b))},g=function(e){var f,g,h=e.previousSibling;h&&h.nodeType==e.nodeType&&(a=e,f=e.length,b=h.length,e.insertData(0,h.data),h.parentNode.removeChild(h),a==c?(d+=b,c=a):c==e.parentNode&&(g=fb(e),d==g?(c=e,d=f):d>g&&d--))},h=!0,eb(c)?c.length==d&&e(c):(d>0&&(i=c.childNodes[d-1],i&&eb(i)&&e(i)),h=!this.collapsed),h?eb(a)?0==b&&g(a):b<a.childNodes.length&&(j=a.childNodes[b],j&&eb(j)&&g(j)):(a=c,b=d),f(this,a,b,c,d)},collapseToPoint:function(a,b){p(a,!0),r(a,b),this.setStartAndEnd(a,b)}}),C(c)}function F(a){a.collapsed=a.startContainer===a.endContainer&&a.startOffset===a.endOffset,a.commonAncestorContainer=a.collapsed?a.startContainer:ab.getCommonAncestor(a.startContainer,a.endContainer)}function G(a,b,c,d,e){a.startContainer=b,a.startOffset=c,a.endContainer=d,a.endOffset=e,a.document=ab.getDocument(b),F(a)}function H(a){this.startContainer=a,this.startOffset=0,this.endContainer=a,this.endOffset=0,this.document=a,F(this)}var I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,_,ab=a.dom,bb=a.util,cb=ab.DomPosition,db=a.DOMException,eb=ab.isCharacterDataNode,fb=ab.getNodeIndex,gb=ab.isOrIsAncestorOf,hb=ab.getDocument,ib=ab.comparePoints,jb=ab.splitDataNode,kb=ab.getClosestAncestorIn,lb=ab.getNodeLength,mb=ab.arrayContains,nb=ab.getRootContainer,ob=a.features.crashyTextNodes;n.prototype={_current:null,_next:null,_first:null,_last:null,isSingleCharacterDataNode:!1,reset:function(){this._current=null,this._next=this._first},hasNext:function(){return!!this._next},next:function(){var a=this._current=this._next;return a&&(this._next=a!==this._last?a.nextSibling:null,eb(a)&&this.clonePartiallySelectedTextNodes&&(a===this.ec&&(a=a.cloneNode(!0)).deleteData(this.eo,a.length-this.eo),this._current===this.sc&&(a=a.cloneNode(!0)).deleteData(0,this.so))),a},remove:function(){var a,b,c=this._current;!eb(c)||c!==this.sc&&c!==this.ec?c.parentNode&&c.parentNode.removeChild(c):(a=c===this.sc?this.so:0,b=c===this.ec?this.eo:c.length,a!=b&&c.deleteData(a,b-a))},isPartiallySelectedSubtree:function(){var a=this._current;return b(a,this.range)},getSubtreeIterator:function(){var a,b,d,e,f,g;return this.isSingleCharacterDataNode?(a=this.range.cloneRange(),a.collapse(!1)):(a=new H(c(this.range)),b=this._current,d=b,e=0,f=b,g=lb(b),gb(b,this.sc)&&(d=this.sc,e=this.so),gb(b,this.ec)&&(f=this.ec,g=this.eo),G(a,d,e,f,g)),new n(a,this.clonePartiallySelectedTextNodes)},detach:function(){this.range=this._current=this._next=this._first=this._last=this.sc=this.so=this.ec=this.eo=null}},I=[1,3,4,5,7,8,10],J=[2,9,11],K=[5,6,10,12],L=[1,3,4,5,7,8,10,11],M=[1,3,4,5,7,8],N=o([9,11]),O=o(K),P=o([6,10,12]),Q=document.createElement("style"),R=!1;try{Q.innerHTML="<b>x</b>",R=3==Q.firstChild.nodeType}catch(pb){}a.features.htmlParsingConforms=R,S=R?function(a){var b,c=this.startContainer,d=hb(c);if(!c)throw new db("INVALID_STATE_ERR");return b=null,1==c.nodeType?b=c:eb(c)&&(b=ab.parentElement(c)),b=null===b||"HTML"==b.nodeName&&ab.isHtmlNamespace(hb(b).documentElement)&&ab.isHtmlNamespace(b)?d.createElement("body"):b.cloneNode(!1),b.innerHTML=a,ab.fragmentFromNodeChildren(b)}:function(a){var b=c(this),d=b.createElement("body");return d.innerHTML=a,ab.fragmentFromNodeChildren(d)},T=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"],U=0,V=1,W=2,X=3,Y=0,Z=1,$=2,_=3,bb.extend(a.rangePrototype,{compareBoundaryPoints:function(a,b){var c,d,e,f,g,h;return y(this),s(this.startContainer,b.startContainer),g=a==X||a==U?"start":"end",h=a==V||a==U?"start":"end",c=this[g+"Container"],d=this[g+"Offset"],e=b[h+"Container"],f=b[h+"Offset"],ib(c,d,e,f)},insertNode:function(a){if(y(this),q(a,L),t(this.startContainer),gb(a,this.startContainer))throw new db("HIERARCHY_REQUEST_ERR");var b=f(a,this.startContainer,this.startOffset);this.setStartBefore(b)},cloneContents:function(){var a,b,d;return y(this),this.collapsed?c(this).createDocumentFragment():this.startContainer===this.endContainer&&eb(this.startContainer)?(a=this.startContainer.cloneNode(!0),a.data=a.data.slice(this.startOffset,this.endOffset),b=c(this).createDocumentFragment(),b.appendChild(a),b):(d=new n(this,!0),a=h(d),d.detach(),a)},canSurroundContents:function(){var a,c;return y(this),t(this.startContainer),t(this.endContainer),a=new n(this,!0),c=a._first&&b(a._first,this)||a._last&&b(a._last,this),a.detach(),!c},surroundContents:function(a){if(q(a,M),!this.canSurroundContents())throw new db("INVALID_STATE_ERR");var b=this.extractContents();if(a.hasChildNodes())for(;a.lastChild;)a.removeChild(a.lastChild);f(a,this.startContainer,this.startOffset),a.appendChild(b),this.selectNode(a)},cloneRange:function(){var a,b,d;for(y(this),a=new H(c(this)),b=T.length;b--;)d=T[b],a[d]=this[d];return a},toString:function(){var a,b,c;return y(this),a=this.startContainer,a===this.endContainer&&eb(a)?3==a.nodeType||4==a.nodeType?a.data.slice(this.startOffset,this.endOffset):"":(b=[],c=new n(this,!0),i(c,function(a){(3==a.nodeType||4==a.nodeType)&&b.push(a.data)}),c.detach(),b.join(""))},compareNode:function(a){var b,c,d,e;if(y(this),b=a.parentNode,c=fb(a),!b)throw new db("NOT_FOUND_ERR");return d=this.comparePoint(b,c),e=this.comparePoint(b,c+1),0>d?e>0?$:Y:e>0?Z:_},comparePoint:function(a,b){return y(this),u(a,"HIERARCHY_REQUEST_ERR"),s(a,this.startContainer),ib(a,b,this.startContainer,this.startOffset)<0?-1:ib(a,b,this.endContainer,this.endOffset)>0?1:0},createContextualFragment:S,toHtml:function(){return A(this)},intersectsNode:function(a,b){var d,e,f,g;return y(this),u(a,"NOT_FOUND_ERR"),hb(a)!==c(this)?!1:(d=a.parentNode,e=fb(a),u(d,"NOT_FOUND_ERR"),f=ib(d,e,this.endContainer,this.endOffset),g=ib(d,e+1,this.startContainer,this.startOffset),b?0>=f&&g>=0:0>f&&g>0)},isPointInRange:function(a,b){return y(this),u(a,"HIERARCHY_REQUEST_ERR"),s(a,this.startContainer),ib(a,b,this.startContainer,this.startOffset)>=0&&ib(a,b,this.endContainer,this.endOffset)<=0},intersectsRange:function(a){return g(this,a,!1)},intersectsOrTouchesRange:function(a){return g(this,a,!0)},intersection:function(a){var b,c,d;return this.intersectsRange(a)?(b=ib(this.startContainer,this.startOffset,a.startContainer,a.startOffset),c=ib(this.endContainer,this.endOffset,a.endContainer,a.endOffset),d=this.cloneRange(),-1==b&&d.setStart(a.startContainer,a.startOffset),1==c&&d.setEnd(a.endContainer,a.endOffset),d):null},union:function(a){if(this.intersectsOrTouchesRange(a)){var b=this.cloneRange();return-1==ib(a.startContainer,a.startOffset,this.startContainer,this.startOffset)&&b.setStart(a.startContainer,a.startOffset),1==ib(a.endContainer,a.endOffset,this.endContainer,this.endOffset)&&b.setEnd(a.endContainer,a.endOffset),b}throw new db("Ranges do not intersect")},containsNode:function(a,b){return b?this.intersectsNode(a,!1):this.compareNode(a)==_},containsNodeContents:function(a){return this.comparePoint(a,0)>=0&&this.comparePoint(a,lb(a))<=0},containsRange:function(a){var b=this.intersection(a);return null!==b&&a.equals(b)},containsNodeText:function(a){var b,c,d=this.cloneRange();return d.selectNode(a),b=d.getNodes([3]),b.length>0?(d.setStart(b[0],0),c=b.pop(),d.setEnd(c,c.length),this.containsRange(d)):this.containsNodeContents(a)},getNodes:function(a,b){return y(this),l(this,a,b)},getDocument:function(){return c(this)},collapseBefore:function(a){this.setEndBefore(a),this.collapse(!1)},collapseAfter:function(a){this.setStartAfter(a),this.collapse(!0)},getBookmark:function(b){var d,e,f,g=c(this),h=a.createRange(g);return b=b||ab.getBody(g),h.selectNodeContents(b),d=this.intersection(h),e=0,f=0,d&&(h.setEnd(d.startContainer,d.startOffset),e=(""+h).length,f=e+(""+d).length),{start:e,end:f,containerNode:b}},moveToBookmark:function(a){var b,c,d,e,f,g,h,i=a.containerNode,j=0;for(this.setStart(i,0),this.collapse(!0),b=[i],d=!1,e=!1;!e&&(c=b.pop());)if(3==c.nodeType)f=j+c.length,!d&&a.start>=j&&a.start<=f&&(this.setStart(c,a.start-j),d=!0),d&&a.end>=j&&a.end<=f&&(this.setEnd(c,a.end-j),e=!0),j=f;else for(h=c.childNodes,g=h.length;g--;)b.push(h[g])},getName:function(){return"DomRange"},equals:function(a){return H.rangesEqual(this,a)},isValid:function(){return x(this)},inspect:function(){return m(this)},detach:function(){}}),E(H,G),bb.extend(H,{rangeProperties:T,RangeIterator:n,copyComparisonConstants:C,createPrototypeRange:E,inspect:m,toHtml:A,getRangeDocument:c,rangesEqual:function(a,b){return a.startContainer===b.startContainer&&a.startOffset===b.startOffset&&a.endContainer===b.endContainer&&a.endOffset===b.endOffset}}),a.DomRange=H}),H.createCoreModule("WrappedRange",["DomRange"],function(a,b){var c,d,e,f,g,h,i,j,k=a.dom,l=a.util,m=k.DomPosition,n=a.DomRange,o=k.getBody,p=k.getContentDocument,q=k.isCharacterDataNode;a.features.implementsDomRange&&!function(){function d(a){for(var b,c=s.length;c--;)b=s[c],a[b]=a.nativeRange[b];a.collapsed=a.startContainer===a.endContainer&&a.startOffset===a.endOffset}function e(a,b,c,d,e){var f=a.startContainer!==b||a.startOffset!=c,g=a.endContainer!==d||a.endOffset!=e,h=!a.equals(a.nativeRange);(f||g||h)&&(a.setEnd(d,e),a.setStart(b,c))}var f,g,h,i,j,m,q,r,s=n.rangeProperties;c=function(a){if(!a)throw b.createError("WrappedRange: Range must be specified");this.nativeRange=a,d(this)},n.createPrototypeRange(c,e),f=c.prototype,f.selectNode=function(a){this.nativeRange.selectNode(a),d(this)},f.cloneContents=function(){return this.nativeRange.cloneContents()},f.surroundContents=function(a){this.nativeRange.surroundContents(a),d(this)},f.collapse=function(a){this.nativeRange.collapse(a),d(this)},f.cloneRange=function(){return new c(this.nativeRange.cloneRange())},f.refresh=function(){d(this)},f.toString=function(){return""+this.nativeRange},h=document.createTextNode("test"),o(document).appendChild(h),i=document.createRange(),i.setStart(h,0),i.setEnd(h,0);try{i.setStart(h,1),f.setStart=function(a,b){this.nativeRange.setStart(a,b),d(this)},f.setEnd=function(a,b){this.nativeRange.setEnd(a,b),d(this)},g=function(a){return function(b){this.nativeRange[a](b),d(this)}}}catch(t){f.setStart=function(a,b){try{this.nativeRange.setStart(a,b)}catch(c){this.nativeRange.setEnd(a,b),this.nativeRange.setStart(a,b)}d(this)},f.setEnd=function(a,b){try{this.nativeRange.setEnd(a,b)}catch(c){this.nativeRange.setStart(a,b),this.nativeRange.setEnd(a,b)}d(this)},g=function(a,b){return function(c){try{this.nativeRange[a](c)}catch(e){this.nativeRange[b](c),this.nativeRange[a](c)}d(this)}}}f.setStartBefore=g("setStartBefore","setEndBefore"),f.setStartAfter=g("setStartAfter","setEndAfter"),f.setEndBefore=g("setEndBefore","setStartBefore"),f.setEndAfter=g("setEndAfter","setStartAfter"),f.selectNodeContents=function(a){this.setStartAndEnd(a,0,k.getNodeLength(a))},i.selectNodeContents(h),i.setEnd(h,3),j=document.createRange(),j.selectNodeContents(h),j.setEnd(h,4),j.setStart(h,2),f.compareBoundaryPoints=-1==i.compareBoundaryPoints(i.START_TO_END,j)&&1==i.compareBoundaryPoints(i.END_TO_START,j)?function(a,b){return b=b.nativeRange||b,a==b.START_TO_END?a=b.END_TO_START:a==b.END_TO_START&&(a=b.START_TO_END),this.nativeRange.compareBoundaryPoints(a,b)}:function(a,b){return this.nativeRange.compareBoundaryPoints(a,b.nativeRange||b)},m=document.createElement("div"),m.innerHTML="123",q=m.firstChild,r=o(document),r.appendChild(m),i.setStart(q,1),i.setEnd(q,2),i.deleteContents(),"13"==q.data&&(f.deleteContents=function(){this.nativeRange.deleteContents(),d(this)},f.extractContents=function(){var a=this.nativeRange.extractContents();return d(this),a}),r.removeChild(m),r=null,l.isHostMethod(i,"createContextualFragment")&&(f.createContextualFragment=function(a){return this.nativeRange.createContextualFragment(a)}),o(document).removeChild(h),f.getName=function(){return"WrappedRange"},a.WrappedRange=c,a.createNativeRange=function(a){return a=p(a,b,"createNativeRange"),a.createRange()}}(),a.features.implementsTextRange&&(e=function(a){var b,c,d,e=a.parentElement(),f=a.duplicate();return f.collapse(!0),b=f.parentElement(),f=a.duplicate(),f.collapse(!1),c=f.parentElement(),d=b==c?b:k.getCommonAncestor(b,c),d==e?d:k.getCommonAncestor(e,d)},f=function(a){return 0==a.compareEndPoints("StartToEnd",a)},g=function(a,b,c,d,e){var f,g,h,i,j,l,n,o,p,r,s,t,u,v,w,x,y=a.duplicate();if(y.collapse(c),f=y.parentElement(),k.isOrIsAncestorOf(b,f)||(f=b),!f.canHaveHTML)return g=new m(f.parentNode,k.getNodeIndex(f)),{boundaryPosition:g,nodeInfo:{nodeIndex:g.offset,containerElement:g.node}};for(h=k.getDocument(f).createElement("span"),h.parentNode&&h.parentNode.removeChild(h),j=c?"StartToStart":"StartToEnd",r=e&&e.containerElement==f?e.nodeIndex:0,s=f.childNodes.length,t=s,u=t;;){if(u==s?f.appendChild(h):f.insertBefore(h,f.childNodes[u]),y.moveToElementText(h),i=y.compareEndPoints(j,a),0==i||r==t)break;if(-1==i){if(t==r+1)break;r=u}else t=t==r+1?r:u;u=Math.floor((r+t)/2),f.removeChild(h)}if(p=h.nextSibling,-1==i&&p&&q(p)){if(y.setEndPoint(c?"EndToStart":"EndToEnd",a),/[\r\n]/.test(p.data))for(w=y.duplicate(),x=w.text.replace(/\r\n/g,"\r").length,v=w.moveStart("character",x);-1==(i=w.compareEndPoints("StartToEnd",w));)v++,w.moveStart("character",1);else v=y.text.length;o=new m(p,v)}else l=(d||!c)&&h.previousSibling,n=(d||c)&&h.nextSibling,o=n&&q(n)?new m(n,0):l&&q(l)?new m(l,l.data.length):new m(f,k.getNodeIndex(h));return h.parentNode.removeChild(h),{boundaryPosition:o,nodeInfo:{nodeIndex:u,containerElement:f}}},h=function(a,b){var c,d,e,f,g=a.offset,h=k.getDocument(a.node),i=o(h).createTextRange(),j=q(a.node);return j?(c=a.node,d=c.parentNode):(f=a.node.childNodes,c=g<f.length?f[g]:null,d=a.node),e=h.createElement("span"),e.innerHTML="&#feff;",c?d.insertBefore(e,c):d.appendChild(e),i.moveToElementText(e),i.collapse(!b),d.removeChild(e),j&&i[b?"moveStart":"moveEnd"]("character",g),i},d=function(a){this.textRange=a,this.refresh()},d.prototype=new n(document),d.prototype.refresh=function(){var a,b,c,d=e(this.textRange);
  f(this.textRange)?b=a=g(this.textRange,d,!0,!0).boundaryPosition:(c=g(this.textRange,d,!0,!1),a=c.boundaryPosition,b=g(this.textRange,d,!1,!1,c.nodeInfo).boundaryPosition),this.setStart(a.node,a.offset),this.setEnd(b.node,b.offset)},d.prototype.getName=function(){return"WrappedTextRange"},n.copyComparisonConstants(d),i=function(a){var b,c,d;return a.collapsed?h(new m(a.startContainer,a.startOffset),!0):(b=h(new m(a.startContainer,a.startOffset),!0),c=h(new m(a.endContainer,a.endOffset),!1),d=o(n.getRangeDocument(a)).createTextRange(),d.setEndPoint("StartToStart",b),d.setEndPoint("EndToEnd",c),d)},d.rangeToTextRange=i,d.prototype.toTextRange=function(){return i(this)},a.WrappedTextRange=d,(!a.features.implementsDomRange||a.config.preferTextRange)&&(j=function(){return this}(),void 0===j.Range&&(j.Range=d),a.createNativeRange=function(a){return a=p(a,b,"createNativeRange"),o(a).createTextRange()},a.WrappedRange=d)),a.createRange=function(c){return c=p(c,b,"createRange"),new a.WrappedRange(a.createNativeRange(c))},a.createRangyRange=function(a){return a=p(a,b,"createRangyRange"),new n(a)},a.createIframeRange=function(c){return b.deprecationNotice("createIframeRange()","createRange(iframeEl)"),a.createRange(c)},a.createIframeRangyRange=function(c){return b.deprecationNotice("createIframeRangyRange()","createRangyRange(iframeEl)"),a.createRangyRange(c)},a.addShimListener(function(b){var c=b.document;void 0===c.createRange&&(c.createRange=function(){return a.createRange(c)}),c=b=null})}),H.createCoreModule("WrappedSelection",["DomRange","WrappedRange"],function(a,b){function c(a){return"string"==typeof a?/^backward(s)?$/i.test(a):!!a}function d(a,c){if(a){if(A.isWindow(a))return a;if(a instanceof r)return a.win;var d=A.getContentDocument(a,b,c);return A.getWindow(d)}return window}function e(a){return d(a,"getWinSelection").getSelection()}function f(a){return d(a,"getDocSelection").document.selection}function g(a){var b=!1;return a.anchorNode&&(b=1==A.comparePoints(a.anchorNode,a.anchorOffset,a.focusNode,a.focusOffset)),b}function h(a,b,c){var d=c?"end":"start",e=c?"start":"end";a.anchorNode=b[d+"Container"],a.anchorOffset=b[d+"Offset"],a.focusNode=b[e+"Container"],a.focusOffset=b[e+"Offset"]}function i(a){var b=a.nativeSelection;a.anchorNode=b.anchorNode,a.anchorOffset=b.anchorOffset,a.focusNode=b.focusNode,a.focusOffset=b.focusOffset}function j(a){a.anchorNode=a.focusNode=null,a.anchorOffset=a.focusOffset=0,a.rangeCount=0,a.isCollapsed=!0,a._ranges.length=0}function k(b){var c;return b instanceof D?(c=a.createNativeRange(b.getDocument()),c.setEnd(b.endContainer,b.endOffset),c.setStart(b.startContainer,b.startOffset)):b instanceof E?c=b.nativeRange:J.implementsDomRange&&b instanceof A.getWindow(b.startContainer).Range&&(c=b),c}function l(a){if(!a.length||1!=a[0].nodeType)return!1;for(var b=1,c=a.length;c>b;++b)if(!A.isAncestorOf(a[0],a[b]))return!1;return!0}function m(a){var c=a.getNodes();if(!l(c))throw b.createError("getSingleElementFromRange: range "+a.inspect()+" did not consist of a single element");return c[0]}function n(a){return!!a&&void 0!==a.text}function o(a,b){var c=new E(b);a._ranges=[c],h(a,c,!1),a.rangeCount=1,a.isCollapsed=c.collapsed}function p(b){var c,d,e,f;if(b._ranges.length=0,"None"==b.docSelection.type)j(b);else if(c=b.docSelection.createRange(),n(c))o(b,c);else{for(b.rangeCount=c.length,e=L(c.item(0)),f=0;f<b.rangeCount;++f)d=a.createRange(e),d.selectNode(c.item(f)),b._ranges.push(d);b.isCollapsed=1==b.rangeCount&&b._ranges[0].collapsed,h(b,b._ranges[b.rangeCount-1],!1)}}function q(a,c){var d,e,f=a.docSelection.createRange(),g=m(c),h=L(f.item(0)),i=M(h).createControlRange();for(d=0,e=f.length;e>d;++d)i.add(f.item(d));try{i.add(g)}catch(j){throw b.createError("addRange(): Element within the specified Range could not be added to control selection (does it have layout?)")}i.select(),p(a)}function r(a,b,c){this.nativeSelection=a,this.docSelection=b,this._ranges=[],this.win=c,this.refresh()}function s(a){a.win=a.anchorNode=a.focusNode=a._ranges=null,a.rangeCount=a.anchorOffset=a.focusOffset=0,a.detached=!0}function t(a,b){for(var c,d,e=bb.length;e--;)if(c=bb[e],d=c.selection,"deleteAll"==b)s(d);else if(c.win==a)return"delete"==b?(bb.splice(e,1),!0):d;return"deleteAll"==b&&(bb.length=0),null}function u(a,c){var d,e,f,g=L(c[0].startContainer),h=M(g).createControlRange();for(d=0,f=c.length;f>d;++d){e=m(c[d]);try{h.add(e)}catch(i){throw b.createError("setRanges(): Element within one of the specified Ranges could not be added to control selection (does it have layout?)")}}h.select(),p(a)}function v(a,b){if(a.win.document!=L(b))throw new F("WRONG_DOCUMENT_ERR")}function w(b){return function(c,d){var e;this.rangeCount?(e=this.getRangeAt(0),e["set"+(b?"Start":"End")](c,d)):(e=a.createRange(this.win.document),e.setStartAndEnd(c,d)),this.setSingleRange(e,this.isBackward())}}function x(a){var b,c,d=[],e=new G(a.anchorNode,a.anchorOffset),f=new G(a.focusNode,a.focusOffset),g="function"==typeof a.getName?a.getName():"Selection";if(void 0!==a.rangeCount)for(b=0,c=a.rangeCount;c>b;++b)d[b]=D.inspect(a.getRangeAt(b));return"["+g+"(Ranges: "+d.join(", ")+")(anchor: "+e.inspect()+", focus: "+f.inspect()+"]"}var y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,_,ab,bb,cb,db,eb,fb,gb,hb;if(a.config.checkSelectionRanges=!0,y="boolean",z="number",A=a.dom,B=a.util,C=B.isHostMethod,D=a.DomRange,E=a.WrappedRange,F=a.DOMException,G=A.DomPosition,J=a.features,K="Control",L=A.getDocument,M=A.getBody,N=D.rangesEqual,O=C(window,"getSelection"),P=B.isHostObject(document,"selection"),J.implementsWinGetSelection=O,J.implementsDocSelection=P,Q=P&&(!O||a.config.preferTextRange),Q?(H=f,a.isSelectionValid=function(a){var b=d(a,"isSelectionValid").document,c=b.selection;return"None"!=c.type||L(c.createRange().parentElement())==b}):O?(H=e,a.isSelectionValid=function(){return!0}):b.fail("Neither document.selection or window.getSelection() detected."),a.getNativeSelection=H,R=H(),S=a.createNativeRange(document),T=M(document),U=B.areHostProperties(R,["anchorNode","focusNode","anchorOffset","focusOffset"]),J.selectionHasAnchorAndFocus=U,V=C(R,"extend"),J.selectionHasExtend=V,W=typeof R.rangeCount==z,J.selectionHasRangeCount=W,X=!1,Y=!0,Z=V?function(b,c){var d=D.getRangeDocument(c),e=a.createRange(d);e.collapseToPoint(c.endContainer,c.endOffset),b.addRange(k(e)),b.extend(c.startContainer,c.startOffset)}:null,B.areHostMethods(R,["addRange","getRangeAt","removeAllRanges"])&&typeof R.rangeCount==z&&J.implementsDomRange&&!function(){var b,c,d,e,f,h,i,j,k,l,m,n=window.getSelection();if(n){for(b=n.rangeCount,c=b>1,d=[],e=g(n),f=0;b>f;++f)d[f]=n.getRangeAt(f);for(h=M(document),i=h.appendChild(document.createElement("div")),i.contentEditable="false",j=i.appendChild(document.createTextNode("   ")),k=document.createRange(),k.setStart(j,1),k.collapse(!0),n.addRange(k),Y=1==n.rangeCount,n.removeAllRanges(),c||(l=window.navigator.appVersion.match(/Chrome\/(.*?) /),l&&parseInt(l[1])>=36?X=!1:(m=k.cloneRange(),k.setStart(j,0),m.setEnd(j,3),m.setStart(j,2),n.addRange(k),n.addRange(m),X=2==n.rangeCount)),h.removeChild(i),n.removeAllRanges(),f=0;b>f;++f)0==f&&e?Z?Z(n,d[f]):(a.warn("Rangy initialization: original selection was backwards but selection has been restored forwards because the browser does not support Selection.extend"),n.addRange(d[f])):n.addRange(d[f])}}(),J.selectionSupportsMultipleRanges=X,J.collapsedNonEditableSelectionsSupported=Y,$=!1,T&&C(T,"createControlRange")&&(_=T.createControlRange(),B.areHostProperties(_,["item","add"])&&($=!0)),J.implementsControlRange=$,I=U?function(a){return a.anchorNode===a.focusNode&&a.anchorOffset===a.focusOffset}:function(a){return a.rangeCount?a.getRangeAt(a.rangeCount-1).collapsed:!1},C(R,"getRangeAt")?ab=function(a,b){try{return a.getRangeAt(b)}catch(c){return null}}:U&&(ab=function(b){var c=L(b.anchorNode),d=a.createRange(c);return d.setStartAndEnd(b.anchorNode,b.anchorOffset,b.focusNode,b.focusOffset),d.collapsed!==this.isCollapsed&&d.setStartAndEnd(b.focusNode,b.focusOffset,b.anchorNode,b.anchorOffset),d}),r.prototype=a.selectionPrototype,bb=[],cb=function(a){var b,c,e;return a&&a instanceof r?(a.refresh(),a):(a=d(a,"getNativeSelection"),b=t(a),c=H(a),e=P?f(a):null,b?(b.nativeSelection=c,b.docSelection=e,b.refresh()):(b=new r(c,e,a),bb.push({win:a,selection:b})),b)},a.getSelection=cb,a.getIframeSelection=function(c){return b.deprecationNotice("getIframeSelection()","getSelection(iframeEl)"),a.getSelection(A.getIframeWindow(c))},db=r.prototype,!Q&&U&&B.areHostMethods(R,["removeAllRanges","addRange"]))db.removeAllRanges=function(){this.nativeSelection.removeAllRanges(),j(this)},eb=function(a,b){Z(a.nativeSelection,b),a.refresh()},db.addRange=W?function(b,d){var e,f;$&&P&&this.docSelection.type==K?q(this,b):c(d)&&V?eb(this,b):(X?e=this.rangeCount:(this.removeAllRanges(),e=0),this.nativeSelection.addRange(k(b).cloneRange()),this.rangeCount=this.nativeSelection.rangeCount,this.rangeCount==e+1?(a.config.checkSelectionRanges&&(f=ab(this.nativeSelection,this.rangeCount-1),f&&!N(f,b)&&(b=new E(f))),this._ranges[this.rangeCount-1]=b,h(this,b,hb(this.nativeSelection)),this.isCollapsed=I(this)):this.refresh())}:function(a,b){c(b)&&V?eb(this,a):(this.nativeSelection.addRange(k(a)),this.refresh())},db.setRanges=function(a){if($&&P&&a.length>1)u(this,a);else{this.removeAllRanges();for(var b=0,c=a.length;c>b;++b)this.addRange(a[b])}};else{if(!(C(R,"empty")&&C(S,"select")&&$&&Q))return b.fail("No means of selecting a Range or TextRange was found"),!1;db.removeAllRanges=function(){var a,b,c;try{this.docSelection.empty(),"None"!=this.docSelection.type&&(this.anchorNode?a=L(this.anchorNode):this.docSelection.type==K&&(b=this.docSelection.createRange(),b.length&&(a=L(b.item(0)))),a&&(c=M(a).createTextRange(),c.select(),this.docSelection.empty()))}catch(d){}j(this)},db.addRange=function(b){this.docSelection.type==K?q(this,b):(a.WrappedTextRange.rangeToTextRange(b).select(),this._ranges[0]=b,this.rangeCount=1,this.isCollapsed=this._ranges[0].collapsed,h(this,b,!1))},db.setRanges=function(a){this.removeAllRanges();var b=a.length;b>1?u(this,a):b&&this.addRange(a[0])}}if(db.getRangeAt=function(a){if(0>a||a>=this.rangeCount)throw new F("INDEX_SIZE_ERR");return this._ranges[a].cloneRange()},Q)fb=function(b){var c;a.isSelectionValid(b.win)?c=b.docSelection.createRange():(c=M(b.win.document).createTextRange(),c.collapse(!0)),b.docSelection.type==K?p(b):n(c)?o(b,c):j(b)};else if(C(R,"getRangeAt")&&typeof R.rangeCount==z)fb=function(b){if($&&P&&b.docSelection.type==K)p(b);else if(b._ranges.length=b.rangeCount=b.nativeSelection.rangeCount,b.rangeCount){for(var c=0,d=b.rangeCount;d>c;++c)b._ranges[c]=new a.WrappedRange(b.nativeSelection.getRangeAt(c));h(b,b._ranges[b.rangeCount-1],hb(b.nativeSelection)),b.isCollapsed=I(b)}else j(b)};else{if(!U||typeof R.isCollapsed!=y||typeof S.collapsed!=y||!J.implementsDomRange)return b.fail("No means of obtaining a Range or TextRange from the user's selection was found"),!1;fb=function(a){var b,c=a.nativeSelection;c.anchorNode?(b=ab(c,0),a._ranges=[b],a.rangeCount=1,i(a),a.isCollapsed=I(a)):j(a)}}db.refresh=function(a){var b,c=a?this._ranges.slice(0):null,d=this.anchorNode,e=this.anchorOffset;if(fb(this),a){if(b=c.length,b!=this._ranges.length)return!0;if(this.anchorNode!=d||this.anchorOffset!=e)return!0;for(;b--;)if(!N(c[b],this._ranges[b]))return!0;return!1}},gb=function(a,b){var c,d,e=a.getAllRanges();for(a.removeAllRanges(),c=0,d=e.length;d>c;++c)N(b,e[c])||a.addRange(e[c]);a.rangeCount||j(a)},db.removeRange=$&&P?function(a){var b,c,d,e,f,g,h,i;if(this.docSelection.type==K){for(b=this.docSelection.createRange(),c=m(a),d=L(b.item(0)),e=M(d).createControlRange(),g=!1,h=0,i=b.length;i>h;++h)f=b.item(h),f!==c||g?e.add(b.item(h)):g=!0;e.select(),p(this)}else gb(this,a)}:function(a){gb(this,a)},!Q&&U&&J.implementsDomRange?(hb=g,db.isBackward=function(){return hb(this)}):hb=db.isBackward=function(){return!1},db.isBackwards=db.isBackward,db.toString=function(){var a,b,c=[];for(a=0,b=this.rangeCount;b>a;++a)c[a]=""+this._ranges[a];return c.join("")},db.collapse=function(b,c){v(this,b);var d=a.createRange(b);d.collapseToPoint(b,c),this.setSingleRange(d),this.isCollapsed=!0},db.collapseToStart=function(){if(!this.rangeCount)throw new F("INVALID_STATE_ERR");var a=this._ranges[0];this.collapse(a.startContainer,a.startOffset)},db.collapseToEnd=function(){if(!this.rangeCount)throw new F("INVALID_STATE_ERR");var a=this._ranges[this.rangeCount-1];this.collapse(a.endContainer,a.endOffset)},db.selectAllChildren=function(b){v(this,b);var c=a.createRange(b);c.selectNodeContents(b),this.setSingleRange(c)},db.deleteFromDocument=function(){var a,b,c,d,e;if($&&P&&this.docSelection.type==K){for(a=this.docSelection.createRange();a.length;)b=a.item(0),a.remove(b),b.parentNode.removeChild(b);this.refresh()}else if(this.rangeCount&&(c=this.getAllRanges(),c.length)){for(this.removeAllRanges(),d=0,e=c.length;e>d;++d)c[d].deleteContents();this.addRange(c[e-1])}},db.eachRange=function(a,b){for(var c=0,d=this._ranges.length;d>c;++c)if(a(this.getRangeAt(c)))return b},db.getAllRanges=function(){var a=[];return this.eachRange(function(b){a.push(b)}),a},db.setSingleRange=function(a,b){this.removeAllRanges(),this.addRange(a,b)},db.callMethodOnEachRange=function(a,b){var c=[];return this.eachRange(function(d){c.push(d[a].apply(d,b))}),c},db.setStart=w(!0),db.setEnd=w(!1),a.rangePrototype.select=function(a){cb(this.getDocument()).setSingleRange(this,a)},db.changeEachRange=function(a){var b=[],c=this.isBackward();this.eachRange(function(c){a(c),b.push(c)}),this.removeAllRanges(),c&&1==b.length?this.addRange(b[0],"backward"):this.setRanges(b)},db.containsNode=function(a,b){return this.eachRange(function(c){return c.containsNode(a,b)},!0)||!1},db.getBookmark=function(a){return{backward:this.isBackward(),rangeBookmarks:this.callMethodOnEachRange("getBookmark",[a])}},db.moveToBookmark=function(b){var c,d,e,f=[];for(c=0;d=b.rangeBookmarks[c++];)e=a.createRange(this.win),e.moveToBookmark(d),f.push(e);b.backward?this.setSingleRange(f[0],"backward"):this.setRanges(f)},db.toHtml=function(){var a=[];return this.eachRange(function(b){a.push(D.toHtml(b))}),a.join("")},J.implementsTextRange&&(db.getNativeTextRange=function(){var c,d;if(c=this.docSelection){if(d=c.createRange(),n(d))return d;throw b.createError("getNativeTextRange: selection is a control selection")}if(this.rangeCount>0)return a.WrappedTextRange.rangeToTextRange(this.getRangeAt(0));throw b.createError("getNativeTextRange: selection contains no range")}),db.getName=function(){return"WrappedSelection"},db.inspect=function(){return x(this)},db.detach=function(){t(this.win,"delete"),s(this)},r.detachAll=function(){t(null,"deleteAll")},r.inspect=x,r.isDirectionBackward=c,a.Selection=r,a.selectionPrototype=db,a.addShimListener(function(a){void 0===a.getSelection&&(a.getSelection=function(){return cb(a)}),a=null})}),H)},this),function(a,b){"function"==typeof define&&define.amd?define(["rangy"],a):a(b.rangy)}(function(a){a.createModule("SaveRestore",["WrappedRange"],function(a,b){function c(a,b){return(b||document).getElementById(a)}function d(a,b){var c,d="selectionBoundary_"+ +new Date+"_"+(""+Math.random()).slice(2),e=o.getDocument(a.startContainer),f=a.cloneRange();return f.collapse(b),c=e.createElement("span"),c.id=d,c.style.lineHeight="0",c.style.display="none",c.className="rangySelectionBoundary",c.appendChild(e.createTextNode(p)),f.insertNode(c),c}function e(a,d,e,f){var g=c(e,a);g?(d[f?"setStartBefore":"setEndBefore"](g),g.parentNode.removeChild(g)):b.warn("Marker element has been removed. Cannot restore selection.")}function f(a,b){return b.compareBoundaryPoints(a.START_TO_START,a)}function g(b,c){var e,f,g=a.DomRange.getRangeDocument(b),h=""+b;return b.collapsed?(f=d(b,!1),{document:g,markerId:f.id,collapsed:!0}):(f=d(b,!1),e=d(b,!0),{document:g,startMarkerId:e.id,endMarkerId:f.id,collapsed:!1,backward:c,toString:function(){return"original text: '"+h+"', new text: '"+b+"'"}})}function h(d,f){var g,h,i,j=d.document;return void 0===f&&(f=!0),g=a.createRange(j),d.collapsed?(h=c(d.markerId,j),h?(h.style.display="inline",i=h.previousSibling,i&&3==i.nodeType?(h.parentNode.removeChild(h),g.collapseToPoint(i,i.length)):(g.collapseBefore(h),h.parentNode.removeChild(h))):b.warn("Marker element has been removed. Cannot restore selection.")):(e(j,g,d.startMarkerId,!0),e(j,g,d.endMarkerId,!1)),f&&g.normalizeBoundaries(),g}function i(b,d){var e,h,i,j,k=[];for(b=b.slice(0),b.sort(f),i=0,j=b.length;j>i;++i)k[i]=g(b[i],d);for(i=j-1;i>=0;--i)e=b[i],h=a.DomRange.getRangeDocument(e),e.collapsed?e.collapseAfter(c(k[i].markerId,h)):(e.setEndBefore(c(k[i].endMarkerId,h)),e.setStartAfter(c(k[i].startMarkerId,h)));return k}function j(c){var d,e,f,g;return a.isSelectionValid(c)?(d=a.getSelection(c),e=d.getAllRanges(),f=1==e.length&&d.isBackward(),g=i(e,f),f?d.setSingleRange(e[0],"backward"):d.setRanges(e),{win:c,rangeInfos:g,restored:!1}):(b.warn("Cannot save selection. This usually happens when the selection is collapsed and the selection document has lost focus."),null)}function k(a){var b,c=[],d=a.length;for(b=d-1;b>=0;b--)c[b]=h(a[b],!0);return c}function l(b,c){var d,e,f,g;b.restored||(d=b.rangeInfos,e=a.getSelection(b.win),f=k(d),g=d.length,1==g&&c&&a.features.selectionHasExtend&&d[0].backward?(e.removeAllRanges(),e.addRange(f[0],!0)):e.setRanges(f),b.restored=!0)}function m(a,b){var d=c(b,a);d&&d.parentNode.removeChild(d)}function n(a){var b,c,d,e=a.rangeInfos;for(b=0,c=e.length;c>b;++b)d=e[b],d.collapsed?m(a.doc,d.markerId):(m(a.doc,d.startMarkerId),m(a.doc,d.endMarkerId))}var o=a.dom,p="﻿";a.util.extend(a,{saveRange:g,restoreRange:h,saveRanges:i,restoreRanges:k,saveSelection:j,restoreSelection:l,removeMarkerElement:m,removeMarkers:n})})},this),Base=function(){},Base.extend=function(a,b){var c,d,e,f=Base.prototype.extend;return Base._prototyping=!0,c=new this,f.call(c,a),c.base=function(){},delete Base._prototyping,d=c.constructor,e=c.constructor=function(){if(!Base._prototyping)if(this._constructing||this.constructor==e)this._constructing=!0,d.apply(this,arguments),delete this._constructing;else if(null!=arguments[0])return(arguments[0].extend||f).call(arguments[0],c)},e.ancestor=this,e.extend=this.extend,e.forEach=this.forEach,e.implement=this.implement,e.prototype=c,e.toString=this.toString,e.valueOf=function(a){return"object"==a?e:d.valueOf()},f.call(e,b),"function"==typeof e.init&&e.init(),e},Base.prototype={extend:function(a,b){var c,d,e,f,g,h,i;if(arguments.length>1)c=this[a],!c||"function"!=typeof b||c.valueOf&&c.valueOf()==b.valueOf()||!/\bbase\b/.test(b)||(d=b.valueOf(),b=function(){var a,b=this.base||Base.prototype.base;return this.base=c,a=d.apply(this,arguments),this.base=b,a},b.valueOf=function(a){return"object"==a?b:d},b.toString=Base.toString),this[a]=b;else if(a){for(e=Base.prototype.extend,Base._prototyping||"function"==typeof this||(e=this.extend||e),f={toSource:null},g=["constructor","toString","valueOf"],h=Base._prototyping?0:1;i=g[h++];)a[i]!=f[i]&&e.call(this,i,a[i]);for(i in a)f[i]||e.call(this,i,a[i])}return this}},Base=Base.extend({constructor:function(){this.extend(arguments[0])}},{ancestor:Object,version:"1.1",forEach:function(a,b,c){for(var d in a)void 0===this.prototype[d]&&b.call(c,a[d],d,a)},implement:function(){for(var a=0;a<arguments.length;a++)"function"==typeof arguments[a]?arguments[a](this.prototype):this.prototype.extend(arguments[a]);return this},toString:function(){return this.valueOf()+""}}),wysihtml5.browser=function(){function a(a){return+(/ipad|iphone|ipod/.test(a)&&a.match(/ os (\d+).+? like mac os x/)||[void 0,0])[1]}function b(a){return+(a.match(/android (\d+)/)||[void 0,0])[1]}function c(a,b){var c,d=-1;return"Microsoft Internet Explorer"==navigator.appName?c=RegExp("MSIE ([0-9]{1,}[.0-9]{0,})"):"Netscape"==navigator.appName&&(c=RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})")),c&&null!=c.exec(navigator.userAgent)&&(d=parseFloat(RegExp.$1)),-1===d?!1:a?b?"<"===b?d>a:">"===b?a>d:"<="===b?d>=a:">="===b?a>=d:void 0:a===d:!0}var d=navigator.userAgent,e=document.createElement("div"),f=-1!==d.indexOf("Gecko")&&-1===d.indexOf("KHTML"),g=-1!==d.indexOf("AppleWebKit/"),h=-1!==d.indexOf("Chrome/"),i=-1!==d.indexOf("Opera/");return{USER_AGENT:d,supported:function(){var c=this.USER_AGENT.toLowerCase(),d="contentEditable"in e,f=document.execCommand&&document.queryCommandSupported&&document.queryCommandState,g=document.querySelector&&document.querySelectorAll,h=this.isIos()&&a(c)<5||this.isAndroid()&&b(c)<4||-1!==c.indexOf("opera mobi")||-1!==c.indexOf("hpwos/");return d&&f&&g&&!h},isTouchDevice:function(){return this.supportsEvent("touchmove")},isIos:function(){return/ipad|iphone|ipod/i.test(this.USER_AGENT)},isAndroid:function(){return-1!==this.USER_AGENT.indexOf("Android")},supportsSandboxedIframes:function(){return c()},throwsMixedContentWarningWhenIframeSrcIsEmpty:function(){return!("querySelector"in document)},displaysCaretInEmptyContentEditableCorrectly:function(){return c()},hasCurrentStyleProperty:function(){return"currentStyle"in e},hasHistoryIssue:function(){return f&&"Mac"===navigator.platform.substr(0,3)},insertsLineBreaksOnReturn:function(){return f},supportsPlaceholderAttributeOn:function(a){return"placeholder"in a},supportsEvent:function(a){return"on"+a in e||function(){return e.setAttribute("on"+a,"return;"),"function"==typeof e["on"+a]}()},supportsEventsInIframeCorrectly:function(){return!i},supportsHTML5Tags:function(a){var b=a.createElement("div"),c="<article>foo</article>";return b.innerHTML=c,b.innerHTML.toLowerCase()===c},supportsCommand:function(){var a={formatBlock:c(10,"<="),insertUnorderedList:c(),insertOrderedList:c()},b={insertHTML:f};return function(c,d){var e=a[d];if(!e){try{return c.queryCommandSupported(d)}catch(f){}try{return c.queryCommandEnabled(d)}catch(g){return!!b[d]}}return!1}}(),doesAutoLinkingInContentEditable:function(){return c()},canDisableAutoLinking:function(){return this.supportsCommand(document,"AutoUrlDetect")},clearsContentEditableCorrectly:function(){return f||i||g},supportsGetAttributeCorrectly:function(){var a=document.createElement("td");return"1"!=a.getAttribute("rowspan")},canSelectImagesInContentEditable:function(){return f||c()||i},autoScrollsToCaret:function(){return!g},autoClosesUnclosedTags:function(){var a,b,c=e.cloneNode(!1);return c.innerHTML="<p><div></div>",b=c.innerHTML.toLowerCase(),a="<p></p><div></div>"===b||"<p><div></div></p>"===b,this.autoClosesUnclosedTags=function(){return a},a},supportsNativeGetElementsByClassName:function(){return-1!==(document.getElementsByClassName+"").indexOf("[native code]")},supportsSelectionModify:function(){return"getSelection"in window&&"modify"in window.getSelection()},needsSpaceAfterLineBreak:function(){return i},supportsSpeechApiOn:function(a){var b=d.match(/Chrome\/(\d+)/)||[void 0,0];return b[1]>=11&&("onwebkitspeechchange"in a||"speech"in a)},crashesWhenDefineProperty:function(a){return c(9)&&("XMLHttpRequest"===a||"XDomainRequest"===a)},doesAsyncFocus:function(){return c()},hasProblemsSettingCaretAfterImg:function(){return c()},hasUndoInContextMenu:function(){return f||h||i},hasInsertNodeIssue:function(){return i},hasIframeFocusIssue:function(){return c()},createsNestedInvalidMarkupAfterPaste:function(){return g},supportsMutationEvents:function(){return"MutationEvent"in window},supportsModenPaste:function(){return!("clipboardData"in window)}}}(),wysihtml5.lang.array=function(a){return{contains:function(b){if(Array.isArray(b)){for(var c=b.length;c--;)if(-1!==wysihtml5.lang.array(a).indexOf(b[c]))return!0;return!1}return-1!==wysihtml5.lang.array(a).indexOf(b)},indexOf:function(b){if(a.indexOf)return a.indexOf(b);for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},without:function(b){b=wysihtml5.lang.array(b);for(var c=[],d=0,e=a.length;e>d;d++)b.contains(a[d])||c.push(a[d]);return c},get:function(){for(var b=0,c=a.length,d=[];c>b;b++)d.push(a[b]);return d},map:function(b,c){if(Array.prototype.map)return a.map(b,c);for(var d=a.length>>>0,e=Array(d),f=0;d>f;f++)e[f]=b.call(c,a[f],f,a);return e},unique:function(){for(var b=[],c=a.length,d=0;c>d;)wysihtml5.lang.array(b).contains(a[d])||b.push(a[d]),d++;return b}}},wysihtml5.lang.Dispatcher=Base.extend({on:function(a,b){return this.events=this.events||{},this.events[a]=this.events[a]||[],this.events[a].push(b),this},off:function(a,b){this.events=this.events||{};var c,d,e=0;if(a){for(c=this.events[a]||[],d=[];e<c.length;e++)c[e]!==b&&b&&d.push(c[e]);this.events[a]=d}else this.events={};return this},fire:function(a,b){this.events=this.events||{};for(var c=this.events[a]||[],d=0;d<c.length;d++)c[d].call(this,b);return this},observe:function(){return this.on.apply(this,arguments)},stopObserving:function(){return this.off.apply(this,arguments)}}),wysihtml5.lang.object=function(a){return{merge:function(b){for(var c in b)a[c]=b[c];return this},get:function(){return a},clone:function(b){var c,d={};if(null===a||!wysihtml5.lang.object(a).isPlainObject())return a;for(c in a)a.hasOwnProperty(c)&&(d[c]=b?wysihtml5.lang.object(a[c]).clone(b):a[c]);return d},isArray:function(){return"[object Array]"===Object.prototype.toString.call(a)},isFunction:function(){return"[object Function]"===Object.prototype.toString.call(a)},isPlainObject:function(){return"[object Object]"===Object.prototype.toString.call(a)}}},function(){var a=/^\s+/,b=/\s+$/,c=/[&<>\t"]/g,d={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","	":"&nbsp; "};wysihtml5.lang.string=function(e){return e+="",{trim:function(){return e.replace(a,"").replace(b,"")},interpolate:function(a){for(var b in a)e=this.replace("#{"+b+"}").by(a[b]);return e},replace:function(a){return{by:function(b){return e.split(a).join(b)}}},escapeHTML:function(a,b){var f=e.replace(c,function(a){return d[a]});return a&&(f=f.replace(/(?:\r\n|\r|\n)/g,"<br />")),b&&(f=f.replace(/  /gi,"&nbsp; ")),f}}}}(),function(a){function b(a,b){return f(a,b)?a:(a===a.ownerDocument.documentElement&&(a=a.ownerDocument.body),g(a,b))}function c(a){return a.replace(i,function(a,b){var c,d,e=(b.match(j)||[])[1]||"",f=l[e];return b=b.replace(j,""),b.split(f).length>b.split(e).length&&(b+=e,e=""),c=b,d=b,b.length>k&&(d=d.substr(0,k)+"..."),"www."===c.substr(0,4)&&(c="http://"+c),'<a href="'+c+'">'+d+"</a>"+e})}function d(a){var b=a._wysihtml5_tempElement;return b||(b=a._wysihtml5_tempElement=a.createElement("div")),b}function e(b){var e=b.parentNode,f=a.lang.string(b.data).escapeHTML(),g=d(e.ownerDocument);for(g.innerHTML="<span></span>"+c(f),g.removeChild(g.firstChild);g.firstChild;)e.insertBefore(g.firstChild,b);e.removeChild(b)}function f(b,c){for(var d;b.parentNode;){if(b=b.parentNode,d=b.nodeName,b.className&&a.lang.array(b.className.split(" ")).contains(c))return!0;if(h.contains(d))return!0;if("body"===d)return!1}return!1}function g(b,c){if(!(h.contains(b.nodeName)||b.className&&a.lang.array(b.className.split(" ")).contains(c))){if(b.nodeType===a.TEXT_NODE&&b.data.match(i))return e(b),void 0;for(var d=a.lang.array(b.childNodes).get(),f=d.length,j=0;f>j;j++)g(d[j],c);return b}}var h=a.lang.array(["CODE","PRE","A","SCRIPT","HEAD","TITLE","STYLE"]),i=/((https?:\/\/|www\.)[^\s<]{3,})/gi,j=/([^\w\/\-](,?))$/i,k=100,l={")":"(","]":"[","}":"{"};a.dom.autoLink=b,a.dom.autoLink.URL_REG_EXP=i}(wysihtml5),function(a){var b=a.dom;b.addClass=function(a,c){var d=a.classList;return d?d.add(c):(b.hasClass(a,c)||(a.className+=" "+c),void 0)},b.removeClass=function(a,b){var c=a.classList;return c?c.remove(b):(a.className=a.className.replace(RegExp("(^|\\s+)"+b+"(\\s+|$)")," "),void 0)},b.hasClass=function(a,b){var c,d=a.classList;return d?d.contains(b):(c=a.className,c.length>0&&(c==b||RegExp("(^|\\s)"+b+"(\\s|$)").test(c)))}}(wysihtml5),wysihtml5.dom.contains=function(){var a=document.documentElement;return a.contains?function(a,b){return b.nodeType!==wysihtml5.ELEMENT_NODE&&(b=b.parentNode),a!==b&&a.contains(b)}:a.compareDocumentPosition?function(a,b){return!!(16&a.compareDocumentPosition(b))}:void 0}(),wysihtml5.dom.convertToList=function(){function a(a,b){var c=a.createElement("li");return b.appendChild(c),c}function b(a,b){return a.createElement(b)}function c(c,d,e){if("UL"===c.nodeName||"OL"===c.nodeName||"MENU"===c.nodeName)return c;var f,g,h,i,j,k,l,m,n,o=c.ownerDocument,p=b(o,d),q=c.querySelectorAll("br"),r=q.length;for(n=0;r>n;n++)for(i=q[n];(j=i.parentNode)&&j!==c&&j.lastChild===i;){if("block"===wysihtml5.dom.getStyle("display").from(j)){j.removeChild(i);break}wysihtml5.dom.insert(i).after(i.parentNode)}for(f=wysihtml5.lang.array(c.childNodes).get(),g=f.length,n=0;g>n;n++)m=m||a(o,p),h=f[n],k="block"===wysihtml5.dom.getStyle("display").from(h),l="BR"===h.nodeName,!k||e&&wysihtml5.dom.hasClass(h,e)?l?m=m.firstChild?null:m:m.appendChild(h):(m=m.firstChild?a(o,p):m,m.appendChild(h),m=null);return 0===f.length&&a(o,p),c.parentNode.replaceChild(p,c),p}return c}(),wysihtml5.dom.copyAttributes=function(a){return{from:function(b){return{to:function(c){for(var d,e=0,f=a.length;f>e;e++)d=a[e],void 0!==b[d]&&""!==b[d]&&(c[d]=b[d]);return{andTo:arguments.callee}}}}}},function(a){var b=["-webkit-box-sizing","-moz-box-sizing","-ms-box-sizing","box-sizing"],c=function(b){return d(b)?parseInt(a.getStyle("width").from(b),10)<b.offsetWidth:!1},d=function(c){for(var d=0,e=b.length;e>d;d++)if("border-box"===a.getStyle(b[d]).from(c))return b[d]};a.copyStyles=function(d){return{from:function(e){c(e)&&(d=wysihtml5.lang.array(d).without(b));for(var f,g="",h=d.length,i=0;h>i;i++)f=d[i],g+=f+":"+a.getStyle(f).from(e)+";";return{to:function(b){return a.setStyles(g).on(b),{andTo:arguments.callee}}}}}}}(wysihtml5.dom),function(a){a.dom.delegate=function(b,c,d,e){return a.dom.observe(b,d,function(d){for(var f=d.target,g=a.lang.array(b.querySelectorAll(c));f&&f!==b;){if(g.contains(f)){e.call(f,d);break}f=f.parentNode}})}}(wysihtml5),function(a){a.dom.domNode=function(b){var c=[a.ELEMENT_NODE,a.TEXT_NODE],d=function(b){return b.nodeType===a.TEXT_NODE&&/^\s*$/g.test(b.data)};return{prev:function(e){var f=b.previousSibling,g=e&&e.nodeTypes?e.nodeTypes:c;return f?!a.lang.array(g).contains(f.nodeType)||e&&e.ignoreBlankTexts&&d(f)?a.dom.domNode(f).prev(e):f:null},next:function(e){var f=b.nextSibling,g=e&&e.nodeTypes?e.nodeTypes:c;return f?!a.lang.array(g).contains(f.nodeType)||e&&e.ignoreBlankTexts&&d(f)?a.dom.domNode(f).next(e):f:null}}}}(wysihtml5),wysihtml5.dom.getAsDom=function(){var a=function(a,b){var c=b.createElement("div");c.style.display="none",b.body.appendChild(c);try{c.innerHTML=a}catch(d){}return b.body.removeChild(c),c},b=function(a){if(!a._wysihtml5_supportsHTML5Tags){for(var b=0,d=c.length;d>b;b++)a.createElement(c[b]);a._wysihtml5_supportsHTML5Tags=!0}},c=["abbr","article","aside","audio","bdi","canvas","command","datalist","details","figcaption","figure","footer","header","hgroup","keygen","mark","meter","nav","output","progress","rp","rt","ruby","svg","section","source","summary","time","track","video","wbr"];return function(c,d){d=d||document;var e;return"object"==typeof c&&c.nodeType?(e=d.createElement("div"),e.appendChild(c)):wysihtml5.browser.supportsHTML5Tags(d)?(e=d.createElement("div"),e.innerHTML=c):(b(d),e=a(c,d)),e}}(),wysihtml5.dom.getParentElement=function(){function a(a,b){return b&&b.length?"string"==typeof b?a===b:wysihtml5.lang.array(b).contains(a):!0}function b(a){return a.nodeType===wysihtml5.ELEMENT_NODE}function c(a,b,c){var d=(a.className||"").match(c)||[];return b?d[d.length-1]===b:!!d.length}function d(a,b,c){var d=(a.getAttribute("style")||"").match(c)||[];return b?d[d.length-1]===b:!!d.length}return function(e,f,g,h){var i=f.cssStyle||f.styleRegExp,j=f.className||f.classRegExp;for(g=g||50;g--&&e&&"BODY"!==e.nodeName&&(!h||e!==h);){if(b(e)&&a(e.nodeName,f.nodeName)&&(!i||d(e,f.cssStyle,f.styleRegExp))&&(!j||c(e,f.className,f.classRegExp)))return e;e=e.parentNode}return null}}(),wysihtml5.dom.getStyle=function(){function a(a){return a.replace(c,function(a){return a.charAt(1).toUpperCase()
  })}var b={"float":"styleFloat"in document.createElement("div").style?"styleFloat":"cssFloat"},c=/\-[a-z]/g;return function(c){return{from:function(d){var e,f,g,h,i,j,k,l,m;if(d.nodeType===wysihtml5.ELEMENT_NODE){if(e=d.ownerDocument,f=b[c]||a(c),g=d.style,h=d.currentStyle,i=g[f],i)return i;if(h)try{return h[f]}catch(n){}return j=e.defaultView||e.parentWindow,k=("height"===c||"width"===c)&&"TEXTAREA"===d.nodeName,j.getComputedStyle?(k&&(l=g.overflow,g.overflow="hidden"),m=j.getComputedStyle(d,null).getPropertyValue(c),k&&(g.overflow=l||""),m):void 0}}}}}(),wysihtml5.dom.getTextNodes=function(a,b){var c=[];for(a=a.firstChild;a;a=a.nextSibling)3==a.nodeType?b&&/^\s*$/.test(a.innerText||a.textContent)||c.push(a):c=c.concat(wysihtml5.dom.getTextNodes(a,b));return c},wysihtml5.dom.hasElementWithTagName=function(){function a(a){return a._wysihtml5_identifier||(a._wysihtml5_identifier=c++)}var b={},c=1;return function(c,d){var e=a(c)+":"+d,f=b[e];return f||(f=b[e]=c.getElementsByTagName(d)),f.length>0}}(),function(a){function b(a){return a._wysihtml5_identifier||(a._wysihtml5_identifier=d++)}var c={},d=1;a.dom.hasElementWithClassName=function(d,e){if(!a.browser.supportsNativeGetElementsByClassName())return!!d.querySelector("."+e);var f=b(d)+":"+e,g=c[f];return g||(g=c[f]=d.getElementsByClassName(e)),g.length>0}}(wysihtml5),wysihtml5.dom.insert=function(a){return{after:function(b){b.parentNode.insertBefore(a,b.nextSibling)},before:function(b){b.parentNode.insertBefore(a,b)},into:function(b){b.appendChild(a)}}},wysihtml5.dom.insertCSS=function(a){return a=a.join("\n"),{into:function(b){var c,d,e=b.createElement("style");return e.type="text/css",e.styleSheet?e.styleSheet.cssText=a:e.appendChild(b.createTextNode(a)),c=b.querySelector("head link"),c?(c.parentNode.insertBefore(e,c),void 0):(d=b.querySelector("head"),d&&d.appendChild(e),void 0)}}},function(a){a.dom.lineBreaks=function(b){function c(a){return"BR"===a.nodeName}function d(b){return c(b)?!0:"block"===a.dom.getStyle("display").from(b)?!0:!1}return{add:function(){var c=b.ownerDocument,e=a.dom.domNode(b).next({ignoreBlankTexts:!0}),f=a.dom.domNode(b).prev({ignoreBlankTexts:!0});e&&!d(e)&&a.dom.insert(c.createElement("br")).after(b),f&&!d(f)&&a.dom.insert(c.createElement("br")).before(b)},remove:function(){var d=a.dom.domNode(b).next({ignoreBlankTexts:!0}),e=a.dom.domNode(b).prev({ignoreBlankTexts:!0});d&&c(d)&&d.parentNode.removeChild(d),e&&c(e)&&e.parentNode.removeChild(e)}}}}(wysihtml5),wysihtml5.dom.observe=function(a,b,c){b="string"==typeof b?[b]:b;for(var d,e,f=0,g=b.length;g>f;f++)e=b[f],a.addEventListener?a.addEventListener(e,c,!1):(d=function(b){"target"in b||(b.target=b.srcElement),b.preventDefault=b.preventDefault||function(){this.returnValue=!1},b.stopPropagation=b.stopPropagation||function(){this.cancelBubble=!0},c.call(a,b)},a.attachEvent("on"+e,d));return{stop:function(){for(var e,f=0,g=b.length;g>f;f++)e=b[f],a.removeEventListener?a.removeEventListener(e,c,!1):a.detachEvent("on"+e,d)}}},wysihtml5.dom.parse=function(a,b){function c(a,b){var c,f,g,h,i,j,k,l,m;for(wysihtml5.lang.object(t).merge(s).merge(b.rules).get(),c=b.context||a.ownerDocument||document,f=c.createDocumentFragment(),g="string"==typeof a,h=!1,b.clearInternals===!0&&(h=!0),i=g?wysihtml5.dom.getAsDom(a,c):a,t.selectors&&e(i,t.selectors);i.firstChild;)k=i.firstChild,j=d(k,b.cleanUp,h,b.uneditableClass),j&&f.appendChild(j),k!==j&&i.removeChild(k);if(b.unjoinNbsps)for(l=wysihtml5.dom.getTextNodes(f),m=l.length;m--;)l[m].nodeValue=l[m].nodeValue.replace(/([\S\u00A0])\u00A0/gi,"$1 ");return i.innerHTML="",i.appendChild(f),g?wysihtml5.quirks.getCorrectInnerHTML(i):i}function d(a,b,c,e){var f,g,h,i=a.nodeType,j=a.childNodes,k=j.length,l=p[i],m=0;if(e&&1===i&&wysihtml5.dom.hasClass(a,e))return a;if(g=l&&l(a,c),!g){if(g===!1){for(f=a.ownerDocument.createDocumentFragment(),m=k;m--;)j[m]&&(h=d(j[m],b,c,e),h&&(j[m]===h&&m--,f.insertBefore(h,f.firstChild)));return"block"===wysihtml5.dom.getStyle("display").from(a)&&f.appendChild(a.ownerDocument.createElement("br")),wysihtml5.lang.array(["div","pre","p","table","td","th","ul","ol","li","dd","dl","footer","header","section","h1","h2","h3","h4","h5","h6"]).contains(a.nodeName.toLowerCase())&&a.parentNode.lastChild!==a&&(a.nextSibling&&3===a.nextSibling.nodeType&&/^\s/.test(a.nextSibling.nodeValue)||f.appendChild(a.ownerDocument.createTextNode(" "))),f.normalize&&f.normalize(),f}return null}for(m=0;k>m;m++)j[m]&&(h=d(j[m],b,c,e),h&&(j[m]===h&&m--,g.appendChild(h)));if(b&&g.nodeName.toLowerCase()===q&&(!g.childNodes.length||/^\s*$/gi.test(g.innerHTML)&&(c||"_wysihtml5-temp-placeholder"!==a.className&&"rangySelectionBoundary"!==a.className)||!g.attributes.length)){for(f=g.ownerDocument.createDocumentFragment();g.firstChild;)f.appendChild(g.firstChild);return f.normalize&&f.normalize(),f}return g.normalize&&g.normalize(),g}function e(a,b){var c,d,e,f;for(c in b)if(b.hasOwnProperty(c))for(wysihtml5.lang.object(b[c]).isFunction()?d=b[c]:"string"==typeof b[c]&&z[b[c]]&&(d=z[b[c]]),e=a.querySelectorAll(c),f=e.length;f--;)d(e[f])}function f(a,b){var c,d,e,f=t.tags,h=a.nodeName.toLowerCase(),j=a.scopeName;if(a._wysihtml5)return null;if(a._wysihtml5=1,"wysihtml5-temp"===a.className)return null;if(j&&"HTML"!=j&&(h=j+":"+h),"outerHTML"in a&&(wysihtml5.browser.autoClosesUnclosedTags()||"P"!==a.nodeName||"</p>"===a.outerHTML.slice(-4).toLowerCase()||(h="div")),h in f){if(c=f[h],!c||c.remove)return null;if(c.unwrap)return!1;c="string"==typeof c?{rename_tag:c}:c}else{if(!a.firstChild)return null;c={rename_tag:q}}if(c.one_of_type&&!g(a,t,c.one_of_type,b)){if(!c.remove_action)return null;if("unwrap"===c.remove_action)return!1;if("rename"!==c.remove_action)return null;e=c.remove_action_rename_to||q}return d=a.ownerDocument.createElement(e||c.rename_tag||h),m(a,d,c,b),i(a,d,c),a=null,d.normalize&&d.normalize(),d}function g(a,b,c,d){var e,f;if("SPAN"===a.nodeName&&!d&&("_wysihtml5-temp-placeholder"===a.className||"rangySelectionBoundary"===a.className))return!0;for(f in c)if(c.hasOwnProperty(f)&&b.type_definitions&&b.type_definitions[f]&&(e=b.type_definitions[f],h(a,e)))return!0;return!1}function h(a,b){var c,d,e,f,g,h,i,j,k=a.getAttribute("class"),l=a.getAttribute("style");if(b.methods)for(h in b.methods)if(b.methods.hasOwnProperty(h)&&y[h]&&y[h](a))return!0;if(k&&b.classes)for(k=k.replace(/^\s+/g,"").replace(/\s+$/g,"").split(r),c=k.length,i=0;c>i;i++)if(b.classes[k[i]])return!0;if(l&&b.styles){l=l.split(";");for(d in b.styles)if(b.styles.hasOwnProperty(d))for(j=l.length;j--;)if(g=l[j].split(":"),g[0].replace(/\s/g,"").toLowerCase()===d&&(b.styles[d]===!0||1===b.styles[d]||wysihtml5.lang.array(b.styles[d]).contains(g[1].replace(/\s/g,"").toLowerCase())))return!0}if(b.attrs)for(e in b.attrs)if(b.attrs.hasOwnProperty(e)&&(f=wysihtml5.dom.getAttribute(a,e),"string"==typeof f&&f.search(b.attrs[e])>-1))return!0;return!1}function i(a,b,c){var d,e;if(c&&c.keep_styles)for(d in c.keep_styles)if(c.keep_styles.hasOwnProperty(d)){if(e="float"===d?a.style.styleFloat||a.style.cssFloat:a.style[d],c.keep_styles[d]instanceof RegExp&&!c.keep_styles[d].test(e))continue;"float"===d?b.style[a.style.styleFloat?"styleFloat":"cssFloat"]=e:a.style[d]&&(b.style[d]=e)}}function j(a,b){var c,d=[];for(c in b)b.hasOwnProperty(c)&&0===c.indexOf(a)&&d.push(c);return d}function k(a,b,c,d){var e,f=v[c];return f&&(b||"alt"===a&&"IMG"==d)&&(e=f(b),"string"==typeof e)?e:!1}function l(a,b){var c,d,e,f,g,h=wysihtml5.lang.object(t.attributes||{}).clone(),i=wysihtml5.lang.object(h).merge(wysihtml5.lang.object(b||{}).clone()).get(),l={},m=wysihtml5.dom.getAttributes(a);for(c in i)if(/\*$/.test(c))for(e=j(c.slice(0,-1),m),f=0,g=e.length;g>f;f++)d=k(e[f],m[e[f]],i[c],a.nodeName),d!==!1&&(l[e[f]]=d);else d=k(c,m[c],i[c],a.nodeName),d!==!1&&(l[c]=d);return l}function m(a,b,c,d){var e,f,g,h,i,j={},k=c.set_class,m=c.add_class,n=c.add_style,o=c.set_attributes,p=t.classes,q=0,s=[],u=[],v=[],y=[];if(o&&(j=wysihtml5.lang.object(o).clone()),j=wysihtml5.lang.object(j).merge(l(a,c.check_attributes)).get(),k&&s.push(k),m)for(h in m)i=x[m[h]],i&&(g=i(wysihtml5.dom.getAttribute(a,h)),"string"==typeof g&&s.push(g));if(n)for(h in n)i=w[n[h]],i&&(newStyle=i(wysihtml5.dom.getAttribute(a,h)),"string"==typeof newStyle&&u.push(newStyle));if("string"==typeof p&&"any"===p&&a.getAttribute("class"))if(t.classes_blacklist){for(y=a.getAttribute("class"),y&&(s=s.concat(y.split(r))),e=s.length;e>q;q++)f=s[q],t.classes_blacklist[f]||v.push(f);v.length&&(j["class"]=wysihtml5.lang.array(v).unique().join(" "))}else j["class"]=a.getAttribute("class");else{for(d||(p["_wysihtml5-temp-placeholder"]=1,p._rangySelectionBoundary=1,p["wysiwyg-tmp-selected-cell"]=1),y=a.getAttribute("class"),y&&(s=s.concat(y.split(r))),e=s.length;e>q;q++)f=s[q],p[f]&&v.push(f);v.length&&(j["class"]=wysihtml5.lang.array(v).unique().join(" "))}j["class"]&&d&&(j["class"]=j["class"].replace("wysiwyg-tmp-selected-cell",""),/^\s*$/g.test(j["class"])&&delete j["class"]),u.length&&(j.style=wysihtml5.lang.array(u).unique().join(" "));for(h in j)try{b.setAttribute(h,j[h])}catch(z){}j.src&&(void 0!==j.width&&b.setAttribute("width",j.width),void 0!==j.height&&b.setAttribute("height",j.height))}function n(a){var b,c=a.nextSibling;return c&&c.nodeType===wysihtml5.TEXT_NODE?(c.data=a.data.replace(u,"")+c.data.replace(u,""),void 0):(b=a.data.replace(u,""),a.ownerDocument.createTextNode(b))}function o(a){return t.comments?a.ownerDocument.createComment(a.nodeValue):void 0}var p={1:f,3:n,8:o},q="span",r=/\s+/,s={tags:{},classes:{}},t={},u=/\uFEFF/g,v={url:function(){var a=/^https?:\/\//i;return function(b){return b&&b.match(a)?b.replace(a,function(a){return a.toLowerCase()}):null}}(),src:function(){var a=/^(\/|https?:\/\/)/i;return function(b){return b&&b.match(a)?b.replace(a,function(a){return a.toLowerCase()}):null}}(),href:function(){var a=/^(#|\/|https?:\/\/|mailto:)/i;return function(b){return b&&b.match(a)?b.replace(a,function(a){return a.toLowerCase()}):null}}(),alt:function(){var a=/[^ a-z0-9_\-]/gi;return function(b){return b?b.replace(a,""):""}}(),numbers:function(){var a=/\D/g;return function(b){return b=(b||"").replace(a,""),b||null}}(),any:function(){return function(a){return a}}()},w={align_text:function(){var a={left:"text-align: left;",right:"text-align: right;",center:"text-align: center;"};return function(b){return a[(b+"").toLowerCase()]}}()},x={align_img:function(){var a={left:"wysiwyg-float-left",right:"wysiwyg-float-right"};return function(b){return a[(b+"").toLowerCase()]}}(),align_text:function(){var a={left:"wysiwyg-text-align-left",right:"wysiwyg-text-align-right",center:"wysiwyg-text-align-center",justify:"wysiwyg-text-align-justify"};return function(b){return a[(b+"").toLowerCase()]}}(),clear_br:function(){var a={left:"wysiwyg-clear-left",right:"wysiwyg-clear-right",both:"wysiwyg-clear-both",all:"wysiwyg-clear-both"};return function(b){return a[(b+"").toLowerCase()]}}(),size_font:function(){var a={1:"wysiwyg-font-size-xx-small",2:"wysiwyg-font-size-small",3:"wysiwyg-font-size-medium",4:"wysiwyg-font-size-large",5:"wysiwyg-font-size-x-large",6:"wysiwyg-font-size-xx-large",7:"wysiwyg-font-size-xx-large","-":"wysiwyg-font-size-smaller","+":"wysiwyg-font-size-larger"};return function(b){return a[(b+"").charAt(0)]}}()},y={has_visible_contet:function(){var a,b=["img","video","picture","br","script","noscript","style","table","iframe","object","embed","audio","svg","input","button","select","textarea","canvas"];return function(c){if(a=(c.innerText||c.textContent).replace(/\s/g,""),a&&a.length>0)return!0;for(var d=b.length;d--;)if(c.querySelector(b[d]))return!0;return c.offsetWidth&&c.offsetWidth>0&&c.offsetHeight&&c.offsetHeight>0?!0:!1}}()},z={unwrap:function(a){wysihtml5.dom.unwrap(a)},remove:function(a){a.parentNode.removeChild(a)}};return c(a,b)},wysihtml5.dom.removeEmptyTextNodes=function(a){for(var b,c=wysihtml5.lang.array(a.childNodes).get(),d=c.length,e=0;d>e;e++)b=c[e],b.nodeType===wysihtml5.TEXT_NODE&&""===b.data&&b.parentNode.removeChild(b)},wysihtml5.dom.renameElement=function(a,b){for(var c,d=a.ownerDocument.createElement(b);c=a.firstChild;)d.appendChild(c);return wysihtml5.dom.copyAttributes(["align","className"]).from(a).to(d),a.parentNode.replaceChild(d,a),d},wysihtml5.dom.replaceWithChildNodes=function(a){if(a.parentNode){if(!a.firstChild)return a.parentNode.removeChild(a),void 0;for(var b=a.ownerDocument.createDocumentFragment();a.firstChild;)b.appendChild(a.firstChild);a.parentNode.replaceChild(b,a),a=b=null}},function(a){function b(b){return"block"===a.getStyle("display").from(b)}function c(a){return"BR"===a.nodeName}function d(a){var b=a.ownerDocument.createElement("br");a.appendChild(b)}function e(a,e){if(a.nodeName.match(/^(MENU|UL|OL)$/)){var f,g,h,i,j,k,l=a.ownerDocument,m=l.createDocumentFragment(),n=wysihtml5.dom.domNode(a).prev({ignoreBlankTexts:!0});if(e)for(!n||b(n)||c(n)||d(m);k=a.firstElementChild||a.firstChild;){for(g=k.lastChild;f=k.firstChild;)h=f===g,i=h&&!b(f)&&!c(f),m.appendChild(f),i&&d(m);k.parentNode.removeChild(k)}else for(;k=a.firstElementChild||a.firstChild;){if(k.querySelector&&k.querySelector("div, p, ul, ol, menu, blockquote, h1, h2, h3, h4, h5, h6"))for(;f=k.firstChild;)m.appendChild(f);else{for(j=l.createElement("p");f=k.firstChild;)j.appendChild(f);m.appendChild(j)}k.parentNode.removeChild(k)}a.parentNode.replaceChild(m,a)}}a.resolveList=e}(wysihtml5.dom),function(a){var b=document,c=["parent","top","opener","frameElement","frames","localStorage","globalStorage","sessionStorage","indexedDB"],d=["open","close","openDialog","showModalDialog","alert","confirm","prompt","openDatabase","postMessage","XMLHttpRequest","XDomainRequest"],e=["referrer","write","open","close"];a.dom.Sandbox=Base.extend({constructor:function(b,c){this.callback=b||a.EMPTY_FUNCTION,this.config=a.lang.object({}).merge(c).get(),this.editableArea=this._createIframe()},insertInto:function(a){"string"==typeof a&&(a=b.getElementById(a)),a.appendChild(this.editableArea)},getIframe:function(){return this.editableArea},getWindow:function(){this._readyError()},getDocument:function(){this._readyError()},destroy:function(){var a=this.getIframe();a.parentNode.removeChild(a)},_readyError:function(){throw Error("wysihtml5.Sandbox: Sandbox iframe isn't loaded yet")},_createIframe:function(){var c=this,d=b.createElement("iframe");return d.className="wysihtml5-sandbox",a.dom.setAttributes({security:"restricted",allowtransparency:"true",frameborder:0,width:0,height:0,marginwidth:0,marginheight:0}).on(d),a.browser.throwsMixedContentWarningWhenIframeSrcIsEmpty()&&(d.src="javascript:'<html></html>'"),d.onload=function(){d.onreadystatechange=d.onload=null,c._onLoadIframe(d)},d.onreadystatechange=function(){/loaded|complete/.test(d.readyState)&&(d.onreadystatechange=d.onload=null,c._onLoadIframe(d))},d},_onLoadIframe:function(f){var g,h,i,j,k,l,m;if(a.dom.contains(b.documentElement,f)){if(g=this,h=f.contentWindow,i=f.contentWindow.document,j=b.characterSet||b.charset||"utf-8",k=this._getHtml({charset:j,stylesheets:this.config.stylesheets}),i.open("text/html","replace"),i.write(k),i.close(),this.getWindow=function(){return f.contentWindow},this.getDocument=function(){return f.contentWindow.document},h.onerror=function(a,b,c){throw Error("wysihtml5.Sandbox: "+a,b,c)},!a.browser.supportsSandboxedIframes()){for(l=0,m=c.length;m>l;l++)this._unset(h,c[l]);for(l=0,m=d.length;m>l;l++)this._unset(h,d[l],a.EMPTY_FUNCTION);for(l=0,m=e.length;m>l;l++)this._unset(i,e[l]);this._unset(i,"cookie","",!0)}this.loaded=!0,setTimeout(function(){g.callback(g)},0)}},_getHtml:function(b){var c,d=b.stylesheets,e="",f=0;if(d="string"==typeof d?[d]:d,d)for(c=d.length;c>f;f++)e+='<link rel="stylesheet" href="'+d[f]+'">';return b.stylesheets=e,a.lang.string('<!DOCTYPE html><html><head><meta charset="#{charset}">#{stylesheets}</head><body></body></html>').interpolate(b)},_unset:function(b,c,d,e){try{b[c]=d}catch(f){}try{b.__defineGetter__(c,function(){return d})}catch(f){}if(e)try{b.__defineSetter__(c,function(){})}catch(f){}if(!a.browser.crashesWhenDefineProperty(c))try{var g={get:function(){return d}};e&&(g.set=function(){}),Object.defineProperty(b,c,g)}catch(f){}}})}(wysihtml5),function(a){var b=document;a.dom.ContentEditableArea=Base.extend({getContentEditable:function(){return this.element},getWindow:function(){return this.element.ownerDocument.defaultView},getDocument:function(){return this.element.ownerDocument},constructor:function(b,c,d){this.callback=b||a.EMPTY_FUNCTION,this.config=a.lang.object({}).merge(c).get(),this.element=d?this._bindElement(d):this._createElement()},_createElement:function(){var a=b.createElement("div");return a.className="wysihtml5-sandbox",this._loadElement(a),a},_bindElement:function(a){return a.className=a.className&&""!=a.className?a.className+" wysihtml5-sandbox":"wysihtml5-sandbox",this._loadElement(a,!0),a},_loadElement:function(a,b){var c,d=this;b||(c=this._getHtml(),a.innerHTML=c),this.getWindow=function(){return a.ownerDocument.defaultView},this.getDocument=function(){return a.ownerDocument},this.loaded=!0,setTimeout(function(){d.callback(d)},0)},_getHtml:function(){return""}})}(wysihtml5),function(){var a={className:"class"};wysihtml5.dom.setAttributes=function(b){return{on:function(c){for(var d in b)c.setAttribute(a[d]||d,b[d])}}}}(),wysihtml5.dom.setStyles=function(a){return{on:function(b){var c,d=b.style;if("string"==typeof a)return d.cssText+=";"+a,void 0;for(c in a)"float"===c?(d.cssFloat=a[c],d.styleFloat=a[c]):d[c]=a[c]}}},function(a){a.simulatePlaceholder=function(b,c,d){var e="placeholder",f=function(){var b=c.element.offsetWidth>0&&c.element.offsetHeight>0;c.hasPlaceholderSet()&&(c.clear(),c.element.focus(),b&&setTimeout(function(){var a=c.selection.getSelection();a.focusNode&&a.anchorNode||c.selection.selectNode(c.element.firstChild||c.element)},0)),c.placeholderSet=!1,a.removeClass(c.element,e)},g=function(){c.isEmpty()&&(c.placeholderSet=!0,c.setValue(d),a.addClass(c.element,e))};b.on("set_placeholder",g).on("unset_placeholder",f).on("focus:composer",f).on("paste:composer",f).on("blur:composer",g),g()}}(wysihtml5.dom),function(a){var b=document.documentElement;"textContent"in b?(a.setTextContent=function(a,b){a.textContent=b},a.getTextContent=function(a){return a.textContent}):"innerText"in b?(a.setTextContent=function(a,b){a.innerText=b},a.getTextContent=function(a){return a.innerText}):(a.setTextContent=function(a,b){a.nodeValue=b},a.getTextContent=function(a){return a.nodeValue})}(wysihtml5.dom),wysihtml5.dom.getAttribute=function(a,b){var c,d,e,f=!wysihtml5.browser.supportsGetAttributeCorrectly();return b=b.toLowerCase(),c=a.nodeName,"IMG"==c&&"src"==b&&wysihtml5.dom.isLoadedImage(a)===!0?a.src:f&&"outerHTML"in a?(d=a.outerHTML.toLowerCase(),e=-1!=d.indexOf(" "+b+"="),e?a.getAttribute(b):null):a.getAttribute(b)},wysihtml5.dom.getAttributes=function(a){var b,c=!wysihtml5.browser.supportsGetAttributeCorrectly(),d=a.nodeName,e=[];for(b in a.attributes)(a.attributes.hasOwnProperty&&a.attributes.hasOwnProperty(b)||!a.attributes.hasOwnProperty&&Object.prototype.hasOwnProperty.call(a.attributes,b))&&a.attributes[b].specified&&("IMG"==d&&"src"==a.attributes[b].name.toLowerCase()&&wysihtml5.dom.isLoadedImage(a)===!0?e.src=a.src:wysihtml5.lang.array(["rowspan","colspan"]).contains(a.attributes[b].name.toLowerCase())&&c?1!==a.attributes[b].value&&(e[a.attributes[b].name]=a.attributes[b].value):e[a.attributes[b].name]=a.attributes[b].value);return e},wysihtml5.dom.isLoadedImage=function(a){try{return a.complete&&!a.mozMatchesSelector(":-moz-broken")}catch(b){if(a.complete&&"complete"===a.readyState)return!0}},function(a){function b(a,b){var c,d,e,f,g=[];for(d=0,e=a.length;e>d;d++)if(c=a[d].querySelectorAll(b),c)for(f=c.length;f--;g.unshift(c[f]));return g}function d(a){a.parentNode.removeChild(a)}function e(a,b){a.parentNode.insertBefore(b,a.nextSibling)}function f(a,b){for(var c=a.nextSibling;1!=c.nodeType;)if(c=c.nextSibling,!b||b==c.tagName.toLowerCase())return c;return null}var g=a.dom,h=function(a){this.el=a,this.isColspan=!1,this.isRowspan=!1,this.firstCol=!0,this.lastCol=!0,this.firstRow=!0,this.lastRow=!0,this.isReal=!0,this.spanCollection=[],this.modified=!1},i=function(a,b){a?(this.cell=a,this.table=g.getParentElement(a,{nodeName:["TABLE"]})):b&&(this.table=b,this.cell=this.table.querySelectorAll("th, td")[0])};i.prototype={addSpannedCellToMap:function(a,b,c,d,e,f){var g,i,j=[],k=c+(f?parseInt(f,10)-1:0),l=d+(e?parseInt(e,10)-1:0);for(g=c;k>=g;g++)for(void 0===b[g]&&(b[g]=[]),i=d;l>=i;i++)b[g][i]=new h(a),b[g][i].isColspan=e&&parseInt(e,10)>1,b[g][i].isRowspan=f&&parseInt(f,10)>1,b[g][i].firstCol=i==d,b[g][i].lastCol=i==l,b[g][i].firstRow=g==c,b[g][i].lastRow=g==k,b[g][i].isReal=i==d&&g==c,b[g][i].spanCollection=j,j.push(b[g][i])},setCellAsModified:function(a){if(a.modified=!0,a.spanCollection.length>0)for(var b=0,c=a.spanCollection.length;c>b;b++)a.spanCollection[b].modified=!0},setTableMap:function(){var a,b,c,d,e,f,i,j,k=[],l=this.getTableRows();for(a=0;a<l.length;a++)for(b=l[a],c=this.getRowCells(b),f=0,void 0===k[a]&&(k[a]=[]),d=0;d<c.length;d++){for(e=c[d];void 0!==k[a][f];)f++;i=g.getAttribute(e,"colspan"),j=g.getAttribute(e,"rowspan"),i||j?(this.addSpannedCellToMap(e,k,a,f,i,j),f+=i?parseInt(i,10):1):(k[a][f]=new h(e),f++)}return this.map=k,k},getRowCells:function(c){var d=this.table.querySelectorAll("table"),e=d?b(d,"th, td"):[],f=c.querySelectorAll("th, td"),g=e.length>0?a.lang.array(f).without(e):f;return g},getTableRows:function(){var c=this.table.querySelectorAll("table"),d=c?b(c,"tr"):[],e=this.table.querySelectorAll("tr"),f=d.length>0?a.lang.array(e).without(d):e;return f},getMapIndex:function(a){var b,c,d=this.map.length,e=this.map&&this.map[0]?this.map[0].length:0;for(b=0;d>b;b++)for(c=0;e>c;c++)if(this.map[b][c].el===a)return{row:b,col:c};return!1},getElementAtIndex:function(a){return this.setTableMap(),this.map[a.row]&&this.map[a.row][a.col]&&this.map[a.row][a.col].el?this.map[a.row][a.col].el:null},getMapElsTo:function(a){var b,c,d,e,f,g,h=[];if(this.setTableMap(),this.idx_start=this.getMapIndex(this.cell),this.idx_end=this.getMapIndex(a),(this.idx_start.row>this.idx_end.row||this.idx_start.row==this.idx_end.row&&this.idx_start.col>this.idx_end.col)&&(b=this.idx_start,this.idx_start=this.idx_end,this.idx_end=b),this.idx_start.col>this.idx_end.col&&(c=this.idx_start.col,this.idx_start.col=this.idx_end.col,this.idx_end.col=c),null!=this.idx_start&&null!=this.idx_end)for(d=this.idx_start.row,e=this.idx_end.row;e>=d;d++)for(f=this.idx_start.col,g=this.idx_end.col;g>=f;f++)h.push(this.map[d][f].el);return h},orderSelectionEnds:function(a){var b,c;return this.setTableMap(),this.idx_start=this.getMapIndex(this.cell),this.idx_end=this.getMapIndex(a),(this.idx_start.row>this.idx_end.row||this.idx_start.row==this.idx_end.row&&this.idx_start.col>this.idx_end.col)&&(b=this.idx_start,this.idx_start=this.idx_end,this.idx_end=b),this.idx_start.col>this.idx_end.col&&(c=this.idx_start.col,this.idx_start.col=this.idx_end.col,this.idx_end.col=c),{start:this.map[this.idx_start.row][this.idx_start.col].el,end:this.map[this.idx_end.row][this.idx_end.col].el}},createCells:function(a,b,c){var d,e,f,g=this.table.ownerDocument,h=g.createDocumentFragment();for(e=0;b>e;e++){if(d=g.createElement(a),c)for(f in c)c.hasOwnProperty(f)&&d.setAttribute(f,c[f]);d.appendChild(document.createTextNode(" ")),h.appendChild(d)}return h},correctColIndexForUnreals:function(a,b){var c,d,e=this.map[b],f=-1;for(c=0,d=a;a>c;c++)e[c].isReal&&f++;return f},getLastNewCellOnRow:function(a,b){var c,d,e,f,g=this.getRowCells(a);for(e=0,f=g.length;f>e;e++)if(c=g[e],d=this.getMapIndex(c),d===!1||void 0!==b&&d.row!=b)return c;return null},removeEmptyTable:function(){var a=this.table.querySelectorAll("td, th");return a&&0!=a.length?!1:(d(this.table),!0)},splitRowToCells:function(a){var b,c,d;a.isColspan&&(b=parseInt(g.getAttribute(a.el,"colspan")||1,10),c=a.el.tagName.toLowerCase(),b>1&&(d=this.createCells(c,b-1),e(a.el,d)),a.el.removeAttribute("colspan"))},getRealRowEl:function(a,b){var c,d,e=null,f=null;for(b=b||this.idx,c=0,d=this.map[b.row].length;d>c;c++)if(f=this.map[b.row][c],f.isReal&&(e=g.getParentElement(f.el,{nodeName:["TR"]}),e))return e;return null===e&&a&&(e=g.getParentElement(this.map[b.row][b.col].el,{nodeName:["TR"]})||null),e},injectRowAt:function(a,b,c,d,f){var h,i,j=this.getRealRowEl(!1,{row:a,col:b}),k=this.createCells(d,c);j?(h=this.correctColIndexForUnreals(b,a),h>=0?e(this.getRowCells(j)[h],k):j.insertBefore(k,j.firstChild)):(i=this.table.ownerDocument.createElement("tr"),i.appendChild(k),e(g.getParentElement(f.el,{nodeName:["TR"]}),i))},canMerge:function(a){var b,c,d,e,f,g;for(this.to=a,this.setTableMap(),this.idx_start=this.getMapIndex(this.cell),this.idx_end=this.getMapIndex(this.to),(this.idx_start.row>this.idx_end.row||this.idx_start.row==this.idx_end.row&&this.idx_start.col>this.idx_end.col)&&(b=this.idx_start,this.idx_start=this.idx_end,this.idx_end=b),this.idx_start.col>this.idx_end.col&&(c=this.idx_start.col,this.idx_start.col=this.idx_end.col,this.idx_end.col=c),d=this.idx_start.row,e=this.idx_end.row;e>=d;d++)for(f=this.idx_start.col,g=this.idx_end.col;g>=f;f++)if(this.map[d][f].isColspan||this.map[d][f].isRowspan)return!1;return!0},decreaseCellSpan:function(a,b){var c=parseInt(g.getAttribute(a.el,b),10)-1;c>=1?a.el.setAttribute(b,c):(a.el.removeAttribute(b),"colspan"==b&&(a.isColspan=!1),"rowspan"==b&&(a.isRowspan=!1),a.firstCol=!0,a.lastCol=!0,a.firstRow=!0,a.lastRow=!0,a.isReal=!0)},removeSurplusLines:function(){var a,b,c,e,f,h,i,j;if(this.setTableMap(),this.map){for(c=0,e=this.map.length;e>c;c++){for(a=this.map[c],i=!0,f=0,h=a.length;h>f;f++)if(b=a[f],!(g.getAttribute(b.el,"rowspan")&&parseInt(g.getAttribute(b.el,"rowspan"),10)>1&&b.firstRow!==!0)){i=!1;break}if(i)for(f=0;h>f;f++)this.decreaseCellSpan(a[f],"rowspan")}for(j=this.getTableRows(),c=0,e=j.length;e>c;c++)a=j[c],0==a.childNodes.length&&/^\s*$/.test(a.textContent||a.innerText)&&d(a)}},fillMissingCells:function(){var a,b,c,d=0,f=0,g=null;if(this.setTableMap(),this.map){for(d=this.map.length,a=0;d>a;a++)this.map[a].length>f&&(f=this.map[a].length);for(b=0;d>b;b++)for(c=0;f>c;c++)this.map[b]&&!this.map[b][c]&&c>0&&(this.map[b][c]=new h(this.createCells("td",1)),g=this.map[b][c-1],g&&g.el&&g.el.parent&&e(this.map[b][c-1].el,this.map[b][c].el))}},rectify:function(){return this.removeEmptyTable()?!1:(this.removeSurplusLines(),this.fillMissingCells(),!0)},unmerge:function(){var a,b,c,d,e,f;if(this.rectify()&&(this.setTableMap(),this.idx=this.getMapIndex(this.cell),this.idx)){if(a=this.map[this.idx.row][this.idx.col],b=g.getAttribute(a.el,"colspan")?parseInt(g.getAttribute(a.el,"colspan"),10):1,c=a.el.tagName.toLowerCase(),a.isRowspan){if(d=parseInt(g.getAttribute(a.el,"rowspan"),10),d>1)for(e=1,f=d-1;f>=e;e++)this.injectRowAt(this.idx.row+e,this.idx.col,b,c,a);a.el.removeAttribute("rowspan")}this.splitRowToCells(a)}},merge:function(a){var b,c,e,f,g,h;if(this.rectify())if(this.canMerge(a)){for(b=this.idx_end.row-this.idx_start.row+1,c=this.idx_end.col-this.idx_start.col+1,e=this.idx_start.row,f=this.idx_end.row;f>=e;e++)for(g=this.idx_start.col,h=this.idx_end.col;h>=g;g++)e==this.idx_start.row&&g==this.idx_start.col?(b>1&&this.map[e][g].el.setAttribute("rowspan",b),c>1&&this.map[e][g].el.setAttribute("colspan",c)):(/^\s*<br\/?>\s*$/.test(this.map[e][g].el.innerHTML.toLowerCase())||(this.map[this.idx_start.row][this.idx_start.col].el.innerHTML+=" "+this.map[e][g].el.innerHTML),d(this.map[e][g].el));this.rectify()}else window.console&&void 0},collapseCellToNextRow:function(a){var b,c,d,f=this.getMapIndex(a.el),h=f.row+1,i={row:h,col:f.col};h<this.map.length&&(b=this.getRealRowEl(!1,i),null!==b&&(c=this.correctColIndexForUnreals(i.col,i.row),c>=0?e(this.getRowCells(b)[c],a.el):(d=this.getLastNewCellOnRow(b,h),null!==d?e(d,a.el):b.insertBefore(a.el,b.firstChild)),parseInt(g.getAttribute(a.el,"rowspan"),10)>2?a.el.setAttribute("rowspan",parseInt(g.getAttribute(a.el,"rowspan"),10)-1):a.el.removeAttribute("rowspan")))},removeRowCell:function(a){a.isReal?a.isRowspan?this.collapseCellToNextRow(a):d(a.el):parseInt(g.getAttribute(a.el,"rowspan"),10)>2?a.el.setAttribute("rowspan",parseInt(g.getAttribute(a.el,"rowspan"),10)-1):a.el.removeAttribute("rowspan")},getRowElementsByCell:function(){var a,b,c,d=[];if(this.setTableMap(),this.idx=this.getMapIndex(this.cell),this.idx!==!1)for(a=this.map[this.idx.row],b=0,c=a.length;c>b;b++)a[b].isReal&&d.push(a[b].el);return d},getColumnElementsByCell:function(){var a,b,c=[];if(this.setTableMap(),this.idx=this.getMapIndex(this.cell),this.idx!==!1)for(a=0,b=this.map.length;b>a;a++)this.map[a][this.idx.col]&&this.map[a][this.idx.col].isReal&&c.push(this.map[a][this.idx.col].el);return c},removeRow:function(){var a,b,c,e=g.getParentElement(this.cell,{nodeName:["TR"]});if(e){if(this.setTableMap(),this.idx=this.getMapIndex(this.cell),this.idx!==!1)for(a=this.map[this.idx.row],b=0,c=a.length;c>b;b++)a[b].modified||(this.setCellAsModified(a[b]),this.removeRowCell(a[b]));d(e)}},removeColCell:function(a){a.isColspan?parseInt(g.getAttribute(a.el,"colspan"),10)>2?a.el.setAttribute("colspan",parseInt(g.getAttribute(a.el,"colspan"),10)-1):a.el.removeAttribute("colspan"):a.isReal&&d(a.el)},removeColumn:function(){if(this.setTableMap(),this.idx=this.getMapIndex(this.cell),this.idx!==!1)for(var a=0,b=this.map.length;b>a;a++)this.map[a][this.idx.col].modified||(this.setCellAsModified(this.map[a][this.idx.col]),this.removeColCell(this.map[a][this.idx.col]))},remove:function(a){if(this.rectify()){switch(a){case"row":this.removeRow();break;case"column":this.removeColumn()}this.rectify()}},addRow:function(a){var b,c,d,f,h,i=this.table.ownerDocument;if(this.setTableMap(),this.idx=this.getMapIndex(this.cell),"below"==a&&g.getAttribute(this.cell,"rowspan")&&(this.idx.row=this.idx.row+parseInt(g.getAttribute(this.cell,"rowspan"),10)-1),this.idx!==!1){for(b=this.map[this.idx.row],c=i.createElement("tr"),d=0,f=b.length;f>d;d++)b[d].modified||(this.setCellAsModified(b[d]),this.addRowCell(b[d],c,a));switch(a){case"below":e(this.getRealRowEl(!0),c);break;case"above":h=g.getParentElement(this.map[this.idx.row][this.idx.col].el,{nodeName:["TR"]}),h&&h.parentNode.insertBefore(c,h)}}},addRowCell:function(a,b,d){var e=a.isColspan?{colspan:g.getAttribute(a.el,"colspan")}:null;a.isReal?"above"!=d&&a.isRowspan?a.el.setAttribute("rowspan",parseInt(g.getAttribute(a.el,"rowspan"),10)+1):b.appendChild(this.createCells("td",1,e)):"above"!=d&&a.isRowspan&&a.lastRow?b.appendChild(this.createCells("td",1,e)):c.isRowspan&&a.el.attr("rowspan",parseInt(g.getAttribute(a.el,"rowspan"),10)+1)},add:function(a){this.rectify()&&(("below"==a||"above"==a)&&this.addRow(a),("before"==a||"after"==a)&&this.addColumn(a))},addColCell:function(a,b,d){var f,h=a.el.tagName.toLowerCase();switch(d){case"before":f=!a.isColspan||a.firstCol;break;case"after":f=!a.isColspan||a.lastCol||a.isColspan&&c.el==this.cell}if(f){switch(d){case"before":a.el.parentNode.insertBefore(this.createCells(h,1),a.el);break;case"after":e(a.el,this.createCells(h,1))}a.isRowspan&&this.handleCellAddWithRowspan(a,b+1,d)}else a.el.setAttribute("colspan",parseInt(g.getAttribute(a.el,"colspan"),10)+1)},addColumn:function(a){var b,c,d,e;if(this.setTableMap(),this.idx=this.getMapIndex(this.cell),"after"==a&&g.getAttribute(this.cell,"colspan")&&(this.idx.col=this.idx.col+parseInt(g.getAttribute(this.cell,"colspan"),10)-1),this.idx!==!1)for(d=0,e=this.map.length;e>d;d++)b=this.map[d],b[this.idx.col]&&(c=b[this.idx.col],c.modified||(this.setCellAsModified(c),this.addColCell(c,d,a)))},handleCellAddWithRowspan:function(a,b,c){var d,h,i,j,k=parseInt(g.getAttribute(this.cell,"rowspan"),10)-1,l=g.getParentElement(a.el,{nodeName:["TR"]}),m=a.el.tagName.toLowerCase(),n=this.table.ownerDocument;for(j=0;k>j;j++)if(d=this.correctColIndexForUnreals(this.idx.col,b+j),l=f(l,"tr"),l)if(d>0)switch(c){case"before":h=this.getRowCells(l),d>0&&this.map[b+j][this.idx.col].el!=h[d]&&d==h.length-1?e(h[d],this.createCells(m,1)):h[d].parentNode.insertBefore(this.createCells(m,1),h[d]);
  break;case"after":e(this.getRowCells(l)[d],this.createCells(m,1))}else l.insertBefore(this.createCells(m,1),l.firstChild);else i=n.createElement("tr"),i.appendChild(this.createCells(m,1)),this.table.appendChild(i)}},g.table={getCellsBetween:function(a,b){var c=new i(a);return c.getMapElsTo(b)},addCells:function(a,b){var c=new i(a);c.add(b)},removeCells:function(a,b){var c=new i(a);c.remove(b)},mergeCellsBetween:function(a,b){var c=new i(a);c.merge(b)},unmergeCell:function(a){var b=new i(a);b.unmerge()},orderSelectionEnds:function(a,b){var c=new i(a);return c.orderSelectionEnds(b)},indexOf:function(a){var b=new i(a);return b.setTableMap(),b.getMapIndex(a)},findCell:function(a,b){var c=new i(null,a);return c.getElementAtIndex(b)},findRowByCell:function(a){var b=new i(a);return b.getRowElementsByCell()},findColumnByCell:function(a){var b=new i(a);return b.getColumnElementsByCell()},canMerge:function(a,b){var c=new i(a);return c.canMerge(b)}}}(wysihtml5),wysihtml5.dom.query=function(a,b){var c,d,e,f,g=[];for(a.nodeType&&(a=[a]),d=0,e=a.length;e>d;d++)if(c=a[d].querySelectorAll(b),c)for(f=c.length;f--;g.unshift(c[f]));return g},wysihtml5.dom.compareDocumentPosition=function(){var a=document.documentElement;return a.compareDocumentPosition?function(a,b){return a.compareDocumentPosition(b)}:function(a,b){var c,d,e,f,g,h,i,j,k;if(c=9===a.nodeType?a:a.ownerDocument,d=9===b.nodeType?b:b.ownerDocument,a===b)return 0;if(a===b.ownerDocument)return 20;if(a.ownerDocument===b)return 10;if(c!==d)return 1;if(2===a.nodeType&&a.childNodes&&-1!==wysihtml5.lang.array(a.childNodes).indexOf(b))return 20;if(2===b.nodeType&&b.childNodes&&-1!==wysihtml5.lang.array(b.childNodes).indexOf(a))return 10;for(e=a,f=[],g=null;e;){if(e==b)return 10;f.push(e),e=e.parentNode}for(e=b,g=null;e;){if(e==a)return 20;if(h=wysihtml5.lang.array(f).indexOf(e),-1!==h)return i=f[h],j=wysihtml5.lang.array(i.childNodes).indexOf(f[h-1]),k=wysihtml5.lang.array(i.childNodes).indexOf(g),j>k?2:4;g=e,e=e.parentNode}return 1}}(),wysihtml5.dom.unwrap=function(a){if(a.parentNode){for(;a.lastChild;)wysihtml5.dom.insert(a.lastChild).after(a);a.parentNode.removeChild(a)}},wysihtml5.dom.getPastedHtml=function(a){var b;return a.clipboardData&&(wysihtml5.lang.array(a.clipboardData.types).contains("text/html")?b=a.clipboardData.getData("text/html"):wysihtml5.lang.array(a.clipboardData.types).contains("text/plain")&&(b=wysihtml5.lang.string(a.clipboardData.getData("text/plain")).escapeHTML(!0,!0))),b},wysihtml5.dom.getPastedHtmlWithDiv=function(a,b){var c=a.selection.getBookmark(),d=a.element.ownerDocument,e=d.createElement("DIV");d.body.appendChild(e),e.style.width="1px",e.style.height="1px",e.style.overflow="hidden",e.setAttribute("contenteditable","true"),e.focus(),setTimeout(function(){a.selection.setBookmark(c),b(e.innerHTML),e.parentNode.removeChild(e)},0)},wysihtml5.quirks.cleanPastedHTML=function(){var a=function(a){var b=wysihtml5.lang.string(a).trim(),c=b.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");return RegExp("^((?!^"+c+"$).)*$","i")},b=function(b,c){var d,e,f=wysihtml5.lang.object(b).clone(!0);for(d in f.tags)if(f.tags.hasOwnProperty(d)&&f.tags[d].keep_styles)for(e in f.tags[d].keep_styles)f.tags[d].keep_styles.hasOwnProperty(e)&&c[e]&&(f.tags[d].keep_styles[e]=a(c[e]));return f},c=function(a,b){var c,d,e;if(!a)return null;for(d=0,e=a.length;e>d;d++)if(a[d].condition||(c=a[d].set),a[d].condition&&a[d].condition.test(b))return a[d].set;return c};return function(a,d){var e,f={color:wysihtml5.dom.getStyle("color").from(d.referenceNode),fontSize:wysihtml5.dom.getStyle("font-size").from(d.referenceNode)},g=b(c(d.rules,a)||{},f);return e=wysihtml5.dom.parse(a,{rules:g,cleanUp:!0,context:d.referenceNode.ownerDocument,uneditableClass:d.uneditableClass,clearInternals:!0,unjoinNbsps:!0}),e}}(),wysihtml5.quirks.ensureProperClearing=function(){var a=function(){var a=this;setTimeout(function(){var b=a.innerHTML.toLowerCase();("<p>&nbsp;</p>"==b||"<p>&nbsp;</p><p>&nbsp;</p>"==b)&&(a.innerHTML="")},0)};return function(b){wysihtml5.dom.observe(b.element,["cut","keydown"],a)}}(),function(a){var b="%7E";a.quirks.getCorrectInnerHTML=function(c){var d,e,f,g,h,i=c.innerHTML;if(-1===i.indexOf(b))return i;for(d=c.querySelectorAll("[href*='~'], [src*='~']"),h=0,g=d.length;g>h;h++)e=d[h].href||d[h].src,f=a.lang.string(e).replace("~").by(b),i=a.lang.string(i).replace(f).by(e);return i}}(wysihtml5),function(a){var b="wysihtml5-quirks-redraw";a.quirks.redraw=function(c){a.dom.addClass(c,b),a.dom.removeClass(c,b);try{var d=c.ownerDocument;d.execCommand("italic",!1,null),d.execCommand("italic",!1,null)}catch(e){}}}(wysihtml5),wysihtml5.quirks.tableCellsSelection=function(a,b){function c(){return k.observe(a,"mousedown",function(a){var b=wysihtml5.dom.getParentElement(a.target,{nodeName:["TD","TH"]});b&&d(b)}),l}function d(c){l.start=c,l.end=c,l.cells=[c],l.table=k.getParentElement(l.start,{nodeName:["TABLE"]}),l.table&&(e(),k.addClass(c,m),n=k.observe(a,"mousemove",g),o=k.observe(a,"mouseup",h),b.fire("tableselectstart").fire("tableselectstart:composer"))}function e(){var b,c;if(a&&(b=a.querySelectorAll("."+m),b.length>0))for(c=0;c<b.length;c++)k.removeClass(b[c],m)}function f(a){for(var b=0;b<a.length;b++)k.addClass(a[b],m)}function g(a){var c,d=null,g=k.getParentElement(a.target,{nodeName:["TD","TH"]});g&&l.table&&l.start&&(d=k.getParentElement(g,{nodeName:["TABLE"]}),d&&d===l.table&&(e(),c=l.end,l.end=g,l.cells=k.table.getCellsBetween(l.start,g),l.cells.length>1&&b.composer.selection.deselect(),f(l.cells),l.end!==c&&b.fire("tableselectchange").fire("tableselectchange:composer")))}function h(){n.stop(),o.stop(),b.fire("tableselect").fire("tableselect:composer"),setTimeout(function(){i()},0)}function i(){var c=k.observe(a.ownerDocument,"click",function(a){c.stop(),k.getParentElement(a.target,{nodeName:["TABLE"]})!=l.table&&(e(),l.table=null,l.start=null,l.end=null,b.fire("tableunselect").fire("tableunselect:composer"))})}function j(a,c){l.start=a,l.end=c,l.table=k.getParentElement(l.start,{nodeName:["TABLE"]}),selectedCells=k.table.getCellsBetween(l.start,l.end),f(selectedCells),i(),b.fire("tableselect").fire("tableselect:composer")}var k=wysihtml5.dom,l={table:null,start:null,end:null,cells:null,select:j},m="wysiwyg-tmp-selected-cell",n=null,o=null;return c()},function(a){var b=/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*([\d\.]+)\s*\)/i,c=/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/i,d=/^#([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])/i,e=/^#([0-9a-f])([0-9a-f])([0-9a-f])/i,f=function(a){return RegExp("(^|\\s|;)"+a+"\\s*:\\s*[^;$]+","gi")};a.quirks.styleParser={parseColor:function(g,h){var i,j,k,l=f(h),m=g.match(l),n=10;if(m){for(k=m.length;k--;)m[k]=a.lang.string(m[k].split(":")[1]).trim();if(i=m[m.length-1],b.test(i))j=i.match(b);else if(c.test(i))j=i.match(c);else if(d.test(i))j=i.match(d),n=16;else if(e.test(i))return j=i.match(e),j.shift(),j.push(1),a.lang.array(j).map(function(a,b){return 3>b?16*parseInt(a,16)+parseInt(a,16):parseFloat(a)});if(j)return j.shift(),j[3]||j.push(1),a.lang.array(j).map(function(a,b){return 3>b?parseInt(a,n):parseFloat(a)})}return!1},unparseColor:function(a,b){if(b){if("hex"==b)return a[0].toString(16).toUpperCase()+a[1].toString(16).toUpperCase()+a[2].toString(16).toUpperCase();if("hash"==b)return"#"+a[0].toString(16).toUpperCase()+a[1].toString(16).toUpperCase()+a[2].toString(16).toUpperCase();if("rgb"==b)return"rgb("+a[0]+","+a[1]+","+a[2]+")";if("rgba"==b)return"rgba("+a[0]+","+a[1]+","+a[2]+","+a[3]+")";if("csv"==b)return a[0]+","+a[1]+","+a[2]+","+a[3]}return a[3]&&1!==a[3]?"rgba("+a[0]+","+a[1]+","+a[2]+","+a[3]+")":"rgb("+a[0]+","+a[1]+","+a[2]+")"},parseFontSize:function(b){var c=b.match(f("font-size"));return c?a.lang.string(c[c.length-1].split(":")[1]).trim():!1}}}(wysihtml5),function(a){function b(a){var b=0;if(a.parentNode)do b+=a.offsetTop||0,a=a.offsetParent;while(a);return b}function c(a,b){for(var c=0;b!==a;)if(c++,b=b.parentNode,!b)throw Error("not a descendant of ancestor!");return c}function d(a){if(!a.canSurroundContents())for(var b=a.commonAncestorContainer,d=c(b,a.startContainer),e=c(b,a.endContainer);!a.canSurroundContents();)d>e?(a.setStartBefore(a.startContainer),d=c(b,a.startContainer)):(a.setEndAfter(a.endContainer),e=c(b,a.endContainer))}var e=a.dom;a.Selection=Base.extend({constructor:function(a,b,c){window.rangy.init(),this.editor=a,this.composer=a.composer,this.doc=this.composer.doc,this.contain=b,this.unselectableClass=c||!1},getBookmark:function(){var a=this.getRange();return a&&d(a),a&&a.cloneRange()},setBookmark:function(a){a&&this.setSelection(a)},setBefore:function(a){var b=rangy.createRange(this.doc);return b.setStartBefore(a),b.setEndBefore(a),this.setSelection(b)},setAfter:function(a){var b=rangy.createRange(this.doc);return b.setStartAfter(a),b.setEndAfter(a),this.setSelection(b)},selectNode:function(b,c){var d=rangy.createRange(this.doc),f=b.nodeType===a.ELEMENT_NODE,g="canHaveHTML"in b?b.canHaveHTML:"IMG"!==b.nodeName,h=f?b.innerHTML:b.data,i=""===h||h===a.INVISIBLE_SPACE,j=e.getStyle("display").from(b),k="block"===j||"list-item"===j;if(i&&f&&g&&!c)try{b.innerHTML=a.INVISIBLE_SPACE}catch(l){}g?d.selectNodeContents(b):d.selectNode(b),g&&i&&f?d.collapse(k):g&&i&&(d.setStartAfter(b),d.setEndAfter(b)),this.setSelection(d)},getSelectedNode:function(a){var b,c;return a&&this.doc.selection&&"Control"===this.doc.selection.type&&(c=this.doc.selection.createRange(),c&&c.length)?c.item(0):(b=this.getSelection(this.doc),b.focusNode===b.anchorNode?b.focusNode:(c=this.getRange(this.doc),c?c.commonAncestorContainer:this.doc.body))},fixSelBorders:function(){var a=this.getRange();d(a),this.setSelection(a)},getSelectedOwnNodes:function(){var a,b,c=this.getOwnRanges(),d=[];for(a=0,b=c.length;b>a;a++)d.push(c[a].commonAncestorContainer||this.doc.body);return d},findNodesInSelection:function(b){var c,d,e,f=this.getOwnRanges(),g=[];for(d=0,e=f.length;e>d;d++)c=f[d].getNodes([1],function(c){return a.lang.array(b).contains(c.nodeName)}),g=g.concat(c);return g},containsUneditable:function(){var a,b,c=this.getOwnUneditables(),d=this.getSelection();for(a=0,b=c.length;b>a;a++)if(d.containsNode(c[a]))return!0;return!1},deleteContents:function(){var a,b=this.getOwnRanges();for(a=b.length;a--;)b[a].deleteContents();this.setSelection(b[0])},getPreviousNode:function(b,c){var d,e,f;return b||(d=this.getSelection(),b=d.anchorNode),b===this.contain?!1:(e=b.previousSibling,e===this.contain?!1:(e&&3!==e.nodeType&&1!==e.nodeType?e=this.getPreviousNode(e,c):e&&3===e.nodeType&&/^\s*$/.test(e.textContent)?e=this.getPreviousNode(e,c):c&&e&&1===e.nodeType&&!a.lang.array(["BR","HR","IMG"]).contains(e.nodeName)&&/^[\s]*$/.test(e.innerHTML)?e=this.getPreviousNode(e,c):e||b===this.contain||(f=b.parentNode,f!==this.contain&&(e=this.getPreviousNode(f,c))),e!==this.contain?e:!1))},getSelectionParentsByTag:function(){var b,c,d,e=this.getSelectedOwnNodes(),f=[];for(c=0,d=e.length;d>c;c++)b=e[c].nodeName&&"LI"===e[c].nodeName?e[c]:a.dom.getParentElement(e[c],{nodeName:["LI"]},!1,this.contain),b&&f.push(b);return f.length?f:null},getRangeToNodeEnd:function(){if(this.isCollapsed()){var a=this.getRange(),b=a.startContainer,c=a.startOffset,d=rangy.createRange(this.doc);return d.selectNodeContents(b),d.setStart(b,c),d}},caretIsLastInSelection:function(){var a=(rangy.createRange(this.doc),this.getSelection(),this.getRangeToNodeEnd().cloneContents()),b=a.textContent;return/^\s*$/.test(b)},caretIsFirstInSelection:function(){var b=rangy.createRange(this.doc),c=this.getSelection(),d=this.getRange(),e=d.startContainer;return e.nodeType===a.TEXT_NODE?this.isCollapsed()&&e.nodeType===a.TEXT_NODE&&/^\s*$/.test(e.data.substr(0,d.startOffset)):(b.selectNodeContents(this.getRange().commonAncestorContainer),b.collapse(!0),this.isCollapsed()&&(b.startContainer===c.anchorNode||b.endContainer===c.anchorNode)&&b.startOffset===c.anchorOffset)},caretIsInTheBeginnig:function(b){var c=this.getSelection(),d=c.anchorNode,e=c.anchorOffset;return b?0===e&&(d.nodeName&&d.nodeName===b.toUpperCase()||a.dom.getParentElement(d.parentNode,{nodeName:b},1)):0===e&&!this.getPreviousNode(d,!0)},caretIsBeforeUneditable:function(){var a,b,c,d,e=this.getSelection(),f=e.anchorNode,g=e.anchorOffset;if(0===g&&(a=this.getPreviousNode(f,!0),a))for(b=this.getOwnUneditables(),c=0,d=b.length;d>c;c++)if(a===b[c])return b[c];return!1},executeAndRestoreRangy:function(a){var b=this.doc.defaultView||this.doc.parentWindow,c=rangy.saveSelection(b);if(c)try{a()}catch(d){setTimeout(function(){throw d},0)}else a();rangy.restoreSelection(c)},executeAndRestore:function(b,c){var d,f,g,h,i,j,k,l,m,n=this.doc.body,o=c&&n.scrollTop,p=c&&n.scrollLeft,q="_wysihtml5-temp-placeholder",r='<span class="'+q+'">'+a.INVISIBLE_SPACE+"</span>",s=this.getRange(!0);if(!s)return b(n,n),void 0;s.collapsed||(k=s.cloneRange(),j=k.createContextualFragment(r),k.collapse(!1),k.insertNode(j),k.detach()),i=s.createContextualFragment(r),s.insertNode(i),j&&(d=this.contain.querySelectorAll("."+q),s.setStartBefore(d[0]),s.setEndAfter(d[d.length-1])),this.setSelection(s);try{b(s.startContainer,s.endContainer)}catch(t){setTimeout(function(){throw t},0)}if(d=this.contain.querySelectorAll("."+q),d&&d.length)for(l=rangy.createRange(this.doc),g=d[0].nextSibling,d.length>1&&(h=d[d.length-1].previousSibling),h&&g?(l.setStartBefore(g),l.setEndAfter(h)):(f=this.doc.createTextNode(a.INVISIBLE_SPACE),e.insert(f).after(d[0]),l.setStartBefore(f),l.setEndAfter(f)),this.setSelection(l),m=d.length;m--;)d[m].parentNode.removeChild(d[m]);else this.contain.focus();c&&(n.scrollTop=o,n.scrollLeft=p);try{d.parentNode.removeChild(d)}catch(u){}},set:function(a,b){var c=rangy.createRange(this.doc);c.setStart(a,b||0),this.setSelection(c)},insertHTML:function(a){var b,c=(rangy.createRange(this.doc),this.doc.createElement("DIV")),d=this.doc.createDocumentFragment();for(c.innerHTML=a,b=c.lastChild;c.firstChild;)d.appendChild(c.firstChild);this.insertNode(d),b&&this.setAfter(b)},insertNode:function(a){var b=this.getRange();b&&b.insertNode(a)},surround:function(a){var b,c,d=this.getOwnRanges(),e=[];if(0==d.length)return e;for(c=d.length;c--;){b=this.doc.createElement(a.nodeName),e.push(b),a.className&&(b.className=a.className),a.cssStyle&&b.setAttribute("style",a.cssStyle);try{d[c].surroundContents(b),this.selectNode(b)}catch(f){b.appendChild(d[c].extractContents()),d[c].insertNode(b)}}return e},deblockAndSurround:function(b){var c,d,e,f=this.doc.createElement("div"),g=rangy.createRange(this.doc);if(f.className=b.className,this.composer.commands.exec("formatBlock",b.nodeName,b.className),c=this.contain.querySelectorAll("."+b.className),c[0])for(c[0].parentNode.insertBefore(f,c[0]),g.setStartBefore(c[0]),g.setEndAfter(c[c.length-1]),d=g.extractContents();d.firstChild;)if(e=d.firstChild,1==e.nodeType&&a.dom.hasClass(e,b.className)){for(;e.firstChild;)f.appendChild(e.firstChild);"BR"!==e.nodeName&&f.appendChild(this.doc.createElement("br")),d.removeChild(e)}else f.appendChild(e);else f=null;return f},scrollIntoView:function(){var c,d=this.doc,e=5,f=d.documentElement.scrollHeight>d.documentElement.offsetHeight,g=d._wysihtml5ScrollIntoViewElement=d._wysihtml5ScrollIntoViewElement||function(){var b=d.createElement("span");return b.innerHTML=a.INVISIBLE_SPACE,b}();f&&(this.insertNode(g),c=b(g),g.parentNode.removeChild(g),c>=d.body.scrollTop+d.documentElement.offsetHeight-e&&(d.body.scrollTop=c))},selectLine:function(){a.browser.supportsSelectionModify()?this._selectLine_W3C():this.doc.selection&&this._selectLine_MSIE()},_selectLine_W3C:function(){var a=this.doc.defaultView,b=a.getSelection();b.modify("move","left","lineboundary"),b.modify("extend","right","lineboundary")},_selectLine_MSIE:function(){var a,b,c,d,e,f=this.doc.selection.createRange(),g=f.boundingTop,h=this.doc.body.scrollWidth;if(f.moveToPoint){for(0===g&&(c=this.doc.createElement("span"),this.insertNode(c),g=c.offsetTop,c.parentNode.removeChild(c)),g+=1,d=-10;h>d;d+=2)try{f.moveToPoint(d,g);break}catch(i){}for(a=g,b=this.doc.selection.createRange(),e=h;e>=0;e--)try{b.moveToPoint(e,a);break}catch(j){}f.setEndPoint("EndToEnd",b),f.select()}},getText:function(){var a=this.getSelection();return a?""+a:""},getNodes:function(a,b){var c=this.getRange();return c?c.getNodes([a],b):[]},fixRangeOverflow:function(a){var b,c;this.contain&&this.contain.firstChild&&a&&(b=a.compareNode(this.contain),2!==b?(1===b&&a.setStartBefore(this.contain.firstChild),0===b&&a.setEndAfter(this.contain.lastChild),3===b&&(a.setStartBefore(this.contain.firstChild),a.setEndAfter(this.contain.lastChild))):this._detectInlineRangeProblems(a)&&(c=a.endContainer.previousElementSibling,c&&a.setEnd(c,this._endOffsetForNode(c))))},_endOffsetForNode:function(a){var b=document.createRange();return b.selectNodeContents(a),b.endOffset},_detectInlineRangeProblems:function(a){var b=e.compareDocumentPosition(a.startContainer,a.endContainer);return 0==a.endOffset&&4&b},getRange:function(a){var b=this.getSelection(),c=b&&b.rangeCount&&b.getRangeAt(0);return a!==!0&&this.fixRangeOverflow(c),c},getOwnUneditables:function(){var b=e.query(this.contain,"."+this.unselectableClass),c=e.query(b,"."+this.unselectableClass);return a.lang.array(b).without(c)},getOwnRanges:function(){var a,b,c,d,e,f,g,h=[],i=this.getRange();if(i&&h.push(i),this.unselectableClass&&this.contain&&i&&(b=this.getOwnUneditables(),b.length>0))for(d=0,e=b.length;e>d;d++)for(a=[],f=0,g=h.length;g>f;f++){if(h[f])switch(h[f].compareNode(b[d])){case 2:break;case 3:c=h[f].cloneRange(),c.setEndBefore(b[d]),a.push(c),c=h[f].cloneRange(),c.setStartAfter(b[d]),a.push(c);break;default:a.push(h[f])}h=a}return h},getSelection:function(){return rangy.getSelection(this.doc.defaultView||this.doc.parentWindow)},setSelection:function(a){var b=this.doc.defaultView||this.doc.parentWindow,c=rangy.getSelection(b);return c.setSingleRange(a)},createRange:function(){return rangy.createRange(this.doc)},isCollapsed:function(){return this.getSelection().isCollapsed},getHtml:function(){return this.getSelection().toHtml()},isEndToEndInNode:function(b){var c=this.getRange(),d=c.commonAncestorContainer,e=c.startContainer,f=c.endContainer;if(d.nodeType===a.TEXT_NODE&&(d=d.parentNode),e.nodeType===a.TEXT_NODE&&!/^\s*$/.test(e.data.substr(c.startOffset)))return!1;if(f.nodeType===a.TEXT_NODE&&!/^\s*$/.test(f.data.substr(c.endOffset)))return!1;for(;e&&e!==d;){if(e.nodeType!==a.TEXT_NODE&&!a.dom.contains(d,e))return!1;if(a.dom.domNode(e).prev({ignoreBlankTexts:!0}))return!1;e=e.parentNode}for(;f&&f!==d;){if(f.nodeType!==a.TEXT_NODE&&!a.dom.contains(d,f))return!1;if(a.dom.domNode(f).next({ignoreBlankTexts:!0}))return!1;f=f.parentNode}return a.lang.array(b).contains(d.nodeName)?d:!1},deselect:function(){var a=this.getSelection();a&&a.removeAllRanges()}})}(wysihtml5),function(a,b){function c(a,b,c){if(!a.className)return!1;var d=a.className.match(c)||[];return d[d.length-1]===b}function d(a,b){if(!a.getAttribute||!a.getAttribute("style"))return!1;a.getAttribute("style").match(b);return a.getAttribute("style").match(b)?!0:!1}function e(a,b,c){a.getAttribute("style")?(h(a,c),a.getAttribute("style")&&!/^\s*$/.test(a.getAttribute("style"))?a.setAttribute("style",b+";"+a.getAttribute("style")):a.setAttribute("style",b)):a.setAttribute("style",b)}function f(a,b,c){a.className?(g(a,c),a.className+=" "+b):a.className=b}function g(a,b){a.className&&(a.className=a.className.replace(b,""))}function h(a,b){var c,d,e=[];if(a.getAttribute("style")){for(c=a.getAttribute("style").split(";"),d=c.length;d--;)c[d].match(b)||/^\s*$/.test(c[d])||e.push(c[d]);e.length?a.setAttribute("style",e.join(";")):a.removeAttribute("style")}}function i(a,b){var c,d,e,f=[],g=b.split(";"),h=a.getAttribute("style");if(h){for(h=h.replace(/\s/gi,"").toLowerCase(),f.push(RegExp("(^|\\s|;)"+b.replace(/\s/gi,"").replace(/([\(\)])/gi,"\\$1").toLowerCase().replace(";",";?").replace(/rgb\\\((\d+),(\d+),(\d+)\\\)/gi,"\\s?rgb\\($1,\\s?$2,\\s?$3\\)"),"gi")),c=g.length;c-->0;)/^\s*$/.test(g[c])||f.push(RegExp("(^|\\s|;)"+g[c].replace(/\s/gi,"").replace(/([\(\)])/gi,"\\$1").toLowerCase().replace(";",";?").replace(/rgb\\\((\d+),(\d+),(\d+)\\\)/gi,"\\s?rgb\\($1,\\s?$2,\\s?$3\\)"),"gi"));for(d=0,e=f.length;e>d;d++)if(h.match(f[d]))return f[d]}return!1}function j(c,d,e,f){return e?i(c,e):f?a.dom.hasClass(c,f):b.dom.arrayContains(d,c.tagName.toLowerCase())}function k(a,b,c,d){for(var e=a.length;e--;)if(!j(a[e],b,c,d))return!1;return a.length?!0:!1}function l(a,b,c){var d=i(a,b);return d?(h(a,d),"remove"):(e(a,b,c),"change")}function m(a,b){return a.className.replace(u," ")==b.className.replace(u," ")}function n(a){for(var b=a.parentNode;a.firstChild;)b.insertBefore(a.firstChild,a);b.removeChild(a)}function o(a,b){if(a.attributes.length!=b.attributes.length)return!1;for(var c,d,e,f=0,g=a.attributes.length;g>f;++f)if(c=a.attributes[f],e=c.name,"class"!=e){if(d=b.attributes.getNamedItem(e),c.specified!=d.specified)return!1;if(c.specified&&c.nodeValue!==d.nodeValue)return!1}return!0}function p(a,c){return b.dom.isCharacterDataNode(a)?0==c?!!a.previousSibling:c==a.length?!!a.nextSibling:!0:c>0&&c<a.childNodes.length}function q(a,c,d,e){var f,g;if(b.dom.isCharacterDataNode(c)&&(0==d?(d=b.dom.getNodeIndex(c),c=c.parentNode):d==c.length?(d=b.dom.getNodeIndex(c)+1,c=c.parentNode):f=b.dom.splitDataNode(c,d)),!(f||e&&c===e)){for(f=c.cloneNode(!1),f.id&&f.removeAttribute("id");g=c.childNodes[d];)f.appendChild(g);b.dom.insertAfter(f,c)}return c==a?f:q(a,f.parentNode,b.dom.getNodeIndex(f),e)}function r(b){this.isElementMerge=b.nodeType==a.ELEMENT_NODE,this.firstTextNode=this.isElementMerge?b.lastChild:b,this.textNodes=[this.firstTextNode]}function s(a,b,c,d,e,f,g){this.tagNames=a||[t],this.cssClass=b||(b===!1?!1:""),this.similarClassRegExp=c,this.cssStyle=e||"",this.similarStyleRegExp=f,this.normalize=d,this.applyToAnyTagName=!1,this.container=g}var t="span",u=/\s+/g;r.prototype={doMerge:function(){var a,b,c,d,e,f=[];for(d=0,e=this.textNodes.length;e>d;++d)a=this.textNodes[d],b=a.parentNode,f[d]=a.data,d&&(b.removeChild(a),b.hasChildNodes()||b.parentNode.removeChild(b));return this.firstTextNode.data=c=f.join(""),c},getLength:function(){for(var a=this.textNodes.length,b=0;a--;)b+=this.textNodes[a].length;return b},toString:function(){var a,b,c=[];for(a=0,b=this.textNodes.length;b>a;++a)c[a]="'"+this.textNodes[a].data+"'";return"[Merge("+c.join(",")+")]"}},s.prototype={getAncestorWithClass:function(d){for(var e;d;){if(e=this.cssClass?c(d,this.cssClass,this.similarClassRegExp):""!==this.cssStyle?!1:!0,d.nodeType==a.ELEMENT_NODE&&"false"!=d.getAttribute("contenteditable")&&b.dom.arrayContains(this.tagNames,d.tagName.toLowerCase())&&e)return d;d=d.parentNode}return!1},getAncestorWithStyle:function(c){for(var e;c;){if(e=this.cssStyle?d(c,this.similarStyleRegExp):!1,c.nodeType==a.ELEMENT_NODE&&"false"!=c.getAttribute("contenteditable")&&b.dom.arrayContains(this.tagNames,c.tagName.toLowerCase())&&e)return c;c=c.parentNode}return!1},getMatchingAncestor:function(a){var b=this.getAncestorWithClass(a),c=!1;return b?this.cssStyle&&(c="class"):(b=this.getAncestorWithStyle(a),b&&(c="style")),{element:b,type:c}},postApply:function(a,b){var c,d,e,f,g,h,i=a[0],j=a[a.length-1],k=[],l=i,m=j,n=0,o=j.length;for(f=0,g=a.length;g>f;++f)d=a[f],e=null,d&&d.parentNode&&(e=this.getAdjacentMergeableTextNode(d.parentNode,!1)),e?(c||(c=new r(e),k.push(c)),c.textNodes.push(d),d===i&&(l=c.firstTextNode,n=l.length),d===j&&(m=c.firstTextNode,o=c.getLength())):c=null;if(j&&j.parentNode&&(h=this.getAdjacentMergeableTextNode(j.parentNode,!0),h&&(c||(c=new r(j),k.push(c)),c.textNodes.push(h))),k.length){for(f=0,g=k.length;g>f;++f)k[f].doMerge();b.setStart(l,n),b.setEnd(m,o)}},getAdjacentMergeableTextNode:function(b,c){var d,e=b.nodeType==a.TEXT_NODE,f=e?b.parentNode:b,g=c?"nextSibling":"previousSibling";if(e){if(d=b[g],d&&d.nodeType==a.TEXT_NODE)return d}else if(d=f[g],d&&this.areElementsMergeable(b,d))return d[c?"firstChild":"lastChild"];return null},areElementsMergeable:function(a,c){return b.dom.arrayContains(this.tagNames,(a.tagName||"").toLowerCase())&&b.dom.arrayContains(this.tagNames,(c.tagName||"").toLowerCase())&&m(a,c)&&o(a,c)},createContainer:function(a){var b=a.createElement(this.tagNames[0]);return this.cssClass&&(b.className=this.cssClass),this.cssStyle&&b.setAttribute("style",this.cssStyle),b},applyToTextNode:function(a){var c,d=a.parentNode;1==d.childNodes.length&&b.dom.arrayContains(this.tagNames,d.tagName.toLowerCase())?(this.cssClass&&f(d,this.cssClass,this.similarClassRegExp),this.cssStyle&&e(d,this.cssStyle,this.similarStyleRegExp)):(c=this.createContainer(b.dom.getDocument(a)),a.parentNode.insertBefore(c,a),c.appendChild(a))},isRemovable:function(c){return b.dom.arrayContains(this.tagNames,c.tagName.toLowerCase())&&""===a.lang.string(c.className).trim()&&(!c.getAttribute("style")||""===a.lang.string(c.getAttribute("style")).trim())},undoToTextNode:function(a,b,c,d){var e,f=c?!1:!0,h=c||d,i=!1;b.containsNode(h)||(e=b.cloneRange(),e.selectNode(h),e.isPointInRange(b.endContainer,b.endOffset)&&p(b.endContainer,b.endOffset)&&(q(h,b.endContainer,b.endOffset,this.container),b.setEndAfter(h)),e.isPointInRange(b.startContainer,b.startOffset)&&p(b.startContainer,b.startOffset)&&(h=q(h,b.startContainer,b.startOffset,this.container))),!f&&this.similarClassRegExp&&g(h,this.similarClassRegExp),f&&this.similarStyleRegExp&&(i="change"===l(h,this.cssStyle,this.similarStyleRegExp)),this.isRemovable(h)&&!i&&n(h)},applyToRange:function(b){var c,d,e,f,g,h;for(d=b.length;d--;){if(c=b[d].getNodes([a.TEXT_NODE]),!c.length)try{return e=this.createContainer(b[d].endContainer.ownerDocument),b[d].surroundContents(e),this.selectNode(b[d],e),void 0}catch(i){}if(b[d].splitBoundaries(),c=b[d].getNodes([a.TEXT_NODE]),c.length){for(g=0,h=c.length;h>g;++g)f=c[g],this.getMatchingAncestor(f).element||this.applyToTextNode(f);b[d].setStart(c[0],0),f=c[c.length-1],b[d].setEnd(f,f.length),this.normalize&&this.postApply(c,b[d])}}},undoToRange:function(b){var c,d,e,f,g,h,i,j;for(f=b.length;f--;){for(c=b[f].getNodes([a.TEXT_NODE]),c.length?(b[f].splitBoundaries(),c=b[f].getNodes([a.TEXT_NODE])):(g=b[f].endContainer.ownerDocument,h=g.createTextNode(a.INVISIBLE_SPACE),b[f].insertNode(h),b[f].selectNode(h),c=[h]),i=0,j=c.length;j>i;++i)b[f].isValid()&&(d=c[i],e=this.getMatchingAncestor(d),"style"===e.type?this.undoToTextNode(d,b[f],!1,e.element):e.element&&this.undoToTextNode(d,b[f],e.element));1==j?this.selectNode(b[f],c[0]):(b[f].setStart(c[0],0),d=c[c.length-1],b[f].setEnd(d,d.length),this.normalize&&this.postApply(c,b[f]))}},selectNode:function(b,c){var d=c.nodeType===a.ELEMENT_NODE,e="canHaveHTML"in c?c.canHaveHTML:!0,f=d?c.innerHTML:c.data,g=""===f||f===a.INVISIBLE_SPACE;if(g&&d&&e)try{c.innerHTML=a.INVISIBLE_SPACE}catch(h){}b.selectNodeContents(c),g&&d?b.collapse(!1):g&&(b.setStartAfter(c),b.setEndAfter(c))},getTextSelectedByRange:function(a,b){var c,d,e=b.cloneRange();return e.selectNodeContents(a),c=e.intersection(b),d=c?""+c:"",e.detach(),d},isAppliedToRange:function(b){var c,d,e,f,g,h,i=[],j="full";for(e=b.length;e--;){if(d=b[e].getNodes([a.TEXT_NODE]),!d.length)return c=this.getMatchingAncestor(b[e].startContainer).element,c?{elements:[c],coverage:j}:!1;for(f=0,g=d.length;g>f;++f)h=this.getTextSelectedByRange(d[f],b[e]),c=this.getMatchingAncestor(d[f]).element,c&&""!=h?(i.push(c),1===a.dom.getTextNodes(c,!0).length?j="full":"full"===j&&(j="inline")):c||(j="partial")}return i.length?{elements:i,coverage:j}:!1},toggleRange:function(a){var b,c=this.isAppliedToRange(a);c?"full"===c.coverage?this.undoToRange(a):"inline"===c.coverage?(b=k(c.elements,this.tagNames,this.cssStyle,this.cssClass),this.undoToRange(a),b||this.applyToRange(a)):(k(c.elements,this.tagNames,this.cssStyle,this.cssClass)||this.undoToRange(a),this.applyToRange(a)):this.applyToRange(a)}},a.selection.HTMLApplier=s}(wysihtml5,rangy),wysihtml5.Commands=Base.extend({constructor:function(a){this.editor=a,this.composer=a.composer,this.doc=this.composer.doc},support:function(a){return wysihtml5.browser.supportsCommand(this.doc,a)},exec:function(a,b){var c=wysihtml5.commands[a],d=wysihtml5.lang.array(arguments).get(),e=c&&c.exec,f=null;if(this.editor.fire("beforecommand:composer"),e)d.unshift(this.composer),f=e.apply(c,d);else try{f=this.doc.execCommand(a,!1,b)}catch(g){}return this.editor.fire("aftercommand:composer"),f},state:function(a){var b=wysihtml5.commands[a],c=wysihtml5.lang.array(arguments).get(),d=b&&b.state;if(d)return c.unshift(this.composer),d.apply(b,c);try{return this.doc.queryCommandState(a)}catch(e){return!1}},stateValue:function(a){var b=wysihtml5.commands[a],c=wysihtml5.lang.array(arguments).get(),d=b&&b.stateValue;return d?(c.unshift(this.composer),d.apply(b,c)):!1}}),wysihtml5.commands.bold={exec:function(a,b){wysihtml5.commands.formatInline.execWithToggle(a,b,"b")},state:function(a,b){return wysihtml5.commands.formatInline.state(a,b,"b")}},function(a){function b(b,c){var g,h,i,j,k,l,m,n,o,p=b.doc,q="_wysihtml5-temp-"+ +new Date,r=/non-matching-class/g,s=0;for(a.commands.formatInline.exec(b,d,e,q,r,d,d,!0,!0),h=p.querySelectorAll(e+"."+q),g=h.length;g>s;s++){i=h[s],i.removeAttribute("class");for(o in c)"text"!==o&&i.setAttribute(o,c[o])}l=i,1===g&&(m=f.getTextContent(i),j=!!i.querySelector("*"),k=""===m||m===a.INVISIBLE_SPACE,!j&&k&&(f.setTextContent(i,c.text||i.href),n=p.createTextNode(" "),b.selection.setAfter(i),f.insert(n).after(i),l=n)),b.selection.setAfter(l)}function c(a,b,c){var d,e,f,g;for(e=b.length;e--;){for(d=b[e].attributes,f=d.length;f--;)b[e].removeAttribute(d.item(f).name);for(g in c)c.hasOwnProperty(g)&&b[e].setAttribute(g,c[g])}}var d,e="A",f=a.dom;a.commands.createLink={exec:function(a,d,e){var f=this.state(a,d);f?a.selection.executeAndRestore(function(){c(a,f,e)}):(e="object"==typeof e?e:{href:e},b(a,e))},state:function(b,c){return a.commands.formatInline.state(b,c,"A")}}}(wysihtml5),function(a){function b(a,b){for(var d,e,f,g=b.length,h=0;g>h;h++)d=b[h],e=c.getParentElement(d,{nodeName:"code"}),f=c.getTextContent(d),f.match(c.autoLink.URL_REG_EXP)&&!e?e=c.renameElement(d,"code"):c.replaceWithChildNodes(d)}var c=a.dom;a.commands.removeLink={exec:function(a,c){var d=this.state(a,c);d&&a.selection.executeAndRestore(function(){b(a,d)})},state:function(b,c){return a.commands.formatInline.state(b,c,"A")}}}(wysihtml5),function(a){var b=/wysiwyg-font-size-[0-9a-z\-]+/g;a.commands.fontSize={exec:function(c,d,e){a.commands.formatInline.execWithToggle(c,d,"span","wysiwyg-font-size-"+e,b)},state:function(c,d,e){return a.commands.formatInline.state(c,d,"span","wysiwyg-font-size-"+e,b)}}}(wysihtml5),function(a){var b=/(\s|^)font-size\s*:\s*[^;\s]+;?/gi;a.commands.fontSizeStyle={exec:function(c,d,e){e="object"==typeof e?e.size:e,/^\s*$/.test(e)||a.commands.formatInline.execWithToggle(c,d,"span",!1,!1,"font-size:"+e,b)},state:function(c,d){return a.commands.formatInline.state(c,d,"span",!1,!1,"font-size",b)},stateValue:function(b,c){var d,e=this.state(b,c);return e&&a.lang.object(e).isArray()&&(e=e[0]),e&&(d=e.getAttribute("style"),d)?a.quirks.styleParser.parseFontSize(d):!1}}}(wysihtml5),function(a){var b=/wysiwyg-color-[0-9a-z]+/g;a.commands.foreColor={exec:function(c,d,e){a.commands.formatInline.execWithToggle(c,d,"span","wysiwyg-color-"+e,b)},state:function(c,d,e){return a.commands.formatInline.state(c,d,"span","wysiwyg-color-"+e,b)}}}(wysihtml5),function(a){var b=/(\s|^)color\s*:\s*[^;\s]+;?/gi;a.commands.foreColorStyle={exec:function(c,d,e){var f,g=a.quirks.styleParser.parseColor("object"==typeof e?"color:"+e.color:"color:"+e,"color");g&&(f="color: rgb("+g[0]+","+g[1]+","+g[2]+");",1!==g[3]&&(f+="color: rgba("+g[0]+","+g[1]+","+g[2]+","+g[3]+");"),a.commands.formatInline.execWithToggle(c,d,"span",!1,!1,f,b))},state:function(c,d){return a.commands.formatInline.state(c,d,"span",!1,!1,"color",b)},stateValue:function(b,c,d){var e,f=this.state(b,c);return f&&a.lang.object(f).isArray()&&(f=f[0]),f&&(e=f.getAttribute("style"),e&&e)?(val=a.quirks.styleParser.parseColor(e,"color"),a.quirks.styleParser.unparseColor(val,d)):!1
  }}}(wysihtml5),function(a){var b=/(\s|^)background-color\s*:\s*[^;\s]+;?/gi;a.commands.bgColorStyle={exec:function(c,d,e){var f,g=a.quirks.styleParser.parseColor("object"==typeof e?"background-color:"+e.color:"background-color:"+e,"background-color");g&&(f="background-color: rgb("+g[0]+","+g[1]+","+g[2]+");",1!==g[3]&&(f+="background-color: rgba("+g[0]+","+g[1]+","+g[2]+","+g[3]+");"),a.commands.formatInline.execWithToggle(c,d,"span",!1,!1,f,b))},state:function(c,d){return a.commands.formatInline.state(c,d,"span",!1,!1,"background-color",b)},stateValue:function(b,c,d){var e,f=this.state(b,c),g=!1;return f&&a.lang.object(f).isArray()&&(f=f[0]),f&&(e=f.getAttribute("style"),e)?(g=a.quirks.styleParser.parseColor(e,"background-color"),a.quirks.styleParser.unparseColor(g,d)):!1}}}(wysihtml5),function(a){function b(b,c,e){b.className?(d(b,e),b.className=a.lang.string(b.className+" "+c).trim()):b.className=c}function c(b,c,d){e(b,d),b.getAttribute("style")?b.setAttribute("style",a.lang.string(b.getAttribute("style")+" "+c).trim()):b.setAttribute("style",c)}function d(b,c){var d=c.test(b.className);return b.className=b.className.replace(c,""),""==a.lang.string(b.className).trim()&&b.removeAttribute("class"),d}function e(b,c){var d=c.test(b.getAttribute("style"));return b.setAttribute("style",(b.getAttribute("style")||"").replace(c,"")),""==a.lang.string(b.getAttribute("style")||"").trim()&&b.removeAttribute("style"),d}function f(a){var b=a.lastChild;b&&g(b)&&b.parentNode.removeChild(b)}function g(a){return"BR"===a.nodeName}function h(b,c){var d,e,g;for(b.selection.isCollapsed()&&b.selection.selectLine(),d=b.selection.surround(c),e=0,g=d.length;g>e;e++)a.dom.lineBreaks(d[e]).remove(),f(d[e])}function i(b){return!!a.lang.string(b.className).trim()}function j(b){return!!a.lang.string(b.getAttribute("style")||"").trim()}var k=a.dom,l=["H1","H2","H3","H4","H5","H6","P","PRE","DIV"];a.commands.formatBlock={exec:function(f,g,m,n,o,p,q){var r,s,t,u,v,w=(f.doc,this.state(f,g,m,n,o,p,q)),x=f.config.useLineBreaks,y=x?"DIV":"P";return m="string"==typeof m?m.toUpperCase():m,w.length?(f.selection.executeAndRestoreRangy(function(){var b,c,f;for(b=w.length;b--;){if(o&&(s=d(w[b],o)),q&&(u=e(w[b],q)),(u||s)&&null===m&&w[b].nodeName!=y)return;c=i(w[b]),f=j(w[b]),c||f||!x&&"P"!==m?k.renameElement(w[b],"P"===m?"DIV":y):(a.dom.lineBreaks(w[b]).add(),k.replaceWithChildNodes(w[b]))}}),void 0):((null!==m&&!a.lang.array(l).contains(m)||(r=f.selection.findNodesInSelection(l).concat(f.selection.getSelectedOwnNodes()),f.selection.executeAndRestoreRangy(function(){for(var a=r.length;a--;)v=k.getParentElement(r[a],{nodeName:l}),v==f.element&&(v=null),v&&(m&&(v=k.renameElement(v,m)),n&&b(v,n,o),p&&c(v,p,q),t=!0)}),!t))&&h(f,{nodeName:m||y,className:n||null,cssStyle:p||null}),void 0)},state:function(b,c,d,e,f,g,h){var i,j,l,m=b.selection.getSelectedOwnNodes(),n=[];for(d="string"==typeof d?d.toUpperCase():d,j=0,l=m.length;l>j;j++)i=k.getParentElement(m[j],{nodeName:d,className:e,classRegExp:f,cssStyle:g,styleRegExp:h}),i&&-1==a.lang.array(n).indexOf(i)&&n.push(i);return 0==n.length?!1:n}}}(wysihtml5),wysihtml5.commands.formatCode={exec:function(a,b,c){var d,e,f,g=this.state(a);g?a.selection.executeAndRestore(function(){d=g.querySelector("code"),wysihtml5.dom.replaceWithChildNodes(g),d&&wysihtml5.dom.replaceWithChildNodes(d)}):(e=a.selection.getRange(),f=e.extractContents(),g=a.doc.createElement("pre"),d=a.doc.createElement("code"),c&&(d.className=c),g.appendChild(d),d.appendChild(f),e.insertNode(g),a.selection.selectNode(g))},state:function(a){var b=a.selection.getSelectedNode();return b&&b.nodeName&&"PRE"==b.nodeName&&b.firstChild&&b.firstChild.nodeName&&"CODE"==b.firstChild.nodeName?b:wysihtml5.dom.getParentElement(b,{nodeName:"CODE"})&&wysihtml5.dom.getParentElement(b,{nodeName:"PRE"})}},function(a){function b(a){var b=d[a];return b?[a.toLowerCase(),b.toLowerCase()]:[a.toLowerCase()]}function c(c,d,f,g,h,i){var j=c;return d&&(j+=":"+d),g&&(j+=":"+g),e[j]||(e[j]=new a.selection.HTMLApplier(b(c),d,f,!0,g,h,i)),e[j]}var d={strong:"b",em:"i",b:"strong",i:"em"},e={};a.commands.formatInline={exec:function(a,b,d,e,f,g,h,i,j){var k=a.selection.createRange(),l=a.selection.getOwnRanges();return l&&0!=l.length?(a.selection.getSelection().removeAllRanges(),c(d,e,f,g,h,a.element).toggleRange(l),i?j||a.cleanUp():(k.setStart(l[0].startContainer,l[0].startOffset),k.setEnd(l[l.length-1].endContainer,l[l.length-1].endOffset),a.selection.setSelection(k),a.selection.executeAndRestore(function(){j||a.cleanUp()},!0,!0)),void 0):!1},execWithToggle:function(b,c,d,e,f,g,h){var i,j=this;this.state(b,c,d,e,f,g,h)&&b.selection.isCollapsed()&&!b.selection.caretIsLastInSelection()&&!b.selection.caretIsFirstInSelection()?(i=j.state(b,c,d,e,f)[0],b.selection.executeAndRestoreRangy(function(){i.parentNode;b.selection.selectNode(i,!0),a.commands.formatInline.exec(b,c,d,e,f,g,h,!0,!0)})):this.state(b,c,d,e,f,g,h)&&!b.selection.isCollapsed()?b.selection.executeAndRestoreRangy(function(){a.commands.formatInline.exec(b,c,d,e,f,g,h,!0,!0)}):a.commands.formatInline.exec(b,c,d,e,f,g,h)},state:function(b,e,f,g,h,i,j){var k,l,m=b.doc,n=d[f]||f;return a.dom.hasElementWithTagName(m,f)||a.dom.hasElementWithTagName(m,n)?g&&!a.dom.hasElementWithClassName(m,g)?!1:(k=b.selection.getOwnRanges(),k&&0!==k.length?(l=c(f,g,h,i,j,b.element).isAppliedToRange(k),l&&l.elements?l.elements:!1):!1):!1}}}(wysihtml5),function(a){a.commands.insertBlockQuote={exec:function(b,c){var d=this.state(b,c),e=b.selection.isEndToEndInNode(["H1","H2","H3","H4","H5","H6","P"]);b.selection.executeAndRestore(function(){if(d)b.config.useLineBreaks&&a.dom.lineBreaks(d).add(),a.dom.unwrap(d);else if(b.selection.isCollapsed()&&b.selection.selectLine(),e){var c=e.ownerDocument.createElement("blockquote");a.dom.insert(c).after(e),c.appendChild(e)}else b.selection.surround({nodeName:"blockquote"})})},state:function(b){var c=b.selection.getSelectedNode(),d=a.dom.getParentElement(c,{nodeName:"BLOCKQUOTE"},!1,b.element);return d?d:!1}}}(wysihtml5),wysihtml5.commands.insertHTML={exec:function(a,b,c){a.commands.support(b)?a.doc.execCommand(b,!1,c):a.selection.insertHTML(c)},state:function(){return!1}},function(a){var b="IMG";a.commands.insertImage={exec:function(c,d,e){var f,g,h,i,j;if(e="object"==typeof e?e:{src:e},f=c.doc,g=this.state(c),g)return c.selection.setBefore(g),i=g.parentNode,i.removeChild(g),a.dom.removeEmptyTextNodes(i),"A"!==i.nodeName||i.firstChild||(c.selection.setAfter(i),i.parentNode.removeChild(i)),a.quirks.redraw(c.element),void 0;g=f.createElement(b);for(j in e)g.setAttribute("className"===j?"class":j,e[j]);c.selection.insertNode(g),a.browser.hasProblemsSettingCaretAfterImg()?(h=f.createTextNode(a.INVISIBLE_SPACE),c.selection.insertNode(h),c.selection.setAfter(h)):c.selection.setAfter(g)},state:function(c){var d,e,f,g=c.doc;return a.dom.hasElementWithTagName(g,b)?(d=c.selection.getSelectedNode(),d?d.nodeName===b?d:d.nodeType!==a.ELEMENT_NODE?!1:(e=c.selection.getText(),e=a.lang.string(e).trim(),e?!1:(f=c.selection.getNodes(a.ELEMENT_NODE,function(a){return"IMG"===a.nodeName}),1!==f.length?!1:f[0])):!1):!1}}}(wysihtml5),function(a){var b="<br>"+(a.browser.needsSpaceAfterLineBreak()?" ":"");a.commands.insertLineBreak={exec:function(c,d){c.commands.support(d)?(c.doc.execCommand(d,!1,null),a.browser.autoScrollsToCaret()||c.selection.scrollIntoView()):c.commands.exec("insertHTML",b)},state:function(){return!1}}}(wysihtml5),wysihtml5.commands.insertOrderedList={exec:function(a,b){wysihtml5.commands.insertList.exec(a,b,"OL")},state:function(a,b){return wysihtml5.commands.insertList.state(a,b,"OL")}},wysihtml5.commands.insertUnorderedList={exec:function(a,b){wysihtml5.commands.insertList.exec(a,b,"UL")},state:function(a,b){return wysihtml5.commands.insertList.state(a,b,"UL")}},wysihtml5.commands.insertList=function(a){var b=function(a,b){if(a&&a.nodeName){"string"==typeof b&&(b=[b]);for(var c=b.length;c--;)if(a.nodeName===b[c])return!0}return!1},c=function(c,d,e){var f,g,h={el:null,other:!1};return c&&(f=a.dom.getParentElement(c,{nodeName:"LI"}),g="UL"===d?"OL":"UL",b(c,d)?h.el=c:b(c,g)?h={el:c,other:!0}:f&&(b(f.parentNode,d)?h.el=f.parentNode:b(f.parentNode,g)&&(h={el:f.parentNode,other:!0}))),h.el&&!e.element.contains(h.el)&&(h.el=null),h},d=function(b,c,d){var e,g="UL"===c?"OL":"UL";d.selection.executeAndRestore(function(){var h,i,j=f(g,d);if(j.length)for(h=j.length;h--;)a.dom.renameElement(j[h],c.toLowerCase());else{for(e=f(["OL","UL"],d),i=e.length;i--;)a.dom.resolveList(e[i],d.config.useLineBreaks);a.dom.resolveList(b,d.config.useLineBreaks)}})},e=function(b,c,d){var e="UL"===c?"OL":"UL";d.selection.executeAndRestore(function(){var g,h=[b].concat(f(e,d));for(g=h.length;g--;)a.dom.renameElement(h[g],c.toLowerCase())})},f=function(a,c){var d,e=c.selection.getOwnRanges(),f=[];for(d=e.length;d--;)f=f.concat(e[d].getNodes([1],function(c){return b(c,a)}));return f},g=function(b,c){c.selection.executeAndRestoreRangy(function(){var d,e,f="_wysihtml5-temp-"+(new Date).getTime(),g=c.selection.deblockAndSurround({nodeName:"div",className:f}),h=/\uFEFF/g;g.innerHTML=g.innerHTML.replace(h,""),g&&(d=a.lang.array(["","<br>",a.INVISIBLE_SPACE]).contains(g.innerHTML),e=a.dom.convertToList(g,b.toLowerCase(),c.parent.config.uneditableContainerClassname),d&&c.selection.selectNode(e.querySelector("li"),!0))})};return{exec:function(a,b,f){var h=a.doc,i="OL"===f?"insertOrderedList":"insertUnorderedList",j=a.selection.getSelectedNode(),k=c(j,f,a);k.el?k.other?e(k.el,f,a):d(k.el,f,a):a.commands.support(i)?h.execCommand(i,!1,null):g(f,a)},state:function(a,b,d){var e=a.selection.getSelectedNode(),f=c(e,d,a);return f.el&&!f.other?f.el:!1}}}(wysihtml5),wysihtml5.commands.italic={exec:function(a,b){wysihtml5.commands.formatInline.execWithToggle(a,b,"i")},state:function(a,b){return wysihtml5.commands.formatInline.state(a,b,"i")}},function(a){var b="wysiwyg-text-align-center",c=/wysiwyg-text-align-[0-9a-z]+/g;a.commands.justifyCenter={exec:function(d){return a.commands.formatBlock.exec(d,"formatBlock",null,b,c)},state:function(d){return a.commands.formatBlock.state(d,"formatBlock",null,b,c)}}}(wysihtml5),function(a){var b="wysiwyg-text-align-left",c=/wysiwyg-text-align-[0-9a-z]+/g;a.commands.justifyLeft={exec:function(d){return a.commands.formatBlock.exec(d,"formatBlock",null,b,c)},state:function(d){return a.commands.formatBlock.state(d,"formatBlock",null,b,c)}}}(wysihtml5),function(a){var b="wysiwyg-text-align-right",c=/wysiwyg-text-align-[0-9a-z]+/g;a.commands.justifyRight={exec:function(d){return a.commands.formatBlock.exec(d,"formatBlock",null,b,c)},state:function(d){return a.commands.formatBlock.state(d,"formatBlock",null,b,c)}}}(wysihtml5),function(a){var b="wysiwyg-text-align-justify",c=/wysiwyg-text-align-[0-9a-z]+/g;a.commands.justifyFull={exec:function(d){return a.commands.formatBlock.exec(d,"formatBlock",null,b,c)},state:function(d){return a.commands.formatBlock.state(d,"formatBlock",null,b,c)}}}(wysihtml5),function(a){var b="text-align: right;",c=/(\s|^)text-align\s*:\s*[^;\s]+;?/gi;a.commands.alignRightStyle={exec:function(d){return a.commands.formatBlock.exec(d,"formatBlock",null,null,null,b,c)},state:function(d){return a.commands.formatBlock.state(d,"formatBlock",null,null,null,b,c)}}}(wysihtml5),function(a){var b="text-align: left;",c=/(\s|^)text-align\s*:\s*[^;\s]+;?/gi;a.commands.alignLeftStyle={exec:function(d){return a.commands.formatBlock.exec(d,"formatBlock",null,null,null,b,c)},state:function(d){return a.commands.formatBlock.state(d,"formatBlock",null,null,null,b,c)}}}(wysihtml5),function(a){var b="text-align: center;",c=/(\s|^)text-align\s*:\s*[^;\s]+;?/gi;a.commands.alignCenterStyle={exec:function(d){return a.commands.formatBlock.exec(d,"formatBlock",null,null,null,b,c)},state:function(d){return a.commands.formatBlock.state(d,"formatBlock",null,null,null,b,c)}}}(wysihtml5),wysihtml5.commands.redo={exec:function(a){return a.undoManager.redo()},state:function(){return!1}},wysihtml5.commands.underline={exec:function(a,b){wysihtml5.commands.formatInline.execWithToggle(a,b,"u")},state:function(a,b){return wysihtml5.commands.formatInline.state(a,b,"u")}},wysihtml5.commands.undo={exec:function(a){return a.undoManager.undo()},state:function(){return!1}},wysihtml5.commands.createTable={exec:function(a,b,c){var d,e,f;if(c&&c.cols&&c.rows&&parseInt(c.cols,10)>0&&parseInt(c.rows,10)>0){for(f=c.tableStyle?'<table style="'+c.tableStyle+'">':"<table>",f+="<tbody>",e=0;e<c.rows;e++){for(f+="<tr>",d=0;d<c.cols;d++)f+="<td>&nbsp;</td>";f+="</tr>"}f+="</tbody></table>",a.commands.exec("insertHTML",f)}},state:function(){return!1}},wysihtml5.commands.mergeTableCells={exec:function(a,b){a.tableSelection&&a.tableSelection.start&&a.tableSelection.end&&(this.state(a,b)?wysihtml5.dom.table.unmergeCell(a.tableSelection.start):wysihtml5.dom.table.mergeCellsBetween(a.tableSelection.start,a.tableSelection.end))},state:function(a){if(a.tableSelection){var b=a.tableSelection.start,c=a.tableSelection.end;if(b&&c&&b==c&&(wysihtml5.dom.getAttribute(b,"colspan")&&parseInt(wysihtml5.dom.getAttribute(b,"colspan"),10)>1||wysihtml5.dom.getAttribute(b,"rowspan")&&parseInt(wysihtml5.dom.getAttribute(b,"rowspan"),10)>1))return[b]}return!1}},wysihtml5.commands.addTableCells={exec:function(a,b,c){if(a.tableSelection&&a.tableSelection.start&&a.tableSelection.end){var d=wysihtml5.dom.table.orderSelectionEnds(a.tableSelection.start,a.tableSelection.end);"before"==c||"above"==c?wysihtml5.dom.table.addCells(d.start,c):("after"==c||"below"==c)&&wysihtml5.dom.table.addCells(d.end,c),setTimeout(function(){a.tableSelection.select(d.start,d.end)},0)}},state:function(){return!1}},wysihtml5.commands.deleteTableCells={exec:function(a,b,c){if(a.tableSelection&&a.tableSelection.start&&a.tableSelection.end){var d,e=wysihtml5.dom.table.orderSelectionEnds(a.tableSelection.start,a.tableSelection.end),f=wysihtml5.dom.table.indexOf(e.start),g=a.tableSelection.table;wysihtml5.dom.table.removeCells(e.start,c),setTimeout(function(){d=wysihtml5.dom.table.findCell(g,f),d||("row"==c&&(d=wysihtml5.dom.table.findCell(g,{row:f.row-1,col:f.col})),"column"==c&&(d=wysihtml5.dom.table.findCell(g,{row:f.row,col:f.col-1}))),d&&a.tableSelection.select(d,d)},0)}},state:function(){return!1}},wysihtml5.commands.indentList={exec:function(a){var b=a.selection.getSelectionParentsByTag("LI");return b?this.tryToPushLiLevel(b,a.selection):!1},state:function(){return!1},tryToPushLiLevel:function(a,b){var c,d,e,f,g,h=!1;return b.executeAndRestoreRangy(function(){for(var b=a.length;b--;)f=a[b],c="OL"===f.parentNode.nodeName?"OL":"UL",d=f.ownerDocument.createElement(c),e=wysihtml5.dom.domNode(f).prev({nodeTypes:[wysihtml5.ELEMENT_NODE]}),g=e?e.querySelector("ul, ol"):null,e&&(g?g.appendChild(f):(d.appendChild(f),e.appendChild(d)),h=!0)}),h}},wysihtml5.commands.outdentList={exec:function(a){var b=a.selection.getSelectionParentsByTag("LI");return b?this.tryToPullLiLevel(b,a):!1},state:function(){return!1},tryToPullLiLevel:function(a,b){var c,d,e,f,g,h=!1,i=this;return b.selection.executeAndRestoreRangy(function(){var j,k;for(j=a.length;j--;)if(f=a[j],f.parentNode&&(c=f.parentNode,"OL"===c.tagName||"UL"===c.tagName)){if(h=!0,d=wysihtml5.dom.getParentElement(c.parentNode,{nodeName:["OL","UL"]},!1,b.element),e=wysihtml5.dom.getParentElement(c.parentNode,{nodeName:["LI"]},!1,b.element),d&&e)f.nextSibling&&(g=i.getAfterList(c,f),f.appendChild(g)),d.insertBefore(f,e.nextSibling);else{for(f.nextSibling&&(g=i.getAfterList(c,f),f.appendChild(g)),k=f.childNodes.length;k--;)c.parentNode.insertBefore(f.childNodes[k],c.nextSibling);c.parentNode.insertBefore(document.createElement("br"),c.nextSibling),f.parentNode.removeChild(f)}0===c.childNodes.length&&c.parentNode.removeChild(c)}}),h},getAfterList:function(a,b){for(var c=a.nodeName,d=document.createElement(c);b.nextSibling;)d.appendChild(b.nextSibling);return d}},function(a){var b=90,c=89,d=8,e=46,f=25,g="data-wysihtml5-selection-node",h="data-wysihtml5-selection-offset",i=('<span id="_wysihtml5-undo" class="_wysihtml5-temp">'+a.INVISIBLE_SPACE+"</span>",'<span id="_wysihtml5-redo" class="_wysihtml5-temp">'+a.INVISIBLE_SPACE+"</span>",a.dom);a.UndoManager=a.lang.Dispatcher.extend({constructor:function(a){this.editor=a,this.composer=a.composer,this.element=this.composer.element,this.position=0,this.historyStr=[],this.historyDom=[],this.transact(),this._observe()},_observe:function(){{var a,f=this;this.composer.sandbox.getDocument()}i.observe(this.element,"keydown",function(a){if(!a.altKey&&(a.ctrlKey||a.metaKey)){var d=a.keyCode,e=d===b&&!a.shiftKey,g=d===b&&a.shiftKey||d===c;e?(f.undo(),a.preventDefault()):g&&(f.redo(),a.preventDefault())}}),i.observe(this.element,"keydown",function(b){var c=b.keyCode;c!==a&&(a=c,(c===d||c===e)&&f.transact())}),this.editor.on("newword:composer",function(){f.transact()}).on("beforecommand:composer",function(){f.transact()})},transact:function(){var b,c,d,e,i,j,k,l=this.historyStr[this.position-1],m=this.composer.getValue(!1,!1),n=this.element.offsetWidth>0&&this.element.offsetHeight>0;m!==l&&(j=this.historyStr.length=this.historyDom.length=this.position,j>f&&(this.historyStr.shift(),this.historyDom.shift(),this.position--),this.position++,n&&(b=this.composer.selection.getRange(),c=b&&b.startContainer?b.startContainer:this.element,d=b&&b.startOffset?b.startOffset:0,c.nodeType===a.ELEMENT_NODE?e=c:(e=c.parentNode,i=this.getChildNodeIndex(e,c)),e.setAttribute(h,d),void 0!==i&&e.setAttribute(g,i)),k=this.element.cloneNode(!!m),this.historyDom.push(k),this.historyStr.push(m),e&&(e.removeAttribute(h),e.removeAttribute(g)))},undo:function(){this.transact(),this.undoPossible()&&(this.set(this.historyDom[--this.position-1]),this.editor.fire("undo:composer"))},redo:function(){this.redoPossible()&&(this.set(this.historyDom[++this.position-1]),this.editor.fire("redo:composer"))},undoPossible:function(){return this.position>1},redoPossible:function(){return this.position<this.historyStr.length},set:function(a){var b,c,d,e,f,i;for(this.element.innerHTML="",b=0,c=a.childNodes,d=a.childNodes.length;d>b;b++)this.element.appendChild(c[b].cloneNode(!0));a.hasAttribute(h)?(e=a.getAttribute(h),i=a.getAttribute(g),f=this.element):(f=this.element.querySelector("["+h+"]")||this.element,e=f.getAttribute(h),i=f.getAttribute(g),f.removeAttribute(h),f.removeAttribute(g)),null!==i&&(f=this.getChildNodeByIndex(f,+i)),this.composer.selection.set(f,e)},getChildNodeIndex:function(a,b){for(var c=0,d=a.childNodes,e=d.length;e>c;c++)if(d[c]===b)return c},getChildNodeByIndex:function(a,b){return a.childNodes[b]}})}(wysihtml5),wysihtml5.views.View=Base.extend({constructor:function(a,b,c){this.parent=a,this.element=b,this.config=c,this.config.noTextarea||this._observeViewChange()},_observeViewChange:function(){var a=this;this.parent.on("beforeload",function(){a.parent.on("change_view",function(b){b===a.name?(a.parent.currentView=a,a.show(),setTimeout(function(){a.focus()},0)):a.hide()})})},focus:function(){if(this.element.ownerDocument.querySelector(":focus")!==this.element)try{this.element.focus()}catch(a){}},hide:function(){this.element.style.display="none"},show:function(){this.element.style.display=""},disable:function(){this.element.setAttribute("disabled","disabled")},enable:function(){this.element.removeAttribute("disabled")}}),function(a){var b=a.dom,c=a.browser;a.views.Composer=a.views.View.extend({name:"composer",CARET_HACK:"<br>",constructor:function(a,b,c){this.base(a,b,c),this.config.noTextarea?this.editableArea=b:this.textarea=this.parent.textarea,this.config.contentEditableMode?this._initContentEditableArea():this._initSandbox()},clear:function(){this.element.innerHTML=c.displaysCaretInEmptyContentEditableCorrectly()?"":this.CARET_HACK},getValue:function(b,c){var d=this.isEmpty()?"":a.quirks.getCorrectInnerHTML(this.element);return b!==!1&&(d=this.parent.parse(d,c===!1?!1:!0)),d},setValue:function(a,b){b&&(a=this.parent.parse(a));try{this.element.innerHTML=a}catch(c){this.element.innerText=a}},cleanUp:function(){this.parent.parse(this.element)},show:function(){this.editableArea.style.display=this._displayStyle||"",this.config.noTextarea||this.textarea.element.disabled||(this.disable(),this.enable())},hide:function(){this._displayStyle=b.getStyle("display").from(this.editableArea),"none"===this._displayStyle&&(this._displayStyle=null),this.editableArea.style.display="none"},disable:function(){this.parent.fire("disable:composer"),this.element.removeAttribute("contentEditable")},enable:function(){this.parent.fire("enable:composer"),this.element.setAttribute("contentEditable","true")},focus:function(b){a.browser.doesAsyncFocus()&&this.hasPlaceholderSet()&&this.clear(),this.base();var c=this.element.lastChild;b&&c&&this.selection&&("BR"===c.nodeName?this.selection.setBefore(this.element.lastChild):this.selection.setAfter(this.element.lastChild))},getTextContent:function(){return b.getTextContent(this.element)},hasPlaceholderSet:function(){return this.getTextContent()==(this.config.noTextarea?this.editableArea.getAttribute("data-placeholder"):this.textarea.element.getAttribute("placeholder"))&&this.placeholderSet},isEmpty:function(){var a=this.element.innerHTML.toLowerCase();return/^(\s|<br>|<\/br>|<p>|<\/p>)*$/i.test(a)||""===a||"<br>"===a||"<p></p>"===a||"<p><br></p>"===a||this.hasPlaceholderSet()},_initContentEditableArea:function(){var a=this;this.config.noTextarea?this.sandbox=new b.ContentEditableArea(function(){a._create()},{},this.editableArea):(this.sandbox=new b.ContentEditableArea(function(){a._create()}),this.editableArea=this.sandbox.getContentEditable(),b.insert(this.editableArea).after(this.textarea.element),this._createWysiwygFormField())},_initSandbox:function(){var a,c=this;this.sandbox=new b.Sandbox(function(){c._create()},{stylesheets:this.config.stylesheets}),this.editableArea=this.sandbox.getIframe(),a=this.textarea.element,b.insert(this.editableArea).after(a),this._createWysiwygFormField()},_createWysiwygFormField:function(){if(this.textarea.element.form){var a=document.createElement("input");a.type="hidden",a.name="_wysihtml5_mode",a.value=1,b.insert(a).after(this.textarea.element)}},_create:function(){var d,e,f=this;this.doc=this.sandbox.getDocument(),this.element=this.config.contentEditableMode?this.sandbox.getContentEditable():this.doc.body,this.config.noTextarea?this.cleanUp():(this.textarea=this.parent.textarea,this.element.innerHTML=this.textarea.getValue(!0,!1)),this.selection=new a.Selection(this.parent,this.element,this.config.uneditableContainerClassname),this.commands=new a.Commands(this.parent),this.config.noTextarea||b.copyAttributes(["className","spellcheck","title","lang","dir","accessKey"]).from(this.textarea.element).to(this.element),b.addClass(this.element,this.config.composerClassName),this.config.style&&!this.config.contentEditableMode&&this.style(),this.observe(),d=this.config.name,d&&(b.addClass(this.element,d),this.config.contentEditableMode||b.addClass(this.editableArea,d)),this.enable(),!this.config.noTextarea&&this.textarea.element.disabled&&this.disable(),e="string"==typeof this.config.placeholder?this.config.placeholder:this.config.noTextarea?this.editableArea.getAttribute("data-placeholder"):this.textarea.element.getAttribute("placeholder"),e&&b.simulatePlaceholder(this.parent,this,e),this.commands.exec("styleWithCSS",!1),this._initAutoLinking(),this._initObjectResizing(),this._initUndoManager(),this._initLineBreaking(),this.config.noTextarea||!this.textarea.element.hasAttribute("autofocus")&&document.querySelector(":focus")!=this.textarea.element||c.isIos()||setTimeout(function(){f.focus(!0)},100),c.clearsContentEditableCorrectly()||a.quirks.ensureProperClearing(this),this.initSync&&this.config.sync&&this.initSync(),this.config.noTextarea||this.textarea.hide(),this.parent.fire("beforeload").fire("load")},_initAutoLinking:function(){var d,e,f,g=this,h=c.canDisableAutoLinking(),i=c.doesAutoLinkingInContentEditable();h&&this.commands.exec("autoUrlDetect",!1),this.config.autoLink&&((!i||i&&h)&&(this.parent.on("newword:composer",function(){b.getTextContent(g.element).match(b.autoLink.URL_REG_EXP)&&g.selection.executeAndRestore(function(c,d){var e,f=g.element.querySelectorAll("."+g.config.uneditableContainerClassname),h=!1;for(e=f.length;e--;)a.dom.contains(f[e],d)&&(h=!0);h||b.autoLink(d.parentNode,[g.config.uneditableContainerClassname])})}),b.observe(this.element,"blur",function(){b.autoLink(g.element,[g.config.uneditableContainerClassname])})),d=this.sandbox.getDocument().getElementsByTagName("a"),e=b.autoLink.URL_REG_EXP,f=function(c){var d=a.lang.string(b.getTextContent(c)).trim();return"www."===d.substr(0,4)&&(d="http://"+d),d},b.observe(this.element,"keydown",function(a){if(d.length){var c,h=g.selection.getSelectedNode(a.target.ownerDocument),i=b.getParentElement(h,{nodeName:"A"},4);i&&(c=f(i),setTimeout(function(){var a=f(i);a!==c&&a.match(e)&&i.setAttribute("href",a)},0))}}))},_initObjectResizing:function(){if(this.commands.exec("enableObjectResizing",!0),c.supportsEvent("resizeend")){var d=["width","height"],e=d.length,f=this.element;b.observe(f,"resizeend",function(b){var c,g=b.target||b.srcElement,h=g.style,i=0;if("IMG"===g.nodeName){for(;e>i;i++)c=d[i],h[c]&&(g.setAttribute(c,parseInt(h[c],10)),h[c]="");a.quirks.redraw(f)}})}},_initUndoManager:function(){this.undoManager=new a.UndoManager(this.parent)},_initLineBreaking:function(){function d(a){var c=b.getParentElement(a,{nodeName:["P","DIV"]},2);c&&b.contains(e.element,c)&&e.selection.executeAndRestore(function(){e.config.useLineBreaks?b.replaceWithChildNodes(c):"P"!==c.nodeName&&b.renameElement(c,"p")})}var e=this,f=["LI","P","H1","H2","H3","H4","H5","H6"],g=["UL","OL","MENU"];this.config.useLineBreaks||b.observe(this.element,["focus","keydown"],function(){if(e.isEmpty()){var a=e.doc.createElement("P");e.element.innerHTML="",e.element.appendChild(a),c.displaysCaretInEmptyContentEditableCorrectly()?e.selection.selectNode(a,!0):(a.innerHTML="<br>",e.selection.setBefore(a.firstChild))}}),b.observe(this.element,"keydown",function(c){var h,i=c.keyCode;if(!c.shiftKey&&(i===a.ENTER_KEY||i===a.BACKSPACE_KEY))return h=b.getParentElement(e.selection.getSelectedNode(),{nodeName:f},4),h?(setTimeout(function(){var c,f=e.selection.getSelectedNode();if("LI"===h.nodeName){if(!f)return;c=b.getParentElement(f,{nodeName:g},2),c||d(f)}i===a.ENTER_KEY&&h.nodeName.match(/^H[1-6]$/)&&d(f)},0),void 0):(e.config.useLineBreaks&&i===a.ENTER_KEY&&!a.browser.insertsLineBreaksOnReturn()&&(c.preventDefault(),e.commands.exec("insertLineBreak")),void 0)})}})}(wysihtml5),function(a){var b=a.dom,c=document,d=window,e=c.createElement("div"),f=["background-color","color","cursor","font-family","font-size","font-style","font-variant","font-weight","line-height","letter-spacing","text-align","text-decoration","text-indent","text-rendering","word-break","word-wrap","word-spacing"],g=["background-color","border-collapse","border-bottom-color","border-bottom-style","border-bottom-width","border-left-color","border-left-style","border-left-width","border-right-color","border-right-style","border-right-width","border-top-color","border-top-style","border-top-width","clear","display","float","margin-bottom","margin-left","margin-right","margin-top","outline-color","outline-offset","outline-width","outline-style","padding-left","padding-right","padding-top","padding-bottom","position","top","left","right","bottom","z-index","vertical-align","text-align","-webkit-box-sizing","-moz-box-sizing","-ms-box-sizing","box-sizing","-webkit-box-shadow","-moz-box-shadow","-ms-box-shadow","box-shadow","-webkit-border-top-right-radius","-moz-border-radius-topright","border-top-right-radius","-webkit-border-bottom-right-radius","-moz-border-radius-bottomright","border-bottom-right-radius","-webkit-border-bottom-left-radius","-moz-border-radius-bottomleft","border-bottom-left-radius","-webkit-border-top-left-radius","-moz-border-radius-topleft","border-top-left-radius","width","height"],h=["html                 { height: 100%; }","body                 { height: 100%; padding: 1px 0 0 0; margin: -1px 0 0 0; }","body > p:first-child { margin-top: 0; }","._wysihtml5-temp     { display: none; }",a.browser.isGecko?"body.placeholder { color: graytext !important; }":"body.placeholder { color: #a9a9a9 !important; }","img:-moz-broken      { -moz-force-broken-image-icon: 1; height: 24px; width: 24px; }"],i=function(a){if(a.setActive)try{a.setActive()}catch(e){}else{var f=a.style,g=c.documentElement.scrollTop||c.body.scrollTop,h=c.documentElement.scrollLeft||c.body.scrollLeft,i={position:f.position,top:f.top,left:f.left,WebkitUserSelect:f.WebkitUserSelect};b.setStyles({position:"absolute",top:"-99999px",left:"-99999px",WebkitUserSelect:"none"}).on(a),a.focus(),b.setStyles(i).on(a),d.scrollTo&&d.scrollTo(h,g)}};a.views.Composer.prototype.style=function(){var d,j,k=this,l=c.querySelector(":focus"),m=this.textarea.element,n=m.hasAttribute("placeholder"),o=n&&m.getAttribute("placeholder"),p=m.style.display,q=m.disabled;return this.focusStylesHost=e.cloneNode(!1),this.blurStylesHost=e.cloneNode(!1),this.disabledStylesHost=e.cloneNode(!1),n&&m.removeAttribute("placeholder"),m===l&&m.blur(),m.disabled=!1,m.style.display=d="none",(m.getAttribute("rows")&&"auto"===b.getStyle("height").from(m)||m.getAttribute("cols")&&"auto"===b.getStyle("width").from(m))&&(m.style.display=d=p),b.copyStyles(g).from(m).to(this.editableArea).andTo(this.blurStylesHost),b.copyStyles(f).from(m).to(this.element).andTo(this.blurStylesHost),b.insertCSS(h).into(this.element.ownerDocument),m.disabled=!0,b.copyStyles(g).from(m).to(this.disabledStylesHost),b.copyStyles(f).from(m).to(this.disabledStylesHost),m.disabled=q,m.style.display=p,i(m),m.style.display=d,b.copyStyles(g).from(m).to(this.focusStylesHost),b.copyStyles(f).from(m).to(this.focusStylesHost),m.style.display=p,b.copyStyles(["display"]).from(m).to(this.editableArea),j=a.lang.array(g).without(["display"]),l?l.focus():m.blur(),n&&m.setAttribute("placeholder",o),this.parent.on("focus:composer",function(){b.copyStyles(j).from(k.focusStylesHost).to(k.editableArea),b.copyStyles(f).from(k.focusStylesHost).to(k.element)}),this.parent.on("blur:composer",function(){b.copyStyles(j).from(k.blurStylesHost).to(k.editableArea),b.copyStyles(f).from(k.blurStylesHost).to(k.element)}),this.parent.observe("disable:composer",function(){b.copyStyles(j).from(k.disabledStylesHost).to(k.editableArea),b.copyStyles(f).from(k.disabledStylesHost).to(k.element)}),this.parent.observe("enable:composer",function(){b.copyStyles(j).from(k.blurStylesHost).to(k.editableArea),b.copyStyles(f).from(k.blurStylesHost).to(k.element)}),this}}(wysihtml5),function(a){var b=a.dom,c=a.browser,d={66:"bold",73:"italic",85:"underline"},e=function(a,b,c){var d,e=a.getPreviousNode(b,!0),f=a.getSelectedNode();if(1!==f.nodeType&&f.parentNode!==c&&(f=f.parentNode),e)if(1==f.nodeType){if(d=f.firstChild,1==e.nodeType)for(;f.firstChild;)e.appendChild(f.firstChild);else for(;f.firstChild;)b.parentNode.insertBefore(f.firstChild,b);f.parentNode&&f.parentNode.removeChild(f),a.setBefore(d)}else 1==e.nodeType?e.appendChild(f):b.parentNode.insertBefore(f,b),a.setBefore(f)},f=function(a,b,c,d){var f,g,h;b.isCollapsed()?b.caretIsInTheBeginnig("LI")?(a.preventDefault(),d.commands.exec("outdentList")):b.caretIsInTheBeginnig()?a.preventDefault():(b.caretIsFirstInSelection()&&b.getPreviousNode()&&b.getPreviousNode().nodeName&&/^H\d$/gi.test(b.getPreviousNode().nodeName)&&(f=b.getPreviousNode(),a.preventDefault(),/^\s*$/.test(f.textContent||f.innerText)?f.parentNode.removeChild(f):(g=f.ownerDocument.createRange(),g.selectNodeContents(f),g.collapse(!1),b.setSelection(g))),h=b.caretIsBeforeUneditable(),h&&(a.preventDefault(),e(b,h,c))):b.containsUneditable()&&(a.preventDefault(),b.deleteContents())},g=function(a){if(a.selection.isCollapsed()){if(a.selection.caretIsInTheBeginnig("LI")&&a.commands.exec("indentList"))return}else a.selection.deleteContents();
  a.commands.exec("insertHTML","&emsp;")};a.views.Composer.prototype.observe=function(){var e,h,i=this,j=this.getValue(!1,!1),k=this.sandbox.getIframe?this.sandbox.getIframe():this.sandbox.getContentEditable(),l=this.element,m=c.supportsEventsInIframeCorrectly()||this.sandbox.getContentEditable?l:this.sandbox.getWindow(),n=["drop","paste","beforepaste"],o=["drop","paste","mouseup","focus","keyup"];b.observe(k,"DOMNodeRemoved",function(){clearInterval(e),i.parent.fire("destroy:composer")}),c.supportsMutationEvents()||(e=setInterval(function(){b.contains(document.documentElement,k)||(clearInterval(e),i.parent.fire("destroy:composer"))},250)),b.observe(m,o,function(){setTimeout(function(){i.parent.fire("interaction").fire("interaction:composer")},0)}),this.config.handleTables&&(!this.tableClickHandle&&this.doc.execCommand&&a.browser.supportsCommand(this.doc,"enableObjectResizing")&&a.browser.supportsCommand(this.doc,"enableInlineTableEditing")&&(this.sandbox.getIframe?this.tableClickHandle=b.observe(k,["focus","mouseup","mouseover"],function(){i.doc.execCommand("enableObjectResizing",!1,"false"),i.doc.execCommand("enableInlineTableEditing",!1,"false"),i.tableClickHandle.stop()}):setTimeout(function(){i.doc.execCommand("enableObjectResizing",!1,"false"),i.doc.execCommand("enableInlineTableEditing",!1,"false")},0)),this.tableSelection=a.quirks.tableCellsSelection(l,i.parent)),b.observe(m,"focus",function(a){i.parent.fire("focus",a).fire("focus:composer",a),setTimeout(function(){j=i.getValue(!1,!1)},0)}),b.observe(m,"blur",function(a){if(j!==i.getValue(!1,!1)){var b=a;"function"==typeof Object.create&&(b=Object.create(a,{type:{value:"change"}})),i.parent.fire("change",b).fire("change:composer",b)}i.parent.fire("blur",a).fire("blur:composer",a)}),b.observe(l,"dragenter",function(){i.parent.fire("unset_placeholder")}),b.observe(l,n,function(a){i.parent.fire(a.type,a).fire(a.type+":composer",a)}),this.config.copyedFromMarking&&b.observe(l,"copy",function(a){a.clipboardData&&(a.clipboardData.setData("text/html",i.config.copyedFromMarking+i.selection.getHtml()),a.preventDefault()),i.parent.fire(a.type,a).fire(a.type+":composer",a)}),b.observe(l,"keyup",function(b){var c=b.keyCode;(c===a.SPACE_KEY||c===a.ENTER_KEY)&&i.parent.fire("newword:composer")}),this.parent.on("paste:composer",function(){setTimeout(function(){i.parent.fire("newword:composer")},0)}),c.canSelectImagesInContentEditable()||b.observe(l,"mousedown",function(b){var c=b.target,d=l.querySelectorAll("img"),e=l.querySelectorAll("."+i.config.uneditableContainerClassname+" img"),f=a.lang.array(d).without(e);"IMG"===c.nodeName&&a.lang.array(f).contains(c)&&i.selection.selectNode(c)}),c.canSelectImagesInContentEditable()||b.observe(l,"drop",function(){setTimeout(function(){i.selection.getSelection().removeAllRanges()},0)}),c.hasHistoryIssue()&&c.supportsSelectionModify()&&b.observe(l,"keydown",function(a){if(a.metaKey||a.ctrlKey){var b=a.keyCode,c=l.ownerDocument.defaultView,d=c.getSelection();(37===b||39===b)&&(37===b&&(d.modify("extend","left","lineboundary"),a.shiftKey||d.collapseToStart()),39===b&&(d.modify("extend","right","lineboundary"),a.shiftKey||d.collapseToEnd()),a.preventDefault())}}),b.observe(l,"keydown",function(a){var b=a.keyCode,c=d[b];(a.ctrlKey||a.metaKey)&&!a.altKey&&c&&(i.commands.exec(c),a.preventDefault()),8===b?f(a,i.selection,l,i):i.config.handleTabKey&&9===b&&(a.preventDefault(),g(i,l))}),b.observe(l,"keydown",function(b){var c,d=i.selection.getSelectedNode(!0),e=b.keyCode;!d||"IMG"!==d.nodeName||e!==a.BACKSPACE_KEY&&e!==a.DELETE_KEY||(c=d.parentNode,c.removeChild(d),"A"!==c.nodeName||c.firstChild||c.parentNode.removeChild(c),setTimeout(function(){a.quirks.redraw(l)},0),b.preventDefault())}),!this.config.contentEditableMode&&c.hasIframeFocusIssue()&&(b.observe(k,"focus",function(){setTimeout(function(){i.doc.querySelector(":focus")!==i.element&&i.focus()},0)}),b.observe(this.element,"blur",function(){setTimeout(function(){i.selection.getSelection().removeAllRanges()},0)})),h={IMG:"Image: ",A:"Link: "},b.observe(l,"mouseover",function(a){var b,c,d=a.target,e=d.nodeName;("A"===e||"IMG"===e)&&(c=d.hasAttribute("title"),c||(b=h[e]+(d.getAttribute("href")||d.getAttribute("src")),d.setAttribute("title",b)))})}}(wysihtml5),function(a){var b=400;a.views.Synchronizer=Base.extend({constructor:function(a,b,c){this.editor=a,this.textarea=b,this.composer=c,this._observe()},fromComposerToTextarea:function(b){this.textarea.setValue(a.lang.string(this.composer.getValue(!1,!1)).trim(),b)},fromTextareaToComposer:function(a){var b=this.textarea.getValue(!1,!1);b?this.composer.setValue(b,a):(this.composer.clear(),this.editor.fire("set_placeholder"))},sync:function(a){"textarea"===this.editor.currentView.name?this.fromTextareaToComposer(a):this.fromComposerToTextarea(a)},_observe:function(){var c,d=this,e=this.textarea.element.form,f=function(){c=setInterval(function(){d.fromComposerToTextarea()},b)},g=function(){clearInterval(c),c=null};f(),e&&(a.dom.observe(e,"submit",function(){d.sync(!0)}),a.dom.observe(e,"reset",function(){setTimeout(function(){d.fromTextareaToComposer()},0)})),this.editor.on("change_view",function(a){"composer"!==a||c?"textarea"===a&&(d.fromComposerToTextarea(!0),g()):(d.fromTextareaToComposer(!0),f())}),this.editor.on("destroy:composer",g)}})}(wysihtml5),wysihtml5.views.Textarea=wysihtml5.views.View.extend({name:"textarea",constructor:function(a,b,c){this.base(a,b,c),this._observe()},clear:function(){this.element.value=""},getValue:function(a){var b=this.isEmpty()?"":this.element.value;return a!==!1&&(b=this.parent.parse(b)),b},setValue:function(a,b){b&&(a=this.parent.parse(a)),this.element.value=a},cleanUp:function(){var a=this.parent.parse(this.element.value);this.element.value=a},hasPlaceholderSet:function(){var a=wysihtml5.browser.supportsPlaceholderAttributeOn(this.element),b=this.element.getAttribute("placeholder")||null,c=this.element.value,d=!c;return a&&d||c===b},isEmpty:function(){return!wysihtml5.lang.string(this.element.value).trim()||this.hasPlaceholderSet()},_observe:function(){var a=this.element,b=this.parent,c={focusin:"focus",focusout:"blur"},d=wysihtml5.browser.supportsEvent("focusin")?["focusin","focusout","change"]:["focus","blur","change"];b.on("beforeload",function(){wysihtml5.dom.observe(a,d,function(a){var d=c[a.type]||a.type;b.fire(d).fire(d+":textarea")}),wysihtml5.dom.observe(a,["paste","drop"],function(){setTimeout(function(){b.fire("paste").fire("paste:textarea")},0)})})}}),function(a){var b,c={name:b,style:!0,toolbar:b,showToolbarAfterInit:!0,autoLink:!0,handleTables:!0,handleTabKey:!0,parserRules:{tags:{br:{},span:{},div:{},p:{}},classes:{}},pasteParserRulesets:null,parser:a.dom.parse,composerClassName:"wysihtml5-editor",bodyClassName:"wysihtml5-supported",useLineBreaks:!0,stylesheets:[],placeholderText:b,supportTouchDevices:!0,cleanUp:!0,contentEditableMode:!1,uneditableContainerClassname:"wysihtml5-uneditable-container",copyedFromMarking:'<meta name="copied-from" content="wysihtml5">'};a.Editor=a.lang.Dispatcher.extend({constructor:function(b,d){if(this.editableElement="string"==typeof b?document.getElementById(b):b,this.config=a.lang.object({}).merge(c).merge(d).get(),this._isCompatible=a.browser.supported(),"textarea"!=this.editableElement.nodeName.toLowerCase()&&(this.config.contentEditableMode=!0,this.config.noTextarea=!0),this.config.noTextarea||(this.textarea=new a.views.Textarea(this,this.editableElement,this.config),this.currentView=this.textarea),!this._isCompatible||!this.config.supportTouchDevices&&a.browser.isTouchDevice()){var e=this;return setTimeout(function(){e.fire("beforeload").fire("load")},0),void 0}a.dom.addClass(document.body,this.config.bodyClassName),this.composer=new a.views.Composer(this,this.editableElement,this.config),this.currentView=this.composer,"function"==typeof this.config.parser&&this._initParser(),this.on("beforeload",this.handleBeforeLoad)},handleBeforeLoad:function(){this.config.noTextarea||(this.synchronizer=new a.views.Synchronizer(this,this.textarea,this.composer)),this.config.toolbar&&(this.toolbar=new a.toolbar.Toolbar(this,this.config.toolbar,this.config.showToolbarAfterInit))},isCompatible:function(){return this._isCompatible},clear:function(){return this.currentView.clear(),this},getValue:function(a,b){return this.currentView.getValue(a,b)},setValue:function(a,b){return this.fire("unset_placeholder"),a?(this.currentView.setValue(a,b),this):this.clear()},cleanUp:function(){this.currentView.cleanUp()},focus:function(a){return this.currentView.focus(a),this},disable:function(){return this.currentView.disable(),this},enable:function(){return this.currentView.enable(),this},isEmpty:function(){return this.currentView.isEmpty()},hasPlaceholderSet:function(){return this.currentView.hasPlaceholderSet()},parse:function(b,c){var d=this.config.contentEditableMode?document:this.composer?this.composer.sandbox.getDocument():null,e=this.config.parser(b,{rules:this.config.parserRules,cleanUp:this.config.cleanUp,context:d,uneditableClass:this.config.uneditableContainerClassname,clearInternals:c});return"object"==typeof b&&a.quirks.redraw(b),e},_initParser:function(){var b,c=this;a.browser.supportsModenPaste()?this.on("paste:composer",function(d){d.preventDefault(),b=a.dom.getPastedHtml(d),b&&c._cleanAndPaste(b)}):this.on("beforepaste:composer",function(b){b.preventDefault(),a.dom.getPastedHtmlWithDiv(c.composer,function(a){a&&c._cleanAndPaste(a)})})},_cleanAndPaste:function(b){var c=a.quirks.cleanPastedHTML(b,{referenceNode:this.composer.element,rules:this.config.pasteParserRulesets||[{set:this.config.parserRules}],uneditableClass:this.config.uneditableContainerClassname});this.composer.selection.deleteContents(),this.composer.selection.insertHTML(c)}})}(wysihtml5),function(a){var b=a.dom,c="wysihtml5-command-dialog-opened",d="input, select, textarea",e="[data-wysihtml5-dialog-field]",f="data-wysihtml5-dialog-field";a.toolbar.Dialog=a.lang.Dispatcher.extend({constructor:function(a,b){this.link=a,this.container=b},_observe:function(){var e,f,g,h,i,j;if(!this._observed){for(e=this,f=function(a){var b=e._serialize();b==e.elementToChange?e.fire("edit",b):e.fire("save",b),e.hide(),a.preventDefault(),a.stopPropagation()},b.observe(e.link,"click",function(){b.hasClass(e.link,c)&&setTimeout(function(){e.hide()},0)}),b.observe(this.container,"keydown",function(b){var c=b.keyCode;c===a.ENTER_KEY&&f(b),c===a.ESCAPE_KEY&&(e.fire("cancel"),e.hide())}),b.delegate(this.container,"[data-wysihtml5-dialog-action=save]","click",f),b.delegate(this.container,"[data-wysihtml5-dialog-action=cancel]","click",function(a){e.fire("cancel"),e.hide(),a.preventDefault(),a.stopPropagation()}),g=this.container.querySelectorAll(d),h=0,i=g.length,j=function(){clearInterval(e.interval)};i>h;h++)b.observe(g[h],"change",j);this._observed=!0}},_serialize:function(){for(var a=this.elementToChange||{},b=this.container.querySelectorAll(e),c=b.length,d=0;c>d;d++)a[b[d].getAttribute(f)]=b[d].value;return a},_interpolate:function(a){for(var b,c,d,g=document.querySelector(":focus"),h=this.container.querySelectorAll(e),i=h.length,j=0;i>j;j++)b=h[j],b!==g&&(a&&"hidden"===b.type||(c=b.getAttribute(f),d=this.elementToChange&&"boolean"!=typeof this.elementToChange?this.elementToChange.getAttribute(c)||"":b.defaultValue,b.value=d))},show:function(a){if(!b.hasClass(this.link,c)){var e=this,f=this.container.querySelector(d);if(this.elementToChange=a,this._observe(),this._interpolate(),a&&(this.interval=setInterval(function(){e._interpolate(!0)},500)),b.addClass(this.link,c),this.container.style.display="",this.fire("show"),f&&!a)try{f.focus()}catch(g){}}},hide:function(){clearInterval(this.interval),this.elementToChange=null,b.removeClass(this.link,c),this.container.style.display="none",this.fire("hide")}})}(wysihtml5),function(a){var b=a.dom,c={position:"relative"},d={left:0,margin:0,opacity:0,overflow:"hidden",padding:0,position:"absolute",top:0,zIndex:1},e={cursor:"inherit",fontSize:"50px",height:"50px",marginTop:"-25px",outline:0,padding:0,position:"absolute",right:"-4px",top:"50%"},f={"x-webkit-speech":"",speech:""};a.toolbar.Speech=function(g,h){var i,j,k,l=document.createElement("input");return a.browser.supportsSpeechApiOn(l)?(i=g.editor.textarea.element.getAttribute("lang"),i&&(f.lang=i),j=document.createElement("div"),a.lang.object(d).merge({width:h.offsetWidth+"px",height:h.offsetHeight+"px"}),b.insert(l).into(j),b.insert(j).into(h),b.setStyles(e).on(l),b.setAttributes(f).on(l),b.setStyles(d).on(j),b.setStyles(c).on(h),k="onwebkitspeechchange"in l?"webkitspeechchange":"speechchange",b.observe(l,k,function(){g.execCommand("insertText",l.value),l.value=""}),b.observe(l,"click",function(a){b.hasClass(h,"wysihtml5-command-disabled")&&a.preventDefault(),a.stopPropagation()}),void 0):(h.style.display="none",void 0)}}(wysihtml5),function(a){var b="wysihtml5-command-disabled",c="wysihtml5-commands-disabled",d="wysihtml5-command-active",e="wysihtml5-action-active",f=a.dom;a.toolbar.Toolbar=Base.extend({constructor:function(f,g,h){this.editor=f,this.container="string"==typeof g?document.getElementById(g):g,this.composer=f.composer,this._getLinks("command"),this._getLinks("action"),this._observe(),h&&this.show(),null!=f.config.classNameCommandDisabled&&(b=f.config.classNameCommandDisabled),null!=f.config.classNameCommandsDisabled&&(c=f.config.classNameCommandsDisabled),null!=f.config.classNameCommandActive&&(d=f.config.classNameCommandActive),null!=f.config.classNameActionActive&&(e=f.config.classNameActionActive);for(var i=this.container.querySelectorAll("[data-wysihtml5-command=insertSpeech]"),j=i.length,k=0;j>k;k++)new a.toolbar.Speech(this,i[k])},_getLinks:function(b){for(var c,d,e,f,g,h=this[b+"Links"]=a.lang.array(this.container.querySelectorAll("[data-wysihtml5-"+b+"]")).get(),i=h.length,j=0,k=this[b+"Mapping"]={};i>j;j++)c=h[j],e=c.getAttribute("data-wysihtml5-"+b),f=c.getAttribute("data-wysihtml5-"+b+"-value"),d=this.container.querySelector("[data-wysihtml5-"+b+"-group='"+e+"']"),g=this._getDialog(c,e),k[e+":"+f]={link:c,group:d,name:e,value:f,dialog:g,state:!1}},_getDialog:function(b,c){var d,e,f=this,g=this.container.querySelector("[data-wysihtml5-dialog='"+c+"']");return g&&(d=a.toolbar["Dialog_"+c]?new a.toolbar["Dialog_"+c](b,g):new a.toolbar.Dialog(b,g),d.on("show",function(){e=f.composer.selection.getBookmark(),f.editor.fire("show:dialog",{command:c,dialogContainer:g,commandLink:b})}),d.on("save",function(a){e&&f.composer.selection.setBookmark(e),f._execCommand(c,a),f.editor.fire("save:dialog",{command:c,dialogContainer:g,commandLink:b})}),d.on("cancel",function(){f.editor.focus(!1),f.editor.fire("cancel:dialog",{command:c,dialogContainer:g,commandLink:b})})),d},execCommand:function(a,b){if(!this.commandsDisabled){var c=this.commandMapping[a+":"+b];c&&c.dialog&&!c.state?c.dialog.show():this._execCommand(a,b)}},_execCommand:function(a,b){this.editor.focus(!1),this.composer.commands.exec(a,b),this._updateLinkStates()},execAction:function(a){var b=this.editor;"change_view"===a&&b.textarea&&(b.currentView===b.textarea?b.fire("change_view","composer"):b.fire("change_view","textarea")),"showSource"==a&&b.fire("showSource")},_observe:function(){for(var a=this,b=this.editor,d=this.container,e=this.commandLinks.concat(this.actionLinks),g=e.length,h=0;g>h;h++)"A"===e[h].nodeName?f.setAttributes({href:"javascript:;",unselectable:"on"}).on(e[h]):f.setAttributes({unselectable:"on"}).on(e[h]);f.delegate(d,"[data-wysihtml5-command], [data-wysihtml5-action]","mousedown",function(a){a.preventDefault()}),f.delegate(d,"[data-wysihtml5-command]","click",function(b){var c=this,d=c.getAttribute("data-wysihtml5-command"),e=c.getAttribute("data-wysihtml5-command-value");a.execCommand(d,e),b.preventDefault()}),f.delegate(d,"[data-wysihtml5-action]","click",function(b){var c=this.getAttribute("data-wysihtml5-action");a.execAction(c),b.preventDefault()}),b.on("interaction:composer",function(){a._updateLinkStates()}),b.on("focus:composer",function(){a.bookmark=null}),this.editor.config.handleTables&&(b.on("tableselect:composer",function(){a.container.querySelectorAll('[data-wysihtml5-hiddentools="table"]')[0].style.display=""}),b.on("tableunselect:composer",function(){a.container.querySelectorAll('[data-wysihtml5-hiddentools="table"]')[0].style.display="none"})),b.on("change_view",function(e){b.textarea&&setTimeout(function(){a.commandsDisabled="composer"!==e,a._updateLinkStates(),a.commandsDisabled?f.addClass(d,c):f.removeClass(d,c)},0)})},_updateLinkStates:function(){var c,g,h,i,j=this.commandMapping,k=this.actionMapping;for(c in j)i=j[c],this.commandsDisabled?(g=!1,f.removeClass(i.link,d),i.group&&f.removeClass(i.group,d),i.dialog&&i.dialog.hide()):(g=this.composer.commands.state(i.name,i.value),f.removeClass(i.link,b),i.group&&f.removeClass(i.group,b)),i.state!==g&&(i.state=g,g?(f.addClass(i.link,d),i.group&&f.addClass(i.group,d),i.dialog&&("object"==typeof g||a.lang.object(g).isArray()?(!i.dialog.multiselect&&a.lang.object(g).isArray()&&(g=1===g.length?g[0]:!0,i.state=g),i.dialog.show(g)):i.dialog.hide())):(f.removeClass(i.link,d),i.group&&f.removeClass(i.group,d),i.dialog&&i.dialog.hide()));for(c in k)h=k[c],"change_view"===h.name&&(h.state=this.editor.currentView===this.editor.textarea,h.state?f.addClass(h.link,e):f.removeClass(h.link,e))},show:function(){this.container.style.display=""},hide:function(){this.container.style.display="none"}})}(wysihtml5),function(a){a.toolbar.Dialog_createTable=a.toolbar.Dialog.extend({show:function(a){this.base(a)}})}(wysihtml5),function(a){var b=(a.dom,"[data-wysihtml5-dialog-field]"),c="data-wysihtml5-dialog-field";a.toolbar.Dialog_foreColorStyle=a.toolbar.Dialog.extend({multiselect:!0,_serialize:function(){for(var a={},d=this.container.querySelectorAll(b),e=d.length,f=0;e>f;f++)a[d[f].getAttribute(c)]=d[f].value;return a},_interpolate:function(d){for(var e,f=document.querySelector(":focus"),g=this.container.querySelectorAll(b),h=g.length,i=0,j=this.elementToChange?a.lang.object(this.elementToChange).isArray()?this.elementToChange[0]:this.elementToChange:null,k=j?j.getAttribute("style"):null,l=k?a.quirks.styleParser.parseColor(k,"color"):null;h>i;i++)e=g[i],e!==f&&(d&&"hidden"===e.type||"color"===e.getAttribute(c)&&(e.value=l?l[3]&&1!=l[3]?"rgba("+l[0]+","+l[1]+","+l[2]+","+l[3]+");":"rgb("+l[0]+","+l[1]+","+l[2]+");":"rgb(0,0,0);"))}})}(wysihtml5),function(a){a.dom;a.toolbar.Dialog_fontSizeStyle=a.toolbar.Dialog.extend({multiselect:!0,_serialize:function(){return{size:this.container.querySelector('[data-wysihtml5-dialog-field="size"]').value}},_interpolate:function(){var b=document.querySelector(":focus"),c=this.container.querySelector("[data-wysihtml5-dialog-field='size']"),d=this.elementToChange?a.lang.object(this.elementToChange).isArray()?this.elementToChange[0]:this.elementToChange:null,e=d?d.getAttribute("style"):null,f=e?a.quirks.styleParser.parseFontSize(e):null;c&&c!==b&&f&&!/^\s*$/.test(f)&&(c.value=f)}})}(wysihtml5),Handlebars=function(){var a=function(){"use strict";function a(a){this.string=a}var b;return a.prototype.toString=function(){return""+this.string},b=a}(),b=function(a){"use strict";function b(a){return k[a]||"&amp;"}function c(a,b){for(var c in b)Object.prototype.hasOwnProperty.call(b,c)&&(a[c]=b[c])}function d(a){return a instanceof j?""+a:a||0===a?(a=""+a,m.test(a)?a.replace(l,b):a):""}function e(a){return a||0===a?h(a)&&0===a.length?!0:!1:!0}var f,g,h,i={},j=a,k={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},l=/[&<>"'`]/g,m=/[&<>"'`]/;return i.extend=c,f=Object.prototype.toString,i.toString=f,g=function(a){return"function"==typeof a},g(/x/)&&(g=function(a){return"function"==typeof a&&"[object Function]"===f.call(a)}),i.isFunction=g,h=Array.isArray||function(a){return a&&"object"==typeof a?"[object Array]"===f.call(a):!1},i.isArray=h,i.escapeExpression=d,i.isEmpty=e,i}(a),c=function(){"use strict";function a(a,b){var d,e,f;for(b&&b.firstLine&&(d=b.firstLine,a+=" - "+d+":"+b.firstColumn),e=Error.prototype.constructor.call(this,a),f=0;f<c.length;f++)this[c[f]]=e[c[f]];d&&(this.lineNumber=d,this.column=b.firstColumn)}var b,c=["description","fileName","lineNumber","message","name","number","stack"];return a.prototype=Error(),b=a}(),d=function(a,b){"use strict";function c(a,b){this.helpers=a||{},this.partials=b||{},d(this)}function d(a){a.registerHelper("helperMissing",function(a){if(2===arguments.length)return void 0;throw new p("Missing helper: '"+a+"'")}),a.registerHelper("blockHelperMissing",function(b,c){var d=c.inverse||function(){},e=c.fn;return i(b)&&(b=b.call(this)),b===!0?e(this):b===!1||null==b?d(this):h(b)?b.length>0?a.helpers.each(b,c):d(this):e(b)}),a.registerHelper("each",function(a,b){var c,d,e,f=b.fn,g=b.inverse,j=0,k="";if(i(a)&&(a=a.call(this)),b.data&&(c=m(b.data)),a&&"object"==typeof a)if(h(a))for(d=a.length;d>j;j++)c&&(c.index=j,c.first=0===j,c.last=j===a.length-1),k+=f(a[j],{data:c});else for(e in a)a.hasOwnProperty(e)&&(c&&(c.key=e,c.index=j,c.first=0===j),k+=f(a[e],{data:c}),j++);return 0===j&&(k=g(this)),k}),a.registerHelper("if",function(a,b){return i(a)&&(a=a.call(this)),!b.hash.includeZero&&!a||o.isEmpty(a)?b.inverse(this):b.fn(this)}),a.registerHelper("unless",function(b,c){return a.helpers["if"].call(this,b,{fn:c.inverse,inverse:c.fn,hash:c.hash})}),a.registerHelper("with",function(a,b){return i(a)&&(a=a.call(this)),o.isEmpty(a)?void 0:b.fn(a)}),a.registerHelper("log",function(b,c){var d=c.data&&null!=c.data.level?parseInt(c.data.level,10):1;a.log(d,b)})}function e(a,b){l.log(a,b)}var f,g,h,i,j,k,l,m,n={},o=a,p=b,q="1.3.0";return n.VERSION=q,f=4,n.COMPILER_REVISION=f,g={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:">= 1.0.0"},n.REVISION_CHANGES=g,h=o.isArray,i=o.isFunction,j=o.toString,k="[object Object]",n.HandlebarsEnvironment=c,c.prototype={constructor:c,logger:l,log:e,registerHelper:function(a,b,c){if(j.call(a)===k){if(c||b)throw new p("Arg not supported with multiple helpers");o.extend(this.helpers,a)}else c&&(b.not=c),this.helpers[a]=b},registerPartial:function(a,b){j.call(a)===k?o.extend(this.partials,a):this.partials[a]=b}},l={methodMap:{0:"debug",1:"info",2:"warn",3:"error"},DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,log:function(a,b){if(l.level<=a){var c=l.methodMap[a];"undefined"!=typeof console&&console[c]&&console[c].call(console,b)}}},n.logger=l,n.log=e,m=function(a){var b={};return o.extend(b,a),b},n.createFrame=m,n}(b,c),e=function(a,b,c){"use strict";function d(a){var b,c,d=a&&a[0]||1,e=m;if(d!==e){if(e>d)throw b=n[e],c=n[d],new l("Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version ("+b+") or downgrade your runtime to an older version ("+c+").");throw new l("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version ("+a[1]+").")}}function e(a,b){if(!b)throw new l("No environment passed to template");var c=function(a,c,d,e,f,g){var h,i=b.VM.invokePartial.apply(this,arguments);if(null!=i)return i;if(b.compile)return h={helpers:e,partials:f,data:g},f[c]=b.compile(a,{data:void 0!==g},b),f[c](d,h);throw new l("The partial "+c+" could not be compiled when running in runtime-only mode")},d={escapeExpression:k.escapeExpression,invokePartial:c,programs:[],program:function(a,b,c){var d=this.programs[a];return c?d=g(a,b,c):d||(d=this.programs[a]=g(a,b)),d},merge:function(a,b){var c=a||b;return a&&b&&a!==b&&(c={},k.extend(c,b),k.extend(c,a)),c},programWithDepth:b.VM.programWithDepth,noop:b.VM.noop,compilerInfo:null};return function(c,e){var f,g,h,i;return e=e||{},h=e.partial?e:b,e.partial||(f=e.helpers,g=e.partials),i=a.call(d,h,c,f,g,e.data),e.partial||b.VM.checkRevision(d.compilerInfo),i}}function f(a,b,c){var d=Array.prototype.slice.call(arguments,3),e=function(a,e){return e=e||{},b.apply(this,[a,e.data||c].concat(d))};return e.program=a,e.depth=d.length,e}function g(a,b,c){var d=function(a,d){return d=d||{},b(a,d.data||c)};return d.program=a,d.depth=0,d}function h(a,b,c,d,e,f){var g={partial:!0,helpers:d,partials:e,data:f};if(void 0===a)throw new l("The partial "+b+" could not be found");return a instanceof Function?a(c,g):void 0}function i(){return""}var j={},k=a,l=b,m=c.COMPILER_REVISION,n=c.REVISION_CHANGES;return j.checkRevision=d,j.template=e,j.programWithDepth=f,j.program=g,j.invokePartial=h,j.noop=i,j}(b,c,d),f=function(a,b,c,d,e){"use strict";var f,g=a,h=b,i=c,j=d,k=e,l=function(){var a=new g.HandlebarsEnvironment;return j.extend(a,g),a.SafeString=h,a.Exception=i,a.Utils=j,a.VM=k,a.template=function(b){return k.template(b,a)},a},m=l();return m.create=l,f=m}(d,a,c,b,e);return f}(),this.wysihtml5=this.wysihtml5||{},this.wysihtml5.tpl=this.wysihtml5.tpl||{},this.wysihtml5.tpl.blockquote=Handlebars.template(function(a,b,c,d,e){function f(a){var b,c="";return c+="btn-"+l((b=a&&a.options,b=null==b||b===!1?b:b.toolbar,b=null==b||b===!1?b:b.size,typeof b===k?b.apply(a):b)),c}function g(){return' \n      <span class="fa fa-quote-left"></span>\n    '}function h(){return'\n      <span class="glyphicon glyphicon-quote"></span>\n    '}this.compilerInfo=[4,">= 1.0.0"],c=this.merge(c,a.helpers),e=e||{};var i,j="",k="function",l=this.escapeExpression,m=this;return j+='<li>\n  <a class="btn ',i=c["if"].call(b,(i=b&&b.options,i=null==i||i===!1?i:i.toolbar,null==i||i===!1?i:i.size),{hash:{},inverse:m.noop,fn:m.program(1,f,e),data:e}),(i||0===i)&&(j+=i),j+=' btn-default" data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="blockquote" data-wysihtml5-display-format-name="false" tabindex="-1">\n    ',i=c["if"].call(b,(i=b&&b.options,i=null==i||i===!1?i:i.toolbar,null==i||i===!1?i:i.fa),{hash:{},inverse:m.program(5,h,e),fn:m.program(3,g,e),data:e}),(i||0===i)&&(j+=i),j+="\n  </a>\n</li>\n",j}),this.wysihtml5.tpl.color=Handlebars.template(function(a,b,c,d,e){function f(a){var b,c="";return c+="btn-"+j((b=a&&a.options,b=null==b||b===!1?b:b.toolbar,b=null==b||b===!1?b:b.size,typeof b===i?b.apply(a):b)),c}this.compilerInfo=[4,">= 1.0.0"],c=this.merge(c,a.helpers),e=e||{};var g,h="",i="function",j=this.escapeExpression,k=this;return h+='<li class="dropdown">\n  <a class="btn btn-default dropdown-toggle ',g=c["if"].call(b,(g=b&&b.options,g=null==g||g===!1?g:g.toolbar,null==g||g===!1?g:g.size),{hash:{},inverse:k.noop,fn:k.program(1,f,e),data:e}),(g||0===g)&&(h+=g),h+='" data-toggle="dropdown" tabindex="-1">\n    <span class="current-color">'+j((g=b&&b.locale,g=null==g||g===!1?g:g.colours,g=null==g||g===!1?g:g.black,typeof g===i?g.apply(b):g))+'</span>\n    <b class="caret"></b>\n  </a>\n  <ul class="dropdown-menu">\n    <li><div class="wysihtml5-colors" data-wysihtml5-command-value="black"></div><a class="wysihtml5-colors-title" data-wysihtml5-command="foreColor" data-wysihtml5-command-value="black">'+j((g=b&&b.locale,g=null==g||g===!1?g:g.colours,g=null==g||g===!1?g:g.black,typeof g===i?g.apply(b):g))+'</a></li>\n    <li><div class="wysihtml5-colors" data-wysihtml5-command-value="silver"></div><a class="wysihtml5-colors-title" data-wysihtml5-command="foreColor" data-wysihtml5-command-value="silver">'+j((g=b&&b.locale,g=null==g||g===!1?g:g.colours,g=null==g||g===!1?g:g.silver,typeof g===i?g.apply(b):g))+'</a></li>\n    <li><div class="wysihtml5-colors" data-wysihtml5-command-value="gray"></div><a class="wysihtml5-colors-title" data-wysihtml5-command="foreColor" data-wysihtml5-command-value="gray">'+j((g=b&&b.locale,g=null==g||g===!1?g:g.colours,g=null==g||g===!1?g:g.gray,typeof g===i?g.apply(b):g))+'</a></li>\n    <li><div class="wysihtml5-colors" data-wysihtml5-command-value="maroon"></div><a class="wysihtml5-colors-title" data-wysihtml5-command="foreColor" data-wysihtml5-command-value="maroon">'+j((g=b&&b.locale,g=null==g||g===!1?g:g.colours,g=null==g||g===!1?g:g.maroon,typeof g===i?g.apply(b):g))+'</a></li>\n    <li><div class="wysihtml5-colors" data-wysihtml5-command-value="red"></div><a class="wysihtml5-colors-title" data-wysihtml5-command="foreColor" data-wysihtml5-command-value="red">'+j((g=b&&b.locale,g=null==g||g===!1?g:g.colours,g=null==g||g===!1?g:g.red,typeof g===i?g.apply(b):g))+'</a></li>\n    <li><div class="wysihtml5-colors" data-wysihtml5-command-value="purple"></div><a class="wysihtml5-colors-title" data-wysihtml5-command="foreColor" data-wysihtml5-command-value="purple">'+j((g=b&&b.locale,g=null==g||g===!1?g:g.colours,g=null==g||g===!1?g:g.purple,typeof g===i?g.apply(b):g))+'</a></li>\n    <li><div class="wysihtml5-colors" data-wysihtml5-command-value="green"></div><a class="wysihtml5-colors-title" data-wysihtml5-command="foreColor" data-wysihtml5-command-value="green">'+j((g=b&&b.locale,g=null==g||g===!1?g:g.colours,g=null==g||g===!1?g:g.green,typeof g===i?g.apply(b):g))+'</a></li>\n    <li><div class="wysihtml5-colors" data-wysihtml5-command-value="olive"></div><a class="wysihtml5-colors-title" data-wysihtml5-command="foreColor" data-wysihtml5-command-value="olive">'+j((g=b&&b.locale,g=null==g||g===!1?g:g.colours,g=null==g||g===!1?g:g.olive,typeof g===i?g.apply(b):g))+'</a></li>\n    <li><div class="wysihtml5-colors" data-wysihtml5-command-value="navy"></div><a class="wysihtml5-colors-title" data-wysihtml5-command="foreColor" data-wysihtml5-command-value="navy">'+j((g=b&&b.locale,g=null==g||g===!1?g:g.colours,g=null==g||g===!1?g:g.navy,typeof g===i?g.apply(b):g))+'</a></li>\n    <li><div class="wysihtml5-colors" data-wysihtml5-command-value="blue"></div><a class="wysihtml5-colors-title" data-wysihtml5-command="foreColor" data-wysihtml5-command-value="blue">'+j((g=b&&b.locale,g=null==g||g===!1?g:g.colours,g=null==g||g===!1?g:g.blue,typeof g===i?g.apply(b):g))+'</a></li>\n    <li><div class="wysihtml5-colors" data-wysihtml5-command-value="orange"></div><a class="wysihtml5-colors-title" data-wysihtml5-command="foreColor" data-wysihtml5-command-value="orange">'+j((g=b&&b.locale,g=null==g||g===!1?g:g.colours,g=null==g||g===!1?g:g.orange,typeof g===i?g.apply(b):g))+"</a></li>\n  </ul>\n</li>\n",h}),this.wysihtml5.tpl.emphasis=Handlebars.template(function(a,b,c,d,e){function f(a){var b,c="";return c+="btn-"+k((b=a&&a.options,b=null==b||b===!1?b:b.toolbar,b=null==b||b===!1?b:b.size,typeof b===j?b.apply(a):b)),c}function g(a,b){var d,e="";return e+='\n    <a class="btn ',d=c["if"].call(a,(d=a&&a.options,d=null==d||d===!1?d:d.toolbar,null==d||d===!1?d:d.size),{hash:{},inverse:l.noop,fn:l.program(1,f,b),data:b}),(d||0===d)&&(e+=d),e+=' btn-default" data-wysihtml5-command="small" title="CTRL+S" tabindex="-1">'+k((d=a&&a.locale,d=null==d||d===!1?d:d.emphasis,d=null==d||d===!1?d:d.small,typeof d===j?d.apply(a):d))+"</a>\n    ",e}this.compilerInfo=[4,">= 1.0.0"],c=this.merge(c,a.helpers),e=e||{};var h,i="",j="function",k=this.escapeExpression,l=this;return i+='<li>\n  <div class="btn-group">\n    <a class="btn ',h=c["if"].call(b,(h=b&&b.options,h=null==h||h===!1?h:h.toolbar,null==h||h===!1?h:h.size),{hash:{},inverse:l.noop,fn:l.program(1,f,e),data:e}),(h||0===h)&&(i+=h),i+=' btn-default" data-wysihtml5-command="bold" title="CTRL+B" tabindex="-1">'+k((h=b&&b.locale,h=null==h||h===!1?h:h.emphasis,h=null==h||h===!1?h:h.bold,typeof h===j?h.apply(b):h))+'</a>\n    <a class="btn ',h=c["if"].call(b,(h=b&&b.options,h=null==h||h===!1?h:h.toolbar,null==h||h===!1?h:h.size),{hash:{},inverse:l.noop,fn:l.program(1,f,e),data:e}),(h||0===h)&&(i+=h),i+=' btn-default" data-wysihtml5-command="italic" title="CTRL+I" tabindex="-1">'+k((h=b&&b.locale,h=null==h||h===!1?h:h.emphasis,h=null==h||h===!1?h:h.italic,typeof h===j?h.apply(b):h))+'</a>\n    <a class="btn ',h=c["if"].call(b,(h=b&&b.options,h=null==h||h===!1?h:h.toolbar,null==h||h===!1?h:h.size),{hash:{},inverse:l.noop,fn:l.program(1,f,e),data:e}),(h||0===h)&&(i+=h),i+=' btn-default" data-wysihtml5-command="underline" title="CTRL+U" tabindex="-1">'+k((h=b&&b.locale,h=null==h||h===!1?h:h.emphasis,h=null==h||h===!1?h:h.underline,typeof h===j?h.apply(b):h))+"</a>\n    ",h=c["if"].call(b,(h=b&&b.options,h=null==h||h===!1?h:h.toolbar,h=null==h||h===!1?h:h.emphasis,null==h||h===!1?h:h.small),{hash:{},inverse:l.noop,fn:l.program(3,g,e),data:e}),(h||0===h)&&(i+=h),i+="\n  </div>\n</li>\n",i
  }),this.wysihtml5.tpl["font-styles"]=Handlebars.template(function(a,b,c,d,e){function f(a){var b,c="";return c+="btn-"+l((b=a&&a.options,b=null==b||b===!1?b:b.toolbar,b=null==b||b===!1?b:b.size,typeof b===k?b.apply(a):b)),c}function g(){return'\n      <span class="fa fa-font"></span>\n    '}function h(){return'\n      <span class="glyphicon glyphicon-font"></span>\n    '}this.compilerInfo=[4,">= 1.0.0"],c=this.merge(c,a.helpers),e=e||{};var i,j="",k="function",l=this.escapeExpression,m=this;return j+='<li class="dropdown">\n  <a class="btn btn-default dropdown-toggle ',i=c["if"].call(b,(i=b&&b.options,i=null==i||i===!1?i:i.toolbar,null==i||i===!1?i:i.size),{hash:{},inverse:m.noop,fn:m.program(1,f,e),data:e}),(i||0===i)&&(j+=i),j+='" data-toggle="dropdown">\n    ',i=c["if"].call(b,(i=b&&b.options,i=null==i||i===!1?i:i.toolbar,null==i||i===!1?i:i.fa),{hash:{},inverse:m.program(5,h,e),fn:m.program(3,g,e),data:e}),(i||0===i)&&(j+=i),j+='\n    <span class="current-font">'+l((i=b&&b.locale,i=null==i||i===!1?i:i.font_styles,i=null==i||i===!1?i:i.normal,typeof i===k?i.apply(b):i))+'</span>\n    <b class="caret"></b>\n  </a>\n  <ul class="dropdown-menu">\n    <li><a data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="p" tabindex="-1">'+l((i=b&&b.locale,i=null==i||i===!1?i:i.font_styles,i=null==i||i===!1?i:i.normal,typeof i===k?i.apply(b):i))+'</a></li>\n    <li><a data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="h1" tabindex="-1">'+l((i=b&&b.locale,i=null==i||i===!1?i:i.font_styles,i=null==i||i===!1?i:i.h1,typeof i===k?i.apply(b):i))+'</a></li>\n    <li><a data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="h2" tabindex="-1">'+l((i=b&&b.locale,i=null==i||i===!1?i:i.font_styles,i=null==i||i===!1?i:i.h2,typeof i===k?i.apply(b):i))+'</a></li>\n    <li><a data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="h3" tabindex="-1">'+l((i=b&&b.locale,i=null==i||i===!1?i:i.font_styles,i=null==i||i===!1?i:i.h3,typeof i===k?i.apply(b):i))+'</a></li>\n    <li><a data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="h4" tabindex="-1">'+l((i=b&&b.locale,i=null==i||i===!1?i:i.font_styles,i=null==i||i===!1?i:i.h4,typeof i===k?i.apply(b):i))+'</a></li>\n    <li><a data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="h5" tabindex="-1">'+l((i=b&&b.locale,i=null==i||i===!1?i:i.font_styles,i=null==i||i===!1?i:i.h5,typeof i===k?i.apply(b):i))+'</a></li>\n    <li><a data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="h6" tabindex="-1">'+l((i=b&&b.locale,i=null==i||i===!1?i:i.font_styles,i=null==i||i===!1?i:i.h6,typeof i===k?i.apply(b):i))+"</a></li>\n  </ul>\n</li>\n",j}),this.wysihtml5.tpl.html=Handlebars.template(function(a,b,c,d,e){function f(a){var b,c="";return c+="btn-"+l((b=a&&a.options,b=null==b||b===!1?b:b.toolbar,b=null==b||b===!1?b:b.size,typeof b===k?b.apply(a):b)),c}function g(){return'\n        <span class="fa fa-pencil"></span>\n      '}function h(){return'\n        <span class="glyphicon glyphicon-pencil"></span>\n      '}this.compilerInfo=[4,">= 1.0.0"],c=this.merge(c,a.helpers),e=e||{};var i,j="",k="function",l=this.escapeExpression,m=this;return j+='<li>\n  <div class="btn-group">\n    <a class="btn ',i=c["if"].call(b,(i=b&&b.options,i=null==i||i===!1?i:i.toolbar,null==i||i===!1?i:i.size),{hash:{},inverse:m.noop,fn:m.program(1,f,e),data:e}),(i||0===i)&&(j+=i),j+=' btn-default" data-wysihtml5-action="change_view" title="'+l((i=b&&b.locale,i=null==i||i===!1?i:i.html,i=null==i||i===!1?i:i.edit,typeof i===k?i.apply(b):i))+'" tabindex="-1">\n      ',i=c["if"].call(b,(i=b&&b.options,i=null==i||i===!1?i:i.toolbar,null==i||i===!1?i:i.fa),{hash:{},inverse:m.program(5,h,e),fn:m.program(3,g,e),data:e}),(i||0===i)&&(j+=i),j+="\n    </a>\n  </div>\n</li>\n",j}),this.wysihtml5.tpl.image=Handlebars.template(function(a,b,c,d,e){function f(){return"modal-sm"}function g(a){var b,c="";return c+="btn-"+m((b=a&&a.options,b=null==b||b===!1?b:b.toolbar,b=null==b||b===!1?b:b.size,typeof b===l?b.apply(a):b)),c}function h(){return'\n      <span class="fa fa-file-image-o"></span>\n    '}function i(){return'\n      <span class="glyphicon glyphicon-picture"></span>\n    '}this.compilerInfo=[4,">= 1.0.0"],c=this.merge(c,a.helpers),e=e||{};var j,k="",l="function",m=this.escapeExpression,n=this;return k+='<li>\n  <div class="bootstrap-wysihtml5-insert-image-modal modal fade" data-wysihtml5-dialog="insertImage">\n    <div class="modal-dialog ',j=c["if"].call(b,(j=b&&b.options,j=null==j||j===!1?j:j.toolbar,null==j||j===!1?j:j.smallmodals),{hash:{},inverse:n.noop,fn:n.program(1,f,e),data:e}),(j||0===j)&&(k+=j),k+='">\n      <div class="modal-content">\n        <div class="modal-header">\n          <a class="close" data-dismiss="modal">&times;</a>\n          <h3>'+m((j=b&&b.locale,j=null==j||j===!1?j:j.image,j=null==j||j===!1?j:j.insert,typeof j===l?j.apply(b):j))+'</h3>\n        </div>\n        <div class="modal-body">\n          <div class="form-group">\n            <input value="http://" class="bootstrap-wysihtml5-insert-image-url form-control" data-wysihtml5-dialog-field="src">\n          </div> \n        </div>\n        <div class="modal-footer">\n          <a class="btn btn-default" data-dismiss="modal" data-wysihtml5-dialog-action="cancel" href="#">'+m((j=b&&b.locale,j=null==j||j===!1?j:j.image,j=null==j||j===!1?j:j.cancel,typeof j===l?j.apply(b):j))+'</a>\n          <a class="btn btn-primary" data-dismiss="modal"  data-wysihtml5-dialog-action="save" href="#">'+m((j=b&&b.locale,j=null==j||j===!1?j:j.image,j=null==j||j===!1?j:j.insert,typeof j===l?j.apply(b):j))+'</a>\n        </div>\n      </div>\n    </div>\n  </div>\n  <a class="btn ',j=c["if"].call(b,(j=b&&b.options,j=null==j||j===!1?j:j.toolbar,null==j||j===!1?j:j.size),{hash:{},inverse:n.noop,fn:n.program(3,g,e),data:e}),(j||0===j)&&(k+=j),k+=' btn-default" data-wysihtml5-command="insertImage" title="'+m((j=b&&b.locale,j=null==j||j===!1?j:j.image,j=null==j||j===!1?j:j.insert,typeof j===l?j.apply(b):j))+'" tabindex="-1">\n    ',j=c["if"].call(b,(j=b&&b.options,j=null==j||j===!1?j:j.toolbar,null==j||j===!1?j:j.fa),{hash:{},inverse:n.program(7,i,e),fn:n.program(5,h,e),data:e}),(j||0===j)&&(k+=j),k+="\n  </a>\n</li>\n",k}),this.wysihtml5.tpl.link=Handlebars.template(function(a,b,c,d,e){function f(){return"modal-sm"}function g(a){var b,c="";return c+="btn-"+m((b=a&&a.options,b=null==b||b===!1?b:b.toolbar,b=null==b||b===!1?b:b.size,typeof b===l?b.apply(a):b)),c}function h(){return'\n      <span class="fa fa-share-square-o"></span>\n    '}function i(){return'\n      <span class="glyphicon glyphicon-share"></span>\n    '}this.compilerInfo=[4,">= 1.0.0"],c=this.merge(c,a.helpers),e=e||{};var j,k="",l="function",m=this.escapeExpression,n=this;return k+='<li>\n  <div class="bootstrap-wysihtml5-insert-link-modal modal fade" data-wysihtml5-dialog="createLink">\n    <div class="modal-dialog ',j=c["if"].call(b,(j=b&&b.options,j=null==j||j===!1?j:j.toolbar,null==j||j===!1?j:j.smallmodals),{hash:{},inverse:n.noop,fn:n.program(1,f,e),data:e}),(j||0===j)&&(k+=j),k+='">\n      <div class="modal-content">\n        <div class="modal-header">\n          <a class="close" data-dismiss="modal">&times;</a>\n          <h3>'+m((j=b&&b.locale,j=null==j||j===!1?j:j.link,j=null==j||j===!1?j:j.insert,typeof j===l?j.apply(b):j))+'</h3>\n        </div>\n        <div class="modal-body">\n          <div class="form-group">\n            <input value="http://" class="bootstrap-wysihtml5-insert-link-url form-control" data-wysihtml5-dialog-field="href">\n          </div> \n          <div class="checkbox">\n            <label> \n              <input type="checkbox" class="bootstrap-wysihtml5-insert-link-target" checked>'+m((j=b&&b.locale,j=null==j||j===!1?j:j.link,j=null==j||j===!1?j:j.target,typeof j===l?j.apply(b):j))+'\n            </label>\n          </div>\n        </div>\n        <div class="modal-footer">\n          <a class="btn btn-default" data-dismiss="modal" data-wysihtml5-dialog-action="cancel" href="#">'+m((j=b&&b.locale,j=null==j||j===!1?j:j.link,j=null==j||j===!1?j:j.cancel,typeof j===l?j.apply(b):j))+'</a>\n          <a href="#" class="btn btn-primary" data-dismiss="modal" data-wysihtml5-dialog-action="save">'+m((j=b&&b.locale,j=null==j||j===!1?j:j.link,j=null==j||j===!1?j:j.insert,typeof j===l?j.apply(b):j))+'</a>\n        </div>\n      </div>\n    </div>\n  </div>\n  <a class="btn ',j=c["if"].call(b,(j=b&&b.options,j=null==j||j===!1?j:j.toolbar,null==j||j===!1?j:j.size),{hash:{},inverse:n.noop,fn:n.program(3,g,e),data:e}),(j||0===j)&&(k+=j),k+=' btn-default" data-wysihtml5-command="createLink" title="'+m((j=b&&b.locale,j=null==j||j===!1?j:j.link,j=null==j||j===!1?j:j.insert,typeof j===l?j.apply(b):j))+'" tabindex="-1">\n    ',j=c["if"].call(b,(j=b&&b.options,j=null==j||j===!1?j:j.toolbar,null==j||j===!1?j:j.fa),{hash:{},inverse:n.program(7,i,e),fn:n.program(5,h,e),data:e}),(j||0===j)&&(k+=j),k+="\n  </a>\n</li>\n",k}),this.wysihtml5.tpl.lists=Handlebars.template(function(a,b,c,d,e){function f(a){var b,c="";return c+="btn-"+r((b=a&&a.options,b=null==b||b===!1?b:b.toolbar,b=null==b||b===!1?b:b.size,typeof b===q?b.apply(a):b)),c}function g(){return'\n      <span class="fa fa-list-ul"></span>\n    '}function h(){return'\n      <span class="glyphicon glyphicon-list"></span>\n    '}function i(){return'\n      <span class="fa fa-list-ol"></span>\n    '}function j(){return'\n      <span class="glyphicon glyphicon-th-list"></span>\n    '}function k(){return'\n      <span class="fa fa-outdent"></span>\n    '}function l(){return'\n      <span class="glyphicon glyphicon-indent-right"></span>\n    '}function m(){return'\n      <span class="fa fa-indent"></span>\n    '}function n(){return'\n      <span class="glyphicon glyphicon-indent-left"></span>\n    '}this.compilerInfo=[4,">= 1.0.0"],c=this.merge(c,a.helpers),e=e||{};var o,p="",q="function",r=this.escapeExpression,s=this;return p+='<li>\n  <div class="btn-group">\n    <a class="btn ',o=c["if"].call(b,(o=b&&b.options,o=null==o||o===!1?o:o.toolbar,null==o||o===!1?o:o.size),{hash:{},inverse:s.noop,fn:s.program(1,f,e),data:e}),(o||0===o)&&(p+=o),p+=' btn-default" data-wysihtml5-command="insertUnorderedList" title="'+r((o=b&&b.locale,o=null==o||o===!1?o:o.lists,o=null==o||o===!1?o:o.unordered,typeof o===q?o.apply(b):o))+'" tabindex="-1">\n    ',o=c["if"].call(b,(o=b&&b.options,o=null==o||o===!1?o:o.toolbar,null==o||o===!1?o:o.fa),{hash:{},inverse:s.program(5,h,e),fn:s.program(3,g,e),data:e}),(o||0===o)&&(p+=o),p+='\n    </a>\n    <a class="btn ',o=c["if"].call(b,(o=b&&b.options,o=null==o||o===!1?o:o.toolbar,null==o||o===!1?o:o.size),{hash:{},inverse:s.noop,fn:s.program(1,f,e),data:e}),(o||0===o)&&(p+=o),p+=' btn-default" data-wysihtml5-command="insertOrderedList" title="'+r((o=b&&b.locale,o=null==o||o===!1?o:o.lists,o=null==o||o===!1?o:o.ordered,typeof o===q?o.apply(b):o))+'" tabindex="-1">\n    ',o=c["if"].call(b,(o=b&&b.options,o=null==o||o===!1?o:o.toolbar,null==o||o===!1?o:o.fa),{hash:{},inverse:s.program(9,j,e),fn:s.program(7,i,e),data:e}),(o||0===o)&&(p+=o),p+='\n    </a>\n    <a class="btn ',o=c["if"].call(b,(o=b&&b.options,o=null==o||o===!1?o:o.toolbar,null==o||o===!1?o:o.size),{hash:{},inverse:s.noop,fn:s.program(1,f,e),data:e}),(o||0===o)&&(p+=o),p+=' btn-default" data-wysihtml5-command="Outdent" title="'+r((o=b&&b.locale,o=null==o||o===!1?o:o.lists,o=null==o||o===!1?o:o.outdent,typeof o===q?o.apply(b):o))+'" tabindex="-1">\n    ',o=c["if"].call(b,(o=b&&b.options,o=null==o||o===!1?o:o.toolbar,null==o||o===!1?o:o.fa),{hash:{},inverse:s.program(13,l,e),fn:s.program(11,k,e),data:e}),(o||0===o)&&(p+=o),p+='\n    </a>\n    <a class="btn ',o=c["if"].call(b,(o=b&&b.options,o=null==o||o===!1?o:o.toolbar,null==o||o===!1?o:o.size),{hash:{},inverse:s.noop,fn:s.program(1,f,e),data:e}),(o||0===o)&&(p+=o),p+=' btn-default" data-wysihtml5-command="Indent" title="'+r((o=b&&b.locale,o=null==o||o===!1?o:o.lists,o=null==o||o===!1?o:o.indent,typeof o===q?o.apply(b):o))+'" tabindex="-1">\n    ',o=c["if"].call(b,(o=b&&b.options,o=null==o||o===!1?o:o.toolbar,null==o||o===!1?o:o.fa),{hash:{},inverse:s.program(17,n,e),fn:s.program(15,m,e),data:e}),(o||0===o)&&(p+=o),p+="\n    </a>\n  </div>\n</li>\n",p}),function(a){"use strict";"function"==typeof define&&define.amd?define("bootstrap.wysihtml5",["jquery","wysihtml5","bootstrap","bootstrap.wysihtml5.templates","bootstrap.wysihtml5.commands"],a):a(jQuery,wysihtml5)}(function(a,b){"use strict";var c=function(a,b){var c,d,e,f=function(a,c,d){return b.tpl[a]?b.tpl[a]({locale:c,options:d}):void 0},g=function(c,e){var f,g;this.el=c,f=a.extend(!0,{},d,e);for(g in f.customTemplates)f.customTemplates.hasOwnProperty(g)&&(b.tpl[g]=f.customTemplates[g]);this.toolbar=this.createToolbar(c,f),this.editor=this.createEditor(f)};g.prototype={constructor:g,createEditor:function(b){b=b||{},b=a.extend(!0,{},b),b.toolbar=this.toolbar[0],this.initializeEditor(this.el[0],b)},initializeEditor:function(a,c){var d,e=new b.Editor(this.el[0],c);if(e.on("beforeload",this.syncBootstrapDialogEvents),e.on("beforeload",this.loadParserRules),e.composer.editableArea.contentDocument?this.addMoreShortcuts(e,e.composer.editableArea.contentDocument.body||e.composer.editableArea.contentDocument,c.shortcuts):this.addMoreShortcuts(e,e.composer.editableArea,c.shortcuts),c&&c.events)for(d in c.events)c.events.hasOwnProperty(d)&&e.on(d,c.events[d]);return e},loadParserRules:function(){"string"===a.type(this.config.parserRules)&&a.ajax({dataType:"json",url:this.config.parserRules,context:this,error:function(a,b,c){void 0},success:function(a){this.config.parserRules=a,void 0}}),this.config.pasteParserRulesets&&"string"===a.type(this.config.pasteParserRulesets)&&a.ajax({dataType:"json",url:this.config.pasteParserRulesets,context:this,error:function(a,b,c){void 0},success:function(a){this.config.pasteParserRulesets=a}})},syncBootstrapDialogEvents:function(){var b=this;a.map(this.toolbar.commandMapping,function(a){return[a]}).filter(function(a){return a.dialog}).map(function(a){return a.dialog}).forEach(function(c){c.on("show",function(){a(this.container).modal("show")}),c.on("hide",function(){a(this.container).modal("hide"),setTimeout(b.composer.focus,0)}),a(c.container).on("shown.bs.modal",function(){a(this).find("input, select, textarea").first().focus()})}),this.on("change_view",function(){a(this.toolbar.container.children).find("a.btn").not('[data-wysihtml5-action="change_view"]').toggleClass("disabled")})},createToolbar:function(b,c){var g,h,i=this,j=a("<ul/>",{"class":"wysihtml5-toolbar",style:"display:none"}),k=c.locale||d.locale||"en";e.hasOwnProperty(k)||(void 0,k="en"),g=a.extend(!0,{},e.en,e[k]);for(h in c.toolbar)c.toolbar[h]&&j.append(f(h,g,c));return j.find('a[data-wysihtml5-command="formatBlock"]').click(function(b){var c=b.delegateTarget||b.target||b.srcElement,d=a(c),e=d.data("wysihtml5-display-format-name"),f=d.data("wysihtml5-format-name")||d.html();(void 0===e||"true"===e)&&i.toolbar.find(".current-font").text(f)}),j.find('a[data-wysihtml5-command="foreColor"]').click(function(b){var c=b.target||b.srcElement,d=a(c);i.toolbar.find(".current-color").text(d.html())}),this.el.before(j),j},addMoreShortcuts:function(a,c,d){b.dom.observe(c,"keydown",function(c){var e,f=c.keyCode,g=d[f];(c.ctrlKey||c.metaKey||c.altKey)&&g&&b.commands[g]&&(e=a.toolbar.commandMapping[g+":null"],e&&e.dialog&&!e.state?e.dialog.show():b.commands[g].exec(a.composer,g),c.preventDefault())})}},c={resetDefaults:function(){a.fn.wysihtml5.defaultOptions=a.extend(!0,{},a.fn.wysihtml5.defaultOptionsCache)},bypassDefaults:function(b){return this.each(function(){var c=a(this);c.data("wysihtml5",new g(c,b))})},shallowExtend:function(b){var d=a.extend({},a.fn.wysihtml5.defaultOptions,b||{},a(this).data()),e=this;return c.bypassDefaults.apply(e,[d])},deepExtend:function(b){var d=a.extend(!0,{},a.fn.wysihtml5.defaultOptions,b||{}),e=this;return c.bypassDefaults.apply(e,[d])},init:function(a){var b=this;return c.shallowExtend.apply(b,[a])}},a.fn.wysihtml5=function(b){return c[b]?c[b].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof b&&b?(a.error("Method "+b+" does not exist on jQuery.wysihtml5"),void 0):c.init.apply(this,arguments)},a.fn.wysihtml5.Constructor=g,d=a.fn.wysihtml5.defaultOptions={toolbar:{"font-styles":!0,color:!1,emphasis:{small:!0},blockquote:!0,lists:!0,html:!1,link:!0,image:!0,smallmodals:!1},useLineBreaks:!1,parserRules:{classes:{"wysiwyg-color-silver":1,"wysiwyg-color-gray":1,"wysiwyg-color-white":1,"wysiwyg-color-maroon":1,"wysiwyg-color-red":1,"wysiwyg-color-purple":1,"wysiwyg-color-fuchsia":1,"wysiwyg-color-green":1,"wysiwyg-color-lime":1,"wysiwyg-color-olive":1,"wysiwyg-color-yellow":1,"wysiwyg-color-navy":1,"wysiwyg-color-blue":1,"wysiwyg-color-teal":1,"wysiwyg-color-aqua":1,"wysiwyg-color-orange":1},tags:{b:{},i:{},strong:{},em:{},p:{},br:{},ol:{},ul:{},li:{},h1:{},h2:{},h3:{},h4:{},h5:{},h6:{},blockquote:{},u:1,img:{check_attributes:{width:"numbers",alt:"alt",src:"url",height:"numbers"}},a:{check_attributes:{href:"url"},set_attributes:{target:"_blank",rel:"nofollow"}},span:1,div:1,small:1,code:1,pre:1}},locale:"en",shortcuts:{83:"small",75:"createLink"}},void 0===a.fn.wysihtml5.defaultOptionsCache&&(a.fn.wysihtml5.defaultOptionsCache=a.extend(!0,{},a.fn.wysihtml5.defaultOptions)),e=a.fn.wysihtml5.locale={}};c(a,b)}),function(a){a.commands.small={exec:function(b,c){return a.commands.formatInline.exec(b,c,"small")},state:function(b,c){return a.commands.formatInline.state(b,c,"small")}}}(wysihtml5),function(a){"function"==typeof define&&define.amd?define("bootstrap.wysihtml5.en-US",["jquery","bootstrap.wysihtml5"],a):a(jQuery)}(function(a){a.fn.wysihtml5.locale.en=a.fn.wysihtml5.locale["en-US"]={font_styles:{normal:"Normal text",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6"},emphasis:{bold:"Bold",italic:"Italic",underline:"Underline",small:"Small"},lists:{unordered:"Unordered list",ordered:"Ordered list",outdent:"Outdent",indent:"Indent"},link:{insert:"Insert link",cancel:"Cancel",target:"Open link in new window"},image:{insert:"Insert image",cancel:"Cancel"},html:{edit:"Edit HTML"},colours:{black:"Black",silver:"Silver",gray:"Grey",maroon:"Maroon",red:"Red",purple:"Purple",green:"Green",olive:"Olive",navy:"Navy",blue:"Blue",orange:"Orange"}}});
  /*! DataTables 1.10.7
   * ©2008-2015 SpryMedia Ltd - datatables.net/license
   */
  (function(Ea,Q,k){var P=function(h){function W(a){var b,c,e={};h.each(a,function(d){if((b=d.match(/^([^A-Z]+?)([A-Z])/))&&-1!=="a aa ai ao as b fn i m o s ".indexOf(b[1]+" "))c=d.replace(b[0],b[2].toLowerCase()),e[c]=d,"o"===b[1]&&W(a[d])});a._hungarianMap=e}function H(a,b,c){a._hungarianMap||W(a);var e;h.each(b,function(d){e=a._hungarianMap[d];if(e!==k&&(c||b[e]===k))"o"===e.charAt(0)?(b[e]||(b[e]={}),h.extend(!0,b[e],b[d]),H(a[e],b[e],c)):b[e]=b[d]})}function P(a){var b=m.defaults.oLanguage,c=a.sZeroRecords;
  !a.sEmptyTable&&(c&&"No data available in table"===b.sEmptyTable)&&E(a,a,"sZeroRecords","sEmptyTable");!a.sLoadingRecords&&(c&&"Loading..."===b.sLoadingRecords)&&E(a,a,"sZeroRecords","sLoadingRecords");a.sInfoThousands&&(a.sThousands=a.sInfoThousands);(a=a.sDecimal)&&db(a)}function eb(a){A(a,"ordering","bSort");A(a,"orderMulti","bSortMulti");A(a,"orderClasses","bSortClasses");A(a,"orderCellsTop","bSortCellsTop");A(a,"order","aaSorting");A(a,"orderFixed","aaSortingFixed");A(a,"paging","bPaginate");
  A(a,"pagingType","sPaginationType");A(a,"pageLength","iDisplayLength");A(a,"searching","bFilter");if(a=a.aoSearchCols)for(var b=0,c=a.length;b<c;b++)a[b]&&H(m.models.oSearch,a[b])}function fb(a){A(a,"orderable","bSortable");A(a,"orderData","aDataSort");A(a,"orderSequence","asSorting");A(a,"orderDataType","sortDataType");var b=a.aDataSort;b&&!h.isArray(b)&&(a.aDataSort=[b])}function gb(a){var a=a.oBrowser,b=h("<div/>").css({position:"absolute",top:0,left:0,height:1,width:1,overflow:"hidden"}).append(h("<div/>").css({position:"absolute",
  top:1,left:1,width:100,overflow:"scroll"}).append(h('<div class="test"/>').css({width:"100%",height:10}))).appendTo("body"),c=b.find(".test");a.bScrollOversize=100===c[0].offsetWidth;a.bScrollbarLeft=1!==Math.round(c.offset().left);b.remove()}function hb(a,b,c,e,d,f){var g,j=!1;c!==k&&(g=c,j=!0);for(;e!==d;)a.hasOwnProperty(e)&&(g=j?b(g,a[e],e,a):a[e],j=!0,e+=f);return g}function Fa(a,b){var c=m.defaults.column,e=a.aoColumns.length,c=h.extend({},m.models.oColumn,c,{nTh:b?b:Q.createElement("th"),sTitle:c.sTitle?
  c.sTitle:b?b.innerHTML:"",aDataSort:c.aDataSort?c.aDataSort:[e],mData:c.mData?c.mData:e,idx:e});a.aoColumns.push(c);c=a.aoPreSearchCols;c[e]=h.extend({},m.models.oSearch,c[e]);ka(a,e,h(b).data())}function ka(a,b,c){var b=a.aoColumns[b],e=a.oClasses,d=h(b.nTh);if(!b.sWidthOrig){b.sWidthOrig=d.attr("width")||null;var f=(d.attr("style")||"").match(/width:\s*(\d+[pxem%]+)/);f&&(b.sWidthOrig=f[1])}c!==k&&null!==c&&(fb(c),H(m.defaults.column,c),c.mDataProp!==k&&!c.mData&&(c.mData=c.mDataProp),c.sType&&
  (b._sManualType=c.sType),c.className&&!c.sClass&&(c.sClass=c.className),h.extend(b,c),E(b,c,"sWidth","sWidthOrig"),c.iDataSort!==k&&(b.aDataSort=[c.iDataSort]),E(b,c,"aDataSort"));var g=b.mData,j=R(g),i=b.mRender?R(b.mRender):null,c=function(a){return"string"===typeof a&&-1!==a.indexOf("@")};b._bAttrSrc=h.isPlainObject(g)&&(c(g.sort)||c(g.type)||c(g.filter));b.fnGetData=function(a,b,c){var e=j(a,b,k,c);return i&&b?i(e,b,a,c):e};b.fnSetData=function(a,b,c){return S(g)(a,b,c)};"number"!==typeof g&&
  (a._rowReadObject=!0);a.oFeatures.bSort||(b.bSortable=!1,d.addClass(e.sSortableNone));a=-1!==h.inArray("asc",b.asSorting);c=-1!==h.inArray("desc",b.asSorting);!b.bSortable||!a&&!c?(b.sSortingClass=e.sSortableNone,b.sSortingClassJUI=""):a&&!c?(b.sSortingClass=e.sSortableAsc,b.sSortingClassJUI=e.sSortJUIAscAllowed):!a&&c?(b.sSortingClass=e.sSortableDesc,b.sSortingClassJUI=e.sSortJUIDescAllowed):(b.sSortingClass=e.sSortable,b.sSortingClassJUI=e.sSortJUI)}function X(a){if(!1!==a.oFeatures.bAutoWidth){var b=
  a.aoColumns;Ga(a);for(var c=0,e=b.length;c<e;c++)b[c].nTh.style.width=b[c].sWidth}b=a.oScroll;(""!==b.sY||""!==b.sX)&&Y(a);w(a,null,"column-sizing",[a])}function la(a,b){var c=Z(a,"bVisible");return"number"===typeof c[b]?c[b]:null}function $(a,b){var c=Z(a,"bVisible"),c=h.inArray(b,c);return-1!==c?c:null}function aa(a){return Z(a,"bVisible").length}function Z(a,b){var c=[];h.map(a.aoColumns,function(a,d){a[b]&&c.push(d)});return c}function Ha(a){var b=a.aoColumns,c=a.aoData,e=m.ext.type.detect,d,
  f,g,j,i,h,l,q,n;d=0;for(f=b.length;d<f;d++)if(l=b[d],n=[],!l.sType&&l._sManualType)l.sType=l._sManualType;else if(!l.sType){g=0;for(j=e.length;g<j;g++){i=0;for(h=c.length;i<h;i++){n[i]===k&&(n[i]=x(a,i,d,"type"));q=e[g](n[i],a);if(!q&&g!==e.length-1)break;if("html"===q)break}if(q){l.sType=q;break}}l.sType||(l.sType="string")}}function ib(a,b,c,e){var d,f,g,j,i,o,l=a.aoColumns;if(b)for(d=b.length-1;0<=d;d--){o=b[d];var q=o.targets!==k?o.targets:o.aTargets;h.isArray(q)||(q=[q]);f=0;for(g=q.length;f<
  g;f++)if("number"===typeof q[f]&&0<=q[f]){for(;l.length<=q[f];)Fa(a);e(q[f],o)}else if("number"===typeof q[f]&&0>q[f])e(l.length+q[f],o);else if("string"===typeof q[f]){j=0;for(i=l.length;j<i;j++)("_all"==q[f]||h(l[j].nTh).hasClass(q[f]))&&e(j,o)}}if(c){d=0;for(a=c.length;d<a;d++)e(d,c[d])}}function K(a,b,c,e){var d=a.aoData.length,f=h.extend(!0,{},m.models.oRow,{src:c?"dom":"data"});f._aData=b;a.aoData.push(f);for(var b=a.aoColumns,f=0,g=b.length;f<g;f++)c&&Ia(a,d,f,x(a,d,f)),b[f].sType=null;a.aiDisplayMaster.push(d);
  (c||!a.oFeatures.bDeferRender)&&Ja(a,d,c,e);return d}function ma(a,b){var c;b instanceof h||(b=h(b));return b.map(function(b,d){c=na(a,d);return K(a,c.data,d,c.cells)})}function x(a,b,c,e){var d=a.iDraw,f=a.aoColumns[c],g=a.aoData[b]._aData,j=f.sDefaultContent,c=f.fnGetData(g,e,{settings:a,row:b,col:c});if(c===k)return a.iDrawError!=d&&null===j&&(I(a,0,"Requested unknown parameter "+("function"==typeof f.mData?"{function}":"'"+f.mData+"'")+" for row "+b,4),a.iDrawError=d),j;if((c===g||null===c)&&
  null!==j)c=j;else if("function"===typeof c)return c.call(g);return null===c&&"display"==e?"":c}function Ia(a,b,c,e){a.aoColumns[c].fnSetData(a.aoData[b]._aData,e,{settings:a,row:b,col:c})}function Ka(a){return h.map(a.match(/(\\.|[^\.])+/g),function(a){return a.replace(/\\./g,".")})}function R(a){if(h.isPlainObject(a)){var b={};h.each(a,function(a,c){c&&(b[a]=R(c))});return function(a,c,f,g){var j=b[c]||b._;return j!==k?j(a,c,f,g):a}}if(null===a)return function(a){return a};if("function"===typeof a)return function(b,
  c,f,g){return a(b,c,f,g)};if("string"===typeof a&&(-1!==a.indexOf(".")||-1!==a.indexOf("[")||-1!==a.indexOf("("))){var c=function(a,b,f){var g,j;if(""!==f){j=Ka(f);for(var i=0,h=j.length;i<h;i++){f=j[i].match(ba);g=j[i].match(T);if(f){j[i]=j[i].replace(ba,"");""!==j[i]&&(a=a[j[i]]);g=[];j.splice(0,i+1);j=j.join(".");i=0;for(h=a.length;i<h;i++)g.push(c(a[i],b,j));a=f[0].substring(1,f[0].length-1);a=""===a?g:g.join(a);break}else if(g){j[i]=j[i].replace(T,"");a=a[j[i]]();continue}if(null===a||a[j[i]]===
  k)return k;a=a[j[i]]}}return a};return function(b,d){return c(b,d,a)}}return function(b){return b[a]}}function S(a){if(h.isPlainObject(a))return S(a._);if(null===a)return function(){};if("function"===typeof a)return function(b,e,d){a(b,"set",e,d)};if("string"===typeof a&&(-1!==a.indexOf(".")||-1!==a.indexOf("[")||-1!==a.indexOf("("))){var b=function(a,e,d){var d=Ka(d),f;f=d[d.length-1];for(var g,j,i=0,h=d.length-1;i<h;i++){g=d[i].match(ba);j=d[i].match(T);if(g){d[i]=d[i].replace(ba,"");a[d[i]]=[];
  f=d.slice();f.splice(0,i+1);g=f.join(".");j=0;for(h=e.length;j<h;j++)f={},b(f,e[j],g),a[d[i]].push(f);return}j&&(d[i]=d[i].replace(T,""),a=a[d[i]](e));if(null===a[d[i]]||a[d[i]]===k)a[d[i]]={};a=a[d[i]]}if(f.match(T))a[f.replace(T,"")](e);else a[f.replace(ba,"")]=e};return function(c,e){return b(c,e,a)}}return function(b,e){b[a]=e}}function La(a){return D(a.aoData,"_aData")}function oa(a){a.aoData.length=0;a.aiDisplayMaster.length=0;a.aiDisplay.length=0}function pa(a,b,c){for(var e=-1,d=0,f=a.length;d<
  f;d++)a[d]==b?e=d:a[d]>b&&a[d]--; -1!=e&&c===k&&a.splice(e,1)}function ca(a,b,c,e){var d=a.aoData[b],f,g=function(c,f){for(;c.childNodes.length;)c.removeChild(c.firstChild);c.innerHTML=x(a,b,f,"display")};if("dom"===c||(!c||"auto"===c)&&"dom"===d.src)d._aData=na(a,d,e,e===k?k:d._aData).data;else{var j=d.anCells;if(j)if(e!==k)g(j[e],e);else{c=0;for(f=j.length;c<f;c++)g(j[c],c)}}d._aSortData=null;d._aFilterData=null;g=a.aoColumns;if(e!==k)g[e].sType=null;else{c=0;for(f=g.length;c<f;c++)g[c].sType=null;
  Ma(d)}}function na(a,b,c,e){var d=[],f=b.firstChild,g,j=0,i,o=a.aoColumns,l=a._rowReadObject,e=e||l?{}:[],q=function(a,b){if("string"===typeof a){var c=a.indexOf("@");-1!==c&&(c=a.substring(c+1),S(a)(e,b.getAttribute(c)))}},a=function(a){if(c===k||c===j)g=o[j],i=h.trim(a.innerHTML),g&&g._bAttrSrc?(S(g.mData._)(e,i),q(g.mData.sort,a),q(g.mData.type,a),q(g.mData.filter,a)):l?(g._setter||(g._setter=S(g.mData)),g._setter(e,i)):e[j]=i;j++};if(f)for(;f;){b=f.nodeName.toUpperCase();if("TD"==b||"TH"==b)a(f),
  d.push(f);f=f.nextSibling}else{d=b.anCells;f=0;for(b=d.length;f<b;f++)a(d[f])}return{data:e,cells:d}}function Ja(a,b,c,e){var d=a.aoData[b],f=d._aData,g=[],j,i,h,l,q;if(null===d.nTr){j=c||Q.createElement("tr");d.nTr=j;d.anCells=g;j._DT_RowIndex=b;Ma(d);l=0;for(q=a.aoColumns.length;l<q;l++){h=a.aoColumns[l];i=c?e[l]:Q.createElement(h.sCellType);g.push(i);if(!c||h.mRender||h.mData!==l)i.innerHTML=x(a,b,l,"display");h.sClass&&(i.className+=" "+h.sClass);h.bVisible&&!c?j.appendChild(i):!h.bVisible&&c&&
  i.parentNode.removeChild(i);h.fnCreatedCell&&h.fnCreatedCell.call(a.oInstance,i,x(a,b,l),f,b,l)}w(a,"aoRowCreatedCallback",null,[j,f,b])}d.nTr.setAttribute("role","row")}function Ma(a){var b=a.nTr,c=a._aData;if(b){c.DT_RowId&&(b.id=c.DT_RowId);if(c.DT_RowClass){var e=c.DT_RowClass.split(" ");a.__rowc=a.__rowc?Na(a.__rowc.concat(e)):e;h(b).removeClass(a.__rowc.join(" ")).addClass(c.DT_RowClass)}c.DT_RowAttr&&h(b).attr(c.DT_RowAttr);c.DT_RowData&&h(b).data(c.DT_RowData)}}function jb(a){var b,c,e,d,
  f,g=a.nTHead,j=a.nTFoot,i=0===h("th, td",g).length,o=a.oClasses,l=a.aoColumns;i&&(d=h("<tr/>").appendTo(g));b=0;for(c=l.length;b<c;b++)f=l[b],e=h(f.nTh).addClass(f.sClass),i&&e.appendTo(d),a.oFeatures.bSort&&(e.addClass(f.sSortingClass),!1!==f.bSortable&&(e.attr("tabindex",a.iTabIndex).attr("aria-controls",a.sTableId),Oa(a,f.nTh,b))),f.sTitle!=e.html()&&e.html(f.sTitle),Pa(a,"header")(a,e,f,o);i&&da(a.aoHeader,g);h(g).find(">tr").attr("role","row");h(g).find(">tr>th, >tr>td").addClass(o.sHeaderTH);
  h(j).find(">tr>th, >tr>td").addClass(o.sFooterTH);if(null!==j){a=a.aoFooter[0];b=0;for(c=a.length;b<c;b++)f=l[b],f.nTf=a[b].cell,f.sClass&&h(f.nTf).addClass(f.sClass)}}function ea(a,b,c){var e,d,f,g=[],j=[],i=a.aoColumns.length,o;if(b){c===k&&(c=!1);e=0;for(d=b.length;e<d;e++){g[e]=b[e].slice();g[e].nTr=b[e].nTr;for(f=i-1;0<=f;f--)!a.aoColumns[f].bVisible&&!c&&g[e].splice(f,1);j.push([])}e=0;for(d=g.length;e<d;e++){if(a=g[e].nTr)for(;f=a.firstChild;)a.removeChild(f);f=0;for(b=g[e].length;f<b;f++)if(o=
  i=1,j[e][f]===k){a.appendChild(g[e][f].cell);for(j[e][f]=1;g[e+i]!==k&&g[e][f].cell==g[e+i][f].cell;)j[e+i][f]=1,i++;for(;g[e][f+o]!==k&&g[e][f].cell==g[e][f+o].cell;){for(c=0;c<i;c++)j[e+c][f+o]=1;o++}h(g[e][f].cell).attr("rowspan",i).attr("colspan",o)}}}}function M(a){var b=w(a,"aoPreDrawCallback","preDraw",[a]);if(-1!==h.inArray(!1,b))C(a,!1);else{var b=[],c=0,e=a.asStripeClasses,d=e.length,f=a.oLanguage,g=a.iInitDisplayStart,j="ssp"==B(a),i=a.aiDisplay;a.bDrawing=!0;g!==k&&-1!==g&&(a._iDisplayStart=
  j?g:g>=a.fnRecordsDisplay()?0:g,a.iInitDisplayStart=-1);var g=a._iDisplayStart,o=a.fnDisplayEnd();if(a.bDeferLoading)a.bDeferLoading=!1,a.iDraw++,C(a,!1);else if(j){if(!a.bDestroying&&!kb(a))return}else a.iDraw++;if(0!==i.length){f=j?a.aoData.length:o;for(j=j?0:g;j<f;j++){var l=i[j],q=a.aoData[l];null===q.nTr&&Ja(a,l);l=q.nTr;if(0!==d){var n=e[c%d];q._sRowStripe!=n&&(h(l).removeClass(q._sRowStripe).addClass(n),q._sRowStripe=n)}w(a,"aoRowCallback",null,[l,q._aData,c,j]);b.push(l);c++}}else c=f.sZeroRecords,
  1==a.iDraw&&"ajax"==B(a)?c=f.sLoadingRecords:f.sEmptyTable&&0===a.fnRecordsTotal()&&(c=f.sEmptyTable),b[0]=h("<tr/>",{"class":d?e[0]:""}).append(h("<td />",{valign:"top",colSpan:aa(a),"class":a.oClasses.sRowEmpty}).html(c))[0];w(a,"aoHeaderCallback","header",[h(a.nTHead).children("tr")[0],La(a),g,o,i]);w(a,"aoFooterCallback","footer",[h(a.nTFoot).children("tr")[0],La(a),g,o,i]);e=h(a.nTBody);e.children().detach();e.append(h(b));w(a,"aoDrawCallback","draw",[a]);a.bSorted=!1;a.bFiltered=!1;a.bDrawing=
  !1}}function N(a,b){var c=a.oFeatures,e=c.bFilter;c.bSort&&lb(a);e?fa(a,a.oPreviousSearch):a.aiDisplay=a.aiDisplayMaster.slice();!0!==b&&(a._iDisplayStart=0);a._drawHold=b;M(a);a._drawHold=!1}function mb(a){var b=a.oClasses,c=h(a.nTable),c=h("<div/>").insertBefore(c),e=a.oFeatures,d=h("<div/>",{id:a.sTableId+"_wrapper","class":b.sWrapper+(a.nTFoot?"":" "+b.sNoFooter)});a.nHolding=c[0];a.nTableWrapper=d[0];a.nTableReinsertBefore=a.nTable.nextSibling;for(var f=a.sDom.split(""),g,j,i,o,l,q,n=0;n<f.length;n++){g=
  null;j=f[n];if("<"==j){i=h("<div/>")[0];o=f[n+1];if("'"==o||'"'==o){l="";for(q=2;f[n+q]!=o;)l+=f[n+q],q++;"H"==l?l=b.sJUIHeader:"F"==l&&(l=b.sJUIFooter);-1!=l.indexOf(".")?(o=l.split("."),i.id=o[0].substr(1,o[0].length-1),i.className=o[1]):"#"==l.charAt(0)?i.id=l.substr(1,l.length-1):i.className=l;n+=q}d.append(i);d=h(i)}else if(">"==j)d=d.parent();else if("l"==j&&e.bPaginate&&e.bLengthChange)g=nb(a);else if("f"==j&&e.bFilter)g=ob(a);else if("r"==j&&e.bProcessing)g=pb(a);else if("t"==j)g=qb(a);else if("i"==
  j&&e.bInfo)g=rb(a);else if("p"==j&&e.bPaginate)g=sb(a);else if(0!==m.ext.feature.length){i=m.ext.feature;q=0;for(o=i.length;q<o;q++)if(j==i[q].cFeature){g=i[q].fnInit(a);break}}g&&(i=a.aanFeatures,i[j]||(i[j]=[]),i[j].push(g),d.append(g))}c.replaceWith(d)}function da(a,b){var c=h(b).children("tr"),e,d,f,g,j,i,o,l,q,n;a.splice(0,a.length);f=0;for(i=c.length;f<i;f++)a.push([]);f=0;for(i=c.length;f<i;f++){e=c[f];for(d=e.firstChild;d;){if("TD"==d.nodeName.toUpperCase()||"TH"==d.nodeName.toUpperCase()){l=
  1*d.getAttribute("colspan");q=1*d.getAttribute("rowspan");l=!l||0===l||1===l?1:l;q=!q||0===q||1===q?1:q;g=0;for(j=a[f];j[g];)g++;o=g;n=1===l?!0:!1;for(j=0;j<l;j++)for(g=0;g<q;g++)a[f+g][o+j]={cell:d,unique:n},a[f+g].nTr=e}d=d.nextSibling}}}function qa(a,b,c){var e=[];c||(c=a.aoHeader,b&&(c=[],da(c,b)));for(var b=0,d=c.length;b<d;b++)for(var f=0,g=c[b].length;f<g;f++)if(c[b][f].unique&&(!e[f]||!a.bSortCellsTop))e[f]=c[b][f].cell;return e}function ra(a,b,c){w(a,"aoServerParams","serverParams",[b]);
  if(b&&h.isArray(b)){var e={},d=/(.*?)\[\]$/;h.each(b,function(a,b){var c=b.name.match(d);c?(c=c[0],e[c]||(e[c]=[]),e[c].push(b.value)):e[b.name]=b.value});b=e}var f,g=a.ajax,j=a.oInstance,i=function(b){w(a,null,"xhr",[a,b,a.jqXHR]);c(b)};if(h.isPlainObject(g)&&g.data){f=g.data;var o=h.isFunction(f)?f(b,a):f,b=h.isFunction(f)&&o?o:h.extend(!0,b,o);delete g.data}o={data:b,success:function(b){var c=b.error||b.sError;c&&I(a,0,c);a.json=b;i(b)},dataType:"json",cache:!1,type:a.sServerMethod,error:function(b,
  c){var f=w(a,null,"xhr",[a,null,a.jqXHR]);-1===h.inArray(!0,f)&&("parsererror"==c?I(a,0,"Invalid JSON response",1):4===b.readyState&&I(a,0,"Ajax error",7));C(a,!1)}};a.oAjaxData=b;w(a,null,"preXhr",[a,b]);a.fnServerData?a.fnServerData.call(j,a.sAjaxSource,h.map(b,function(a,b){return{name:b,value:a}}),i,a):a.sAjaxSource||"string"===typeof g?a.jqXHR=h.ajax(h.extend(o,{url:g||a.sAjaxSource})):h.isFunction(g)?a.jqXHR=g.call(j,b,i,a):(a.jqXHR=h.ajax(h.extend(o,g)),g.data=f)}function kb(a){return a.bAjaxDataGet?
  (a.iDraw++,C(a,!0),ra(a,tb(a),function(b){ub(a,b)}),!1):!0}function tb(a){var b=a.aoColumns,c=b.length,e=a.oFeatures,d=a.oPreviousSearch,f=a.aoPreSearchCols,g,j=[],i,o,l,q=U(a);g=a._iDisplayStart;i=!1!==e.bPaginate?a._iDisplayLength:-1;var n=function(a,b){j.push({name:a,value:b})};n("sEcho",a.iDraw);n("iColumns",c);n("sColumns",D(b,"sName").join(","));n("iDisplayStart",g);n("iDisplayLength",i);var k={draw:a.iDraw,columns:[],order:[],start:g,length:i,search:{value:d.sSearch,regex:d.bRegex}};for(g=
  0;g<c;g++)o=b[g],l=f[g],i="function"==typeof o.mData?"function":o.mData,k.columns.push({data:i,name:o.sName,searchable:o.bSearchable,orderable:o.bSortable,search:{value:l.sSearch,regex:l.bRegex}}),n("mDataProp_"+g,i),e.bFilter&&(n("sSearch_"+g,l.sSearch),n("bRegex_"+g,l.bRegex),n("bSearchable_"+g,o.bSearchable)),e.bSort&&n("bSortable_"+g,o.bSortable);e.bFilter&&(n("sSearch",d.sSearch),n("bRegex",d.bRegex));e.bSort&&(h.each(q,function(a,b){k.order.push({column:b.col,dir:b.dir});n("iSortCol_"+a,b.col);
  n("sSortDir_"+a,b.dir)}),n("iSortingCols",q.length));b=m.ext.legacy.ajax;return null===b?a.sAjaxSource?j:k:b?j:k}function ub(a,b){var c=sa(a,b),e=b.sEcho!==k?b.sEcho:b.draw,d=b.iTotalRecords!==k?b.iTotalRecords:b.recordsTotal,f=b.iTotalDisplayRecords!==k?b.iTotalDisplayRecords:b.recordsFiltered;if(e){if(1*e<a.iDraw)return;a.iDraw=1*e}oa(a);a._iRecordsTotal=parseInt(d,10);a._iRecordsDisplay=parseInt(f,10);e=0;for(d=c.length;e<d;e++)K(a,c[e]);a.aiDisplay=a.aiDisplayMaster.slice();a.bAjaxDataGet=!1;
  M(a);a._bInitComplete||ta(a,b);a.bAjaxDataGet=!0;C(a,!1)}function sa(a,b){var c=h.isPlainObject(a.ajax)&&a.ajax.dataSrc!==k?a.ajax.dataSrc:a.sAjaxDataProp;return"data"===c?b.aaData||b[c]:""!==c?R(c)(b):b}function ob(a){var b=a.oClasses,c=a.sTableId,e=a.oLanguage,d=a.oPreviousSearch,f=a.aanFeatures,g='<input type="search" class="'+b.sFilterInput+'"/>',j=e.sSearch,j=j.match(/_INPUT_/)?j.replace("_INPUT_",g):j+g,b=h("<div/>",{id:!f.f?c+"_filter":null,"class":b.sFilter}).append(h("<label/>").append(j)),
  f=function(){var b=!this.value?"":this.value;b!=d.sSearch&&(fa(a,{sSearch:b,bRegex:d.bRegex,bSmart:d.bSmart,bCaseInsensitive:d.bCaseInsensitive}),a._iDisplayStart=0,M(a))},g=null!==a.searchDelay?a.searchDelay:"ssp"===B(a)?400:0,i=h("input",b).val(d.sSearch).attr("placeholder",e.sSearchPlaceholder).bind("keyup.DT search.DT input.DT paste.DT cut.DT",g?ua(f,g):f).bind("keypress.DT",function(a){if(13==a.keyCode)return!1}).attr("aria-controls",c);h(a.nTable).on("search.dt.DT",function(b,c){if(a===c)try{i[0]!==
  Q.activeElement&&i.val(d.sSearch)}catch(f){}});return b[0]}function fa(a,b,c){var e=a.oPreviousSearch,d=a.aoPreSearchCols,f=function(a){e.sSearch=a.sSearch;e.bRegex=a.bRegex;e.bSmart=a.bSmart;e.bCaseInsensitive=a.bCaseInsensitive};Ha(a);if("ssp"!=B(a)){vb(a,b.sSearch,c,b.bEscapeRegex!==k?!b.bEscapeRegex:b.bRegex,b.bSmart,b.bCaseInsensitive);f(b);for(b=0;b<d.length;b++)wb(a,d[b].sSearch,b,d[b].bEscapeRegex!==k?!d[b].bEscapeRegex:d[b].bRegex,d[b].bSmart,d[b].bCaseInsensitive);xb(a)}else f(b);a.bFiltered=
  !0;w(a,null,"search",[a])}function xb(a){for(var b=m.ext.search,c=a.aiDisplay,e,d,f=0,g=b.length;f<g;f++){for(var j=[],i=0,h=c.length;i<h;i++)d=c[i],e=a.aoData[d],b[f](a,e._aFilterData,d,e._aData,i)&&j.push(d);c.length=0;c.push.apply(c,j)}}function wb(a,b,c,e,d,f){if(""!==b)for(var g=a.aiDisplay,e=Qa(b,e,d,f),d=g.length-1;0<=d;d--)b=a.aoData[g[d]]._aFilterData[c],e.test(b)||g.splice(d,1)}function vb(a,b,c,e,d,f){var e=Qa(b,e,d,f),d=a.oPreviousSearch.sSearch,f=a.aiDisplayMaster,g;0!==m.ext.search.length&&
  (c=!0);g=yb(a);if(0>=b.length)a.aiDisplay=f.slice();else{if(g||c||d.length>b.length||0!==b.indexOf(d)||a.bSorted)a.aiDisplay=f.slice();b=a.aiDisplay;for(c=b.length-1;0<=c;c--)e.test(a.aoData[b[c]]._sFilterRow)||b.splice(c,1)}}function Qa(a,b,c,e){a=b?a:va(a);c&&(a="^(?=.*?"+h.map(a.match(/"[^"]+"|[^ ]+/g)||[""],function(a){if('"'===a.charAt(0))var b=a.match(/^"(.*)"$/),a=b?b[1]:a;return a.replace('"',"")}).join(")(?=.*?")+").*$");return RegExp(a,e?"i":"")}function va(a){return a.replace(Yb,"\\$1")}
  function yb(a){var b=a.aoColumns,c,e,d,f,g,j,i,h,l=m.ext.type.search;c=!1;e=0;for(f=a.aoData.length;e<f;e++)if(h=a.aoData[e],!h._aFilterData){j=[];d=0;for(g=b.length;d<g;d++)c=b[d],c.bSearchable?(i=x(a,e,d,"filter"),l[c.sType]&&(i=l[c.sType](i)),null===i&&(i=""),"string"!==typeof i&&i.toString&&(i=i.toString())):i="",i.indexOf&&-1!==i.indexOf("&")&&(wa.innerHTML=i,i=Zb?wa.textContent:wa.innerText),i.replace&&(i=i.replace(/[\r\n]/g,"")),j.push(i);h._aFilterData=j;h._sFilterRow=j.join("  ");c=!0}return c}
  function zb(a){return{search:a.sSearch,smart:a.bSmart,regex:a.bRegex,caseInsensitive:a.bCaseInsensitive}}function Ab(a){return{sSearch:a.search,bSmart:a.smart,bRegex:a.regex,bCaseInsensitive:a.caseInsensitive}}function rb(a){var b=a.sTableId,c=a.aanFeatures.i,e=h("<div/>",{"class":a.oClasses.sInfo,id:!c?b+"_info":null});c||(a.aoDrawCallback.push({fn:Bb,sName:"information"}),e.attr("role","status").attr("aria-live","polite"),h(a.nTable).attr("aria-describedby",b+"_info"));return e[0]}function Bb(a){var b=
  a.aanFeatures.i;if(0!==b.length){var c=a.oLanguage,e=a._iDisplayStart+1,d=a.fnDisplayEnd(),f=a.fnRecordsTotal(),g=a.fnRecordsDisplay(),j=g?c.sInfo:c.sInfoEmpty;g!==f&&(j+=" "+c.sInfoFiltered);j+=c.sInfoPostFix;j=Cb(a,j);c=c.fnInfoCallback;null!==c&&(j=c.call(a.oInstance,a,e,d,f,g,j));h(b).html(j)}}function Cb(a,b){var c=a.fnFormatNumber,e=a._iDisplayStart+1,d=a._iDisplayLength,f=a.fnRecordsDisplay(),g=-1===d;return b.replace(/_START_/g,c.call(a,e)).replace(/_END_/g,c.call(a,a.fnDisplayEnd())).replace(/_MAX_/g,
  c.call(a,a.fnRecordsTotal())).replace(/_TOTAL_/g,c.call(a,f)).replace(/_PAGE_/g,c.call(a,g?1:Math.ceil(e/d))).replace(/_PAGES_/g,c.call(a,g?1:Math.ceil(f/d)))}function ga(a){var b,c,e=a.iInitDisplayStart,d=a.aoColumns,f;c=a.oFeatures;if(a.bInitialised){mb(a);jb(a);ea(a,a.aoHeader);ea(a,a.aoFooter);C(a,!0);c.bAutoWidth&&Ga(a);b=0;for(c=d.length;b<c;b++)f=d[b],f.sWidth&&(f.nTh.style.width=s(f.sWidth));N(a);d=B(a);"ssp"!=d&&("ajax"==d?ra(a,[],function(c){var f=sa(a,c);for(b=0;b<f.length;b++)K(a,f[b]);
  a.iInitDisplayStart=e;N(a);C(a,!1);ta(a,c)},a):(C(a,!1),ta(a)))}else setTimeout(function(){ga(a)},200)}function ta(a,b){a._bInitComplete=!0;b&&X(a);w(a,"aoInitComplete","init",[a,b])}function Ra(a,b){var c=parseInt(b,10);a._iDisplayLength=c;Sa(a);w(a,null,"length",[a,c])}function nb(a){for(var b=a.oClasses,c=a.sTableId,e=a.aLengthMenu,d=h.isArray(e[0]),f=d?e[0]:e,e=d?e[1]:e,d=h("<select/>",{name:c+"_length","aria-controls":c,"class":b.sLengthSelect}),g=0,j=f.length;g<j;g++)d[0][g]=new Option(e[g],
  f[g]);var i=h("<div><label/></div>").addClass(b.sLength);a.aanFeatures.l||(i[0].id=c+"_length");i.children().append(a.oLanguage.sLengthMenu.replace("_MENU_",d[0].outerHTML));h("select",i).val(a._iDisplayLength).bind("change.DT",function(){Ra(a,h(this).val());M(a)});h(a.nTable).bind("length.dt.DT",function(b,c,f){a===c&&h("select",i).val(f)});return i[0]}function sb(a){var b=a.sPaginationType,c=m.ext.pager[b],e="function"===typeof c,d=function(a){M(a)},b=h("<div/>").addClass(a.oClasses.sPaging+b)[0],
  f=a.aanFeatures;e||c.fnInit(a,b,d);f.p||(b.id=a.sTableId+"_paginate",a.aoDrawCallback.push({fn:function(a){if(e){var b=a._iDisplayStart,i=a._iDisplayLength,h=a.fnRecordsDisplay(),l=-1===i,b=l?0:Math.ceil(b/i),i=l?1:Math.ceil(h/i),h=c(b,i),q,l=0;for(q=f.p.length;l<q;l++)Pa(a,"pageButton")(a,f.p[l],l,h,b,i)}else c.fnUpdate(a,d)},sName:"pagination"}));return b}function Ta(a,b,c){var e=a._iDisplayStart,d=a._iDisplayLength,f=a.fnRecordsDisplay();0===f||-1===d?e=0:"number"===typeof b?(e=b*d,e>f&&(e=0)):
  "first"==b?e=0:"previous"==b?(e=0<=d?e-d:0,0>e&&(e=0)):"next"==b?e+d<f&&(e+=d):"last"==b?e=Math.floor((f-1)/d)*d:I(a,0,"Unknown paging action: "+b,5);b=a._iDisplayStart!==e;a._iDisplayStart=e;b&&(w(a,null,"page",[a]),c&&M(a));return b}function pb(a){return h("<div/>",{id:!a.aanFeatures.r?a.sTableId+"_processing":null,"class":a.oClasses.sProcessing}).html(a.oLanguage.sProcessing).insertBefore(a.nTable)[0]}function C(a,b){a.oFeatures.bProcessing&&h(a.aanFeatures.r).css("display",b?"block":"none");w(a,
  null,"processing",[a,b])}function qb(a){var b=h(a.nTable);b.attr("role","grid");var c=a.oScroll;if(""===c.sX&&""===c.sY)return a.nTable;var e=c.sX,d=c.sY,f=a.oClasses,g=b.children("caption"),j=g.length?g[0]._captionSide:null,i=h(b[0].cloneNode(!1)),o=h(b[0].cloneNode(!1)),l=b.children("tfoot");c.sX&&"100%"===b.attr("width")&&b.removeAttr("width");l.length||(l=null);c=h("<div/>",{"class":f.sScrollWrapper}).append(h("<div/>",{"class":f.sScrollHead}).css({overflow:"hidden",position:"relative",border:0,
  width:e?!e?null:s(e):"100%"}).append(h("<div/>",{"class":f.sScrollHeadInner}).css({"box-sizing":"content-box",width:c.sXInner||"100%"}).append(i.removeAttr("id").css("margin-left",0).append("top"===j?g:null).append(b.children("thead"))))).append(h("<div/>",{"class":f.sScrollBody}).css({overflow:"auto",height:!d?null:s(d),width:!e?null:s(e)}).append(b));l&&c.append(h("<div/>",{"class":f.sScrollFoot}).css({overflow:"hidden",border:0,width:e?!e?null:s(e):"100%"}).append(h("<div/>",{"class":f.sScrollFootInner}).append(o.removeAttr("id").css("margin-left",
  0).append("bottom"===j?g:null).append(b.children("tfoot")))));var b=c.children(),q=b[0],f=b[1],n=l?b[2]:null;if(e)h(f).on("scroll.DT",function(){var a=this.scrollLeft;q.scrollLeft=a;l&&(n.scrollLeft=a)});a.nScrollHead=q;a.nScrollBody=f;a.nScrollFoot=n;a.aoDrawCallback.push({fn:Y,sName:"scrolling"});return c[0]}function Y(a){var b=a.oScroll,c=b.sX,e=b.sXInner,d=b.sY,f=b.iBarWidth,g=h(a.nScrollHead),j=g[0].style,i=g.children("div"),o=i[0].style,l=i.children("table"),i=a.nScrollBody,q=h(i),n=i.style,
  k=h(a.nScrollFoot).children("div"),p=k.children("table"),m=h(a.nTHead),r=h(a.nTable),t=r[0],O=t.style,L=a.nTFoot?h(a.nTFoot):null,ha=a.oBrowser,w=ha.bScrollOversize,v,u,y,x,z,A=[],B=[],C=[],D,E=function(a){a=a.style;a.paddingTop="0";a.paddingBottom="0";a.borderTopWidth="0";a.borderBottomWidth="0";a.height=0};r.children("thead, tfoot").remove();z=m.clone().prependTo(r);v=m.find("tr");y=z.find("tr");z.find("th, td").removeAttr("tabindex");L&&(x=L.clone().prependTo(r),u=L.find("tr"),x=x.find("tr"));
  c||(n.width="100%",g[0].style.width="100%");h.each(qa(a,z),function(b,c){D=la(a,b);c.style.width=a.aoColumns[D].sWidth});L&&G(function(a){a.style.width=""},x);b.bCollapse&&""!==d&&(n.height=q[0].offsetHeight+m[0].offsetHeight+"px");g=r.outerWidth();if(""===c){if(O.width="100%",w&&(r.find("tbody").height()>i.offsetHeight||"scroll"==q.css("overflow-y")))O.width=s(r.outerWidth()-f)}else""!==e?O.width=s(e):g==q.width()&&q.height()<r.height()?(O.width=s(g-f),r.outerWidth()>g-f&&(O.width=s(g))):O.width=
  s(g);g=r.outerWidth();G(E,y);G(function(a){C.push(a.innerHTML);A.push(s(h(a).css("width")))},y);G(function(a,b){a.style.width=A[b]},v);h(y).height(0);L&&(G(E,x),G(function(a){B.push(s(h(a).css("width")))},x),G(function(a,b){a.style.width=B[b]},u),h(x).height(0));G(function(a,b){a.innerHTML='<div class="dataTables_sizing" style="height:0;overflow:hidden;">'+C[b]+"</div>";a.style.width=A[b]},y);L&&G(function(a,b){a.innerHTML="";a.style.width=B[b]},x);if(r.outerWidth()<g){u=i.scrollHeight>i.offsetHeight||
  "scroll"==q.css("overflow-y")?g+f:g;if(w&&(i.scrollHeight>i.offsetHeight||"scroll"==q.css("overflow-y")))O.width=s(u-f);(""===c||""!==e)&&I(a,1,"Possible column misalignment",6)}else u="100%";n.width=s(u);j.width=s(u);L&&(a.nScrollFoot.style.width=s(u));!d&&w&&(n.height=s(t.offsetHeight+f));d&&b.bCollapse&&(n.height=s(d),b=c&&t.offsetWidth>i.offsetWidth?f:0,t.offsetHeight<i.offsetHeight&&(n.height=s(t.offsetHeight+b)));b=r.outerWidth();l[0].style.width=s(b);o.width=s(b);l=r.height()>i.clientHeight||
  "scroll"==q.css("overflow-y");ha="padding"+(ha.bScrollbarLeft?"Left":"Right");o[ha]=l?f+"px":"0px";L&&(p[0].style.width=s(b),k[0].style.width=s(b),k[0].style[ha]=l?f+"px":"0px");q.scroll();if((a.bSorted||a.bFiltered)&&!a._drawHold)i.scrollTop=0}function G(a,b,c){for(var e=0,d=0,f=b.length,g,j;d<f;){g=b[d].firstChild;for(j=c?c[d].firstChild:null;g;)1===g.nodeType&&(c?a(g,j,e):a(g,e),e++),g=g.nextSibling,j=c?j.nextSibling:null;d++}}function Ga(a){var b=a.nTable,c=a.aoColumns,e=a.oScroll,d=e.sY,f=e.sX,
  g=e.sXInner,j=c.length,e=Z(a,"bVisible"),i=h("th",a.nTHead),o=b.getAttribute("width"),l=b.parentNode,k=!1,n,m;(n=b.style.width)&&-1!==n.indexOf("%")&&(o=n);for(n=0;n<e.length;n++)m=c[e[n]],null!==m.sWidth&&(m.sWidth=Db(m.sWidthOrig,l),k=!0);if(!k&&!f&&!d&&j==aa(a)&&j==i.length)for(n=0;n<j;n++)c[n].sWidth=s(i.eq(n).width());else{j=h(b).clone().css("visibility","hidden").removeAttr("id");j.find("tbody tr").remove();var p=h("<tr/>").appendTo(j.find("tbody"));j.find("tfoot th, tfoot td").css("width",
  "");i=qa(a,j.find("thead")[0]);for(n=0;n<e.length;n++)m=c[e[n]],i[n].style.width=null!==m.sWidthOrig&&""!==m.sWidthOrig?s(m.sWidthOrig):"";if(a.aoData.length)for(n=0;n<e.length;n++)k=e[n],m=c[k],h(Eb(a,k)).clone(!1).append(m.sContentPadding).appendTo(p);j.appendTo(l);f&&g?j.width(g):f?(j.css("width","auto"),j.width()<l.offsetWidth&&j.width(l.offsetWidth)):d?j.width(l.offsetWidth):o&&j.width(o);Fb(a,j[0]);if(f){for(n=g=0;n<e.length;n++)m=c[e[n]],d=h(i[n]).outerWidth(),g+=null===m.sWidthOrig?d:parseInt(m.sWidth,
  10)+d-h(i[n]).width();j.width(s(g));b.style.width=s(g)}for(n=0;n<e.length;n++)if(m=c[e[n]],d=h(i[n]).width())m.sWidth=s(d);b.style.width=s(j.css("width"));j.remove()}o&&(b.style.width=s(o));if((o||f)&&!a._reszEvt)b=function(){h(Ea).bind("resize.DT-"+a.sInstance,ua(function(){X(a)}))},a.oBrowser.bScrollOversize?setTimeout(b,1E3):b(),a._reszEvt=!0}function ua(a,b){var c=b!==k?b:200,e,d;return function(){var b=this,g=+new Date,j=arguments;e&&g<e+c?(clearTimeout(d),d=setTimeout(function(){e=k;a.apply(b,
  j)},c)):(e=g,a.apply(b,j))}}function Db(a,b){if(!a)return 0;var c=h("<div/>").css("width",s(a)).appendTo(b||Q.body),e=c[0].offsetWidth;c.remove();return e}function Fb(a,b){var c=a.oScroll;if(c.sX||c.sY)c=!c.sX?c.iBarWidth:0,b.style.width=s(h(b).outerWidth()-c)}function Eb(a,b){var c=Gb(a,b);if(0>c)return null;var e=a.aoData[c];return!e.nTr?h("<td/>").html(x(a,c,b,"display"))[0]:e.anCells[b]}function Gb(a,b){for(var c,e=-1,d=-1,f=0,g=a.aoData.length;f<g;f++)c=x(a,f,b,"display")+"",c=c.replace($b,""),
  c.length>e&&(e=c.length,d=f);return d}function s(a){return null===a?"0px":"number"==typeof a?0>a?"0px":a+"px":a.match(/\d$/)?a+"px":a}function Hb(){var a=m.__scrollbarWidth;if(a===k){var b=h("<p/>").css({position:"absolute",top:0,left:0,width:"100%",height:150,padding:0,overflow:"scroll",visibility:"hidden"}).appendTo("body"),a=b[0].offsetWidth-b[0].clientWidth;m.__scrollbarWidth=a;b.remove()}return a}function U(a){var b,c,e=[],d=a.aoColumns,f,g,j,i;b=a.aaSortingFixed;c=h.isPlainObject(b);var o=[];
  f=function(a){a.length&&!h.isArray(a[0])?o.push(a):o.push.apply(o,a)};h.isArray(b)&&f(b);c&&b.pre&&f(b.pre);f(a.aaSorting);c&&b.post&&f(b.post);for(a=0;a<o.length;a++){i=o[a][0];f=d[i].aDataSort;b=0;for(c=f.length;b<c;b++)g=f[b],j=d[g].sType||"string",o[a]._idx===k&&(o[a]._idx=h.inArray(o[a][1],d[g].asSorting)),e.push({src:i,col:g,dir:o[a][1],index:o[a]._idx,type:j,formatter:m.ext.type.order[j+"-pre"]})}return e}function lb(a){var b,c,e=[],d=m.ext.type.order,f=a.aoData,g=0,j,i=a.aiDisplayMaster,h;
  Ha(a);h=U(a);b=0;for(c=h.length;b<c;b++)j=h[b],j.formatter&&g++,Ib(a,j.col);if("ssp"!=B(a)&&0!==h.length){b=0;for(c=i.length;b<c;b++)e[i[b]]=b;g===h.length?i.sort(function(a,b){var c,d,g,j,i=h.length,k=f[a]._aSortData,m=f[b]._aSortData;for(g=0;g<i;g++)if(j=h[g],c=k[j.col],d=m[j.col],c=c<d?-1:c>d?1:0,0!==c)return"asc"===j.dir?c:-c;c=e[a];d=e[b];return c<d?-1:c>d?1:0}):i.sort(function(a,b){var c,g,j,i,k=h.length,m=f[a]._aSortData,r=f[b]._aSortData;for(j=0;j<k;j++)if(i=h[j],c=m[i.col],g=r[i.col],i=d[i.type+
  "-"+i.dir]||d["string-"+i.dir],c=i(c,g),0!==c)return c;c=e[a];g=e[b];return c<g?-1:c>g?1:0})}a.bSorted=!0}function Jb(a){for(var b,c,e=a.aoColumns,d=U(a),a=a.oLanguage.oAria,f=0,g=e.length;f<g;f++){c=e[f];var j=c.asSorting;b=c.sTitle.replace(/<.*?>/g,"");var i=c.nTh;i.removeAttribute("aria-sort");c.bSortable&&(0<d.length&&d[0].col==f?(i.setAttribute("aria-sort","asc"==d[0].dir?"ascending":"descending"),c=j[d[0].index+1]||j[0]):c=j[0],b+="asc"===c?a.sSortAscending:a.sSortDescending);i.setAttribute("aria-label",
  b)}}function Ua(a,b,c,e){var d=a.aaSorting,f=a.aoColumns[b].asSorting,g=function(a,b){var c=a._idx;c===k&&(c=h.inArray(a[1],f));return c+1<f.length?c+1:b?null:0};"number"===typeof d[0]&&(d=a.aaSorting=[d]);c&&a.oFeatures.bSortMulti?(c=h.inArray(b,D(d,"0")),-1!==c?(b=g(d[c],!0),null===b&&1===d.length&&(b=0),null===b?d.splice(c,1):(d[c][1]=f[b],d[c]._idx=b)):(d.push([b,f[0],0]),d[d.length-1]._idx=0)):d.length&&d[0][0]==b?(b=g(d[0]),d.length=1,d[0][1]=f[b],d[0]._idx=b):(d.length=0,d.push([b,f[0]]),d[0]._idx=
  0);N(a);"function"==typeof e&&e(a)}function Oa(a,b,c,e){var d=a.aoColumns[c];Va(b,{},function(b){!1!==d.bSortable&&(a.oFeatures.bProcessing?(C(a,!0),setTimeout(function(){Ua(a,c,b.shiftKey,e);"ssp"!==B(a)&&C(a,!1)},0)):Ua(a,c,b.shiftKey,e))})}function xa(a){var b=a.aLastSort,c=a.oClasses.sSortColumn,e=U(a),d=a.oFeatures,f,g;if(d.bSort&&d.bSortClasses){d=0;for(f=b.length;d<f;d++)g=b[d].src,h(D(a.aoData,"anCells",g)).removeClass(c+(2>d?d+1:3));d=0;for(f=e.length;d<f;d++)g=e[d].src,h(D(a.aoData,"anCells",
  g)).addClass(c+(2>d?d+1:3))}a.aLastSort=e}function Ib(a,b){var c=a.aoColumns[b],e=m.ext.order[c.sSortDataType],d;e&&(d=e.call(a.oInstance,a,b,$(a,b)));for(var f,g=m.ext.type.order[c.sType+"-pre"],j=0,i=a.aoData.length;j<i;j++)if(c=a.aoData[j],c._aSortData||(c._aSortData=[]),!c._aSortData[b]||e)f=e?d[j]:x(a,j,b,"sort"),c._aSortData[b]=g?g(f):f}function ya(a){if(a.oFeatures.bStateSave&&!a.bDestroying){var b={time:+new Date,start:a._iDisplayStart,length:a._iDisplayLength,order:h.extend(!0,[],a.aaSorting),
  search:zb(a.oPreviousSearch),columns:h.map(a.aoColumns,function(b,e){return{visible:b.bVisible,search:zb(a.aoPreSearchCols[e])}})};w(a,"aoStateSaveParams","stateSaveParams",[a,b]);a.oSavedState=b;a.fnStateSaveCallback.call(a.oInstance,a,b)}}function Kb(a){var b,c,e=a.aoColumns;if(a.oFeatures.bStateSave){var d=a.fnStateLoadCallback.call(a.oInstance,a);if(d&&d.time&&(b=w(a,"aoStateLoadParams","stateLoadParams",[a,d]),-1===h.inArray(!1,b)&&(b=a.iStateDuration,!(0<b&&d.time<+new Date-1E3*b)&&e.length===
  d.columns.length))){a.oLoadedState=h.extend(!0,{},d);d.start!==k&&(a._iDisplayStart=d.start,a.iInitDisplayStart=d.start);d.length!==k&&(a._iDisplayLength=d.length);d.order!==k&&(a.aaSorting=[],h.each(d.order,function(b,c){a.aaSorting.push(c[0]>=e.length?[0,c[1]]:c)}));d.search!==k&&h.extend(a.oPreviousSearch,Ab(d.search));b=0;for(c=d.columns.length;b<c;b++){var f=d.columns[b];f.visible!==k&&(e[b].bVisible=f.visible);f.search!==k&&h.extend(a.aoPreSearchCols[b],Ab(f.search))}w(a,"aoStateLoaded","stateLoaded",
  [a,d])}}}function za(a){var b=m.settings,a=h.inArray(a,D(b,"nTable"));return-1!==a?b[a]:null}function I(a,b,c,e){c="DataTables warning: "+(null!==a?"table id="+a.sTableId+" - ":"")+c;e&&(c+=". For more information about this error, please see http://datatables.net/tn/"+e);if(b)Ea.console&&console.log&&console.log(c);else if(b=m.ext,b=b.sErrMode||b.errMode,w(a,null,"error",[a,e,c]),"alert"==b)alert(c);else{if("throw"==b)throw Error(c);"function"==typeof b&&b(a,e,c)}}function E(a,b,c,e){h.isArray(c)?
  h.each(c,function(c,f){h.isArray(f)?E(a,b,f[0],f[1]):E(a,b,f)}):(e===k&&(e=c),b[c]!==k&&(a[e]=b[c]))}function Lb(a,b,c){var e,d;for(d in b)b.hasOwnProperty(d)&&(e=b[d],h.isPlainObject(e)?(h.isPlainObject(a[d])||(a[d]={}),h.extend(!0,a[d],e)):a[d]=c&&"data"!==d&&"aaData"!==d&&h.isArray(e)?e.slice():e);return a}function Va(a,b,c){h(a).bind("click.DT",b,function(b){a.blur();c(b)}).bind("keypress.DT",b,function(a){13===a.which&&(a.preventDefault(),c(a))}).bind("selectstart.DT",function(){return!1})}function z(a,
  b,c,e){c&&a[b].push({fn:c,sName:e})}function w(a,b,c,e){var d=[];b&&(d=h.map(a[b].slice().reverse(),function(b){return b.fn.apply(a.oInstance,e)}));null!==c&&(b=h.Event(c+".dt"),h(a.nTable).trigger(b,e),d.push(b.result));return d}function Sa(a){var b=a._iDisplayStart,c=a.fnDisplayEnd(),e=a._iDisplayLength;b>=c&&(b=c-e);b-=b%e;if(-1===e||0>b)b=0;a._iDisplayStart=b}function Pa(a,b){var c=a.renderer,e=m.ext.renderer[b];return h.isPlainObject(c)&&c[b]?e[c[b]]||e._:"string"===typeof c?e[c]||e._:e._}function B(a){return a.oFeatures.bServerSide?
  "ssp":a.ajax||a.sAjaxSource?"ajax":"dom"}function Wa(a,b){var c=[],c=Mb.numbers_length,e=Math.floor(c/2);b<=c?c=V(0,b):a<=e?(c=V(0,c-2),c.push("ellipsis"),c.push(b-1)):(a>=b-1-e?c=V(b-(c-2),b):(c=V(a-e+2,a+e-1),c.push("ellipsis"),c.push(b-1)),c.splice(0,0,"ellipsis"),c.splice(0,0,0));c.DT_el="span";return c}function db(a){h.each({num:function(b){return Aa(b,a)},"num-fmt":function(b){return Aa(b,a,Xa)},"html-num":function(b){return Aa(b,a,Ba)},"html-num-fmt":function(b){return Aa(b,a,Ba,Xa)}},function(b,
  c){u.type.order[b+a+"-pre"]=c;b.match(/^html\-/)&&(u.type.search[b+a]=u.type.search.html)})}function Nb(a){return function(){var b=[za(this[m.ext.iApiIndex])].concat(Array.prototype.slice.call(arguments));return m.ext.internal[a].apply(this,b)}}var m,u,t,r,v,Ya={},Ob=/[\r\n]/g,Ba=/<.*?>/g,ac=/^[\w\+\-]/,bc=/[\w\+\-]$/,Yb=RegExp("(\\/|\\.|\\*|\\+|\\?|\\||\\(|\\)|\\[|\\]|\\{|\\}|\\\\|\\$|\\^|\\-)","g"),Xa=/[',$\u00a3\u20ac\u00a5%\u2009\u202F\u20BD\u20a9\u20BArfk]/gi,J=function(a){return!a||!0===a||
  "-"===a?!0:!1},Pb=function(a){var b=parseInt(a,10);return!isNaN(b)&&isFinite(a)?b:null},Qb=function(a,b){Ya[b]||(Ya[b]=RegExp(va(b),"g"));return"string"===typeof a&&"."!==b?a.replace(/\./g,"").replace(Ya[b],"."):a},Za=function(a,b,c){var e="string"===typeof a;if(J(a))return!0;b&&e&&(a=Qb(a,b));c&&e&&(a=a.replace(Xa,""));return!isNaN(parseFloat(a))&&isFinite(a)},Rb=function(a,b,c){return J(a)?!0:!(J(a)||"string"===typeof a)?null:Za(a.replace(Ba,""),b,c)?!0:null},D=function(a,b,c){var e=[],d=0,f=a.length;
  if(c!==k)for(;d<f;d++)a[d]&&a[d][b]&&e.push(a[d][b][c]);else for(;d<f;d++)a[d]&&e.push(a[d][b]);return e},ia=function(a,b,c,e){var d=[],f=0,g=b.length;if(e!==k)for(;f<g;f++)a[b[f]][c]&&d.push(a[b[f]][c][e]);else for(;f<g;f++)d.push(a[b[f]][c]);return d},V=function(a,b){var c=[],e;b===k?(b=0,e=a):(e=b,b=a);for(var d=b;d<e;d++)c.push(d);return c},Sb=function(a){for(var b=[],c=0,e=a.length;c<e;c++)a[c]&&b.push(a[c]);return b},Na=function(a){var b=[],c,e,d=a.length,f,g=0;e=0;a:for(;e<d;e++){c=a[e];for(f=
  0;f<g;f++)if(b[f]===c)continue a;b.push(c);g++}return b},A=function(a,b,c){a[b]!==k&&(a[c]=a[b])},ba=/\[.*?\]$/,T=/\(\)$/,wa=h("<div>")[0],Zb=wa.textContent!==k,$b=/<.*?>/g;m=function(a){this.$=function(a,b){return this.api(!0).$(a,b)};this._=function(a,b){return this.api(!0).rows(a,b).data()};this.api=function(a){return a?new t(za(this[u.iApiIndex])):new t(this)};this.fnAddData=function(a,b){var c=this.api(!0),e=h.isArray(a)&&(h.isArray(a[0])||h.isPlainObject(a[0]))?c.rows.add(a):c.row.add(a);(b===
  k||b)&&c.draw();return e.flatten().toArray()};this.fnAdjustColumnSizing=function(a){var b=this.api(!0).columns.adjust(),c=b.settings()[0],e=c.oScroll;a===k||a?b.draw(!1):(""!==e.sX||""!==e.sY)&&Y(c)};this.fnClearTable=function(a){var b=this.api(!0).clear();(a===k||a)&&b.draw()};this.fnClose=function(a){this.api(!0).row(a).child.hide()};this.fnDeleteRow=function(a,b,c){var e=this.api(!0),a=e.rows(a),d=a.settings()[0],h=d.aoData[a[0][0]];a.remove();b&&b.call(this,d,h);(c===k||c)&&e.draw();return h};
  this.fnDestroy=function(a){this.api(!0).destroy(a)};this.fnDraw=function(a){this.api(!0).draw(a)};this.fnFilter=function(a,b,c,e,d,h){d=this.api(!0);null===b||b===k?d.search(a,c,e,h):d.column(b).search(a,c,e,h);d.draw()};this.fnGetData=function(a,b){var c=this.api(!0);if(a!==k){var e=a.nodeName?a.nodeName.toLowerCase():"";return b!==k||"td"==e||"th"==e?c.cell(a,b).data():c.row(a).data()||null}return c.data().toArray()};this.fnGetNodes=function(a){var b=this.api(!0);return a!==k?b.row(a).node():b.rows().nodes().flatten().toArray()};
  this.fnGetPosition=function(a){var b=this.api(!0),c=a.nodeName.toUpperCase();return"TR"==c?b.row(a).index():"TD"==c||"TH"==c?(a=b.cell(a).index(),[a.row,a.columnVisible,a.column]):null};this.fnIsOpen=function(a){return this.api(!0).row(a).child.isShown()};this.fnOpen=function(a,b,c){return this.api(!0).row(a).child(b,c).show().child()[0]};this.fnPageChange=function(a,b){var c=this.api(!0).page(a);(b===k||b)&&c.draw(!1)};this.fnSetColumnVis=function(a,b,c){a=this.api(!0).column(a).visible(b);(c===
  k||c)&&a.columns.adjust().draw()};this.fnSettings=function(){return za(this[u.iApiIndex])};this.fnSort=function(a){this.api(!0).order(a).draw()};this.fnSortListener=function(a,b,c){this.api(!0).order.listener(a,b,c)};this.fnUpdate=function(a,b,c,e,d){var h=this.api(!0);c===k||null===c?h.row(b).data(a):h.cell(b,c).data(a);(d===k||d)&&h.columns.adjust();(e===k||e)&&h.draw();return 0};this.fnVersionCheck=u.fnVersionCheck;var b=this,c=a===k,e=this.length;c&&(a={});this.oApi=this.internal=u.internal;for(var d in m.ext.internal)d&&
  (this[d]=Nb(d));this.each(function(){var d={},d=1<e?Lb(d,a,!0):a,g=0,j,i=this.getAttribute("id"),o=!1,l=m.defaults,q=h(this);if("table"!=this.nodeName.toLowerCase())I(null,0,"Non-table node initialisation ("+this.nodeName+")",2);else{eb(l);fb(l.column);H(l,l,!0);H(l.column,l.column,!0);H(l,h.extend(d,q.data()));var n=m.settings,g=0;for(j=n.length;g<j;g++){var r=n[g];if(r.nTable==this||r.nTHead.parentNode==this||r.nTFoot&&r.nTFoot.parentNode==this){g=d.bRetrieve!==k?d.bRetrieve:l.bRetrieve;if(c||g)return r.oInstance;
  if(d.bDestroy!==k?d.bDestroy:l.bDestroy){r.oInstance.fnDestroy();break}else{I(r,0,"Cannot reinitialise DataTable",3);return}}if(r.sTableId==this.id){n.splice(g,1);break}}if(null===i||""===i)this.id=i="DataTables_Table_"+m.ext._unique++;var p=h.extend(!0,{},m.models.oSettings,{sDestroyWidth:q[0].style.width,sInstance:i,sTableId:i});p.nTable=this;p.oApi=b.internal;p.oInit=d;n.push(p);p.oInstance=1===b.length?b:q.dataTable();eb(d);d.oLanguage&&P(d.oLanguage);d.aLengthMenu&&!d.iDisplayLength&&(d.iDisplayLength=
  h.isArray(d.aLengthMenu[0])?d.aLengthMenu[0][0]:d.aLengthMenu[0]);d=Lb(h.extend(!0,{},l),d);E(p.oFeatures,d,"bPaginate bLengthChange bFilter bSort bSortMulti bInfo bProcessing bAutoWidth bSortClasses bServerSide bDeferRender".split(" "));E(p,d,["asStripeClasses","ajax","fnServerData","fnFormatNumber","sServerMethod","aaSorting","aaSortingFixed","aLengthMenu","sPaginationType","sAjaxSource","sAjaxDataProp","iStateDuration","sDom","bSortCellsTop","iTabIndex","fnStateLoadCallback","fnStateSaveCallback",
  "renderer","searchDelay",["iCookieDuration","iStateDuration"],["oSearch","oPreviousSearch"],["aoSearchCols","aoPreSearchCols"],["iDisplayLength","_iDisplayLength"],["bJQueryUI","bJUI"]]);E(p.oScroll,d,[["sScrollX","sX"],["sScrollXInner","sXInner"],["sScrollY","sY"],["bScrollCollapse","bCollapse"]]);E(p.oLanguage,d,"fnInfoCallback");z(p,"aoDrawCallback",d.fnDrawCallback,"user");z(p,"aoServerParams",d.fnServerParams,"user");z(p,"aoStateSaveParams",d.fnStateSaveParams,"user");z(p,"aoStateLoadParams",
  d.fnStateLoadParams,"user");z(p,"aoStateLoaded",d.fnStateLoaded,"user");z(p,"aoRowCallback",d.fnRowCallback,"user");z(p,"aoRowCreatedCallback",d.fnCreatedRow,"user");z(p,"aoHeaderCallback",d.fnHeaderCallback,"user");z(p,"aoFooterCallback",d.fnFooterCallback,"user");z(p,"aoInitComplete",d.fnInitComplete,"user");z(p,"aoPreDrawCallback",d.fnPreDrawCallback,"user");i=p.oClasses;d.bJQueryUI?(h.extend(i,m.ext.oJUIClasses,d.oClasses),d.sDom===l.sDom&&"lfrtip"===l.sDom&&(p.sDom='<"H"lfr>t<"F"ip>'),p.renderer)?
  h.isPlainObject(p.renderer)&&!p.renderer.header&&(p.renderer.header="jqueryui"):p.renderer="jqueryui":h.extend(i,m.ext.classes,d.oClasses);q.addClass(i.sTable);if(""!==p.oScroll.sX||""!==p.oScroll.sY)p.oScroll.iBarWidth=Hb();!0===p.oScroll.sX&&(p.oScroll.sX="100%");p.iInitDisplayStart===k&&(p.iInitDisplayStart=d.iDisplayStart,p._iDisplayStart=d.iDisplayStart);null!==d.iDeferLoading&&(p.bDeferLoading=!0,g=h.isArray(d.iDeferLoading),p._iRecordsDisplay=g?d.iDeferLoading[0]:d.iDeferLoading,p._iRecordsTotal=
  g?d.iDeferLoading[1]:d.iDeferLoading);var t=p.oLanguage;h.extend(!0,t,d.oLanguage);""!==t.sUrl&&(h.ajax({dataType:"json",url:t.sUrl,success:function(a){P(a);H(l.oLanguage,a);h.extend(true,t,a);ga(p)},error:function(){ga(p)}}),o=!0);null===d.asStripeClasses&&(p.asStripeClasses=[i.sStripeOdd,i.sStripeEven]);var g=p.asStripeClasses,s=q.children("tbody").find("tr").eq(0);-1!==h.inArray(!0,h.map(g,function(a){return s.hasClass(a)}))&&(h("tbody tr",this).removeClass(g.join(" ")),p.asDestroyStripes=g.slice());
  n=[];g=this.getElementsByTagName("thead");0!==g.length&&(da(p.aoHeader,g[0]),n=qa(p));if(null===d.aoColumns){r=[];g=0;for(j=n.length;g<j;g++)r.push(null)}else r=d.aoColumns;g=0;for(j=r.length;g<j;g++)Fa(p,n?n[g]:null);ib(p,d.aoColumnDefs,r,function(a,b){ka(p,a,b)});if(s.length){var u=function(a,b){return a.getAttribute("data-"+b)!==null?b:null};h.each(na(p,s[0]).cells,function(a,b){var c=p.aoColumns[a];if(c.mData===a){var d=u(b,"sort")||u(b,"order"),e=u(b,"filter")||u(b,"search");if(d!==null||e!==
  null){c.mData={_:a+".display",sort:d!==null?a+".@data-"+d:k,type:d!==null?a+".@data-"+d:k,filter:e!==null?a+".@data-"+e:k};ka(p,a)}}})}var v=p.oFeatures;d.bStateSave&&(v.bStateSave=!0,Kb(p,d),z(p,"aoDrawCallback",ya,"state_save"));if(d.aaSorting===k){n=p.aaSorting;g=0;for(j=n.length;g<j;g++)n[g][1]=p.aoColumns[g].asSorting[0]}xa(p);v.bSort&&z(p,"aoDrawCallback",function(){if(p.bSorted){var a=U(p),b={};h.each(a,function(a,c){b[c.src]=c.dir});w(p,null,"order",[p,a,b]);Jb(p)}});z(p,"aoDrawCallback",
  function(){(p.bSorted||B(p)==="ssp"||v.bDeferRender)&&xa(p)},"sc");gb(p);g=q.children("caption").each(function(){this._captionSide=q.css("caption-side")});j=q.children("thead");0===j.length&&(j=h("<thead/>").appendTo(this));p.nTHead=j[0];j=q.children("tbody");0===j.length&&(j=h("<tbody/>").appendTo(this));p.nTBody=j[0];j=q.children("tfoot");if(0===j.length&&0<g.length&&(""!==p.oScroll.sX||""!==p.oScroll.sY))j=h("<tfoot/>").appendTo(this);0===j.length||0===j.children().length?q.addClass(i.sNoFooter):
  0<j.length&&(p.nTFoot=j[0],da(p.aoFooter,p.nTFoot));if(d.aaData)for(g=0;g<d.aaData.length;g++)K(p,d.aaData[g]);else(p.bDeferLoading||"dom"==B(p))&&ma(p,h(p.nTBody).children("tr"));p.aiDisplay=p.aiDisplayMaster.slice();p.bInitialised=!0;!1===o&&ga(p)}});b=null;return this};var Tb=[],y=Array.prototype,cc=function(a){var b,c,e=m.settings,d=h.map(e,function(a){return a.nTable});if(a){if(a.nTable&&a.oApi)return[a];if(a.nodeName&&"table"===a.nodeName.toLowerCase())return b=h.inArray(a,d),-1!==b?[e[b]]:
  null;if(a&&"function"===typeof a.settings)return a.settings().toArray();"string"===typeof a?c=h(a):a instanceof h&&(c=a)}else return[];if(c)return c.map(function(){b=h.inArray(this,d);return-1!==b?e[b]:null}).toArray()};t=function(a,b){if(!(this instanceof t))return new t(a,b);var c=[],e=function(a){(a=cc(a))&&c.push.apply(c,a)};if(h.isArray(a))for(var d=0,f=a.length;d<f;d++)e(a[d]);else e(a);this.context=Na(c);b&&this.push.apply(this,b.toArray?b.toArray():b);this.selector={rows:null,cols:null,opts:null};
  t.extend(this,this,Tb)};m.Api=t;t.prototype={any:function(){return 0!==this.flatten().length},concat:y.concat,context:[],each:function(a){for(var b=0,c=this.length;b<c;b++)a.call(this,this[b],b,this);return this},eq:function(a){var b=this.context;return b.length>a?new t(b[a],this[a]):null},filter:function(a){var b=[];if(y.filter)b=y.filter.call(this,a,this);else for(var c=0,e=this.length;c<e;c++)a.call(this,this[c],c,this)&&b.push(this[c]);return new t(this.context,b)},flatten:function(){var a=[];
  return new t(this.context,a.concat.apply(a,this.toArray()))},join:y.join,indexOf:y.indexOf||function(a,b){for(var c=b||0,e=this.length;c<e;c++)if(this[c]===a)return c;return-1},iterator:function(a,b,c,e){var d=[],f,g,h,i,o,l=this.context,q,n,m=this.selector;"string"===typeof a&&(e=c,c=b,b=a,a=!1);g=0;for(h=l.length;g<h;g++){var p=new t(l[g]);if("table"===b)f=c.call(p,l[g],g),f!==k&&d.push(f);else if("columns"===b||"rows"===b)f=c.call(p,l[g],this[g],g),f!==k&&d.push(f);else if("column"===b||"column-rows"===
  b||"row"===b||"cell"===b){n=this[g];"column-rows"===b&&(q=Ca(l[g],m.opts));i=0;for(o=n.length;i<o;i++)f=n[i],f="cell"===b?c.call(p,l[g],f.row,f.column,g,i):c.call(p,l[g],f,g,i,q),f!==k&&d.push(f)}}return d.length||e?(a=new t(l,a?d.concat.apply([],d):d),b=a.selector,b.rows=m.rows,b.cols=m.cols,b.opts=m.opts,a):this},lastIndexOf:y.lastIndexOf||function(a,b){return this.indexOf.apply(this.toArray.reverse(),arguments)},length:0,map:function(a){var b=[];if(y.map)b=y.map.call(this,a,this);else for(var c=
  0,e=this.length;c<e;c++)b.push(a.call(this,this[c],c));return new t(this.context,b)},pluck:function(a){return this.map(function(b){return b[a]})},pop:y.pop,push:y.push,reduce:y.reduce||function(a,b){return hb(this,a,b,0,this.length,1)},reduceRight:y.reduceRight||function(a,b){return hb(this,a,b,this.length-1,-1,-1)},reverse:y.reverse,selector:null,shift:y.shift,sort:y.sort,splice:y.splice,toArray:function(){return y.slice.call(this)},to$:function(){return h(this)},toJQuery:function(){return h(this)},
  unique:function(){return new t(this.context,Na(this))},unshift:y.unshift};t.extend=function(a,b,c){if(c.length&&b&&(b instanceof t||b.__dt_wrapper)){var e,d,f,g=function(a,b,c){return function(){var d=b.apply(a,arguments);t.extend(d,d,c.methodExt);return d}};e=0;for(d=c.length;e<d;e++)f=c[e],b[f.name]="function"===typeof f.val?g(a,f.val,f):h.isPlainObject(f.val)?{}:f.val,b[f.name].__dt_wrapper=!0,t.extend(a,b[f.name],f.propExt)}};t.register=r=function(a,b){if(h.isArray(a))for(var c=0,e=a.length;c<
  e;c++)t.register(a[c],b);else for(var d=a.split("."),f=Tb,g,j,c=0,e=d.length;c<e;c++){g=(j=-1!==d[c].indexOf("()"))?d[c].replace("()",""):d[c];var i;a:{i=0;for(var o=f.length;i<o;i++)if(f[i].name===g){i=f[i];break a}i=null}i||(i={name:g,val:{},methodExt:[],propExt:[]},f.push(i));c===e-1?i.val=b:f=j?i.methodExt:i.propExt}};t.registerPlural=v=function(a,b,c){t.register(a,c);t.register(b,function(){var a=c.apply(this,arguments);return a===this?this:a instanceof t?a.length?h.isArray(a[0])?new t(a.context,
  a[0]):a[0]:k:a})};r("tables()",function(a){var b;if(a){b=t;var c=this.context;if("number"===typeof a)a=[c[a]];else var e=h.map(c,function(a){return a.nTable}),a=h(e).filter(a).map(function(){var a=h.inArray(this,e);return c[a]}).toArray();b=new b(a)}else b=this;return b});r("table()",function(a){var a=this.tables(a),b=a.context;return b.length?new t(b[0]):a});v("tables().nodes()","table().node()",function(){return this.iterator("table",function(a){return a.nTable},1)});v("tables().body()","table().body()",
  function(){return this.iterator("table",function(a){return a.nTBody},1)});v("tables().header()","table().header()",function(){return this.iterator("table",function(a){return a.nTHead},1)});v("tables().footer()","table().footer()",function(){return this.iterator("table",function(a){return a.nTFoot},1)});v("tables().containers()","table().container()",function(){return this.iterator("table",function(a){return a.nTableWrapper},1)});r("draw()",function(a){return this.iterator("table",function(b){N(b,
  !1===a)})});r("page()",function(a){return a===k?this.page.info().page:this.iterator("table",function(b){Ta(b,a)})});r("page.info()",function(){if(0===this.context.length)return k;var a=this.context[0],b=a._iDisplayStart,c=a._iDisplayLength,e=a.fnRecordsDisplay(),d=-1===c;return{page:d?0:Math.floor(b/c),pages:d?1:Math.ceil(e/c),start:b,end:a.fnDisplayEnd(),length:c,recordsTotal:a.fnRecordsTotal(),recordsDisplay:e}});r("page.len()",function(a){return a===k?0!==this.context.length?this.context[0]._iDisplayLength:
  k:this.iterator("table",function(b){Ra(b,a)})});var Ub=function(a,b,c){if(c){var e=new t(a);e.one("draw",function(){c(e.ajax.json())})}"ssp"==B(a)?N(a,b):(C(a,!0),ra(a,[],function(c){oa(a);for(var c=sa(a,c),e=0,g=c.length;e<g;e++)K(a,c[e]);N(a,b);C(a,!1)}))};r("ajax.json()",function(){var a=this.context;if(0<a.length)return a[0].json});r("ajax.params()",function(){var a=this.context;if(0<a.length)return a[0].oAjaxData});r("ajax.reload()",function(a,b){return this.iterator("table",function(c){Ub(c,
  !1===b,a)})});r("ajax.url()",function(a){var b=this.context;if(a===k){if(0===b.length)return k;b=b[0];return b.ajax?h.isPlainObject(b.ajax)?b.ajax.url:b.ajax:b.sAjaxSource}return this.iterator("table",function(b){h.isPlainObject(b.ajax)?b.ajax.url=a:b.ajax=a})});r("ajax.url().load()",function(a,b){return this.iterator("table",function(c){Ub(c,!1===b,a)})});var $a=function(a,b,c,e,d){var f=[],g,j,i,o,l,q;i=typeof b;if(!b||"string"===i||"function"===i||b.length===k)b=[b];i=0;for(o=b.length;i<o;i++){j=
  b[i]&&b[i].split?b[i].split(","):[b[i]];l=0;for(q=j.length;l<q;l++)(g=c("string"===typeof j[l]?h.trim(j[l]):j[l]))&&g.length&&f.push.apply(f,g)}a=u.selector[a];if(a.length){i=0;for(o=a.length;i<o;i++)f=a[i](e,d,f)}return f},ab=function(a){a||(a={});a.filter&&a.search===k&&(a.search=a.filter);return h.extend({search:"none",order:"current",page:"all"},a)},bb=function(a){for(var b=0,c=a.length;b<c;b++)if(0<a[b].length)return a[0]=a[b],a[0].length=1,a.length=1,a.context=[a.context[b]],a;a.length=0;return a},
  Ca=function(a,b){var c,e,d,f=[],g=a.aiDisplay;c=a.aiDisplayMaster;var j=b.search;e=b.order;d=b.page;if("ssp"==B(a))return"removed"===j?[]:V(0,c.length);if("current"==d){c=a._iDisplayStart;for(e=a.fnDisplayEnd();c<e;c++)f.push(g[c])}else if("current"==e||"applied"==e)f="none"==j?c.slice():"applied"==j?g.slice():h.map(c,function(a){return-1===h.inArray(a,g)?a:null});else if("index"==e||"original"==e){c=0;for(e=a.aoData.length;c<e;c++)"none"==j?f.push(c):(d=h.inArray(c,g),(-1===d&&"removed"==j||0<=d&&
  "applied"==j)&&f.push(c))}return f};r("rows()",function(a,b){a===k?a="":h.isPlainObject(a)&&(b=a,a="");var b=ab(b),c=this.iterator("table",function(c){var d=b;return $a("row",a,function(a){var b=Pb(a);if(b!==null&&!d)return[b];var j=Ca(c,d);if(b!==null&&h.inArray(b,j)!==-1)return[b];if(!a)return j;if(typeof a==="function")return h.map(j,function(b){var d=c.aoData[b];return a(b,d._aData,d.nTr)?b:null});b=Sb(ia(c.aoData,j,"nTr"));return a.nodeName&&h.inArray(a,b)!==-1?[a._DT_RowIndex]:h(b).filter(a).map(function(){return this._DT_RowIndex}).toArray()},
  c,d)},1);c.selector.rows=a;c.selector.opts=b;return c});r("rows().nodes()",function(){return this.iterator("row",function(a,b){return a.aoData[b].nTr||k},1)});r("rows().data()",function(){return this.iterator(!0,"rows",function(a,b){return ia(a.aoData,b,"_aData")},1)});v("rows().cache()","row().cache()",function(a){return this.iterator("row",function(b,c){var e=b.aoData[c];return"search"===a?e._aFilterData:e._aSortData},1)});v("rows().invalidate()","row().invalidate()",function(a){return this.iterator("row",
  function(b,c){ca(b,c,a)})});v("rows().indexes()","row().index()",function(){return this.iterator("row",function(a,b){return b},1)});v("rows().remove()","row().remove()",function(){var a=this;return this.iterator("row",function(b,c,e){var d=b.aoData;d.splice(c,1);for(var f=0,g=d.length;f<g;f++)null!==d[f].nTr&&(d[f].nTr._DT_RowIndex=f);h.inArray(c,b.aiDisplay);pa(b.aiDisplayMaster,c);pa(b.aiDisplay,c);pa(a[e],c,!1);Sa(b)})});r("rows.add()",function(a){var b=this.iterator("table",function(b){var c,
  f,g,h=[];f=0;for(g=a.length;f<g;f++)c=a[f],c.nodeName&&"TR"===c.nodeName.toUpperCase()?h.push(ma(b,c)[0]):h.push(K(b,c));return h},1),c=this.rows(-1);c.pop();c.push.apply(c,b.toArray());return c});r("row()",function(a,b){return bb(this.rows(a,b))});r("row().data()",function(a){var b=this.context;if(a===k)return b.length&&this.length?b[0].aoData[this[0]]._aData:k;b[0].aoData[this[0]]._aData=a;ca(b[0],this[0],"data");return this});r("row().node()",function(){var a=this.context;return a.length&&this.length?
  a[0].aoData[this[0]].nTr||null:null});r("row.add()",function(a){a instanceof h&&a.length&&(a=a[0]);var b=this.iterator("table",function(b){return a.nodeName&&"TR"===a.nodeName.toUpperCase()?ma(b,a)[0]:K(b,a)});return this.row(b[0])});var cb=function(a,b){var c=a.context;c.length&&(c=c[0].aoData[b!==k?b:a[0]],c._details&&(c._details.remove(),c._detailsShow=k,c._details=k))},Vb=function(a,b){var c=a.context;if(c.length&&a.length){var e=c[0].aoData[a[0]];if(e._details){(e._detailsShow=b)?e._details.insertAfter(e.nTr):
  e._details.detach();var d=c[0],f=new t(d),g=d.aoData;f.off("draw.dt.DT_details column-visibility.dt.DT_details destroy.dt.DT_details");0<D(g,"_details").length&&(f.on("draw.dt.DT_details",function(a,b){d===b&&f.rows({page:"current"}).eq(0).each(function(a){a=g[a];a._detailsShow&&a._details.insertAfter(a.nTr)})}),f.on("column-visibility.dt.DT_details",function(a,b){if(d===b)for(var c,e=aa(b),f=0,h=g.length;f<h;f++)c=g[f],c._details&&c._details.children("td[colspan]").attr("colspan",e)}),f.on("destroy.dt.DT_details",
  function(a,b){if(d===b)for(var c=0,e=g.length;c<e;c++)g[c]._details&&cb(f,c)}))}}};r("row().child()",function(a,b){var c=this.context;if(a===k)return c.length&&this.length?c[0].aoData[this[0]]._details:k;if(!0===a)this.child.show();else if(!1===a)cb(this);else if(c.length&&this.length){var e=c[0],c=c[0].aoData[this[0]],d=[],f=function(a,b){if(h.isArray(a)||a instanceof h)for(var c=0,k=a.length;c<k;c++)f(a[c],b);else a.nodeName&&"tr"===a.nodeName.toLowerCase()?d.push(a):(c=h("<tr><td/></tr>").addClass(b),
  h("td",c).addClass(b).html(a)[0].colSpan=aa(e),d.push(c[0]))};f(a,b);c._details&&c._details.remove();c._details=h(d);c._detailsShow&&c._details.insertAfter(c.nTr)}return this});r(["row().child.show()","row().child().show()"],function(){Vb(this,!0);return this});r(["row().child.hide()","row().child().hide()"],function(){Vb(this,!1);return this});r(["row().child.remove()","row().child().remove()"],function(){cb(this);return this});r("row().child.isShown()",function(){var a=this.context;return a.length&&
  this.length?a[0].aoData[this[0]]._detailsShow||!1:!1});var dc=/^(.+):(name|visIdx|visible)$/,Wb=function(a,b,c,e,d){for(var c=[],e=0,f=d.length;e<f;e++)c.push(x(a,d[e],b));return c};r("columns()",function(a,b){a===k?a="":h.isPlainObject(a)&&(b=a,a="");var b=ab(b),c=this.iterator("table",function(c){var d=a,f=b,g=c.aoColumns,j=D(g,"sName"),i=D(g,"nTh");return $a("column",d,function(a){var b=Pb(a);if(a==="")return V(g.length);if(b!==null)return[b>=0?b:g.length+b];if(typeof a==="function"){var d=Ca(c,
  f);return h.map(g,function(b,f){return a(f,Wb(c,f,0,0,d),i[f])?f:null})}var k=typeof a==="string"?a.match(dc):"";if(k)switch(k[2]){case "visIdx":case "visible":b=parseInt(k[1],10);if(b<0){var m=h.map(g,function(a,b){return a.bVisible?b:null});return[m[m.length+b]]}return[la(c,b)];case "name":return h.map(j,function(a,b){return a===k[1]?b:null})}else return h(i).filter(a).map(function(){return h.inArray(this,i)}).toArray()},c,f)},1);c.selector.cols=a;c.selector.opts=b;return c});v("columns().header()",
  "column().header()",function(){return this.iterator("column",function(a,b){return a.aoColumns[b].nTh},1)});v("columns().footer()","column().footer()",function(){return this.iterator("column",function(a,b){return a.aoColumns[b].nTf},1)});v("columns().data()","column().data()",function(){return this.iterator("column-rows",Wb,1)});v("columns().dataSrc()","column().dataSrc()",function(){return this.iterator("column",function(a,b){return a.aoColumns[b].mData},1)});v("columns().cache()","column().cache()",
  function(a){return this.iterator("column-rows",function(b,c,e,d,f){return ia(b.aoData,f,"search"===a?"_aFilterData":"_aSortData",c)},1)});v("columns().nodes()","column().nodes()",function(){return this.iterator("column-rows",function(a,b,c,e,d){return ia(a.aoData,d,"anCells",b)},1)});v("columns().visible()","column().visible()",function(a,b){return this.iterator("column",function(c,e){if(a===k)return c.aoColumns[e].bVisible;var d=c.aoColumns,f=d[e],g=c.aoData,j,i,m;if(a!==k&&f.bVisible!==a){if(a){var l=
  h.inArray(!0,D(d,"bVisible"),e+1);j=0;for(i=g.length;j<i;j++)m=g[j].nTr,d=g[j].anCells,m&&m.insertBefore(d[e],d[l]||null)}else h(D(c.aoData,"anCells",e)).detach();f.bVisible=a;ea(c,c.aoHeader);ea(c,c.aoFooter);if(b===k||b)X(c),(c.oScroll.sX||c.oScroll.sY)&&Y(c);w(c,null,"column-visibility",[c,e,a]);ya(c)}})});v("columns().indexes()","column().index()",function(a){return this.iterator("column",function(b,c){return"visible"===a?$(b,c):c},1)});r("columns.adjust()",function(){return this.iterator("table",
  function(a){X(a)},1)});r("column.index()",function(a,b){if(0!==this.context.length){var c=this.context[0];if("fromVisible"===a||"toData"===a)return la(c,b);if("fromData"===a||"toVisible"===a)return $(c,b)}});r("column()",function(a,b){return bb(this.columns(a,b))});r("cells()",function(a,b,c){h.isPlainObject(a)&&(a.row===k?(c=a,a=null):(c=b,b=null));h.isPlainObject(b)&&(c=b,b=null);if(null===b||b===k)return this.iterator("table",function(b){var d=a,e=ab(c),f=b.aoData,g=Ca(b,e),i=Sb(ia(f,g,"anCells")),
  j=h([].concat.apply([],i)),l,m=b.aoColumns.length,o,r,t,s,u,v;return $a("cell",d,function(a){var c=typeof a==="function";if(a===null||a===k||c){o=[];r=0;for(t=g.length;r<t;r++){l=g[r];for(s=0;s<m;s++){u={row:l,column:s};if(c){v=b.aoData[l];a(u,x(b,l,s),v.anCells?v.anCells[s]:null)&&o.push(u)}else o.push(u)}}return o}return h.isPlainObject(a)?[a]:j.filter(a).map(function(a,b){l=b.parentNode._DT_RowIndex;return{row:l,column:h.inArray(b,f[l].anCells)}}).toArray()},b,e)});var e=this.columns(b,c),d=this.rows(a,
  c),f,g,j,i,m,l=this.iterator("table",function(a,b){f=[];g=0;for(j=d[b].length;g<j;g++){i=0;for(m=e[b].length;i<m;i++)f.push({row:d[b][g],column:e[b][i]})}return f},1);h.extend(l.selector,{cols:b,rows:a,opts:c});return l});v("cells().nodes()","cell().node()",function(){return this.iterator("cell",function(a,b,c){return(a=a.aoData[b].anCells)?a[c]:k},1)});r("cells().data()",function(){return this.iterator("cell",function(a,b,c){return x(a,b,c)},1)});v("cells().cache()","cell().cache()",function(a){a=
  "search"===a?"_aFilterData":"_aSortData";return this.iterator("cell",function(b,c,e){return b.aoData[c][a][e]},1)});v("cells().render()","cell().render()",function(a){return this.iterator("cell",function(b,c,e){return x(b,c,e,a)},1)});v("cells().indexes()","cell().index()",function(){return this.iterator("cell",function(a,b,c){return{row:b,column:c,columnVisible:$(a,c)}},1)});v("cells().invalidate()","cell().invalidate()",function(a){return this.iterator("cell",function(b,c,e){ca(b,c,a,e)})});r("cell()",
  function(a,b,c){return bb(this.cells(a,b,c))});r("cell().data()",function(a){var b=this.context,c=this[0];if(a===k)return b.length&&c.length?x(b[0],c[0].row,c[0].column):k;Ia(b[0],c[0].row,c[0].column,a);ca(b[0],c[0].row,"data",c[0].column);return this});r("order()",function(a,b){var c=this.context;if(a===k)return 0!==c.length?c[0].aaSorting:k;"number"===typeof a?a=[[a,b]]:h.isArray(a[0])||(a=Array.prototype.slice.call(arguments));return this.iterator("table",function(b){b.aaSorting=a.slice()})});
  r("order.listener()",function(a,b,c){return this.iterator("table",function(e){Oa(e,a,b,c)})});r(["columns().order()","column().order()"],function(a){var b=this;return this.iterator("table",function(c,e){var d=[];h.each(b[e],function(b,c){d.push([c,a])});c.aaSorting=d})});r("search()",function(a,b,c,e){var d=this.context;return a===k?0!==d.length?d[0].oPreviousSearch.sSearch:k:this.iterator("table",function(d){d.oFeatures.bFilter&&fa(d,h.extend({},d.oPreviousSearch,{sSearch:a+"",bRegex:null===b?!1:
  b,bSmart:null===c?!0:c,bCaseInsensitive:null===e?!0:e}),1)})});v("columns().search()","column().search()",function(a,b,c,e){return this.iterator("column",function(d,f){var g=d.aoPreSearchCols;if(a===k)return g[f].sSearch;d.oFeatures.bFilter&&(h.extend(g[f],{sSearch:a+"",bRegex:null===b?!1:b,bSmart:null===c?!0:c,bCaseInsensitive:null===e?!0:e}),fa(d,d.oPreviousSearch,1))})});r("state()",function(){return this.context.length?this.context[0].oSavedState:null});r("state.clear()",function(){return this.iterator("table",
  function(a){a.fnStateSaveCallback.call(a.oInstance,a,{})})});r("state.loaded()",function(){return this.context.length?this.context[0].oLoadedState:null});r("state.save()",function(){return this.iterator("table",function(a){ya(a)})});m.versionCheck=m.fnVersionCheck=function(a){for(var b=m.version.split("."),a=a.split("."),c,e,d=0,f=a.length;d<f;d++)if(c=parseInt(b[d],10)||0,e=parseInt(a[d],10)||0,c!==e)return c>e;return!0};m.isDataTable=m.fnIsDataTable=function(a){var b=h(a).get(0),c=!1;h.each(m.settings,
  function(a,d){var f=d.nScrollHead?h("table",d.nScrollHead)[0]:null,g=d.nScrollFoot?h("table",d.nScrollFoot)[0]:null;if(d.nTable===b||f===b||g===b)c=!0});return c};m.tables=m.fnTables=function(a){return h.map(m.settings,function(b){if(!a||a&&h(b.nTable).is(":visible"))return b.nTable})};m.util={throttle:ua,escapeRegex:va};m.camelToHungarian=H;r("$()",function(a,b){var c=this.rows(b).nodes(),c=h(c);return h([].concat(c.filter(a).toArray(),c.find(a).toArray()))});h.each(["on","one","off"],function(a,
  b){r(b+"()",function(){var a=Array.prototype.slice.call(arguments);a[0].match(/\.dt\b/)||(a[0]+=".dt");var e=h(this.tables().nodes());e[b].apply(e,a);return this})});r("clear()",function(){return this.iterator("table",function(a){oa(a)})});r("settings()",function(){return new t(this.context,this.context)});r("init()",function(){var a=this.context;return a.length?a[0].oInit:null});r("data()",function(){return this.iterator("table",function(a){return D(a.aoData,"_aData")}).flatten()});r("destroy()",
  function(a){a=a||!1;return this.iterator("table",function(b){var c=b.nTableWrapper.parentNode,e=b.oClasses,d=b.nTable,f=b.nTBody,g=b.nTHead,j=b.nTFoot,i=h(d),f=h(f),k=h(b.nTableWrapper),l=h.map(b.aoData,function(a){return a.nTr}),q;b.bDestroying=!0;w(b,"aoDestroyCallback","destroy",[b]);a||(new t(b)).columns().visible(!0);k.unbind(".DT").find(":not(tbody *)").unbind(".DT");h(Ea).unbind(".DT-"+b.sInstance);d!=g.parentNode&&(i.children("thead").detach(),i.append(g));j&&d!=j.parentNode&&(i.children("tfoot").detach(),
  i.append(j));i.detach();k.detach();b.aaSorting=[];b.aaSortingFixed=[];xa(b);h(l).removeClass(b.asStripeClasses.join(" "));h("th, td",g).removeClass(e.sSortable+" "+e.sSortableAsc+" "+e.sSortableDesc+" "+e.sSortableNone);b.bJUI&&(h("th span."+e.sSortIcon+", td span."+e.sSortIcon,g).detach(),h("th, td",g).each(function(){var a=h("div."+e.sSortJUIWrapper,this);h(this).append(a.contents());a.detach()}));!a&&c&&c.insertBefore(d,b.nTableReinsertBefore);f.children().detach();f.append(l);i.css("width",b.sDestroyWidth).removeClass(e.sTable);
  (q=b.asDestroyStripes.length)&&f.children().each(function(a){h(this).addClass(b.asDestroyStripes[a%q])});c=h.inArray(b,m.settings);-1!==c&&m.settings.splice(c,1)})});h.each(["column","row","cell"],function(a,b){r(b+"s().every()",function(a){return this.iterator(b,function(e,d,f){a.call((new t(e))[b](d,f))})})});r("i18n()",function(a,b,c){var e=this.context[0],a=R(a)(e.oLanguage);a===k&&(a=b);c!==k&&h.isPlainObject(a)&&(a=a[c]!==k?a[c]:a._);return a.replace("%d",c)});m.version="1.10.7";m.settings=
  [];m.models={};m.models.oSearch={bCaseInsensitive:!0,sSearch:"",bRegex:!1,bSmart:!0};m.models.oRow={nTr:null,anCells:null,_aData:[],_aSortData:null,_aFilterData:null,_sFilterRow:null,_sRowStripe:"",src:null};m.models.oColumn={idx:null,aDataSort:null,asSorting:null,bSearchable:null,bSortable:null,bVisible:null,_sManualType:null,_bAttrSrc:!1,fnCreatedCell:null,fnGetData:null,fnSetData:null,mData:null,mRender:null,nTh:null,nTf:null,sClass:null,sContentPadding:null,sDefaultContent:null,sName:null,sSortDataType:"std",
  sSortingClass:null,sSortingClassJUI:null,sTitle:null,sType:null,sWidth:null,sWidthOrig:null};m.defaults={aaData:null,aaSorting:[[0,"asc"]],aaSortingFixed:[],ajax:null,aLengthMenu:[10,25,50,100],aoColumns:null,aoColumnDefs:null,aoSearchCols:[],asStripeClasses:null,bAutoWidth:!0,bDeferRender:!1,bDestroy:!1,bFilter:!0,bInfo:!0,bJQueryUI:!1,bLengthChange:!0,bPaginate:!0,bProcessing:!1,bRetrieve:!1,bScrollCollapse:!1,bServerSide:!1,bSort:!0,bSortMulti:!0,bSortCellsTop:!1,bSortClasses:!0,bStateSave:!1,
  fnCreatedRow:null,fnDrawCallback:null,fnFooterCallback:null,fnFormatNumber:function(a){return a.toString().replace(/\B(?=(\d{3})+(?!\d))/g,this.oLanguage.sThousands)},fnHeaderCallback:null,fnInfoCallback:null,fnInitComplete:null,fnPreDrawCallback:null,fnRowCallback:null,fnServerData:null,fnServerParams:null,fnStateLoadCallback:function(a){try{return JSON.parse((-1===a.iStateDuration?sessionStorage:localStorage).getItem("DataTables_"+a.sInstance+"_"+location.pathname))}catch(b){}},fnStateLoadParams:null,
  fnStateLoaded:null,fnStateSaveCallback:function(a,b){try{(-1===a.iStateDuration?sessionStorage:localStorage).setItem("DataTables_"+a.sInstance+"_"+location.pathname,JSON.stringify(b))}catch(c){}},fnStateSaveParams:null,iStateDuration:7200,iDeferLoading:null,iDisplayLength:10,iDisplayStart:0,iTabIndex:0,oClasses:{},oLanguage:{oAria:{sSortAscending:": activate to sort column ascending",sSortDescending:": activate to sort column descending"},oPaginate:{sFirst:"First",sLast:"Last",sNext:"Next",sPrevious:"Previous"},
  sEmptyTable:"No data available in table",sInfo:"Showing _START_ to _END_ of _TOTAL_ entries",sInfoEmpty:"Showing 0 to 0 of 0 entries",sInfoFiltered:"(filtered from _MAX_ total entries)",sInfoPostFix:"",sDecimal:"",sThousands:",",sLengthMenu:"Show _MENU_ entries",sLoadingRecords:"Loading...",sProcessing:"Processing...",sSearch:"Search:",sSearchPlaceholder:"",sUrl:"",sZeroRecords:"No matching records found"},oSearch:h.extend({},m.models.oSearch),sAjaxDataProp:"data",sAjaxSource:null,sDom:"lfrtip",searchDelay:null,
  sPaginationType:"simple_numbers",sScrollX:"",sScrollXInner:"",sScrollY:"",sServerMethod:"GET",renderer:null};W(m.defaults);m.defaults.column={aDataSort:null,iDataSort:-1,asSorting:["asc","desc"],bSearchable:!0,bSortable:!0,bVisible:!0,fnCreatedCell:null,mData:null,mRender:null,sCellType:"td",sClass:"",sContentPadding:"",sDefaultContent:null,sName:"",sSortDataType:"std",sTitle:null,sType:null,sWidth:null};W(m.defaults.column);m.models.oSettings={oFeatures:{bAutoWidth:null,bDeferRender:null,bFilter:null,
  bInfo:null,bLengthChange:null,bPaginate:null,bProcessing:null,bServerSide:null,bSort:null,bSortMulti:null,bSortClasses:null,bStateSave:null},oScroll:{bCollapse:null,iBarWidth:0,sX:null,sXInner:null,sY:null},oLanguage:{fnInfoCallback:null},oBrowser:{bScrollOversize:!1,bScrollbarLeft:!1},ajax:null,aanFeatures:[],aoData:[],aiDisplay:[],aiDisplayMaster:[],aoColumns:[],aoHeader:[],aoFooter:[],oPreviousSearch:{},aoPreSearchCols:[],aaSorting:null,aaSortingFixed:[],asStripeClasses:null,asDestroyStripes:[],
  sDestroyWidth:0,aoRowCallback:[],aoHeaderCallback:[],aoFooterCallback:[],aoDrawCallback:[],aoRowCreatedCallback:[],aoPreDrawCallback:[],aoInitComplete:[],aoStateSaveParams:[],aoStateLoadParams:[],aoStateLoaded:[],sTableId:"",nTable:null,nTHead:null,nTFoot:null,nTBody:null,nTableWrapper:null,bDeferLoading:!1,bInitialised:!1,aoOpenRows:[],sDom:null,searchDelay:null,sPaginationType:"two_button",iStateDuration:0,aoStateSave:[],aoStateLoad:[],oSavedState:null,oLoadedState:null,sAjaxSource:null,sAjaxDataProp:null,
  bAjaxDataGet:!0,jqXHR:null,json:k,oAjaxData:k,fnServerData:null,aoServerParams:[],sServerMethod:null,fnFormatNumber:null,aLengthMenu:null,iDraw:0,bDrawing:!1,iDrawError:-1,_iDisplayLength:10,_iDisplayStart:0,_iRecordsTotal:0,_iRecordsDisplay:0,bJUI:null,oClasses:{},bFiltered:!1,bSorted:!1,bSortCellsTop:null,oInit:null,aoDestroyCallback:[],fnRecordsTotal:function(){return"ssp"==B(this)?1*this._iRecordsTotal:this.aiDisplayMaster.length},fnRecordsDisplay:function(){return"ssp"==B(this)?1*this._iRecordsDisplay:
  this.aiDisplay.length},fnDisplayEnd:function(){var a=this._iDisplayLength,b=this._iDisplayStart,c=b+a,e=this.aiDisplay.length,d=this.oFeatures,f=d.bPaginate;return d.bServerSide?!1===f||-1===a?b+e:Math.min(b+a,this._iRecordsDisplay):!f||c>e||-1===a?e:c},oInstance:null,sInstance:null,iTabIndex:0,nScrollHead:null,nScrollFoot:null,aLastSort:[],oPlugins:{}};m.ext=u={buttons:{},classes:{},errMode:"alert",feature:[],search:[],selector:{cell:[],column:[],row:[]},internal:{},legacy:{ajax:null},pager:{},renderer:{pageButton:{},
  header:{}},order:{},type:{detect:[],search:{},order:{}},_unique:0,fnVersionCheck:m.fnVersionCheck,iApiIndex:0,oJUIClasses:{},sVersion:m.version};h.extend(u,{afnFiltering:u.search,aTypes:u.type.detect,ofnSearch:u.type.search,oSort:u.type.order,afnSortData:u.order,aoFeatures:u.feature,oApi:u.internal,oStdClasses:u.classes,oPagination:u.pager});h.extend(m.ext.classes,{sTable:"dataTable",sNoFooter:"no-footer",sPageButton:"paginate_button",sPageButtonActive:"current",sPageButtonDisabled:"disabled",sStripeOdd:"odd",
  sStripeEven:"even",sRowEmpty:"dataTables_empty",sWrapper:"dataTables_wrapper",sFilter:"dataTables_filter",sInfo:"dataTables_info",sPaging:"dataTables_paginate paging_",sLength:"dataTables_length",sProcessing:"dataTables_processing",sSortAsc:"sorting_asc",sSortDesc:"sorting_desc",sSortable:"sorting",sSortableAsc:"sorting_asc_disabled",sSortableDesc:"sorting_desc_disabled",sSortableNone:"sorting_disabled",sSortColumn:"sorting_",sFilterInput:"",sLengthSelect:"",sScrollWrapper:"dataTables_scroll",sScrollHead:"dataTables_scrollHead",
  sScrollHeadInner:"dataTables_scrollHeadInner",sScrollBody:"dataTables_scrollBody",sScrollFoot:"dataTables_scrollFoot",sScrollFootInner:"dataTables_scrollFootInner",sHeaderTH:"",sFooterTH:"",sSortJUIAsc:"",sSortJUIDesc:"",sSortJUI:"",sSortJUIAscAllowed:"",sSortJUIDescAllowed:"",sSortJUIWrapper:"",sSortIcon:"",sJUIHeader:"",sJUIFooter:""});var Da="",Da="",F=Da+"ui-state-default",ja=Da+"css_right ui-icon ui-icon-",Xb=Da+"fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix";h.extend(m.ext.oJUIClasses,
  m.ext.classes,{sPageButton:"fg-button ui-button "+F,sPageButtonActive:"ui-state-disabled",sPageButtonDisabled:"ui-state-disabled",sPaging:"dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi ui-buttonset-multi paging_",sSortAsc:F+" sorting_asc",sSortDesc:F+" sorting_desc",sSortable:F+" sorting",sSortableAsc:F+" sorting_asc_disabled",sSortableDesc:F+" sorting_desc_disabled",sSortableNone:F+" sorting_disabled",sSortJUIAsc:ja+"triangle-1-n",sSortJUIDesc:ja+"triangle-1-s",sSortJUI:ja+"carat-2-n-s",
  sSortJUIAscAllowed:ja+"carat-1-n",sSortJUIDescAllowed:ja+"carat-1-s",sSortJUIWrapper:"DataTables_sort_wrapper",sSortIcon:"DataTables_sort_icon",sScrollHead:"dataTables_scrollHead "+F,sScrollFoot:"dataTables_scrollFoot "+F,sHeaderTH:F,sFooterTH:F,sJUIHeader:Xb+" ui-corner-tl ui-corner-tr",sJUIFooter:Xb+" ui-corner-bl ui-corner-br"});var Mb=m.ext.pager;h.extend(Mb,{simple:function(){return["previous","next"]},full:function(){return["first","previous","next","last"]},simple_numbers:function(a,b){return["previous",
  Wa(a,b),"next"]},full_numbers:function(a,b){return["first","previous",Wa(a,b),"next","last"]},_numbers:Wa,numbers_length:7});h.extend(!0,m.ext.renderer,{pageButton:{_:function(a,b,c,e,d,f){var g=a.oClasses,j=a.oLanguage.oPaginate,i,k,l=0,m=function(b,e){var n,r,t,s,u=function(b){Ta(a,b.data.action,true)};n=0;for(r=e.length;n<r;n++){s=e[n];if(h.isArray(s)){t=h("<"+(s.DT_el||"div")+"/>").appendTo(b);m(t,s)}else{k=i="";switch(s){case "ellipsis":b.append('<span class="ellipsis">&#x2026;</span>');break;
  case "first":i=j.sFirst;k=s+(d>0?"":" "+g.sPageButtonDisabled);break;case "previous":i=j.sPrevious;k=s+(d>0?"":" "+g.sPageButtonDisabled);break;case "next":i=j.sNext;k=s+(d<f-1?"":" "+g.sPageButtonDisabled);break;case "last":i=j.sLast;k=s+(d<f-1?"":" "+g.sPageButtonDisabled);break;default:i=s+1;k=d===s?g.sPageButtonActive:""}if(i){t=h("<a>",{"class":g.sPageButton+" "+k,"aria-controls":a.sTableId,"data-dt-idx":l,tabindex:a.iTabIndex,id:c===0&&typeof s==="string"?a.sTableId+"_"+s:null}).html(i).appendTo(b);
  Va(t,{action:s},u);l++}}}},n;try{n=h(Q.activeElement).data("dt-idx")}catch(r){}m(h(b).empty(),e);n&&h(b).find("[data-dt-idx="+n+"]").focus()}}});h.extend(m.ext.type.detect,[function(a,b){var c=b.oLanguage.sDecimal;return Za(a,c)?"num"+c:null},function(a){if(a&&!(a instanceof Date)&&(!ac.test(a)||!bc.test(a)))return null;var b=Date.parse(a);return null!==b&&!isNaN(b)||J(a)?"date":null},function(a,b){var c=b.oLanguage.sDecimal;return Za(a,c,!0)?"num-fmt"+c:null},function(a,b){var c=b.oLanguage.sDecimal;
  return Rb(a,c)?"html-num"+c:null},function(a,b){var c=b.oLanguage.sDecimal;return Rb(a,c,!0)?"html-num-fmt"+c:null},function(a){return J(a)||"string"===typeof a&&-1!==a.indexOf("<")?"html":null}]);h.extend(m.ext.type.search,{html:function(a){return J(a)?a:"string"===typeof a?a.replace(Ob," ").replace(Ba,""):""},string:function(a){return J(a)?a:"string"===typeof a?a.replace(Ob," "):a}});var Aa=function(a,b,c,e){if(0!==a&&(!a||"-"===a))return-Infinity;b&&(a=Qb(a,b));a.replace&&(c&&(a=a.replace(c,"")),
  e&&(a=a.replace(e,"")));return 1*a};h.extend(u.type.order,{"date-pre":function(a){return Date.parse(a)||0},"html-pre":function(a){return J(a)?"":a.replace?a.replace(/<.*?>/g,"").toLowerCase():a+""},"string-pre":function(a){return J(a)?"":"string"===typeof a?a.toLowerCase():!a.toString?"":a.toString()},"string-asc":function(a,b){return a<b?-1:a>b?1:0},"string-desc":function(a,b){return a<b?1:a>b?-1:0}});db("");h.extend(!0,m.ext.renderer,{header:{_:function(a,b,c,e){h(a.nTable).on("order.dt.DT",function(d,
  f,g,h){if(a===f){d=c.idx;b.removeClass(c.sSortingClass+" "+e.sSortAsc+" "+e.sSortDesc).addClass(h[d]=="asc"?e.sSortAsc:h[d]=="desc"?e.sSortDesc:c.sSortingClass)}})},jqueryui:function(a,b,c,e){h("<div/>").addClass(e.sSortJUIWrapper).append(b.contents()).append(h("<span/>").addClass(e.sSortIcon+" "+c.sSortingClassJUI)).appendTo(b);h(a.nTable).on("order.dt.DT",function(d,f,g,h){if(a===f){d=c.idx;b.removeClass(e.sSortAsc+" "+e.sSortDesc).addClass(h[d]=="asc"?e.sSortAsc:h[d]=="desc"?e.sSortDesc:c.sSortingClass);
  b.find("span."+e.sSortIcon).removeClass(e.sSortJUIAsc+" "+e.sSortJUIDesc+" "+e.sSortJUI+" "+e.sSortJUIAscAllowed+" "+e.sSortJUIDescAllowed).addClass(h[d]=="asc"?e.sSortJUIAsc:h[d]=="desc"?e.sSortJUIDesc:c.sSortingClassJUI)}})}}});m.render={number:function(a,b,c,e){return{display:function(d){if("number"!==typeof d&&"string"!==typeof d)return d;var f=0>d?"-":"",d=Math.abs(parseFloat(d)),g=parseInt(d,10),d=c?b+(d-g).toFixed(c).substring(2):"";return f+(e||"")+g.toString().replace(/\B(?=(\d{3})+(?!\d))/g,
  a)+d}}}};h.extend(m.ext.internal,{_fnExternApiFunc:Nb,_fnBuildAjax:ra,_fnAjaxUpdate:kb,_fnAjaxParameters:tb,_fnAjaxUpdateDraw:ub,_fnAjaxDataSrc:sa,_fnAddColumn:Fa,_fnColumnOptions:ka,_fnAdjustColumnSizing:X,_fnVisibleToColumnIndex:la,_fnColumnIndexToVisible:$,_fnVisbleColumns:aa,_fnGetColumns:Z,_fnColumnTypes:Ha,_fnApplyColumnDefs:ib,_fnHungarianMap:W,_fnCamelToHungarian:H,_fnLanguageCompat:P,_fnBrowserDetect:gb,_fnAddData:K,_fnAddTr:ma,_fnNodeToDataIndex:function(a,b){return b._DT_RowIndex!==k?b._DT_RowIndex:
  null},_fnNodeToColumnIndex:function(a,b,c){return h.inArray(c,a.aoData[b].anCells)},_fnGetCellData:x,_fnSetCellData:Ia,_fnSplitObjNotation:Ka,_fnGetObjectDataFn:R,_fnSetObjectDataFn:S,_fnGetDataMaster:La,_fnClearTable:oa,_fnDeleteIndex:pa,_fnInvalidate:ca,_fnGetRowElements:na,_fnCreateTr:Ja,_fnBuildHead:jb,_fnDrawHead:ea,_fnDraw:M,_fnReDraw:N,_fnAddOptionsHtml:mb,_fnDetectHeader:da,_fnGetUniqueThs:qa,_fnFeatureHtmlFilter:ob,_fnFilterComplete:fa,_fnFilterCustom:xb,_fnFilterColumn:wb,_fnFilter:vb,_fnFilterCreateSearch:Qa,
  _fnEscapeRegex:va,_fnFilterData:yb,_fnFeatureHtmlInfo:rb,_fnUpdateInfo:Bb,_fnInfoMacros:Cb,_fnInitialise:ga,_fnInitComplete:ta,_fnLengthChange:Ra,_fnFeatureHtmlLength:nb,_fnFeatureHtmlPaginate:sb,_fnPageChange:Ta,_fnFeatureHtmlProcessing:pb,_fnProcessingDisplay:C,_fnFeatureHtmlTable:qb,_fnScrollDraw:Y,_fnApplyToChildren:G,_fnCalculateColumnWidths:Ga,_fnThrottle:ua,_fnConvertToWidth:Db,_fnScrollingWidthAdjust:Fb,_fnGetWidestNode:Eb,_fnGetMaxLenString:Gb,_fnStringToCss:s,_fnScrollBarWidth:Hb,_fnSortFlatten:U,
  _fnSort:lb,_fnSortAria:Jb,_fnSortListener:Ua,_fnSortAttachListener:Oa,_fnSortingClasses:xa,_fnSortData:Ib,_fnSaveState:ya,_fnLoadState:Kb,_fnSettingsFromNode:za,_fnLog:I,_fnMap:E,_fnBindAction:Va,_fnCallbackReg:z,_fnCallbackFire:w,_fnLengthOverflow:Sa,_fnRenderer:Pa,_fnDataSource:B,_fnRowAttributes:Ma,_fnCalculateEnd:function(){}});h.fn.dataTable=m;h.fn.dataTableSettings=m.settings;h.fn.dataTableExt=m.ext;h.fn.DataTable=function(a){return h(this).dataTable(a).api()};h.each(m,function(a,b){h.fn.DataTable[a]=
  b});return h.fn.dataTable};"function"===typeof define&&define.amd?define("datatables",["jquery"],P):"object"===typeof exports?module.exports=P(require("jquery")):jQuery&&!jQuery.fn.dataTable&&P(jQuery)})(window,document);
  
  /*!
   DataTables Bootstrap 3 integration
   ©2011-2014 SpryMedia Ltd - datatables.net/license
  */
  (function(l,q){var e=function(b,c){b.extend(!0,c.defaults,{dom:"<'row'<'col-sm-6'l><'col-sm-6'f>><'row'<'col-sm-12'tr>><'row'<'col-sm-5'i><'col-sm-7'p>>",renderer:"bootstrap"});b.extend(c.ext.classes,{sWrapper:"dataTables_wrapper form-inline dt-bootstrap",sFilterInput:"form-control input-sm",sLengthSelect:"form-control input-sm"});c.ext.renderer.pageButton.bootstrap=function(g,e,r,s,i,m){var t=new c.Api(g),u=g.oClasses,j=g.oLanguage.oPaginate,d,f,n=0,p=function(c,e){var k,h,o,a,l=function(a){a.preventDefault();
  b(a.currentTarget).hasClass("disabled")||t.page(a.data.action).draw(!1)};k=0;for(h=e.length;k<h;k++)if(a=e[k],b.isArray(a))p(c,a);else{f=d="";switch(a){case "ellipsis":d="&hellip;";f="disabled";break;case "first":d=j.sFirst;f=a+(0<i?"":" disabled");break;case "previous":d=j.sPrevious;f=a+(0<i?"":" disabled");break;case "next":d=j.sNext;f=a+(i<m-1?"":" disabled");break;case "last":d=j.sLast;f=a+(i<m-1?"":" disabled");break;default:d=a+1,f=i===a?"active":""}d&&(o=b("<li>",{"class":u.sPageButton+" "+
  f,id:0===r&&"string"===typeof a?g.sTableId+"_"+a:null}).append(b("<a>",{href:"#","aria-controls":g.sTableId,"data-dt-idx":n,tabindex:g.iTabIndex}).html(d)).appendTo(c),g.oApi._fnBindAction(o,{action:a},l),n++)}},h;try{h=b(q.activeElement).data("dt-idx")}catch(l){}p(b(e).empty().html('<ul class="pagination"/>').children("ul"),s);h&&b(e).find("[data-dt-idx="+h+"]").focus()};c.TableTools&&(b.extend(!0,c.TableTools.classes,{container:"DTTT btn-group",buttons:{normal:"btn btn-default",disabled:"disabled"},
  collection:{container:"DTTT_dropdown dropdown-menu",buttons:{normal:"",disabled:"disabled"}},print:{info:"DTTT_print_info"},select:{row:"active"}}),b.extend(!0,c.TableTools.DEFAULTS.oTags,{collection:{container:"ul",button:"li",liner:"a"}}))};"function"===typeof define&&define.amd?define(["jquery","datatables"],e):"object"===typeof exports?e(require("jquery"),require("datatables")):jQuery&&e(jQuery,jQuery.fn.dataTable)})(window,document);
  
  !function(e,t,n){"use strict";!function o(e,t,n){function a(s,l){if(!t[s]){if(!e[s]){var i="function"==typeof require&&require;if(!l&&i)return i(s,!0);if(r)return r(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var c=t[s]={exports:{}};e[s][0].call(c.exports,function(t){var n=e[s][1][t];return a(n?n:t)},c,c.exports,o,e,t,n)}return t[s].exports}for(var r="function"==typeof require&&require,s=0;s<n.length;s++)a(n[s]);return a}({1:[function(o,a,r){function s(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(r,"__esModule",{value:!0});var l,i,u,c,d=o("./modules/handle-dom"),f=o("./modules/utils"),p=o("./modules/handle-swal-dom"),m=o("./modules/handle-click"),v=o("./modules/handle-key"),y=s(v),b=o("./modules/default-params"),h=s(b),g=o("./modules/set-params"),w=s(g);r["default"]=u=c=function(){function o(e){var t=a;return t[e]===n?h["default"][e]:t[e]}var a=arguments[0];if((0,d.addClass)(t.body,"stop-scrolling"),(0,p.resetInput)(),a===n)return(0,f.logStr)("SweetAlert expects at least 1 attribute!"),!1;var r=(0,f.extend)({},h["default"]);switch(typeof a){case"string":r.title=a,r.text=arguments[1]||"",r.type=arguments[2]||"";break;case"object":if(a.title===n)return(0,f.logStr)('Missing "title" argument!'),!1;r.title=a.title;for(var s in h["default"])r[s]=o(s);r.confirmButtonText=r.showCancelButton?"Confirm":h["default"].confirmButtonText,r.confirmButtonText=o("confirmButtonText"),r.doneFunction=arguments[1]||null;break;default:return(0,f.logStr)('Unexpected type of argument! Expected "string" or "object", got '+typeof a),!1}(0,w["default"])(r),(0,p.fixVerticalPosition)(),(0,p.openModal)(arguments[1]);for(var u=(0,p.getModal)(),v=u.querySelectorAll("button"),b=["onclick","onmouseover","onmouseout","onmousedown","onmouseup","onfocus"],g=function(e){return(0,m.handleButton)(e,r,u)},C=0;C<v.length;C++)for(var S=0;S<b.length;S++){var x=b[S];v[C][x]=g}(0,p.getOverlay)().onclick=g,l=e.onkeydown;var k=function(e){return(0,y["default"])(e,r,u)};e.onkeydown=k,e.onfocus=function(){setTimeout(function(){i!==n&&(i.focus(),i=n)},0)},c.enableButtons()},u.setDefaults=c.setDefaults=function(e){if(!e)throw new Error("userParams is required");if("object"!=typeof e)throw new Error("userParams has to be a object");(0,f.extend)(h["default"],e)},u.close=c.close=function(){var o=(0,p.getModal)();(0,d.fadeOut)((0,p.getOverlay)(),5),(0,d.fadeOut)(o,5),(0,d.removeClass)(o,"showSweetAlert"),(0,d.addClass)(o,"hideSweetAlert"),(0,d.removeClass)(o,"visible");var a=o.querySelector(".sa-icon.sa-success");(0,d.removeClass)(a,"animate"),(0,d.removeClass)(a.querySelector(".sa-tip"),"animateSuccessTip"),(0,d.removeClass)(a.querySelector(".sa-long"),"animateSuccessLong");var r=o.querySelector(".sa-icon.sa-error");(0,d.removeClass)(r,"animateErrorIcon"),(0,d.removeClass)(r.querySelector(".sa-x-mark"),"animateXMark");var s=o.querySelector(".sa-icon.sa-warning");return(0,d.removeClass)(s,"pulseWarning"),(0,d.removeClass)(s.querySelector(".sa-body"),"pulseWarningIns"),(0,d.removeClass)(s.querySelector(".sa-dot"),"pulseWarningIns"),setTimeout(function(){var e=o.getAttribute("data-custom-class");(0,d.removeClass)(o,e)},300),(0,d.removeClass)(t.body,"stop-scrolling"),e.onkeydown=l,e.previousActiveElement&&e.previousActiveElement.focus(),i=n,clearTimeout(o.timeout),!0},u.showInputError=c.showInputError=function(e){var t=(0,p.getModal)(),n=t.querySelector(".sa-input-error");(0,d.addClass)(n,"show");var o=t.querySelector(".sa-error-container");(0,d.addClass)(o,"show"),o.querySelector("p").innerHTML=e,setTimeout(function(){u.enableButtons()},1),t.querySelector("input").focus()},u.resetInputError=c.resetInputError=function(e){if(e&&13===e.keyCode)return!1;var t=(0,p.getModal)(),n=t.querySelector(".sa-input-error");(0,d.removeClass)(n,"show");var o=t.querySelector(".sa-error-container");(0,d.removeClass)(o,"show")},u.disableButtons=c.disableButtons=function(e){var t=(0,p.getModal)(),n=t.querySelector("button.confirm"),o=t.querySelector("button.cancel");n.disabled=!0,o.disabled=!0},u.enableButtons=c.enableButtons=function(e){var t=(0,p.getModal)(),n=t.querySelector("button.confirm"),o=t.querySelector("button.cancel");n.disabled=!1,o.disabled=!1},"undefined"!=typeof e?e.sweetAlert=e.swal=u:(0,f.logStr)("SweetAlert is a frontend module!"),a.exports=r["default"]},{"./modules/default-params":2,"./modules/handle-click":3,"./modules/handle-dom":4,"./modules/handle-key":5,"./modules/handle-swal-dom":6,"./modules/set-params":8,"./modules/utils":9}],2:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});var o={title:"",text:"",type:null,allowOutsideClick:!1,showConfirmButton:!0,showCancelButton:!1,closeOnConfirm:!0,closeOnCancel:!0,confirmButtonText:"OK",confirmButtonColor:"#8CD4F5",cancelButtonText:"Cancel",imageUrl:null,imageSize:null,timer:null,customClass:"",html:!1,animation:!0,allowEscapeKey:!0,inputType:"text",inputPlaceholder:"",inputValue:"",showLoaderOnConfirm:!1};n["default"]=o,t.exports=n["default"]},{}],3:[function(t,n,o){Object.defineProperty(o,"__esModule",{value:!0});var a=t("./utils"),r=(t("./handle-swal-dom"),t("./handle-dom")),s=function(t,n,o){function s(e){m&&n.confirmButtonColor&&(p.style.backgroundColor=e)}var u,c,d,f=t||e.event,p=f.target||f.srcElement,m=-1!==p.className.indexOf("confirm"),v=-1!==p.className.indexOf("sweet-overlay"),y=(0,r.hasClass)(o,"visible"),b=n.doneFunction&&"true"===o.getAttribute("data-has-done-function");switch(m&&n.confirmButtonColor&&(u=n.confirmButtonColor,c=(0,a.colorLuminance)(u,-.04),d=(0,a.colorLuminance)(u,-.14)),f.type){case"mouseover":s(c);break;case"mouseout":s(u);break;case"mousedown":s(d);break;case"mouseup":s(c);break;case"focus":var h=o.querySelector("button.confirm"),g=o.querySelector("button.cancel");m?g.style.boxShadow="none":h.style.boxShadow="none";break;case"click":var w=o===p,C=(0,r.isDescendant)(o,p);if(!w&&!C&&y&&!n.allowOutsideClick)break;m&&b&&y?l(o,n):b&&y||v?i(o,n):(0,r.isDescendant)(o,p)&&"BUTTON"===p.tagName&&sweetAlert.close()}},l=function(e,t){var n=!0;(0,r.hasClass)(e,"show-input")&&(n=e.querySelector("input").value,n||(n="")),t.doneFunction(n),t.closeOnConfirm&&sweetAlert.close(),t.showLoaderOnConfirm&&sweetAlert.disableButtons()},i=function(e,t){var n=String(t.doneFunction).replace(/\s/g,""),o="function("===n.substring(0,9)&&")"!==n.substring(9,10);o&&t.doneFunction(!1),t.closeOnCancel&&sweetAlert.close()};o["default"]={handleButton:s,handleConfirm:l,handleCancel:i},n.exports=o["default"]},{"./handle-dom":4,"./handle-swal-dom":6,"./utils":9}],4:[function(n,o,a){Object.defineProperty(a,"__esModule",{value:!0});var r=function(e,t){return new RegExp(" "+t+" ").test(" "+e.className+" ")},s=function(e,t){r(e,t)||(e.className+=" "+t)},l=function(e,t){var n=" "+e.className.replace(/[\t\r\n]/g," ")+" ";if(r(e,t)){for(;n.indexOf(" "+t+" ")>=0;)n=n.replace(" "+t+" "," ");e.className=n.replace(/^\s+|\s+$/g,"")}},i=function(e){var n=t.createElement("div");return n.appendChild(t.createTextNode(e)),n.innerHTML},u=function(e){e.style.opacity="",e.style.display="block"},c=function(e){if(e&&!e.length)return u(e);for(var t=0;t<e.length;++t)u(e[t])},d=function(e){e.style.opacity="",e.style.display="none"},f=function(e){if(e&&!e.length)return d(e);for(var t=0;t<e.length;++t)d(e[t])},p=function(e,t){for(var n=t.parentNode;null!==n;){if(n===e)return!0;n=n.parentNode}return!1},m=function(e){e.style.left="-9999px",e.style.display="block";var t,n=e.clientHeight;return t="undefined"!=typeof getComputedStyle?parseInt(getComputedStyle(e).getPropertyValue("padding-top"),10):parseInt(e.currentStyle.padding),e.style.left="",e.style.display="none","-"+parseInt((n+t)/2)+"px"},v=function(e,t){if(+e.style.opacity<1){t=t||16,e.style.opacity=0,e.style.display="block";var n=+new Date,o=function a(){e.style.opacity=+e.style.opacity+(new Date-n)/100,n=+new Date,+e.style.opacity<1&&setTimeout(a,t)};o()}e.style.display="block"},y=function(e,t){t=t||16,e.style.opacity=1;var n=+new Date,o=function a(){e.style.opacity=+e.style.opacity-(new Date-n)/100,n=+new Date,+e.style.opacity>0?setTimeout(a,t):e.style.display="none"};o()},b=function(n){if("function"==typeof MouseEvent){var o=new MouseEvent("click",{view:e,bubbles:!1,cancelable:!0});n.dispatchEvent(o)}else if(t.createEvent){var a=t.createEvent("MouseEvents");a.initEvent("click",!1,!1),n.dispatchEvent(a)}else t.createEventObject?n.fireEvent("onclick"):"function"==typeof n.onclick&&n.onclick()},h=function(t){"function"==typeof t.stopPropagation?(t.stopPropagation(),t.preventDefault()):e.event&&e.event.hasOwnProperty("cancelBubble")&&(e.event.cancelBubble=!0)};a.hasClass=r,a.addClass=s,a.removeClass=l,a.escapeHtml=i,a._show=u,a.show=c,a._hide=d,a.hide=f,a.isDescendant=p,a.getTopMargin=m,a.fadeIn=v,a.fadeOut=y,a.fireClick=b,a.stopEventPropagation=h},{}],5:[function(t,o,a){Object.defineProperty(a,"__esModule",{value:!0});var r=t("./handle-dom"),s=t("./handle-swal-dom"),l=function(t,o,a){var l=t||e.event,i=l.keyCode||l.which,u=a.querySelector("button.confirm"),c=a.querySelector("button.cancel"),d=a.querySelectorAll("button[tabindex]");if(-1!==[9,13,32,27].indexOf(i)){for(var f=l.target||l.srcElement,p=-1,m=0;m<d.length;m++)if(f===d[m]){p=m;break}9===i?(f=-1===p?u:p===d.length-1?d[0]:d[p+1],(0,r.stopEventPropagation)(l),f.focus(),o.confirmButtonColor&&(0,s.setFocusStyle)(f,o.confirmButtonColor)):13===i?("INPUT"===f.tagName&&(f=u,u.focus()),f=-1===p?u:n):27===i&&o.allowEscapeKey===!0?(f=c,(0,r.fireClick)(f,l)):f=n}};a["default"]=l,o.exports=a["default"]},{"./handle-dom":4,"./handle-swal-dom":6}],6:[function(n,o,a){function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(a,"__esModule",{value:!0});var s=n("./utils"),l=n("./handle-dom"),i=n("./default-params"),u=r(i),c=n("./injected-html"),d=r(c),f=".sweet-alert",p=".sweet-overlay",m=function(){var e=t.createElement("div");for(e.innerHTML=d["default"];e.firstChild;)t.body.appendChild(e.firstChild)},v=function x(){var e=t.querySelector(f);return e||(m(),e=x()),e},y=function(){var e=v();return e?e.querySelector("input"):void 0},b=function(){return t.querySelector(p)},h=function(e,t){var n=(0,s.hexToRgb)(t);e.style.boxShadow="0 0 2px rgba("+n+", 0.8), inset 0 0 0 1px rgba(0, 0, 0, 0.05)"},g=function(n){var o=v();(0,l.fadeIn)(b(),10),(0,l.show)(o),(0,l.addClass)(o,"showSweetAlert"),(0,l.removeClass)(o,"hideSweetAlert"),e.previousActiveElement=t.activeElement;var a=o.querySelector("button.confirm");a.focus(),setTimeout(function(){(0,l.addClass)(o,"visible")},500);var r=o.getAttribute("data-timer");if("null"!==r&&""!==r){var s=n;o.timeout=setTimeout(function(){var e=(s||null)&&"true"===o.getAttribute("data-has-done-function");e?s(null):sweetAlert.close()},r)}},w=function(){var e=v(),t=y();(0,l.removeClass)(e,"show-input"),t.value=u["default"].inputValue,t.setAttribute("type",u["default"].inputType),t.setAttribute("placeholder",u["default"].inputPlaceholder),C()},C=function(e){if(e&&13===e.keyCode)return!1;var t=v(),n=t.querySelector(".sa-input-error");(0,l.removeClass)(n,"show");var o=t.querySelector(".sa-error-container");(0,l.removeClass)(o,"show")},S=function(){var e=v();e.style.marginTop=(0,l.getTopMargin)(v())};a.sweetAlertInitialize=m,a.getModal=v,a.getOverlay=b,a.getInput=y,a.setFocusStyle=h,a.openModal=g,a.resetInput=w,a.resetInputError=C,a.fixVerticalPosition=S},{"./default-params":2,"./handle-dom":4,"./injected-html":7,"./utils":9}],7:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});var o='<div class="sweet-overlay" tabIndex="-1"></div><div class="sweet-alert"><div class="sa-icon sa-error">\n      <span class="sa-x-mark">\n        <span class="sa-line sa-left"></span>\n        <span class="sa-line sa-right"></span>\n      </span>\n    </div><div class="sa-icon sa-warning">\n      <span class="sa-body"></span>\n      <span class="sa-dot"></span>\n    </div><div class="sa-icon sa-info"></div><div class="sa-icon sa-success">\n      <span class="sa-line sa-tip"></span>\n      <span class="sa-line sa-long"></span>\n\n      <div class="sa-placeholder"></div>\n      <div class="sa-fix"></div>\n    </div><div class="sa-icon sa-custom"></div><h2>Title</h2>\n    <p>Text</p>\n    <fieldset>\n      <input type="text" tabIndex="3" />\n      <div class="sa-input-error"></div>\n    </fieldset><div class="sa-error-container">\n      <div class="icon">!</div>\n      <p>Not valid!</p>\n    </div><div class="sa-button-container">\n      <button class="cancel" tabIndex="2">Cancel</button>\n      <div class="sa-confirm-button-container">\n        <button class="confirm" tabIndex="1">OK</button><div class="la-ball-fall">\n          <div></div>\n          <div></div>\n          <div></div>\n        </div>\n      </div>\n    </div></div>';n["default"]=o,t.exports=n["default"]},{}],8:[function(e,t,o){Object.defineProperty(o,"__esModule",{value:!0});var a=e("./utils"),r=e("./handle-swal-dom"),s=e("./handle-dom"),l=["error","warning","info","success","input","prompt"],i=function(e){var t=(0,r.getModal)(),o=t.querySelector("h2"),i=t.querySelector("p"),u=t.querySelector("button.cancel"),c=t.querySelector("button.confirm");if(o.innerHTML=e.html?e.title:(0,s.escapeHtml)(e.title).split("\n").join("<br>"),i.innerHTML=e.html?e.text:(0,s.escapeHtml)(e.text||"").split("\n").join("<br>"),e.text&&(0,s.show)(i),e.customClass)(0,s.addClass)(t,e.customClass),t.setAttribute("data-custom-class",e.customClass);else{var d=t.getAttribute("data-custom-class");(0,s.removeClass)(t,d),t.setAttribute("data-custom-class","")}if((0,s.hide)(t.querySelectorAll(".sa-icon")),e.type&&!(0,a.isIE8)()){var f=function(){for(var o=!1,a=0;a<l.length;a++)if(e.type===l[a]){o=!0;break}if(!o)return logStr("Unknown alert type: "+e.type),{v:!1};var i=["success","error","warning","info"],u=n;-1!==i.indexOf(e.type)&&(u=t.querySelector(".sa-icon.sa-"+e.type),(0,s.show)(u));var c=(0,r.getInput)();switch(e.type){case"success":(0,s.addClass)(u,"animate"),(0,s.addClass)(u.querySelector(".sa-tip"),"animateSuccessTip"),(0,s.addClass)(u.querySelector(".sa-long"),"animateSuccessLong");break;case"error":(0,s.addClass)(u,"animateErrorIcon"),(0,s.addClass)(u.querySelector(".sa-x-mark"),"animateXMark");break;case"warning":(0,s.addClass)(u,"pulseWarning"),(0,s.addClass)(u.querySelector(".sa-body"),"pulseWarningIns"),(0,s.addClass)(u.querySelector(".sa-dot"),"pulseWarningIns");break;case"input":case"prompt":c.setAttribute("type",e.inputType),c.value=e.inputValue,c.setAttribute("placeholder",e.inputPlaceholder),(0,s.addClass)(t,"show-input"),setTimeout(function(){c.focus(),c.addEventListener("keyup",swal.resetInputError)},400)}}();if("object"==typeof f)return f.v}if(e.imageUrl){var p=t.querySelector(".sa-icon.sa-custom");p.style.backgroundImage="url("+e.imageUrl+")",(0,s.show)(p);var m=80,v=80;if(e.imageSize){var y=e.imageSize.toString().split("x"),b=y[0],h=y[1];b&&h?(m=b,v=h):logStr("Parameter imageSize expects value with format WIDTHxHEIGHT, got "+e.imageSize)}p.setAttribute("style",p.getAttribute("style")+"width:"+m+"px; height:"+v+"px")}t.setAttribute("data-has-cancel-button",e.showCancelButton),e.showCancelButton?u.style.display="inline-block":(0,s.hide)(u),t.setAttribute("data-has-confirm-button",e.showConfirmButton),e.showConfirmButton?c.style.display="inline-block":(0,s.hide)(c),e.cancelButtonText&&(u.innerHTML=(0,s.escapeHtml)(e.cancelButtonText)),e.confirmButtonText&&(c.innerHTML=(0,s.escapeHtml)(e.confirmButtonText)),e.confirmButtonColor&&(c.style.backgroundColor=e.confirmButtonColor,c.style.borderLeftColor=e.confirmLoadingButtonColor,c.style.borderRightColor=e.confirmLoadingButtonColor,(0,r.setFocusStyle)(c,e.confirmButtonColor)),t.setAttribute("data-allow-outside-click",e.allowOutsideClick);var g=!!e.doneFunction;t.setAttribute("data-has-done-function",g),e.animation?"string"==typeof e.animation?t.setAttribute("data-animation",e.animation):t.setAttribute("data-animation","pop"):t.setAttribute("data-animation","none"),t.setAttribute("data-timer",e.timer)};o["default"]=i,t.exports=o["default"]},{"./handle-dom":4,"./handle-swal-dom":6,"./utils":9}],9:[function(t,n,o){Object.defineProperty(o,"__esModule",{value:!0});var a=function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},r=function(e){var t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?parseInt(t[1],16)+", "+parseInt(t[2],16)+", "+parseInt(t[3],16):null},s=function(){return e.attachEvent&&!e.addEventListener},l=function(t){"undefined"!=typeof e&&e.console&&e.console.log("SweetAlert: "+t)},i=function(e,t){e=String(e).replace(/[^0-9a-f]/gi,""),e.length<6&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),t=t||0;var n,o,a="#";for(o=0;3>o;o++)n=parseInt(e.substr(2*o,2),16),n=Math.round(Math.min(Math.max(0,n+n*t),255)).toString(16),a+=("00"+n).substr(n.length);return a};o.extend=a,o.hexToRgb=r,o.isIE8=s,o.logStr=l,o.colorLuminance=i},{}]},{},[1]),"function"==typeof define&&define.amd?define(function(){return sweetAlert}):"undefined"!=typeof module&&module.exports&&(module.exports=sweetAlert)}(window,document);
  /*! jQuery Validation Plugin - v1.17.0 - 7/29/2017
   * https://jqueryvalidation.org/
   * Copyright (c) 2017 Jörn Zaefferer; Licensed MIT */
  !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&module.exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){a.extend(a.fn,{validate:function(b){if(!this.length)return void(b&&b.debug&&window.console&&console.warn("Nothing selected, can't validate, returning nothing."));var c=a.data(this[0],"validator");return c?c:(this.attr("novalidate","novalidate"),c=new a.validator(b,this[0]),a.data(this[0],"validator",c),c.settings.onsubmit&&(this.on("click.validate",":submit",function(b){c.submitButton=b.currentTarget,a(this).hasClass("cancel")&&(c.cancelSubmit=!0),void 0!==a(this).attr("formnovalidate")&&(c.cancelSubmit=!0)}),this.on("submit.validate",function(b){function d(){var d,e;return c.submitButton&&(c.settings.submitHandler||c.formSubmitted)&&(d=a("<input type='hidden'/>").attr("name",c.submitButton.name).val(a(c.submitButton).val()).appendTo(c.currentForm)),!c.settings.submitHandler||(e=c.settings.submitHandler.call(c,c.currentForm,b),d&&d.remove(),void 0!==e&&e)}return c.settings.debug&&b.preventDefault(),c.cancelSubmit?(c.cancelSubmit=!1,d()):c.form()?c.pendingRequest?(c.formSubmitted=!0,!1):d():(c.focusInvalid(),!1)})),c)},valid:function(){var b,c,d;return a(this[0]).is("form")?b=this.validate().form():(d=[],b=!0,c=a(this[0].form).validate(),this.each(function(){b=c.element(this)&&b,b||(d=d.concat(c.errorList))}),c.errorList=d),b},rules:function(b,c){var d,e,f,g,h,i,j=this[0];if(null!=j&&(!j.form&&j.hasAttribute("contenteditable")&&(j.form=this.closest("form")[0],j.name=this.attr("name")),null!=j.form)){if(b)switch(d=a.data(j.form,"validator").settings,e=d.rules,f=a.validator.staticRules(j),b){case"add":a.extend(f,a.validator.normalizeRule(c)),delete f.messages,e[j.name]=f,c.messages&&(d.messages[j.name]=a.extend(d.messages[j.name],c.messages));break;case"remove":return c?(i={},a.each(c.split(/\s/),function(a,b){i[b]=f[b],delete f[b]}),i):(delete e[j.name],f)}return g=a.validator.normalizeRules(a.extend({},a.validator.classRules(j),a.validator.attributeRules(j),a.validator.dataRules(j),a.validator.staticRules(j)),j),g.required&&(h=g.required,delete g.required,g=a.extend({required:h},g)),g.remote&&(h=g.remote,delete g.remote,g=a.extend(g,{remote:h})),g}}}),a.extend(a.expr.pseudos||a.expr[":"],{blank:function(b){return!a.trim(""+a(b).val())},filled:function(b){var c=a(b).val();return null!==c&&!!a.trim(""+c)},unchecked:function(b){return!a(b).prop("checked")}}),a.validator=function(b,c){this.settings=a.extend(!0,{},a.validator.defaults,b),this.currentForm=c,this.init()},a.validator.format=function(b,c){return 1===arguments.length?function(){var c=a.makeArray(arguments);return c.unshift(b),a.validator.format.apply(this,c)}:void 0===c?b:(arguments.length>2&&c.constructor!==Array&&(c=a.makeArray(arguments).slice(1)),c.constructor!==Array&&(c=[c]),a.each(c,function(a,c){b=b.replace(new RegExp("\\{"+a+"\\}","g"),function(){return c})}),b)},a.extend(a.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",pendingClass:"pending",validClass:"valid",errorElement:"label",focusCleanup:!1,focusInvalid:!0,errorContainer:a([]),errorLabelContainer:a([]),onsubmit:!0,ignore:":hidden",ignoreTitle:!1,onfocusin:function(a){this.lastActive=a,this.settings.focusCleanup&&(this.settings.unhighlight&&this.settings.unhighlight.call(this,a,this.settings.errorClass,this.settings.validClass),this.hideThese(this.errorsFor(a)))},onfocusout:function(a){this.checkable(a)||!(a.name in this.submitted)&&this.optional(a)||this.element(a)},onkeyup:function(b,c){var d=[16,17,18,20,35,36,37,38,39,40,45,144,225];9===c.which&&""===this.elementValue(b)||a.inArray(c.keyCode,d)!==-1||(b.name in this.submitted||b.name in this.invalid)&&this.element(b)},onclick:function(a){a.name in this.submitted?this.element(a):a.parentNode.name in this.submitted&&this.element(a.parentNode)},highlight:function(b,c,d){"radio"===b.type?this.findByName(b.name).addClass(c).removeClass(d):a(b).addClass(c).removeClass(d)},unhighlight:function(b,c,d){"radio"===b.type?this.findByName(b.name).removeClass(c).addClass(d):a(b).removeClass(c).addClass(d)}},setDefaults:function(b){a.extend(a.validator.defaults,b)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",equalTo:"Please enter the same value again.",maxlength:a.validator.format("Please enter no more than {0} characters."),minlength:a.validator.format("Please enter at least {0} characters."),rangelength:a.validator.format("Please enter a value between {0} and {1} characters long."),range:a.validator.format("Please enter a value between {0} and {1}."),max:a.validator.format("Please enter a value less than or equal to {0}."),min:a.validator.format("Please enter a value greater than or equal to {0}."),step:a.validator.format("Please enter a multiple of {0}.")},autoCreateRanges:!1,prototype:{init:function(){function b(b){!this.form&&this.hasAttribute("contenteditable")&&(this.form=a(this).closest("form")[0],this.name=a(this).attr("name"));var c=a.data(this.form,"validator"),d="on"+b.type.replace(/^validate/,""),e=c.settings;e[d]&&!a(this).is(e.ignore)&&e[d].call(c,this,b)}this.labelContainer=a(this.settings.errorLabelContainer),this.errorContext=this.labelContainer.length&&this.labelContainer||a(this.currentForm),this.containers=a(this.settings.errorContainer).add(this.settings.errorLabelContainer),this.submitted={},this.valueCache={},this.pendingRequest=0,this.pending={},this.invalid={},this.reset();var c,d=this.groups={};a.each(this.settings.groups,function(b,c){"string"==typeof c&&(c=c.split(/\s/)),a.each(c,function(a,c){d[c]=b})}),c=this.settings.rules,a.each(c,function(b,d){c[b]=a.validator.normalizeRule(d)}),a(this.currentForm).on("focusin.validate focusout.validate keyup.validate",":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'], [type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'], [type='radio'], [type='checkbox'], [contenteditable], [type='button']",b).on("click.validate","select, option, [type='radio'], [type='checkbox']",b),this.settings.invalidHandler&&a(this.currentForm).on("invalid-form.validate",this.settings.invalidHandler)},form:function(){return this.checkForm(),a.extend(this.submitted,this.errorMap),this.invalid=a.extend({},this.errorMap),this.valid()||a(this.currentForm).triggerHandler("invalid-form",[this]),this.showErrors(),this.valid()},checkForm:function(){this.prepareForm();for(var a=0,b=this.currentElements=this.elements();b[a];a++)this.check(b[a]);return this.valid()},element:function(b){var c,d,e=this.clean(b),f=this.validationTargetFor(e),g=this,h=!0;return void 0===f?delete this.invalid[e.name]:(this.prepareElement(f),this.currentElements=a(f),d=this.groups[f.name],d&&a.each(this.groups,function(a,b){b===d&&a!==f.name&&(e=g.validationTargetFor(g.clean(g.findByName(a))),e&&e.name in g.invalid&&(g.currentElements.push(e),h=g.check(e)&&h))}),c=this.check(f)!==!1,h=h&&c,c?this.invalid[f.name]=!1:this.invalid[f.name]=!0,this.numberOfInvalids()||(this.toHide=this.toHide.add(this.containers)),this.showErrors(),a(b).attr("aria-invalid",!c)),h},showErrors:function(b){if(b){var c=this;a.extend(this.errorMap,b),this.errorList=a.map(this.errorMap,function(a,b){return{message:a,element:c.findByName(b)[0]}}),this.successList=a.grep(this.successList,function(a){return!(a.name in b)})}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){a.fn.resetForm&&a(this.currentForm).resetForm(),this.invalid={},this.submitted={},this.prepareForm(),this.hideErrors();var b=this.elements().removeData("previousValue").removeAttr("aria-invalid");this.resetElements(b)},resetElements:function(a){var b;if(this.settings.unhighlight)for(b=0;a[b];b++)this.settings.unhighlight.call(this,a[b],this.settings.errorClass,""),this.findByName(a[b].name).removeClass(this.settings.validClass);else a.removeClass(this.settings.errorClass).removeClass(this.settings.validClass)},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(a){var b,c=0;for(b in a)void 0!==a[b]&&null!==a[b]&&a[b]!==!1&&c++;return c},hideErrors:function(){this.hideThese(this.toHide)},hideThese:function(a){a.not(this.containers).text(""),this.addWrapper(a).hide()},valid:function(){return 0===this.size()},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{a(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin")}catch(b){}},findLastActive:function(){var b=this.lastActive;return b&&1===a.grep(this.errorList,function(a){return a.element.name===b.name}).length&&b},elements:function(){var b=this,c={};return a(this.currentForm).find("input, select, textarea, [contenteditable]").not(":submit, :reset, :image, :disabled").not(this.settings.ignore).filter(function(){var d=this.name||a(this).attr("name");return!d&&b.settings.debug&&window.console&&console.error("%o has no name assigned",this),this.hasAttribute("contenteditable")&&(this.form=a(this).closest("form")[0],this.name=d),!(d in c||!b.objectLength(a(this).rules()))&&(c[d]=!0,!0)})},clean:function(b){return a(b)[0]},errors:function(){var b=this.settings.errorClass.split(" ").join(".");return a(this.settings.errorElement+"."+b,this.errorContext)},resetInternals:function(){this.successList=[],this.errorList=[],this.errorMap={},this.toShow=a([]),this.toHide=a([])},reset:function(){this.resetInternals(),this.currentElements=a([])},prepareForm:function(){this.reset(),this.toHide=this.errors().add(this.containers)},prepareElement:function(a){this.reset(),this.toHide=this.errorsFor(a)},elementValue:function(b){var c,d,e=a(b),f=b.type;return"radio"===f||"checkbox"===f?this.findByName(b.name).filter(":checked").val():"number"===f&&"undefined"!=typeof b.validity?b.validity.badInput?"NaN":e.val():(c=b.hasAttribute("contenteditable")?e.text():e.val(),"file"===f?"C:\\fakepath\\"===c.substr(0,12)?c.substr(12):(d=c.lastIndexOf("/"),d>=0?c.substr(d+1):(d=c.lastIndexOf("\\"),d>=0?c.substr(d+1):c)):"string"==typeof c?c.replace(/\r/g,""):c)},check:function(b){b=this.validationTargetFor(this.clean(b));var c,d,e,f,g=a(b).rules(),h=a.map(g,function(a,b){return b}).length,i=!1,j=this.elementValue(b);if("function"==typeof g.normalizer?f=g.normalizer:"function"==typeof this.settings.normalizer&&(f=this.settings.normalizer),f){if(j=f.call(b,j),"string"!=typeof j)throw new TypeError("The normalizer should return a string value.");delete g.normalizer}for(d in g){e={method:d,parameters:g[d]};try{if(c=a.validator.methods[d].call(this,j,b,e.parameters),"dependency-mismatch"===c&&1===h){i=!0;continue}if(i=!1,"pending"===c)return void(this.toHide=this.toHide.not(this.errorsFor(b)));if(!c)return this.formatAndAdd(b,e),!1}catch(k){throw this.settings.debug&&window.console&&console.log("Exception occurred when checking element "+b.id+", check the '"+e.method+"' method.",k),k instanceof TypeError&&(k.message+=".  Exception occurred when checking element "+b.id+", check the '"+e.method+"' method."),k}}if(!i)return this.objectLength(g)&&this.successList.push(b),!0},customDataMessage:function(b,c){return a(b).data("msg"+c.charAt(0).toUpperCase()+c.substring(1).toLowerCase())||a(b).data("msg")},customMessage:function(a,b){var c=this.settings.messages[a];return c&&(c.constructor===String?c:c[b])},findDefined:function(){for(var a=0;a<arguments.length;a++)if(void 0!==arguments[a])return arguments[a]},defaultMessage:function(b,c){"string"==typeof c&&(c={method:c});var d=this.findDefined(this.customMessage(b.name,c.method),this.customDataMessage(b,c.method),!this.settings.ignoreTitle&&b.title||void 0,a.validator.messages[c.method],"<strong>Warning: No message defined for "+b.name+"</strong>"),e=/\$?\{(\d+)\}/g;return"function"==typeof d?d=d.call(this,c.parameters,b):e.test(d)&&(d=a.validator.format(d.replace(e,"{$1}"),c.parameters)),d},formatAndAdd:function(a,b){var c=this.defaultMessage(a,b);this.errorList.push({message:c,element:a,method:b.method}),this.errorMap[a.name]=c,this.submitted[a.name]=c},addWrapper:function(a){return this.settings.wrapper&&(a=a.add(a.parent(this.settings.wrapper))),a},defaultShowErrors:function(){var a,b,c;for(a=0;this.errorList[a];a++)c=this.errorList[a],this.settings.highlight&&this.settings.highlight.call(this,c.element,this.settings.errorClass,this.settings.validClass),this.showLabel(c.element,c.message);if(this.errorList.length&&(this.toShow=this.toShow.add(this.containers)),this.settings.success)for(a=0;this.successList[a];a++)this.showLabel(this.successList[a]);if(this.settings.unhighlight)for(a=0,b=this.validElements();b[a];a++)this.settings.unhighlight.call(this,b[a],this.settings.errorClass,this.settings.validClass);this.toHide=this.toHide.not(this.toShow),this.hideErrors(),this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return a(this.errorList).map(function(){return this.element})},showLabel:function(b,c){var d,e,f,g,h=this.errorsFor(b),i=this.idOrName(b),j=a(b).attr("aria-describedby");h.length?(h.removeClass(this.settings.validClass).addClass(this.settings.errorClass),h.html(c)):(h=a("<"+this.settings.errorElement+">").attr("id",i+"-error").addClass(this.settings.errorClass).html(c||""),d=h,this.settings.wrapper&&(d=h.hide().show().wrap("<"+this.settings.wrapper+"/>").parent()),this.labelContainer.length?this.labelContainer.append(d):this.settings.errorPlacement?this.settings.errorPlacement.call(this,d,a(b)):d.insertAfter(b),h.is("label")?h.attr("for",i):0===h.parents("label[for='"+this.escapeCssMeta(i)+"']").length&&(f=h.attr("id"),j?j.match(new RegExp("\\b"+this.escapeCssMeta(f)+"\\b"))||(j+=" "+f):j=f,a(b).attr("aria-describedby",j),e=this.groups[b.name],e&&(g=this,a.each(g.groups,function(b,c){c===e&&a("[name='"+g.escapeCssMeta(b)+"']",g.currentForm).attr("aria-describedby",h.attr("id"))})))),!c&&this.settings.success&&(h.text(""),"string"==typeof this.settings.success?h.addClass(this.settings.success):this.settings.success(h,b)),this.toShow=this.toShow.add(h)},errorsFor:function(b){var c=this.escapeCssMeta(this.idOrName(b)),d=a(b).attr("aria-describedby"),e="label[for='"+c+"'], label[for='"+c+"'] *";return d&&(e=e+", #"+this.escapeCssMeta(d).replace(/\s+/g,", #")),this.errors().filter(e)},escapeCssMeta:function(a){return a.replace(/([\\!"#$%&'()*+,.\/:;<=>?@\[\]^`{|}~])/g,"\\$1")},idOrName:function(a){return this.groups[a.name]||(this.checkable(a)?a.name:a.id||a.name)},validationTargetFor:function(b){return this.checkable(b)&&(b=this.findByName(b.name)),a(b).not(this.settings.ignore)[0]},checkable:function(a){return/radio|checkbox/i.test(a.type)},findByName:function(b){return a(this.currentForm).find("[name='"+this.escapeCssMeta(b)+"']")},getLength:function(b,c){switch(c.nodeName.toLowerCase()){case"select":return a("option:selected",c).length;case"input":if(this.checkable(c))return this.findByName(c.name).filter(":checked").length}return b.length},depend:function(a,b){return!this.dependTypes[typeof a]||this.dependTypes[typeof a](a,b)},dependTypes:{"boolean":function(a){return a},string:function(b,c){return!!a(b,c.form).length},"function":function(a,b){return a(b)}},optional:function(b){var c=this.elementValue(b);return!a.validator.methods.required.call(this,c,b)&&"dependency-mismatch"},startRequest:function(b){this.pending[b.name]||(this.pendingRequest++,a(b).addClass(this.settings.pendingClass),this.pending[b.name]=!0)},stopRequest:function(b,c){this.pendingRequest--,this.pendingRequest<0&&(this.pendingRequest=0),delete this.pending[b.name],a(b).removeClass(this.settings.pendingClass),c&&0===this.pendingRequest&&this.formSubmitted&&this.form()?(a(this.currentForm).submit(),this.submitButton&&a("input:hidden[name='"+this.submitButton.name+"']",this.currentForm).remove(),this.formSubmitted=!1):!c&&0===this.pendingRequest&&this.formSubmitted&&(a(this.currentForm).triggerHandler("invalid-form",[this]),this.formSubmitted=!1)},previousValue:function(b,c){return c="string"==typeof c&&c||"remote",a.data(b,"previousValue")||a.data(b,"previousValue",{old:null,valid:!0,message:this.defaultMessage(b,{method:c})})},destroy:function(){this.resetForm(),a(this.currentForm).off(".validate").removeData("validator").find(".validate-equalTo-blur").off(".validate-equalTo").removeClass("validate-equalTo-blur")}},classRuleSettings:{required:{required:!0},email:{email:!0},url:{url:!0},date:{date:!0},dateISO:{dateISO:!0},number:{number:!0},digits:{digits:!0},creditcard:{creditcard:!0}},addClassRules:function(b,c){b.constructor===String?this.classRuleSettings[b]=c:a.extend(this.classRuleSettings,b)},classRules:function(b){var c={},d=a(b).attr("class");return d&&a.each(d.split(" "),function(){this in a.validator.classRuleSettings&&a.extend(c,a.validator.classRuleSettings[this])}),c},normalizeAttributeRule:function(a,b,c,d){/min|max|step/.test(c)&&(null===b||/number|range|text/.test(b))&&(d=Number(d),isNaN(d)&&(d=void 0)),d||0===d?a[c]=d:b===c&&"range"!==b&&(a[c]=!0)},attributeRules:function(b){var c,d,e={},f=a(b),g=b.getAttribute("type");for(c in a.validator.methods)"required"===c?(d=b.getAttribute(c),""===d&&(d=!0),d=!!d):d=f.attr(c),this.normalizeAttributeRule(e,g,c,d);return e.maxlength&&/-1|2147483647|524288/.test(e.maxlength)&&delete e.maxlength,e},dataRules:function(b){var c,d,e={},f=a(b),g=b.getAttribute("type");for(c in a.validator.methods)d=f.data("rule"+c.charAt(0).toUpperCase()+c.substring(1).toLowerCase()),this.normalizeAttributeRule(e,g,c,d);return e},staticRules:function(b){var c={},d=a.data(b.form,"validator");return d.settings.rules&&(c=a.validator.normalizeRule(d.settings.rules[b.name])||{}),c},normalizeRules:function(b,c){return a.each(b,function(d,e){if(e===!1)return void delete b[d];if(e.param||e.depends){var f=!0;switch(typeof e.depends){case"string":f=!!a(e.depends,c.form).length;break;case"function":f=e.depends.call(c,c)}f?b[d]=void 0===e.param||e.param:(a.data(c.form,"validator").resetElements(a(c)),delete b[d])}}),a.each(b,function(d,e){b[d]=a.isFunction(e)&&"normalizer"!==d?e(c):e}),a.each(["minlength","maxlength"],function(){b[this]&&(b[this]=Number(b[this]))}),a.each(["rangelength","range"],function(){var c;b[this]&&(a.isArray(b[this])?b[this]=[Number(b[this][0]),Number(b[this][1])]:"string"==typeof b[this]&&(c=b[this].replace(/[\[\]]/g,"").split(/[\s,]+/),b[this]=[Number(c[0]),Number(c[1])]))}),a.validator.autoCreateRanges&&(null!=b.min&&null!=b.max&&(b.range=[b.min,b.max],delete b.min,delete b.max),null!=b.minlength&&null!=b.maxlength&&(b.rangelength=[b.minlength,b.maxlength],delete b.minlength,delete b.maxlength)),b},normalizeRule:function(b){if("string"==typeof b){var c={};a.each(b.split(/\s/),function(){c[this]=!0}),b=c}return b},addMethod:function(b,c,d){a.validator.methods[b]=c,a.validator.messages[b]=void 0!==d?d:a.validator.messages[b],c.length<3&&a.validator.addClassRules(b,a.validator.normalizeRule(b))},methods:{required:function(b,c,d){if(!this.depend(d,c))return"dependency-mismatch";if("select"===c.nodeName.toLowerCase()){var e=a(c).val();return e&&e.length>0}return this.checkable(c)?this.getLength(b,c)>0:b.length>0},email:function(a,b){return this.optional(b)||/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(a)},url:function(a,b){return this.optional(b)||/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[\/?#]\S*)?$/i.test(a)},date:function(a,b){return this.optional(b)||!/Invalid|NaN/.test(new Date(a).toString())},dateISO:function(a,b){return this.optional(b)||/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(a)},number:function(a,b){return this.optional(b)||/^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(a)},digits:function(a,b){return this.optional(b)||/^\d+$/.test(a)},minlength:function(b,c,d){var e=a.isArray(b)?b.length:this.getLength(b,c);return this.optional(c)||e>=d},maxlength:function(b,c,d){var e=a.isArray(b)?b.length:this.getLength(b,c);return this.optional(c)||e<=d},rangelength:function(b,c,d){var e=a.isArray(b)?b.length:this.getLength(b,c);return this.optional(c)||e>=d[0]&&e<=d[1]},min:function(a,b,c){return this.optional(b)||a>=c},max:function(a,b,c){return this.optional(b)||a<=c},range:function(a,b,c){return this.optional(b)||a>=c[0]&&a<=c[1]},step:function(b,c,d){var e,f=a(c).attr("type"),g="Step attribute on input type "+f+" is not supported.",h=["text","number","range"],i=new RegExp("\\b"+f+"\\b"),j=f&&!i.test(h.join()),k=function(a){var b=(""+a).match(/(?:\.(\d+))?$/);return b&&b[1]?b[1].length:0},l=function(a){return Math.round(a*Math.pow(10,e))},m=!0;if(j)throw new Error(g);return e=k(d),(k(b)>e||l(b)%l(d)!==0)&&(m=!1),this.optional(c)||m},equalTo:function(b,c,d){var e=a(d);return this.settings.onfocusout&&e.not(".validate-equalTo-blur").length&&e.addClass("validate-equalTo-blur").on("blur.validate-equalTo",function(){a(c).valid()}),b===e.val()},remote:function(b,c,d,e){if(this.optional(c))return"dependency-mismatch";e="string"==typeof e&&e||"remote";var f,g,h,i=this.previousValue(c,e);return this.settings.messages[c.name]||(this.settings.messages[c.name]={}),i.originalMessage=i.originalMessage||this.settings.messages[c.name][e],this.settings.messages[c.name][e]=i.message,d="string"==typeof d&&{url:d}||d,h=a.param(a.extend({data:b},d.data)),i.old===h?i.valid:(i.old=h,f=this,this.startRequest(c),g={},g[c.name]=b,a.ajax(a.extend(!0,{mode:"abort",port:"validate"+c.name,dataType:"json",data:g,context:f.currentForm,success:function(a){var d,g,h,j=a===!0||"true"===a;f.settings.messages[c.name][e]=i.originalMessage,j?(h=f.formSubmitted,f.resetInternals(),f.toHide=f.errorsFor(c),f.formSubmitted=h,f.successList.push(c),f.invalid[c.name]=!1,f.showErrors()):(d={},g=a||f.defaultMessage(c,{method:e,parameters:b}),d[c.name]=i.message=g,f.invalid[c.name]=!0,f.showErrors(d)),i.valid=j,f.stopRequest(c,j)}},d)),"pending")}}});var b,c={};return a.ajaxPrefilter?a.ajaxPrefilter(function(a,b,d){var e=a.port;"abort"===a.mode&&(c[e]&&c[e].abort(),c[e]=d)}):(b=a.ajax,a.ajax=function(d){var e=("mode"in d?d:a.ajaxSettings).mode,f=("port"in d?d:a.ajaxSettings).port;return"abort"===e?(c[f]&&c[f].abort(),c[f]=b.apply(this,arguments),c[f]):b.apply(this,arguments)}),a});
  /*! AdminLTE app.js
   * ================
   * Main JS application file for AdminLTE v2. This file
   * should be included in all pages. It controls some layout
   * options and implements exclusive AdminLTE plugins.
   *
   * @Author  Almsaeed Studio
   * @Support <http://www.almsaeedstudio.com>
   * @Email   <abdullah@almsaeedstudio.com>
   * @version 2.3.8
   * @license MIT <http://opensource.org/licenses/MIT>
   */
  
  //Make sure jQuery has been loaded before app.js
  if (typeof jQuery === "undefined") {
    throw new Error("AdminLTE requires jQuery");
  }
  
  /* AdminLTE
   *
   * @type Object
   * @description $.AdminLTE is the main object for the template's app.
   *              It's used for implementing functions and options related
   *              to the template. Keeping everything wrapped in an object
   *              prevents conflict with other plugins and is a better
   *              way to organize our code.
   */
  $.AdminLTE = {};
  
  /* --------------------
   * - AdminLTE Options -
   * --------------------
   * Modify these options to suit your implementation
   */
  $.AdminLTE.options = {
    //Add slimscroll to navbar menus
    //This requires you to load the slimscroll plugin
    //in every page before app.js
    navbarMenuSlimscroll: true,
    navbarMenuSlimscrollWidth: "3px", //The width of the scroll bar
    navbarMenuHeight: "200px", //The height of the inner menu
    //General animation speed for JS animated elements such as box collapse/expand and
    //sidebar treeview slide up/down. This options accepts an integer as milliseconds,
    //'fast', 'normal', or 'slow'
    animationSpeed: 500,
    //Sidebar push menu toggle button selector
    sidebarToggleSelector: "[data-toggle='offcanvas']",
    //Activate sidebar push menu
    sidebarPushMenu: true,
    //Activate sidebar slimscroll if the fixed layout is set (requires SlimScroll Plugin)
    sidebarSlimScroll: true,
    //Enable sidebar expand on hover effect for sidebar mini
    //This option is forced to true if both the fixed layout and sidebar mini
    //are used together
    sidebarExpandOnHover: false,
    //BoxRefresh Plugin
    enableBoxRefresh: true,
    //Bootstrap.js tooltip
    enableBSToppltip: true,
    BSTooltipSelector: "[data-toggle='tooltip']",
    //Enable Fast Click. Fastclick.js creates a more
    //native touch experience with touch devices. If you
    //choose to enable the plugin, make sure you load the script
    //before AdminLTE's app.js
    enableFastclick: false,
    //Control Sidebar Tree views
    enableControlTreeView: true,
    //Control Sidebar Options
    enableControlSidebar: true,
    controlSidebarOptions: {
      //Which button should trigger the open/close event
      toggleBtnSelector: "[data-toggle='control-sidebar']",
      //The sidebar selector
      selector: ".control-sidebar",
      //Enable slide over content
      slide: true
    },
    //Box Widget Plugin. Enable this plugin
    //to allow boxes to be collapsed and/or removed
    enableBoxWidget: true,
    //Box Widget plugin options
    boxWidgetOptions: {
      boxWidgetIcons: {
        //Collapse icon
        collapse: 'fa-minus',
        //Open icon
        open: 'fa-plus',
        //Remove icon
        remove: 'fa-times'
      },
      boxWidgetSelectors: {
        //Remove button selector
        remove: '[data-widget="remove"]',
        //Collapse button selector
        collapse: '[data-widget="collapse"]'
      }
    },
    //Direct Chat plugin options
    directChat: {
      //Enable direct chat by default
      enable: true,
      //The button to open and close the chat contacts pane
      contactToggleSelector: '[data-widget="chat-pane-toggle"]'
    },
    //Define the set of colors to use globally around the website
    colors: {
      lightBlue: "#3c8dbc",
      red: "#f56954",
      green: "#00a65a",
      aqua: "#00c0ef",
      yellow: "#f39c12",
      blue: "#0073b7",
      navy: "#001F3F",
      teal: "#39CCCC",
      olive: "#3D9970",
      lime: "#01FF70",
      orange: "#FF851B",
      fuchsia: "#F012BE",
      purple: "#8E24AA",
      maroon: "#D81B60",
      black: "#222222",
      gray: "#d2d6de"
    },
    //The standard screen sizes that bootstrap uses.
    //If you change these in the variables.less file, change
    //them here too.
    screenSizes: {
      xs: 480,
      sm: 768,
      md: 992,
      lg: 1200
    }
  };
  
  /* ------------------
   * - Implementation -
   * ------------------
   * The next block of code implements AdminLTE's
   * functions and plugins as specified by the
   * options above.
   */
  $(function () {
    "use strict";
  
    //Fix for IE page transitions
    $("body").removeClass("hold-transition");
  
    //Extend options if external options exist
    if (typeof AdminLTEOptions !== "undefined") {
      $.extend(true,
        $.AdminLTE.options,
        AdminLTEOptions);
    }
  
    //Easy access to options
    var o = $.AdminLTE.options;
  
    //Set up the object
    _init();
  
    //Activate the layout maker
    $.AdminLTE.layout.activate();
  
    //Enable sidebar tree view controls
    if (o.enableControlTreeView) {
      $.AdminLTE.tree('.sidebar');
    }
  
    //Enable control sidebar
    if (o.enableControlSidebar) {
      $.AdminLTE.controlSidebar.activate();
    }
  
    //Add slimscroll to navbar dropdown
    if (o.navbarMenuSlimscroll && typeof $.fn.slimscroll != 'undefined') {
      $(".navbar .menu").slimscroll({
        height: o.navbarMenuHeight,
        alwaysVisible: false,
        size: o.navbarMenuSlimscrollWidth
      }).css("width", "100%");
    }
  
    //Activate sidebar push menu
    if (o.sidebarPushMenu) {
      $.AdminLTE.pushMenu.activate(o.sidebarToggleSelector);
    }
  
    //Activate Bootstrap tooltip
    if (o.enableBSToppltip) {
      $('body').tooltip({
        selector: o.BSTooltipSelector,
        container: 'body'
      });
    }
  
    //Activate box widget
    if (o.enableBoxWidget) {
      $.AdminLTE.boxWidget.activate();
    }
  
    //Activate fast click
    if (o.enableFastclick && typeof FastClick != 'undefined') {
      FastClick.attach(document.body);
    }
  
    //Activate direct chat widget
    if (o.directChat.enable) {
      $(document).on('click', o.directChat.contactToggleSelector, function () {
        var box = $(this).parents('.direct-chat').first();
        box.toggleClass('direct-chat-contacts-open');
      });
    }
  
    /*
     * INITIALIZE BUTTON TOGGLE
     * ------------------------
     */
    $('.btn-group[data-toggle="btn-toggle"]').each(function () {
      var group = $(this);
      $(this).find(".btn").on('click', function (e) {
        group.find(".btn.active").removeClass("active");
        $(this).addClass("active");
        e.preventDefault();
      });
  
    });
  });
  
  /* ----------------------------------
   * - Initialize the AdminLTE Object -
   * ----------------------------------
   * All AdminLTE functions are implemented below.
   */
  function _init() {
    'use strict';
    /* Layout
     * ======
     * Fixes the layout height in case min-height fails.
     *
     * @type Object
     * @usage $.AdminLTE.layout.activate()
     *        $.AdminLTE.layout.fix()
     *        $.AdminLTE.layout.fixSidebar()
     */
    $.AdminLTE.layout = {
      activate: function () {
        var _this = this;
        _this.fix();
        _this.fixSidebar();
        $('body, html, .wrapper').css('height', 'auto');
        $(window, ".wrapper").resize(function () {
          _this.fix();
          _this.fixSidebar();
        });
      },
      fix: function () {
        // Remove overflow from .wrapper if layout-boxed exists
        $(".layout-boxed > .wrapper").css('overflow', 'hidden');
        //Get window height and the wrapper height
        var footer_height = $('.main-footer').outerHeight() || 0;
        var neg = $('.main-header').outerHeight() + footer_height;
        var window_height = $(window).height();
        var sidebar_height = $(".sidebar").height() || 0;
        //Set the min-height of the content and sidebar based on the
        //the height of the document.
        if ($("body").hasClass("fixed")) {
          $(".content-wrapper, .right-side").css('min-height', window_height - footer_height);
        } else {
          var postSetWidth;
          if (window_height >= sidebar_height) {
            $(".content-wrapper, .right-side").css('min-height', window_height - neg);
            postSetWidth = window_height - neg;
          } else {
            $(".content-wrapper, .right-side").css('min-height', sidebar_height);
            postSetWidth = sidebar_height;
          }
  
          //Fix for the control sidebar height
          var controlSidebar = $($.AdminLTE.options.controlSidebarOptions.selector);
          if (typeof controlSidebar !== "undefined") {
            if (controlSidebar.height() > postSetWidth)
              $(".content-wrapper, .right-side").css('min-height', controlSidebar.height());
          }
  
        }
      },
      fixSidebar: function () {
        //Make sure the body tag has the .fixed class
        if (!$("body").hasClass("fixed")) {
          if (typeof $.fn.slimScroll != 'undefined') {
            $(".sidebar").slimScroll({destroy: true}).height("auto");
          }
          return;
        } else if (typeof $.fn.slimScroll == 'undefined' && window.console) {
          window.console.error("Error: the fixed layout requires the slimscroll plugin!");
        }
        //Enable slimscroll for fixed layout
        if ($.AdminLTE.options.sidebarSlimScroll) {
          if (typeof $.fn.slimScroll != 'undefined') {
            //Destroy if it exists
            $(".sidebar").slimScroll({destroy: true}).height("auto");
            //Add slimscroll
            $(".sidebar").slimScroll({
              height: ($(window).height() - $(".main-header").height()) + "px",
              color: "rgba(0,0,0,0.2)",
              size: "3px"
            });
          }
        }
      }
    };
  
    /* PushMenu()
     * ==========
     * Adds the push menu functionality to the sidebar.
     *
     * @type Function
     * @usage: $.AdminLTE.pushMenu("[data-toggle='offcanvas']")
     */
    $.AdminLTE.pushMenu = {
      activate: function (toggleBtn) {
        //Get the screen sizes
        var screenSizes = $.AdminLTE.options.screenSizes;
  
        //Enable sidebar toggle
        $(document).on('click', toggleBtn, function (e) {
          e.preventDefault();
  
          //Enable sidebar push menu
          if ($(window).width() > (screenSizes.sm - 1)) {
            if ($("body").hasClass('sidebar-collapse')) {
              $("body").removeClass('sidebar-collapse').trigger('expanded.pushMenu');
            } else {
              $("body").addClass('sidebar-collapse').trigger('collapsed.pushMenu');
            }
          }
          //Handle sidebar push menu for small screens
          else {
            if ($("body").hasClass('sidebar-open')) {
              $("body").removeClass('sidebar-open').removeClass('sidebar-collapse').trigger('collapsed.pushMenu');
            } else {
              $("body").addClass('sidebar-open').trigger('expanded.pushMenu');
            }
          }
        });
  
        $(".content-wrapper").click(function () {
          //Enable hide menu when clicking on the content-wrapper on small screens
          if ($(window).width() <= (screenSizes.sm - 1) && $("body").hasClass("sidebar-open")) {
            $("body").removeClass('sidebar-open');
          }
        });
  
        //Enable expand on hover for sidebar mini
        if ($.AdminLTE.options.sidebarExpandOnHover
          || ($('body').hasClass('fixed')
          && $('body').hasClass('sidebar-mini'))) {
          this.expandOnHover();
        }
      },
      expandOnHover: function () {
        var _this = this;
        var screenWidth = $.AdminLTE.options.screenSizes.sm - 1;
        //Expand sidebar on hover
        $('.main-sidebar').hover(function () {
          if ($('body').hasClass('sidebar-mini')
            && $("body").hasClass('sidebar-collapse')
            && $(window).width() > screenWidth) {
            _this.expand();
          }
        }, function () {
          if ($('body').hasClass('sidebar-mini')
            && $('body').hasClass('sidebar-expanded-on-hover')
            && $(window).width() > screenWidth) {
            _this.collapse();
          }
        });
      },
      expand: function () {
        $("body").removeClass('sidebar-collapse').addClass('sidebar-expanded-on-hover');
      },
      collapse: function () {
        if ($('body').hasClass('sidebar-expanded-on-hover')) {
          $('body').removeClass('sidebar-expanded-on-hover').addClass('sidebar-collapse');
        }
      }
    };
  
    /* Tree()
     * ======
     * Converts the sidebar into a multilevel
     * tree view menu.
     *
     * @type Function
     * @Usage: $.AdminLTE.tree('.sidebar')
     */
    $.AdminLTE.tree = function (menu) {
      var _this = this;
      var animationSpeed = $.AdminLTE.options.animationSpeed;
      $(document).off('click', menu + ' li a')
        .on('click', menu + ' li a', function (e) {
          //Get the clicked link and the next element
          var $this = $(this);
          var checkElement = $this.next();
  
          //Check if the next element is a menu and is visible
          if ((checkElement.is('.treeview-menu')) && (checkElement.is(':visible')) && (!$('body').hasClass('sidebar-collapse'))) {
            //Close the menu
            checkElement.slideUp(animationSpeed, function () {
              checkElement.removeClass('menu-open');
              //Fix the layout in case the sidebar stretches over the height of the window
              //_this.layout.fix();
            });
            checkElement.parent("li").removeClass("active");
          }
          //If the menu is not visible
          else if ((checkElement.is('.treeview-menu')) && (!checkElement.is(':visible'))) {
            //Get the parent menu
            var parent = $this.parents('ul').first();
            //Close all open menus within the parent
            var ul = parent.find('ul:visible').slideUp(animationSpeed);
            //Remove the menu-open class from the parent
            ul.removeClass('menu-open');
            //Get the parent li
            var parent_li = $this.parent("li");
  
            //Open the target menu and add the menu-open class
            checkElement.slideDown(animationSpeed, function () {
              //Add the class active to the parent li
              checkElement.addClass('menu-open');
              parent.find('li.active').removeClass('active');
              parent_li.addClass('active');
              //Fix the layout in case the sidebar stretches over the height of the window
              _this.layout.fix();
            });
          }
          //if this isn't a link, prevent the page from being redirected
          if (checkElement.is('.treeview-menu')) {
            e.preventDefault();
          }
        });
    };
  
    /* ControlSidebar
     * ==============
     * Adds functionality to the right sidebar
     *
     * @type Object
     * @usage $.AdminLTE.controlSidebar.activate(options)
     */
    $.AdminLTE.controlSidebar = {
      //instantiate the object
      activate: function () {
        //Get the object
        var _this = this;
        //Update options
        var o = $.AdminLTE.options.controlSidebarOptions;
        //Get the sidebar
        var sidebar = $(o.selector);
        //The toggle button
        var btn = $(o.toggleBtnSelector);
  
        //Listen to the click event
        btn.on('click', function (e) {
          e.preventDefault();
          //If the sidebar is not open
          if (!sidebar.hasClass('control-sidebar-open')
            && !$('body').hasClass('control-sidebar-open')) {
            //Open the sidebar
            _this.open(sidebar, o.slide);
          } else {
            _this.close(sidebar, o.slide);
          }
        });
  
        //If the body has a boxed layout, fix the sidebar bg position
        var bg = $(".control-sidebar-bg");
        _this._fix(bg);
  
        //If the body has a fixed layout, make the control sidebar fixed
        if ($('body').hasClass('fixed')) {
          _this._fixForFixed(sidebar);
        } else {
          //If the content height is less than the sidebar's height, force max height
          if ($('.content-wrapper, .right-side').height() < sidebar.height()) {
            _this._fixForContent(sidebar);
          }
        }
      },
      //Open the control sidebar
      open: function (sidebar, slide) {
        //Slide over content
        if (slide) {
          sidebar.addClass('control-sidebar-open');
        } else {
          //Push the content by adding the open class to the body instead
          //of the sidebar itself
          $('body').addClass('control-sidebar-open');
        }
      },
      //Close the control sidebar
      close: function (sidebar, slide) {
        if (slide) {
          sidebar.removeClass('control-sidebar-open');
        } else {
          $('body').removeClass('control-sidebar-open');
        }
      },
      _fix: function (sidebar) {
        var _this = this;
        if ($("body").hasClass('layout-boxed')) {
          sidebar.css('position', 'absolute');
          sidebar.height($(".wrapper").height());
          if (_this.hasBindedResize) {
            return;
          }
          $(window).resize(function () {
            _this._fix(sidebar);
          });
          _this.hasBindedResize = true;
        } else {
          sidebar.css({
            'position': 'fixed',
            'height': 'auto'
          });
        }
      },
      _fixForFixed: function (sidebar) {
        sidebar.css({
          'position': 'fixed',
          'max-height': '100%',
          'overflow': 'auto',
          'padding-bottom': '50px'
        });
      },
      _fixForContent: function (sidebar) {
        $(".content-wrapper, .right-side").css('min-height', sidebar.height());
      }
    };
  
    /* BoxWidget
     * =========
     * BoxWidget is a plugin to handle collapsing and
     * removing boxes from the screen.
     *
     * @type Object
     * @usage $.AdminLTE.boxWidget.activate()
     *        Set all your options in the main $.AdminLTE.options object
     */
    $.AdminLTE.boxWidget = {
      selectors: $.AdminLTE.options.boxWidgetOptions.boxWidgetSelectors,
      icons: $.AdminLTE.options.boxWidgetOptions.boxWidgetIcons,
      animationSpeed: $.AdminLTE.options.animationSpeed,
      activate: function (_box) {
        var _this = this;
        if (!_box) {
          _box = document; // activate all boxes per default
        }
        //Listen for collapse event triggers
        $(_box).on('click', _this.selectors.collapse, function (e) {
          e.preventDefault();
          _this.collapse($(this));
        });
  
        //Listen for remove event triggers
        $(_box).on('click', _this.selectors.remove, function (e) {
          e.preventDefault();
          _this.remove($(this));
        });
      },
      collapse: function (element) {
        var _this = this;
        //Find the box parent
        var box = element.parents(".box").first();
        //Find the body and the footer
        var box_content = box.find("> .box-body, > .box-footer, > form  >.box-body, > form > .box-footer");
        if (!box.hasClass("collapsed-box")) {
          //Convert minus into plus
          element.children(":first")
            .removeClass(_this.icons.collapse)
            .addClass(_this.icons.open);
          //Hide the content
          box_content.slideUp(_this.animationSpeed, function () {
            box.addClass("collapsed-box");
          });
        } else {
          //Convert plus into minus
          element.children(":first")
            .removeClass(_this.icons.open)
            .addClass(_this.icons.collapse);
          //Show the content
          box_content.slideDown(_this.animationSpeed, function () {
            box.removeClass("collapsed-box");
          });
        }
      },
      remove: function (element) {
        //Find the box parent
        var box = element.parents(".box").first();
        box.slideUp(this.animationSpeed);
      }
    };
  }
  
  /* ------------------
   * - Custom Plugins -
   * ------------------
   * All custom plugins are defined below.
   */
  
  /*
   * BOX REFRESH BUTTON
   * ------------------
   * This is a custom plugin to use with the component BOX. It allows you to add
   * a refresh button to the box. It converts the box's state to a loading state.
   *
   * @type plugin
   * @usage $("#box-widget").boxRefresh( options );
   */
  (function ($) {
  
    "use strict";
  
    $.fn.boxRefresh = function (options) {
  
      // Render options
      var settings = $.extend({
        //Refresh button selector
        trigger: ".refresh-btn",
        //File source to be loaded (e.g: ajax/src.php)
        source: "",
        //Callbacks
        onLoadStart: function (box) {
          return box;
        }, //Right after the button has been clicked
        onLoadDone: function (box) {
          return box;
        } //When the source has been loaded
  
      }, options);
  
      //The overlay
      var overlay = $('<div class="overlay"><div class="fa fa-refresh fa-spin"></div></div>');
  
      return this.each(function () {
        //if a source is specified
        if (settings.source === "") {
          if (window.console) {
            window.console.log("Please specify a source first - boxRefresh()");
          }
          return;
        }
        //the box
        var box = $(this);
        //the button
        var rBtn = box.find(settings.trigger).first();
  
        //On trigger click
        rBtn.on('click', function (e) {
          e.preventDefault();
          //Add loading overlay
          start(box);
  
          //Perform ajax call
          box.find(".box-body").load(settings.source, function () {
            done(box);
          });
        });
      });
  
      function start(box) {
        //Add overlay and loading img
        box.append(overlay);
  
        settings.onLoadStart.call(box);
      }
  
      function done(box) {
        //Remove overlay and loading img
        box.find(overlay).remove();
  
        settings.onLoadDone.call(box);
      }
  
    };
  
  })(jQuery);
  
  /*
   * EXPLICIT BOX CONTROLS
   * -----------------------
   * This is a custom plugin to use with the component BOX. It allows you to activate
   * a box inserted in the DOM after the app.js was loaded, toggle and remove box.
   *
   * @type plugin
   * @usage $("#box-widget").activateBox();
   * @usage $("#box-widget").toggleBox();
   * @usage $("#box-widget").removeBox();
   */
  (function ($) {
  
    'use strict';
  
    $.fn.activateBox = function () {
      $.AdminLTE.boxWidget.activate(this);
    };
  
    $.fn.toggleBox = function () {
      var button = $($.AdminLTE.boxWidget.selectors.collapse, this);
      $.AdminLTE.boxWidget.collapse(button);
    };
  
    $.fn.removeBox = function () {
      var button = $($.AdminLTE.boxWidget.selectors.remove, this);
      $.AdminLTE.boxWidget.remove(button);
    };
  
  })(jQuery);
  
  /*
   * TODO LIST CUSTOM PLUGIN
   * -----------------------
   * This plugin depends on iCheck plugin for checkbox and radio inputs
   *
   * @type plugin
   * @usage $("#todo-widget").todolist( options );
   */
  (function ($) {
  
    'use strict';
  
    $.fn.todolist = function (options) {
      // Render options
      var settings = $.extend({
        //When the user checks the input
        onCheck: function (ele) {
          return ele;
        },
        //When the user unchecks the input
        onUncheck: function (ele) {
          return ele;
        }
      }, options);
  
      return this.each(function () {
  
        if (typeof $.fn.iCheck != 'undefined') {
          $('input', this).on('ifChecked', function () {
            var ele = $(this).parents("li").first();
            ele.toggleClass("done");
            settings.onCheck.call(ele);
          });
  
          $('input', this).on('ifUnchecked', function () {
            var ele = $(this).parents("li").first();
            ele.toggleClass("done");
            settings.onUncheck.call(ele);
          });
        } else {
          $('input', this).on('change', function () {
            var ele = $(this).parents("li").first();
            ele.toggleClass("done");
            if ($('input', ele).is(":checked")) {
              settings.onCheck.call(ele);
            } else {
              settings.onUncheck.call(ele);
            }
          });
        }
      });
    };
  }(jQuery));
  
  /**
   * AdminLTE Demo Menu
   * ------------------
   * You should not use this file in production.
   * This file is for demo purposes only.
   */
  (function ($, AdminLTE) {
  
    "use strict";
  
    /**
     * List of all the available skins
     *
     * @type Array
     */
    var my_skins = [
      "skin-blue",
      "skin-black",
      "skin-red",
      "skin-yellow",
      "skin-purple",
      "skin-green",
      "skin-blue-light",
      "skin-black-light",
      "skin-red-light",
      "skin-yellow-light",
      "skin-purple-light",
      "skin-green-light"
    ];
  
    //Create the new tab
    var tab_pane = $("<div />", {
      "id": "control-sidebar-theme-demo-options-tab",
      "class": "tab-pane active"
    });
  
    //Create the tab button
    var tab_button = $("<li />", {"class": "active"})
        .html("<a href='#control-sidebar-theme-demo-options-tab' data-toggle='tab'>"
        + "<i class='fa fa-wrench'></i>"
        + "</a>");
  
    //Add the tab button to the right sidebar tabs
    $("[href='#control-sidebar-home-tab']")
        .parent()
        .before(tab_button);
  
    //Create the menu
    var demo_settings = $("<div />");
  
    //Layout options
    demo_settings.append(
        "<h4 class='control-sidebar-heading'>"
        + "Layout Options"
        + "</h4>"
          //Fixed layout
        + "<div class='form-group'>"
        + "<label class='control-sidebar-subheading'>"
        + "<input type='checkbox' data-layout='fixed' class='pull-right'/> "
        + "Fixed layout"
        + "</label>"
        + "<p>Activate the fixed layout. You can't use fixed and boxed layouts together</p>"
        + "</div>"
          //Boxed layout
        + "<div class='form-group'>"
        + "<label class='control-sidebar-subheading'>"
        + "<input type='checkbox' data-layout='layout-boxed'class='pull-right'/> "
        + "Boxed Layout"
        + "</label>"
        + "<p>Activate the boxed layout</p>"
        + "</div>"
          //Sidebar Toggle
        + "<div class='form-group'>"
        + "<label class='control-sidebar-subheading'>"
        + "<input type='checkbox' data-layout='sidebar-collapse' class='pull-right'/> "
        + "Toggle Sidebar"
        + "</label>"
        + "<p>Toggle the left sidebar's state (open or collapse)</p>"
        + "</div>"
          //Sidebar mini expand on hover toggle
        + "<div class='form-group'>"
        + "<label class='control-sidebar-subheading'>"
        + "<input type='checkbox' data-enable='expandOnHover' class='pull-right'/> "
        + "Sidebar Expand on Hover"
        + "</label>"
        + "<p>Let the sidebar mini expand on hover</p>"
        + "</div>"
          //Control Sidebar Toggle
        + "<div class='form-group'>"
        + "<label class='control-sidebar-subheading'>"
        + "<input type='checkbox' data-controlsidebar='control-sidebar-open' class='pull-right'/> "
        + "Toggle Right Sidebar Slide"
        + "</label>"
        + "<p>Toggle between slide over content and push content effects</p>"
        + "</div>"
          //Control Sidebar Skin Toggle
        + "<div class='form-group'>"
        + "<label class='control-sidebar-subheading'>"
        + "<input type='checkbox' data-sidebarskin='toggle' class='pull-right'/> "
        + "Toggle Right Sidebar Skin"
        + "</label>"
        + "<p>Toggle between dark and light skins for the right sidebar</p>"
        + "</div>"
    );
    var skins_list = $("<ul />", {"class": 'list-unstyled clearfix'});
  
    //Dark sidebar skins
    var skin_blue =
        $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
            .append("<a href='javascript:void(0);' data-skin='skin-blue' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
            + "<div><span style='display:block; width: 20%; float: left; height: 7px; background: #367fa9;'></span><span class='bg-light-blue' style='display:block; width: 80%; float: left; height: 7px;'></span></div>"
            + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #222d32;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
            + "</a>"
            + "<p class='text-center no-margin'>Blue</p>");
    skins_list.append(skin_blue);
    var skin_black =
        $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
            .append("<a href='javascript:void(0);' data-skin='skin-black' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
            + "<div style='box-shadow: 0 0 2px rgba(0,0,0,0.1)' class='clearfix'><span style='display:block; width: 20%; float: left; height: 7px; background: #fefefe;'></span><span style='display:block; width: 80%; float: left; height: 7px; background: #fefefe;'></span></div>"
            + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #222;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
            + "</a>"
            + "<p class='text-center no-margin'>Black</p>");
    skins_list.append(skin_black);
    var skin_purple =
        $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
            .append("<a href='javascript:void(0);' data-skin='skin-purple' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
            + "<div><span style='display:block; width: 20%; float: left; height: 7px;' class='bg-purple-active'></span><span class='bg-purple' style='display:block; width: 80%; float: left; height: 7px;'></span></div>"
            + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #222d32;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
            + "</a>"
            + "<p class='text-center no-margin'>Purple</p>");
    skins_list.append(skin_purple);
    var skin_green =
        $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
            .append("<a href='javascript:void(0);' data-skin='skin-green' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
            + "<div><span style='display:block; width: 20%; float: left; height: 7px;' class='bg-green-active'></span><span class='bg-green' style='display:block; width: 80%; float: left; height: 7px;'></span></div>"
            + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #222d32;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
            + "</a>"
            + "<p class='text-center no-margin'>Green</p>");
    skins_list.append(skin_green);
    var skin_red =
        $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
            .append("<a href='javascript:void(0);' data-skin='skin-red' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
            + "<div><span style='display:block; width: 20%; float: left; height: 7px;' class='bg-red-active'></span><span class='bg-red' style='display:block; width: 80%; float: left; height: 7px;'></span></div>"
            + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #222d32;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
            + "</a>"
            + "<p class='text-center no-margin'>Red</p>");
    skins_list.append(skin_red);
    var skin_yellow =
        $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
            .append("<a href='javascript:void(0);' data-skin='skin-yellow' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
            + "<div><span style='display:block; width: 20%; float: left; height: 7px;' class='bg-yellow-active'></span><span class='bg-yellow' style='display:block; width: 80%; float: left; height: 7px;'></span></div>"
            + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #222d32;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
            + "</a>"
            + "<p class='text-center no-margin'>Yellow</p>");
    skins_list.append(skin_yellow);
  
    //Light sidebar skins
    var skin_blue_light =
        $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
            .append("<a href='javascript:void(0);' data-skin='skin-blue-light' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
            + "<div><span style='display:block; width: 20%; float: left; height: 7px; background: #367fa9;'></span><span class='bg-light-blue' style='display:block; width: 80%; float: left; height: 7px;'></span></div>"
            + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #f9fafc;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
            + "</a>"
            + "<p class='text-center no-margin' style='font-size: 12px'>Blue Light</p>");
    skins_list.append(skin_blue_light);
    var skin_black_light =
        $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
            .append("<a href='javascript:void(0);' data-skin='skin-black-light' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
            + "<div style='box-shadow: 0 0 2px rgba(0,0,0,0.1)' class='clearfix'><span style='display:block; width: 20%; float: left; height: 7px; background: #fefefe;'></span><span style='display:block; width: 80%; float: left; height: 7px; background: #fefefe;'></span></div>"
            + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #f9fafc;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
            + "</a>"
            + "<p class='text-center no-margin' style='font-size: 12px'>Black Light</p>");
    skins_list.append(skin_black_light);
    var skin_purple_light =
        $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
            .append("<a href='javascript:void(0);' data-skin='skin-purple-light' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
            + "<div><span style='display:block; width: 20%; float: left; height: 7px;' class='bg-purple-active'></span><span class='bg-purple' style='display:block; width: 80%; float: left; height: 7px;'></span></div>"
            + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #f9fafc;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
            + "</a>"
            + "<p class='text-center no-margin' style='font-size: 12px'>Purple Light</p>");
    skins_list.append(skin_purple_light);
    var skin_green_light =
        $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
            .append("<a href='javascript:void(0);' data-skin='skin-green-light' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
            + "<div><span style='display:block; width: 20%; float: left; height: 7px;' class='bg-green-active'></span><span class='bg-green' style='display:block; width: 80%; float: left; height: 7px;'></span></div>"
            + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #f9fafc;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
            + "</a>"
            + "<p class='text-center no-margin' style='font-size: 12px'>Green Light</p>");
    skins_list.append(skin_green_light);
    var skin_red_light =
        $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
            .append("<a href='javascript:void(0);' data-skin='skin-red-light' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
            + "<div><span style='display:block; width: 20%; float: left; height: 7px;' class='bg-red-active'></span><span class='bg-red' style='display:block; width: 80%; float: left; height: 7px;'></span></div>"
            + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #f9fafc;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
            + "</a>"
            + "<p class='text-center no-margin' style='font-size: 12px'>Red Light</p>");
    skins_list.append(skin_red_light);
    var skin_yellow_light =
        $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
            .append("<a href='javascript:void(0);' data-skin='skin-yellow-light' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
            + "<div><span style='display:block; width: 20%; float: left; height: 7px;' class='bg-yellow-active'></span><span class='bg-yellow' style='display:block; width: 80%; float: left; height: 7px;'></span></div>"
            + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #f9fafc;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
            + "</a>"
            + "<p class='text-center no-margin' style='font-size: 12px;'>Yellow Light</p>");
    skins_list.append(skin_yellow_light);
  
    demo_settings.append("<h4 class='control-sidebar-heading'>Skins</h4>");
    demo_settings.append(skins_list);
  
    tab_pane.append(demo_settings);
    $("#control-sidebar-home-tab").after(tab_pane);
  
    setup();
  
    /**
     * Toggles layout classes
     *
     * @param String cls the layout class to toggle
     * @returns void
     */
    function change_layout(cls) {
      $("body").toggleClass(cls);
      AdminLTE.layout.fixSidebar();
      //Fix the problem with right sidebar and layout boxed
      if (cls == "layout-boxed")
        AdminLTE.controlSidebar._fix($(".control-sidebar-bg"));
      if ($('body').hasClass('fixed') && cls == 'fixed') {
        AdminLTE.pushMenu.expandOnHover();
        AdminLTE.layout.activate();
      }
      AdminLTE.controlSidebar._fix($(".control-sidebar-bg"));
      AdminLTE.controlSidebar._fix($(".control-sidebar"));
    }
  
    /**
     * Replaces the old skin with the new skin
     * @param String cls the new skin class
     * @returns Boolean false to prevent link's default action
     */
    function change_skin(cls) {
      $.each(my_skins, function (i) {
        $("body").removeClass(my_skins[i]);
      });
  
      $("body").addClass(cls);
      store('skin', cls);
      return false;
    }
  
    /**
     * Store a new settings in the browser
     *
     * @param String name Name of the setting
     * @param String val Value of the setting
     * @returns void
     */
    function store(name, val) {
      if (typeof (Storage) !== "undefined") {
        localStorage.setItem(name, val);
      } else {
        window.alert('Please use a modern browser to properly view this template!');
      }
    }
  
    /**
     * Get a prestored setting
     *
     * @param String name Name of of the setting
     * @returns String The value of the setting | null
     */
    function get(name) {
      if (typeof (Storage) !== "undefined") {
        return localStorage.getItem(name);
      } else {
        window.alert('Please use a modern browser to properly view this template!');
      }
    }
  
    /**
     * Retrieve default settings and apply them to the template
     *
     * @returns void
     */
    function setup() {
      var tmp = get('skin');
      if (tmp && $.inArray(tmp, my_skins))
        change_skin(tmp);
  
      //Add the change skin listener
      $("[data-skin]").on('click', function (e) {
        if($(this).hasClass('knob'))
          return;
        e.preventDefault();
        change_skin($(this).data('skin'));
      });
  
      //Add the layout manager
      $("[data-layout]").on('click', function () {
        change_layout($(this).data('layout'));
      });
  
      $("[data-controlsidebar]").on('click', function () {
        change_layout($(this).data('controlsidebar'));
        var slide = !AdminLTE.options.controlSidebarOptions.slide;
        AdminLTE.options.controlSidebarOptions.slide = slide;
        if (!slide)
          $('.control-sidebar').removeClass('control-sidebar-open');
      });
  
      $("[data-sidebarskin='toggle']").on('click', function () {
        var sidebar = $(".control-sidebar");
        if (sidebar.hasClass("control-sidebar-dark")) {
          sidebar.removeClass("control-sidebar-dark")
          sidebar.addClass("control-sidebar-light")
        } else {
          sidebar.removeClass("control-sidebar-light")
          sidebar.addClass("control-sidebar-dark")
        }
      });
  
      $("[data-enable='expandOnHover']").on('click', function () {
        $(this).attr('disabled', true);
        AdminLTE.pushMenu.expandOnHover();
        if (!$('body').hasClass('sidebar-collapse'))
          $("[data-layout='sidebar-collapse']").click();
      });
  
      // Reset options
      if ($('body').hasClass('fixed')) {
        $("[data-layout='fixed']").attr('checked', 'checked');
      }
      if ($('body').hasClass('layout-boxed')) {
        $("[data-layout='layout-boxed']").attr('checked', 'checked');
      }
      if ($('body').hasClass('sidebar-collapse')) {
        $("[data-layout='sidebar-collapse']").attr('checked', 'checked');
      }
  
    }
  })(jQuery, $.AdminLTE);
  
  /**
   * Created by Junnyor on 09/07/2017.
   */
  
   function xmlToJson(xml) {
  
      // Create the return object
      var obj = {};
  
      if (xml.nodeType == 1) { // element
          // do attributes
          if (xml.attributes.length > 0) {
          obj["@attributes"] = {};
              for (var j = 0; j < xml.attributes.length; j++) {
                  var attribute = xml.attributes.item(j);
                  obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
              }
          }
      } else if (xml.nodeType == 3) { // text
          obj = xml.nodeValue;
      }
  
      // do children
      // If just one text node inside
      if (xml.hasChildNodes() && xml.childNodes.length === 1 && xml.childNodes[0].nodeType === 3) {
          obj = xml.childNodes[0].nodeValue;
      }
      else if (xml.hasChildNodes()) {
          for(var i = 0; i < xml.childNodes.length; i++) {
              var item = xml.childNodes.item(i);
              var nodeName = item.nodeName;
              if (typeof(obj[nodeName]) == "undefined") {
                  obj[nodeName] = xmlToJson(item);
              } else {
                  if (typeof(obj[nodeName].push) == "undefined") {
                      var old = obj[nodeName];
                      obj[nodeName] = [];
                      obj[nodeName].push(old);
                  }
                  obj[nodeName].push(xmlToJson(item));
              }
          }
      }
      return obj;
  }
  
  function getFormattedDate(date) {
      var date = new Date(date);
      var month = date.getMonth() + 1;
      var day = date.getDate();
      var year = date.getFullYear();
      var hours = date.getHours();
      var minutes = date.getMinutes();
      if(day < 10){
          day = '0'+day;
      }
      if(month < 10){
          month = '0'+month;
      }
      return day + "/" + month + "/" + year+' '+hours+':'+minutes;
  }
  
  Number.prototype.format = function(n, x) {
      var re = '(\\d)(?=(\\d{' + (x || 3) + '})+' + (n > 0 ? '\\.' : '$') + ')';
      return this.toFixed(Math.max(0, ~~n)).replace(new RegExp(re, 'g'), '$1,');
  };
  
  //Função para validar CPF
  function validateCPF(cpf){
  
      var numbers, digits, sum, i, result, equal_digits;
      equal_digits = 1;
      cpf = cpf.replace(/\.|\-/g, '');
      if (cpf.length < 11) {
          return false;
      }
      for (i = 0; i < cpf.length - 1; i++)
          if (cpf.charAt(i) != cpf.charAt(i + 1))
          {
              equal_digits = 0;
              break;
          }
      if (!equal_digits)
      {
          numbers = cpf.substring(0,9);
          digits = cpf.substring(9);
          sum = 0;
          for (i = 10; i > 1; i--)
              sum += numbers.charAt(10 - i) * i;
          result = sum % 11 < 2 ? 0 : 11 - sum % 11;
          if (result != digits.charAt(0))
              return false;
          numbers = cpf.substring(0,10);
          sum = 0;
          for (i = 11; i > 1; i--)
              sum += numbers.charAt(11 - i) * i;
          result = sum % 11 < 2 ? 0 : 11 - sum % 11;
          if (result != digits.charAt(1))
              return false;
          return true;
      }
      else
          return false;
  }
  
  function serialize(form) {
      if (!form || form.nodeName !== "FORM") {
          return;
      }
      var i, j, q = [];
      for (i = form.elements.length - 1; i >= 0; i = i - 1) {
          if (form.elements[i].name === "") {
              continue;
          }
          switch (form.elements[i].nodeName) {
              case 'INPUT':
                  switch (form.elements[i].type) {
                      case 'text':
                      case 'hidden':
                      case 'password':
                      case 'button':
                      case 'reset':
                      case 'submit':
                          q.push(form.elements[i].name + "=" + encodeURIComponent(form.elements[i].value));
                          break;
                      case 'checkbox':
                      case 'radio':
                          if (form.elements[i].checked) {
                              q.push(form.elements[i].name + "=" + encodeURIComponent(form.elements[i].value));
                          }
                          break;
                  }
                  break;
              case 'file':
                  break;
              case 'TEXTAREA':
                  q.push(form.elements[i].name + "=" + encodeURIComponent(form.elements[i].value));
                  break;
              case 'SELECT':
                  switch (form.elements[i].type) {
                      case 'select-one':
                          q.push(form.elements[i].name + "=" + encodeURIComponent(form.elements[i].value));
                          break;
                      case 'select-multiple':
                          for (j = form.elements[i].options.length - 1; j >= 0; j = j - 1) {
                              if (form.elements[i].options[j].selected) {
                                  q.push(form.elements[i].name + "=" + encodeURIComponent(form.elements[i].options[j].value));
                              }
                          }
                          break;
                  }
                  break;
              case 'BUTTON':
                  switch (form.elements[i].type) {
                      case 'reset':
                      case 'submit':
                      case 'button':
                          q.push(form.elements[i].name + "=" + encodeURIComponent(form.elements[i].value));
                          break;
                  }
                  break;
          }
      }
      return q.join("&");
  }
  
  function convertToSlug(str){
      str = str.replace(/^\s+|\s+$/g, ''); // trim
      str = str.toLowerCase();
  
      // remove accents, swap ñ for n, etc
      var from = "ãàáäâẽèéëêìíïîõòóöôùúüûñç·/_,:;";
      var to = "aaaaaeeeeeiiiiooooouuuunc------";
      for (var i = 0, l = from.length; i < l; i++) {
          str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
      }
  
      str = str.replace(/[^a-z0-9 -]/g, '') // remove invalid chars
          .replace(/\s+/g, '-') // collapse whitespace and replace by -
          .replace(/-+/g, '-'); // collapse dashes
  
      return str;
  }
  
  function validateForm(params){
      var el = params.el;
      var input = params.input;
      var validate = params.validate != undefined ? 0 : 1;
  
      el.validate({
          submitHandler: function(frm){
              var data = el.serialize();
              var action = el.attr('action');
              swal({
                  title: "Você realmente deseja atualizar os dados?",
                  type: "info",
                  showCancelButton: true,
                  cancelButtonText: "Cancelar",
                  confirmButtonColor: "#00a65a",
                  confirmButtonText: "Salvar",
                  closeOnConfirm: false,
                  showLoaderOnConfirm: true
              }, function () {
                  $.ajax({
                      url: action,
                      method: 'POST',
                      dataType: 'Json',
                      headers: {
                          'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                      },
                      data: data,
                      success: function (data) {
                          if(data == 'true')
                              swal("Atualizado!", "", "success");
                          else
                              swal("Oops...", "Something went wrong!", "error");
                      },
                      error: function(data){
                          swal("Oops...", "Something went wrong!", "error");
                      }
                  });
  
              });
          }
      });
  
      if(validate == 1) {
          //Implementando validações para os inputs do formulário
          input.each(function (item) {
              $(this).rules("add", {
                  required: true,
                  number: true,
                  minlength: 3,
                  min: 0,
                  messages: {
                      required: "Este campo é obrigatório",
                      number: "Informe somente números",
                      minlength: "Informe no mínimo 2 números com 1 casa decimal"
                  }
              });
          });
      }
  }
  
  function tests(param){
  
      var name = param.name != undefined ? param.name : '';
      var form = param.form;
      var btn = param.btn;
      var inputSelect = param.inputSelect;
      var classInputText = param.classInputText;
      var inputText = param.inputText;
      var row = param.row;
      var routeDestroy = param.route.destroy;
      var routeFind = param.route.find != undefined ? param.route.find : 'find_protocol';
  
      //Código para seleção de procolos
      inputSelect.select2().on('select2:select', function (e) {
          window.console.log(param);
          var args = e.params.data;
          $.ajax({
              method: 'GET',
              url: '/admin/tests/'+test_id+'/protocols/'+args.id+'/'+routeFind,
              success: function(data){
  
                      var result = '';
                      if (data.result != '') {
                          result = data.result;
                      }
  
                      var html = '<input type="hidden" name="protocol_' + data.id + '[id]" value="' + data.id + '">';
                      html += '<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 calculated" id="' + args.text.replace(' ', '_') + '" style="display: none;">';
                          html += '<div class="form-group">';
                              html += '<label for="protocol_' + name+'_'+data.id + '[result]">' + data.name +'</label><br>';
                              html += '<label for="protocol_' + name+'_'+data.id + '[result]">' + data.formula +'</label>';
                              html += '<div class="input-group">';
                                  html += '<input id="protocol_' + name+'_'+data.id + '[result]" value="' + result + '" name="protocol_' + data.id + '[result]" type="text" class="number ' + classInputText + ' form-control">';
                                  html += '<span class="input-group-addon" id="">'+data.measure+'</span>';
                              html += '</div>';
                          html += '</div>';
                          html += '<div class="form-group">';
                              html += '<label for="protocol_' + data.id + '[obs]">Observaçao</label>';
                              html += '<textarea id="protocol_' + data.id + '[obs]" name="protocol_' + data.id + '[obs]" class="textarea form-control"></textarea>';
                          html += '</div>';
                      html += '</div>';
  
  
                      html = $(html);
                      html.hide();
  
                      btn.fadeIn('slow').removeClass('desactive');
  
                      row.append(html);
  
                      html.find('.number').inputmask("decimal");
  
                      html.fadeIn('slow');
  
                      html.find('.textarea').wysihtml5({
                          toolbar: {
                              html: true
                          }
                      });
  
                      html.find('.' + classInputText).rules("add", {
                          required: true,
                          number: true,
                          minlength: true,
                          messages: {
                              required: "Este campo é obrigatório",
                              number: "Informe somente números",
                              minlength: "Informe no mínimo 3 números com casas decimais"
                          }
                      });
  
              },
              dataType: 'Json',
              headers: {
                  'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
              }
          });
  
      }).on('select2:unselect', function(e){
          var args = e.params.data;
          $.ajax({
              method: 'DELETE',
              url: '/admin/tests/'+test_id+'/protocols/'+args.id+'/'+routeDestroy,
              success: function(data) {
                  if(data == 'true'){
                      swal("Removido!", "", "success");
                  }
                  form.find('#'+args.text.replace(' ', '_')).fadeOut('slow').promise().done(function(){
                      $(this).remove();
                      var rows = form.find('.calculated').length;
                      if(rows == 0){
                          btn.fadeOut('slow').addClass('desactive');
                      }
                  });
              },
              dataType: 'Json',
              headers: {
                  'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
              }
          });
  
      });
  
      //Validação do formulário
      form.validate({
          submitHandler: function(frm){
              var data = serialize(frm);
              var action = form.attr('action');
              swal({
                  title: "Você realmente deseja atualizar os dados?",
                  type: "info",
                  showCancelButton: true,
                  cancelButtonText: "Cancelar",
                  confirmButtonColor: "#00a65a",
                  confirmButtonText: "Salvar",
                  closeOnConfirm: false,
                  showLoaderOnConfirm: true
              }, function () {
                  $.ajax({
                      url: action,
                      method: 'POST',
                      dataType: 'Json',
                      headers: {
                          'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                      },
                      data: data,
                      success: function (data) {
                          if(data == 'true')
                              swal("Atualizado!", "", "success");
                          else
                              swal("Oops...", "Something went wrong!", "error");
                      },
                      error: function(data){
                          swal("Oops...", "Something went wrong!", "error");
                      }
                  });
  
              });
          }
      });
  
  
      //Implementando validações para os inputs do formulário
      inputText.each(function (item) {
          $(this).rules("add", {
              required: true,
              number: true,
              minlength: 1,
              messages: {
                  required: "Este campo é obrigatório",
                  number: "Informe somente números",
                  minlength: "Informe no mínimo 1 número"
              }
          });
  
          $(this).inputmask("decimal", {
              "placeholder": ""
          });
      });
  
  }
  
  /*function executeAjax(params){
      var url = params.url;
      var dataType = params.dataType != undefined ? params.dataType : '';
      var headers = params.headers;
      var method = params.method;
      var callbackSuccess = params.success;
  
      $.ajax({
          url: url,
          dataType: dataType,
          data: $(this).serialize(),
          success: callbackSuccess,
          method: method,
          headers: headers
      });
  }*/
  
  function openModalWithFields(params){
      var routeBlade = params.routeBlade;
      var inputClass = params.inputClass;
      //Ativo o modal ajax
      $('#ajaxLoader').modal('toggle');
      //Requisição para retornar a blade
      $.ajax({
          url: routeBlade,
          method: 'GET',
          success: function (data) {
              //Escondo o modal ajax
              $('#ajaxLoader').modal('hide');
              //Transformando a blade em objeto jquery
              data = $(data);
              //Adicionando o modal ao body
              $("body").append(data);
              //Ativando o modal
              $(data).modal('toggle');
              //Formulário do modal
              var form = data.find('form');
              //Validação do formulário
              form.validate({
                  submitHandler: function(frm){
                      var data = form.serialize();
                      var action = form.attr('action');
                      swal({
                          title: "Você realmente deseja atualizar os dados?",
                          type: "info",
                          showCancelButton: true,
                          cancelButtonText: "Cancelar",
                          confirmButtonColor: "#00a65a",
                          confirmButtonText: "Salvar",
                          closeOnConfirm: false,
                          showLoaderOnConfirm: true
                      }, function () {
                          $.ajax({
                              url: action,
                              method: 'POST',
                              dataType: 'Json',
                              headers: {
                                  'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                              },
                              data: data,
                              success: function (data) {
                                  if(data == 'true')
                                      swal("Atualizado!", "", "success");
                                  else
                                      swal("Oops...", "Something went wrong!", "error");
                              },
                              error: function(data){
                                  swal("Oops...", "Something went wrong!", "error");
                              }
                          });
  
                      });
                  }
              });
  
              //Evento disparado ao esconder o modal
              $(data).on('hidden.bs.modal', function (e) {
                  $(this).remove();
                  form.unbind("submit");
              });
  
              //Adicionando validações e máscaras aos fields do formulário
              form.find('.'+inputClass).each(function(){
                  $(this).rules("add", {
                      required: true,
                      number: true,
                      minlength: 1,
                      messages: {
                          required: "Este campo é obrigatório",
                          number: "Informe somente números",
                          minlength: "Informe no mínimo 1"
                      }
                  });
  
                  $(this).inputmask("decimal", {
                      "placeholder": ""
                  });
              });
  
          },
          headers: {
              'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
          }
      });
  }
  
  $(function () {
  
      var App = function(){
          this.init();
      };
  
      App.prototype.init = function(){
          this._tooltip();
          this._buttonDelete();
      };
  
      App.prototype._tooltip = function(){
          $('[data-toggle="tooltip"]').css({
              'cursor': 'pointer'
          }).tooltip();
      }
  
      App.prototype._buttonDelete = function(){
          $('[data-method]').append(function(){
              var method;
              if($(this).attr('data-method') != undefined || $(this).attr('data-method') != ""){
                  method = $(this).attr('data-method');
              }else{
                  method = "POST";
              }
              var typeAlert = $(this).attr('data-alert');
              var message = $(this).attr('data-message');
              var name = null;
              switch (typeAlert) {
                  case 'send_email':
                      name = "send_email";
                      break;
                  case 'released_for_certification':
                      name = "released_for_certification";
                      break;
                  default:
                      name = "delete_item";
                      break;
              }
              return "\n" +
                  "<form action='" + $(this).attr('href') + "' method='POST' data-message='" + message + "' name='" + name + "' style='display:none'>\n" +
                  "   <input type='hidden' name='_method' value='" + $(this).attr('data-method') + "'>\n" +
                  "   <input type='hidden' name='_token' value='" + $('meta[name="_token"]').attr('content') + "'>\n" +
                  "</form>\n"
          })
          .removeAttr('href')
          .attr('style', 'cursor:pointer;')
          .attr('onclick', '$(this).find("form").submit();');
          /*
              Generic are you sure dialog
           */
          $('form[name=delete_item]').submit(function () {
              return confirm("Tem certeza que deseja excluir esse item?");
          });
      }
  
      //Método para validar o CPF
      $.validator.addMethod("isCPF", function(value, element) {
          return validateCPF(value);
      });
  
      //Desabilitando todos os elementos com a classe desactive
      $('.desactive').hide();
  
      $(".title-has-slug").on('keyup', function () {
          var slug = convertToSlug(this.value);
          $(".slug-from-title").val(slug);
      });
  
      /*$('.number2').inputmask("regex", {
          regex: "/\-|\d/"
      });*/
  
      $('.number').inputmask("decimal");
  
      $('.decimal').inputmask("decimal");
  
      $(".money-br").maskMoney({
          thousands: '.',
          decimal: ',',
          affixesStay: false,
          allowZero: true,
          prefix: 'R$ ',
      });
  
      $('.textarea').css({
          'width': '100%'
      });
  
      //Initialize Select2 Elements
      $(".select2").select2();
  
      //Initialize Select2 Elements
      $(".select2-tags").select2({
          tags: true
      });
  
      $(".textarea").wysihtml5({
          toolbar: {
              html: true
          }
      });
  
      //Datemask dd/mm/yyyy
      $("#datemask").inputmask("dd/mm/yyyy", {"placeholder": "dd/mm/yyyy"});
  
  
      $(".rg").inputmask("99.999.999-99", {"placeholder": ""});
      $(".cpf").inputmask("999.999.999-99", {"placeholder": ""});
  
      $(".phone").inputmask("(99) 9999-9999", {"placeholder": ""});
      $(".cell_phone").inputmask("(99) [9]9999-9999");
  
  
  
  
      $(".birth_date").inputmask("dd/mm/yyyy", {"placeholder": "dd/mm/yyyy"});
  
      //Datemask2 mm/dd/yyyy
      $("#datemask2").inputmask("mm/dd/yyyy", {"placeholder": "mm/dd/yyyy"});
      //Money Euro
      $("[data-mask]").inputmask();
  
      $('.cm').inputmask("[9][9]9.99", {
          "placeholder": ""
      });
  
      //Date range picker
      $('#reservation').daterangepicker();
      //Date range picker with time picker
      $('#reservationtime').daterangepicker({timePicker: true, timePickerIncrement: 30, format: 'MM/DD/YYYY h:mm A'});
      //Date range as a button
      $('#daterange-btn').daterangepicker({
          ranges: {
              'Today': [moment(), moment()],
              'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
              'Last 7 Days': [moment().subtract(6, 'days'), moment()],
              'Last 30 Days': [moment().subtract(29, 'days'), moment()],
              'This Month': [moment().startOf('month'), moment().endOf('month')],
              'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
          },
          startDate: moment().subtract(29, 'days'),
          endDate: moment()
      },
          function (start, end) {
              $('#daterange-btn span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
      });
  
      $.fn.datepicker.dates['pt-br'] = {
          days: ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado"],
          daysShort: ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"],
          daysMin: ["Do", "Se", "Te", "Qua", "Qui", "Se", "Sa"],
          months: ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"],
          monthsShort: ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"],
          today: "Hoje",
          clear: "Limpar",
          format: "dd/mm/yyyy",
          titleFormat: "MM yyyy", /* Leverages same syntax as 'format' */
          weekStart: 0
      };
  
      //Date picker
      $('.datepicker').datepicker({
          language: 'pt-br'
      });
  
      //iCheck for checkbox and radio inputs
      $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
          checkboxClass: 'icheckbox_minimal-blue',
          radioClass: 'iradio_minimal-blue'
      }).on('ifChanged', function(e) {
          // Get the field name
          //var field = $(this).attr('name');
          //alert(field);
      });
  
      //Red color scheme for iCheck
      $('input[type="checkbox"].minimal-red, input[type="radio"].minimal-red').iCheck({
          checkboxClass: 'icheckbox_minimal-red',
          radioClass: 'iradio_minimal-red'
      });
      //Flat red color scheme for iCheck
      $('input[type="checkbox"].flat-red, input[type="radio"].flat-red').iCheck({
          checkboxClass: 'icheckbox_flat-green',
          radioClass: 'iradio_flat-green'
      }).on('ifClicked', function(e) {
          // Get the field name
          var field = $(this);
          if(field.attr('class').indexOf('answer-yes-click') >= 0){
              window.console.log(field.parent().parent().parent());
              field.parent().parent().parent().find('.answer-yes').css({
                  'display': 'block'
              });
          }else{
              field.parent().parent().parent().find('.answer-yes').css({
                  'display': 'none'
              });
          }
      });
  
      //Flat red color scheme for iCheck
      $('#check-all').iCheck({
          checkboxClass: 'icheckbox_flat-green',
          radioClass: 'iradio_flat-green'
      }).on('ifChanged', function(e){
          const field = $(this)[0];        
          if(field.checked){
              $('.permissions input[type="checkbox"].flat-red, input[type="radio"].flat-red').each(function(i, val){
                  $(this)[0].checked = true;
              });
          }else{
              $('.permissions input[type="checkbox"].flat-red, input[type="radio"].flat-red').each(function(i, val){
                  $(this)[0].checked = false;
              });
          }
          $('.permissions input[type="checkbox"].flat-red, input[type="radio"].flat-red').iCheck('update');
      });
  
      //Colorpicker
      $(".my-colorpicker1").colorpicker();
      //color picker with addon
      $(".my-colorpicker2").colorpicker();
  
      //Timepicker
      $(".timepicker").timepicker({
          //showInputs: false,
          showMeridian: false,
          disableFocus: true
      });
  
      $.fn.dataTable.ext.errMode = 'none';
  
  
      /*$('[data-method]').append(function(){
          var method;
          if($(this).attr('data-method') != undefined || $(this).attr('data-method') != ""){
              method = $(this).attr('data-method');
          }else{
              method = "POST";
          }
          var typeAlert = $(this).attr('data-alert');
          var message = $(this).attr('data-message');
          var name = null;
          switch (typeAlert) {
              case 'send_email':
                  name = "send_email";
                  break;
              case 'released_for_certification':
                  name = "released_for_certification";
                  break;
              default:
                  name = "delete_item";
                  break;
          }
          return "\n" +
              "<form action='" + $(this).attr('href') + "' method='POST' data-message='" + message + "' name='" + name + "' style='display:none'>\n" +
              "   <input type='hidden' name='_method' value='" + $(this).attr('data-method') + "'>\n" +
              "   <input type='hidden' name='_token' value='" + $('meta[name="_token"]').attr('content') + "'>\n" +
              "</form>\n"
      })
      .removeAttr('href')
      .attr('style', 'cursor:pointer;')
      .attr('onclick', '$(this).find("form").submit();');
  
  
       Generic are you sure dialog
  
      $('form[name=delete_item]').submit(function () {
          return confirm("Tem certeza que deseja excluir esse item?");
      });*/
  
      
      $('.answer-yes').css({
          'display': 'none'
      });
  
      $('.editor-active').css({
          'display': 'block'
      });
  
      var table = $('.data-table').DataTable({
          rowReorder: {
              selector: 'td:nth-child(2)'
          },
          paging: false,
          lengthChange: false,
          searching: true,
          ordering: true,
          info: false,
          lengthMenu: [10, 20, 50],
          autoWidth: true,
          responsive: true,
          scroll: true,
          scrollX: true,
          scrollCollapse: true,
          language: {
              search: "Pesquisar",
              zeroRecords: "Não foram encontrados registros",
              processing: "Processando...",
              thousands: ",",
              lengthMenu: "Listando _MENU_ registros",
              emptyTable: "Não há registros disponíveis",
              info: false
          }
      });
  
  
      $('body').on('click', '.pagination a', function(e) {
          var elementToBeUpdate = $('.content-to-be-update');
          var btn = $(this);
          e.preventDefault();
          $.ajax({
              method: 'get',
              url: btn.attr('href'),
              data: {},
              beforeSend: function(){
                  elementToBeUpdate.append('<img style="position: absolute; left: 0; top: 0; z-index: 100000;" src="/img/loading2.gif" />');
              },
              success: function(data){
                  elementToBeUpdate.html(data);
                  elementToBeUpdate.find('table.data-table').DataTable({
                      paging: false,
                      info: false,
                      autoWidth: true,
                      responsive: true,
                      scroll: true,
                      scrollX: true,
                      scrollCollapse: true,
                      language: {
                          search: "Pesquisar",
                          zeroRecords: "Não foram encontrados registros",
                          processing: "Processando...",
                          thousands: ",",
                          lengthMenu: "Listando _MENU_ registros",
                          emptyTable: "Não há registros disponíveis",
                          info: ''
                      }
                  });
                  console.log(btn);
                  window.history.pushState("", "", btn.attr('href'));
              },
              error: function(error){
  
              }
          });
      });
  
      function getData(url){
          
      }
  
      /*var table = $('.data-table').DataTable({
          rowReorder: {
              selector: 'td:nth-child(2)'
          },
          paging: true,
          lengthChange: true,
          searching: true,
          ordering: true,
          info: true,
          lengthMenu: [10, 20, 50],
          autoWidth: true,
          responsive: true,
          scroll: true,
          scrollX: true,
          scrollCollapse: true,
          language: {
              search: "Pesquisar",
              paginate: {
                  first: "Primeiro",
                  last: "Último",
                  next: "Próximo",
                  previous: "Anterior"
              },
              zeroRecords: "Não foram encontrados registros",
              processing: "Processando...",
              thousands: ",",
              lengthMenu: "Listando _MENU_ registros",
              emptyTable: "Não há registros disponíveis",
              info: "Mostrando de _START_ até _END_ no total de _TOTAL_ registros"
          }
      });*/
  
      function submitFormWithSweetAlertAndAjax(id){
          form = $('#'+id);
          form.submit(function(e){
              e.preventDefault();
              var form = $(this);
              swal({
                  title: "Você realmente deseja atualizar os dados?",
                  type: "info",
                  cancelButtonText: "Cancelar",
                  showCancelButton: true,
                  confirmButtonColor: "#00a65a",
                  confirmButtonText: "Salvar",
                  closeOnConfirm: false,
                  showLoaderOnConfirm: true,
              },function(){
                  $.ajax({
                      url: form.attr('action'),
                      method: 'POST',
                      dataType: 'Json',
                      headers: {
                          'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                      },
                      data: form.serialize(),
                      success: function(data){
                          window.console.log(data);
                          swal("Atualizado!", "", "success");
                      }
                  });
              });
          });
      }
  
      submitFormWithSweetAlertAndAjax('update_weight_and_height');
      submitFormWithSweetAlertAndAjax('update_perimetros_circunferencias');
      submitFormWithSweetAlertAndAjax('update_bioempedancia');
      submitFormWithSweetAlertAndAjax('update_parq');
      submitFormWithSweetAlertAndAjax('update_pregras_cutaneas');
      submitFormWithSweetAlertAndAjax('update_riscos_coronarios');
  
      /**
       * Função para fazer submit de formulário com AJAX
       * @param id
       * @param form_id
       */
      function updateFormForBtn(id, form_id){
          var el = document.getElementById(id);
          if(el == undefined || el == null){
              return false;
          }
          document.getElementById(id).addEventListener('click', function(){
              swal({
                  title: "Você realmente deseja atualizar os dados?",
                  type: "info",
                  showCancelButton: true,
                  cancelButtonText: "Cancelar",
                  confirmButtonColor: "#00a65a",
                  confirmButtonText: "Salvar",
                  closeOnConfirm: false,
                  showLoaderOnConfirm: true,
              }, function () {
                  var formElement = $('#'+form_id);
                  formElement.ajaxForm({
                      url: $(this).attr('action'),
                      type: "POST",
                      headers: {
                          'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                      },
                      uploadProgress: function(event, position, total, percentComplete){
                      },
                      beforeSend: function(){
                      },
                      success: function(data){
                          window.console.log(data);
                          swal("Atualizado!", "", "success");
                      },
                      resetForm: true,
                      dataType: 'Json'
                  }).submit();
              });
          }, false);
      }
  
      //Form Análise Postural Anterior
      updateFormForBtn(
          'btn_update_analise_postural_anterior',
          'update_analise_postural_anterior'
      );
      //Form Análise Postural Lateral Esquerda
      updateFormForBtn(
          'btn_update_analise_postural_lateral_esquerda',
          'update_analise_postural_lateral_esquerda'
      );
      //Form Análise Postural Lateral Direita
      updateFormForBtn(
          'btn_update_analise_postural_lateral_direita',
          'update_analise_postural_lateral_direita'
      );
      //Form Análise Postural Posterior
      updateFormForBtn(
          'btn_update_analise_postural_posterior',
          'update_analise_postural_posterior'
      );
  
  
      function sendImg(element, frm, tab){
          var el = document.querySelector(element);
          if(el == undefined || el == null){
              return ;
          }
          var file;
          var form = $(frm);
          var action = form.attr('action');
          var tabElement = $(tab);
  
          el.addEventListener('change', function(evt){
              file = this.files[0];
              form.ajaxForm({
                  url: action,
                  type: "POST",
                  headers: {
                      'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                  },
                  beforeSend: function(){
                      tabElement.find('input[type="submit"]').hide();
                      tabElement.find('img.desactive').show();
                  },
                  success: function(data){
                      tabElement.find('input[type="submit"]').show();
                      tabElement.find('img.desactive').hide();
                      form.find('#img-reader').show();
                      tabElement.find('input[name="uploaded_image"]').val('1');
                  },
                  resetForm: true,
                  dataType: 'Json'
              }).submit();
              //Fazendo upload da imagem para o navegador
  
              if(window.FileReader){
                  if(file.type.indexOf('image') >= 0){
                      var reader = new FileReader();
                      reader.onprogress = function(evt){
                      };
                      reader.onloadend = function(e){
                          form.find('#visualizar').find('#img-reader').attr('src', e.target.result);
                      };
                      reader.readAsDataURL(file);
                  }
              }
          }, false);
      }
  
      sendImg(
          '#btn_img_analise_postural_anterior',
          '#send_img_analise_postural_anterior',
          '#tab_analise_postural_anterior'
      );
      sendImg(
          '#btn_img_analise_postural_lateral_esquerda',
          '#send_img_analise_postural_lateral_esquerda',
          '#tab_analise_postural_lateral_esquerda'
      );
      sendImg(
          '#btn_img_analise_postural_lateral_direita',
          '#send_img_analise_postural_lateral_direita',
          '#tab_analise_postural_lateral_direita'
      );
      sendImg(
          '#btn_img_analise_postural_posterior',
          '#send_img_analise_postural_posterior',
          '#tab_analise_postural_posterior'
      );
  
  
      /**
       * Created by Junnyor on 03/08/2017.
       */
  
  
  
      /*var el = document.getElementById('save-frequencia-cardiaca-maxima');
      if(el != undefined || el != null) {
          el.addEventListener('submit', function (e) {
              e.preventDefault();
              var data = serialize(this);
              var action = document.querySelector('#' + this.getAttribute('id')).getAttribute('action');
              swal({
                  title: "Você realmente deseja atualizar os dados?",
                  type: "info",
                  showCancelButton: true,
                  cancelButtonText: "Cancelar",
                  confirmButtonColor: "#00a65a",
                  confirmButtonText: "Salvar",
                  closeOnConfirm: false,
                  showLoaderOnConfirm: true
              }, function () {
                  $.ajax({
                      url: action,
                      method: 'POST',
                      dataType: 'Json',
                      headers: {
                          'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                      },
                      data: data,
                      success: function (data) {
                          if(data == 'true')
                              swal("Atualizado!", "", "success");
                          else
                              swal("Oops...", "Something went wrong!", "error");
                      },
                      error: function(data){
                          swal("Oops...", "Something went wrong!", "error");
                      }
                  });
  
              });
          }, false);
      }*/
      window.App = new App;
  });