{"version":3,"file":"TextMagnifier_Prod.BCvbTEeQ.mjs","names":["useRef","useMemo","lines","_Fragment","useId"],"sources":["https:/framerusercontent.com/modules/pYGJbktLS5nZG5gcVsy0/KNBzza2Jq9PDRC7k9cRA/TextMagnifier_Prod.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useSpring,useMotionValue,useMotionValueEvent}from\"framer-motion\";import{useRef,useId,useMemo,useEffect}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n *\n * @framerDisableUnlink\n *\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 200\n */export default function MagneticText({text,color,font,transform,balance,userSelect,tag,style,range,smoothing}){const id=useInstanceId();const isCanvas=RenderTarget.current()===RenderTarget.canvas;const spanClassName=`${id}-span`;const Tag=tag;const springTransition={damping:100,stiffness:mapRange(smoothing,0,100,2e3,50)};const hasSpring=smoothing!==0;const mouseX=useMotionValue(0);const mouseY=useMotionValue(0);const mouseXSpring=useSpring(mouseX,springTransition);const mouseYSpring=useSpring(mouseY,springTransition);const elementsRef=useRef([]);// Add global mouse tracking effect\nuseEffect(()=>{const handleMouseMove=e=>{mouseX.set(e.clientX);mouseY.set(e.clientY);};window.addEventListener(\"mousemove\",handleMouseMove);return()=>window.removeEventListener(\"mousemove\",handleMouseMove);},[]);const lines=useMemo(()=>{const textLines=text.split(\"\\n\");const lines=[];for(let i=0;i<textLines.length;i++){const line=textLines[i].split(/[ \\t]+/);lines.push(line);}return lines;},[text]);let index=0;const createLineChildren=(lineIndex,lineWords)=>{return lineWords.map((word,wordIndex)=>/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"span\",{className:`${id}-word-wrapper`,children:word.split(\"\").map((char,charIndex)=>{const savedIndex=index;index++;return /*#__PURE__*/_jsx(\"span\",{ref:el=>{if(el)elementsRef.current[savedIndex]=el;},className:spanClassName,children:char},`${lineIndex}-${wordIndex}-${charIndex}`);})},`${lineIndex}-${wordIndex}`),wordIndex<lineWords.length-1&&\" \"]}));};const updateScale=(mx,my)=>{for(let i=0;i<elementsRef.current.length;i++){const element=elementsRef.current[i];if(!element)continue;const rect=element.getBoundingClientRect();const characterCenterX=rect.left+rect.width/2;const characterCenterY=rect.top+rect.height/2;const distance=Math.sqrt(Math.pow(characterCenterX-mx,2)+Math.pow(characterCenterY-my,2));const d=clamp01(mapRange(distance,range/2,0,0,1));const scaleX=mapRange(d,0,1,1,1.2);const w=mapRange(d,0,1,0,.07);const padding=mapRange(d,0,1,0,.05);const scaleY=mapRange(d,0,1,1,.95);element.style.transform=`scale(${scaleX}, ${scaleY})`;element.style[\"-webkit-text-stroke-width\"]=`${w}em`;element.style.paddingInline=`${padding}em`;}};useMotionValueEvent(hasSpring?mouseXSpring:mouseX,\"change\",mx=>{if(mouseY){updateScale(mx,hasSpring?mouseYSpring.get():mouseY.get());}});useMotionValueEvent(hasSpring?mouseYSpring:mouseY,\"change\",my=>{if(mouseX){updateScale(hasSpring?mouseXSpring.get():mouseX.get(),my);}});return /*#__PURE__*/_jsxs(Tag,{style:{position:\"relative\",cursor:\"default\",margin:0,whiteSpace:style?.width?\"pre\":\"nowrap\",fontWeight:400,textAlign:\"center\",userSelect:userSelect?\"auto\":\"none\",textWrap:balance?\"balance\":undefined,textTransform:transform,color,...font,...style},children:[/*#__PURE__*/_jsx(\"style\",{children:`\n\t.${id}-line {\n\t\twidth: 100%;\n\t\tdisplay: block;\n\t\ttransform-style: preserve-3d;\n\t}\n\t.${id}-word-wrapper {\n\t\tdisplay: inline-block;\n\t\ttransform-style: preserve-3d;\n\t\twhite-space: pre;\n\t}\n\t.${id}-span {\n\t\tdisplay: inline-block;\n\t\ttransform-style: preserve-3d;\n\t\twhite-space: pre;\n\t\twill-change: transform, -webkit-text-stroke-width, padding-inline;\n\t\ttransform-origin: 50% 50%};\n\t\t-webkit-text-stroke-color: currentColor;\n\t}\n`}),lines.length===1?createLineChildren(0,lines[0]):lines.map((lineWords,lineIndex)=>/*#__PURE__*/_jsx(\"span\",{className:`${id}-line`,children:createLineChildren(lineIndex,lineWords)},lineIndex))]});}MagneticText.displayName=\"Text Magnifier\";addPropertyControls(MagneticText,{text:{type:ControlType.String,defaultValue:\"Learn Framer With Framer University\",displayTextArea:true},range:{type:ControlType.Number,defaultValue:200},smoothing:{type:ControlType.Number,defaultValue:50,min:0,max:100,step:1},font:{type:\"font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:32,lineHeight:1.2}},color:{type:ControlType.Color,defaultValue:\"#999999\"},transform:{type:ControlType.Enum,defaultValue:\"none\",options:[\"none\",\"uppercase\",\"lowercase\"],optionTitles:[\"None\",\"Uppercase\",\"Lowercase\"]},balance:{type:ControlType.Boolean,defaultValue:false},userSelect:{type:ControlType.Boolean,defaultValue:false},tag:{type:ControlType.Enum,defaultValue:\"p\",displaySegmentedControl:true,options:[\"h1\",\"h2\",\"h3\",\"p\"],optionTitles:[\"H1\",\"H2\",\"H3\",\"P\"],description:\"More components at [Framer University](https://frameruni.link/cc).\"}});const useInstanceId=()=>{const id=useId();const cleanId=id.replace(/:/g,\"\");const instanceId=`frameruni-${cleanId}`;return instanceId;};function mapRange(value,fromLow,fromHigh,toLow,toHigh){if(fromLow===fromHigh){return toLow;}const percentage=(value-fromLow)/(fromHigh-fromLow);return toLow+percentage*(toHigh-toLow);}function clamp01(value){return Math.max(0,Math.min(value,1));}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"MagneticText\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"200\",\"framerDisableUnlink\":\"*\",\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"400\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextMagnifier_Prod.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