{"version":3,"file":"BrightProjectReel.COb__LSh.mjs","names":["useRef","useState","__esmMin","init_ssg_sandbox_shims","window","_e","de","init_jsx_runtime","c","p","init_npm_react_18_3_1","ce","useInView","useReducedMotion","init_framer_motion_DhsWWWsN","addPropertyControls","ControlType","init_framer_Bf4_tcb2","useIsStaticRenderer","BrightProjectReel","root","player","mounted","intent","pendingPauses","pendingPlays","expectedPlayEvents","playbackRevision","isStatic","inView","reducedMotion","pageVisible","setPageVisible","pageLoaded","setPageLoaded","activatedSource","setActivatedSource","frameSource","setFrameSource","failedSource","setFailedSource","source","video","browser","canMount","hasFrame","gates","pause","element","visibleNow","g","shouldResume","update","onLoad","controls","autoplay","reconcilePlayback","revision","request","mediaStyle","poster","style","title","event","programmatic","pending","init_BrightProjectReel"],"sources":["https:/framerusercontent.com/modules/sqpdVv6ZkkBbGE9isJgl/uRBPMQ74DPuGPSSIyA5x/BrightProjectReel.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{useInView,useReducedMotion}from\"framer-motion\";/**\n * @framerIntrinsicWidth 960\n * @framerIntrinsicHeight 540\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function BrightProjectReel({video=\"\",poster,title=\"Project reel\",controls=false,autoplay=true,style}){const root=useRef(null);const player=useRef(null);const mounted=useRef(false);const intent=useRef(\"auto\");const pendingPauses=useRef(new WeakMap);const pendingPlays=useRef(new WeakSet);const expectedPlayEvents=useRef(new WeakSet);const playbackRevision=useRef(0);const isStatic=useIsStaticRenderer();const inView=useInView(root,{amount:.15});const reducedMotion=useReducedMotion();const[pageVisible,setPageVisible]=useState(false);const[pageLoaded,setPageLoaded]=useState(false);const[activatedSource,setActivatedSource]=useState(\"\");const[frameSource,setFrameSource]=useState(\"\");const[failedSource,setFailedSource]=useState(\"\");const source=typeof video===\"string\"?video.trim():\"\";const browser=typeof window!==\"undefined\"&&typeof document!==\"undefined\";const canMount=browser&&!isStatic&&!!source&&activatedSource===source&&failedSource!==source;const hasFrame=canMount&&frameSource===source;const gates=useRef({inView,pageVisible,isStatic,reducedMotion,autoplay,source,canMount});gates.current={inView,pageVisible,isStatic,reducedMotion,autoplay,source,canMount};const pause=element=>{if(!element||element.paused)return;pendingPauses.current.set(element,(pendingPauses.current.get(element)||0)+1);element.pause();};const visibleNow=()=>{const g=gates.current;return mounted.current&&g.canMount&&g.inView&&g.pageVisible&&!g.isStatic&&typeof document!==\"undefined\"&&!document.hidden;};const shouldResume=()=>{const g=gates.current;return visibleNow()&&g.reducedMotion===false&&intent.current!==\"pause\"&&(g.autoplay||intent.current===\"play\");};useEffect(()=>{mounted.current=true;return()=>{mounted.current=false;pause(player.current);};},[]);useEffect(()=>{intent.current=\"auto\";setFailedSource(\"\");setFrameSource(\"\");},[source]);useEffect(()=>{if(isStatic||typeof document===\"undefined\")return;const update=()=>{if(document.hidden)pause(player.current);setPageVisible(!document.hidden);};update();document.addEventListener(\"visibilitychange\",update);return()=>document.removeEventListener(\"visibilitychange\",update);},[isStatic]);// Wait for the page load event so the video never competes with the poster (LCP).\nuseEffect(()=>{if(isStatic||typeof window===\"undefined\"||typeof document===\"undefined\")return;if(document.readyState===\"complete\"){setPageLoaded(true);return;}const onLoad=()=>setPageLoaded(true);window.addEventListener(\"load\",onLoad,{once:true});return()=>window.removeEventListener(\"load\",onLoad);},[isStatic]);// Load on view: attach the video source only once the page has loaded and the reel is in view.\n// Until then the poster shows. A reduced-motion visitor can still choose to play through native controls.\nuseEffect(()=>{if(source&&inView&&pageLoaded&&pageVisible&&!isStatic&&(controls||autoplay&&reducedMotion===false)){setActivatedSource(source);}},[source,inView,pageLoaded,pageVisible,isStatic,controls,autoplay,reducedMotion]);// Capture the actual element: React may clear the ref before cleanup runs.\nuseEffect(()=>{const element=player.current;return()=>{pause(element);};},[canMount,source]);const reconcilePlayback=element=>{if(player.current!==element||!shouldResume()){pause(element);return;}if(!element.paused||pendingPlays.current.has(element))return;const revision=playbackRevision.current;pendingPlays.current.add(element);expectedPlayEvents.current.add(element);let request;try{request=element.play();}catch{pendingPlays.current.delete(element);expectedPlayEvents.current.delete(element);return;}request.then(()=>{// A play request can settle after scrolling away or changing the file.\nif(player.current!==element||!shouldResume())pause(element);}).catch(()=>{expectedPlayEvents.current.delete(element);// Keep the poster; native controls can retry when they are enabled.\n}).finally(()=>{pendingPlays.current.delete(element);// An interrupted request can settle after a rapid leave-and-return.\n// Retry only for a new gate revision, never loop on blocked autoplay.\nif(revision!==playbackRevision.current&&element.paused&&player.current===element&&shouldResume())reconcilePlayback(element);});};useEffect(()=>{playbackRevision.current+=1;const element=player.current;if(element&&canMount)reconcilePlayback(element);},[canMount,source,inView,pageVisible,isStatic,reducedMotion,autoplay]);const mediaStyle={position:\"absolute\",inset:0,display:\"block\",width:\"100%\",height:\"100%\",objectFit:\"contain\"};const state=!source?\"poster\":isStatic||!browser?\"static\":failedSource===source?\"error\":hasFrame?\"ready\":canMount?\"loading\":\"deferred\";return /*#__PURE__*/_jsxs(\"div\",{ref:root,\"data-bright-project-reel\":\"true\",\"data-reel-state\":state,\"data-reel-controls\":controls?\"true\":\"false\",style:{background:source||poster?.src?\"#F8F9F8\":\"transparent\",...style,position:\"relative\",width:\"100%\",height:\"100%\",overflow:\"hidden\"},children:[poster?.src&&/*#__PURE__*/_jsx(\"img\",{src:poster.src,srcSet:poster.srcSet,sizes:\"min(calc(100vw - 48px), 1248px)\",alt:poster.alt||title,\"aria-hidden\":hasFrame||canMount&&controls?true:undefined,width:960,height:540,loading:\"eager\",fetchPriority:\"high\",decoding:\"async\",style:{...mediaStyle,opacity:hasFrame?0:1,pointerEvents:\"none\"}}),canMount&&/*#__PURE__*/_jsx(\"video\",{ref:player,src:source,muted:true,playsInline:true,loop:true,controls:controls,preload:\"none\",\"aria-label\":title,\"aria-hidden\":!controls?true:undefined,tabIndex:controls?undefined:-1,style:{...mediaStyle,opacity:hasFrame||controls?1:0,pointerEvents:controls?\"auto\":\"none\"},onLoadedData:event=>{if(event.currentTarget.readyState>=2)setFrameSource(source);},onPlaying:()=>{setFrameSource(source);},onError:()=>{setFailedSource(source);},onPlay:event=>{const element=event.currentTarget;if(player.current!==element)return;const programmatic=expectedPlayEvents.current.has(element);expectedPlayEvents.current.delete(element);if(!visibleNow()||programmatic&&!shouldResume()){pause(element);return;}if(!programmatic)intent.current=\"play\";},onPause:event=>{const element=event.currentTarget;const pending=pendingPauses.current.get(element)||0;if(pending>0){if(pending===1)pendingPauses.current.delete(element);else pendingPauses.current.set(element,pending-1);return;}if(player.current===element&&visibleNow())intent.current=\"pause\";}},source)]});}addPropertyControls(BrightProjectReel,{video:{type:ControlType.File,title:\"Video\",allowedFileTypes:[\"mp4\",\"webm\"],description:\"Optional project reel. An empty file keeps the poster or underlying artwork.\"},poster:{type:ControlType.ResponsiveImage,title:\"Poster\",description:\"Use a still from this project. Shown before playback, on the canvas and if playback fails.\"},title:{type:ControlType.String,title:\"Title\",defaultValue:\"Project reel\"},controls:{type:ControlType.Boolean,title:\"Controls\",defaultValue:false},autoplay:{type:ControlType.Boolean,title:\"Autoplay\",defaultValue:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"BrightProjectReel\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"540\",\"framerIntrinsicWidth\":\"960\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./BrightProjectReel.map"],"mappings":"A,6QAKG,SAAwBmB,EAAkB,CAAC,QAAM,GAAG,SAAO,QAAM,eAAe,WAAS,GAAM,WAAS,GAAK,SAAO,CAAC,IAAMC,EAAKpB,EAAO,IAAI,EAAQqB,EAAOrB,EAAO,IAAI,EAAQs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