{"version":3,"file":"EmblaNavigationButton.DHNSEtg3.mjs","names":["useState","useCallback","emblaApi"],"sources":["https:/framerusercontent.com/modules/Puo3ZO7bCrj0OpyNBdCB/MWIZwTnsBZI5AZKe11Zr/EmblaNavigationButton.js"],"sourcesContent":["// Get Started: https://www.framer.com/developers\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{isValidElement,useState,useCallback,useEffect,cloneElement}from\"react\";import{useEmblaStore}from\"https://framer.com/m/emblaStore-y8Nj.js@BxaccQyWVI49wcPo9pwY\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n * @framerIntrinsicHeight 200\n * @framerIntrinsicWidth 200\n */export default function EmblaNavigationButton(props){const{carouselID,action,componentSlot}=props;const[isDisabled,setIsDisabled]=useState(false);const component=componentSlot?.[0];const emblaApi=useEmblaStore(state=>state.emblaInstances.get(carouselID));const handleClick=useCallback(event=>{if(emblaApi){if(action==\"Next\"){emblaApi.scrollNext();}else{emblaApi.scrollPrev();}}else{console.warn(`Embla instance with ID \"${carouselID}\" not found.`);}},[emblaApi,action]);const onButtonAutoplayClick=useCallback(callback=>{const autoScroll=emblaApi?.plugins()?.autoScroll;const autoPlay=emblaApi?.plugins()?.autoplay;const autoMove=autoPlay||autoScroll;if(autoMove){const resetOrStop=autoMove.options.stopOnInteraction===false?autoMove.reset:autoMove.stop;resetOrStop();}callback();},[emblaApi]);const onSelect=useCallback(emblaApi=>{if(action==\"Next\"){setIsDisabled(!emblaApi.canScrollNext());}else{setIsDisabled(!emblaApi.canScrollPrev());}},[action,emblaApi]);useEffect(()=>{if(!emblaApi)return;onSelect(emblaApi);emblaApi.on(\"reInit\",onSelect).on(\"select\",onSelect);},[emblaApi,onSelect]);const styleObj={background:component?\"transparent\":\"lavender\",padding:component?0:\"8px 16px\",color:component?undefined:\"RebeccaPurple\",border:component?\"none\":\"1px solid RebeccaPurple\",opacity:isDisabled?.5:undefined,pointerEvents:isDisabled?\"none\":\"all\",userSelect:\"none\",cursor:isDisabled?\"not-allowed\":\"pointer\",width:\"100%\",height:\"100%\"};return /*#__PURE__*/_jsx(DivButton,{style:styleObj,onActivate:e=>{onButtonAutoplayClick(handleClick);},children:component?/*#__PURE__*/cloneElement(component,{...component.props,tabIndex:-1,style:{...component.props.style,maxWidth:\"100%\",maxHeight:\"100%\"}}):action});}const DivButton=({onActivate,onClick,children,...rest})=>/*#__PURE__*/_jsx(\"button\",{onClick:e=>{onClick?.(e);onActivate?.(e);},type:\"button\",...rest,children:children});function sanitizeInteractiveElement(element){if(!/*#__PURE__*/isValidElement(element))return element;const{type,props}=element;console.log(type,props,/*#__PURE__*/isValidElement(element));const isInteractive=type===\"a\"||type===\"button\"||typeof props.onClick===\"function\"||props.role===\"button\"||props.tabIndex===0;if(isInteractive){// Replace interactive element with span\nreturn /*#__PURE__*/_jsx(\"span\",{style:props.style,className:props.className,children:props.children});}// Recurse into children (in case of nested <a>/<button>)\nreturn /*#__PURE__*/cloneElement(element,{...props,children:sanitizeInteractiveElement(props.children)});}addPropertyControls(EmblaNavigationButton,{carouselID:{title:\"ID\",defaultValue:\"kniff-swiper-1\",type:ControlType.String,description:\"Use the same ID as the Swiper instance you want to control\"},action:{type:ControlType.Enum,options:[\"Prev\",\"Next\"],defaultValue:\"Next\"},componentSlot:{title:\"Connect\",type:ControlType.Slot,maxCount:1}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"EmblaNavigationButton\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"200\",\"framerIntrinsicWidth\":\"200\",\"framerSupportedLayoutHeight\":\"any\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./EmblaNavigationButton.map"],"mappings":"wPAMG,SAAwB,EAAsB,EAAM,CAAC,GAAK,CAAC,aAAW,SAAO,iBAAe,EAAW,CAAC,EAAW,G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