window.Sticksy=function(){"use strict";var s="static",i="fixed",n="stuck";function e(t,i){if(!t)throw new Error("You have to specify the target element");if("string"!=typeof t&&!(t instanceof Element))throw new Error("Expected a string or element, but got: "+Object.prototype.toString.call(t));var n=r.findElement(t);if(!n)throw new Error("Cannot find target element: "+t);var s=n.parentNode;if(!s)throw new Error("Cannot find container of target element: "+t);i=i||{},this.t={containerEl:s,targetEl:n,topSpacing:i.topSpacing||0,enabled:i.enabled||!0,listen:i.listen||!1},this.onStateChanged=null,this.nodeRef=n,this.i()}e.instances=[],e.enabledInstances=[],e.prototype.i=function(){var t=this;this.state=s,this.o=[],this.h=[];for(var i=this.t.targetEl;i;){var n=i.cloneNode(!0);n.style.visibility="hidden",n.style.pointerEvents="none",n.className+=" sticksy-dummy-node",n.removeAttribute("id"),this.t.targetEl.parentNode.insertBefore(n,this.t.targetEl),this.o.push(i),this.h.push(n),i=i.nextElementSibling}this.u=0,this.l={top:0,bottom:0},this.v=!1,this.t.containerEl.style.position="relative",this.m=-1===getComputedStyle(this.t.containerEl).display.indexOf("flex"),this.t.listen&&(this.p=new MutationObserver(function(){t.hardRefresh()}),this.g()),e.instances.push(this),this.t.enabled&&e.enabledInstances.push(this),this.hardRefresh()},e.prototype.g=function(){this.t.listen&&!this.v&&(this.p.observe(this.t.containerEl,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this.v=!0)},e.prototype.C=function(){this.t.listen&&this.v&&(this.p.disconnect(),this.v=!1)},e.prototype.M=function(t){return t=this.l.bottom?n:i},e.prototype.S=function(){this.u=r.getComputedBox(this.o[this.o.length-1]).bottomWithMargin-r.getComputedBox(this.o[0]).topWithMargin},e.prototype.j=function(){var t=this.t.containerEl,i=this.o,t=r.getComputedBox(t),i=r.getComputedBox(i[0]);this.l={top:i.topWithMargin-this.t.topSpacing,bottom:t.bottom-t.paddingBottom-this.t.topSpacing-this.u}},e.prototype.B=function(t){t===s?(this.P(this.o),this.T(this.h)):(this.k(this.o),t===i?this.O(this.o):this.W(this.o),this.D(this.h))},e.prototype.refresh=function(){var t=this.M(window.pageYOffset,this.l);t!==this.state&&(this.state=t,this.C(),this.B(t),this.g(),"function"==typeof this.onStateChanged&&this.onStateChanged(t))},e.prototype.hardRefresh=function(){this.C();var t=this.state;this.state=s,this.B(this.state),this.k(this.o),this.S(),this.j(),this.state=this.M(window.pageYOffset,this.l),this.B(this.state),this.g(),"function"==typeof this.onStateChanged&&t!==this.state&&this.onStateChanged(this.state)},e.prototype.enable=function(){this.t.enabled=!0,e.enabledInstances.push(this),this.hardRefresh()},e.prototype.disable=function(){this.t.enabled=!1,this.state=s,this.B(this.state),e.enabledInstances.splice(e.enabledInstances.indexOf(this),1)},e.prototype.O=function(t){for(var i=0,n=this.t.topSpacing,s=0;s