{"version":3,"file":"DecryptedText.GjJrP9Rh.mjs","names":["useState","useRef","useCallback"],"sources":["https:/framerusercontent.com/modules/f3cWzQsGdvndsuVZA10P/grAk8WihTr6suzFEVSVg/DecryptedText.js"],"sourcesContent":["// DecryptedText component that animates from random characters to the final text\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState,useRef,startTransition,useCallback}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function DecryptedText(props){const{text=\"Hello World\",animateOn=\"hover\",speed=50,maxIterations=15,revealDirection=\"start\",characters=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*\",font,color}=props;const[displayText,setDisplayText]=useState(text);const[isAnimating,setIsAnimating]=useState(false);const[hasAnimated,setHasAnimated]=useState(false);const intervalRef=useRef(null);const iterationRef=useRef(0);const containerRef=useRef(null);const animate=useCallback(()=>{if(typeof window===\"undefined\")return;if(isAnimating)return;if(animateOn===\"view\"&&hasAnimated)return;startTransition(()=>setIsAnimating(true));iterationRef.current=0;if(intervalRef.current!==null){clearInterval(intervalRef.current);}intervalRef.current=window.setInterval(()=>{iterationRef.current+=1;const newText=text.split(\"\").map((char,index)=>{if(char===\" \")return\" \";// Calculate reveal based on direction\nlet shouldReveal=false;if(revealDirection===\"start\"){const revealedCount=Math.floor(iterationRef.current/maxIterations*text.length);shouldReveal=index<revealedCount;}else if(revealDirection===\"end\"){const revealedCount=Math.floor(iterationRef.current/maxIterations*text.length);shouldReveal=index>=text.length-revealedCount;}else{// center\nconst revealedCount=Math.floor(iterationRef.current/maxIterations*text.length);const center=Math.floor(text.length/2);const radius=Math.floor(revealedCount/2);shouldReveal=Math.abs(index-center)<=radius;}if(shouldReveal)return text[index];return characters[Math.floor(Math.random()*characters.length)];}).join(\"\");startTransition(()=>setDisplayText(newText));if(iterationRef.current>=maxIterations){startTransition(()=>{setDisplayText(text);setIsAnimating(false);if(animateOn===\"view\"){setHasAnimated(true);}});if(intervalRef.current!==null){clearInterval(intervalRef.current);intervalRef.current=null;}}},speed);},[isAnimating,animateOn,hasAnimated,text,maxIterations,revealDirection,characters,speed]);const stopAnimation=()=>{if(intervalRef.current!==null){clearInterval(intervalRef.current);intervalRef.current=null;}startTransition(()=>{setDisplayText(text);setIsAnimating(false);});};// Intersection Observer for \"view\" mode\nuseEffect(()=>{if(animateOn!==\"view\"||!containerRef.current)return;if(typeof window===\"undefined\"||typeof IntersectionObserver===\"undefined\")return;const observer=new IntersectionObserver(entries=>{entries.forEach(entry=>{if(entry.isIntersecting&&!hasAnimated){animate();}});},{threshold:.5});observer.observe(containerRef.current);return()=>{observer.disconnect();};},[animateOn,hasAnimated,animate]);useEffect(()=>{return()=>{if(intervalRef.current!==null){clearInterval(intervalRef.current);}};},[]);return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...props.style,position:\"relative\",width:\"max-content\",minWidth:\"max-content\",minHeight:5},onMouseEnter:animateOn===\"hover\"?animate:undefined,onMouseLeave:animateOn===\"hover\"?stopAnimation:undefined,children:/*#__PURE__*/_jsx(\"span\",{style:{...font,color,whiteSpace:\"pre\"},children:displayText||text})});}addPropertyControls(DecryptedText,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Hello World\"},animateOn:{type:ControlType.Enum,title:\"Animate On\",options:[\"hover\",\"view\"],optionTitles:[\"Hover\",\"View\"],defaultValue:\"hover\",displaySegmentedControl:true},revealDirection:{type:ControlType.Enum,title:\"Reveal Direction\",options:[\"start\",\"end\",\"center\"],optionTitles:[\"Start\",\"End\",\"Center\"],defaultValue:\"start\",displaySegmentedControl:true},speed:{type:ControlType.Number,title:\"Speed\",defaultValue:50,min:10,max:200,step:10,unit:\"ms\"},maxIterations:{type:ControlType.Number,title:\"Max Iterations\",defaultValue:15,min:5,max:50,step:1},characters:{type:ControlType.String,title:\"Characters\",defaultValue:\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*\",displayTextArea:true},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"32px\",variant:\"Bold\",letterSpacing:\"-0.03em\",lineHeight:\"1em\"}},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#000000\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"DecryptedText\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./DecryptedText.map"],"mappings":"oNAIG,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,OAAK,cAAc,YAAU,QAAQ,QAAM,GAAG,gBAAc,GAAG,kBAAgB,QAAQ,aAAW,yEAAyE,OAAK,SAAO,EAAW,CAAC,EAAY,GAAgBA,EAAS,EAAK,CAAM,CAAC,EAAY,GAAgBA,EAAS,GAAM,CAAM,CAAC,EAAY,GAAgBA,EAAS,GAAM,CAAO,EAAYC,EAAO,KAAK,CAAO,EAAaA,EAAO,EAAE,CAAO,EAAaA,EAAO,KAAK,CAAO,EAAQC,MAAgB,CAAW,IAAS,SAAsB,GAAsB,IAAY,QAAQ,IAAmB,MAAoB,EAAe,GAAK,CAAC,CAAC,EAAa,QAAQ,EAAK,EAAY,UAAU,MAAM,cAAc,EAAY,QAAQ,CAAE,EAAY,QAAQ,EAAO,gBAAgB,CAAC,EAAa,SAAS,EAAE,IAAM,EAAQ,EAAK,MAAM,GAAG,CAAC,KAAK,EAAK,IAAQ,CAAC,GAAG,IAAO,IAAI,MAAM,IACr3B,IAAI,EAAa,GAAM,GAAG,IAAkB,QAAwF,EAAa,EAAxE,KAAK,MAAM,EAAa,QAAQ,EAAc,EAAK,OAAO,SAA2C,IAAkB,MAAM,CAAC,IAAM,EAAc,KAAK,M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