/**
 * Copyright 2020 The Pennsylvania State University
 * @license Apache-2.0, see License.md for full text.
 */
const IntersectionObserverMixin=function(e){return class extends e{constructor(){super(),this.elementVisible=!1,this.IOThresholds=[0,.25,.5,.75,1],this.IORootMargin="0px",this.IOVisibleLimit=.5,this.IORemoveOnVisible=!0,this.IODelay=100,this.IORoot=null}static get properties(){let e={};return super.properties&&(e=super.properties),{...e,elementVisible:{type:Boolean,attribute:"element-visible",reflect:!0}}}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.elementVisible||(this.intersectionObserver=new IntersectionObserver(this.handleIntersectionCallback.bind(this),{root:this.IORoot,rootMargin:this.IORootMargin,threshold:this.IOThresholds,delay:this.IODelay}),this.intersectionObserver.observe(this))}disconnectedCallback(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.elementVisible=!1),super.disconnectedCallback&&super.disconnectedCallback()}handleIntersectionCallback(e){for(let t of e){Number(t.intersectionRatio).toFixed(2)>=this.IOVisibleLimit?(this.elementVisible=!0,this.IORemoveOnVisible&&this.intersectionObserver.disconnect()):this.elementVisible=!1}}}};export{IntersectionObserverMixin};