{"version":3,"file":"InfinityLoopCarousel.BK86q0ev.mjs","names":["useRef","useState","useMemo","useCallback","__esmMin","window","le","z","pe","init_ssg_sandbox_shims","init_npm_react_18_3_1","_e","ne","c","init_jsx_runtime","de","useAnimationFrame","motion","useMotionValue","init_framer_motion_DhsWWWsN","addPropertyControls","init_framer_D1IzEvwH","ControlType","getImageNodes","images","fallbackImages","src","i","EmptyState","InfinityScrollCarousel","props","x","trackRef","isHovered","isDragging","velocity","downPos","downTime","startupUntil","seamEase","SEAM_EASE_MS","dimensions","setDimensions","imageNodes","imagesSlot","isSlot","itemRefs","tripled","group","nodes","widths","el","heights","newTrackWidth","sum","width","gap","imageWidth","clampToMiddleGroup","groupWidth","current","time","STARTUP_DELAY_MS","deltaSeconds","delta","decayFactor","dragDamping","hoverFactor","pauseMode","seamFactor","move","speed","newPosition","lowerBound","wrapped","setItemRef","index","trySynthesizeClick","clientX","clientY","evt","maxHeight","totalWidth","now","dx","dy","dt","distance","CLICK_DISTANCE_PX","CLICK_TIME_MS","tripledImages","node","init_InfinityLoopCarousel"],"sources":["https:/framerusercontent.com/modules/E4KY3cQuZFOFHvTqnT8a/Xx5rEFsOIqrUBfIEEMPR/InfinityLoopCarousel.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useRef,cloneElement,useLayoutEffect,useState,useMemo,useCallback}from\"react\";import{motion,useMotionValue,useAnimationFrame}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";// --- Tap vs Drag thresholds ---\nconst CLICK_DISTANCE_PX=6;const CLICK_TIME_MS=300;const now=()=>performance.now?performance.now():Date.now();// --- Startup delay + seam micro-ease ---\nconst STARTUP_DELAY_MS=1e3// wait 1s on first load\n;const SEAM_EASE_MS=350// 0.35s ease-in-out around seam\n;const EmptyState=()=>/*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",height:\"100%\",display:\"flex\",flexDirection:\"column\",alignItems:\"center\",justifyContent:\"center\",color:\"#999\",fontSize:16,textAlign:\"center\",padding:24,boxSizing:\"border-box\",gap:8,background:\"#F7F8FA\",borderRadius:12,border:\"1px solid #E5E7EB\"},children:[/*#__PURE__*/_jsx(\"span\",{style:{fontWeight:700,fontSize:18,color:\"#222\"},children:\"Connect to Content\"}),/*#__PURE__*/_jsx(\"span\",{style:{color:\"#666\",fontWeight:400,fontSize:15},children:\"Add image groups or CMS gallery to display here.\"})]});function getImageNodes(images,fallbackImages){if(images?.length>0)return images.filter(Boolean);if(fallbackImages?.length>0){return fallbackImages.map((src,i)=>src?/*#__PURE__*/_jsx(\"img\",{src:src,alt:`Carousel image ${i+1}`,draggable:false,style:{width:\"100%\",height:\"100%\",objectFit:\"cover\",display:\"block\",userSelect:\"none\",WebkitUserDrag:\"none\"}},i):null).filter(Boolean);}return[/*#__PURE__*/_jsx(EmptyState,{},\"empty\")];}export default function InfinityScrollCarousel(props){const{imagesSlot,images,speed=20,gap=0,pauseMode=\"none\",imageWidth,dragDamping=20}=props;const x=useMotionValue(0);const trackRef=useRef(null);const isHovered=useRef(false);const isDragging=useRef(false);const velocity=useRef(0);// tap vs drag\nconst downPos=useRef({x:0,y:0});const downTime=useRef(0);// startup delay\nconst startupUntil=useRef(null);// seam micro-ease state\nconst seamEase=useRef({active:false,start:0,dur:SEAM_EASE_MS});const[dimensions,setDimensions]=useState({trackWidth:0,itemHeights:[],itemWidths:[]});const imageNodes=getImageNodes(imagesSlot,images);const isSlot=imagesSlot?.length>0;const itemRefs=useRef([]);const{tripledImages,groupWidth,totalWidth,maxHeight}=useMemo(()=>{const tripled=[...imageNodes,...imageNodes,...imageNodes];const trackWidth=dimensions.trackWidth;const group=trackWidth;const totalW=group*3;const maxH=dimensions.itemHeights.length?Math.max(...dimensions.itemHeights):\"auto\";return{tripledImages:tripled,groupWidth:group,totalWidth:totalW,maxHeight:maxH};},[imageNodes,dimensions]);useLayoutEffect(()=>{if(!trackRef.current||imageNodes.length===0)return;const nodes=itemRefs.current.slice(0,imageNodes.length);const widths=nodes.map(el=>el?.offsetWidth||0);const heights=nodes.map(el=>el?.offsetHeight||0);const newTrackWidth=widths.reduce((sum,width)=>sum+width,0)+gap*imageNodes.length;setDimensions({trackWidth:newTrackWidth,itemHeights:heights,itemWidths:widths});},[imagesSlot,images,imageWidth,gap,imageNodes.length]);const clampToMiddleGroup=useCallback(()=>{if(!groupWidth)return;const current=x.get();const lowerBound=-groupWidth*2;const upperBound=0;if(current<=lowerBound)x.set(current+groupWidth);else if(current>=upperBound)x.set(current-groupWidth);},[groupWidth,x]);useAnimationFrame((time,delta)=>{if(!groupWidth)return;// initialize startup delay the first time we enter the loop\nif(startupUntil.current===null){startupUntil.current=time+STARTUP_DELAY_MS;}// During startup delay, do nothing (but still let user drag)\nif(!isDragging.current&&time<startupUntil.current){return;}const deltaSeconds=delta/1e3;if(isDragging.current){velocity.current=x.getVelocity();clampToMiddleGroup();return;}// Inertia glide if user released drag\nif(Math.abs(velocity.current)>10){const decayFactor=1-Math.min(Math.max(dragDamping,1),50)/100;x.set(x.get()+velocity.current*deltaSeconds);velocity.current*=decayFactor;clampToMiddleGroup();return;}// Base auto speed with optional hover slowdown/pause\nlet hoverFactor=1;if(pauseMode===\"pause\"&&isHovered.current)hoverFactor=0;else if(pauseMode===\"slow\"&&isHovered.current)hoverFactor=.8;// Seam ease factor (1 -> 0 -> 1 over 0.2s)\nlet seamFactor=1;if(seamEase.current.active){const t=Math.min(1,(time-seamEase.current.start)/seamEase.current.dur);// Smooth symmetric dip using cosine or sine:\n// m(t) = 1 - sin(pi * t)  => 1 -> 0 -> 1\nseamFactor=.3+.7*(1-Math.sin(Math.PI*t));if(t>=1)seamEase.current.active=false;}const effectiveSpeed=speed*hoverFactor*seamFactor;const move=deltaSeconds*effectiveSpeed;let newPosition=x.get()-move;const lowerBound=-groupWidth*2;const upperBound=0;// Detect seam crossing and wrap (then trigger micro-ease)\nlet wrapped=false;if(newPosition<=lowerBound){newPosition+=groupWidth;wrapped=true;}else if(newPosition>=upperBound){newPosition-=groupWidth;wrapped=true;}x.set(newPosition);if(wrapped){// Start a 0.2s ease-in-out dip right after the wrap\nseamEase.current.active=true;seamEase.current.start=time;}});const setItemRef=useCallback((el,index)=>{if(index<imageNodes.length)itemRefs.current[index]=el;},[imageNodes.length]);const trySynthesizeClick=(clientX,clientY)=>{const el=document.elementFromPoint(clientX,clientY);if(!el)return;const evt=new MouseEvent(\"click\",{bubbles:true,cancelable:true,clientX,clientY,view:window});el.dispatchEvent(evt);};return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",overflow:\"hidden\",position:\"relative\",cursor:isDragging.current?\"grabbing\":\"grab\",display:\"block\",height:maxHeight,minHeight:40,userSelect:\"none\"},children:/*#__PURE__*/_jsx(motion.div,{ref:trackRef,style:{display:\"flex\",gap:`${gap}px`,x,width:totalWidth||\"auto\",willChange:\"transform\",pointerEvents:\"auto\",touchAction:\"none\"},drag:\"x\",dragConstraints:false,dragElastic:.1,dragTransition:{bounceStiffness:100,bounceDamping:dragDamping,power:0},onPointerDown:e=>{downPos.current={x:e.clientX,y:e.clientY};downTime.current=now();},onDragStart:()=>{isDragging.current=true;},onDrag:clampToMiddleGroup,onDragEnd:()=>{isDragging.current=false;clampToMiddleGroup();},onPointerUp:e=>{const dx=e.clientX-downPos.current.x;const dy=e.clientY-downPos.current.y;const dt=now()-downTime.current;const distance=Math.hypot(dx,dy);if(!isDragging.current&&distance<=CLICK_DISTANCE_PX&&dt<=CLICK_TIME_MS){requestAnimationFrame(()=>{trySynthesizeClick(e.clientX,e.clientY);});}},onHoverStart:()=>isHovered.current=true,onHoverEnd:()=>isHovered.current=false,children:tripledImages.map((node,index)=>/*#__PURE__*/_jsx(\"div\",{ref:el=>setItemRef(el,index),draggable:false,onDragStart:e=>e.preventDefault(),style:{width:isSlot?\"auto\":imageWidth,height:\"auto\",flexShrink:0,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",pointerEvents:\"auto\",userSelect:\"none\",WebkitUserDrag:\"none\"},children:/*#__PURE__*/cloneElement(node,{draggable:false,style:{width:\"100%\",height:\"100%\",objectFit:\"cover\",userSelect:\"none\",WebkitUserDrag:\"none\",...node.props?.style||{}}})},index))})});}addPropertyControls(InfinityScrollCarousel,{imagesSlot:{type:ControlType.Slot,title:\"Images\",maxCount:10},speed:{type:ControlType.Number,title:\"Speed\",min:10,max:500,defaultValue:40},gap:{type:ControlType.Number,title:\"Gap\",min:0,max:100,defaultValue:20},dragDamping:{type:ControlType.Number,title:\"Drag Damping\",min:1,max:50,defaultValue:20},pauseMode:{type:ControlType.Enum,title:\"Hover\",options:[\"none\",\"slow\",\"pause\"],optionTitles:[\"None\",\"Slow\",\"Pause\"],defaultValue:\"slow\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"InfinityScrollCarousel\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./InfinityLoopCarousel.map"],"mappings":"A,4RAIwjB,SAASuB,EAAc,EAAO,EAAe,CAA4U,OAAxUC,GAAQ,OAAO,EAASA,EAAO,OAAO,OAAO,EAAKC,GAAgB,OAAO,EAAUA,EAAe,KAAK,EAAI,IAAIC,EAAiB,gBAAK,MAAM,CAAK,MAAI,IAAI,kBAAkBC,EAAE,IAAI,UAAU,GAAM,MAAM,CAAC,MAAM,OAAO,OAAO,OAAO,UAAU,QAAQ,QAAQ,QAAQ,WAAW,OAAO,eAAe,MAAM,CAAC,EAAEA,CAAC,EAAE,IAAI,CAAC,CAAC,OAAO,OAAO,EAAS,CAAc,gBAAKC,EAAW,CAAC,EAAE,OAAO,CAAC,CAAE,CAAC,SAAwBC,EAAuB,EAAM,CAAC,GAAK,CAAC,aAAW,SAAO,QAAM,GAAG,MAAI,EAAE,YAAU,OAAO,aAAW,cAAY,IAAIC,EAAYC,EAAEb,EAAe,CAAC,EAAQc,EAAShC,EAAO,IAAI,EAAQiC,EAAUjC,EAAO,EAAK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