{"version":3,"file":"Examples.4Oa6eWA0.mjs","names":["useStore","useState","Wrapped","useRef","useState","useCallback","Children"],"sources":["https:/framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js","https:/framer.com/m/framer/store.js@^1.0.0","https:/framerusercontent.com/modules/28rXvpPsrum7FH6cMELS/1jCAazZw1EGHjrG5Nu5D/Utils.js","https:/framer.com/m/framer/utils.js@^0.9.0","https:/framerusercontent.com/modules/lenhCobGA7Jpo1wRONUx/TzJg3UwYkJF1Pcv4gCoJ/Examples.js"],"sourcesContent":["import{useState,useEffect}from\"react\";import{Data,useObserveData}from\"framer\";export function createStore(state1){// Use Data so that a Preview reload resets the state\nconst dataStore=Data({state:Object.freeze({...state1})});// Create a set function that updates the state\nconst setDataStore=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(dataStore.state);}dataStore.state=Object.freeze({...dataStore.state,...newState});};// Store the initial state, copy the object if it's an object\nlet storeState=typeof state1===\"object\"?Object.freeze({...state1}):state1;// Keep a list of all the listeners, in the form of React hook setters\nconst storeSetters=new Set();// Create a set function that updates all the listeners / setters\nconst setStoreState=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(storeState);}storeState=typeof newState===\"object\"?Object.freeze({...storeState,...newState}):newState;// Update all the listeners / setters with the new value\nstoreSetters.forEach(setter=>setter(storeState));};// Create the actual hook based on everything above\nfunction useStore(){// Create the hook we are going to use as a listener\nconst[state,setState]=useState(storeState);// If we unmount the component using this hook, we need to remove the listener\n// @ts-ignore\nuseEffect(()=>{// But right now, we need to add the listener\nstoreSetters.add(setState);return()=>storeSetters.delete(setState);},[]);// If Data context exists, use Data, otherwise use vanilla React state\nif(useObserveData()===true){useObserveData();return[dataStore.state,setDataStore];}else{// Return the state and a function to update the central store\nreturn[state,setStoreState];}}return useStore;}\nexport const __FramerMetadata__ = {\"exports\":{\"createStore\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./createStore.map","/*\n * createStore (framer/store@1.0.1)\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js\"\n","export const centerContent = {\n    display: \"flex\",\n    justifyContent: \"center\",\n    alignItems: \"center\"\n};\nexport const autoSizingText = {\n    width: \"max-content\",\n    wordBreak: \"break-word\",\n    overflowWrap: \"break-word\",\n    overflow: \"hidden\",\n    whiteSpace: \"pre-wrap\",\n    flexShrink: 0\n};\nexport const defaultContainerStyles = {\n    ...centerContent,\n    overflow: \"hidden\"\n};\nexport const containerStyles = defaultContainerStyles;\nexport const randomColor = ()=>\"#\" + Math.floor(Math.random() * 16777215).toString(16)\n;\n\nexport const __FramerMetadata__ = {\"exports\":{\"centerContent\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"containerStyles\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"autoSizingText\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"defaultContainerStyles\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"randomColor\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}}}}\n//# sourceMappingURL=./Utils.map","/*\n * Utils (framer/utils@0.9.0)\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/28rXvpPsrum7FH6cMELS/1jCAazZw1EGHjrG5Nu5D/Utils.js\"\n","import{jsx as _jsx}from\"react/jsx-runtime\";import{Children,cloneElement,forwardRef,isValidElement,startTransition,useCallback,useEffect,useRef,useState}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{useAnimation}from\"framer-motion\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{randomColor}from\"https://framer.com/m/framer/utils.js@^0.9.0\";// Learn more: https://www.framer.com/docs/guides/overrides/\nconst useStore=createStore({background:\"#0099FF\"});const HOVER_MULTIPLIER=1.6;const RAMP_DURATION=.6;export function withRotate(Component){return props=>{return /*#__PURE__*/_jsx(Component,{...props,animate:{rotate:90},transition:{duration:2}});};}export function withHover(Component){return props=>{return /*#__PURE__*/_jsx(Component,{...props,whileHover:{scale:1.05}});};}export function withRandomColor(Component){return props=>{const[store,setStore]=useStore();return /*#__PURE__*/_jsx(Component,{...props,animate:{background:store.background},onClick:()=>{setStore({background:randomColor()});}});};}export function withRandomDrift(Component){const Wrapped=/*#__PURE__*/forwardRef(function Wrapped(props,forwardedRef){const{range=120,speed=4,scalePulse=true,...rest}=props;const controls=useAnimation();const isStaticRenderer=useIsStaticRenderer();const elementRef=useRef(null);const[isHovered,setIsHovered]=useState(false);const setRefs=useCallback(node=>{elementRef.current=node;if(typeof forwardedRef===\"function\"){forwardedRef(node);}else if(forwardedRef&&\"current\"in forwardedRef){forwardedRef.current=node;}},[forwardedRef]);useEffect(()=>{if(typeof window===\"undefined\"||isStaticRenderer)return;const node=elementRef.current;if(!node)return;let target=node.parentElement;let cursor=node.parentElement;while(cursor){const{width}=cursor.getBoundingClientRect();if(width>=400){target=cursor;break;}cursor=cursor.parentElement;}if(!target)return;const onEnter=()=>{startTransition(()=>setIsHovered(true));};const onLeave=()=>{startTransition(()=>setIsHovered(false));};target.addEventListener(\"pointerenter\",onEnter);target.addEventListener(\"pointerleave\",onLeave);return()=>{target?.removeEventListener(\"pointerenter\",onEnter);target?.removeEventListener(\"pointerleave\",onLeave);};},[isStaticRenderer]);useEffect(()=>{let cancelled=false;const driftLoop=async()=>{while(!cancelled&&isHovered){const nextX=(Math.random()*2-1)*range;const nextY=(Math.random()*2-1)*range;const nextScale=scalePulse?1+Math.random()*.12:1;await controls.start({x:nextX,y:nextY,scale:nextScale,transition:{duration:Math.max(.5,speed),ease:\"easeInOut\"}});}};if(isStaticRenderer||typeof window===\"undefined\")return;if(isHovered){driftLoop();}else{controls.start({x:0,y:0,scale:1,transition:{duration:Math.max(.5,speed*.8),ease:\"easeOut\"}});}return()=>{cancelled=true;};},[controls,isHovered,isStaticRenderer,range,scalePulse,speed]);return /*#__PURE__*/_jsx(Component,{ref:setRefs,...rest,animate:controls});});addPropertyControls(Wrapped,{range:{type:ControlType.Number,title:\"Range\",defaultValue:120,min:20,max:400,unit:\"px\",step:1},speed:{type:ControlType.Number,title:\"Speed\",defaultValue:4,min:1,max:12,unit:\"s\",step:.1},scalePulse:{type:ControlType.Boolean,title:\"Scale Pulse\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"}});return Wrapped;}export function withBlobHoverSpeed(Component){const Wrapped=/*#__PURE__*/forwardRef(function Wrapped(props,forwardedRef){const{children,onPointerEnter,onPointerLeave,...rest}=props;const isStaticRenderer=useIsStaticRenderer();const[animatedFactor,setAnimatedFactor]=useState(1);const isHoveredRef=useRef(false);const frameRef=useRef(null);const currentFactorRef=useRef(1);const startFactorRef=useRef(1);const targetFactorRef=useRef(1);const startTimeRef=useRef(0);const setRefs=useCallback(node=>{if(typeof forwardedRef===\"function\"){forwardedRef(node);}else if(forwardedRef&&\"current\"in forwardedRef){forwardedRef.current=node;}},[forwardedRef]);const cancelFrame=useCallback(()=>{if(typeof window!==\"undefined\"&&frameRef.current!==null){window.cancelAnimationFrame(frameRef.current);frameRef.current=null;}},[]);const animateTo=useCallback(nextTarget=>{if(typeof window===\"undefined\"||isStaticRenderer){currentFactorRef.current=nextTarget;targetFactorRef.current=nextTarget;startFactorRef.current=nextTarget;startTransition(()=>setAnimatedFactor(nextTarget));return;}cancelFrame();startFactorRef.current=currentFactorRef.current;targetFactorRef.current=nextTarget;startTimeRef.current=typeof performance!==\"undefined\"?performance.now():Date.now();const durationMs=Math.max(.01,RAMP_DURATION)*1e3;const tick=now=>{const elapsed=now-startTimeRef.current;const linearProgress=Math.min(1,elapsed/durationMs);const easedProgress=linearProgress<.5?4*linearProgress*linearProgress*linearProgress:1-Math.pow(-2*linearProgress+2,3)/2;const nextValue=startFactorRef.current+(targetFactorRef.current-startFactorRef.current)*easedProgress;currentFactorRef.current=nextValue;startTransition(()=>setAnimatedFactor(nextValue));if(linearProgress<1){frameRef.current=window.requestAnimationFrame(tick);}else{frameRef.current=null;}};frameRef.current=window.requestAnimationFrame(tick);},[cancelFrame,isStaticRenderer]);useEffect(()=>{return()=>{cancelFrame();};},[cancelFrame]);const handlePointerEnter=useCallback(event=>{isHoveredRef.current=true;animateTo(HOVER_MULTIPLIER);onPointerEnter?.(event);},[animateTo,onPointerEnter]);const handlePointerLeave=useCallback(event=>{isHoveredRef.current=false;animateTo(1);onPointerLeave?.(event);},[animateTo,onPointerLeave]);const transformChildren=useCallback(node=>{return Children.map(node,child=>{if(!/*#__PURE__*/isValidElement(child))return child;const childProps=child.props;const nestedChildren=childProps.children;const transformedNestedChildren=nestedChildren!==undefined?transformChildren(nestedChildren):nestedChildren;const hasNumericSpeed=typeof childProps.speed===\"number\";const nextSpeed=hasNumericSpeed?childProps.speed*animatedFactor:undefined;if(!hasNumericSpeed&&transformedNestedChildren===nestedChildren){return child;}const nextProps={};if(hasNumericSpeed){nextProps.speed=nextSpeed;}if(transformedNestedChildren!==nestedChildren){nextProps.children=transformedNestedChildren;}return /*#__PURE__*/cloneElement(child,nextProps);});},[animatedFactor]);const renderedChildren=isStaticRenderer?children:transformChildren(children);return /*#__PURE__*/_jsx(Component,{ref:setRefs,...rest,children:renderedChildren,onPointerEnter:handlePointerEnter,onPointerLeave:handlePointerLeave});});return Wrapped;}\nexport const __FramerMetadata__ = {\"exports\":{\"withRandomColor\":{\"type\":\"reactHoc\",\"name\":\"withRandomColor\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withHover\":{\"type\":\"reactHoc\",\"name\":\"withHover\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withBlobHoverSpeed\":{\"type\":\"reactHoc\",\"name\":\"withBlobHoverSpeed\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withRandomDrift\":{\"type\":\"reactHoc\",\"name\":\"withRandomDrift\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withRotate\":{\"type\":\"reactHoc\",\"name\":\"withRotate\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Examples.map"],"mappings":"mTAA8E,SAAgB,EAAY,EAAO,CACjH,IAAM,EAAU,EAAK,CAAC,MAAM,OAAO,OAAO,CAAC,GAAG,EAAO,CAAC,CAAC,CAAC,CAClD,EAAa,GAAU,CAC1B,OAAO,GAAW,aAAY,EAAS,EAAS,EAAU,MAAM,EAAE,EAAU,MAAM,OAAO,OAAO,CAAC,GAAG,EAAU,MAAM,GAAG,EAAS,CAAC,EAChI,EAAW,OAAO,GAAS,SAAS,OAAO,OAAO,CAAC,GAAG,EAAO,CAAC,CAAC,EAC7D,EAAa,IAAI,IACjB,EAAc,GAAU,CAC3B,OAAO,GAAW,aAAY,EAAS,EAAS,EAAW,EAAE,EAAW,OAAO,GAAW,SAAS,OAAO,OAAO,CAAC,GAAG,EAAW,GAAG,EAAS,CAAC,CAAC,EACjJ,EAAa,QAAQ,GAAQ,EAAO,EAAW,CAAC,EAChD,SAASA,GAAU,CACnB,GAAK,CAAC,EAAM,GAAUC,EAAS,EAAW,CAK1C,OAHA,OACA,EAAa,IAAI,EAAS,KAAW,EAAa,OAAO,EAAS,EAAG,EAAE,CAAC,CACrE,GAAgB,GAAG,IAAM,GAAgB,CAAO,CAAC,EAAU,MAAM,EAAa,EAC3E,CAAC,EAAM,EAAc,CAAG,OAAOD,mBAfC,IAAwC,iCEAjE,EAAgB,CACzB,QAAS,OACT,eAAgB,SAChB,WAAY,SACf,CAWG,CADA,GAAG,EACO,qBEd+kB,SAAgB,EAAgB,EAAU,CAAC,IAAM,EAAqB,EAAW,SAAiB,EAAM,EAAa,CAAC,GAAK,CAAC,QAAM,IAAI,QAAM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