text: (function(){var e,t,n,i=function(e,t){return function(){return e.apply(t,arguments)}},s=function(e,t){function n(){this.constructor=e}for(var i in t)o.call(t,i)&&(e[i]=t[i]);return n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype,e},o={}.hasOwnProperty;n=!1,e=function(){function e(){}return e.prototype.pushMessage=function(e,t){return null==t&&(t={}),this.elements.frame.contentWindow.postMessage([e,t],"*")},e.prototype.addEvent=function(e,t,n,i){return null==i&&(i=!1),e.addEventListener(t,n,i)},e.prototype.vendorPrefix=function(){var e,t;return t=navigator.userAgent,e=t.indexOf("Chrome")>=0||t.indexOf("Safari")>=0?"-webkit-":t.indexOf("Trident")>=0||t.indexOf("Edge")>=0?"-ms-":t.indexOf("Gecko")>=0&&t.indexOf("Firefox")>=0?"-moz-":void 0,n?e:""},e}(),t=function(e){function t(){this.removeEyecatcher=i(this.removeEyecatcher,this),this.upgradeEyecatcher=i(this.upgradeEyecatcher,this),this.setupEyecatcher=i(this.setupEyecatcher,this),this.update=i(this.update,this),this.widgetReady=i(this.widgetReady,this),this.setHeight=i(this.setHeight,this),this.setBadge=i(this.setBadge,this),this.toggle=i(this.toggle,this),this.reload=i(this.reload,this),this.hide=i(this.hide,this),this.updatePosition=i(this.updatePosition,this),this.setPosition=i(this.setPosition,this),this.getPosition=i(this.getPosition,this),this.show=i(this.show,this),this.attachListeners=i(this.attachListeners,this),this.createElements=i(this.createElements,this),this.setup=i(this.setup,this),this.init=i(this.init,this),this.init()}return s(t,e),t.prototype.init=function(){var e,t,n,i,s,o;return"undefined"!=typeof HW_config&&null!==HW_config&&null!=HW_config.account&&null!=HW_config.selector?(this.localOptions=HW_config,this.visible=!1,this.currentAlign="left",this.eyecatcherLevel=0,null!=this.localOptions.callbacks&&(this.localCallbacks=this.localOptions.callbacks),this.localOptions.callbacks=null,window.setTimeout(function(e){return function(){return e.setup()}}(this),1e3),e=document.querySelector("#HW_badge_cont"),t=document.querySelector("#HW_frame_cont"),n=document.querySelector("#HW_styles_cont"),null!=e&&null!=(i=e.parentNode)&&i.removeChild(e),null!=t&&null!=(s=t.parentNode)&&s.removeChild(t),null!=n&&null!=(o=n.parentNode)&&o.removeChild(n)):console.warn("[Headway] Config object missing or incorrect. Start with:\n\nvar HW_config = {\n  account: 'YOUR_ACCOUNT_ID',\n  selector: 'SELECTOR_WHERE_TO_INJECT_BADGE'\n};"),this},t.prototype.setup=function(){return this.badgeEl=document.querySelector(this.localOptions.selector),this.elements={frameCont:document.createElement("div"),frame:document.createElement("iframe"),badgeCont:document.createElement("span"),badge:document.createElement("span"),style:document.createElement("style"),animate:document.createElement("link")},this.styles="#HW_badge_cont {\n  visibility: hidden;\n  pointer-events: none;\n  display: block;\n  height: 32px;\n  width: 32px;\n  cursor: pointer;\n  position: relative;\n}\n\n#HW_badge_cont.HW_visible {\n  visibility: visible;\n  pointer-events: auto;\n}\n\n#HW_badge {\n  display: block;\n  border-radius: 20px;\n  background: #CD4B5B;\n  height: 16px;\n  width: 16px;\n  color: #fff;\n  text-align: center;\n  line-height: 16px;\n  font-size: 11px;\n  cursor: pointer;\n  position: absolute;\n  top: 8px;\n  left: 8px;\n  opacity: 0;\n  "+this.vendorPrefix()+"transform: scale(0);\n  "+this.vendorPrefix()+"transition: all 0.3s;\n}\n\n#HW_badge.HW_softHidden {\n  background: #d4d4d4;\n  opacity: 1;\n  "+this.vendorPrefix()+"transform: scale(0.6);\n}\n\n#HW_badge.HW_hidden {\n  opacity: 0;\n  "+this.vendorPrefix()+"transform: scale(0);\n}\n\n#HW_badge.HW_visible {\n  opacity: 1;\n  "+this.vendorPrefix()+"transform: scale(1.0);\n}\n\n#HW_frame_cont {\n  pointer-events: none;\n  border-radius: 4px;\n  box-shadow: 0 0 1px rgba(99, 114, 130, 0.32), 0 8px 16px rgba(27, 39, 51, 0.08);\n  background: #fff;\n  border: none;\n  position: absolute;\n  top: -900em;\n  z-index: 999;\n  width: 340px;\n  height: 300px;\n  opacity: 0;\n  will-change: height, margin-top, opacity;\n  margin-top: -10px;\n  "+this.vendorPrefix()+"transition: margin-top 0.15s ease-out, opacity 0.1s ease-out, height 0.3s ease-out;\n}\n\n#HW_frame_cont.HW_visible {\n  opacity: 1;\n  pointer-events: auto;\n  margin-top: 0px;\n}\n\n#HW_frame {\n  background: #fff;\n  border: none;\n  width: 100%;\n  height: 100%;\n  overflow: hidden;\n  border-radius: 4px;\n  position: relative;\n  z-index: 900;\n  "+this.vendorPrefix()+"transition: height 0.3s ease-out;\n}",null!=this.badgeEl?(this.createElements(),this.attachListeners()):console.warn("[Headway] Element provided by selector does not exist.")},t.prototype.createElements=function(){var e,t,n;return this.badgeEl.appendChild(this.elements.badgeCont),this.elements.badgeCont.id="HW_badge_cont",this.elements.badgeCont.addEventListener("click",this.toggle,!1),this.elements.badgeCont.appendChild(this.elements.badge),this.elements.badge.id="HW_badge",document.body.appendChild(this.elements.frameCont),this.elements.frameCont.id="HW_frame_cont",n=this.localOptions.protocol?this.localOptions.protocol+":":location.protocol,t=this.localOptions.debugHost||"headwayapp.co",e=n+"//"+t+"/widgets/"+this.localOptions.account,this.elements.frameCont.appendChild(this.elements.frame),this.elements.frame.id="HW_frame",this.elements.frame.src=e,document.body.appendChild(this.elements.style),this.elements.style.id="HW_styles_cont",this.elements.style.textContent=this.styles},t.prototype.attachListeners=function(){var e;return this.ticking=!1,e=function(e){return function(t){var n,i;switch(i=t.data[0],n=t.data[1],i){case"setHeight":return e.setHeight(n);case"setBadge":return e.setBadge(n);case"widgetReady":return e.widgetReady(n);case"hide":return e.hide();case"reload":return e.reload();case"update":return e.update(n)}}}(this),this.addEvent(window,"message",e),this.addEvent(window,"scroll",this.updatePosition),this.addEvent(window,"resize",this.updatePosition),this.addEvent(document.body,"click",function(e){return function(t){if(e.visible)return e.hide()}}(this)),this.addEvent(this.elements.frame,"load",function(e){return function(t){return e.pushMessage("ready",{host:location.hostname,options:e.localOptions})}}(this))},t.prototype.show=function(){return this.visible=!0,this.updatePosition(),this.elements.frameCont.classList.add("HW_visible"),this.pushMessage("opened",{})},t.prototype.getPosition=function(e){var t,n,i,s,o,a,r;return i={badge:this.elements.badgeCont.getBoundingClientRect(),frame:this.elements.frameCont.getBoundingClientRect()},s=parseInt(i.frame.width),t=parseInt(i.badge.height),r={top:window.pageYOffset+t,right:s-i.badge.width},a={h:i.badge.left>=document.body.scrollWidth-s,v:i.badge.top+i.frame.height>document.documentElement.clientHeight},n=i.badge.left-s<0,o={h:a.h?"left":"right",v:a.v?"top":"bottom"},n&&(o.h="fill"),[i.badge,i.frame,r,o]},t.prototype.setPosition=function(){var e,t,n,i,s;return s=this.getPosition(),e=s[0],t=s[1],i=s[2],n=s[3],"right"===n.h?this.elements.frameCont.style.left=e.left+"px":"left"===n.h?this.elements.frameCont.style.left=e.left-i.right+"px":this.elements.frameCont.style.left="0px","top"===n.v?this.elements.frameCont.style.top=e.top+i.top-t.height-e.height+"px":this.elements.frameCont.style.top=e.top+i.top+"px"},t.prototype.updatePosition=function(){if(this.visible)return this.ticking||window.requestAnimationFrame(function(e){return function(){return e.setPosition(),e.ticking=!1}}(this)),this.ticking=!0},t.prototype.hide=function(){return this.visible=!1,this.elements.frameCont.classList.remove("HW_visible"),this.pushMessage("closed",{})},t.prototype.reload=function(){return this.elements.frame.contentWindow.location.reload()},t.prototype.toggle=function(e){return e.preventDefault(),e.stopPropagation(),this.visible?this.hide():(this.show(),null!=this.localCallbacks&&null!=this.localCallbacks.onShowWidget?this.localCallbacks.onShowWidget.call(this):void 0)},t.prototype.setBadge=function(e){return e.counter>=1?(this.elements.badge.classList.add("HW_visible"),this.elements.badge.innerHTML=e.counter,this.localOptions.eyecatcher?this.setupEyecatcher():void 0):(this.removeEyecatcher(),this.localOptions.softHide?(this.elements.badge.classList.remove("HW_visible"),this.elements.badge.classList.add("HW_softHidden"),this.elements.badge.innerHTML=""):(window.setTimeout(function(e){return function(){return e.elements.badgeCont.classList.remove("HW_visible")}}(this),300),this.elements.badge.classList.remove("HW_visible"),this.elements.badge.classList.add("HW_hidden"),this.elements.badge.innerHTML=e.counter))},t.prototype.setHeight=function(e){return this.elements.frame.style.height=e.height+"px",this.elements.frameCont.style.height=e.height+"px"},t.prototype.widgetReady=function(e){return this.elements.badgeCont.classList.add("HW_visible"),this.localOptions=e.options,window.setTimeout(function(t){return function(){return t.setBadge(e)}}(this),1e3*this.localOptions.badgeDelay)},t.prototype.update=function(e){return this.setBadge(e),this.reload()},t.prototype.setupEyecatcher=function(){var e;return document.body.appendChild(this.elements.animate),this.elements.animate.rel="stylesheet",this.elements.animate.href=location.protocol+"//cdn.headwayapp.co/headway-animate.css",e=["blank","pulse","jello","rubberBand","wobble","shake","bounce"],this.elements.badge.classList.add("HW_animated"),this.upgradeEyecatcher(e)},t.prototype.upgradeEyecatcher=function(e){var t;return t=0,window.setInterval(function(n){return function(){var i;return i="HW_"+e[n.eyecatcherLevel],e.length===n.eyecatcherLevel&&(i=e[e.length-1]),n.elements.badge.classList.add(i),window.setTimeout(function(){if(n.elements.badge.classList.remove(i),t+=1,t>=5)return t=0,n.eyecatcherLevel=n.eyecatcherLevel+1,n.elements.badge.classList.remove(i)},1e3)}}(this),5500)},t.prototype.removeEyecatcher=function(){return this.elements.badge.className=""},t}(e),window.Headway=new t}).call(this);