{"version":3,"file":"HighlightText.CwMD0IDs.mjs","names":["useRef","useMemo"],"sources":["https:/framerusercontent.com/modules/Mp3g66LijXxqrDJASnrK/Mn0zoxmhZ16jVvNt9RqI/HighlightText.js"],"sourcesContent":["// Highlighted Text with Brush Highlighter Effect\n// - Allows users to select words in the text to be highlighted\n// - Brush/highlighter stroke effect for the highlight\n// - Font, highlight color, text size, and words to highlight are configurable\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useMemo,useRef}from\"react\";import{motion,useInView}from\"framer-motion\";/**\n * Brush Highlighted Text\n *\n * @framerIntrinsicWidth 340\n * @framerIntrinsicHeight 56\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */export default function HighlightText(props){const{text=\"This is a sample highlighted text.\",highlightWords=\"sample highlighted\",highlightColor=\"#FFEB3B\",textColor=\"#000000\",font,alignment=\"left\",strokeWidth=12,style}=props;const ref=useRef(null);const isInView=useInView(ref,{once:true,amount:.5});// Prepare brush svg as a data-url background\nconst brushSVG=color=>`url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"100%25\" height=\"30\"><path d=\"M3 22 Q80 13 170 18 T340 27\" fill=\"none\" stroke=\"${encodeURIComponent(color)}\" stroke-width=\"${strokeWidth}\" stroke-linecap=\"round\" stroke-opacity=\"0.65\"/></svg>')`;const highlightWordsArray=useMemo(()=>highlightWords.split(/[, ]+/).map(w=>w.trim()).filter(Boolean),[highlightWords]);// Split the sentence into word tokens, keeping whitespace\nconst getTokens=str=>{const regex=/(\\w+|[.,!?;:()'\\\"-]+|\\s+)/g;return str.match(regex)||[str];};const tokens=useMemo(()=>getTokens(text),[text]);const finalFont=font||{fontSize:\"32px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"};return /*#__PURE__*/_jsx(\"span\",{ref:ref,style:{display:\"inline-block\",minWidth:0,wordBreak:\"break-word\",textAlign:alignment,color:textColor,...finalFont,...style,fontStyle:finalFont.fontStyle},children:tokens.map((word,i)=>{// Remove surrounding punctuation before comparison\nconst base=word.replace(/[.,!?;:'\"()\\-]/g,\"\");const shouldHighlight=highlightWordsArray.some(h=>h.toLowerCase()===base.toLowerCase());if(shouldHighlight&&base){return /*#__PURE__*/_jsx(motion.span,{style:{position:\"relative\",zIndex:1,backgroundImage:brushSVG(highlightColor),backgroundRepeat:\"no-repeat\",backgroundSize:\"100% 70%\",backgroundPosition:\"0 73%\",padding:\"2px 2px 8px 2px\",borderRadius:3,fontStyle:\"inherit\"},initial:{backgroundSize:\"0% 70%\"},animate:{backgroundSize:isInView?\"100% 70%\":\"0% 70%\"},transition:{duration:.6,ease:\"easeOut\",delay:.2},children:word},i);}return /*#__PURE__*/_jsx(\"span\",{children:word},i);})});}addPropertyControls(HighlightText,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"This is a sample highlighted text.\",displayTextArea:true},highlightWords:{type:ControlType.String,title:\"Highlight Words\",placeholder:\"Words to highlight\",defaultValue:\"sample highlighted\"},highlightColor:{type:ControlType.Color,title:\"Highlight Color\",defaultValue:\"#FFEB3B\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},strokeWidth:{type:ControlType.Number,title:\"Stroke Width\",defaultValue:12,min:1,max:30,step:1},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"32px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},alignment:{type:ControlType.Enum,title:\"Alignment\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"left\",displaySegmentedControl:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"HighlightText\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerSupportedLayoutHeight\":\"auto\",\"framerIntrinsicHeight\":\"56\",\"framerIntrin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