{"version":3,"file":"chunks/7a396aa8edd000.js","mappings":";6TACA,snOAoDA,QArDe,WAMb,WAAYA,EAA4BC,GAAa,YALvD,4FAKuD,SACnDC,KAAKD,OAASA,EACdC,KAAKC,MAAQH,EAAcI,cAAc,SAEzCF,KAAKG,QAAU,CACbC,KAAM,KACNC,UAAW,CAAC,EAAG,GAAK,IAGtBL,KAAKM,SAAW,IAAIC,qBAAoB,eAd5C,EAc4C,GAd5C,EAc4C,UAAC,uFAAa,GAd1D,EAc6C,IAd7C,4CAc6C,IAd7C,s2BAcqDN,EAAK,MAE1CO,gBAAkBP,EAAMQ,mBAAqB,IAAG,0CAE/CR,EAAMS,OAA4BC,OAAM,8BAIC,OAJD,yBAI9CV,EAAMS,OAA4BE,OAAQ,EAAK,UACzCX,EAAMS,OAA4BC,OAAM,QAE7C,EAAKZ,OAAOc,UACd,EAAKP,SAASQ,aACf,wBACoC,IAA5Bb,EAAMQ,mBACdR,EAAMS,OAA4BK,QACpC,kCA9BP,OA8BO,sBA9BP,+KA+BK,mDAjBuC,GAiBrCf,KAAKG,SAERH,KAAKgB,MACP,CAlCF,QAiDG,OAjDH,EAkCG,GAlCH,EAkCG,mBAED,WACOhB,KAAKD,OAAOkB,WACfjB,KAAKM,SAASY,QAAQlB,KAAKC,OAC3BD,KAAKmB,aAET,GAAC,wBAED,WAAc,WACZnB,KAAKC,MAAMmB,QAAU,WACd,EAAKrB,OAAOsB,MACf,EAAKf,SAASQ,YAElB,CACF,MAjDF,oEAiDG,EAlDY","sources":["webpack:///./resources/js/components/generic/videoHtml.ts"],"sourcesContent":["class VideoHtml {\n params: any;\n video: HTMLVideoElement;\n options: { root: null; threshold: number[]; };\n observer: IntersectionObserver;\n\n constructor(componentRoot: HTMLElement, params: any) {\n this.params = params;\n this.video = componentRoot.querySelector('video') as HTMLVideoElement;\n\n this.options = {\n root: null,\n threshold: [0, 0.5, 1]\n };\n\n this.observer = new IntersectionObserver(async ([video]) => {\n // setting video player to async await as shown in mdn example. \n if (video.isIntersecting && video.intersectionRatio >= 0.5) {\n try {\n await (video.target as HTMLVideoElement).play();\n } catch(err) {\n // if play run into issue that typically means autoplay is disabled\n // in that case we'll set video player to mute then play the video once more\n (video.target as HTMLVideoElement).muted = true;\n await (video.target as HTMLVideoElement).play();\n }\n if (this.params.controls) {\n this.observer.disconnect();\n }\n } else if (video.intersectionRatio === 0) {\n (video.target as HTMLVideoElement).pause();\n }\n }, this.options);\n\n this.init();\n }\n\n init () {\n if (!this.params.autoplay) {\n this.observer.observe(this.video);\n this.bindEvents();\n }\n }\n\n bindEvents () {\n this.video.onended = () => {\n if (!this.params.loop) {\n this.observer.disconnect();\n }\n }\n }\n}\n\nexport default VideoHtml;"],"names":["componentRoot","params","this","video","querySelector","options","root","threshold","observer","IntersectionObserver","isIntersecting","intersectionRatio","target","play","muted","controls","disconnect","pause","init","autoplay","observe","bindEvents","onended","loop"],"sourceRoot":""}