{"version":3,"file":"Slider.CQq9sdXK.mjs","names":["useState","useRef","useCallback","__esmMin","init_npm_react_18_3_1","ne","_e","p","c","init_jsx_runtime","de","addPropertyControls","init_framer_BL70qLPA","ControlType","ImageSliderWithProgressBar","props","count","images","index","setIndex","isDragging","setIsDragging","dragPercent","setDragPercent","barRef","getRatioAndIndex","bar","rect","ratio","clientX","handlePointerDown","newIndex","handlePointerMove","handlePointerUp","snappedPercent","progressPercent","bottomSpace","img","i","fit","transitionDuration","barWidth","gap","dotSize","barHeight","barColor","handleColor","titleGap","titleColor","titleFont","init_Slider"],"sources":["https:/framerusercontent.com/modules/nN8w4n9u3aQImpK6IsAN/4TYy2kAlrAt4mUhyMFxU/Slider.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useRef,useCallback}from\"react\";import{addPropertyControls,ControlType}from\"framer\";export default function ImageSliderWithProgressBar(props){const{images=[],fit,gap,bottomSpace,barWidth,barHeight,dotSize,barColor,handleColor,borderRadius,transitionDuration,titleGap,titleColor,titleFont}=props;const count=Math.max(images.length,1);const[index,setIndex]=useState(0);const[isDragging,setIsDragging]=useState(false);const[dragPercent,setDragPercent]=useState(null);const barRef=useRef(null);// Convert a pointer's x position into a raw 0–100% position on the bar,\n// plus the nearest image index that position corresponds to\nconst getRatioAndIndex=useCallback(clientX=>{const bar=barRef.current;if(!bar)return{ratio:0,newIndex:index};const rect=bar.getBoundingClientRect();const ratio=Math.min(1,Math.max(0,(clientX-rect.left)/rect.width));// The nearest image to this raw position — image 1 at the very\n// start, the last image at the very end\nconst newIndex=count<=1?0:Math.round(ratio*(count-1));return{ratio,newIndex};},[count,index]);const handlePointerDown=e=>{setIsDragging(true);e.target.setPointerCapture(e.pointerId);const{ratio,newIndex}=getRatioAndIndex(e.clientX);setDragPercent(ratio*100);if(newIndex!==index)setIndex(newIndex);};const handlePointerMove=e=>{if(!isDragging)return;const{ratio,newIndex}=getRatioAndIndex(e.clientX);setDragPercent(ratio*100);if(newIndex!==index)setIndex(newIndex);};const handlePointerUp=e=>{setIsDragging(false);setDragPercent(null);e.target.releasePointerCapture(e.pointerId);};// Progress fill: 0% at the first image, 100% at the last image\nconst snappedPercent=count<=1?0:index/(count-1)*100;// While dragging, the dot follows the cursor exactly; once released,\n// it settles into the exact position of the current image\nconst progressPercent=isDragging&&dragPercent!==null?dragPercent:snappedPercent;return /*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",height:\"100%\",display:\"flex\",flexDirection:\"column\",background:\"#ffffff\",overflow:\"visible\",boxSizing:\"border-box\",paddingBottom:bottomSpace},children:[/*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",width:\"100%\",flex:1,minHeight:0,borderRadius,overflow:\"hidden\",background:\"#ffffff\"},children:[images.map((img,i)=>/*#__PURE__*/_jsx(\"img\",{src:img.src,alt:img.alt||`Slide ${i+1}`,draggable:false,style:{position:\"absolute\",top:0,left:0,width:\"100%\",height:\"100%\",objectFit:fit,opacity:i===index?1:0,transform:`scale(${(img.scale??100)/100})`,transition:`opacity ${transitionDuration}s ease`,pointerEvents:\"none\"}},i)),images.length===0&&/*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",alignItems:\"center\",justifyContent:\"center\",width:\"100%\",height:\"100%\",color:\"#999\",fontFamily:\"sans-serif\",fontSize:14},children:\"Add images in the properties panel\"})]}),/*#__PURE__*/_jsx(\"div\",{onPointerDown:handlePointerDown,onPointerMove:handlePointerMove,onPointerUp:handlePointerUp,style:{width:`${barWidth}%`,margin:`${gap}px auto 0`,padding:`${Math.max(dotSize,24)/2}px ${dotSize/2}px`,boxSizing:\"border-box\",flexShrink:0,overflow:\"visible\",cursor:\"pointer\",touchAction:\"none\"},children:/*#__PURE__*/_jsx(\"div\",{ref:barRef,style:{position:\"relative\",width:\"100%\",height:barHeight,borderRadius:barHeight/2,background:barColor,boxShadow:\"inset 0 2px 3px rgba(0,0,0,0.35), inset 0 -1px 1px rgba(255,255,255,0.5)\"},children:/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:\"50%\",left:`${progressPercent}%`,width:dotSize,height:dotSize,borderRadius:\"50%\",background:handleColor,transform:\"translate(-50%, -50%)\",boxShadow:\"0 1px 4px rgba(0,0,0,0.25)\",transition:isDragging?\"none\":`left ${transitionDuration}s ease`,pointerEvents:\"none\"}})})}),images[index]?.title&&/*#__PURE__*/_jsx(\"div\",{style:{marginTop:titleGap,flexShrink:0,textAlign:\"center\",color:titleColor,...titleFont},children:images[index].title})]});}ImageSliderWithProgressBar.defaultProps={fit:\"contain\",gap:32,bottomSpace:0,barWidth:100,barHeight:6,dotSize:16,barColor:\"#e5e5e5\",handleColor:\"#111111\",borderRadius:12,transitionDuration:.25,titleGap:16,titleColor:\"#111111\",titleFont:{fontFamily:\"Inter, sans-serif\",fontWeight:600,fontSize:16,lineHeight:\"1.4em\"},images:[]};addPropertyControls(ImageSliderWithProgressBar,{images:{type:ControlType.Array,title:\"Images\",control:{type:ControlType.Object,controls:{src:{type:ControlType.Image,title:\"Image\"},alt:{type:ControlType.String,title:\"Alt text\"},title:{type:ControlType.String,title:\"Title\"},scale:{type:ControlType.Number,title:\"Scale\",min:10,max:300,step:1,unit:\"%\",defaultValue:100}}},maxCount:8},fit:{type:ControlType.Enum,title:\"Image Fit\",options:[\"contain\",\"cover\"],optionTitles:[\"Show whole image\",\"Fill & crop\"],defaultValue:\"contain\"},gap:{type:ControlType.Number,title:\"Space Above Bar\",min:0,max:100,step:1,defaultValue:32},bottomSpace:{type:ControlType.Number,title:\"Space Below Bar\",min:0,max:100,step:1,defaultValue:0},barWidth:{type:ControlType.Number,title:\"Bar Width\",min:10,max:100,step:1,unit:\"%\",defaultValue:100},barHeight:{type:ControlType.Number,title:\"Bar Height\",min:2,max:20,step:1,defaultValue:6},dotSize:{type:ControlType.Number,title:\"Dot Size\",min:4,max:60,step:1,defaultValue:16},barColor:{type:ControlType.Color,title:\"Bar Track Color\",defaultValue:\"#e5e5e5\"},handleColor:{type:ControlType.Color,title:\"Handle Color\",defaultValue:\"#111111\"},borderRadius:{type:ControlType.Number,title:\"Image Corner Radius\",min:0,max:60,step:1,defaultValue:12},transitionDuration:{type:ControlType.Number,title:\"Transition Speed (s)\",min:0,max:1,step:.05,defaultValue:.25},titleGap:{type:ControlType.Number,title:\"Space Above Title\",min:0,max:100,step:1,defaultValue:16},titleColor:{type:ControlType.Color,title:\"Title Color\",defaultValue:\"#111111\"},titleFont:{type:ControlType.Font,title:\"Title Font\",controls:\"extended\",defaultValue:{fontFamily:\"Inter, sans-serif\",fontWeight:600,fontSize:16,lineHeight:\"1.4em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ImageSliderWithProgressBar\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Slider.map"],"mappings":"A,+LAA4J,SAAwBc,EAA2B,EAAM,CAAC,GAAK,CAAC,SAAO,CAAC,EAAE,MAAI,MAAI,cAAY,WAAS,YAAU,UAAQ,WAAS,cAAY,eAAa,qBAAmB,WAAS,aAAW,aAAWC,EAAYC,EAAM,KAAK,IAAIC,EAAO,OAAO,CAAC,EAAO,CAACC,EAAMC,GAAUnB,EAAS,CAAC,EAAO,CAACoB,EAAWC,GAAerB,EAAS,EAAK,EAAO,CAACsB,EAAYC,GAAgBvB,EAAS,IAAI,EAAQwB,EAAOvB,EAAO,IAAI,EAE1iBwB,EAAiBvB,EAAY,GAAS,CAAC,IAAMwB,EAAIF,EAAO,QAAQ,GAAG,CAACE,EAAI,MAAM,CAAC,MAAM,EAAE,SAASR,CAAK,EAAE,IAAMS,EAAKD,EAAI,sBAAsB,EAAQE,EAAM,KAAK,IAAI,EAAE,KAAK,IAAI,GAAGC,EAAQF,EAAK,MAAMA,EAAK,KAAK,CAAC,EAE/J,MAAM,CAAC,QAAM,SAApDX,GAAO,EAAE,EAAE,KAAK,MAAMY,GAAOZ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