{"version":3,"file":"ScrambleCycle.CJsbswbT.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/AqRg4z2fBvk9GywVdOtc/l76qPhyR9CST8ma664GN/ScrambleCycle.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useRef,useEffect,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{useInView}from\"framer-motion\";const LETTERS=\"abcdefghijklmnopqrstuvwxyz-.,+*!?@&%/=#^;:()[]{}<>`~|_\\xa3€\";const RANGE_ITERATION=1;const MAX_ITERATION=100;const CYCLE=100/4;/*\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */export default function ScrambleCycle(props){const{text,speed,font,color,tag,loop,delay,userSelect}=props;const content=text.split(\", \");const[encryptedText,setEncryptedText]=useState(content[0]);const[iteration,setIteration]=useState(0);const[textIteration,setTextIteration]=useState(0);const ref=useRef(null);const isInView=useInView(ref);useEffect(()=>{const encrypt=async()=>{await sleep(inverseSpeed(speed));if(iteration>=MAX_ITERATION){if(content.length>textIteration+1){setTextIteration(textIteration+1);}else{setTextIteration(0);}setIteration(0);}const contentLength=content[textIteration].length;if(MAX_ITERATION/2===iteration){await sleep(delay*1e3);if(content.length===textIteration+1&&!loop){return;}}const newEncryptedText=content[textIteration].split(\"\").map((letter,index)=>{const cycleDelay=CYCLE/contentLength*index;if(iteration>cycleDelay+CYCLE&&iteration<cycleDelay+CYCLE*3){return content[textIteration][index];}return LETTERS[Math.floor(Math.random()*LETTERS.length-1)];}).join(\"\");setEncryptedText(newEncryptedText);setIteration(prev=>prev+RANGE_ITERATION);};isInView&&encrypt();},[iteration,isInView,props]);const Tag=tag// Dynamically assign the tag based on the props\n;return /*#__PURE__*/_jsx(Tag,{ref:ref,style:{fontWeight:\"regular\",fontSize:16,...props.font,color,margin:\"0px\",userSelect},children:encryptedText});}ScrambleCycle.displayName=\"Scramble Cycle\";addPropertyControls(ScrambleCycle,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"DESIGNER, DEVELOPER\",description:\"Divide the words with a comma (,) if you want to display them separately.\"},speed:{type:ControlType.Number,title:\"Speed\",defaultValue:50,min:1,max:100},delay:{type:ControlType.Number,title:\"Delay\",defaultValue:1,min:0,max:10,description:\"How long (in seconds) should each word be displayed before scrambling again?\"},font:{type:ControlType.Font,title:\"Font\",defaultValue:\"Inter\",controls:\"extended\"},userSelect:{type:ControlType.Enum,title:\"User Select\",defaultValue:\"Yes\",displaySegmentedControl:true,segmentedControlDirection:\"horizontal\",options:[\"none\",\"auto\"],optionTitles:[\"No\",\"Yes\"]},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#000000\"},tag:{type:ControlType.Enum,title:\"Tag\",defaultValue:\"p\",displaySegmentedControl:true,segmentedControlDirection:\"horizontal\",options:[\"h1\",\"h2\",\"h3\",\"p\"],optionTitles:[\"H1\",\"H2\",\"H3\",\"P\"]},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:true}});const sleep=ms=>new Promise(resolve=>setTimeout(resolve,ms));const inverseSpeed=speed=>101-speed;\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrambleCycle\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any\",\"framerDisableUnlink\":\"*\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrambleCycle.map"],"mappings":"oOAKG,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,OAAK,QAAM,OAAK,QAAM,MAAI,OAAK,QAAM,cAAY,EAAY,EAAQ,EAAK,MAAM,KAAK,CAAM,CAAC,EAAc,GAAkBA,EAAS,EAAQ,GAAG,CAAM,CAAC,EAAU,GAAcA,EAAS,EAAE,CAAM,CAAC,EAAc,GAAkBA,EAAS,EAAE,CAAO,EAAIC,EAAO,KAAK,CAAO,EAAS,EAAU,E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