{"version":3,"file":"CaseVideo.DP6h46WI.mjs","names":["useRef","__esmMin","init_npm_react_18_3_1","c","init_jsx_runtime","ce","de","init_framer_BWFVvmND","ControlType","addPropertyControls","CaseVideo","props","src","file","url","videoRef","video","autoplayLoop","painted","primed","prime","started","startOnView","observer","entry","sized","ratio","style","fit","init_CaseVideo"],"sources":["https:/framerusercontent.com/modules/arOEGiAFBcMCI7ka7SrY/DH0viKqFQzMiiCf0VpGO/CaseVideo.js"],"sourcesContent":["// Case study video: plays a video filling its frame. Autoplay + loop + muted by\n// default to match how videos behaved on the old Cargo site; turn Autoplay Loop\n// off to show native player controls instead. An uploaded Video file takes\n// priority over the Video URL. Built for the case study migration.\n// Autoplaying videos pause while off screen so they don't decode frames (and cost\n// scroll smoothness) when nobody can see them.\n// Ratio (width ÷ height, e.g. 1.7778 for 16:9): when set and the layer's height is\n// Fit, the player keeps that shape at any width, so the video is never cropped or\n// letterboxed. Leave it at 0 to fill whatever frame the layer is given.\n// Start On View holds the video on its first frame until it is scrolled to, then\n// plays it from the beginning — so a viewer never arrives at a clip already halfway\n// through. Without it the browser starts playback as the page loads, off screen.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerIntrinsicWidth 540\n * @framerIntrinsicHeight 304\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight any\n */export default function CaseVideo(props){const{file,url,autoplayLoop,startOnView,fit,ratio,style}=props;const src=file||url;const videoRef=useRef(null);useEffect(()=>{const video=videoRef.current;if(!video||!autoplayLoop||typeof IntersectionObserver===\"undefined\")return;// Has the browser actually put a frame on screen? Framer fades a section in as it\n// is reached, and a video that starts playing inside a still-faded section can end\n// up decoding frames without ever presenting one: it plays, but the layer stays\n// transparent for good. requestVideoFrameCallback only fires on a presented frame,\n// so this stays false in exactly that case.\nlet painted=false;const anyVideo=video;anyVideo.requestVideoFrameCallback?.(()=>{painted=true;});// Reloading once, the first time the video comes into view, gives it a fresh\n// pipeline and the frames appear. Skipped when it is already painting.\nlet primed=false;const prime=()=>{if(primed)return;primed=true;if(!painted)video.load();};// With Start On View the clip has never run, so begin it at zero rather than\n// wherever the browser happened to leave it.\nlet started=!startOnView;const observer=new IntersectionObserver(([entry])=>{if(entry.isIntersecting){prime();if(!started){started=true;video.currentTime=0;}video.play().catch(()=>{});}else video.pause();},// Start On View waits until the player is actually on screen; otherwise\n// playback resumes a little early so scrolling never lands on a frozen frame.\n{rootMargin:startOnView?\"0px\":\"200px 0px\"});observer.observe(video);return()=>observer.disconnect();},[autoplayLoop,startOnView,src]);const sized=ratio>0?{height:\"auto\",aspectRatio:String(ratio)}:{height:\"100%\"};return /*#__PURE__*/_jsx(\"div\",{style:{...style,position:\"relative\",width:\"100%\",...sized,overflow:\"hidden\",background:\"rgba(29, 86, 14, 0.06)\"},children:src?/*#__PURE__*/_jsx(\"video\",{ref:videoRef,src:src,// Holding the first frame until the viewer reaches it means no autoplay\n// attribute: the observer starts playback instead.\nautoPlay:autoplayLoop&&!startOnView,loop:autoplayLoop,muted:autoplayLoop,controls:!autoplayLoop,playsInline:true,preload:autoplayLoop?\"auto\":\"metadata\",style:{position:\"absolute\",inset:0,width:\"100%\",height:\"100%\",objectFit:fit}}):null});}addPropertyControls(CaseVideo,{file:{type:ControlType.File,title:\"Video\",allowedFileTypes:[\"mp4\",\"mov\",\"webm\"]},url:{type:ControlType.String,title:\"Video URL\",defaultValue:\"\"},autoplayLoop:{type:ControlType.Boolean,title:\"Autoplay Loop\",defaultValue:true},startOnView:{type:ControlType.Boolean,title:\"Start On View\",description:\"Hold the first frame until the viewer scrolls to it, then play from the start.\",defaultValue:false,hidden:props=>!props.autoplayLoop},fit:{type:ControlType.Enum,title:\"Fit\",options:[\"cover\",\"contain\"],optionTitles:[\"Cover\",\"Contain\"],defaultValue:\"cover\"},ratio:{type:ControlType.Number,title:\"Ratio\",description:\"Width \\xf7 height (1.7778 = 16:9). Set the layer's height to Fit. 0 = fill the frame.\",defaultValue:0,min:0,max:5,step:1e-4}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CaseVideo\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any\",\"framerIntrinsicWidth\":\"540\",\"framerIntrinsicHeight\":\"304\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CaseVideo.map"],"mappings":"A,iLAkBG,SAAwBU,EAAU,EAAM,CAAC,GAAK,CAAC,OAAK,MAAI,eAAa,cAAY,MAAI,QAAM,SAAOC,EAAYC,EAAIC,GAAMC,EAAUC,EAASf,EAAO,IAAI,EAAEK,MAAc,CAAC,IAAMW,EAAMD,EAAS,QAAQ,GAAG,CAACC,GAAO,CAACC,GAAc,OAAO,qBAAuB,IAAY,OAK3Q,IAAIC,EAAQ,GAA2BF,EAAS,gCAAgC,CAAC,EAAQ,EAAK,CAAC,EAE/F,IAAIG,EAAO,GAAYC,MAAU,CAAID,IAAc,EAAO,GAASD,GAAQF,EAAM,KAAK,EAAE,EAEpFK,EAAQ,CAACC,EAAkBC,EAAS,IAAI,sBAAsB,CAACC,KAAS,CAAIA,EAAM,gBAAgBJ,EAAM,EAAMC,IAAS,EAAQ,GAAK,EAAM,YAAY,GAAGL,EAAM,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,GAAQA,EAAM,MAAM,CAAE,EAE5M,CAAC,WAAWM,EAAY,MAAM,WAAW,CAAC,EAA0B,OAAxBC,EAAS,QAAQP,CAAK,MAAYO,EAAS,WAAW,CAAE,EAAE,CAACN,EAAaK,EAAYV,CAAG,CAAC,EAAE,IAAMa,EAAMC,EAAM,EAAE,CAAC,OAAO,OAAO,YAAY,OAAOA,CAAK,CAAC,EAAE,CAAC,OAAO,MAAM,EAAE,MAAoB,gBAAK,MAAM,CAAC,MAAM,CAAC,GAAGC,EAAM,SAAS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