{"version":3,"file":"HeroVideoAlt.DDPOK6Dc.mjs","names":["React.useState","React.useRef"],"sources":["https:/framerusercontent.com/modules/Kb1kgT33TI0Ht9DP2NZM/vZEtMZ5pYBistdf2zfFZ/HeroVideoAlt.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";/* -------------------------------------------------\n   HeroVideo component\n   ------------------------------------------------- */export function HeroVideo({videoUrl,showControls,posterFile}){const[videoID,setVideoID]=React.useState(null);const[origin,setOrigin]=React.useState(\"\");const[showPoster,setShowPoster]=React.useState(true);// NEW – only load iframe once component is near viewport\nconst[shouldLoadVideo,setShouldLoadVideo]=React.useState(false);const wrapperRef=React.useRef(null);/* -------------------------------------------------\n     * 1️⃣  Get the page origin\n     * ------------------------------------------------- */React.useEffect(()=>{setOrigin(window.location.origin);},[]);/* -------------------------------------------------\n     * 2️⃣  Extract YouTube video ID\n     * ------------------------------------------------- */React.useEffect(()=>{if(!videoUrl)return;try{const parsed=new URL(videoUrl);let id=null;if(parsed.searchParams.get(\"v\")){id=parsed.searchParams.get(\"v\");}else if(parsed.hostname===\"youtu.be\"){id=parsed.pathname.slice(1);}else if(parsed.pathname.includes(\"/shorts/\")){id=parsed.pathname.split(\"/shorts/\")[1];}else if(parsed.pathname.includes(\"/embed/\")){id=parsed.pathname.split(\"/embed/\")[1];}if(id){id=id.split(\"?\")[0].split(\"#\")[0];setVideoID(id);}}catch{// invalid URL → keep videoID null\n}},[videoUrl]);/* -------------------------------------------------\n     * 3️⃣  Lazy load once near viewport\n     * ------------------------------------------------- */React.useEffect(()=>{if(!wrapperRef.current)return;const observer=new IntersectionObserver(([entry])=>{if(entry.isIntersecting){setShouldLoadVideo(true);observer.disconnect();}},{root:null,rootMargin:\"300px\",threshold:.01});observer.observe(wrapperRef.current);return()=>observer.disconnect();},[]);/* -------------------------------------------------\n     * 4️⃣  Build the YouTube embed URL\n     * ------------------------------------------------- */const embedUrl=videoID&&origin?`https://www.youtube.com/embed/${videoID}`+`?autoplay=1`+`&mute=1`+`&controls=${showControls?1:0}`+`&loop=1`+`&playlist=${videoID}`+`&playsinline=1`+`&modestbranding=1`+`&rel=0`+`&enablejsapi=1`+`&origin=${encodeURIComponent(origin)}`:\"\";/* -------------------------------------------------\n     * 5️⃣  Poster background\n     * ------------------------------------------------- */const wrapperMergedStyle={...wrapperStyle,...posterFile&&showPoster?{backgroundImage:`url(${posterFile})`,backgroundSize:\"cover\",backgroundPosition:\"center\"}:{}};return /*#__PURE__*/_jsx(\"div\",{ref:wrapperRef,style:wrapperMergedStyle,children:videoID&&origin&&shouldLoadVideo&&/*#__PURE__*/_jsx(\"iframe\",{src:embedUrl,style:iframeStyle,frameBorder:\"0\",loading:\"lazy\",allow:\"autoplay; fullscreen; picture-in-picture\",allowFullScreen:true,onLoad:()=>setShowPoster(false)},videoID)});}/* -------------------------------------------------\n   Static styles\n   ------------------------------------------------- */const wrapperStyle={position:\"absolute\",inset:0,overflow:\"hidden\",backgroundColor:\"#000\"};const iframeStyle={position:\"absolute\",top:\"50%\",left:\"50%\",width:\"177.78vh\",height:\"100vh\",minWidth:\"100%\",minHeight:\"56.25vw\",transform:\"translate(-50%, -50%)\",pointerEvents:\"auto\"};/* -------------------------------------------------\n   Framer property controls\n   ------------------------------------------------- */addPropertyControls(HeroVideo,{videoUrl:{type:ControlType.String,title:\"YouTube URL\",defaultValue:\"\"},showControls:{type:ControlType.Boolean,title:\"Show Controls\",defaultValue:false},posterFile:{type:ControlType.Image,title:\"Poster Image\",defaultValue:\"\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"HeroVideo\":{\"type\":\"reactComponent\",\"name\":\"HeroVideo\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./HeroVideoAlt.map"],"mappings":"uMAEuD,SAAgB,EAAU,CAAC,WAAS,eAAa,cAAY,CAAC,GAAK,CAAC,EAA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