{"version":3,"file":"Text_highlighter.IyHeNbSM.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/MQ3eN0meZVSV1TrezwqZ/mzpmkDkhQIIsecBPIeno/Text_highlighter.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any\n * @framerIntrinsicWidth auto\n * @framerSupportedLayoutHeight any\n * @framerIntrinsicHeight auto\n */export default function AnimatedHighlighter(props){const[isVisible,setIsVisible]=useState(false);const elementRef=useRef(null);useEffect(()=>{const calculateTriggerPoint=()=>{switch(props.triggerPosition){case\"top\":return window.innerHeight*.2;case\"center\":return window.innerHeight*.5;case\"bottom\":return window.innerHeight*.8;default:return window.innerHeight*.8;}};const handleScroll=()=>{if(elementRef.current){const rect=elementRef.current.getBoundingClientRect();const triggerPoint=calculateTriggerPoint();setIsVisible(rect.top<=triggerPoint+props.triggerOffset);}};window.addEventListener(\"scroll\",handleScroll);handleScroll();return()=>window.removeEventListener(\"scroll\",handleScroll);},[props.triggerPosition,props.triggerOffset]);const highlightText=(text,highlight,color)=>{if(!highlight)return text;const parts=text.split(new RegExp(`(${highlight})`,\"gi\"));return parts.map((part,index)=>{if(part.toLowerCase()===highlight.toLowerCase()){return /*#__PURE__*/_jsxs(\"span\",{style:{padding:\"0 4px\",borderRadius:\"2px\",position:\"relative\",isolation:\"isolate\",display:\"inline-block\",color:props.fontColor},children:[part,props.animate&&/*#__PURE__*/_jsx(\"span\",{style:{position:\"absolute\",inset:0,backgroundColor:color,borderRight:props.showCursor?`${props.cursorThickness}px solid ${props.cursorColor}`:\"none\",transform:isVisible?\"scaleX(1)\":\"scaleX(0)\",transformOrigin:\"left\",transition:\"transform 0.5s ease-out\",zIndex:-1}}),!props.animate&&/*#__PURE__*/_jsx(\"span\",{style:{position:\"absolute\",inset:0,backgroundColor:color,borderRight:props.showCursor?`${props.cursorThickness}px solid ${props.cursorColor}`:\"none\",zIndex:-1}})]},index);}return /*#__PURE__*/_jsx(\"span\",{style:{color:props.fontColor},children:part});});};return /*#__PURE__*/_jsx(\"div\",{ref:elementRef,style:{...props.font},children:highlightText(props.text,props.highlightPhrase,props.highlightColor)});}AnimatedHighlighter.defaultProps={text:\"This is a sample text with highlighted words\",highlightPhrase:\"highlighted\",highlightColor:\"#FFE082\",fontColor:\"#000000\",animate:true,showCursor:false,cursorColor:\"#000000\",cursorThickness:2,triggerPosition:\"bottom\",triggerOffset:0};addPropertyControls(AnimatedHighlighter,{text:{type:ControlType.String,title:\"Text\"},highlightPhrase:{type:ControlType.String,title:\"Highlight Phrase\"},highlightColor:{type:ControlType.Color,title:\"Highlight Color\"},fontColor:{type:ControlType.Color,title:\"Font Color\"},animate:{type:ControlType.Boolean,title:\"Animate\",defaultValue:true},showCursor:{type:ControlType.Boolean,title:\"Show Cursor\",hidden:props=>!props.animate},cursorColor:{type:ControlType.Color,title:\"Cursor Color\",hidden:props=>!props.animate||!props.showCursor},cursorThickness:{type:ControlType.Number,title:\"Cursor Thickness\",min:1,max:10,step:1,hidden:props=>!props.animate||!props.showCursor},triggerPosition:{type:ControlType.Enum,title:\"Trigger Position\",options:[\"top\",\"center\",\"bottom\"],optionTitles:[\"Top\",\"Center\",\"Bottom\"],hidden:props=>!props.animate},triggerOffset:{type:ControlType.Number,title:\"Trigger Offset\",min:-500,max:500,step:10,hidden:props=>!props.animate},font:{type:ControlType.Font,controls:\"extended\",title:\"Font Style\",description:\"v1.1 \\n[via SegmentUI](https://www.segmentUI.com)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AnimatedHighlighter\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"*\",\"framerSupportedLayoutWidth\":\"any\",\"framerIntrinsicHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\",\"framerIntrin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