{"version":3,"file":"HeroVideoAlt.Cl1k5KP8.mjs","names":["React.useRef","React.useState","React.useMemo","React.useCallback","__esmMin","ne","init_ssg_sandbox_shims","init_npm_react_18_3_1","window","pe","ce","init_jsx_runtime","p","_e","de","addPropertyControls","init_framer_DDfsYcI0","ControlType","HeroVideo","wrapperRef","shouldLoadVideo","setShouldLoadVideo","source","videoUrl","captions","subtitlesUrl","youTubeId","getYouTubeId","wrapper","observer","entry","wrapperStyle","style","posterFile","YouTubeSurface","showSubtitles","VideoSurface","url","parsed","host","id","YOUTUBE_ID","iframeRef","heardFromPlayer","isPlaying","setIsPlaying","failed","setFailed","src","params","videoId","onMessage","event","data","fallback","handleLoad","attempts","ping","win","youTubeStyle","hasPoster","videoRef","syncCaptions","tracks","i","poster","videoStyle","init_HeroVideoAlt","props"],"sources":["https:/framerusercontent.com/modules/Kb1kgT33TI0Ht9DP2NZM/UAhDwehJUN847A0mxSua/HeroVideoAlt.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Full-height hero background. Accepts either:\n *  - a public, direct video file URL (e.g. Cloudflare R2), or\n *  - a YouTube link (watch, youtu.be, shorts, embed or live URLs).\n * Autoplays muted, loops, and crops to fill the available width at 100vh.\n * Starts loading within 300px of the viewport.\n * Captions: WebVTT file for direct videos, YouTube's own captions for YouTube.\n */export function HeroVideo({videoUrl=\"\",posterFile=\"\",showSubtitles=false,subtitlesUrl=\"\",style}){const wrapperRef=React.useRef(null);const[shouldLoadVideo,setShouldLoadVideo]=React.useState(false);const source=videoUrl.trim();const captions=subtitlesUrl.trim();const youTubeId=getYouTubeId(source);React.useEffect(()=>{const wrapper=wrapperRef.current;if(!wrapper)return;if(typeof IntersectionObserver===\"undefined\"){setShouldLoadVideo(true);return;}const observer=new IntersectionObserver(([entry])=>{if(entry.isIntersecting){setShouldLoadVideo(true);observer.disconnect();}},{rootMargin:\"300px\",threshold:.01});observer.observe(wrapper);return()=>observer.disconnect();},[]);return /*#__PURE__*/_jsxs(\"div\",{ref:wrapperRef,style:{...wrapperStyle,...style,height:\"100vh\",flexShrink:0,overflow:\"hidden\",...posterFile?{backgroundImage:`url(${JSON.stringify(posterFile)})`,backgroundSize:\"cover\",backgroundPosition:\"center\"}:{}},children:[shouldLoadVideo&&source&&youTubeId&&/*#__PURE__*/_jsx(YouTubeSurface,{videoId:youTubeId,hasPoster:!!posterFile,showSubtitles:showSubtitles},`${youTubeId}|${showSubtitles}`),shouldLoadVideo&&source&&!youTubeId&&/*#__PURE__*/_jsx(VideoSurface,{source:source,poster:posterFile,captions:captions,showSubtitles:showSubtitles},`${source}|${captions}`)]});}/* ---------------------------------------------------------------- *//* YouTube                                                           *//* ---------------------------------------------------------------- */const YOUTUBE_ID=/^[\\w-]{11}$/;/** Returns the 11-character video ID for any common YouTube URL, else null. */function getYouTubeId(url){if(!url)return null;try{const parsed=new URL(url);const host=parsed.hostname.replace(/^(www\\.|m\\.)/,\"\");let id=null;if(host===\"youtu.be\"){id=parsed.pathname.slice(1).split(\"/\")[0];}else if(host.endsWith(\"youtube.com\")||host.endsWith(\"youtube-nocookie.com\")){id=parsed.searchParams.get(\"v\")??parsed.pathname.match(/^\\/(?:embed|shorts|live|v)\\/([\\w-]{11})/)?.[1];}return id&&YOUTUBE_ID.test(id)?id:null;}catch{return null;}}function YouTubeSurface({videoId,hasPoster,showSubtitles}){const iframeRef=React.useRef(null);const heardFromPlayer=React.useRef(false);const[isPlaying,setIsPlaying]=React.useState(false);const[failed,setFailed]=React.useState(false);const src=React.useMemo(()=>{const params=new URLSearchParams({autoplay:\"1\",mute:\"1\",loop:\"1\",playlist:videoId,controls:\"0\",playsinline:\"1\",rel:\"0\",modestbranding:\"1\",iv_load_policy:\"3\",disablekb:\"1\",fs:\"0\",enablejsapi:\"1\",cc_load_policy:showSubtitles?\"1\":\"0\",cc_lang_pref:\"en\"});if(typeof window!==\"undefined\"){params.set(\"origin\",window.location.origin);}return`https://www.youtube-nocookie.com/embed/${videoId}?${params}`;},[videoId,showSubtitles]);// Listen to the player so the iframe only fades in once the video is\n// actually playing — the poster stays visible until then.\nReact.useEffect(()=>{const onMessage=event=>{if(event.source!==iframeRef.current?.contentWindow)return;let data=event.data;if(typeof data===\"string\"){try{data=JSON.parse(data);}catch{return;}}if(!data||typeof data!==\"object\")return;heardFromPlayer.current=true;const state=data.event===\"onStateChange\"?data.info:data.info?.playerState;if(state===1)setIsPlaying(true)// 1 = playing\n;if(data.event===\"onError\")setFailed(true);};window.addEventListener(\"message\",onMessage);// Safety net: if the player never talks back, show it anyway.\nconst fallback=window.setTimeout(()=>{if(!heardFromPlayer.current)setIsPlaying(true);},4e3);return()=>{window.removeEventListener(\"message\",onMessage);window.clearTimeout(fallback);};},[]);// Ask the player to send state updates (repeat until it answers).\nconst handleLoad=React.useCallback(()=>{let attempts=0;const ping=()=>{const win=iframeRef.current?.contentWindow;if(!win||heardFromPlayer.current||attempts>20)return;attempts++;win.postMessage(JSON.stringify({event:\"listening\",id:1,channel:\"widget\"}),\"*\");window.setTimeout(ping,250);};ping();},[]);// Keep the wrapper's poster background visible if the video cannot load.\nif(failed)return null;return /*#__PURE__*/_jsx(\"iframe\",{ref:iframeRef,src:src,title:\"Background video\",style:{...youTubeStyle,opacity:isPlaying||!hasPoster?1:0},allow:\"autoplay; encrypted-media; picture-in-picture\",referrerPolicy:\"strict-origin-when-cross-origin\",tabIndex:-1,\"aria-hidden\":!showSubtitles,onLoad:handleLoad});}/* ---------------------------------------------------------------- *//* Direct video file (R2)                                            *//* ---------------------------------------------------------------- */function VideoSurface({source,poster,captions,showSubtitles}){const videoRef=React.useRef(null);const[failed,setFailed]=React.useState(false);const syncCaptions=React.useCallback(()=>{const tracks=videoRef.current?.textTracks;if(!tracks)return;for(let i=0;i<tracks.length;i++){if(tracks[i].kind===\"captions\"||tracks[i].kind===\"subtitles\"){tracks[i].mode=showSubtitles?\"showing\":\"disabled\";}}},[showSubtitles]);React.useEffect(syncCaptions,[syncCaptions]);// Keep the wrapper's poster background visible if the video cannot load.\nif(failed)return null;return /*#__PURE__*/_jsx(\"video\",{ref:videoRef,src:source,poster:poster||undefined,style:videoStyle,autoPlay:true,muted:true,loop:true,playsInline:true,controls:false,preload:\"metadata\",crossOrigin:captions?\"anonymous\":undefined,disablePictureInPicture:true,\"aria-hidden\":!showSubtitles,onLoadedMetadata:syncCaptions,onError:()=>setFailed(true),children:captions&&/*#__PURE__*/_jsx(\"track\",{kind:\"captions\",src:captions,srcLang:\"en\",label:\"English\",default:showSubtitles,onLoad:syncCaptions})});}/* ---------------------------------------------------------------- *//* Styles                                                            *//* ---------------------------------------------------------------- */const wrapperStyle={position:\"relative\",width:\"100%\",height:\"100vh\",overflow:\"hidden\",backgroundColor:\"#000\",// Lets the YouTube iframe size itself relative to this box (cqw / cqh).\ncontainerType:\"size\"};const videoStyle={position:\"absolute\",inset:0,width:\"100%\",height:\"100%\",objectFit:\"cover\",objectPosition:\"center\",display:\"block\",border:0,pointerEvents:\"none\"};// iframes can't use object-fit, so we size a 16:9 frame large enough to\n// cover the wrapper in both directions and centre it — same effect as \"cover\".\nconst youTubeStyle={position:\"absolute\",top:\"50%\",left:\"50%\",width:\"max(100cqw, 177.78cqh)\",height:\"max(100cqh, 56.25cqw)\",transform:\"translate(-50%, -50%)\",border:0,display:\"block\",pointerEvents:\"none\",transition:\"opacity 0.6s ease\"};addPropertyControls(HeroVideo,{videoUrl:{type:ControlType.String,title:\"Video URL\",defaultValue:\"\",placeholder:\"R2 .mp4 link or YouTube link\",description:\"Public, direct video file URL (e.g. Cloudflare R2) or a YouTube link.\"},posterFile:{type:ControlType.Image,title:\"Poster Image\",defaultValue:\"\"},showSubtitles:{type:ControlType.Boolean,title:\"Subtitles\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},subtitlesUrl:{type:ControlType.String,title:\"Captions URL\",defaultValue:\"\",placeholder:\"https://your-video-domain.com/captions.vtt\",description:\"Optional English WebVTT file. For cross-origin captions, enable CORS on both the video and captions files.\",// YouTube uses its own captions, so this field only shows for direct files.\nhidden:props=>!props.showSubtitles||!!getYouTubeId(props.videoUrl?.trim()??\"\")}});\nexport const __FramerMetadata__ = {\"exports\":{\"HeroVideo\":{\"type\":\"reactComponent\",\"name\":\"HeroVideo\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./HeroVideoAlt.map"],"mappings":"A,2NAOG,SAAgBkB,EAAU,CAAC,WAAS,GAAG,aAAW,GAAG,gBAAc,GAAM,eAAa,GAAG,SAAO,CAAC,IAAMC,EAAWnB,EAAa,IAAI,EAAO,CAACoB,EAAgBC,GAAoBpB,EAAe,EAAK,EAAQqB,EAAOC,EAAS,KAAK,EAAQC,EAASC,EAAa,KAAK,EAAQC,EAAUC,EAAaL,CAAM,EAA6X,OAA3XZ,MAAoB,CAAC,IAAMkB,EAAQT,EAAW,QAAQ,GAAG,CAACS,EAAQ,OAAO,GAAG,OAAO,qBAAuB,IAAY,CAACP,EAAmB,EAAI,EAAE,MAAO,CAAC,IAAMQ,EAAS,IAAI,sBAAsB,CAACC,KAAS,CAAIA,EAAM,iBAAgBT,EAAmB,EAAI,EAAEQ,EAAS,WAAW,EAAG,EAAE,CAAC,WAAW,QAAQ,UAAU,GAAG,CAAC,EAA4B,OAA1BA,EAAS,QAAQD,CAAO,MAAYC,EAAS,WAAW,CAAE,EAAE,CAAC,CAAC,EAAsB,gBAAM,MAAM,CAAC,IAAIV,EAAW,MAAM,CAAC,GAAGY,EAAa,GAAGC,EAAM,OAAO,QAAQ,WAAW,EAAE,SAAS,SAAS,GAAGC,EAAW,CAAC,gBAAgB,OAAO,KAAK,UAAUA,CAAU,EAAE,GAAG,eAAe,QAAQ,mBAAmB,QAAQ,EAAE,CAAC,CAAC,EAAE,SAAS,CAACb,GAAiBE,GAAQI,GAAwB,gBAAKQ,EAAe,CAAC,QAAQR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