{"version":3,"file":"AutoFitToWrapper.DGrWiJHQ.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/T0EFMBvmUdhPvMtc8epV/MpQl44kkKTb8zeSYx5lg/AutoFitToWrapper.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect,useRef,useState}from\"react\";export function withAutoFitToWrapper(Component){return /*#__PURE__*/forwardRef((props,forwardedRef)=>{const localRef=useRef(null);const[fitScale,setFitScale]=useState(1);useEffect(()=>{const element=localRef.current;if(!element)return;const wrapper=element.parentElement;if(!wrapper)return;// Empty breathing room around the composition\nconst MARGIN=10;const updateScale=()=>{// Original, unscaled size of the Figma composition\nconst baseWidth=element.offsetWidth;const baseHeight=element.offsetHeight;// Actual available space inside its wrapper\nconst availableWidth=Math.max(1,wrapper.clientWidth-MARGIN*2);const availableHeight=Math.max(1,wrapper.clientHeight-MARGIN*2);if(baseWidth<=0||baseHeight<=0)return;// Use whichever limit is reached first:\n// width OR height\nconst nextScale=Math.min(availableWidth/baseWidth,availableHeight/baseHeight);setFitScale(nextScale);};updateScale();const observer=new ResizeObserver(updateScale);observer.observe(wrapper);return()=>observer.disconnect();},[]);const setRefs=node=>{localRef.current=node;if(typeof forwardedRef===\"function\"){forwardedRef(node);}else if(forwardedRef){forwardedRef.current=node;}};const style={...props.style,scale:fitScale,transformOrigin:\"50% 50%\"};return /*#__PURE__*/_jsx(Component,{...props,ref:setRefs,style:style});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withAutoFitToWrapper\":{\"type\":\"reactHoc\",\"name\":\"withAutoFitToWrapper\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AutoFitToWrapper.map"],"mappings":"uIAAmG,SAAgB,EAAqB,EAAU,CAAC,OAAoB,GAAY,EAAM,IAAe,CAAC,IAAM,EAASA,EAAO,IAAI,EAAO,CAAC,EAAS,GAAaC,EAAS,CAAC,EAAE,MAAc,CAAC,IAAM,EAAQ,EAAS,QAAQ,GAAG,CAAC,EAAQ,OAAO,IAAM,EAAQ,EAAQ,cAAc,GAAG,CAAC,EAAQ,OAC9X,IAAsB,MAAgB,CACtC,IAAM,EAAU,EAAQ,YAAkB,EAAW,EAAQ,aACvD,EAAe,KAAK,IAAI,EAAE,EAAQ,YAAY,EAAQ,EAAQ,EAAgB,KAAK,IAAI,EAAE,EAAQ,aAAa,EAAQ,EAAE,GAAG,GAAW,GAAG,GAAY,EAAE,OAE7J,IAAM,EAAU,KAAK,IAAI,EAAe,EAAU,EAAgB,CAAU,EAAE,EAAY,CAAS,CAAE,EAAE,EAAY,EAAE,IAAM,EAAS,IAAI,eAAe,CAAW,EAA4B,OAA1B,EAAS,QAAQ,CAAO,MAAY,EAAS,WAAW,CAAE,EAAE,CAAC,CAAC,EAAE,IAAM,EAAQ,GAAM,CAAC,EAAS,QAAQ,EAAQ,OAAO,GAAe,WAAY,EAAa,CAAI,EAAW,IAAc,EAAa,QAAQ,EAAM,EAAQ,EAAM,CAAC,GAAG,EAAM,MAAM,MAAM,EAAS,gBAAgB,SAAS,EAAE,OAAoB,EAAK,EAAU,CAAC,GAAG,EAAM,IAAI,EAAc,OAAK,CAAC,CAAE,CAAC,CAAE,iBALje,IAAwD"}