"use strict";(self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[178],{178:(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var a=r(66845),n=r(16295),s=r(68785),i=r(40864);const d=528;function l(e){let{element:t,width:r,endpoints:l,elementMgr:o}=e;const u=(0,a.useRef)(null),{type:c,url:p,startTime:m,subtitles:f,endTime:h,loop:v,autoplay:y,muted:E}=t,T=(0,a.useMemo)((()=>{if(!t.id)return!0;const e=o.getElementState(t.id,"preventAutoplay");return e||o.setElementState(t.id,"preventAutoplay",!0),null!==e&&void 0!==e&&e}),[t.id,o]);(0,a.useEffect)((()=>{u.current&&(u.current.currentTime=m)}),[m]),(0,a.useEffect)((()=>{const e=u.current,r=()=>{e&&(e.currentTime=t.startTime)};return e&&e.addEventListener("loadedmetadata",r),()=>{e&&e.removeEventListener("loadedmetadata",r)}}),[t]),(0,a.useEffect)((()=>{const e=u.current;if(!e)return;let t=!1;const r=()=>{h>0&&e.currentTime>=h&&(v?(e.currentTime=m||0,e.play()):t||(t=!0,e.pause()))};return h>0&&e.addEventListener("timeupdate",r),()=>{e&&h>0&&e.removeEventListener("timeupdate",r)}}),[h,v,m]),(0,a.useEffect)((()=>{const e=u.current;if(!e)return;const t=()=>{v&&(e.currentTime=m||0,e.play())};return e.addEventListener("ended",t),()=>{e&&e.removeEventListener("ended",t)}}),[v,m]);const g=e=>{const{startTime:r,endTime:a,loop:n,autoplay:s,muted:i}=t,d=new URL(e);if(r&&!isNaN(r)&&d.searchParams.append("start",r.toString()),a&&!isNaN(a)&&d.searchParams.append("end",a.toString()),n){d.searchParams.append("loop","1");const e=d.pathname.split("/").pop();e&&d.searchParams.append("playlist",e)}return s&&d.searchParams.append("autoplay","1"),i&&d.searchParams.append("mute","1"),d.toString()};if(c===n.nk.Type.YOUTUBE_IFRAME){const e=0!==r?.75*r:d;return(0,i.jsx)("iframe",{"data-testid":"stVideo",title:p,src:g(p),width:r,height:e,style:{colorScheme:"normal"},frameBorder:"0",allow:"autoplay; encrypted-media",allowFullScreen:!0})}return(0,i.jsx)("video",{"data-testid":"stVideo",ref:u,controls:!0,muted:E,autoPlay:y&&!T,src:l.buildMediaURL(p),className:"stVideo",style:{width:r,height:0===r?d:void 0},crossOrigin:s.td&&f.length>0?"anonymous":void 0,children:f&&f.map(((e,t)=>(0,i.jsx)("track",{kind:"captions",src:l.buildMediaURL(e.url),label:e.label,default:0===t},t)))})}}}]);