{"version":3,"file":"HeroDeferredVideo.DenfWzzh.mjs","names":["useRef","useState","useCallback","useMemo"],"sources":["https:/framerusercontent.com/modules/8lNWF9vpAvHhED62dHrw/FMmxbyOMSUxdZP5Sjv1t/HeroDeferredVideo.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{startTransition,useCallback,useEffect,useMemo,useRef,useState}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * @framerIntrinsicWidth 1200\n * @framerIntrinsicHeight 675\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function HeroDeferredVideo(props){const{posterUrl={src:\"https://framerusercontent.com/images/GfGkADagM4KEibNcIiRUWlfrR0.jpg\",alt:\"Gradient 1 - Blue\"},altText=\"\",videoUrl=\"https://res.cloudinary.com/snapkit/video/upload/f_mp4,vc_h264,w_1280,q_auto:good,so_0/v1759218213/SnapCube%20Framer/p2ifaftwhfsvaasaotya.mp4\",fallbackDelayMs=5e3,aspectRatio=\"\",debug=false,style}=props;const posterSrc=typeof posterUrl===\"string\"?posterUrl:posterUrl?.src;const posterSrcSet=typeof posterUrl===\"string\"?undefined:posterUrl?.srcSet;const posterAlt=altText||(typeof posterUrl===\"string\"?\"\":posterUrl?.alt)||\"\";const isStatic=useIsStaticRenderer();const rootRef=useRef(null);const mountRef=useRef(null);const enabledRef=useRef(false);const timeoutIdRef=useRef(null);const[showVideo,setShowVideo]=useState(false);const[videoStarted,setVideoStarted]=useState(false);const enableVideo=useCallback(reason=>{if(enabledRef.current)return;enabledRef.current=true;const g=typeof globalThis!==\"undefined\"?globalThis:undefined;if(g&&timeoutIdRef.current!=null){g.clearTimeout(timeoutIdRef.current);timeoutIdRef.current=null;}if(debug&&typeof console!==\"undefined\"){console.log(\"[HeroDeferredVideo] enableVideo:\",reason);}startTransition(()=>setShowVideo(true));},[debug]);useEffect(()=>{if(isStatic)return;if(typeof window===\"undefined\")return;if(showVideo)return;const onFirstInteraction=e=>{enableVideo(`interaction:${e.type}`);};const opts={passive:true};window.addEventListener(\"scroll\",onFirstInteraction,opts);window.addEventListener(\"touchstart\",onFirstInteraction,opts);window.addEventListener(\"pointerdown\",onFirstInteraction,opts);window.addEventListener(\"keydown\",onFirstInteraction);const g=typeof globalThis!==\"undefined\"?globalThis:undefined;if(g){timeoutIdRef.current=g.setTimeout(()=>{enableVideo(\"fallback-timeout\");},Math.max(0,fallbackDelayMs));}return()=>{window.removeEventListener(\"scroll\",onFirstInteraction,opts);window.removeEventListener(\"touchstart\",onFirstInteraction,opts);window.removeEventListener(\"pointerdown\",onFirstInteraction,opts);window.removeEventListener(\"keydown\",onFirstInteraction);if(g&&timeoutIdRef.current!=null){g.clearTimeout(timeoutIdRef.current);timeoutIdRef.current=null;}};},[enableVideo,fallbackDelayMs,isStatic,showVideo]);// Create <video> dynamically ONLY after showVideo\nuseEffect(()=>{if(isStatic)return;if(typeof window===\"undefined\")return;if(!showVideo)return;if(!mountRef.current)return;if(!videoUrl)return;const mount=mountRef.current;mount.innerHTML=\"\";const v=document.createElement(\"video\");v.muted=true;v.playsInline=true;v.loop=true;v.preload=\"none\";v.setAttribute(\"playsinline\",\"\");v.setAttribute(\"preload\",\"none\");v.style.position=\"absolute\";v.style.inset=\"0\";v.style.width=\"100%\";v.style.height=\"100%\";v.style.objectFit=\"cover\";v.style.display=\"block\";v.style.opacity=\"0\";v.style.transition=\"opacity 300ms ease\";const onPlaying=()=>{startTransition(()=>setVideoStarted(true));v.style.opacity=\"1\";if(debug&&typeof console!==\"undefined\"){console.log(\"[HeroDeferredVideo] playing, currentSrc:\",v.currentSrc);}};v.addEventListener(\"playing\",onPlaying,{once:true});mount.appendChild(v);const assignSrcAndPlay=()=>{if(!v.isConnected)return;if(debug&&typeof console!==\"undefined\"){console.log(\"[HeroDeferredVideo] assigning src\");}v.src=videoUrl;try{v.load();}catch{}try{v.play().catch(()=>{});}catch{}};// Ensure poster can finalize LCP before src assignment\nif(typeof window.requestAnimationFrame===\"function\"){window.requestAnimationFrame(()=>{window.setTimeout(assignSrcAndPlay,0);});}else{window.setTimeout(assignSrcAndPlay,0);}return()=>{try{v.pause();}catch{}try{v.removeAttribute(\"src\");v.load();}catch{}try{v.remove();}catch{}};},[debug,isStatic,showVideo,videoUrl]);const posterStyle=useMemo(()=>{return{position:\"absolute\",inset:0,width:\"100%\",height:\"100%\",objectFit:\"cover\",opacity:videoStarted?0:1,transition:\"opacity 300ms ease\",willChange:\"opacity\",display:\"block\",pointerEvents:\"none\"};},[videoStarted]);return /*#__PURE__*/_jsxs(\"div\",{ref:rootRef,style:{position:\"relative\",width:\"100%\",height:\"100vh\",overflow:\"hidden\",...aspectRatio?{aspectRatio}:null,...style},children:[/*#__PURE__*/_jsx(\"div\",{ref:mountRef,style:{position:\"absolute\",inset:0},\"aria-hidden\":altText?undefined:true}),/*#__PURE__*/_jsx(\"img\",{src:posterSrc,srcSet:posterSrcSet,alt:posterAlt,style:posterStyle,draggable:false,loading:\"eager\",fetchPriority:\"high\",decoding:\"async\"})]});}addPropertyControls(HeroDeferredVideo,{videoUrl:{type:ControlType.String,title:\"Video URL\",defaultValue:\"https://res.cloudinary.com/snapkit/video/upload/f_mp4,vc_h264,w_1280,q_auto:good,so_0/v1759218213/SnapCube%20Framer/p2ifaftwhfsvaasaotya.mp4\"},posterUrl:{type:ControlType.ResponsiveImage,title:\"Poster\"},aspectRatio:{type:ControlType.String,title:\"Aspect Ratio\",defaultValue:\"\",placeholder:'e.g. \"16 / 9\"'},fallbackDelayMs:{type:ControlType.Number,title:\"Fallback Delay (ms)\",defaultValue:5e3,min:0,max:3e4,step:250},altText:{type:ControlType.String,title:\"Alt Text\",defaultValue:\"Hero video poster\"},debug:{type:ControlType.Boolean,title:\"Debug\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"HeroDeferredVideo\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"675\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"1200\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./HeroDeferredVideo.map"],"mappings":"gOAMG,SAAwB,EAAkB,EAAM,CAAC,GAAK,CAAC,YAAU,CAAC,IAAI,sEAAsE,IAAI,mBAAmB,EAAE,UAAQ,GAAG,WAAS,+IAA+I,kBAAgB,IAAI,cAAY,GAAG,QAAM,GAAM,SAAO,EAAY,EAAU,OAAO,GAAY,SAAS,EAAU,GAAW,IAAU,EAAa,OAAO,GAAY,SAAS,IAAA,GAAU,GAAW,OAAa,EAAU,IAAU,OAAO,GAAY,SAAS,GAAG,GAAW,MAAM,GAAS,EAAS,EAAoB,EAAQ,EAAQA,EAAO,IAAI,EAAQ,EAASA,EAAO,IAAI,EAAQ,EAAWA,EAAO,EAAK,EAAQ,EAAaA,EAAO,IAAI,EAAO,CAAC,EAAU,GAAcC,EAAS,EAAK,EAAO,CAAC,EAAa,GAAiBA,EAAS,EAAK,EAAQ,EAAYC,EAAY,GAAQ,CAAC,GAAG,EAAW,QAAQ,OAAO,EAAW,QAAQ,GAAK,IAAM,EAAE,OAAO,WAAa,IAAY,WAAW,IAAA,GAAa,GAAG,EAAa,SAAS,OAAM,EAAE,aAAa,EAAa,OAAO,EAAE,EAAa,QAAQ,MAAS,GAAO,OAAO,QAAU,KAAa,QAAQ,IAAI,mCAAmC,CAAM,EAAG,MAAoB,EAAa,EAAI,CAAC,CAAE,EAAE,CAAC,CAAK,CAAC,EAAE,MAAc,CAA0D,GAAtD,GAA0B,IAAS,QAAsB,EAAU,OAAO,IAAM,EAAmB,GAAG,CAAC,EAAY,eAAe,EAAE,MAAM,CAAE,EAAQ,EAAK,CAAC,QAAQ,EAAI,EAAE,EAAO,iBAAiB,SAAS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