{"version":3,"file":"FadeWords.evLMBSnu.mjs","names":["React.useMemo","React.useState","React.useRef","React.useCallback","text"],"sources":["https:/framerusercontent.com/modules/Mzmby6Gz6JmZkDvthUOV/ZlCOSckz13lNnd8BHnS9/FadeWords.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerDisableUnlink\n * @framerIntrinsicWidth 600\n * @framerIntrinsicHeight 300\n */export default function WordBlur(props){const{text=\"This is an experiment to fade a few specific phrases in this paragraph.\",fadedPhrases=[\"fade a few\",\"specific phrases\"],blurStrength=2,opacityStrength=.75,fadeDirection=\"left-to-right\",fadeColor=\"#CCCCCC\",font={fontFamily:\"Inter\",fontSize:\"20px\",fontWeight:400,lineHeight:\"1.6em\",letterSpacing:\"0px\",textAlign:\"left\"},color=\"#000000\",onTextChange}=props;// Generate unique ID for this component instance\nconst uniqueId=React.useMemo(()=>`fade-${Math.random().toString(36).substr(2,9)}`,[]);// State to track clicked elements for mobile\nconst[clickedElements,setClickedElements]=React.useState(new Set);// Check if device is mobile/touch\nconst[isMobile,setIsMobile]=React.useState(false);// Timeout refs for auto-blur\nconst timeoutRefs=React.useRef(new Map);React.useEffect(()=>{const checkMobile=()=>{setIsMobile(window.matchMedia(\"(max-width: 1024px)\").matches||\"ontouchstart\"in window);};checkMobile();window.addEventListener(\"resize\",checkMobile);return()=>window.removeEventListener(\"resize\",checkMobile);},[]);// Clean up timeouts on unmount\nReact.useEffect(()=>{return()=>{timeoutRefs.current.forEach(timeout=>clearTimeout(timeout));};},[]);const fadeText=React.useCallback(text=>{let processed=text;let phraseIndex=0;fadedPhrases.forEach(phrase=>{const regex=new RegExp(`(${phrase})`,\"g\");processed=processed.replace(regex,(_,match)=>{const chars=match.split(\"\");const total=chars.filter(c=>c!==\" \").length;let letterIndex=0;const currentPhraseIndex=phraseIndex++;const isClicked=clickedElements.has(currentPhraseIndex.toString());const wrapped=chars.map(char=>{if(char===\" \")return\" \";return`<span style=\"--i:${letterIndex++}; --total:${total};\">${char}</span>`;}).join(\"\");return`<span class=\"${uniqueId}${isClicked?\" clicked\":\"\"}\" data-phrase=\"${currentPhraseIndex}\">${wrapped}</span>`;});});return processed;},[fadedPhrases,uniqueId,clickedElements]);const handleInput=e=>{if(onTextChange){onTextChange(e.target.innerText);}};const handleClick=e=>{if(!isMobile)return;e.preventDefault();e.stopPropagation();const fadeElement=e.target.closest(`.${uniqueId}`);if(fadeElement){const phraseIndex=fadeElement.getAttribute(\"data-phrase\");// Clear existing timeout for this phrase\nif(timeoutRefs.current.has(phraseIndex)){clearTimeout(timeoutRefs.current.get(phraseIndex));}setClickedElements(prev=>{const newSet=new Set(prev);if(newSet.has(phraseIndex)){newSet.delete(phraseIndex);}else{newSet.add(phraseIndex);// Set timeout to auto-blur after 3 seconds\nconst timeout=setTimeout(()=>{setClickedElements(current=>{const updated=new Set(current);updated.delete(phraseIndex);return updated;});timeoutRefs.current.delete(phraseIndex);},3e3);timeoutRefs.current.set(phraseIndex,timeout);}return newSet;});}};const handleTouchStart=e=>{if(isMobile){e.preventDefault();}};return /*#__PURE__*/_jsxs(\"div\",{children:[/*#__PURE__*/_jsx(\"style\",{children:`\n        .${uniqueId} span {\n          opacity: calc(1 - ${fadeDirection===\"left-to-right\"?\"var(--i)\":\"(var(--total) - 1 - var(--i))\"} / var(--total) * ${opacityStrength});\n          filter: blur(calc(${fadeDirection===\"left-to-right\"?\"var(--i)\":\"(var(--total) - 1 - var(--i))\"} / var(--total) * ${blurStrength}px));\n          color: ${fadeColor};\n          transition: opacity 0.3s, filter 0.3s, color 0.3s;\n        }\n        \n        /* Desktop hover */\n        @media (min-width: 1025px) and (hover: hover) {\n          .${uniqueId}:hover span {\n            opacity: 1 !important;\n            filter: blur(0px) !important;\n            color: ${color} !important;\n          }\n        }\n        \n        /* Mobile and tablet click state */\n        .${uniqueId}.clicked span {\n          opacity: 1 !important;\n          filter: blur(0px) !important;\n          color: ${color} !important;\n        }\n        \n        /* Mobile and tablet cursor */\n        @media (max-width: 1024px) {\n          .${uniqueId} {\n            cursor: pointer;\n            -webkit-touch-callout: none;\n            -webkit-user-select: none;\n            -khtml-user-select: none;\n            -moz-user-select: none;\n            -ms-user-select: none;\n            user-select: none;\n          }\n        }\n      `}),/*#__PURE__*/_jsx(\"p\",{contentEditable:!isMobile,suppressContentEditableWarning:true,onInput:handleInput,onClick:handleClick,onTouchStart:handleTouchStart,dangerouslySetInnerHTML:{__html:fadeText(text)},style:{margin:0,fontFamily:font.fontFamily,fontSize:font.fontSize,fontWeight:font.fontWeight,fontStyle:font.fontStyle,lineHeight:font.lineHeight,letterSpacing:font.letterSpacing,textAlign:font.textAlign,color,userSelect:\"none\",WebkitUserSelect:\"none\",MozUserSelect:\"none\",msUserSelect:\"none\",WebkitTouchCallout:\"none\",WebkitTapHighlightColor:\"transparent\"}})]});}addPropertyControls(WordBlur,{text:{type:ControlType.String,title:\"Text\",displayTextArea:true,defaultValue:\"This is an experiment to fade a few specific phrases in this paragraph.\"},fadedPhrases:{type:ControlType.Array,title:\"Fade Phrases\",control:{type:ControlType.String,placeholder:\"Enter phrase to fade\"},defaultValue:[\"fade a few\",\"specific phrases\"]},blurStrength:{type:ControlType.Number,title:\"Blur Strength\",defaultValue:2,min:0,max:10,step:.1},opacityStrength:{type:ControlType.Number,title:\"Opacity Fade\",defaultValue:.75,min:0,max:1,step:.05},fadeDirection:{type:ControlType.Enum,title:\"Fade Direction\",options:[\"left-to-right\",\"right-to-left\"],optionTitles:[\"Left to Right\",\"Right to Left\"],defaultValue:\"left-to-right\",displaySegmentedControl:true},fadeColor:{type:ControlType.Color,title:\"Fade Color\",defaultValue:\"#CCCCCC\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"20px\",variant:\"Regular\",lineHeight:\"1.6em\",letterSpacing:\"0px\",textAlign:\"left\"}},color:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"WordBlur\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"300\",\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"* @framerIntrinsicWidth 600\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FadeWords.map"],"mappings":"sNAIG,SAAwB,EAAS,EAAM,CAAC,GAAK,CAAC,OAAK,0EAA0E,eAAa,CAAC,aAAa,mBAAmB,CAAC,eAAa,EAAE,kBAAgB,IAAI,gBAAc,gBAAgB,YAAU,UAAU,OAAK,CAAC,WAAW,QAAQ,SAAS,OAAO,WAAW,IAAI,WAAW,QAAQ,cAAc,MAAM,UAAU,OAAO,CAAC,QAAM,UAAU,gBAAc,EAC7Y,EAASA,MAAkB,QAAQ,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,EAAE,CAAC,CAChF,CAAC,EAAgB,GAAoBC,EAAe,IAAI,IAAI,CAC5D,CAAC,EAAS,GAAaA,EAAe,GAAM,CAC3C,EAAYC,EAAa,IAAI,IAAI,CAAC,MAAoB,CAAC,IAAM,MAAgB,CAAC,EAAY,EAAO,WAAW,sBAAsB,CAAC,SAAS,iBAAiB,EAAO,EAA+D,OAA5D,GAAa,CAAC,EAAO,iBAAiB,SAAS,EAAY,KAAW,EAAO,oBAAoB,SAAS,EAAY,EAAG,EAAE,CAAC,CACzS,UAA+B,CAAC,EAAY,QAAQ,QAAQ,GAAS,aAAa,EAAQ,CAAC,EAAK,EAAE,CAAC,CAAC,IAAM,EAASC,EAAkB,GAAM,CAAC,IAAI,EAAUC,EAAS,EAAY,EAAokB,OAAlkB,EAAa,QAAQ,GAAQ,CAAC,IAAM,EAAU,OAAO,IAAI,EAAO,GAAG,IAAI,CAAC,EAAU,EAAU,QAAQ,GAAO,EAAE,IAAQ,CAAC,IAAM,EAAM,EAAM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