{"version":3,"file":"SegmentedVideo.DMPSrGTL.mjs","names":["useMemo","useRef","useState","useCallback"],"sources":["https:/framerusercontent.com/modules/w026IMcATsystTh5FW64/uFf9IKZ2f8ddXvfN3tFV/SegmentedVideo.js"],"sourcesContent":["// Segmented video player, copied from psychotherapy4.men for personcentered.us.\n// Dave's request: play clips that were cut into parts (each under Framer's 5 MB upload limit)\n// as one continuous video. Up to four uploaded files play in order in a single player; the next\n// part preloads in the background so the handoff is hidden (Dave fades each part in iMovie).\n// Click to play; replay at the end. Also works with a single file (e.g. the Kramer introduction).\n// Responsive: when its height is set to Fit, the player fills its column width at a 4:3 ratio,\n// so it resizes itself on desktop, tablet and phone.\n// Only one at a time: when any player on the page starts or resumes, every other player pauses.\n// Oct 2, 2026 (Dave's request): before play, show a still from the video instead of a black\n// window. The clips open on a fade from black, so the still is taken a couple of seconds in\n// (\"Still at\" in the properties panel, default 2 seconds). Playback still starts from the\n// beginning. An uploaded Poster image, if set, takes priority over the still.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useMemo,useRef,useState,useCallback,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";const PLAY_EVENT=\"segmentedvideo:play\";/**\n * Segmented Video\n *\n * @framerIntrinsicWidth 760\n * @framerIntrinsicHeight 570\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any\n */export default function SegmentedVideo(props){const{segment1,segment2,segment3,segment4,poster,stillAt=2,background=\"#000000\",accent=\"#C17A4E\",iconColor=\"#F2EDE4\",playLabel=\"Play video\"}=props;const sources=useMemo(()=>[segment1,segment2,segment3,segment4].filter(s=>typeof s===\"string\"&&s.length>0),[segment1,segment2,segment3,segment4]);const isStatic=useIsStaticRenderer();const refA=useRef(null);const refB=useRef(null);const idRef=useRef(\"sv-\"+Math.random().toString(36).slice(2)+Date.now().toString(36));const[index,setIndex]=useState(0);const[started,setStarted]=useState(false);const[finished,setFinished]=useState(false);// Two players alternate: slot 0 holds even-numbered parts, slot 1 odd-numbered parts.\n// The inactive slot always holds the NEXT part, preloading while the current one plays.\nconst activeSlot=index%2;const srcFor=slot=>{const i=slot===activeSlot?index:index+1;const src=sources[i];if(!src)return src;// The first part carries a time fragment so the browser paints a still from that\n// moment before play. Playback resets to 0 when the viewer presses play.\nif(i===0&&stillAt>0)return`${src}#t=${stillAt}`;return src;};const refFor=slot=>slot===0?refA:refB;// Pause this player whenever another player on the page starts.\nuseEffect(()=>{if(typeof window===\"undefined\"||isStatic)return;const onOtherPlay=e=>{const detail=e.detail;if(detail===idRef.current)return;refA.current?.pause();refB.current?.pause();};window.addEventListener(PLAY_EVENT,onOtherPlay);return()=>window.removeEventListener(PLAY_EVENT,onOtherPlay);},[isStatic]);const announcePlay=useCallback(()=>{if(typeof window===\"undefined\")return;window.dispatchEvent(new CustomEvent(PLAY_EVENT,{detail:idRef.current}));},[]);// Play the active part whenever the index advances after the viewer has started.\nuseEffect(()=>{if(!started||finished||isStatic)return;const el=refFor(activeSlot).current;if(el){el.currentTime=0;const p=el.play();if(p&&typeof p.catch===\"function\")p.catch(()=>{});}// eslint-disable-next-line react-hooks/exhaustive-deps\n},[index,started,finished,isStatic]);const handleEnded=useCallback(slot=>{if(slot!==activeSlot)return;if(index+1<sources.length){startTransition(()=>setIndex(index+1));}else{startTransition(()=>setFinished(true));}},[activeSlot,index,sources.length]);const handleStart=useCallback(()=>{if(sources.length===0)return;announcePlay();// Unlock the second player inside the click, so mobile Safari lets it play later.\nconst other=refB.current;if(other&&sources.length>1){const p=other.play();if(p&&typeof p.then===\"function\"){p.then(()=>{other.pause();other.currentTime=0;}).catch(()=>{});}}startTransition(()=>{setFinished(false);setIndex(0);setStarted(true);});},[sources.length,announcePlay]);const showOverlay=!started||finished;// Fit height: keep a 4:3 box at full column width. Fixed height: fill the frame.\nconst autoHeight=!props.style||props.style.height===undefined;const videoStyle=slot=>({position:\"absolute\",inset:0,width:\"100%\",height:\"100%\",objectFit:\"contain\",background,visibility:slot===activeSlot?\"visible\":\"hidden\"});return /*#__PURE__*/_jsxs(\"div\",{style:{...props.style,position:\"relative\",width:\"100%\",height:autoHeight?undefined:\"100%\",aspectRatio:autoHeight?\"4 / 3\":undefined,background,overflow:\"hidden\"},children:[sources.length===0?/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",inset:0,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",color:iconColor,opacity:.6,fontFamily:\"Inter, sans-serif\",fontSize:14,textAlign:\"center\",padding:24},children:\"Upload video parts in the properties panel (Part 1 to Part 4)\"}):[0,1].map(slot=>/*#__PURE__*/_jsx(\"video\",{ref:refFor(slot),src:srcFor(slot),style:videoStyle(slot),preload:slot===activeSlot?\"metadata\":\"auto\",playsInline:true,controls:started&&!finished&&slot===activeSlot,onPlay:()=>{if(slot===activeSlot&&started)announcePlay();},onEnded:()=>handleEnded(slot)},slot)),poster?.src&&!started&&/*#__PURE__*/_jsx(\"img\",{src:poster.src,srcSet:poster.srcSet,alt:poster.alt||\"\",style:{position:\"absolute\",inset:0,width:\"100%\",height:\"100%\",objectFit:\"cover\"}}),showOverlay&&sources.length>0&&/*#__PURE__*/_jsx(\"button\",{type:\"button\",\"aria-label\":finished?\"Replay video\":playLabel,onClick:isStatic?undefined:handleStart,style:{position:\"absolute\",inset:0,width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",background:finished?\"rgba(0,0,0,0.55)\":\"rgba(0,0,0,0.25)\",border:\"none\",cursor:\"pointer\",padding:0},children:/*#__PURE__*/_jsx(\"span\",{style:{width:72,height:72,borderRadius:\"50%\",background:accent,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",boxShadow:\"0 4px 16px rgba(0,0,0,0.35)\"},children:finished?/*#__PURE__*/_jsxs(\"svg\",{width:\"30\",height:\"30\",viewBox:\"0 0 24 24\",fill:\"none\",stroke:iconColor,strokeWidth:\"2.2\",strokeLinecap:\"round\",strokeLinejoin:\"round\",\"aria-hidden\":\"true\",children:[/*#__PURE__*/_jsx(\"path\",{d:\"M3 12a9 9 0 1 0 3-6.7\"}),/*#__PURE__*/_jsx(\"path\",{d:\"M3 4v5h5\"})]}):/*#__PURE__*/_jsx(\"svg\",{width:\"28\",height:\"28\",viewBox:\"0 0 24 24\",\"aria-hidden\":\"true\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M8 5v14l11-7z\",fill:iconColor})})})})]});}const videoTypes=[\"mp4\",\"webm\",\"mov\",\"m4v\"];addPropertyControls(SegmentedVideo,{segment1:{type:ControlType.File,title:\"Part 1\",allowedFileTypes:videoTypes},segment2:{type:ControlType.File,title:\"Part 2\",allowedFileTypes:videoTypes},segment3:{type:ControlType.File,title:\"Part 3\",allowedFileTypes:videoTypes},segment4:{type:ControlType.File,title:\"Part 4\",allowedFileTypes:videoTypes},stillAt:{type:ControlType.Number,title:\"Still at (sec)\",defaultValue:2,min:0,max:60,step:.5,displayStepper:true},poster:{type:ControlType.ResponsiveImage,title:\"Poster (optional)\"},playLabel:{type:ControlType.String,title:\"Play Label\",defaultValue:\"Play video\"},background:{type:ControlType.Color,title:\"Background\",defaultValue:\"#000000\"},accent:{type:ControlType.Color,title:\"Button\",defaultValue:\"#C17A4E\"},iconColor:{type:ControlType.Color,title:\"Icon\",defaultValue:\"#F2EDE4\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SegmentedVideo\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"570\",\"framerSupportedLayoutHeight\":\"any\",\"framerIntrinsicWidth\":\"760\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SegmentedVideo.map"],"mappings":"yOAoBG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,WAAS,WAAS,WAAS,WAAS,SAAO,UAAQ,EAAE,aAAW,UAAU,SAAO,UA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