1import{B as y}from"./BaseElement.Dw8b55QC.min.js";import{n as l}from"./property.CoOWCv8E.min.js";import{e as d}from"./query.CpiO8Lcb.min.js";import"./lit-element.D1QXZDXi.min.js";import"./base.CShCMygk.min.js";var m=Object.defineProperty,a=(o,e,t,h)=>{for(var s=void 0,r=o.length-1,i;r>=0;r--)(i=o[r])&&(s=i(e,t,s)||s);return s&&m(e,t,s),s};class n extends y{constructor(){super(...arguments),this.autoplay=this.dataset.autoplay==="true",this.loop=this.dataset.loop==="true",this.showControls=this.dataset.showControls==="true",this.isPaused=!1,this.boundHandlePlay=this.handlePlay.bind(this),this.boundHandlePause=this.handlePause.bind(this),this.boundHandleEnded=this.handleEnded.bind(this),this.boundTogglePlayPause=this.togglePlayPause.bind(this),this.boundHandleKeydown=this.handleKeydown.bind(this),this.boundHandleViewportChange=this.handleViewportChange.bind(this)}connectedCallback(){super.connectedCallback(),this.updateIconsForButtonStyle(),this.setupViewportListener(),this.syncVideoSources(),this.setupVideoListeners(),this.setupControlButton(),this.updatePausedState()}updateIconsForButtonStyle(){const e=getComputedStyle(document.documentElement).getPropertyValue("--sizing-inputs-button-radius").trim();e&&parseInt(e)>=500&&(this.playIcon&&this.playIcon.setAttribute("src","icon-video-play-rounded"),this.pauseIcon&&this.pauseIcon.setAttribute("src","icon-video-pause-rounded"))}disconnectedCallback(){super.disconnectedCallback(),this.removeVideoListeners(),this.removeControlButtonListeners(),this.removeViewportListener()}setupVideoListeners(){this.video&&(this.video.addEventListener("play",this.boundHandlePlay),this.video.addEventListener("pause",this.boundHandlePause),this.video.addEventListener("ended",this.boundHandleEnded),this.autoplay&&(this.intersectionObserver=new IntersectionObserver(e=>{e.forEach(t=>{t.isIntersecting?this.video.play().catch(()=>{this.updatePausedState()}):this.video.pause()})},{threshold:.5}),this.intersectionObserver.observe(this)))}removeVideoListeners(){this.video&&(this.video.removeEventListener("play",this.boundHandlePlay),this.video.removeEventListener("pause",this.boundHandlePause),this.video.removeEventListener("ended",this.boundHandleEnded),this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=void 0))}setupControlButton(){!this.showControls||!this.controlButton||(this.controlButton.addEventListener("click",this.boundTogglePlayPause),this.controlButton.addEventListener("keydown",this.boundHandleKeydown))}removeControlButtonListeners(){this.controlButton&&(this.controlButton.removeEventListener("click",this.boundTogglePlayPause),this.controlButton.removeEventListener("keydown",this.boundHandleKeydown))}handleKeydown(e){(e.key===" "||e.key==="Enter")&&(e.preventDefault(),this.togglePlayPause())}togglePlayPause(){this.video&&(this.video.paused?this.video.play().catch(e=>{console.error("Error playing video:",e)}):this.video.pause())}handlePlay(){this.isPaused=!1,this.updatePausedState(),this.video.addEventListener("timeupdate",()=>this.hidePoster(),{once:!0})}handlePause(){this.isPaused=!0,this.updatePausedState()}handleEnded(){this.loop||(this.isPaused=!0,this.updatePausedState(),this.showPoster())}hidePoster(){this.posterElement&&(this.posterElement.style.opacity="0",this.posterElement.style.pointerEvents="none")}showPoster(){this.posterElement&&(this.posterElement.style.opacity="",this.posterElement.style.pointerEvents="")}setupViewportListener(){this.mediaQueryList=window.matchMedia("(min-width: 768px)"),this.mediaQueryList.addEventListener("change",this.boundHandleViewportChange)}removeViewportListener(){this.mediaQueryList&&(this.mediaQueryList.removeEventListener("change",this.boundHandleViewportChange),this.mediaQueryList=void 0)}syncVideoSources(){var r;if(!this.video)return!1;const e=this.video.querySelectorAll("source[data-media]");if(e.length===0)return!1;const h=((r=this.mediaQueryList)==null?void 0:r.matches)??window.matchMedia("(min-width: 768px)").matches?"desktop":"mobile";let s=!1;return e.forEach(i=>{const v=i.getAttribute("data-media"),u=i.getAttribute("src"),c=i.getAttribute("data-src"),p=v===h;p&&!u&&c?(i.setAttribute("src",c),i.removeAttribute("data-src"),s=!0):!p&&u&&(i.setAttribute("data-src",u),i.removeAttribute("src"),s=!0)}),s&&this.video.load(),s}handleViewportChange(){if(!this.video)return;const e=!this.video.paused,t=this.video.currentTime;this.syncVideoSources()&&(e?(this.video.currentTime=t,this.video.play().catch(()=>{this.isPaused=!0,this.updatePausedState(),this.showPoster()})):this.video.currentTime=t)}updatePausedState(){var e;this.isPaused||(e=this.video)!=null&&e.paused?this.setAttribute("data-paused",""):this.removeAttribute("data-paused"),this.toggleIconVisibility()}toggleIconVisibility(){var t;if(!this.playIcon||!this.pauseIcon)return;const e=this.isPaused||((t=this.video)==null?void 0:t.paused);this.playIcon.classList.toggle("hidden",!e),this.pauseIcon.classList.toggle("hidden",e)}}a([d("video")],n.prototype,"video");
1a([d("[data-video-control]")],n.prototype,"controlButton");a([d('[data-icon="play"]')],n.prototype,"playIcon");a([d('[data-icon="pause"]')],n.prototype,"pauseIcon");a([d("[data-video-poster]")],n.prototype,"posterElement");a([l({type:Boolean,attribute:"data-autoplay",converter:o=>o==="true"})],n.prototype,"autoplay");a([l({type:Boolean,attribute:"data-loop",converter:o=>o==="true"})],n.prototype,"loop");a([l({type:Boolean,attribute:"data-show-controls",converter:o=>o==="true"})],n.prototype,"showControls");customElements.define("custom-video",n);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.