{"version":3,"file":"VideoFrameBar.BPPAtGII.mjs","names":["useState","videoId"],"sources":["https:/framerusercontent.com/modules/wJ9FVbTgY4yFYJHATsYx/5CF1HEzvwhnj9Ixr6bvG/VideoFrameBar.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{motion}from\"framer-motion\";import{useEffect,useState}from\"react\";import{useVideoStore}from\"https://framerusercontent.com/modules/fRFpVdPrIhh8XlcDXeAu/F2haXvK7uCMAbtK3LM9l/VideoFrameShared.js\";/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function VideoFrameProgressBar(props){const{videoId,backgroundColor=\"#E1E1E1\",progressColor=\"#0099FF\",borderRadius=2,isCircular=false,circleSize=40,strokeWidth=4}=props;const[videoState]=useVideoStore();const[videoDuration,setVideoDuration]=useState(0);const[progress,setProgress]=useState(0);const[isReady,setIsReady]=useState(true);// Separate the localStorage reading from state updates\nconst getStoredProgress=videoId=>{try{const stored=localStorage.getItem(`video_progress_${videoId}`);const duration=videoState[videoId]?.duration||100;return stored?parseFloat(stored)/duration:0;}catch(e){console.error(\"Error reading from localStorage:\",e);return 0;}};// Handle duration updates separately\nuseEffect(()=>{const video=videoState[videoId];const duration=video?.duration||100;setVideoDuration(duration);},[videoId,videoState]);// Handle progress updates\nuseEffect(()=>{let isMounted=true;const video=videoState[videoId];const storedProgress=getStoredProgress(videoId);if(isMounted){setProgress(storedProgress);}if(!video){return;}const onTimeUpdate=([currentTime])=>{if(!isMounted)return;if(video.duration&&currentTime!==undefined){const newProgress=currentTime/video.duration;setProgress(newProgress);}else{setProgress(storedProgress);}};video.addTimeCallback(onTimeUpdate);return()=>{isMounted=false;if(video){video.removeTimeCallback(onTimeUpdate);}};},[videoId,videoState]);// Update progress when videoId changes\nuseEffect(()=>{setProgress(getStoredProgress(videoId));},[videoId]);if(!isReady){return null;}const currentProgress=progress||getStoredProgress(videoId);if(isCircular){const center=circleSize/2;const radius=(circleSize-strokeWidth)/2;return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\"},children:/*#__PURE__*/_jsxs(\"svg\",{width:circleSize,height:circleSize,viewBox:`0 0 ${circleSize} ${circleSize}`,style:{transform:\"rotate(-90deg)\"},children:[/*#__PURE__*/_jsx(\"circle\",{cx:center,cy:center,r:radius,fill:\"none\",stroke:backgroundColor,strokeWidth:strokeWidth}),/*#__PURE__*/_jsx(motion.circle,{cx:center,cy:center,r:radius,fill:\"none\",stroke:progressColor,strokeWidth:strokeWidth,initial:{pathLength:currentProgress},animate:{pathLength:currentProgress},transition:{duration:.1,ease:\"linear\"}},videoId)]})});}return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\"},children:/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",backgroundColor,borderRadius,overflow:\"hidden\",position:\"relative\"},children:/*#__PURE__*/_jsx(motion.div,{style:{width:\"100%\",height:\"100%\",backgroundColor:progressColor,transformOrigin:\"left\",scaleX:currentProgress,transition:\"transform 0.1s linear\"}})})});}addPropertyControls(VideoFrameProgressBar,{videoId:{type:ControlType.String,title:\"Video ID\",description:\"The ID of the video to track (from VideoFrame's data-video-id attribute)\"},backgroundColor:{type:ControlType.Color,title:\"Background Color\",defaultValue:\"#E1E1E1\"},progressColor:{type:ControlType.Color,title:\"Progress Color\",defaultValue:\"#0099FF\"},isCircular:{type:ControlType.Boolean,title:\"Style\",defaultValue:false,enabledTitle:\"Circular\",disabledTitle:\"Linear\"},height:{type:ControlType.Number,title:\"Height\",defaultValue:4,min:1,max:20,unit:\"px\",hidden(props){return props.isCircular===true;}},borderRadius:{type:ControlType.Number,title:\"Border Radius\",defaultValue:2,min:0,max:20,unit:\"px\",hidden(props){return props.isCircular===true;}},circleSize:{type:ControlType.Number,title:\"Circle Size\",defaultValue:40,min:20,max:200,unit:\"px\",hidden(props){return props.isCircular===false;}},strokeWidth:{type:ControlType.Number,title:\"Stroke Width\",defaultValue:4,min:1,max:20,unit:\"px\",hidden(props){return props.isCircular===false;}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"VideoFrameProgressBar\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"4bAGG,SAAwB,EAAsB,EAAM,CAAC,GAAK,CAAC,UAAQ,kBAAgB,UAAU,gBAAc,UAAU,eAAa,EAAE,aAAW,GAAM,aAAW,GAAG,cAAY,GAAG,EAAW,CAAC,GAAY,GAAe,CAAM,CAAC,EAAc,GAAkBA,EAAS,EAAE,CAAM,CAAC,EAAS,GAAaA,EAAS,EAAE,CAAM,CAAC,EAAQ,GAAYA,EAAS,GAAK,CACzV,EAAkB,GAAS,CAAC,GAAG,CAAC,IAAM,EAAO,aAAa,QAAQ,kBAAkBC,IAAU,CAAO,EAAS,EAAWA,IAAU,UAAU,IAAI,OAAO,EAAO,WAAW,EAAO,CAAC,EAAS,QAAS,EAAE,CAAqD,OAApD,QAAQ,MAAM,mCAAmC,EAAE,CAAQ,IAGpM,GAFpE,MAAc,CAAiC,IAAM,EAA1B,EAAW,IAA+B,UAAU,IAAI,EAAiB,EAAS,EAAG,CAAC,EAAQ,EAAW,CAAC,CACrI,MAAc,CAAC,IAAI,EAAU,GAAW,EAAM,EAAW,GAAe,EAAe,EAAkB,EAAQ,CAA4C,GAAxC,GAAW,EAAY,EAAe,CAAK,CAAC,EAAO,OAAQ,IAAM,GAAc,CAAC,KAAe,CAAK,KAAiB,GAAG,EAAM,UAAU,IAAc,IAAA,GAAU,CAAC,IAAM,EAAY,EAAY,EAAM,SAAS,EAAY,EAAY,MAAO,EAAY,EAAe,EAAwC,OAApC,EAAM,gBAAgB,E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