{"version":3,"file":"TextHighlighter.CkGLIPae.mjs","names":["useMemo","parts"],"sources":["https:/framerusercontent.com/modules/VeDQFb9XcktzPuJyjY4y/zdkFHbKZMuSihtK8svWw/TextHighlighter.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useMemo}from\"react\";/**\n * TextEditor\n *\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any-prefer-auto\n * @framerSupportedLayoutHeight any-prefer-auto\n */export default function TextEditor(props){const{text,font,fontColor,highlightColor,variableFont,style,tag}=props;const regex=/\\{([^}]+)\\}/g;const parts=useMemo(()=>{const parts=[];let lastIndex=0;let match;while((match=regex.exec(text))!==null){if(match.index>lastIndex){parts.push({text:text.slice(lastIndex,match.index),highlight:false});}parts.push({text:match[1],highlight:true});lastIndex=regex.lastIndex;}if(lastIndex<text.length){parts.push({text:text.slice(lastIndex),highlight:false});}return parts;},[text]);const variableFontStyle=useMemo(()=>({fontVariationSettings:`'opsz' ${variableFont.opticalSize}, 'wght' ${variableFont.weight}`}),[variableFont.opticalSize,variableFont.weight]);const Tag=tag;return /*#__PURE__*/_jsx(Tag,{style:{...style,color:fontColor,...font,...variableFontStyle,whiteSpace:\"pre-wrap\",wordBreak:\"break-word\",margin:0,padding:0,display:\"block\",lineHeight:font.lineHeight||\"normal\",minWidth:style?.width?undefined:\"max-content\"},children:parts.map((part,i)=>part.highlight?/*#__PURE__*/_jsx(\"span\",{style:{color:highlightColor},children:part.text},i):/*#__PURE__*/_jsx(\"span\",{children:part.text},i))});}addPropertyControls(TextEditor,{tag:{type:ControlType.Enum,title:\"Tag\",options:[\"p\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"],optionTitles:[\"p\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"],defaultValue:\"p\"},text:{type:ControlType.String,title:\"Text\",description:\"Text put within {brackets} will be highlighted.\",displayTextArea:true,defaultValue:\"This is {highlighted} text.\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:22,variant:\"Regular\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"}},variableFont:{type:ControlType.Object,title:\"Variable\",controls:{opticalSize:{type:ControlType.Number,title:\"Optical\",min:14,max:32,defaultValue:14,step:1},weight:{type:ControlType.Number,title:\"Weight\",min:100,max:900,defaultValue:400,step:1}},defaultValue:{opticalSize:14,weight:400}},fontColor:{type:ControlType.Color,title:\"Color\",defaultValue:\"#000000\"},highlightColor:{type:ControlType.Color,title:\"Highlight\",defaultValue:\"#FFFB8F\"}});TextEditor.displayName=\"Text Highlighter\";\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextEditor\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any-prefer-auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-auto\",\"framerDisableUnlink\":\"*\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextHighlighter.map"],"mappings":"2KAOG,SAAwB,EAAW,EAAM,CAAC,GAAK,CAAC,OAAK,OAAK,YAAU,iBAAe,eAAa,QAAM,OAAK,EAAY,EAAM,eAAqB,EAAMA,MAAY,CAAC,IAAMC,EAAM,EAAE,CAAK,EAAU,EAAM,EAAM,MAAO,EAAM,EAAM,KAAK,EAAK,IAAI,MAAS,EAAM,MAAM,GAAW,EAAM,KAAK,CAAC,KAAK,EAAK,MAAM,EAAU,EAAM,MAAM,CAAC,UAAU,GAAM,CAAC,CAAE,EAAM,KAAK,CAAC,KAAK,EAAM,GAAG,UAAU,GAAK,CAAC,CAAC,EAAU,EAAM,UAA+F,OAAjF,EAAU,EAAK,QAAQ,EAAM,KAAK,CAAC,KAAK,EAAK,MAAM,EAAU,CAAC,UAAU,GAAM,CAAC,CAASA,GAAQ,CAAC,EAAK,CAAC,CAAO,EAAkBD,OAAa,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