import{r as s,g as e,h as t,d as o}from"./p-b3a13b6a.js";import{v as i}from"./p-4ed69de7.js";const l="pn-play-on-scroll pn-scroll [slot=scroll-affected]{position:relative;display:flex}pn-play-on-scroll pn-scroll [slot=scroll-affected] video{width:100%}pn-play-on-scroll pn-scroll [slot=scroll-affected] video:hover{cursor:pointer}";const a=l;const r={root:null,threshold:1,rootMargin:"0px 0px 0px 0px"};const c=(s,e,t)=>{if(!e){s&&s.play();t(false)}};const n=(s,e)=>{s&&s.pause();e(true)};const h=class{constructor(e){s(this,e);this.videoSrc="";this.observerOptions=r;this.showOverlay=false;this.videoId="";this.isManuallyPaused=false;this.isPaused=false}get hostElement(){return e(this)}localObserverOptions;testAdditionalParamIntoCallback=true;video;generateUniqueId(){return i()}componentWillLoad(){this.videoId=this.generateUniqueId()}componentDidLoad(){this.video=document.getElementById(this.videoId);this.video.addEventListener("click",this.handlePlayPauseClicked);this.localObserverOptions=this.observerOptions}handlePlayPauseClicked=()=>{if(this.video.paused||this.video.ended){this.video.play();this.isManuallyPaused=false;this.isPaused=false}else{this.video.pause();this.isManuallyPaused=true;this.isPaused=true}};togglePaused=s=>{this.isPaused=s};render(){return t(o,{key:"b76be7833abdd0c16b2b865e343a764fb5762466"},t("pn-scroll",{key:"c3dbb68e12611706fb4a3cbbbad84287ac3c2e73",intersectFunc:()=>c(this.video,this.isManuallyPaused,this.togglePaused),notIntersectFunc:()=>n(this.video,this.togglePaused),shouldLoop:true,behaviourClasses:"some-behaviour-class",observerOptions:this.localObserverOptions},t("div",{key:"461df9fcf966d409345e945117418eb35d58f540",slot:"scroll-affected"},t("video",{key:"1b23bfb0e5f2ad71d1bbe0740bc7823784ff80c0",playsinline:true,muted:true,autoPlay:true,id:`${this.videoId}`},t("source",{key:"8bf03c50ae3d3245acaae0beb3b7fc7ee048c0d8",src:this.videoSrc,type:"video/mp4"})),t("pn-video-overlay",{key:"21a69fa7ed440704f2e9aa5017f4616322fe9a4b",showOverlay:this.showOverlay,isPaused:this.isManuallyPaused||this.isPaused,onPlayPauseClicked:this.handlePlayPauseClicked}))))}};h.style=a;export{h as pn_play_on_scroll};
//# sourceMappingURL=p-3d11fd8a.entry.js.map