{"version":3,"file":"ScrambleCycle.5_2pXmjo.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/AqRg4z2fBvk9GywVdOtc/FaRD8MvFqPB12J8wbIqf/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 CYCLE=LETTERS.length/2;/*\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()=>{const contentLength=content[textIteration].length;const MAX_ITERATION=CYCLE*2+content[textIteration].length*2;await sleep(inverseSpeed(speed));if(iteration>=MAX_ITERATION){if(content.length>textIteration+1){setTextIteration(textIteration+1);}else{setTextIteration(0);}setIteration(0);}if(MAX_ITERATION/2===iteration){await sleep(delay*1e3);if(content.length===textIteration+1&&!loop){return;}}const newEncryptedText=content[textIteration].split(\"\").map((letter,index)=>{if(iteration>=index+CYCLE&&iteration<=index+CYCLE+content[textIteration].length){return content[textIteration][index];}return LETTERS[Math.floor(Math.random()*LETTERS.length-1)];}).join(\"\");setEncryptedText(newEncryptedText);setIteration(prev=>prev+1);};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:[\"auto\",\"none\"],optionTitles:[\"Yes\",\"No\"]},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,description:\"More components at [Framer University](https://frameruni.link/cc).\"}});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\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerDisableUnlink\":\"*\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrambleCycle.map"],"mappings":"qWAKG,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,E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