{"version":3,"file":"CipherTextScramble.DPVapQhz.mjs","names":["useRef","useState","useCallback"],"sources":["https:/framerusercontent.com/modules/nfV8iqWh5F02w9LlSxUj/vC0XCoxMh4ZrYNIGFSPW/CipherTextScramble.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useRef,useEffect,startTransition,useCallback}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * TextScramble effect displaying animated matrix-like text cycling through phrases.\n *\n * @framerIntrinsicWidth 600\n * @framerIntrinsicHeight 120\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function CipherTextScramble(props){const{phrases=[\"Neo,\",\"sooner or later\",\"you're going to realize\",\"just as I did\",\"that there's a difference\",\"between knowing the path\",\"and walking the path\"],interval=900,font,dudColor=\"#757575\",textColor=\"#FAFAFA\",style,scrambleSpeed=40}=props;const isStatic=useIsStaticRenderer();const containerRef=useRef(null);const[displayText,setDisplayText]=useState(\"\");const[scrambleHtml,setScrambleHtml]=useState(\"\");const[counter,setCounter]=useState(0);const frame=useRef(0);const queue=useRef([]);const raf=useRef(null);// Effect: main scramble logic\nconst setText=useCallback((oldText,newText)=>{const chars=props.scrambleChars||\"!<>-_\\\\/[]{}—=+*^?#________\";const length=Math.max(oldText.length,newText.length);let scrambleQ=[];for(let i=0;i<length;i++){const from=oldText[i]||\"\";const to=newText[i]||\"\";// Scramble speed parameterization\nconst start=Math.floor(Math.random()*props.scrambleSpeed);const end=start+Math.floor(Math.random()*props.scrambleSpeed);scrambleQ.push({from,to,start,end});}queue.current=scrambleQ;frame.current=0;const update=()=>{let output=\"\";let complete=0;for(let i=0,n=scrambleQ.length;i<n;i++){let{from,to,start,end,char}=scrambleQ[i];if(frame.current>=end){complete++;output+=to;}else if(frame.current>=start){if(!char||Math.random()<.28){char=chars[Math.floor(Math.random()*chars.length)];scrambleQ[i].char=char;}output+=`<span class=\"dud\">${char}</span>`;}else{output+=from;}}startTransition(()=>setScrambleHtml(output));if(complete===scrambleQ.length){// Done\nstartTransition(()=>setDisplayText(newText));}else{frame.current++;raf.current=requestAnimationFrame(update);}};update();},[]);useEffect(()=>{if(isStatic){setDisplayText(phrases[0]);setScrambleHtml(phrases[0]);return;}setDisplayText(\"\");setScrambleHtml(\"\");let stopped=false;let localCounter=0;function tick(){setText(displayText,phrases[localCounter]);setTimeout(()=>{if(stopped)return;localCounter=(localCounter+1)%phrases.length;tick();},interval+600);}tick();return()=>{stopped=true;if(raf.current)cancelAnimationFrame(raf.current);};// eslint-disable-next-line\n},[isStatic,phrases,interval,setText,scrambleSpeed]);// Inject Roboto Mono font\nuseEffect(()=>{if(typeof window!==\"undefined\"){if(!document.getElementById(\"roboto-mono-font\")){const l=document.createElement(\"link\");l.id=\"roboto-mono-font\";l.rel=\"stylesheet\";l.href=\"https://fonts.googleapis.com/css?family=Roboto+Mono:100\";document.head.appendChild(l);}}},[]);const actualHtml=scrambleHtml||displayText;return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{...style,width:props.sizing===\"fit-content\"?\"fit-content\":\"100%\",height:props.sizing===\"fit-content\"?\"fit-content\":\"100%\",minHeight:60,display:\"flex\",justifyContent:\"center\",alignItems:\"center\",// Framer native background color only\nbackground:props.backgroundColor,fontFamily:\"'Roboto Mono', monospace\",position:\"relative\"},role:\"region\",\"aria-label\":\"Text Scramble Animated Messages\",children:[/*#__PURE__*/_jsx(\"span\",{style:{...font||{},fontWeight:100,fontSize:font?.fontSize||28,color:textColor,whiteSpace:\"pre-wrap\",width:\"max-content\"},// eslint-disable-next-line\ndangerouslySetInnerHTML:{__html:actualHtml},tabIndex:0,\"aria-live\":\"polite\",\"aria-atomic\":\"true\",\"aria-label\":displayText,onKeyDown:e=>{if([\"ArrowRight\",\"ArrowDown\",\"Space\",\"Enter\"].includes(e.key)){e.preventDefault();startTransition(()=>setCounter(c=>(c+1)%phrases.length));}else if([\"ArrowLeft\",\"ArrowUp\"].includes(e.key)){e.preventDefault();startTransition(()=>setCounter(c=>(c-1+phrases.length)%phrases.length));}}}),/*#__PURE__*/_jsx(\"style\",{children:`.dud { color: ${dudColor} }`})]});}addPropertyControls(CipherTextScramble,{phrases:{type:ControlType.Array,title:\"Phrases\",description:\"Array of phrases to display in the scramble animation.\",control:{type:ControlType.String,placeholder:\"Enter text...\"},defaultValue:[\"Neo,\",\"sooner or later\",\"you're going to realize\",\"just as I did\",\"that there's a difference\",\"between knowing the path\",\"and walking the path\"]},interval:{type:ControlType.Number,title:\"Delay (ms)\",description:\"Delay between phrase transitions in milliseconds.\",defaultValue:900,min:200,max:4e3,unit:\"ms\"},textColor:{type:ControlType.Color,title:\"Main Color\",description:\"Color of the main text.\",defaultValue:\"#FAFAFA\"},dudColor:{type:ControlType.Color,title:\"Scramble Color\",description:\"Color for scrambling effect characters.\",defaultValue:\"#757575\"},font:{type:ControlType.Font,controls:\"extended\",title:\"Font\",description:\"Font style for the displayed text.\",defaultFontType:\"monospace\",defaultValue:{fontSize:28,textAlign:\"center\",lineHeight:1}},scrambleSpeed:{type:ControlType.Number,title:\"Scramble Speed\",description:\"Controls the speed of the scrambling animation (lower is faster).\",defaultValue:40,min:10,max:100,step:1},scrambleChars:{type:ControlType.String,title:\"Scramble Characters\",placeholder:\"!<>-_\\\\/[]{}—=+*^?#________\",defaultValue:\"!<>-_\\\\/[]{}—=+*^?#________\",description:\"Set of characters for the scrambling effect. Modify for creative results.\"},backgroundColor:{type:ControlType.Color,title:\"Background Color\",description:\"Background color for the component.\",defaultValue:\"#212121\"},sizing:{type:ControlType.Enum,title:\"Sizing\",description:\"Component dimensions: fill parent or fit-content.\",options:[\"fill\",\"fit-content\"],optionTitles:[\"Fill (100%)\",\"Fit Content\"],defaultValue:\"fill\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CipherTextScramble\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"600\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"120\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CipherTextScramble.map"],"mappings":"8NAQG,SAAwB,EAAmB,EAAM,CAAC,GAAK,CAAC,UAAQ,CAAC,OAAO,kBAAkB,0BAA0B,gBAAgB,4BAA4B,2BAA2B,uBAAuB,CAAC,WAAS,IAAI,OAAK,WAAS,UAAU,YAAU,UAAU,QAAM,gBAAc,IAAI,EAAY,EAAS,GAAqB,CAAO,EAAaA,EAAO,KAAK,CAAM,CAAC,EAAY,GAAgBC,EAAS,GAAG,CAAM,CAAC,EAAa,GAAiBA,EAAS,GAAG,CAAM,CAAC,EAAQ,GAAYA,EAAS,EAAE,CAAO,EAAMD,EAAO,EAAE,CAAO,EAAMA,EAAO,EAAE,CAAC,CAAO,EAAIA,EAAO,KAAK,CACrjB,EAAQE,GAAa,EAAQ,IAAU,CAAC,IAAM,EAAM,EAAM,eAAe,8BAAoC,EAAO,KAAK,IAAI,EAAQ,OAAO,EAAQ,OAAO,CAAK,EAAU,EAAE,CAAC,IAAI,IAAI,EAAE,EAAE,EAAE,EAAO,IAAI,CAAC,IAAM,EAAK,EAAQ,IAAI,GAAS,EAAG,EAAQ,IAAI,GACtP,EAAM,KAAK,MAAM,KAAK,QAAQ,CAAC,EAAM,cAAc,CAAO,EAAI,EAAM,KAAK,MAAM,KAAK,QAAQ,CAAC,EAAM,cAAc,CAAC,EAAU,KAAK,CAAC,OAAK,KAAG,QAAM,MAAI,CAAC,CAAE,EAAM,QAAQ,EAAU,EAAM,QAAQ,EAAE,IAAM,MAAW,CAAC,IAAI,EAAO,GAAO,EAAS,EAAE,IAAI,IAAI,EAAE,EAAE,EAAE,EAAU,OAAO,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,OAAK,KAAG,QAAM,MAAI,QAAM,EAAU,GA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