{"version":3,"file":"OptimisedVideo.CEuY2oIB.mjs","names":["useRef","useState","useMemo","__esmMin","init_npm_react_18_3_1","te","pe","window","_e","de","p","init_jsx_runtime","ce","init_ssg_sandbox_shims","addPropertyControls","ControlType","init_framer_DKWANagr","OptimisedVideo","props","containerRef","videoRef","isPlaying","setIsPlaying","autoPlay","hasError","setHasError","canPlay","setCanPlay","hasEnteredRange","setHasEnteredRange","lazyLoad","shouldAttachSources","currentPreload","preloadLevel","target","observer","entry","entries","preloadMargin","video","handlePlay","handlePause","handleError","handleCanPlay","handleLoadStart","fetchPriority","webmSrc","mp4Src","style","poster","objectFit","posterFetchPriority","init_OptimisedVideo"],"sources":["https:/framerusercontent.com/modules/YvCKXA9sQN7gJuUQhntK/S1PaxcIZGeOk9IVfyQSx/OptimisedVideo.js"],"sourcesContent":["// OptimisedVideo component with WebM (VP9) and MP4 (H265) fallback for optimal browser coverage\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{startTransition,useEffect,useMemo,useRef,useState}from\"react\";/**\n * OptimisedVideo\n * Serves WebM (VP9) to most browsers, falls back to MP4 (H265/hvc1) for iOS/Safari.\n * Together these two formats cover ~94% of browsers globally.\n *\n * Recommended ffmpeg commands for preparing source files:\n *\n * WebM (VP9) - Balanced quality/performance:\n *   ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 24 -b:v 0 -vf scale=W:-2 -deadline best -an output.webm\n *\n * MP4 (H265 — for iOS/macOS Safari):\n *   ffmpeg -i input.mp4 -c:v libx265 -crf 20 -vf scale=W:-2 -preset veryslow -tag:v hvc1 -movflags faststart -an output.mp4\n *\n * Quality guidelines (CRF values):\n * - WebM: 28-30 (high quality), 30-33 (balanced), 35-40 (smaller files)\n * - MP4: 23-26 (high quality), 26-28 (balanced), 28-32 (smaller files)\n *\n * Notes:\n * - Replace W with your target width (e.g. 1920). The -2 preserves aspect ratio with an even height.\n * - -movflags faststart is required on the MP4 for progressive loading in the browser.\n * - -an removes the audio track. Keep it — even silent files can carry an empty audio stream.\n * - For sharper output at lower resolutions, add: -vf scale=W:-2,unsharp=5:5:1.0\n * - Lower CRF = higher quality but larger files. Balance based on your display size and bandwidth needs.\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function OptimisedVideo(props){const{webmSrc=\"https://framerusercontent.com/assets/MLWPbW1dUQawJLhhun3dBwpgJak.mp4\",mp4Src=\"https://framerusercontent.com/assets/MLWPbW1dUQawJLhhun3dBwpgJak.mp4\",muted,autoPlay,loop,objectFit,borderRadius,poster=\"\",lazyLoad=true,preloadMargin=\"400px\",preloadLevel=\"auto\",fetchPriority=\"auto\",posterFetchPriority=\"high\",style}=props;const containerRef=useRef(null);const videoRef=useRef(null);const[isPlaying,setIsPlaying]=useState(autoPlay);const[hasError,setHasError]=useState(false);const[canPlay,setCanPlay]=useState(false);const[hasEnteredRange,setHasEnteredRange]=useState(()=>{if(!lazyLoad)return true;if(typeof window===\"undefined\")return true;if(typeof window.IntersectionObserver===\"undefined\")return true;return false;});const shouldAttachSources=useMemo(()=>{if(!lazyLoad)return true;return hasEnteredRange;},[lazyLoad,hasEnteredRange]);const currentPreload=useMemo(()=>{if(!shouldAttachSources)return\"none\";return preloadLevel;},[shouldAttachSources,preloadLevel]);useEffect(()=>{if(!lazyLoad){startTransition(()=>setHasEnteredRange(true));return;}if(typeof window===\"undefined\"){startTransition(()=>setHasEnteredRange(true));return;}if(typeof window.IntersectionObserver===\"undefined\"){startTransition(()=>setHasEnteredRange(true));return;}if(hasEnteredRange)return;const target=containerRef.current;if(!target)return;const observer=new window.IntersectionObserver(entries=>{const[entry]=entries;if(!entry)return;if(entry.isIntersecting){startTransition(()=>setHasEnteredRange(true));observer.unobserve(entry.target);observer.disconnect();}},{root:null,rootMargin:preloadMargin||\"400px\",threshold:0});observer.observe(target);return()=>{observer.disconnect();};},[lazyLoad,preloadMargin,hasEnteredRange]);useEffect(()=>{const video=videoRef.current;if(!video)return;const handlePlay=()=>{startTransition(()=>setIsPlaying(true));};const handlePause=()=>{startTransition(()=>setIsPlaying(false));};const handleError=()=>{startTransition(()=>{setHasError(true);setIsPlaying(false);});};const handleCanPlay=()=>{startTransition(()=>setCanPlay(true));};const handleLoadStart=()=>{startTransition(()=>setCanPlay(false));};video.addEventListener(\"play\",handlePlay);video.addEventListener(\"pause\",handlePause);video.addEventListener(\"error\",handleError);video.addEventListener(\"canplaythrough\",handleCanPlay);video.addEventListener(\"loadstart\",handleLoadStart);return()=>{video.removeEventListener(\"play\",handlePlay);video.removeEventListener(\"pause\",handlePause);video.removeEventListener(\"error\",handleError);video.removeEventListener(\"canplaythrough\",handleCanPlay);video.removeEventListener(\"loadstart\",handleLoadStart);};},[]);useEffect(()=>{if(!videoRef.current)return;if(!shouldAttachSources)return;if(autoPlay){videoRef.current.play().catch(()=>{// Ignore play errors (e.g., user hasn't interacted with page yet)\n});}else{videoRef.current.pause();}},[autoPlay,shouldAttachSources]);useEffect(()=>{const video=videoRef.current;if(!video)return;video.setAttribute(\"fetchpriority\",fetchPriority);},[fetchPriority]);useEffect(()=>{const video=videoRef.current;if(!video)return;if(!shouldAttachSources)return;video.load();},[shouldAttachSources,webmSrc,mp4Src]);// Render nothing if no sources are provided\nif(!webmSrc&&!mp4Src)return null;return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{position:\"relative\",width:\"100%\",height:\"100%\",borderRadius,overflow:\"hidden\",...style},children:[/*#__PURE__*/_jsxs(\"video\",{ref:videoRef,autoPlay:autoPlay,loop:loop,muted:muted,playsInline:true,preload:currentPreload,style:{width:\"100%\",height:\"100%\",objectFit,display:\"block\",border:\"none\",outline:\"none\"},children:[shouldAttachSources&&webmSrc&&/*#__PURE__*/_jsx(\"source\",{src:webmSrc,type:\"video/webm\"}),shouldAttachSources&&mp4Src&&/*#__PURE__*/_jsx(\"source\",{src:mp4Src,type:'video/mp4; codecs=\"hvc1\"'})]}),poster&&/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:0,left:0,width:\"100%\",height:\"100%\",backgroundImage:`url(${poster})`,backgroundSize:objectFit,backgroundPosition:\"center\",backgroundRepeat:\"no-repeat\",opacity:isPlaying&&canPlay&&!hasError?0:1,transition:\"opacity 0.5s ease-in-out\",pointerEvents:\"none\"}}),poster&&/*#__PURE__*/_jsx(\"img\",{src:poster,alt:\"\",\"aria-hidden\":true,loading:\"eager\",fetchPriority:posterFetchPriority,style:{display:\"none\"}})]});}addPropertyControls(OptimisedVideo,{webmSrc:{type:ControlType.File,title:\"WebM (VP9)\",allowedFileTypes:[\"webm\"]},mp4Src:{type:ControlType.File,title:\"MP4 (H265)\",allowedFileTypes:[\"mp4\"]},poster:{type:ControlType.File,title:\"Poster image\",allowedFileTypes:[\"png\",\"jpg\",\"jpeg\",\"webp\"]},lazyLoad:{type:ControlType.Boolean,title:\"Lazy Load\",defaultValue:true},preloadMargin:{type:ControlType.String,title:\"Preload Margin\",defaultValue:\"400px\"},preloadLevel:{type:ControlType.Enum,title:\"Preload Level\",options:[\"none\",\"metadata\",\"auto\"],optionTitles:[\"None\",\"Metadata\",\"Auto\"],defaultValue:\"auto\"},fetchPriority:{type:ControlType.Enum,title:\"Fetch Priority\",options:[\"auto\",\"high\",\"low\"],optionTitles:[\"Auto\",\"High\",\"Low\"],defaultValue:\"auto\"},posterFetchPriority:{type:ControlType.Enum,title:\"Poster Fetch Priority\",options:[\"auto\",\"high\",\"low\"],optionTitles:[\"Auto\",\"High\",\"Low\"],defaultValue:\"high\"},muted:{type:ControlType.Boolean,title:\"Muted\",defaultValue:true},autoPlay:{type:ControlType.Boolean,title:\"Autoplay\",defaultValue:true},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:true},objectFit:{type:ControlType.Enum,title:\"Fit\",options:[\"cover\",\"contain\",\"fill\",\"none\",\"scale-down\"],optionTitles:[\"Cover\",\"Contain\",\"Fill\",\"None\",\"Scale down\"],defaultValue:\"cover\"},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:0,min:0,max:100,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"OptimisedVideo\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./OptimisedVideo.map"],"mappings":"A,4NA2BG,SAAwBiB,EAAe,EAAM,CAAC,GAAK,CAAC,UAAQ,uEAAuE,SAAO,uEAAuE,QAAM,WAAS,OAAK,YAAU,eAAa,SAAO,GAAG,WAAS,GAAK,gBAAc,QAAQ,eAAa,OAAO,gBAAc,OAAO,sBAAoB,OAAO,SAAOC,EAAYC,EAAanB,EAAO,IAAI,EAAQoB,EAASpB,EAAO,IAAI,EAAO,CAACqB,EAAUC,GAAcrB,EAASsB,CAAQ,EAAO,CAACC,EAASC,GAAaxB,EAAS,EAAK,EAAO,CAACyB,EAAQC,GAAY1B,EAAS,EAAK,EAAO,CAAC2B,EAAgBC,GAAoB5B,MAAiB,CAAC6B,GAA+BvB,IAAS,QAAkCA,EAAO,uBAAuB,MAAsC,EAAQwB,EAAoB7B,MAAa,CAAI4B,GAA4BF,EAAkB,CAACE,EAASF,CAAe,CAAC,EAAQI,EAAe9B,MAAiB6B,EAAwCE,EAAd,OAA6B,CAACF,EAAoBE,CAAY,CAAC,EAEh+B,OAFk+BrB,MAAc,CAA2J,GAAvJ,CAACkB,GAA0EvB,IAAS,QAA6EA,EAAO,uBAAuB,OAAY,CAACF,MAAoBwB,EAAmB,EAAI,CAAC,EAAE,MAAO,CAAC,GAAGD,EAAgB,OAAO,IAAMM,EAAOf,EAAa,QAAQ,GAAG,CAACe,EAAO,OAAO,IAAMC,EAAS,IAAI5B,EAAO,qBAAqB,GAAS,CAAC,GAAK,CAAC6B,GAAOC,EAAYD,GAAgBA,EAAM,iBAAgB/B,MAAoBwB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