{"version":3,"file":"Swipe_Card.C2dQPxfx.mjs","names":["useState","useCallback","useMemo"],"sources":["https:/framerusercontent.com/modules/Ewtl5cctKotP9qiTCY7K/AgZ2loHLe1vUkou1JYi2/Swipe_Card.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useCallback,useMemo}from\"react\";import{motion,AnimatePresence}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n * @framerIntrinsicWidth 300\n * @framerIntrinsicHeight 400\n */export default function FlipCardComponent(props){const{cards,cardWidth,cardHeight,stackOffset,stackRotation,dragThreshold,animationDuration,animationEase,borderRadius,shadowIntensity,horizontalAlign,style}=props;const[cardOrder,setCardOrder]=useState(()=>cards.map((_,index)=>index));// Calculate z-index and transform for each card based on position in stack\nconst getCardTransform=useCallback((index,cardIndex)=>{const stackPosition=cardOrder.indexOf(cardIndex);const isTopCard=stackPosition===cardOrder.length-1;// Calculate position from bottom to top (reverse the offset direction)\nconst positionFromBottom=cardOrder.length-1-stackPosition;return{zIndex:stackPosition,y:-positionFromBottom*stackOffset,rotate:positionFromBottom*stackRotation,scale:1-positionFromBottom*.02,opacity:1};},[cardOrder,stackOffset,stackRotation]);// Handle drag end to determine if card should flip to back\nconst handleDragEnd=useCallback((event,info,cardIndex)=>{const dragDistance=Math.abs(info.offset.x)+Math.abs(info.offset.y);const velocity=Math.abs(info.velocity.x)+Math.abs(info.velocity.y);// Check if drag meets threshold (distance or velocity)\nif(dragDistance>dragThreshold||velocity>800){// Move the dragged card to the bottom of the stack\nsetCardOrder(prevOrder=>{const newOrder=[...prevOrder];const draggedCardPosition=newOrder.indexOf(cardIndex);const draggedCard=newOrder.splice(draggedCardPosition,1)[0];newOrder.unshift(draggedCard)// Add to beginning (bottom of stack)\n;return newOrder;});}},[dragThreshold]);// Animation variants for instant, realistic transitions\nconst cardVariants={initial:custom=>({...custom,x:0,y:custom.y}),animate:custom=>({...custom,x:0,y:custom.y,transition:{type:\"spring\",damping:30,stiffness:500,mass:.5,restDelta:.01,restSpeed:.01}}),drag:{scale:1.05,rotate:0,transition:{duration:.05}}};// Memoized card components for performance\nconst renderedCards=useMemo(()=>{return cards.map((card,index)=>{const transform=getCardTransform(index,index);const isTopCard=cardOrder.indexOf(index)===cardOrder.length-1;return /*#__PURE__*/_jsxs(motion.div,{custom:transform,variants:cardVariants,initial:\"initial\",animate:\"animate\",exit:\"exit\",whileDrag:\"drag\",drag:isTopCard,dragConstraints:{top:-150,bottom:150,left:-150,right:150},dragElastic:.2,dragSnapToOrigin:true,dragTransition:{power:.3,timeConstant:125,bounceStiffness:500,bounceDamping:30},onDragEnd:(event,info)=>handleDragEnd(event,info,index),style:{position:\"absolute\",width:cardWidth,height:cardHeight,borderRadius,overflow:\"hidden\",cursor:isTopCard?\"grab\":\"default\",boxShadow:`0px ${4+transform.zIndex*2}px ${8+transform.zIndex*4}px rgba(0, 0, 0, ${shadowIntensity})`},whileHover:isTopCard?{scale:1.02}:{},children:[card.image&&/*#__PURE__*/_jsx(\"img\",{src:card.image.src,srcSet:card.image.srcSet,alt:card.image.alt||`Card ${index+1}`,style:{width:\"100%\",height:\"100%\",objectFit:\"cover\",objectPosition:`${card.image.positionX||\"50%\"} ${card.image.positionY||\"50%\"}`,userSelect:\"none\",pointerEvents:\"none\"}}),(card.title||card.description)&&/*#__PURE__*/_jsxs(\"div\",{style:{position:\"absolute\",bottom:0,left:0,right:0,background:\"linear-gradient(transparent, rgba(0,0,0,0.7))\",color:\"white\",padding:\"24px\",textAlign:\"left\"},children:[card.title&&/*#__PURE__*/_jsx(\"h3\",{style:{margin:\"0 0 4px 0\",fontSize:\"18px\",fontWeight:\"600\"},children:card.title}),card.description&&/*#__PURE__*/_jsx(\"p\",{style:{margin:0,fontSize:\"14px\",opacity:.8},children:card.description})]})]},`card-${index}`);});},[cards,cardOrder,cardWidth,cardHeight,borderRadius,shadowIntensity,getCardTransform,cardVariants,handleDragEnd]);return /*#__PURE__*/_jsxs(\"div\",{style:{...style,position:\"relative\",width:cardWidth,height:cardHeight,perspective:\"1000px\",marginLeft:horizontalAlign===\"right\"?\"auto\":horizontalAlign===\"center\"?\"auto\":\"0\",marginRight:horizontalAlign===\"left\"?\"auto\":horizontalAlign===\"center\"?\"auto\":\"0\"},children:[/*#__PURE__*/_jsx(AnimatePresence,{children:renderedCards}),cards.length===0&&/*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",background:\"#f0f0f0\",borderRadius,border:\"2px dashed #ccc\",color:\"#666\",textAlign:\"center\",fontSize:\"14px\"},children:[\"Add cards to create\",/*#__PURE__*/_jsx(\"br\",{}),\"your flip stack\"]})]});}// Default props with placeholder images\nFlipCardComponent.defaultProps={cards:[{title:\"\",description:\"\"},{title:\"\",description:\"\"},{title:\"\",description:\"\"}],cardWidth:300,cardHeight:400,stackOffset:8,stackRotation:2,dragThreshold:80,animationDuration:.3,animationEase:\"easeOut\",borderRadius:16,shadowIntensity:.2,horizontalAlign:\"left\"};// Property Controls\naddPropertyControls(FlipCardComponent,{cards:{type:ControlType.Array,title:\"Cards\",control:{type:ControlType.Object,controls:{image:{type:ControlType.ResponsiveImage,title:\"Image\"},title:{type:ControlType.String,title:\"Title\",placeholder:\"Card title...\"},description:{type:ControlType.String,title:\"Description\",placeholder:\"Card description...\",displayTextArea:true}}},defaultValue:FlipCardComponent.defaultProps.cards,maxCount:10},// Dimensions\ncardWidth:{type:ControlType.Number,title:\"Card Width\",min:200,max:1200,step:10,unit:\"px\",defaultValue:300},cardHeight:{type:ControlType.Number,title:\"Card Height\",min:200,max:800,step:10,unit:\"px\",defaultValue:400},// Stack Appearance\nstackOffset:{type:ControlType.Number,title:\"Stack Offset\",description:\"Vertical offset between stacked cards\",min:0,max:20,step:1,unit:\"px\",defaultValue:8},stackRotation:{type:ControlType.Number,title:\"Stack Rotation\",description:\"Rotation angle between stacked cards\",min:-10,max:10,step:.5,unit:\"\\xb0\",defaultValue:0},// Interaction\ndragThreshold:{type:ControlType.Number,title:\"Drag Threshold\",description:\"Distance to drag before card flips\",min:30,max:200,step:10,unit:\"px\",defaultValue:80},// Animation\nanimationDuration:{type:ControlType.Number,title:\"Animation Speed\",min:.1,max:1,step:.1,unit:\"s\",defaultValue:.3},animationEase:{type:ControlType.Enum,title:\"Animation Ease\",options:[\"linear\",\"easeIn\",\"easeOut\",\"easeInOut\"],optionTitles:[\"Linear\",\"Ease In\",\"Ease Out\",\"Ease In Out\"],defaultValue:\"easeOut\"},// Styling\nborderRadius:{type:ControlType.Number,title:\"Border Radius\",min:0,max:50,step:1,unit:\"px\",defaultValue:16},shadowIntensity:{type:ControlType.Number,title:\"Shadow Intensity\",min:0,max:1,step:.1,defaultValue:.2},// Add this after the shadowIntensity control\nhorizontalAlign:{type:ControlType.Enum,title:\"Horizontal Alignment\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"left\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FlipCardComponent\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"400\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerIntrinsicWidth\":\"300\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Swipe_Card.map"],"mappings":"8XAKG,SAAwB,EAAkB,EAAM,CAAC,GAAK,CAAC,QAAM,YAAU,aAAW,cAAY,gBAAc,gBAAc,oBAAkB,gBAAc,eAAa,kBAAgB,kBAAgB,SAAO,EAAW,CAAC,EAAU,GAAcA,MAAa,EAAM,KAAK,EAAE,IAAQ,EAAM,CAAC,CACxR,EAAiBC,GAAa,EAAM,IAAY,CAAC,IAAM,EAAc,EAAU,QAAQ,EAAU,CAAiC,EAAU,OAAO,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