var t=function(t){this._queue=[],this._onEmptyCallback=t};t.prototype.queue=function(t){this._queue.push(t),1!==this._queue.length||this._active||this._progressQueue()},t.prototype._progressQueue=function(){if(this._queue.length){var t=this._queue.shift();this._active=!0;var e=this.next.bind(this);t&&t(e)}else this._onEmptyCallback()},t.prototype.clear=function(){this._queue=[]},t.prototype.next=function(){this._active=!1,this._progressQueue()};var e=function(t,e,i){this._el=t,this._data=e.config,this._path=e.image,this._currentFrameIndex=0,this._currentFrame=void 0,this._exiting=!1,this._currentAnimation=void 0,this._endCallback=void 0,this._started=!1,this._sounds={},this.currentAnimationName=void 0,this.preloadSounds(i),this._overlays=[this._el];var n=this._el;this._setupElement(this._el);for(var o=1;o=this._currentAnimation.frames.length-1},e.prototype._step=function(){if(this._currentAnimation){var t=Math.min(this._getNextAnimationFrame(),this._currentAnimation.frames.length-1),i=!this._currentFrame||this._currentFrameIndex!==t;this._currentFrameIndex=t,this._atLastFrame()&&this._currentAnimation.useExitBranching||(this._currentFrame=this._currentAnimation.frames[this._currentFrameIndex]),this._draw(),this._playSound(),this._loop=window.setTimeout(this._step.bind(this),this._currentFrame.duration),this._endCallback&&i&&this._atLastFrame()&&(this._currentAnimation.useExitBranching&&!this._exiting?this._endCallback(this.currentAnimationName,e.States.WAITING):this._endCallback(this.currentAnimationName,e.States.EXITED))}},e.prototype.pause=function(){window.clearTimeout(this._loop)},e.prototype.resume=function(){this._step()},e.States={WAITING:1,EXITED:0};var i=function(){var t=void 0!==window.pageXOffset,e="CSS1Compat"===(document.compatMode||"");return{scrollLeft:t?window.pageXOffset:e?document.documentElement.scrollLeft:document.body.scrollLeft,scrollTop:t?window.pageYOffset:e?document.documentElement.scrollTop:document.body.scrollTop}};function n(t){if(!t.getClientRects().length)return{top:0,left:0};var e=t.getBoundingClientRect(),i=t.ownerDocument.defaultView||{pageXOffset:0,pageYOffset:0};return{top:e.top+i.pageYOffset,left:e.left+i.pageXOffset}}function o(t,e){if("inner"===e)return t.clientWidth;if("outer"===e)return t.offsetWidth;var i=window.getComputedStyle(t,null);return"width"===e?t.clientWidth-parseInt(i.getPropertyValue("padding-left"))-parseInt(i.getPropertyValue("padding-right")):"full"===e?t.offsetWidth+parseInt(i.getPropertyValue("margin-left"))+parseInt(i.getPropertyValue("margin-right")):null}function r(t,e){if("inner"===e)return t.clientHeight;if("outer"===e)return t.offsetHeight;var i=window.getComputedStyle(t,null);return"height"===e?t.clientHeight-parseInt(i.getPropertyValue("padding-top"))-parseInt(i.getPropertyValue("padding-bottom")):"full"===e?t.offsetHeight+parseInt(i.getPropertyValue("margin-top"))+parseInt(i.getPropertyValue("margin-bottom")):null}var s=function(){var t=this;this.promise=new Promise((function(e,i){t.resolve=e,t.reject=i}))},a=function(t){this._hiding=null,this._loop=null,this._active=!0,this._hold=!1,this._addWord=null,this._targetEl=t,this._hidden=!0,this._setup()};a.prototype._setup=function(){var t=document.createElement("div");t.className="clippy-balloon",t.setAttribute("hidden","true");var e=document.createElement("div");e.className="clippy-tip";var i=document.createElement("div");i.className="clippy-content",t.appendChild(e),t.appendChild(i),this._balloon=t,this._content=i,this._targetEl.insertAdjacentElement("afterend",t)},a.prototype.reposition=function(){for(var t=["top-left","top-right","bottom-left","bottom-right"],e=0;el||c+s+5>a)}},a.prototype.speak=function(t,e,i){this._hidden=!1,this.show();var n=this._content;n&&(n.style.height="auto",n.style.width="auto",n.innerHTML=e,n.style.height=n.style.height||"",n.style.width=n.style.width||"",n.innerHTML="",this.reposition(),this._complete=t,this._sayWords(e,i,t))},a.prototype.show=function(){this._balloon&&(this._hidden||this._balloon.removeAttribute("hidden"))},a.prototype.hide=function(t){var e;t?null===(e=this._balloon)||void 0===e||e.setAttribute("hidden","true"):this._hiding=window.setTimeout(this._finishHideBalloon.bind(this),2e3)},a.prototype._finishHideBalloon=function(){var t;this._active||(null===(t=this._balloon)||void 0===t||t.setAttribute("hidden","true"),this._hidden=!0,this._hiding=null)},a.prototype._sayWords=function(t,e,i){var n=this;this._active=!0,this._hold=e;var o=t.split(/[^\S-]/),r=this._content,s=1;this._addWord=function(){var t;n._active&&(s>o.length?(n._addWord=null,n._active=!1,n._hold||(i(),n.hide(!1))):(r&&(r.innerHTML=o.slice(0,s).join(" ")),s++,n._loop=window.setTimeout(null===(t=n._addWord)||void 0===t?void 0:t.bind(n),200)))},this._addWord()},a.prototype.close=function(){this._active?this._hold=!1:this._hold&&this._complete&&this._complete()},a.prototype.pause=function(){this._loop&&window.clearTimeout(this._loop),this._hiding&&(window.clearTimeout(this._hiding),this._hiding=null)},a.prototype.resume=function(){this._addWord?this._addWord():this._hold||this._hidden||(this._hiding=window.setTimeout(this._finishHideBalloon.bind(this),2e3))};var l=function(i){this._hidden=!1,this._offset={top:0,left:0};var n=i.agent,o=i.selector;this._queue=new t(this._onQueueEmpty.bind(this));var r=document.createElement("div");r.className="clippy",r.setAttribute("hidden","true"),this._el=r,((o?document.getElementsByClassName(o)[0]:void 0)||document.body).appendChild(this._el),this._animator=new e(this._el,n,[]),this._balloon=new a(this._el),this._setupEvents()};function h(t){return new Promise((function(e,i){import("./agents/"+t+".js").then((function(t){e(t.default)})).catch((function(t){i(t)}))}))}l.prototype.gestureAt=function(t,e){var i=this._getDirection(t,e),n="Gesture"+i,o="Look"+i,r=this.hasAnimation(n)?n:o;return this.play(r)},l.prototype.hide=function(t,e){var i=this;return this._hidden=!0,this._el,this.stop(),t?(this._el.setAttribute("hidden","true"),this.stop(),this.pause(),void(e&&e())):this._playInternal("Hide",(function(){i._el.setAttribute("hidden","true"),i.pause(),e&&e()}))},l.prototype.moveTo=function(t,i,n){var o=this,r="Move"+this._getDirection(t,i);void 0===n&&(n=1e3),this._addToQueue((function(s){if(0===n)return o._el.style.top=i+"px",o._el.style.left=t+"px",o.reposition(),void s();if(!o.hasAnimation(r)){var a=function(){o._el.removeEventListener("animationend",a),s()};return o._el.addEventListener("animationend",a),void o._el.animate({top:i,left:t},{duration:n,iterations:1})}o._playInternal(r,(function(r,a){if(a===e.States.EXITED&&s(),a===e.States.WAITING){var l=function(){o._el.removeEventListener("animationend",l),o._animator.exitAnimation()};o._el.addEventListener("animationend",l),o._el.animate({top:i+"px",left:t+"px"},{duration:n,iterations:1})}}))}),this)},l.prototype._playInternal=function(t,e){var i=this;this._isIdleAnimation()&&this._idleDfd&&this._idleDfd.promise.finally((function(){i._playInternal(t,e)})),this._animator.showAnimation(t,e)},l.prototype.play=function(t,i,n){var o=this;return!!this.hasAnimation(t)&&(void 0===i&&(i=5e3),this._addToQueue((function(r){var s=!1;i&&window.setTimeout((function(){s||o._animator.exitAnimation()}),i),o._playInternal(t,(function(t,i){i===e.States.EXITED&&(s=!0,n&&n(),r())}))}),this),!0)},l.prototype.show=function(t){if(void 0===t&&(t=!0),this._hidden=!1,t)return this._el.removeAttribute("hidden"),this.resume(),void this._onQueueEmpty();var e=this._el.style.top,n=this._el.style.left;if("auto"===e||"auto"!==n){var o=.8*document.querySelector("html").clientWidth,r=.8*(document.querySelector("html").clientHeight+i().scrollLeft);this._el.style.top=r+"px",this._el.style.left=o+"px"}return this.resume(),this.play("Show")},l.prototype.speak=function(t,e){var i=this;void 0===e&&(e=!1),this._addToQueue((function(n){i._balloon.speak(n,t,e)}),this)},l.prototype.closeBalloon=function(){this._balloon.hide()},l.prototype.delay=function(t){var e=this;t=t||250,this._addToQueue((function(i){e._onQueueEmpty(),window.setTimeout(i,t)}))},l.prototype.stopCurrent=function(){this._animator.exitAnimation(),this._balloon.close()},l.prototype.stop=function(){this._queue.clear(),this._animator.exitAnimation(),this._balloon.hide()},l.prototype.hasAnimation=function(t){return this._animator.hasAnimation(t)},l.prototype.animations=function(){return this._animator.animations()},l.prototype.animate=function(){var t=this.animations(),e=t[Math.floor(Math.random()*t.length)];return 0===e.indexOf("Idle")?this.animate():this.play(e)},l.prototype._getDirection=function(t,e){var i=n(this._el),s=r(this._el,"height"),a=o(this._el,"width"),l=i.left+a/2,h=i.top+s/2-e,p=l-t,u=Math.round(180*Math.atan2(h,p)/Math.PI);return-45<=u&&u<45?"Right":45<=u&&u<135?"Up":135<=u&&u<=180||-180<=u&&u<-135?"Left":-135<=u&&u<-45?"Down":"Top"},l.prototype._onQueueEmpty=function(){if(!this._hidden&&!this._isIdleAnimation()){var t=this._getIdleAnimation();this._idleDfd=new s,this._animator.showAnimation(t,this._onIdleComplete.bind(this))}},l.prototype._onIdleComplete=function(t,i){var n;i===e.States.EXITED&&(null===(n=this._idleDfd)||void 0===n||n.resolve(void 0))},l.prototype._isIdleAnimation=function(){var t=this._animator.currentAnimationName;return t&&0===t.indexOf("Idle")},l.prototype._getIdleAnimation=function(){for(var t=this.animations(),e=[],i=0;il&&(d=l-e-5),c-5<0?c=5:c+s+5>a&&(c=a-s-5),this._el.style.left=c+"px",this._el.style.top=d+"px",this._balloon.reposition()}},l.prototype._onMouseDown=function(t){t.preventDefault(),this._startDrag(t)},l.prototype._startDrag=function(t){this.pause(),this._balloon.hide(!0),this._offset=this._calculateClickOffset(t),this._moveHandle=this._dragMove.bind(this),this._upHandle=this._finishDrag.bind(this),window.addEventListener("mousemove",this._moveHandle),window.addEventListener("mouseup",this._upHandle),this._dragUpdateLoop=window.setTimeout(this._updateLocation.bind(this),10)},l.prototype._calculateClickOffset=function(t){var e=t.pageX,i=t.pageY,o=n(this._el);return{top:i-o.top,left:e-o.left}},l.prototype._updateLocation=function(){this._el.style.top=(this._targetY||0)+"px",this._el.style.left=(this._targetX||0)+"px",this._dragUpdateLoop=window.setTimeout(this._updateLocation.bind(this),10)},l.prototype._dragMove=function(t){t.preventDefault();var e=t.clientX-this._offset.left,i=t.clientY-this._offset.top;this._targetX=e,this._targetY=i},l.prototype._finishDrag=function(){window.clearTimeout(this._dragUpdateLoop),this._moveHandle&&window.removeEventListener("mousemove",this._moveHandle),this._upHandle&&window.removeEventListener("mouseup",this._upHandle),this._balloon.show(),this.reposition(),this.resume()},l.prototype._addToQueue=function(t,e){e&&(t=t.bind(e)),this._queue.queue(t)},l.prototype.pause=function(){this._animator.pause(),this._balloon.pause()},l.prototype.resume=function(){this._animator.resume(),this._balloon.resume()};var p={Bonzi:function(){return h("Bonzi")},Clippy:function(){return h("Clippy")},F1:function(){return h("F1")},Genie:function(){return h("Genie")},Genius:function(){return h("Genius")},Links:function(){return h("Links")},Merlin:function(){return h("Merlin")},Peedy:function(){return h("Peedy")},Rocky:function(){return h("Rocky")},Rover:function(){return h("Rover")}},u=[],d=[];!function(t,e){if(t&&"undefined"!=typeof document){var i,n=!0===e.prepend?"prepend":"append",o=!0===e.singleTag,r="string"==typeof e.container?document.querySelector(e.container):document.getElementsByTagName("head")[0];if(o){var s=u.indexOf(r);-1===s&&(s=u.push(r)-1,d[s]={}),i=d[s]&&d[s][n]?d[s][n]:d[s][n]=a()}else i=a();65279===t.charCodeAt(0)&&(t=t.substring(1)),i.styleSheet?i.styleSheet.cssText+=t:i.appendChild(document.createTextNode(t))}function a(){var t=document.createElement("style");if(t.setAttribute("type","text/css"),e.attributes)for(var i=Object.keys(e.attributes),o=0;o