import{r as t,h as s}from"./p-3ba9c73c.js";import{R as e}from"./p-6b3481e9.js";const i=class{constructor(s){t(this,s),this.resolveLocation=e.NOOP,this.url="",this.youtube=!1}componentWillLoad(){if(!this.template)return;if(this.template.location.startsWith("BCE://"))return void this.resolveLocation(this.template.location).then(t=>this.url=t);const t=this.template.location.match(/youtube.com\/watch\?v=([^&]+)/);if(t)return this.youtube=!0,void(this.url=this.createYouTubeURL(t[1]));const s=this.template.location.match(/youtu\.be\/([^\?]+)/);if(s)return this.youtube=!0,void(this.url=this.createYouTubeURL(s[1]));this.url=this.template.location}createYouTubeURL(t){const s=this.template&&new URL(this.template.location);return`${"https://www.youtube.com/embed/"+t}?start=${s&&s.searchParams.get("t")||0}&autoplay=${this.template&&this.template.autoplay}`}renderVideo(){if(!this.template||!this.url)return null;const{autoplay:t}=this.template;return s("video",{key:this.url,autoplay:t,muted:t,playsInline:t,controls:!0},s("source",{src:this.url}))}renderYouTube(){return[s("img",{src:"http://placehold.it/16x9"}),s("iframe",{src:this.url,frameborder:"0",allowFullScreen:!0})]}render(){return this.youtube?this.renderYouTube():this.renderVideo()}static get style(){return"bce-element-video{position:relative;display:block;margin:1rem auto;max-width:1200px;text-align:center}bce-element-video img,bce-element-video video{width:100%;height:auto}bce-element-video img{opacity:0}bce-element-video iframe{position:absolute;top:0;left:0;width:100%;height:100%}\@media screen and (min-width:1024px){bce-element-video{text-align:left;width:auto}}"}};export{i as bce_element_video};