/* Minification failed. Returning unminified contents.
(631,53-54): run-time error JS1100: Expected ',': =
(805,11-19): run-time error JS1004: Expected ';': function
(1043,41-42): run-time error JS1006: Expected ')': {
(1043,70-71): run-time error JS1195: Expected expression: =
(1043,74-75): run-time error JS1195: Expected expression: )
(1043,75-76): run-time error JS1004: Expected ';': {
(1116,22-23): run-time error JS1014: Invalid character: `
(1116,30-31): run-time error JS1193: Expected ',' or ')': {
(1116,40-41): run-time error JS1195: Expected expression: )
(1116,57-58): run-time error JS1014: Invalid character: `
(1116,58-59): run-time error JS1195: Expected expression: )
(1132,34-35): run-time error JS1195: Expected expression: >
(1204,3-4): run-time error JS1195: Expected expression: )
(1204,4-5): run-time error JS1004: Expected ';': )
(1164,5,1203,6): run-time error JS1018: 'return' statement outside of function: return {
        readonly: initializeReadOnly,
        checkToggle: checkBoxToggle,
        checkDefault: checkBoxToggleWithDefault,
        checkOpposite: checkBoxToggleWithOpposite,
        dropDown: dropDownToggle,
        escape: escapeHtml,
        escapeJson: escapeJson,
        jsEscape: jsEscape,
        allChecked: toggleAllChecked,
        confirm: confirmModal,
        ConfirmOK: confirmModalOK,
        confirminfo: confirmInfoModal,
        confirminfos: confirmInfoModals,
        edgegwModal: edgegwModal,
        error: alertError,
        modelState: parseModelState,
        jsonError: errorJson,
        modal: modalError,
        getValue: getValueWithDefault,
        limitCheckbox: checkBoxLimiter,
        selectErrorPanel: selectErrorPanel,
        int: isInt,
        date: formatDate,
        ticks: getTicks,
        submitFormWithCheck: submitFormWithModifiedCheck,
        confirmSubmitFormWithCheck: confirmSubmitFormWithModifiedCheck,
        submitEdgegwFormWithModifiedCheck: submitEdgegwFormWithModifiedCheck,
        hashPassword: getWpaPskKeyFromPassphrase,
        optionModalTimePicker: optionModalTimePicker,
        getRunningTaskStatus: getRunningTaskStatus,
        showEdgeGatewayModalPopup: showEdgeGatewayModalPopup,
        generateAntiForgeryHeaders: generateAntiForgeryHeaders,
        ajaxSetup: ajaxSetup,
        checkRedirectErrorResponse: checkRedirectErrorResponse,
        timerUpdateJwt: timerUpdateJwt,
        setBrowserLocation: setBrowserLocation,
        displayCeErrorResponse: displayCeErrorResponse,
        debounce: debounce
    }
(1068,9-21): run-time error JS1018: 'return' statement outside of function: return false
(1066,13-24): run-time error JS1018: 'return' statement outside of function: return true
(1059,13-24): run-time error JS1018: 'return' statement outside of function: return true
 */
/*!
  * Bootstrap v4.0.0 (https://getbootstrap.com)
  * Copyright 2011-2018 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("jquery"),require("popper.js")):"function"==typeof define&&define.amd?define(["exports","jquery","popper.js"],e):e(t.bootstrap={},t.jQuery,t.Popper)}(this,function(t,e,n){"use strict";function i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function s(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t}function r(){return(r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}e=e&&e.hasOwnProperty("default")?e.default:e,n=n&&n.hasOwnProperty("default")?n.default:n;var o,a,l,h,c,u,f,d,_,g,p,m,v,E,T,y,C,I,A,b,D,S,w,N,O,k,P=function(t){var e=!1;function n(e){var n=this,s=!1;return t(this).one(i.TRANSITION_END,function(){s=!0}),setTimeout(function(){s||i.triggerTransitionEnd(n)},e),this}var i={TRANSITION_END:"bsTransitionEnd",getUID:function(t){do{t+=~~(1e6*Math.random())}while(document.getElementById(t));return t},getSelectorFromElement:function(e){var n,i=e.getAttribute("data-target");i&&"#"!==i||(i=e.getAttribute("href")||""),"#"===i.charAt(0)&&(n=i,i=n="function"==typeof t.escapeSelector?t.escapeSelector(n).substr(1):n.replace(/(:|\.|\[|\]|,|=|@)/g,"\\$1"));try{return t(document).find(i).length>0?i:null}catch(t){return null}},reflow:function(t){return t.offsetHeight},triggerTransitionEnd:function(n){t(n).trigger(e.end)},supportsTransitionEnd:function(){return Boolean(e)},isElement:function(t){return(t[0]||t).nodeType},typeCheckConfig:function(t,e,n){for(var s in n)if(Object.prototype.hasOwnProperty.call(n,s)){var r=n[s],o=e[s],a=o&&i.isElement(o)?"element":(l=o,{}.toString.call(l).match(/\s([a-zA-Z]+)/)[1].toLowerCase());if(!new RegExp(r).test(a))throw new Error(t.toUpperCase()+': Option "'+s+'" provided type "'+a+'" but expected type "'+r+'".')}var l}};return e=("undefined"==typeof window||!window.QUnit)&&{end:"transitionend"},t.fn.emulateTransitionEnd=n,i.supportsTransitionEnd()&&(t.event.special[i.TRANSITION_END]={bindType:e.end,delegateType:e.end,handle:function(e){if(t(e.target).is(this))return e.handleObj.handler.apply(this,arguments)}}),i}(e),L=(a="alert",h="."+(l="bs.alert"),c=(o=e).fn[a],u={CLOSE:"close"+h,CLOSED:"closed"+h,CLICK_DATA_API:"click"+h+".data-api"},f="alert",d="fade",_="show",g=function(){function t(t){this._element=t}var e=t.prototype;return e.close=function(t){t=t||this._element;var e=this._getRootElement(t);this._triggerCloseEvent(e).isDefaultPrevented()||this._removeElement(e)},e.dispose=function(){o.removeData(this._element,l),this._element=null},e._getRootElement=function(t){var e=P.getSelectorFromElement(t),n=!1;return e&&(n=o(e)[0]),n||(n=o(t).closest("."+f)[0]),n},e._triggerCloseEvent=function(t){var e=o.Event(u.CLOSE);return o(t).trigger(e),e},e._removeElement=function(t){var e=this;o(t).removeClass(_),P.supportsTransitionEnd()&&o(t).hasClass(d)?o(t).one(P.TRANSITION_END,function(n){return e._destroyElement(t,n)}).emulateTransitionEnd(150):this._destroyElement(t)},e._destroyElement=function(t){o(t).detach().trigger(u.CLOSED).remove()},t._jQueryInterface=function(e){return this.each(function(){var n=o(this),i=n.data(l);i||(i=new t(this),n.data(l,i)),"close"===e&&i[e](this)})},t._handleDismiss=function(t){return function(e){e&&e.preventDefault(),t.close(this)}},s(t,null,[{key:"VERSION",get:function(){return"4.0.0"}}]),t}(),o(document).on(u.CLICK_DATA_API,'[data-dismiss="alert"]',g._handleDismiss(new g)),o.fn[a]=g._jQueryInterface,o.fn[a].Constructor=g,o.fn[a].noConflict=function(){return o.fn[a]=c,g._jQueryInterface},g),R=(m="button",E="."+(v="bs.button"),T=".data-api",y=(p=e).fn[m],C="active",I="btn",A="focus",b='[data-toggle^="button"]',D='[data-toggle="buttons"]',S="input",w=".active",N=".btn",O={CLICK_DATA_API:"click"+E+T,FOCUS_BLUR_DATA_API:"focus"+E+T+" blur"+E+T},k=function(){function t(t){this._element=t}var e=t.prototype;return e.toggle=function(){var t=!0,e=!0,n=p(this._element).closest(D)[0];if(n){var i=p(this._element).find(S)[0];if(i){if("radio"===i.type)if(i.checked&&p(this._element).hasClass(C))t=!1;else{var s=p(n).find(w)[0];s&&p(s).removeClass(C)}if(t){if(i.hasAttribute("disabled")||n.hasAttribute("disabled")||i.classList.contains("disabled")||n.classList.contains("disabled"))return;i.checked=!p(this._element).hasClass(C),p(i).trigger("change")}i.focus(),e=!1}}e&&this._element.setAttribute("aria-pressed",!p(this._element).hasClass(C)),t&&p(this._element).toggleClass(C)},e.dispose=function(){p.removeData(this._element,v),this._element=null},t._jQueryInterface=function(e){return this.each(function(){var n=p(this).data(v);n||(n=new t(this),p(this).data(v,n)),"toggle"===e&&n[e]()})},s(t,null,[{key:"VERSION",get:function(){return"4.0.0"}}]),t}(),p(document).on(O.CLICK_DATA_API,b,function(t){t.preventDefault();var e=t.target;p(e).hasClass(I)||(e=p(e).closest(N)),k._jQueryInterface.call(p(e),"toggle")}).on(O.FOCUS_BLUR_DATA_API,b,function(t){var e=p(t.target).closest(N)[0];p(e).toggleClass(A,/^focus(in)?$/.test(t.type))}),p.fn[m]=k._jQueryInterface,p.fn[m].Constructor=k,p.fn[m].noConflict=function(){return p.fn[m]=y,k._jQueryInterface},k),j=function(t){var e="carousel",n="bs.carousel",i="."+n,o=t.fn[e],a={interval:5e3,keyboard:!0,slide:!1,pause:"hover",wrap:!0},l={interval:"(number|boolean)",keyboard:"boolean",slide:"(boolean|string)",pause:"(string|boolean)",wrap:"boolean"},h="next",c="prev",u="left",f="right",d={SLIDE:"slide"+i,SLID:"slid"+i,KEYDOWN:"keydown"+i,MOUSEENTER:"mouseenter"+i,MOUSELEAVE:"mouseleave"+i,TOUCHEND:"touchend"+i,LOAD_DATA_API:"load"+i+".data-api",CLICK_DATA_API:"click"+i+".data-api"},_="carousel",g="active",p="slide",m="carousel-item-right",v="carousel-item-left",E="carousel-item-next",T="carousel-item-prev",y={ACTIVE:".active",ACTIVE_ITEM:".active.carousel-item",ITEM:".carousel-item",NEXT_PREV:".carousel-item-next, .carousel-item-prev",INDICATORS:".carousel-indicators",DATA_SLIDE:"[data-slide], [data-slide-to]",DATA_RIDE:'[data-ride="carousel"]'},C=function(){function o(e,n){this._items=null,this._interval=null,this._activeElement=null,this._isPaused=!1,this._isSliding=!1,this.touchTimeout=null,this._config=this._getConfig(n),this._element=t(e)[0],this._indicatorsElement=t(this._element).find(y.INDICATORS)[0],this._addEventListeners()}var C=o.prototype;return C.next=function(){this._isSliding||this._slide(h)},C.nextWhenVisible=function(){!document.hidden&&t(this._element).is(":visible")&&"hidden"!==t(this._element).css("visibility")&&this.next()},C.prev=function(){this._isSliding||this._slide(c)},C.pause=function(e){e||(this._isPaused=!0),t(this._element).find(y.NEXT_PREV)[0]&&P.supportsTransitionEnd()&&(P.triggerTransitionEnd(this._element),this.cycle(!0)),clearInterval(this._interval),this._interval=null},C.cycle=function(t){t||(this._isPaused=!1),this._interval&&(clearInterval(this._interval),this._interval=null),this._config.interval&&!this._isPaused&&(this._interval=setInterval((document.visibilityState?this.nextWhenVisible:this.next).bind(this),this._config.interval))},C.to=function(e){var n=this;this._activeElement=t(this._element).find(y.ACTIVE_ITEM)[0];var i=this._getItemIndex(this._activeElement);if(!(e>this._items.length-1||e<0))if(this._isSliding)t(this._element).one(d.SLID,function(){return n.to(e)});else{if(i===e)return this.pause(),void this.cycle();var s=e>i?h:c;this._slide(s,this._items[e])}},C.dispose=function(){t(this._element).off(i),t.removeData(this._element,n),this._items=null,this._config=null,this._element=null,this._interval=null,this._isPaused=null,this._isSliding=null,this._activeElement=null,this._indicatorsElement=null},C._getConfig=function(t){return t=r({},a,t),P.typeCheckConfig(e,t,l),t},C._addEventListeners=function(){var e=this;this._config.keyboard&&t(this._element).on(d.KEYDOWN,function(t){return e._keydown(t)}),"hover"===this._config.pause&&(t(this._element).on(d.MOUSEENTER,function(t){return e.pause(t)}).on(d.MOUSELEAVE,function(t){return e.cycle(t)}),"ontouchstart"in document.documentElement&&t(this._element).on(d.TOUCHEND,function(){e.pause(),e.touchTimeout&&clearTimeout(e.touchTimeout),e.touchTimeout=setTimeout(function(t){return e.cycle(t)},500+e._config.interval)}))},C._keydown=function(t){if(!/input|textarea/i.test(t.target.tagName))switch(t.which){case 37:t.preventDefault(),this.prev();break;case 39:t.preventDefault(),this.next()}},C._getItemIndex=function(e){return this._items=t.makeArray(t(e).parent().find(y.ITEM)),this._items.indexOf(e)},C._getItemByDirection=function(t,e){var n=t===h,i=t===c,s=this._getItemIndex(e),r=this._items.length-1;if((i&&0===s||n&&s===r)&&!this._config.wrap)return e;var o=(s+(t===c?-1:1))%this._items.length;return-1===o?this._items[this._items.length-1]:this._items[o]},C._triggerSlideEvent=function(e,n){var i=this._getItemIndex(e),s=this._getItemIndex(t(this._element).find(y.ACTIVE_ITEM)[0]),r=t.Event(d.SLIDE,{relatedTarget:e,direction:n,from:s,to:i});return t(this._element).trigger(r),r},C._setActiveIndicatorElement=function(e){if(this._indicatorsElement){t(this._indicatorsElement).find(y.ACTIVE).removeClass(g);var n=this._indicatorsElement.children[this._getItemIndex(e)];n&&t(n).addClass(g)}},C._slide=function(e,n){var i,s,r,o=this,a=t(this._element).find(y.ACTIVE_ITEM)[0],l=this._getItemIndex(a),c=n||a&&this._getItemByDirection(e,a),_=this._getItemIndex(c),C=Boolean(this._interval);if(e===h?(i=v,s=E,r=u):(i=m,s=T,r=f),c&&t(c).hasClass(g))this._isSliding=!1;else if(!this._triggerSlideEvent(c,r).isDefaultPrevented()&&a&&c){this._isSliding=!0,C&&this.pause(),this._setActiveIndicatorElement(c);var I=t.Event(d.SLID,{relatedTarget:c,direction:r,from:l,to:_});P.supportsTransitionEnd()&&t(this._element).hasClass(p)?(t(c).addClass(s),P.reflow(c),t(a).addClass(i),t(c).addClass(i),t(a).one(P.TRANSITION_END,function(){t(c).removeClass(i+" "+s).addClass(g),t(a).removeClass(g+" "+s+" "+i),o._isSliding=!1,setTimeout(function(){return t(o._element).trigger(I)},0)}).emulateTransitionEnd(600)):(t(a).removeClass(g),t(c).addClass(g),this._isSliding=!1,t(this._element).trigger(I)),C&&this.cycle()}},o._jQueryInterface=function(e){return this.each(function(){var i=t(this).data(n),s=r({},a,t(this).data());"object"==typeof e&&(s=r({},s,e));var l="string"==typeof e?e:s.slide;if(i||(i=new o(this,s),t(this).data(n,i)),"number"==typeof e)i.to(e);else if("string"==typeof l){if("undefined"==typeof i[l])throw new TypeError('No method named "'+l+'"');i[l]()}else s.interval&&(i.pause(),i.cycle())})},o._dataApiClickHandler=function(e){var i=P.getSelectorFromElement(this);if(i){var s=t(i)[0];if(s&&t(s).hasClass(_)){var a=r({},t(s).data(),t(this).data()),l=this.getAttribute("data-slide-to");l&&(a.interval=!1),o._jQueryInterface.call(t(s),a),l&&t(s).data(n).to(l),e.preventDefault()}}},s(o,null,[{key:"VERSION",get:function(){return"4.0.0"}},{key:"Default",get:function(){return a}}]),o}();return t(document).on(d.CLICK_DATA_API,y.DATA_SLIDE,C._dataApiClickHandler),t(window).on(d.LOAD_DATA_API,function(){t(y.DATA_RIDE).each(function(){var e=t(this);C._jQueryInterface.call(e,e.data())})}),t.fn[e]=C._jQueryInterface,t.fn[e].Constructor=C,t.fn[e].noConflict=function(){return t.fn[e]=o,C._jQueryInterface},C}(e),H=function(t){var e="collapse",n="bs.collapse",i="."+n,o=t.fn[e],a={toggle:!0,parent:""},l={toggle:"boolean",parent:"(string|element)"},h={SHOW:"show"+i,SHOWN:"shown"+i,HIDE:"hide"+i,HIDDEN:"hidden"+i,CLICK_DATA_API:"click"+i+".data-api"},c="show",u="collapse",f="collapsing",d="collapsed",_="width",g="height",p={ACTIVES:".show, .collapsing",DATA_TOGGLE:'[data-toggle="collapse"]'},m=function(){function i(e,n){this._isTransitioning=!1,this._element=e,this._config=this._getConfig(n),this._triggerArray=t.makeArray(t('[data-toggle="collapse"][href="#'+e.id+'"],[data-toggle="collapse"][data-target="#'+e.id+'"]'));for(var i=t(p.DATA_TOGGLE),s=0;s<i.length;s++){var r=i[s],o=P.getSelectorFromElement(r);null!==o&&t(o).filter(e).length>0&&(this._selector=o,this._triggerArray.push(r))}this._parent=this._config.parent?this._getParent():null,this._config.parent||this._addAriaAndCollapsedClass(this._element,this._triggerArray),this._config.toggle&&this.toggle()}var o=i.prototype;return o.toggle=function(){t(this._element).hasClass(c)?this.hide():this.show()},o.show=function(){var e,s,r=this;if(!this._isTransitioning&&!t(this._element).hasClass(c)&&(this._parent&&0===(e=t.makeArray(t(this._parent).find(p.ACTIVES).filter('[data-parent="'+this._config.parent+'"]'))).length&&(e=null),!(e&&(s=t(e).not(this._selector).data(n))&&s._isTransitioning))){var o=t.Event(h.SHOW);if(t(this._element).trigger(o),!o.isDefaultPrevented()){e&&(i._jQueryInterface.call(t(e).not(this._selector),"hide"),s||t(e).data(n,null));var a=this._getDimension();t(this._element).removeClass(u).addClass(f),this._element.style[a]=0,this._triggerArray.length>0&&t(this._triggerArray).removeClass(d).attr("aria-expanded",!0),this.setTransitioning(!0);var l=function(){t(r._element).removeClass(f).addClass(u).addClass(c),r._element.style[a]="",r.setTransitioning(!1),t(r._element).trigger(h.SHOWN)};if(P.supportsTransitionEnd()){var _="scroll"+(a[0].toUpperCase()+a.slice(1));t(this._element).one(P.TRANSITION_END,l).emulateTransitionEnd(600),this._element.style[a]=this._element[_]+"px"}else l()}}},o.hide=function(){var e=this;if(!this._isTransitioning&&t(this._element).hasClass(c)){var n=t.Event(h.HIDE);if(t(this._element).trigger(n),!n.isDefaultPrevented()){var i=this._getDimension();if(this._element.style[i]=this._element.getBoundingClientRect()[i]+"px",P.reflow(this._element),t(this._element).addClass(f).removeClass(u).removeClass(c),this._triggerArray.length>0)for(var s=0;s<this._triggerArray.length;s++){var r=this._triggerArray[s],o=P.getSelectorFromElement(r);if(null!==o)t(o).hasClass(c)||t(r).addClass(d).attr("aria-expanded",!1)}this.setTransitioning(!0);var a=function(){e.setTransitioning(!1),t(e._element).removeClass(f).addClass(u).trigger(h.HIDDEN)};this._element.style[i]="",P.supportsTransitionEnd()?t(this._element).one(P.TRANSITION_END,a).emulateTransitionEnd(600):a()}}},o.setTransitioning=function(t){this._isTransitioning=t},o.dispose=function(){t.removeData(this._element,n),this._config=null,this._parent=null,this._element=null,this._triggerArray=null,this._isTransitioning=null},o._getConfig=function(t){return(t=r({},a,t)).toggle=Boolean(t.toggle),P.typeCheckConfig(e,t,l),t},o._getDimension=function(){return t(this._element).hasClass(_)?_:g},o._getParent=function(){var e=this,n=null;P.isElement(this._config.parent)?(n=this._config.parent,"undefined"!=typeof this._config.parent.jquery&&(n=this._config.parent[0])):n=t(this._config.parent)[0];var s='[data-toggle="collapse"][data-parent="'+this._config.parent+'"]';return t(n).find(s).each(function(t,n){e._addAriaAndCollapsedClass(i._getTargetFromElement(n),[n])}),n},o._addAriaAndCollapsedClass=function(e,n){if(e){var i=t(e).hasClass(c);n.length>0&&t(n).toggleClass(d,!i).attr("aria-expanded",i)}},i._getTargetFromElement=function(e){var n=P.getSelectorFromElement(e);return n?t(n)[0]:null},i._jQueryInterface=function(e){return this.each(function(){var s=t(this),o=s.data(n),l=r({},a,s.data(),"object"==typeof e&&e);if(!o&&l.toggle&&/show|hide/.test(e)&&(l.toggle=!1),o||(o=new i(this,l),s.data(n,o)),"string"==typeof e){if("undefined"==typeof o[e])throw new TypeError('No method named "'+e+'"');o[e]()}})},s(i,null,[{key:"VERSION",get:function(){return"4.0.0"}},{key:"Default",get:function(){return a}}]),i}();return t(document).on(h.CLICK_DATA_API,p.DATA_TOGGLE,function(e){"A"===e.currentTarget.tagName&&e.preventDefault();var i=t(this),s=P.getSelectorFromElement(this);t(s).each(function(){var e=t(this),s=e.data(n)?"toggle":i.data();m._jQueryInterface.call(e,s)})}),t.fn[e]=m._jQueryInterface,t.fn[e].Constructor=m,t.fn[e].noConflict=function(){return t.fn[e]=o,m._jQueryInterface},m}(e),W=function(t){var e="dropdown",i="bs.dropdown",o="."+i,a=".data-api",l=t.fn[e],h=new RegExp("38|40|27"),c={HIDE:"hide"+o,HIDDEN:"hidden"+o,SHOW:"show"+o,SHOWN:"shown"+o,CLICK:"click"+o,CLICK_DATA_API:"click"+o+a,KEYDOWN_DATA_API:"keydown"+o+a,KEYUP_DATA_API:"keyup"+o+a},u="disabled",f="show",d="dropup",_="dropright",g="dropleft",p="dropdown-menu-right",m="dropdown-menu-left",v="position-static",E='[data-toggle="dropdown"]',T=".dropdown form",y=".dropdown-menu",C=".navbar-nav",I=".dropdown-menu .dropdown-item:not(.disabled)",A="top-start",b="top-end",D="bottom-start",S="bottom-end",w="right-start",N="left-start",O={offset:0,flip:!0,boundary:"scrollParent"},k={offset:"(number|string|function)",flip:"boolean",boundary:"(string|element)"},L=function(){function a(t,e){this._element=t,this._popper=null,this._config=this._getConfig(e),this._menu=this._getMenuElement(),this._inNavbar=this._detectNavbar(),this._addEventListeners()}var l=a.prototype;return l.toggle=function(){if(!this._element.disabled&&!t(this._element).hasClass(u)){var e=a._getParentFromElement(this._element),i=t(this._menu).hasClass(f);if(a._clearMenus(),!i){var s={relatedTarget:this._element},r=t.Event(c.SHOW,s);if(t(e).trigger(r),!r.isDefaultPrevented()){if(!this._inNavbar){if("undefined"==typeof n)throw new TypeError("Bootstrap dropdown require Popper.js (https://popper.js.org)");var o=this._element;t(e).hasClass(d)&&(t(this._menu).hasClass(m)||t(this._menu).hasClass(p))&&(o=e),"scrollParent"!==this._config.boundary&&t(e).addClass(v),this._popper=new n(o,this._menu,this._getPopperConfig())}"ontouchstart"in document.documentElement&&0===t(e).closest(C).length&&t("body").children().on("mouseover",null,t.noop),this._element.focus(),this._element.setAttribute("aria-expanded",!0),t(this._menu).toggleClass(f),t(e).toggleClass(f).trigger(t.Event(c.SHOWN,s))}}}},l.dispose=function(){t.removeData(this._element,i),t(this._element).off(o),this._element=null,this._menu=null,null!==this._popper&&(this._popper.destroy(),this._popper=null)},l.update=function(){this._inNavbar=this._detectNavbar(),null!==this._popper&&this._popper.scheduleUpdate()},l._addEventListeners=function(){var e=this;t(this._element).on(c.CLICK,function(t){t.preventDefault(),t.stopPropagation(),e.toggle()})},l._getConfig=function(n){return n=r({},this.constructor.Default,t(this._element).data(),n),P.typeCheckConfig(e,n,this.constructor.DefaultType),n},l._getMenuElement=function(){if(!this._menu){var e=a._getParentFromElement(this._element);this._menu=t(e).find(y)[0]}return this._menu},l._getPlacement=function(){var e=t(this._element).parent(),n=D;return e.hasClass(d)?(n=A,t(this._menu).hasClass(p)&&(n=b)):e.hasClass(_)?n=w:e.hasClass(g)?n=N:t(this._menu).hasClass(p)&&(n=S),n},l._detectNavbar=function(){return t(this._element).closest(".navbar").length>0},l._getPopperConfig=function(){var t=this,e={};return"function"==typeof this._config.offset?e.fn=function(e){return e.offsets=r({},e.offsets,t._config.offset(e.offsets)||{}),e}:e.offset=this._config.offset,{placement:this._getPlacement(),modifiers:{offset:e,flip:{enabled:this._config.flip},preventOverflow:{boundariesElement:this._config.boundary}}}},a._jQueryInterface=function(e){return this.each(function(){var n=t(this).data(i);if(n||(n=new a(this,"object"==typeof e?e:null),t(this).data(i,n)),"string"==typeof e){if("undefined"==typeof n[e])throw new TypeError('No method named "'+e+'"');n[e]()}})},a._clearMenus=function(e){if(!e||3!==e.which&&("keyup"!==e.type||9===e.which))for(var n=t.makeArray(t(E)),s=0;s<n.length;s++){var r=a._getParentFromElement(n[s]),o=t(n[s]).data(i),l={relatedTarget:n[s]};if(o){var h=o._menu;if(t(r).hasClass(f)&&!(e&&("click"===e.type&&/input|textarea/i.test(e.target.tagName)||"keyup"===e.type&&9===e.which)&&t.contains(r,e.target))){var u=t.Event(c.HIDE,l);t(r).trigger(u),u.isDefaultPrevented()||("ontouchstart"in document.documentElement&&t("body").children().off("mouseover",null,t.noop),n[s].setAttribute("aria-expanded","false"),t(h).removeClass(f),t(r).removeClass(f).trigger(t.Event(c.HIDDEN,l)))}}}},a._getParentFromElement=function(e){var n,i=P.getSelectorFromElement(e);return i&&(n=t(i)[0]),n||e.parentNode},a._dataApiKeydownHandler=function(e){if((/input|textarea/i.test(e.target.tagName)?!(32===e.which||27!==e.which&&(40!==e.which&&38!==e.which||t(e.target).closest(y).length)):h.test(e.which))&&(e.preventDefault(),e.stopPropagation(),!this.disabled&&!t(this).hasClass(u))){var n=a._getParentFromElement(this),i=t(n).hasClass(f);if((i||27===e.which&&32===e.which)&&(!i||27!==e.which&&32!==e.which)){var s=t(n).find(I).get();if(0!==s.length){var r=s.indexOf(e.target);38===e.which&&r>0&&r--,40===e.which&&r<s.length-1&&r++,r<0&&(r=0),s[r].focus()}}else{if(27===e.which){var o=t(n).find(E)[0];t(o).trigger("focus")}t(this).trigger("click")}}},s(a,null,[{key:"VERSION",get:function(){return"4.0.0"}},{key:"Default",get:function(){return O}},{key:"DefaultType",get:function(){return k}}]),a}();return t(document).on(c.KEYDOWN_DATA_API,E,L._dataApiKeydownHandler).on(c.KEYDOWN_DATA_API,y,L._dataApiKeydownHandler).on(c.CLICK_DATA_API+" "+c.KEYUP_DATA_API,L._clearMenus).on(c.CLICK_DATA_API,E,function(e){e.preventDefault(),e.stopPropagation(),L._jQueryInterface.call(t(this),"toggle")}).on(c.CLICK_DATA_API,T,function(t){t.stopPropagation()}),t.fn[e]=L._jQueryInterface,t.fn[e].Constructor=L,t.fn[e].noConflict=function(){return t.fn[e]=l,L._jQueryInterface},L}(e),M=function(t){var e="modal",n="bs.modal",i="."+n,o=t.fn.modal,a={backdrop:!0,keyboard:!0,focus:!0,show:!0},l={backdrop:"(boolean|string)",keyboard:"boolean",focus:"boolean",show:"boolean"},h={HIDE:"hide"+i,HIDDEN:"hidden"+i,SHOW:"show"+i,SHOWN:"shown"+i,FOCUSIN:"focusin"+i,RESIZE:"resize"+i,CLICK_DISMISS:"click.dismiss"+i,KEYDOWN_DISMISS:"keydown.dismiss"+i,MOUSEUP_DISMISS:"mouseup.dismiss"+i,MOUSEDOWN_DISMISS:"mousedown.dismiss"+i,CLICK_DATA_API:"click"+i+".data-api"},c="modal-scrollbar-measure",u="modal-backdrop",f="modal-open",d="fade",_="show",g={DIALOG:".modal-dialog",DATA_TOGGLE:'[data-toggle="modal"]',DATA_DISMISS:'[data-dismiss="modal"]',FIXED_CONTENT:".fixed-top, .fixed-bottom, .is-fixed, .sticky-top",STICKY_CONTENT:".sticky-top",NAVBAR_TOGGLER:".navbar-toggler"},p=function(){function o(e,n){this._config=this._getConfig(n),this._element=e,this._dialog=t(e).find(g.DIALOG)[0],this._backdrop=null,this._isShown=!1,this._isBodyOverflowing=!1,this._ignoreBackdropClick=!1,this._originalBodyPadding=0,this._scrollbarWidth=0}var p=o.prototype;return p.toggle=function(t){return this._isShown?this.hide():this.show(t)},p.show=function(e){var n=this;if(!this._isTransitioning&&!this._isShown){P.supportsTransitionEnd()&&t(this._element).hasClass(d)&&(this._isTransitioning=!0);var i=t.Event(h.SHOW,{relatedTarget:e});t(this._element).trigger(i),this._isShown||i.isDefaultPrevented()||(this._isShown=!0,this._checkScrollbar(),this._setScrollbar(),this._adjustDialog(),t(document.body).addClass(f),this._setEscapeEvent(),this._setResizeEvent(),t(this._element).on(h.CLICK_DISMISS,g.DATA_DISMISS,function(t){return n.hide(t)}),t(this._dialog).on(h.MOUSEDOWN_DISMISS,function(){t(n._element).one(h.MOUSEUP_DISMISS,function(e){t(e.target).is(n._element)&&(n._ignoreBackdropClick=!0)})}),this._showBackdrop(function(){return n._showElement(e)}))}},p.hide=function(e){var n=this;if(e&&e.preventDefault(),!this._isTransitioning&&this._isShown){var i=t.Event(h.HIDE);if(t(this._element).trigger(i),this._isShown&&!i.isDefaultPrevented()){this._isShown=!1;var s=P.supportsTransitionEnd()&&t(this._element).hasClass(d);s&&(this._isTransitioning=!0),this._setEscapeEvent(),this._setResizeEvent(),t(document).off(h.FOCUSIN),t(this._element).removeClass(_),t(this._element).off(h.CLICK_DISMISS),t(this._dialog).off(h.MOUSEDOWN_DISMISS),s?t(this._element).one(P.TRANSITION_END,function(t){return n._hideModal(t)}).emulateTransitionEnd(300):this._hideModal()}}},p.dispose=function(){t.removeData(this._element,n),t(window,document,this._element,this._backdrop).off(i),this._config=null,this._element=null,this._dialog=null,this._backdrop=null,this._isShown=null,this._isBodyOverflowing=null,this._ignoreBackdropClick=null,this._scrollbarWidth=null},p.handleUpdate=function(){this._adjustDialog()},p._getConfig=function(t){return t=r({},a,t),P.typeCheckConfig(e,t,l),t},p._showElement=function(e){var n=this,i=P.supportsTransitionEnd()&&t(this._element).hasClass(d);this._element.parentNode&&this._element.parentNode.nodeType===Node.ELEMENT_NODE||document.body.appendChild(this._element),this._element.style.display="block",this._element.removeAttribute("aria-hidden"),this._element.scrollTop=0,i&&P.reflow(this._element),t(this._element).addClass(_),this._config.focus&&this._enforceFocus();var s=t.Event(h.SHOWN,{relatedTarget:e}),r=function(){n._config.focus&&n._element.focus(),n._isTransitioning=!1,t(n._element).trigger(s)};i?t(this._dialog).one(P.TRANSITION_END,r).emulateTransitionEnd(300):r()},p._enforceFocus=function(){var e=this;t(document).off(h.FOCUSIN).on(h.FOCUSIN,function(n){document!==n.target&&e._element!==n.target&&0===t(e._element).has(n.target).length&&e._element.focus()})},p._setEscapeEvent=function(){var e=this;this._isShown&&this._config.keyboard?t(this._element).on(h.KEYDOWN_DISMISS,function(t){27===t.which&&(t.preventDefault(),e.hide())}):this._isShown||t(this._element).off(h.KEYDOWN_DISMISS)},p._setResizeEvent=function(){var e=this;this._isShown?t(window).on(h.RESIZE,function(t){return e.handleUpdate(t)}):t(window).off(h.RESIZE)},p._hideModal=function(){var e=this;this._element.style.display="none",this._element.setAttribute("aria-hidden",!0),this._isTransitioning=!1,this._showBackdrop(function(){t(document.body).removeClass(f),e._resetAdjustments(),e._resetScrollbar(),t(e._element).trigger(h.HIDDEN)})},p._removeBackdrop=function(){this._backdrop&&(t(this._backdrop).remove(),this._backdrop=null)},p._showBackdrop=function(e){var n=this,i=t(this._element).hasClass(d)?d:"";if(this._isShown&&this._config.backdrop){var s=P.supportsTransitionEnd()&&i;if(this._backdrop=document.createElement("div"),this._backdrop.className=u,i&&t(this._backdrop).addClass(i),t(this._backdrop).appendTo(document.body),t(this._element).on(h.CLICK_DISMISS,function(t){n._ignoreBackdropClick?n._ignoreBackdropClick=!1:t.target===t.currentTarget&&("static"===n._config.backdrop?n._element.focus():n.hide())}),s&&P.reflow(this._backdrop),t(this._backdrop).addClass(_),!e)return;if(!s)return void e();t(this._backdrop).one(P.TRANSITION_END,e).emulateTransitionEnd(150)}else if(!this._isShown&&this._backdrop){t(this._backdrop).removeClass(_);var r=function(){n._removeBackdrop(),e&&e()};P.supportsTransitionEnd()&&t(this._element).hasClass(d)?t(this._backdrop).one(P.TRANSITION_END,r).emulateTransitionEnd(150):r()}else e&&e()},p._adjustDialog=function(){var t=this._element.scrollHeight>document.documentElement.clientHeight;!this._isBodyOverflowing&&t&&(this._element.style.paddingLeft=this._scrollbarWidth+"px"),this._isBodyOverflowing&&!t&&(this._element.style.paddingRight=this._scrollbarWidth+"px")},p._resetAdjustments=function(){this._element.style.paddingLeft="",this._element.style.paddingRight=""},p._checkScrollbar=function(){var t=document.body.getBoundingClientRect();this._isBodyOverflowing=t.left+t.right<window.innerWidth,this._scrollbarWidth=this._getScrollbarWidth()},p._setScrollbar=function(){var e=this;if(this._isBodyOverflowing){t(g.FIXED_CONTENT).each(function(n,i){var s=t(i)[0].style.paddingRight,r=t(i).css("padding-right");t(i).data("padding-right",s).css("padding-right",parseFloat(r)+e._scrollbarWidth+"px")}),t(g.STICKY_CONTENT).each(function(n,i){var s=t(i)[0].style.marginRight,r=t(i).css("margin-right");t(i).data("margin-right",s).css("margin-right",parseFloat(r)-e._scrollbarWidth+"px")}),t(g.NAVBAR_TOGGLER).each(function(n,i){var s=t(i)[0].style.marginRight,r=t(i).css("margin-right");t(i).data("margin-right",s).css("margin-right",parseFloat(r)+e._scrollbarWidth+"px")});var n=document.body.style.paddingRight,i=t("body").css("padding-right");t("body").data("padding-right",n).css("padding-right",parseFloat(i)+this._scrollbarWidth+"px")}},p._resetScrollbar=function(){t(g.FIXED_CONTENT).each(function(e,n){var i=t(n).data("padding-right");"undefined"!=typeof i&&t(n).css("padding-right",i).removeData("padding-right")}),t(g.STICKY_CONTENT+", "+g.NAVBAR_TOGGLER).each(function(e,n){var i=t(n).data("margin-right");"undefined"!=typeof i&&t(n).css("margin-right",i).removeData("margin-right")});var e=t("body").data("padding-right");"undefined"!=typeof e&&t("body").css("padding-right",e).removeData("padding-right")},p._getScrollbarWidth=function(){var t=document.createElement("div");t.className=c,document.body.appendChild(t);var e=t.getBoundingClientRect().width-t.clientWidth;return document.body.removeChild(t),e},o._jQueryInterface=function(e,i){return this.each(function(){var s=t(this).data(n),a=r({},o.Default,t(this).data(),"object"==typeof e&&e);if(s||(s=new o(this,a),t(this).data(n,s)),"string"==typeof e){if("undefined"==typeof s[e])throw new TypeError('No method named "'+e+'"');s[e](i)}else a.show&&s.show(i)})},s(o,null,[{key:"VERSION",get:function(){return"4.0.0"}},{key:"Default",get:function(){return a}}]),o}();return t(document).on(h.CLICK_DATA_API,g.DATA_TOGGLE,function(e){var i,s=this,o=P.getSelectorFromElement(this);o&&(i=t(o)[0]);var a=t(i).data(n)?"toggle":r({},t(i).data(),t(this).data());"A"!==this.tagName&&"AREA"!==this.tagName||e.preventDefault();var l=t(i).one(h.SHOW,function(e){e.isDefaultPrevented()||l.one(h.HIDDEN,function(){t(s).is(":visible")&&s.focus()})});p._jQueryInterface.call(t(i),a,this)}),t.fn.modal=p._jQueryInterface,t.fn.modal.Constructor=p,t.fn.modal.noConflict=function(){return t.fn.modal=o,p._jQueryInterface},p}(e),U=function(t){var e="tooltip",i="bs.tooltip",o="."+i,a=t.fn[e],l=new RegExp("(^|\\s)bs-tooltip\\S+","g"),h={animation:"boolean",template:"string",title:"(string|element|function)",trigger:"string",delay:"(number|object)",html:"boolean",selector:"(string|boolean)",placement:"(string|function)",offset:"(number|string)",container:"(string|element|boolean)",fallbackPlacement:"(string|array)",boundary:"(string|element)"},c={AUTO:"auto",TOP:"top",RIGHT:"right",BOTTOM:"bottom",LEFT:"left"},u={animation:!0,template:'<div class="tooltip" role="tooltip"><div class="arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover focus",title:"",delay:0,html:!1,selector:!1,placement:"top",offset:0,container:!1,fallbackPlacement:"flip",boundary:"scrollParent"},f="show",d="out",_={HIDE:"hide"+o,HIDDEN:"hidden"+o,SHOW:"show"+o,SHOWN:"shown"+o,INSERTED:"inserted"+o,CLICK:"click"+o,FOCUSIN:"focusin"+o,FOCUSOUT:"focusout"+o,MOUSEENTER:"mouseenter"+o,MOUSELEAVE:"mouseleave"+o},g="fade",p="show",m=".tooltip-inner",v=".arrow",E="hover",T="focus",y="click",C="manual",I=function(){function a(t,e){if("undefined"==typeof n)throw new TypeError("Bootstrap tooltips require Popper.js (https://popper.js.org)");this._isEnabled=!0,this._timeout=0,this._hoverState="",this._activeTrigger={},this._popper=null,this.element=t,this.config=this._getConfig(e),this.tip=null,this._setListeners()}var I=a.prototype;return I.enable=function(){this._isEnabled=!0},I.disable=function(){this._isEnabled=!1},I.toggleEnabled=function(){this._isEnabled=!this._isEnabled},I.toggle=function(e){if(this._isEnabled)if(e){var n=this.constructor.DATA_KEY,i=t(e.currentTarget).data(n);i||(i=new this.constructor(e.currentTarget,this._getDelegateConfig()),t(e.currentTarget).data(n,i)),i._activeTrigger.click=!i._activeTrigger.click,i._isWithActiveTrigger()?i._enter(null,i):i._leave(null,i)}else{if(t(this.getTipElement()).hasClass(p))return void this._leave(null,this);this._enter(null,this)}},I.dispose=function(){clearTimeout(this._timeout),t.removeData(this.element,this.constructor.DATA_KEY),t(this.element).off(this.constructor.EVENT_KEY),t(this.element).closest(".modal").off("hide.bs.modal"),this.tip&&t(this.tip).remove(),this._isEnabled=null,this._timeout=null,this._hoverState=null,this._activeTrigger=null,null!==this._popper&&this._popper.destroy(),this._popper=null,this.element=null,this.config=null,this.tip=null},I.show=function(){var e=this;if("none"===t(this.element).css("display"))throw new Error("Please use show on visible elements");var i=t.Event(this.constructor.Event.SHOW);if(this.isWithContent()&&this._isEnabled){t(this.element).trigger(i);var s=t.contains(this.element.ownerDocument.documentElement,this.element);if(i.isDefaultPrevented()||!s)return;var r=this.getTipElement(),o=P.getUID(this.constructor.NAME);r.setAttribute("id",o),this.element.setAttribute("aria-describedby",o),this.setContent(),this.config.animation&&t(r).addClass(g);var l="function"==typeof this.config.placement?this.config.placement.call(this,r,this.element):this.config.placement,h=this._getAttachment(l);this.addAttachmentClass(h);var c=!1===this.config.container?document.body:t(this.config.container);t(r).data(this.constructor.DATA_KEY,this),t.contains(this.element.ownerDocument.documentElement,this.tip)||t(r).appendTo(c),t(this.element).trigger(this.constructor.Event.INSERTED),this._popper=new n(this.element,r,{placement:h,modifiers:{offset:{offset:this.config.offset},flip:{behavior:this.config.fallbackPlacement},arrow:{element:v},preventOverflow:{boundariesElement:this.config.boundary}},onCreate:function(t){t.originalPlacement!==t.placement&&e._handlePopperPlacementChange(t)},onUpdate:function(t){e._handlePopperPlacementChange(t)}}),t(r).addClass(p),"ontouchstart"in document.documentElement&&t("body").children().on("mouseover",null,t.noop);var u=function(){e.config.animation&&e._fixTransition();var n=e._hoverState;e._hoverState=null,t(e.element).trigger(e.constructor.Event.SHOWN),n===d&&e._leave(null,e)};P.supportsTransitionEnd()&&t(this.tip).hasClass(g)?t(this.tip).one(P.TRANSITION_END,u).emulateTransitionEnd(a._TRANSITION_DURATION):u()}},I.hide=function(e){var n=this,i=this.getTipElement(),s=t.Event(this.constructor.Event.HIDE),r=function(){n._hoverState!==f&&i.parentNode&&i.parentNode.removeChild(i),n._cleanTipClass(),n.element.removeAttribute("aria-describedby"),t(n.element).trigger(n.constructor.Event.HIDDEN),null!==n._popper&&n._popper.destroy(),e&&e()};t(this.element).trigger(s),s.isDefaultPrevented()||(t(i).removeClass(p),"ontouchstart"in document.documentElement&&t("body").children().off("mouseover",null,t.noop),this._activeTrigger[y]=!1,this._activeTrigger[T]=!1,this._activeTrigger[E]=!1,P.supportsTransitionEnd()&&t(this.tip).hasClass(g)?t(i).one(P.TRANSITION_END,r).emulateTransitionEnd(150):r(),this._hoverState="")},I.update=function(){null!==this._popper&&this._popper.scheduleUpdate()},I.isWithContent=function(){return Boolean(this.getTitle())},I.addAttachmentClass=function(e){t(this.getTipElement()).addClass("bs-tooltip-"+e)},I.getTipElement=function(){return this.tip=this.tip||t(this.config.template)[0],this.tip},I.setContent=function(){var e=t(this.getTipElement());this.setElementContent(e.find(m),this.getTitle()),e.removeClass(g+" "+p)},I.setElementContent=function(e,n){var i=this.config.html;"object"==typeof n&&(n.nodeType||n.jquery)?i?t(n).parent().is(e)||e.empty().append(n):e.text(t(n).text()):e[i?"html":"text"](n)},I.getTitle=function(){var t=this.element.getAttribute("data-original-title");return t||(t="function"==typeof this.config.title?this.config.title.call(this.element):this.config.title),t},I._getAttachment=function(t){return c[t.toUpperCase()]},I._setListeners=function(){var e=this;this.config.trigger.split(" ").forEach(function(n){if("click"===n)t(e.element).on(e.constructor.Event.CLICK,e.config.selector,function(t){return e.toggle(t)});else if(n!==C){var i=n===E?e.constructor.Event.MOUSEENTER:e.constructor.Event.FOCUSIN,s=n===E?e.constructor.Event.MOUSELEAVE:e.constructor.Event.FOCUSOUT;t(e.element).on(i,e.config.selector,function(t){return e._enter(t)}).on(s,e.config.selector,function(t){return e._leave(t)})}t(e.element).closest(".modal").on("hide.bs.modal",function(){return e.hide()})}),this.config.selector?this.config=r({},this.config,{trigger:"manual",selector:""}):this._fixTitle()},I._fixTitle=function(){var t=typeof this.element.getAttribute("data-original-title");(this.element.getAttribute("title")||"string"!==t)&&(this.element.setAttribute("data-original-title",this.element.getAttribute("title")||""),this.element.setAttribute("title",""))},I._enter=function(e,n){var i=this.constructor.DATA_KEY;(n=n||t(e.currentTarget).data(i))||(n=new this.constructor(e.currentTarget,this._getDelegateConfig()),t(e.currentTarget).data(i,n)),e&&(n._activeTrigger["focusin"===e.type?T:E]=!0),t(n.getTipElement()).hasClass(p)||n._hoverState===f?n._hoverState=f:(clearTimeout(n._timeout),n._hoverState=f,n.config.delay&&n.config.delay.show?n._timeout=setTimeout(function(){n._hoverState===f&&n.show()},n.config.delay.show):n.show())},I._leave=function(e,n){var i=this.constructor.DATA_KEY;(n=n||t(e.currentTarget).data(i))||(n=new this.constructor(e.currentTarget,this._getDelegateConfig()),t(e.currentTarget).data(i,n)),e&&(n._activeTrigger["focusout"===e.type?T:E]=!1),n._isWithActiveTrigger()||(clearTimeout(n._timeout),n._hoverState=d,n.config.delay&&n.config.delay.hide?n._timeout=setTimeout(function(){n._hoverState===d&&n.hide()},n.config.delay.hide):n.hide())},I._isWithActiveTrigger=function(){for(var t in this._activeTrigger)if(this._activeTrigger[t])return!0;return!1},I._getConfig=function(n){return"number"==typeof(n=r({},this.constructor.Default,t(this.element).data(),n)).delay&&(n.delay={show:n.delay,hide:n.delay}),"number"==typeof n.title&&(n.title=n.title.toString()),"number"==typeof n.content&&(n.content=n.content.toString()),P.typeCheckConfig(e,n,this.constructor.DefaultType),n},I._getDelegateConfig=function(){var t={};if(this.config)for(var e in this.config)this.constructor.Default[e]!==this.config[e]&&(t[e]=this.config[e]);return t},I._cleanTipClass=function(){var e=t(this.getTipElement()),n=e.attr("class").match(l);null!==n&&n.length>0&&e.removeClass(n.join(""))},I._handlePopperPlacementChange=function(t){this._cleanTipClass(),this.addAttachmentClass(this._getAttachment(t.placement))},I._fixTransition=function(){var e=this.getTipElement(),n=this.config.animation;null===e.getAttribute("x-placement")&&(t(e).removeClass(g),this.config.animation=!1,this.hide(),this.show(),this.config.animation=n)},a._jQueryInterface=function(e){return this.each(function(){var n=t(this).data(i),s="object"==typeof e&&e;if((n||!/dispose|hide/.test(e))&&(n||(n=new a(this,s),t(this).data(i,n)),"string"==typeof e)){if("undefined"==typeof n[e])throw new TypeError('No method named "'+e+'"');n[e]()}})},s(a,null,[{key:"VERSION",get:function(){return"4.0.0"}},{key:"Default",get:function(){return u}},{key:"NAME",get:function(){return e}},{key:"DATA_KEY",get:function(){return i}},{key:"Event",get:function(){return _}},{key:"EVENT_KEY",get:function(){return o}},{key:"DefaultType",get:function(){return h}}]),a}();return t.fn[e]=I._jQueryInterface,t.fn[e].Constructor=I,t.fn[e].noConflict=function(){return t.fn[e]=a,I._jQueryInterface},I}(e),x=function(t){var e="popover",n="bs.popover",i="."+n,o=t.fn[e],a=new RegExp("(^|\\s)bs-popover\\S+","g"),l=r({},U.Default,{placement:"right",trigger:"click",content:"",template:'<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>'}),h=r({},U.DefaultType,{content:"(string|element|function)"}),c="fade",u="show",f=".popover-header",d=".popover-body",_={HIDE:"hide"+i,HIDDEN:"hidden"+i,SHOW:"show"+i,SHOWN:"shown"+i,INSERTED:"inserted"+i,CLICK:"click"+i,FOCUSIN:"focusin"+i,FOCUSOUT:"focusout"+i,MOUSEENTER:"mouseenter"+i,MOUSELEAVE:"mouseleave"+i},g=function(r){var o,g;function p(){return r.apply(this,arguments)||this}g=r,(o=p).prototype=Object.create(g.prototype),o.prototype.constructor=o,o.__proto__=g;var m=p.prototype;return m.isWithContent=function(){return this.getTitle()||this._getContent()},m.addAttachmentClass=function(e){t(this.getTipElement()).addClass("bs-popover-"+e)},m.getTipElement=function(){return this.tip=this.tip||t(this.config.template)[0],this.tip},m.setContent=function(){var e=t(this.getTipElement());this.setElementContent(e.find(f),this.getTitle());var n=this._getContent();"function"==typeof n&&(n=n.call(this.element)),this.setElementContent(e.find(d),n),e.removeClass(c+" "+u)},m._getContent=function(){return this.element.getAttribute("data-content")||this.config.content},m._cleanTipClass=function(){var e=t(this.getTipElement()),n=e.attr("class").match(a);null!==n&&n.length>0&&e.removeClass(n.join(""))},p._jQueryInterface=function(e){return this.each(function(){var i=t(this).data(n),s="object"==typeof e?e:null;if((i||!/destroy|hide/.test(e))&&(i||(i=new p(this,s),t(this).data(n,i)),"string"==typeof e)){if("undefined"==typeof i[e])throw new TypeError('No method named "'+e+'"');i[e]()}})},s(p,null,[{key:"VERSION",get:function(){return"4.0.0"}},{key:"Default",get:function(){return l}},{key:"NAME",get:function(){return e}},{key:"DATA_KEY",get:function(){return n}},{key:"Event",get:function(){return _}},{key:"EVENT_KEY",get:function(){return i}},{key:"DefaultType",get:function(){return h}}]),p}(U);return t.fn[e]=g._jQueryInterface,t.fn[e].Constructor=g,t.fn[e].noConflict=function(){return t.fn[e]=o,g._jQueryInterface},g}(e),K=function(t){var e="scrollspy",n="bs.scrollspy",i="."+n,o=t.fn[e],a={offset:10,method:"auto",target:""},l={offset:"number",method:"string",target:"(string|element)"},h={ACTIVATE:"activate"+i,SCROLL:"scroll"+i,LOAD_DATA_API:"load"+i+".data-api"},c="dropdown-item",u="active",f={DATA_SPY:'[data-spy="scroll"]',ACTIVE:".active",NAV_LIST_GROUP:".nav, .list-group",NAV_LINKS:".nav-link",NAV_ITEMS:".nav-item",LIST_ITEMS:".list-group-item",DROPDOWN:".dropdown",DROPDOWN_ITEMS:".dropdown-item",DROPDOWN_TOGGLE:".dropdown-toggle"},d="offset",_="position",g=function(){function o(e,n){var i=this;this._element=e,this._scrollElement="BODY"===e.tagName?window:e,this._config=this._getConfig(n),this._selector=this._config.target+" "+f.NAV_LINKS+","+this._config.target+" "+f.LIST_ITEMS+","+this._config.target+" "+f.DROPDOWN_ITEMS,this._offsets=[],this._targets=[],this._activeTarget=null,this._scrollHeight=0,t(this._scrollElement).on(h.SCROLL,function(t){return i._process(t)}),this.refresh(),this._process()}var g=o.prototype;return g.refresh=function(){var e=this,n=this._scrollElement===this._scrollElement.window?d:_,i="auto"===this._config.method?n:this._config.method,s=i===_?this._getScrollTop():0;this._offsets=[],this._targets=[],this._scrollHeight=this._getScrollHeight(),t.makeArray(t(this._selector)).map(function(e){var n,r=P.getSelectorFromElement(e);if(r&&(n=t(r)[0]),n){var o=n.getBoundingClientRect();if(o.width||o.height)return[t(n)[i]().top+s,r]}return null}).filter(function(t){return t}).sort(function(t,e){return t[0]-e[0]}).forEach(function(t){e._offsets.push(t[0]),e._targets.push(t[1])})},g.dispose=function(){t.removeData(this._element,n),t(this._scrollElement).off(i),this._element=null,this._scrollElement=null,this._config=null,this._selector=null,this._offsets=null,this._targets=null,this._activeTarget=null,this._scrollHeight=null},g._getConfig=function(n){if("string"!=typeof(n=r({},a,n)).target){var i=t(n.target).attr("id");i||(i=P.getUID(e),t(n.target).attr("id",i)),n.target="#"+i}return P.typeCheckConfig(e,n,l),n},g._getScrollTop=function(){return this._scrollElement===window?this._scrollElement.pageYOffset:this._scrollElement.scrollTop},g._getScrollHeight=function(){return this._scrollElement.scrollHeight||Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)},g._getOffsetHeight=function(){return this._scrollElement===window?window.innerHeight:this._scrollElement.getBoundingClientRect().height},g._process=function(){var t=this._getScrollTop()+this._config.offset,e=this._getScrollHeight(),n=this._config.offset+e-this._getOffsetHeight();if(this._scrollHeight!==e&&this.refresh(),t>=n){var i=this._targets[this._targets.length-1];this._activeTarget!==i&&this._activate(i)}else{if(this._activeTarget&&t<this._offsets[0]&&this._offsets[0]>0)return this._activeTarget=null,void this._clear();for(var s=this._offsets.length;s--;){this._activeTarget!==this._targets[s]&&t>=this._offsets[s]&&("undefined"==typeof this._offsets[s+1]||t<this._offsets[s+1])&&this._activate(this._targets[s])}}},g._activate=function(e){this._activeTarget=e,this._clear();var n=this._selector.split(",");n=n.map(function(t){return t+'[data-target="'+e+'"],'+t+'[href="'+e+'"]'});var i=t(n.join(","));i.hasClass(c)?(i.closest(f.DROPDOWN).find(f.DROPDOWN_TOGGLE).addClass(u),i.addClass(u)):(i.addClass(u),i.parents(f.NAV_LIST_GROUP).prev(f.NAV_LINKS+", "+f.LIST_ITEMS).addClass(u),i.parents(f.NAV_LIST_GROUP).prev(f.NAV_ITEMS).children(f.NAV_LINKS).addClass(u)),t(this._scrollElement).trigger(h.ACTIVATE,{relatedTarget:e})},g._clear=function(){t(this._selector).filter(f.ACTIVE).removeClass(u)},o._jQueryInterface=function(e){return this.each(function(){var i=t(this).data(n);if(i||(i=new o(this,"object"==typeof e&&e),t(this).data(n,i)),"string"==typeof e){if("undefined"==typeof i[e])throw new TypeError('No method named "'+e+'"');i[e]()}})},s(o,null,[{key:"VERSION",get:function(){return"4.0.0"}},{key:"Default",get:function(){return a}}]),o}();return t(window).on(h.LOAD_DATA_API,function(){for(var e=t.makeArray(t(f.DATA_SPY)),n=e.length;n--;){var i=t(e[n]);g._jQueryInterface.call(i,i.data())}}),t.fn[e]=g._jQueryInterface,t.fn[e].Constructor=g,t.fn[e].noConflict=function(){return t.fn[e]=o,g._jQueryInterface},g}(e),V=function(t){var e="bs.tab",n="."+e,i=t.fn.tab,r={HIDE:"hide"+n,HIDDEN:"hidden"+n,SHOW:"show"+n,SHOWN:"shown"+n,CLICK_DATA_API:"click.bs.tab.data-api"},o="dropdown-menu",a="active",l="disabled",h="fade",c="show",u=".dropdown",f=".nav, .list-group",d=".active",_="> li > .active",g='[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]',p=".dropdown-toggle",m="> .dropdown-menu .active",v=function(){function n(t){this._element=t}var i=n.prototype;return i.show=function(){var e=this;if(!(this._element.parentNode&&this._element.parentNode.nodeType===Node.ELEMENT_NODE&&t(this._element).hasClass(a)||t(this._element).hasClass(l))){var n,i,s=t(this._element).closest(f)[0],o=P.getSelectorFromElement(this._element);if(s){var h="UL"===s.nodeName?_:d;i=(i=t.makeArray(t(s).find(h)))[i.length-1]}var c=t.Event(r.HIDE,{relatedTarget:this._element}),u=t.Event(r.SHOW,{relatedTarget:i});if(i&&t(i).trigger(c),t(this._element).trigger(u),!u.isDefaultPrevented()&&!c.isDefaultPrevented()){o&&(n=t(o)[0]),this._activate(this._element,s);var g=function(){var n=t.Event(r.HIDDEN,{relatedTarget:e._element}),s=t.Event(r.SHOWN,{relatedTarget:i});t(i).trigger(n),t(e._element).trigger(s)};n?this._activate(n,n.parentNode,g):g()}}},i.dispose=function(){t.removeData(this._element,e),this._element=null},i._activate=function(e,n,i){var s=this,r=("UL"===n.nodeName?t(n).find(_):t(n).children(d))[0],o=i&&P.supportsTransitionEnd()&&r&&t(r).hasClass(h),a=function(){return s._transitionComplete(e,r,i)};r&&o?t(r).one(P.TRANSITION_END,a).emulateTransitionEnd(150):a()},i._transitionComplete=function(e,n,i){if(n){t(n).removeClass(c+" "+a);var s=t(n.parentNode).find(m)[0];s&&t(s).removeClass(a),"tab"===n.getAttribute("role")&&n.setAttribute("aria-selected",!1)}if(t(e).addClass(a),"tab"===e.getAttribute("role")&&e.setAttribute("aria-selected",!0),P.reflow(e),t(e).addClass(c),e.parentNode&&t(e.parentNode).hasClass(o)){var r=t(e).closest(u)[0];r&&t(r).find(p).addClass(a),e.setAttribute("aria-expanded",!0)}i&&i()},n._jQueryInterface=function(i){return this.each(function(){var s=t(this),r=s.data(e);if(r||(r=new n(this),s.data(e,r)),"string"==typeof i){if("undefined"==typeof r[i])throw new TypeError('No method named "'+i+'"');r[i]()}})},s(n,null,[{key:"VERSION",get:function(){return"4.0.0"}}]),n}();return t(document).on(r.CLICK_DATA_API,g,function(e){e.preventDefault(),v._jQueryInterface.call(t(this),"show")}),t.fn.tab=v._jQueryInterface,t.fn.tab.Constructor=v,t.fn.tab.noConflict=function(){return t.fn.tab=i,v._jQueryInterface},v}(e);!function(t){if("undefined"==typeof t)throw new TypeError("Bootstrap's JavaScript requires jQuery. jQuery must be included before Bootstrap's JavaScript.");var e=t.fn.jquery.split(" ")[0].split(".");if(e[0]<2&&e[1]<9||1===e[0]&&9===e[1]&&e[2]<1||e[0]>=4)throw new Error("Bootstrap's JavaScript requires at least jQuery v1.9.1 but less than v4.0.0")}(e),t.Util=P,t.Alert=L,t.Button=R,t.Carousel=j,t.Collapse=H,t.Dropdown=W,t.Modal=M,t.Popover=x,t.Scrollspy=K,t.Tab=V,t.Tooltip=U,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=bootstrap.min.js.map;
// case insensitive :contains for jQuery
$.extend($.expr[":"], {
    "containsIN": function (elem, i, match, array) {
        return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
    }
});

// misc utility functions
var utilitiesApp = (function () {

    var jwtRefreshInterval = undefined;

    if (!String.format) {
        String.format = function (format) {
            var args = Array.prototype.slice.call(arguments, 1);
            return format.replace(/{(\d+)}/g, function (match, number) {
                return typeof args[number] != 'undefined'
                    ? args[number]
                    : match
                    ;
            });
        };
    }

    function initializeReadOnly() {
        $("#actions").remove();
        $(".btn-inline").remove();
        $("<style>#sort-page-table label.checkbox-inline, .user-delete-icon, .glyphicon-duplicate, .icon-delete, .icon-add, .gateway-delete-icon, #modal-dismiss-button { display:none !important; }</style>").appendTo("head");
        //$("<style>div.checkbox { width:16px;height:16px; }</style>").appendTo("head");
        $("button[type=submit], #submitButton").prop("disabled", "disabled");
        $("button[type=submit], #submitButton").addClass("disabled");
        $("input.field").prop("disabled", "disabled");
        $("input.field").addClass("disabled");
        $("select").prop("disabled", "disabled");
        $("select").addClass("disabled");
        $(".buttons .btn-large").prop("disabled", "disabled");
        $(".buttons .btn-large").addClass("disabled");
        $(".panel-link a").remove();
        $(".panel-footer a:contains('Add')").remove();
        $(".users input").prop("disabled", "disabled");
        $(".users input").addClass("disabled");
        $("#userIsActive, #customerIsActive, #customerIsPartnerDemo, #customerCanCreateChildCustomers").prop("disabled", "disabled");
        $("#userIsActive, #customerIsActive, #customerIsPartnerDemo, #customerCanCreateChildCustomers").addClass("disabled");
        $("#addGroupBox").remove();
        $("#addRadioSystemBox").remove();
    }

    function toggleAllChecked() {
        $("#all-groups, #all-contacts, #all-users").on("click", function () {
            var allCheckboxes = $(this).closest("ul").find("input[type='checkbox']").slice(1);
            if ($(this).is(":checked")) {
                $(allCheckboxes).each(function () {
                    if (!$(this).is(":checked")) {
                        $(this).prop("checked", true).trigger("change");
                    }
                });
            }
            else {
                $(allCheckboxes).each(function () {
                    if ($(this).is(":checked")) {
                        $(this).prop("checked", false).trigger("change");
                    }
                });
            }
        });
    }

    function getTicks() {
        return (621355968e9 + (new Date()).getTime() * 1e4);
    }

    function isInt(value) {
        var er = /^-?[0-9]+$/;
        return er.test(value);
    }

    function checkBoxToggle(checkBoxId, hiddenFieldId) {
        $(checkBoxId).change(function () {
            $(hiddenFieldId).val($(this).is(":checked"));
        });
    }

    function dropDownToggle(dropDownId, hiddenFieldId, defaultValueId) {
        $(dropDownId).change(function () {
            $(hiddenFieldId).val($(this).val());
        });

        var hiddenValue = $(hiddenFieldId).val();
        var defaultValue = $(defaultValueId).val();

        if (hiddenValue !== null && hiddenValue !== undefined && hiddenValue.length > 0)
            $(dropDownId).val(hiddenValue);
        else if (defaultValue !== null && defaultValue !== undefined && defaultValue.length > 0)
            $(dropDownId).val(defaultValue);
    }

    function checkBoxToggleWithDefault(checkBoxId, hiddenFieldId, defaultValueId) {
        $(checkBoxId).change(function () {
            $(hiddenFieldId).val($(this).is(":checked"));
        });

        var hiddenValue = $(hiddenFieldId).val();
        var defaultValue = $(defaultValueId).val();

        if (hiddenValue !== null && hiddenValue !== undefined && hiddenValue.length > 0) {
            $(checkBoxId).prop("checked", hiddenValue.toLowerCase() === "true");
        }
        else if (defaultValue !== null && defaultValue !== undefined && defaultValue.length > 0) {
            $(checkBoxId).prop("checked", defaultValue.toLowerCase() === "true");
        }
    }

    function checkBoxToggleWithOpposite(checkboxId, hiddenFieldId, defaultValueId) {
        $(checkboxId).change(function () {
            $(hiddenFieldId).val($(this).is(":not(:checked)"));
        });

        var hiddenValue = $(hiddenFieldId).val();
        var defaultValue = $(defaultValueId).val();

        if (hiddenValue !== null && hiddenValue !== undefined && hiddenValue.length > 0) {
            $(checkboxId).prop("checked", hiddenValue.toLowerCase() === "false");
        }
        else if (defaultValue !== null && defaultValue !== undefined && defaultValue.length > 0) {
            $(checkboxId).prop("checked", defaultValue.toLowerCase() === "false");
        }
    }

    function formatDate(date) {
        if (date === null || date === undefined) return "";

        if (date.length === 0) return "-";

        var d = new Date(date.split("T")[0].replace(/-/g, "/"));

        var m = d.getMonth() + 1;

        return (m >= 10 ? "" : "0") + m + "/" + d.getDate() + "/" + d.getFullYear();
    }

    function getValueWithDefault(id, defaultValue) {
        var currentValue = $(id).val();

        if (currentValue === null || currentValue === undefined || currentValue === "")
            currentValue = defaultValue;

        return currentValue;
    }

    function escapeJson(unsafe) {
        if (unsafe === null || unsafe === undefined)
            return "";

        return unsafe.replace(/&#039;/g, "'")
            .replace(/&#034;/g, "\"");
    }

    function jsEscape(unsafe) {
        if (unsafe === null || unsafe === undefined)
            return "";

        unsafe = unsafe.replace(/&#039;/g, "'").replace(/&#034;/g, "\"");

        var jsText = unsafe.match(/<script[^>]*>.*?<\/script>/g);
        if (jsText !== null) {
            jsText.forEach(function (i) {
                unsafe = unsafe.replace(i, escapeHtml(i));
            });
        }
        return unsafe;
    }

    function escapeHtml(unsafe) {
        if (unsafe === null || unsafe === undefined)
            return "";

        return unsafe.replace(/&#039;/g, "'")
            .replace(/&#034;/g, "\"")
            .replace(/</g, "&lt;")
            .replace(/>/g, "&gt;");
    }

    function confirmModal(text, onConfirm, onCancel) {
        $("body").append('<div class="modal fade" id="confirm-message-modal" data-keyboard="false" data-backdrop="static"> \
              <div class="modal-dialog"> \
                <div class="modal-content"> \
                  <div class="modal-header"> \
                    <h4 class="modal-title">\
                    ' + Resources.Global.Confirm + ' </h4> \
                  </div> \
                  <div class="modal-body"> \
                    ' + text + ' \
                  </div> \
                  <div class="modal-footer"> \
                    <button id="modal-cancel-button" type="button" class="btn red" data-dismiss="modal"> \
                        ' + Resources.Global.Cancel + ' \
                    </button > \
                    <button id="modal-ok-button" type="button" class="btn btn-primary" data-dismiss="modal"> \
                        ' + Resources.Global.Ok + ' \
                    </button> \
                  </div> \
                </div> \
              </div> \
             </div>');

        var okClicked = false;
        
        $("#confirm-message-modal").modal("show");
        $("#confirm-message-modal").on("hidden.bs.modal", function () {
            $("#confirm-message-modal").remove();
            if(okClicked){
                onConfirm();
                return;
            }
            if (onCancel !== null && onCancel !== undefined) {
                onCancel();
            }
        });

        $("#modal-ok-button").click(function () {
            okClicked = true;
        });
    }
    function confirmInfoModal(text, callbackFunction, cancelFunction) {
        $("body").append('<div class="modal fade" id="confirm-message-modal" data-keyboard="false" data-backdrop="static"> \
              <div class="modal-dialog"> \
                <div class="modal-content"> \
                  <div class="modal-header"> \
                    <h4 class="modal-title">\
                    ' + Resources.Global.Information + '</h4> \
                  </div> \
                  <div class="modal-body"> \
                    ' + text + ' \
                  </div> \
                  <div class="modal-footer"> \
                    <button id="modal-ok-button" type="button" class="btn btn-primary" data-dismiss="modal"> \
                        ' + Resources.Global.Ok + ' \
                    </button> \
                  </div> \
                </div> \
              </div> \
             </div>');

        $("#confirm-message-modal").modal("show");
        $("#confirm-message-modal").on("hidden.bs.modal", function () {
            $("#confirm-message-modal").remove();
             callbackFunction();
        });
    }

    function confirmInfoModals(text, callbackFunction, cancelFunction) {
        $("body").append('<div class="modal fade" id="confirm-message-modal" data-keyboard="false" data-backdrop="static"> \
              <div class="modal-dialog"> \
                <div class="modal-content"> \
                  <div class="modal-header"> \
                    <h4 class="modal-title">\
                    ' + Resources.Global.Confirm + '</h4> \
                  </div> \
                  <div class="modal-body"> \
                    ' + text + ' \
                  </div> \
                  <div class="modal-footer"> \
                    <button id="modal-ok-button" type="button" class="btn btn-primary" data-dismiss="modal"> \
                        ' + Resources.Global.Ok + ' \
                    </button> \
                    <button id="modal-cancel-button" type="button" class="btn red" data-dismiss="modal"> \
                        ' + Resources.Global.Cancel + ' \
                    </button> \
                  </div> \
                </div> \
              </div> \
             </div>');

        var okClicked = false;
        
        $("#confirm-message-modal").modal("show");
        $("#confirm-message-modal").on("hidden.bs.modal", function () {
            $("#confirm-message-modal").remove();
            if(okClicked){
                callbackFunction();
                return;
            }
            if(cancelFunction !== null && cancelFunction !== undefined){
                cancelFunction();
            }
        });
        $("#modal-ok-button").click(function () {
            okClicked = true;
        });
    }
    function confirmModalOK(title, text, callbackFunction) {
        $("body").append('<div class="modal fade" id="confirm-message-modal" data-keyboard="false" data-backdrop="static"> \
              <div class="modal-dialog"> \
                <div class="modal-content"> \
                  <div class="modal-header"> \
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> \
                    <h4 class="modal-title">' + title + '</h4> \
                  </div> \
                  <div class="modal-body"> \
                    ' + text + ' \
                  </div> \
                  <div class="modal-footer"> \
                    <button id="modal-ok-button" type="button" class="btn btn-primary" data-dismiss="modal"> \
                        ' + Resources.Global.Ok + ' \
                    </button> \
                  </div> \
                </div> \
              </div> \
             </div>');

        $("#confirm-message-modal").modal("show");
        $("#confirm-message-modal").on("hidden.bs.modal", function () {
            $("#confirm-message-modal").remove();
            loadingApp.show();
            callbackFunction();
        });
    }

    function optionModalTimePicker(text, option1, option2, firstOptionFunction, secondOptionFunction, cancelFunction) {
        $("body").append(
            '<div class="modal fade" id="firmware-update-modal" data-keyboard="false" data-backdrop="static"> \
    <div class="modal-dialog"> \
        <div class="modal-content"> \
            <div class="modal-header"> \
                <h4 class="modal-title">Confirm Update Method</h4> \
            </div> \
            <div class="modal-body"> \
            ' + text +' \
                <div class="row" style="background-color: lightgrey; margin-bottom: 20px; cursor: pointer" id="now-row">\
                    <div style="margin-top: 30px; margin-bottom 20px">\
                        <div class="col-md-3">\
                            <input type="radio" id="now-radio" value="now">\
                            <label for="now-radio">NOW</label>\
                        </div>\
                        <div class="col-md-9">\
                            ' + option1 + '\
                        </div>\
                    </div>\
                </div>\
                <div class="row" style="background-color: lightgrey; cursor: pointer; margin-bottom: 15px" id="later-row">\
                    <div class="row" style="margin-top: 30px;">\
                        <div class="col-md-3">\
                            <input type="radio" id="later-radio" value="later">\
                            <label for="later-radio">LATER</label>\
                        </div>\
                        <div class="col-md-9">\
                            ' + option2 + '\
                        </div>\
                    </div>\
                    <div class="row" id="time-selector-div" style="margin-top: 20px;">\
                        <div class="col-md-4 col-md-offset-3" style="text-align: center">\
                            <div class="form-group">\
                                <input class="datepicker" data-provide="datepicker" id="date-picker" placeholder="DATE">\
                                <span class="glyphicon glyphicon-calendar"></span>\
                            </div> \
                        </div>\
                        <div class="col-md-4" style="text-align: center">\
                            <div class="form-group">\
                                <input class="datepicker clockpicker" id="time-picker" placeholder="TIME">\
                                <span class="glyphicon glyphicon-time"></span>\
                            </div>\
                        </div>\
                    </div>\
                </div>\
                    <span class="error-message" style="margin-bottom: 30px;" id="invalid"></span>\
                </div>\
            <div class="modal-footer"> \
                <button id="modal-cancel-button" type="button" class="btn red" data-dismiss="modal">Cancel</button> \
                <button id="submit-button" type="button" class="btn btn-primary">Submit</button> \
            </div> \
        </div>\
    </div> \
</div>');

        $("#now-row").css('background-color', "#0063be");
        $("#now-row").css('color', "white");
        $("#now-radio").prop('checked', true);
        $("#later-radio").prop('checked', false);
        $("#date-picker").prop('disabled', true);
        $("#time-picker").prop('disabled', true);

        $("#now-row").click(function(){
            if(!($("#now-radio").is(':checked'))){
                $("#now-radio").prop('checked', true);
                $("#later-radio").prop('checked', false);
                $("#date-picker").prop('disabled', true);
                $("#time-picker").prop('disabled', true);
                $("#now-row").css('background-color', "#0063be");
                $("#now-row").css('color', "white");
                $("#later-row").css('background-color', "lightgrey");
                $("#later-row").css('color', "black");
            }
            $("#invalid").hide();
        });

        $("#later-row").click(function(){
            if(!($("#later-radio").is(':checked'))){
                $("#later-radio").prop('checked', true);
                $("#now-radio").prop('checked', false);
                $("#date-picker").prop('disabled', false);
                $("#time-picker").prop('disabled', false);
                $("#later-row").css('background-color', "#0063be");
                $("#later-row").css('color', "white");
                $("#time-picker").css('color', "black");
                $("#date-picker").css('color', "black");
                $("#now-row").css('background-color', "lightgrey");
                $("#now-row").css('color', "black");
            }
            $("#invalid").hide();
        });

        $("#firmware-update-modal").modal("show");
        $("#firmware-update-modal").on("hidden.bs.modal", function () {
            $("#firmware-update-modal").remove();
        });

        $('.clockpicker').clockpicker({
            twelvehour: true,
            donetext: "OK",
            default: "now",
            placement: 'right'

        });

        $("#submit-button").click(function(){
            if($("#later-radio").is(':checked')) {
                var time = $("#time-picker").val();
                var date = $("#date-picker").val();
                var datetime = date + time;

                var extract = moment(datetime, "MM/DD/YYYYhh:mma", true).format();
                var extractUtc = moment.utc(extract);

                if (!date.length > 0 || !time.length > 0) {
                    $("#invalid").text(Resources.Global.DateTimeRequiredError);
                    $("#invalid").show();
                }
                else if (!extractUtc.isSameOrBefore((moment().add(2, 'weeks')))) {
                    $("#invalid").text(Resources.Global.TwoWeeksError);
                    $("#invalid").show();
                }
                else if (extractUtc.isSameOrBefore(moment())){
                    $("#invalid").text(Resources.Global.SchedulePastError);
                    $("#invalid").show();
                }
                else {
                    $("#firmware-update-modal").modal("hide");
                    secondOptionFunction(extractUtc.unix());
                }
            }
            else{
                $("#firmware-update-modal").modal("hide");
                firstOptionFunction();
            }
        });

        if (cancelFunction !== null && cancelFunction !== undefined) {
            $("#modal-cancel-button").click(function () {
                cancelFunction();
            });
        }
    }
    
    function edgegwModal(text, option1, option1Text, option2, option2Text, clear, firstOptionFunction, secondOptionFunction, cancelFunction) {
        let modalHtml =
            '<div class="modal fade" id="firmware-update-modal" data-keyboard="false" data-backdrop="static"> \
    <div class="modal-dialog"> \
        <div class="modal-content"> \
            <div class="modal-header"> \
                <h4 class="modal-title">Confirm Update Method</h4> \
            </div> \
            <div class="modal-body"> \
            ' + text +' \
                <div class="row" style="background-color: lightgrey; margin-bottom: 20px; cursor: pointer" id="now-row">\
                    <div style="margin-top: 30px; margin-bottom: 20px">\
                        <div class="col-md-2">\
                            <input type="radio" id="now-radio" value="now">\
                            <label for="now-radio" id="now-label"></label>\
                        </div>\
                        <div class="col-md-9" style="margin-left: 15px;">\
                            ' + option1Text + '\
                        </div>\
                    </div>\
                </div>';

        if (option2) {
            modalHtml +=
                '<div class="row" style="background-color: lightgrey; cursor: pointer; margin-bottom: 20px" id="later-row">\
                   <div class="row" style="margin-top: 30px; margin-bottom: 20px">\
                       <div class="col-md-2">\
                           <input type="radio" id="later-radio" value="later">\
                           <label for="later-radio" id="later-label"></label>\
                       </div>\
                       <div class="col-md-9" style="margin-left: 15px;">\
                           ' + option2Text + '\
                        </div>\
                    </div>\
                </div>';
        }

        modalHtml +=
            '<span class="error-message" style="margin-bottom: 30px;" id="invalid"></span>\
    </div>\
    <div class="modal-footer"> \
        <button id="modal-cancel-button" type="button" class="btn red" data-dismiss="modal">Cancel</button> \
        <button id="submit-button" type="button" class="btn btn-primary">Submit</button> \
    </div> \
</div>\
</div> \
</div>';


        $("body").append(modalHtml);

        $("#now-label").text(option1);
        $("#now-row").css('background-color', "#0063be");
        $("#now-row").css('color', "white");
        $("#now-radio").prop('checked', true);

        $("#now-row").click(function(){
            if(!($("#now-radio").is(':checked'))){
                $("#now-radio").prop('checked', true);
                $("#later-radio").prop('checked', false);
                $("#now-row").css('background-color', "#0063be");
                $("#now-row").css('color', "white");
                $("#later-row").css('background-color', "lightgrey");
                $("#later-row").css('color', "black");
            }
            $("#invalid").hide();
        });

        if (option2)
        {
            $("#later-label").text(option2);
            $("#later-radio").prop('checked', false);

            $("#later-row").click(function(){
                if(!($("#later-radio").is(':checked'))){
                    $("#later-radio").prop('checked', true);
                    $("#now-radio").prop('checked', false);
                    $("#later-row").css('background-color', "#0063be");
                    $("#later-row").css('color', "white");
                    $("#now-row").css('background-color', "lightgrey");
                    $("#now-row").css('color', "black");
                }
                $("#invalid").hide();
            });
        }

        $("#firmware-update-modal").modal("show");
        $("#firmware-update-modal").on("hidden.bs.modal", function () {
            $("#firmware-update-modal").remove();
        });

        $("#submit-button").click(function(){
            if(option2 && $("#later-radio").is(':checked')) {
                if(!clear){
                    $("#invalid").text(Resources.Global.NoClearGatewayError);
                    $("#invalid").show();
                }
                else {
                    $("#firmware-update-modal").modal("hide");
                    secondOptionFunction();
                }
            }
            else{
                $("#firmware-update-modal").modal("hide");
                firstOptionFunction();
            }
        });

        if (cancelFunction !== null && cancelFunction !== undefined) {
            $("#modal-cancel-button").click(function () {
                cancelFunction();
            });
        }
    }

    function alertError(jsonString) {
        var json;
        try {
            json = $.parseJSON(jsonString);
        }
        catch (err) {
            modalError(Resources.Global.Error, Resources.Global.UnknownErrorOccured);
            return;
        }

        errorJson(json);
    }

    function errorJson(json) {
        modalError(Resources.Global.Error, parseModelState(json));
    }

    function parseModelState(json) {
        var errors = [];
        if (json) {
            var modelState = json.ModelState;
            if (!modelState || modelState.length === 0) {

                if (json.Message !== undefined && json.Message !== null) {
                    errors.push(json.Message);
                } else {
                    errors.push(Resources.Global.InternalServerError);
                }
            } else {
                for (var key in modelState) {
                    if (modelState.hasOwnProperty(key)) {
                        for (var i = 0; i < modelState[key].length; i++) {
                            errors.push(modelState[key][i]);
                        }
                    }
                }
            }
        }
        else {
            errors.push(Resources.Global.InternalServerError);
        }

        return errors.join("<br/>");
    }

    function modalError(title, errorMessage, append = true) {

        // if the error message is not there , we update the generic message
        if (errorMessage.length === 0)
            errorMessage = Resources.Global.InternalServerError;

        console.log($('#error-message-modal'));
        if ($('#error-message-modal').length === 0) {
            createModalError(title, errorMessage);
        } else {
            if(append){
                appendModalError(errorMessage);
            } else {
                createModalError(title, errorMessage);
            }
        }
    }

    function createModalError(title, errorMessage) {
        $("body").append('<div class="modal fade" id="error-message-modal"> \
              <div class="modal-dialog"> \
                <div class="modal-content"> \
                  <div class="modal-header"> \
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> \
                    <h4 class="modal-title">' + title + '</h4> \
                  </div> \
                  <div class="modal-body"> \
                    ' + errorMessage + ' \
                  </div> \
                  <div class="modal-footer"> \
                    <button id="modal-ok-button" type="button" class="btn btn-primary" data-dismiss="modal"> \
                        ' + Resources.Global.Ok + ' \
                    </button> \
                  </div> \
                </div> \
              </div> \
             </div>');

        $("#error-message-modal").modal("show");
        var disableHrefs = ['ADD', 'Add', 'IMPORT', 'Import'];
        disableHrefs.forEach(function (href) {
            $(".main a:contains(" + href + ")[href='javascript:void(0)']").removeAttr("href")
        });
        $("button :not(#modal-ok-button)").addClass("disabled");
        $("#error-message-modal").on("hidden.bs.modal", function () {
            disableHrefs.forEach(function (href) {
                $(".main a:contains(" + href + ")[href='']").attr("href", "javascript:void(0)")
            });
            $("button :not(#modal-ok-button)").removeClass("disabled");
            $("#error-message-modal").remove();
        });
    }

    function appendModalError(errorMessage) {
        var domElement = $("#error-message-modal .modal-body");
        var bodyContents = domElement.html() + '<p>' + errorMessage + '</p>';
        domElement.html(bodyContents);
    }

    function checkBoxLimiter(listId, limit) {
        $(listId + " input").change(function () {
            limitCheck(listId, limit);
        });

        limitCheck(listId, limit);
    }

    function limitCheck(listId, limit) {
        var checked = $(listId + " input:checked").not("[data-item='all']").length;

        if (checked >= limit) {
            $(listId + " input:checkbox:not(:checked)").not("[data-item='all']").prop("disabled", "disabled");
            $(listId + " input:checkbox:not(:checked)").not("[data-item='all']").addClass("disabled");
        } else {
            $(listId + " input:checkbox:not(:checked)").not("[data-item='all']").prop("disabled", "");
            $(listId + " input:checkbox:not(:checked)").not("[data-item='all']").removeClass("disabled");
        }
    }

    function selectErrorPanel() {
        // Get the first validation error DOM that isn't empty
        var errorDom = $(".field-validation-error:parent").first();
        if (errorDom.length > 0) {
            var panelId = errorDom.closest(".wizard-panel").attr("id");
            if (panelId) {
                showWizardPanel(panelId);
            }
        }
    }

    function showWizardPanel(id) {
        $(".wizard-panel").hide();
        $("#" + id).show();
    }

    function submitFormWithModifiedCheck(reportStatus) {
        loadingApp.show();
        
        const noChangesElement = $("#noChangesErrorMessage");
        const deviceFormElement = $("#deviceForm");
        noChangesElement.addClass("hidden");
        let changes = true;

        if (reportStatus) { // used for tlk and keystone -> update these properties before reflecting on serialized elements
            var reportStatusSelectedValues = [];
            $("[id$=reportStatus-desired]").filter(":checked").each(function () {
                reportStatusSelectedValues.push($(this).data("reportstatusdesired"));
            });
            var reportStatusValue = reportStatusSelectedValues.join('|');
            $("#Configuration_Desired_ReportStatus").val(reportStatusValue);

            var reportStatusExtValue = 0;
            $("[id$=reportStatusExt-desired]").filter(":checked").each(function () {
                var idx = parseInt($(this).data("reportstatusextdesired"));

                reportStatusExtValue += Math.pow(2, idx);
            });
            $("#Configuration_Desired_ReportStatusExt").val(reportStatusExtValue);

        }


        var extendedConfigMenu = 0;
        if ($("#extendedConfigMenuContactsToggle").filter(":checked").length > 0)
            extendedConfigMenu += 1;
        if ($("#extendedConfigMenuSpeakerToggle").filter(":checked").length > 0)
            extendedConfigMenu += 2;
        $("#Configuration_Desired_ConfigMenu_ExtendedConfigMenu").val(extendedConfigMenu);

        $("#Configuration_Desired_Eva_Cfg").val($("#evaCfgToggle").is(":checked") ? 1 : 0);

        if (deviceFormElement.serialize() === deviceFormElement.data("serialize")) {
            noChangesElement.removeClass("hidden");
            loadingApp.hide();
            changes = false;
        }
        
        var reportStatusSecs = $("#desired_reportStatusSecs").val();
        if (reportStatusSecs < 60 || reportStatusSecs > 10000) {
            $("#validation_reportStatusSecs").removeClass("hidden");
            loadingApp.hide();
            changes = false;
            return;
        } else {
            $("#validation_reportStatusSecs").addClass("hidden");
        }

        
        if (changes === true) {
            deviceFormElement.submit();
        }
    }

    function confirmSubmitFormWithModifiedCheck(reportStatus, confirmText, onConfirm, onCancel) {
        confirmModal(confirmText, function() {
            onConfirm();
            submitFormWithModifiedCheck(reportStatus);
        },
        function () {
            onCancel();
        });
    }

    function showEdgeGatewayModalPopup(forceAction, migrateAction) {
        var confirmation = Resources.Global.UpdateEdgegwConfirmation + "<br/><br/>";
        var forceText = Resources.Global.UpdateEdgegwForce + "<br/><br/>";
        var migrateText = Resources.Global.UpdateEdgegwMigrate;

        loadingApp.hide();

        var clear = $('#isClearEdgeGwPresent').val();
        edgegwModal(confirmation, Resources.Global.Force, forceText, Resources.Global.Migrate, migrateText, clear, forceAction, migrateAction);
    }

    async function submitEdgegwFormWithModifiedCheck() {
        loadingApp.show();
        var noChangesElement = $("#noChangesErrorMessage");
        var validationErrorElement = $("#validationErrorMessage");
        var deviceFormElement = $("#deviceForm");
        noChangesElement.addClass("hidden");
        validationErrorElement.addClass("hidden");
        var changes = true;

        if (deviceFormElement.serialize() === deviceFormElement.data("serialize")) {
            noChangesElement.removeClass("hidden");
            loadingApp.hide();
            changes = false;
        }
        
        if(changes === true) {
            showEdgeGatewayModalPopup(function () {
                deviceFormElement.submit();
            }, function () {
                var force = document.getElementById('force');
                $(force).val(false);
                deviceFormElement.submit();
            });
        }
    }

    //To get the active running task
    function getRunningTaskStatus(controller, link, userid, username, taskname) {
        loadingApp.show();
        utilitiesApp.ajaxSetup();
        $.post(controller + "/runningtaskstatus", {
            userid: userid,
            username: escape(username),
            taskname: taskname
        }).always(function (data) {
            loadingApp.hide();
            if (data.match('<!DOCTYPE html>') !== null) {
                utilitiesApp.modal(Resources.Global.Error, Resources.Global.UnableToProcessRequest);
            }
            else if (data !== '') {
                utilitiesApp.modal(Resources.Global.TaskInProgress, data.replace(/["]/g, ""));
            } else {
                loadingApp.show();
                window.location.href = link;
            }
        }).fail(function () {
            loadingApp.hide();
        });
    }

    function getWpaPskKeyFromPassphrase(pass, salt) {
        /* pad string to 64 bytes and convert to 16 32-bit words */
        function stringtowords(s, padi) {
            /* return a 80-word array for later use in the SHA1 code */
            var z = new Array(80);
            var j = -1, k = 0;
            var n = s.length;
            for (var i = 0; i < 64; i++) {
                var c = 0;
                if (i < n) {
                    c = s.charCodeAt(i);
                } else if (padi) {
                    /* add 4-byte PBKDF2 block index and
                   standard padding for the final SHA1 input block */
                    if (i == n) c = (padi >>> 24) & 0xff;
                    else if (i == n + 1) c = (padi >>> 16) & 0xff;
                    else if (i == n + 2) c = (padi >>> 8) & 0xff;
                    else if (i == n + 3) c = padi & 0xff;
                    else if (i == n + 4) c = 0x80;
                }
                if (k == 0) {
                    j++;
                    z[j] = 0;
                    k = 32;
                }
                k -= 8;
                z[j] = z[j] | (c << k);
            }
            if (padi) z[15] = 8 * (64 + n + 4);


            return z;
        }

        /* compute the intermediate SHA1 state after processing just
        the 64-byte padded HMAC key */
        function initsha(w, padbyte) {
            var pw = (padbyte << 24) | (padbyte << 16) | (padbyte << 8) | padbyte;
            for (var t = 0; t < 16; t++) w[t] ^= pw;
            var s = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0];
            var a = s[0], b = s[1], c = s[2], d = s[3], e = s[4];
            var t;
            for (var k = 16; k < 80; k++) {
                t = w[k - 3] ^ w[k - 8] ^ w[k - 14] ^ w[k - 16];
                w[k] = (t << 1) | (t >>> 31);
            }
            for (var k = 0; k < 20; k++) {
                t = ((a << 5) | (a >>> 27)) + e + w[k] + 0x5A827999 + ((b & c) | ((~b) & d));
                e = d;
                d = c;
                c = (b << 30) | (b >>> 2);
                b = a;
                a = t & 0xffffffff;
            }
            for (var k = 20; k < 40; k++) {
                t = ((a << 5) | (a >>> 27)) + e + w[k] + 0x6ED9EBA1 + (b ^ c ^ d);
                e = d;
                d = c;
                c = (b << 30) | (b >>> 2);
                b = a;
                a = t & 0xffffffff;
            }
            for (var k = 40; k < 60; k++) {
                t = ((a << 5) | (a >>> 27)) + e + w[k] + 0x8F1BBCDC + ((b & c) | (b & d) | (c & d));
                e = d;
                d = c;
                c = (b << 30) | (b >>> 2);
                b = a;
                a = t & 0xffffffff;
            }
            for (var k = 60; k < 80; k++) {
                t = ((a << 5) | (a >>> 27)) + e + w[k] + 0xCA62C1D6 + (b ^ c ^ d);
                e = d;
                d = c;
                c = (b << 30) | (b >>> 2);
                b = a;
                a = t & 0xffffffff;
            }
            s[0] = (s[0] + a) & 0xffffffff;
            s[1] = (s[1] + b) & 0xffffffff;
            s[2] = (s[2] + c) & 0xffffffff;
            s[3] = (s[3] + d) & 0xffffffff;
            s[4] = (s[4] + e) & 0xffffffff;
            return s;
        }

        /* compute the intermediate SHA1 state of the inner and outer parts
           of the HMAC algorithm after processing the padded HMAC key */
        var hmac_istate = initsha(stringtowords(pass, 0), 0x36);
        var hmac_ostate = initsha(stringtowords(pass, 0), 0x5c);

        /* output is created in blocks of 20 bytes at a time and collected
           in a string as hexadecimal digits */
        var hash = '';
        var i = 0;
        while (hash.length < 64) {
            /* prepare 20-byte (5-word) output vector */
            var u = [0, 0, 0, 0, 0];
            /* prepare input vector for the first SHA1 update (salt + block number) */
            i++;
            var w = stringtowords(salt, i);
            /* iterate 4096 times an inner and an outer SHA1 operation */
            for (var j = 0; j < 2 * 4096; j++) {
                /* alternate inner and outer SHA1 operations */
                var s = (j & 1) ? hmac_ostate : hmac_istate;
                /* inline the SHA1 update operation */
                var a = s[0], b = s[1], c = s[2], d = s[3], e = s[4];
                var t;
                for (var k = 16; k < 80; k++) {
                    t = w[k - 3] ^ w[k - 8] ^ w[k - 14] ^ w[k - 16];
                    w[k] = (t << 1) | (t >>> 31);
                }
                for (var k = 0; k < 20; k++) {
                    t = ((a << 5) | (a >>> 27)) + e + w[k] + 0x5A827999 + ((b & c) | ((~b) & d));
                    e = d;
                    d = c;
                    c = (b << 30) | (b >>> 2);
                    b = a;
                    a = t & 0xffffffff;
                }
                for (var k = 20; k < 40; k++) {
                    t = ((a << 5) | (a >>> 27)) + e + w[k] + 0x6ED9EBA1 + (b ^ c ^ d);
                    e = d;
                    d = c;
                    c = (b << 30) | (b >>> 2);
                    b = a;
                    a = t & 0xffffffff;
                }
                for (var k = 40; k < 60; k++) {
                    t = ((a << 5) | (a >>> 27)) + e + w[k] + 0x8F1BBCDC + ((b & c) | (b & d) | (c & d));
                    e = d;
                    d = c;
                    c = (b << 30) | (b >>> 2);
                    b = a;
                    a = t & 0xffffffff;
                }
                for (var k = 60; k < 80; k++) {
                    t = ((a << 5) | (a >>> 27)) + e + w[k] + 0xCA62C1D6 + (b ^ c ^ d);
                    e = d;
                    d = c;
                    c = (b << 30) | (b >>> 2);
                    b = a;
                    a = t & 0xffffffff;
                }
                /* stuff the SHA1 output back into the input vector */
                w[0] = (s[0] + a) & 0xffffffff;
                w[1] = (s[1] + b) & 0xffffffff;
                w[2] = (s[2] + c) & 0xffffffff;
                w[3] = (s[3] + d) & 0xffffffff;
                w[4] = (s[4] + e) & 0xffffffff;
                if (j & 1) {
                    /* XOR the result of each complete HMAC-SHA1 operation into u */
                    u[0] ^= w[0];
                    u[1] ^= w[1];
                    u[2] ^= w[2];
                    u[3] ^= w[3];
                    u[4] ^= w[4];
                } else if (j == 0) {
                    /* pad the new 20-byte input vector for subsequent SHA1 operations */
                    w[5] = 0x80000000;
                    for (var k = 6; k < 15; k++) w[k] = 0;
                    w[15] = 8 * (64 + 20);
                }
            }
            /* convert output vector u to hex and append to output string */
            for (var j = 0; j < 5; j++)
                for (var k = 0; k < 8; k++) {
                    var t = (u[j] >>> (28 - 4 * k)) & 0x0f;
                    hash += (t < 10) ? t : String.fromCharCode(87 + t);
                }
        }

        /* return the first 32 key bytes as a hexadecimal string */
        return hash.substring(0, 64);
    }

    function ajaxSetup() {
        return $.ajaxSetup({ headers: generateAntiForgeryHeaders() });
    }

    function generateAntiForgeryHeaders(){
        let token = $('input[name="__RequestVerificationToken"]').val();
        let headers = {}; 
        headers['__RequestVerificationToken'] = token;
        
        return headers;
    }
    
    function checkRedirectErrorResponse({response = "", vue = false} = {}){
        if(response.status === 503){
            if(vue !== false) {
                vue.errorThrown = true;
            }
            
            if(response.body) {
                window.location.href = response.body.redirect;
            }
            else if(response.responseJSON) {
                window.location.href = response.responseJSON.redirect
            }
            else {
                window.location.href = '/Home/Error';
            }
            
            return true;
        }
        if(response.status === 401){
            if(vue !== false) {
                vue.errorThrown = true;
            }
            location.href = "/Home/Unauthorized";
            return true; 
        }
        return false;
    }

    function timerUpdateJwt(path, jwtTenantId) {
        var isPresentation = path.startsWith("/Presentation");
        var isExpired = path.includes("Account/Expired");
        clearInterval(jwtRefreshInterval);
        if(!isExpired)
        {
            updateJwt(isPresentation, jwtTenantId, false);
            jwtRefreshInterval = setInterval(function(){
                updateJwt(isPresentation, jwtTenantId, true)
            }, 25 * 60 * 1000); // 25 minute interval
        }
    }

    function updateJwt(isPresentation, jwtTenantId, isAsync) {
        $.ajax({
            url: (isPresentation ? "/Presentation" : "") + "/Jwt/Update?tenantId=" + jwtTenantId,
            type: "get",
            async: isAsync,
            success: function (data) {
            },
            error: function (data) {
                if(data.status !== 401) {
                    //if the data.status is 401 the user is on the Unauthorized page, we don't want to navigate to the 
                    //expired page if that is the case
                    window.location.replace((isPresentation ? "/Presentation" : "") + "/Account/Expired");
                }
            }
        });
    }
    
    function getRegionFromLongitude(longitude){
        // add more logic checks when nitro region checks are more granular
        if (longitude >= -167 && longitude <= -53){
            return "us";
        } else {
            return "uk";
        }
    }

    function geoSuccess(pos) {
        var region = getRegionFromLongitude(pos.coords.longitude);
        document.cookie =  'browser_region=' + region + '; expires=Sun, 01 Jan 2040 00:00:00 UTC; path=/';
    }

    function getError(err) {
        console.warn(`ERROR(${err.code}): ${err.message}`);
    }
    
    function setBrowserLocation(){
        if ("geolocation" in navigator) {
            var options = {
                enableHighAccuracy: false,
                timeout: 10000,
                maximumAge: 0
            };
            navigator.geolocation.getCurrentPosition(geoSuccess, getError, options);
        }
    }
    
    function displayCeErrorResponse(errorList) {
        var errorMessage = "";
        errorList.forEach(error => errorMessage += error + '<br>');
        
        return errorMessage;
    }

    /***************************************************************************************
     *    Title: Debounce
     *    Author: David Walsh
     *    Availability: https://gist.github.com/treyhuffine/d628c0cd2e7d25f829159e08c29e92c0#file-debounce-description-js
     ***************************************************************************************/
    function debounce(func, wait, immediate) {
        var timeout;

        return function executedFunction() {
            var context = this;
            var args = arguments;

            var later = function() {
                timeout = null;
                if (!immediate) func.apply(context, args);
            };

            var callNow = immediate && !timeout;

            clearTimeout(timeout);

            timeout = setTimeout(later, wait);

            if (callNow) func.apply(context, args);
        };
    }
    
    return {
        readonly: initializeReadOnly,
        checkToggle: checkBoxToggle,
        checkDefault: checkBoxToggleWithDefault,
        checkOpposite: checkBoxToggleWithOpposite,
        dropDown: dropDownToggle,
        escape: escapeHtml,
        escapeJson: escapeJson,
        jsEscape: jsEscape,
        allChecked: toggleAllChecked,
        confirm: confirmModal,
        ConfirmOK: confirmModalOK,
        confirminfo: confirmInfoModal,
        confirminfos: confirmInfoModals,
        edgegwModal: edgegwModal,
        error: alertError,
        modelState: parseModelState,
        jsonError: errorJson,
        modal: modalError,
        getValue: getValueWithDefault,
        limitCheckbox: checkBoxLimiter,
        selectErrorPanel: selectErrorPanel,
        int: isInt,
        date: formatDate,
        ticks: getTicks,
        submitFormWithCheck: submitFormWithModifiedCheck,
        confirmSubmitFormWithCheck: confirmSubmitFormWithModifiedCheck,
        submitEdgegwFormWithModifiedCheck: submitEdgegwFormWithModifiedCheck,
        hashPassword: getWpaPskKeyFromPassphrase,
        optionModalTimePicker: optionModalTimePicker,
        getRunningTaskStatus: getRunningTaskStatus,
        showEdgeGatewayModalPopup: showEdgeGatewayModalPopup,
        generateAntiForgeryHeaders: generateAntiForgeryHeaders,
        ajaxSetup: ajaxSetup,
        checkRedirectErrorResponse: checkRedirectErrorResponse,
        timerUpdateJwt: timerUpdateJwt,
        setBrowserLocation: setBrowserLocation,
        displayCeErrorResponse: displayCeErrorResponse,
        debounce: debounce
    };
}());;
