var bind=function(n,t){return function(){return n.apply(t,arguments)}};!function(n,t){"function"==typeof define&&define.amd?define(["jquery"],function(i){return n.Tour=t(i)}):"object"==typeof exports?module.exports=t(require("jquery")):n.Tour=t(n.jQuery)}(window,function(n){var t;return t=window.document,function(){function i(t){this._showPopoverAndOverlay=bind(this._showPopoverAndOverlay,this);var i;try{i=window.localStorage}catch(n){i=!1}this._options=n.extend({name:"tour",steps:[],container:"body",autoscroll:!0,keyboard:!0,storage:i,debug:!1,backdrop:!1,backdropContainer:"body",backdropPadding:0,redirect:!0,orphan:!1,duration:!1,delay:!1,basePath:"",template:'<div class="popover" role="tooltip"> <div class="arrow"><\/div> <h3 class="popover-title"><\/h3> <div class="popover-content"><\/div> <div class="popover-navigation"> <div class="btn-group"> <button class="btn btn-sm btn-default" data-role="prev">&laquo; Prev<\/button> <button class="btn btn-sm btn-default" data-role="next">Next &raquo;<\/button> <button class="btn btn-sm btn-default" data-role="pause-resume" data-pause-text="Pause" data-resume-text="Resume">Pause<\/button> <\/div> <button class="btn btn-sm btn-default" data-role="end">End tour<\/button> <\/div> <\/div>',afterSetState:function(){},afterGetState:function(){},afterRemoveState:function(){},onStart:function(){},onEnd:function(){},onShow:function(){},onShown:function(){},onHide:function(){},onHidden:function(){},onNext:function(){},onPrev:function(){},onPause:function(){},onResume:function(){},onRedirectError:function(){}},t);this._force=!1;this._inited=!1;this._current=null;this.backdrops=[]}return i.prototype.addSteps=function(n){for(var r,t=0,i=n.length;t<i;t++)r=n[t],this.addStep(r);return this},i.prototype.addStep=function(n){return this._options.steps.push(n),this},i.prototype.getStep=function(t){if(null!=this._options.steps[t])return n.extend({id:"step-"+t,path:"",host:"",placement:"right",title:"",content:"<p><\/p>",next:t===this._options.steps.length-1?-1:t+1,prev:t-1,animation:!0,container:this._options.container,autoscroll:this._options.autoscroll,backdrop:this._options.backdrop,backdropContainer:this._options.backdropContainer,backdropPadding:this._options.backdropPadding,redirect:this._options.redirect,reflexElement:this._options.steps[t].element,backdropElement:this._options.steps[t].element,orphan:this._options.orphan,duration:this._options.duration,delay:this._options.delay,template:this._options.template,onShow:this._options.onShow,onShown:this._options.onShown,onHide:this._options.onHide,onHidden:this._options.onHidden,onNext:this._options.onNext,onPrev:this._options.onPrev,onPause:this._options.onPause,onResume:this._options.onResume,onRedirectError:this._options.onRedirectError},this._options.steps[t])},i.prototype.init=function(n){return this._force=n,this.ended()?(this._debug("Tour ended, init prevented."),this):(this.setCurrentStep(),this._initMouseNavigation(),this._initKeyboardNavigation(),this._onResize(function(n){return function(){return n.showStep(n._current)}}(this)),this._onScroll(function(n){return function(){return n._showPopoverAndOverlay(n._current)}}(this)),null!==this._current&&this.showStep(this._current),this._inited=!0,this)},i.prototype.start=function(n){var t;return null==n&&(n=!1),this._inited||this.init(n),null===this._current&&(t=this._makePromise(null!=this._options.onStart?this._options.onStart(this):void 0),this._callOnPromiseDone(t,this.showStep,0)),this},i.prototype.next=function(){var n;return n=this.hideStep(this._current,this._current+1),this._callOnPromiseDone(n,this._showNextStep)},i.prototype.prev=function(){var n;return n=this.hideStep(this._current,this._current-1),this._callOnPromiseDone(n,this._showPrevStep)},i.prototype.goTo=function(n){var t;return t=this.hideStep(this._current,n),this._callOnPromiseDone(t,this.showStep,n)},i.prototype.end=function(){var i,r;return i=function(i){return function(){if(n(t).off("click.tour-"+i._options.name),n(t).off("keyup.tour-"+i._options.name),n(window).off("resize.tour-"+i._options.name),n(window).off("scroll.tour-"+i._options.name),i._setState("end","yes"),i._inited=!1,i._force=!1,i._clearTimer(),null!=i._options.onEnd)return i._options.onEnd(i)}}(this),r=this.hideStep(this._current),this._callOnPromiseDone(r,i)},i.prototype.ended=function(){return!this._force&&!!this._getState("end")},i.prototype.restart=function(){return this._removeState("current_step"),this._removeState("end"),this._removeState("redirect_to"),this.start()},i.prototype.pause=function(){var n;return(n=this.getStep(this._current))&&n.duration?(this._paused=!0,this._duration-=(new Date).getTime()-this._start,window.clearTimeout(this._timer),this._debug("Paused/Stopped step "+(this._current+1)+" timer ("+this._duration+" remaining)."),null!=n.onPause?n.onPause(this,this._duration):void 0):this},i.prototype.resume=function(){var n;return(n=this.getStep(this._current))&&n.duration?(this._paused=!1,this._start=(new Date).getTime(),this._duration=this._duration||n.duration,this._timer=window.setTimeout(function(n){return function(){return n._isLast()?n.next():n.end()}}(this),this._duration),this._debug("Started step "+(this._current+1)+" timer with duration "+this._duration),null!=n.onResume&&this._duration!==n.duration?n.onResume(this,this._duration):void 0):this},i.prototype.hideStep=function(t,i){var u,e,f,r;if(r=this.getStep(t))return this._clearTimer(),f=this._makePromise(null!=r.onHide?r.onHide(this,t):void 0),e=function(u){return function(){var f,e;if((f=n(r.element)).data("bs.popover")||f.data("popover")||(f=n("body")),f.popover("destroy").removeClass("tour-"+u._options.name+"-element tour-"+u._options.name+"-"+t+"-element").removeData("bs.popover"),r.reflex&&n(r.reflexElement).removeClass("tour-step-element-reflex").off(u._reflexEvent(r.reflex)+".tour-"+u._options.name),r.backdrop&&((e=null!=i&&u.getStep(i))&&e.backdrop&&e.backdropElement===r.backdropElement||u._hideOverlayElement(r)),null!=r.onHidden)return r.onHidden(u)}}(this),u=r.delay.hide||r.delay,"[object Number]"==={}.toString.call(u)&&u>0?(this._debug("Wait "+u+" milliseconds to hide the step "+(this._current+1)),window.setTimeout(function(n){return function(){return n._callOnPromiseDone(f,e)}}(this),u)):this._callOnPromiseDone(f,e),f},i.prototype.showStep=function(n){var u,f,r,e,o,i;return this.ended()?(this._debug("Tour ended, showStep prevented."),this):(i=this.getStep(n))&&(o=n<this._current,f=this._makePromise(null!=i.onShow?i.onShow(this,n):void 0),this.setCurrentStep(n),u=function(){switch({}.toString.call(i.path)){case"[object Function]":return i.path();case"[object String]":return this._options.basePath+i.path;default:return i.path}}.call(this),!i.redirect||!this._isRedirect(i.host,u,t.location)||(this._redirect(i,n,u),this._isJustPathHashDifferent(i.host,u,t.location)))?(e=function(t){return function(){if(t._isOrphan(i)){if(!1===i.orphan)return t._debug("Skip the orphan step "+(t._current+1)+".\nOrphan option is false and the element does not exist or is hidden."),void(o?t._showPrevStep():t._showNextStep());t._debug("Show the orphan step "+(t._current+1)+". Orphans option is true.")}if(i.autoscroll?t._scrollIntoView(n):t._showPopoverAndOverlay(n),i.duration)return t.resume()}}(this),r=i.delay.show||i.delay,"[object Number]"==={}.toString.call(r)&&r>0?(this._debug("Wait "+r+" milliseconds to show the step "+(this._current+1)),window.setTimeout(function(n){return function(){return n._callOnPromiseDone(f,e)}}(this),r)):this._callOnPromiseDone(f,e),f):void 0},i.prototype.getCurrentStep=function(){return this._current},i.prototype.setCurrentStep=function(n){return null!=n?(this._current=n,this._setState("current_step",n)):(this._current=this._getState("current_step"),this._current=null===this._current?null:parseInt(this._current,10)),this},i.prototype.redraw=function(){return this._showOverlayElement(this.getStep(this.getCurrentStep()))},i.prototype._setState=function(n,t){var i;if(this._options.storage){i=this._options.name+"_"+n;try{this._options.storage.setItem(i,t)}catch(n){n.code===DOMException.QUOTA_EXCEEDED_ERR&&this._debug("LocalStorage quota exceeded. State storage failed.")}return this._options.afterSetState(i,t)}return null==this._state&&(this._state={}),this._state[n]=t},i.prototype._removeState=function(n){var t;return this._options.storage?(t=this._options.name+"_"+n,this._options.storage.removeItem(t),this._options.afterRemoveState(t)):null!=this._state?delete this._state[n]:void 0},i.prototype._getState=function(n){var i,t;return this._options.storage?(i=this._options.name+"_"+n,t=this._options.storage.getItem(i)):null!=this._state&&(t=this._state[n]),void 0!==t&&"null"!==t||(t=null),this._options.afterGetState(n,t),t},i.prototype._showNextStep=function(){var t,i,n;return n=this.getStep(this._current),i=function(t){return function(){return t.showStep(n.next)}}(this),t=this._makePromise(null!=n.onNext?n.onNext(this):void 0),this._callOnPromiseDone(t,i)},i.prototype._showPrevStep=function(){var t,i,n;return n=this.getStep(this._current),i=function(t){return function(){return t.showStep(n.prev)}}(this),t=this._makePromise(null!=n.onPrev?n.onPrev(this):void 0),this._callOnPromiseDone(t,i)},i.prototype._debug=function(n){if(this._options.debug)return window.console.log("Bootstrap Tour '"+this._options.name+"' | "+n)},i.prototype._isRedirect=function(n,t,i){var r;return!(null==n||""===n||!("[object RegExp]"==={}.toString.call(n)&&!n.test(i.origin)||"[object String]"==={}.toString.call(n)&&this._isHostDifferent(n,i)))||(r=[i.pathname,i.search,i.hash].join(""),null!=t&&""!==t&&("[object RegExp]"==={}.toString.call(t)&&!t.test(r)||"[object String]"==={}.toString.call(t)&&this._isPathDifferent(t,r)))},i.prototype._isHostDifferent=function(n,t){switch({}.toString.call(n)){case"[object RegExp]":return!n.test(t.origin);case"[object String]":return this._getProtocol(n)!==this._getProtocol(t.href)||this._getHost(n)!==this._getHost(t.href);default:return!0}},i.prototype._isPathDifferent=function(n,t){return this._getPath(n)!==this._getPath(t)||!this._equal(this._getQuery(n),this._getQuery(t))||!this._equal(this._getHash(n),this._getHash(t))},i.prototype._isJustPathHashDifferent=function(n,t,i){var r;return(null==n||""===n||!this._isHostDifferent(n,i))&&(r=[i.pathname,i.search,i.hash].join(""),"[object String]"==={}.toString.call(t)&&this._getPath(t)===this._getPath(r)&&this._equal(this._getQuery(t),this._getQuery(r))&&!this._equal(this._getHash(t),this._getHash(r)))},i.prototype._redirect=function(i,r,u){var f;return n.isFunction(i.redirect)?i.redirect.call(this,u):(f="[object String]"==={}.toString.call(i.host)?""+i.host+u:u,this._debug("Redirect to "+f),this._getState("redirect_to")!==""+r?(this._setState("redirect_to",""+r),t.location.href=f):(this._debug("Error redirection loop to "+u),this._removeState("redirect_to"),null!=i.onRedirectError?i.onRedirectError(this):void 0))},i.prototype._isOrphan=function(t){return null==t.element||!n(t.element).length||n(t.element).is(":hidden")&&"http://www.w3.org/2000/svg"!==n(t.element)[0].namespaceURI},i.prototype._isLast=function(){return this._current<this._options.steps.length-1},i.prototype._showPopoverAndOverlay=function(n){var t;if(this.getCurrentStep()===n&&!this.ended())return(t=this.getStep(n)).backdrop&&this._showOverlayElement(t),this._showPopover(t,n),null!=t.onShown&&t.onShown(this),this._debug("Step "+(this._current+1)+" of "+this._options.steps.length)},i.prototype._showPopover=function(t,i){var r,u,f,e,o;if(n(".tour-"+this._options.name).remove(),e=n.extend({},this._options),f=this._isOrphan(t),t.template=this._template(t,i),f&&(t.element="body",t.placement="top"),(r=n(t.element)).addClass("tour-"+this._options.name+"-element tour-"+this._options.name+"-"+i+"-element"),t.options&&n.extend(e,t.options),t.reflex&&!f&&n(t.reflexElement).addClass("tour-step-element-reflex").off(this._reflexEvent(t.reflex)+".tour-"+this._options.name).on(this._reflexEvent(t.reflex)+".tour-"+this._options.name,function(n){return function(){return n._isLast()?n.next():n.end()}}(this)),o=!0===t.smartPlacement&&-1===t.placement.search(/auto/i),r.popover({placement:o?"auto "+t.placement:t.placement,trigger:"manual",title:t.title,content:t.content,html:!0,animation:t.animation,container:t.container,template:t.template,selector:t.element}).popover("show"),(u=r.data("bs.popover")?r.data("bs.popover").tip():r.data("popover").tip()).attr("id",t.id),"fixed"===r.css("position")&&u.css("position","fixed"),this._reposition(u,t),f)return this._center(u)},i.prototype._template=function(t,i){var f,e,o,s,r,u;return u=t.template,this._isOrphan(t)&&"[object Boolean]"!=={}.toString.call(t.orphan)&&(u=t.orphan),r=n(n.isFunction(u)?u(i,t):u),f=r.find(".popover-navigation"),o=f.find('[data-role="prev"]'),e=f.find('[data-role="next"]'),s=f.find('[data-role="pause-resume"]'),this._isOrphan(t)&&r.addClass("orphan"),r.addClass("tour-"+this._options.name+" tour-"+this._options.name+"-"+i),t.reflex&&r.addClass("tour-"+this._options.name+"-reflex"),t.prev<0&&o.addClass("disabled").prop("disabled",!0).prop("tabindex",-1),t.next<0&&e.addClass("disabled").prop("disabled",!0).prop("tabindex",-1),t.duration||s.remove(),r.clone().wrap("<div>").parent().html()},i.prototype._reflexEvent=function(n){return"[object Boolean]"==={}.toString.call(n)?"click":n},i.prototype._reposition=function(i,r){var o,s,h,c,f,e,u;if(c=i[0].offsetWidth,s=i[0].offsetHeight,u=i.offset(),f=u.left,e=u.top,(o=n(t).outerHeight()-u.top-i.outerHeight())<0&&(u.top=u.top+o),(h=n("html").outerWidth()-u.left-i.outerWidth())<0&&(u.left=u.left+h),u.top<0&&(u.top=0),u.left<0&&(u.left=0),i.offset(u),"bottom"===r.placement||"top"===r.placement){if(f!==u.left)return this._replaceArrow(i,2*(u.left-f),c,"left")}else if(e!==u.top)return this._replaceArrow(i,2*(u.top-e),s,"top")},i.prototype._center=function(t){return t.css("top",n(window).outerHeight()/2-t.outerHeight()/2)},i.prototype._replaceArrow=function(n,t,i,r){return n.find(".arrow").css(r,t?50*(1-t/i)+"%":"")},i.prototype._scrollIntoView=function(t){var f,e,h,o,r,i,s,u;if(s=this.getStep(t),!(f=n(s.element)).length)return this._showPopoverAndOverlay(t);switch(e=n(window),r=f.offset().top,o=f.outerHeight(),u=e.height(),i=0,s.placement){case"top":i=Math.max(0,r-u/2);break;case"left":case"right":i=Math.max(0,r+o/2-u/2);break;case"bottom":i=Math.max(0,r+o-u/2)}return this._debug("Scroll into view. ScrollTop: "+i+". Element offset: "+r+". Window height: "+u+"."),h=0,n("body, html").stop(!0,!0).animate({scrollTop:Math.ceil(i)},function(n){return function(){if(2==++h)return n._showPopoverAndOverlay(t),n._debug("Scroll into view.\nAnimation end element offset: "+f.offset().top+".\nWindow height: "+e.height()+".")}}(this))},i.prototype._onResize=function(t,i){return n(window).on("resize.tour-"+this._options.name,function(){return clearTimeout(i),i=setTimeout(t,100)})},i.prototype._onScroll=function(t,i){return n(window).on("scroll.tour-"+this._options.name,function(){return clearTimeout(i),i=setTimeout(t,100)})},i.prototype._initMouseNavigation=function(){var i;return i=this,n(t).off("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='prev']").off("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='next']").off("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='end']").off("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='pause-resume']").on("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='next']",function(n){return function(t){return t.preventDefault(),n.next()}}(this)).on("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='prev']",function(n){return function(t){if(t.preventDefault(),n._current>0)return n.prev()}}(this)).on("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='end']",function(n){return function(t){return t.preventDefault(),n.end()}}(this)).on("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='pause-resume']",function(t){var r;return t.preventDefault(),(r=n(this)).text(i._paused?r.data("pause-text"):r.data("resume-text")),i._paused?i.resume():i.pause()})},i.prototype._initKeyboardNavigation=function(){if(this._options.keyboard)return n(t).on("keyup.tour-"+this._options.name,function(n){return function(t){if(t.which)switch(t.which){case 39:return t.preventDefault(),n._isLast()?n.next():n.end();case 37:if(t.preventDefault(),n._current>0)return n.prev()}}}(this))},i.prototype._makePromise=function(t){return t&&n.isFunction(t.then)?t:null},i.prototype._callOnPromiseDone=function(n,t,i){return n?n.then(function(n){return function(){return t.call(n,i)}}(this)):t.call(this,i)},i.prototype._showBackground=function(i,r){var f,h,c,o,l,e,a,u,s;for(c=n(t).height(),s=n(t).width(),u=[],o=0,l=(a=["top","bottom","left","right"]).length;o<l;o++)switch(e=a[o],f=null!=(h=this.backdrops)[e]?h[e]:h[e]=n("<div>",{"class":"tour-backdrop "+e}),n(i.backdropContainer).append(f),e){case"top":u.push(f.height(r.offset.top>0?r.offset.top:0).width(s).offset({top:0,left:0}));break;case"bottom":u.push(f.offset({top:r.offset.top+r.height,left:0}).height(c-(r.offset.top+r.height)).width(s));break;case"left":u.push(f.offset({top:r.offset.top,left:0}).height(r.height).width(r.offset.left>0?r.offset.left:0));break;case"right":u.push(f.offset({top:r.offset.top,left:r.offset.left+r.width}).height(r.height).width(s-(r.offset.left+r.width)));break;default:u.push(void 0)}return u},i.prototype._showOverlayElement=function(t){var i,r;return 0===(i=n(t.backdropElement)).length?r={width:0,height:0,offset:{top:0,left:0}}:(r={width:i.innerWidth(),height:i.innerHeight(),offset:i.offset()},i.addClass("tour-step-backdrop"),t.backdropPadding&&(r=this._applyBackdropPadding(t.backdropPadding,r))),this._showBackground(t,r)},i.prototype._hideOverlayElement=function(t){var i,u,r;n(t.backdropElement).removeClass("tour-step-backdrop");r=this.backdrops;for(u in r)(i=r[u])&&void 0!==i.remove&&i.remove();return this.backdrops=[]},i.prototype._applyBackdropPadding=function(n,t){return"object"==typeof n?(null==n.top&&(n.top=0),null==n.right&&(n.right=0),null==n.bottom&&(n.bottom=0),null==n.left&&(n.left=0),t.offset.top=t.offset.top-n.top,t.offset.left=t.offset.left-n.left,t.width=t.width+n.left+n.right,t.height=t.height+n.top+n.bottom):(t.offset.top=t.offset.top-n,t.offset.left=t.offset.left-n,t.width=t.width+2*n,t.height=t.height+2*n),t},i.prototype._clearTimer=function(){return window.clearTimeout(this._timer),this._timer=null,this._duration=null},i.prototype._getProtocol=function(n){return(n=n.split("://")).length>1?n[0]:"http"},i.prototype._getHost=function(n){return n=n.split("//"),(n=n.length>1?n[1]:n[0]).split("/")[0]},i.prototype._getPath=function(n){return n.replace(/\/?$/,"").split("?")[0].split("#")[0]},i.prototype._getQuery=function(n){return this._getParams(n,"?")},i.prototype._getHash=function(n){return this._getParams(n,"#")},i.prototype._getParams=function(n,t){var i,e,u,r,f;if(1===(r=n.split(t)).length)return{};for(f={},i=0,e=(r=r[1].split("&")).length;i<e;i++)f[(u=(u=r[i]).split("="))[0]]=u[1]||"";return f},i.prototype._equal=function(n,t){var u,i,f,e,o,r;if("[object Object]"==={}.toString.call(n)&&"[object Object]"==={}.toString.call(t)){if(e=Object.keys(n),o=Object.keys(t),e.length!==o.length)return!1;for(i in n)if(r=n[i],!this._equal(t[i],r))return!1;return!0}if("[object Array]"==={}.toString.call(n)&&"[object Array]"==={}.toString.call(t)){if(n.length!==t.length)return!1;for(i=u=0,f=n.length;u<f;i=++u)if(r=n[i],!this._equal(r,t[i]))return!1;return!0}return n===t},i}()})