{"version":3,"file":"TextMobileViewportScale.CPpujncK.mjs","names":["useState","useCallback","useRef","useMemo"],"sources":["https:/framerusercontent.com/modules/LfM2yRgZm9ihpD4tEAkT/j5hk3iUtfKFniJWHCSen/TextMobileViewportScale.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,startTransition,useCallback,useEffect,useMemo,useRef,useState}from\"react\";const MOBILE_BASE_WIDTH=375;const TABLET_BREAKPOINT=800;function getViewportWidth(){if(typeof window===\"undefined\")return 0;return window.innerWidth;}function useMobileScale(){const[viewportWidth,setViewportWidth]=useState(0);const updateViewportWidth=useCallback(()=>{if(typeof window!==\"undefined\"){const nextWidth=window.innerWidth;startTransition(()=>{setViewportWidth(prev=>prev===nextWidth?prev:nextWidth);});}},[]);useEffect(()=>{if(typeof window===\"undefined\")return;startTransition(()=>{setViewportWidth(getViewportWidth());});window.addEventListener(\"resize\",updateViewportWidth);return()=>{window.removeEventListener(\"resize\",updateViewportWidth);};},[updateViewportWidth]);const safeViewportWidth=viewportWidth>0?viewportWidth:MOBILE_BASE_WIDTH;const isMobile=safeViewportWidth<TABLET_BREAKPOINT;const scale=isMobile?safeViewportWidth/MOBILE_BASE_WIDTH:1;return{isMobile,scale};}// Scales text proportionally to the real phone viewport width (below 800px)\n// via CSS zoom, without forcing a fixed reference width on the text box\n// itself — the text keeps whatever width its own parent layout already\n// gives it (padding, siblings, maxWidth, etc.), only its rendered size scales.\nexport function withMobileTextViewportScale(Component){return /*#__PURE__*/forwardRef(function WithMobileTextViewportScale(props,ref){const{isMobile,scale}=useMobileScale();if(!isMobile){return /*#__PURE__*/_jsx(Component,{ref:ref,...props});}return /*#__PURE__*/_jsx(\"div\",{style:{zoom:scale},children:/*#__PURE__*/_jsx(Component,{ref:ref,...props})});});}// Scales a full-width mobile bar (e.g. a footer) proportionally to the real\n// phone viewport width (below 800px), matching the technique already used\n// for the mobile header/page canvas: render at a fixed 375px reference\n// width, then zoom to the real viewport, measuring natural height so the\n// surrounding vertical stack reserves the correct (scaled) space for it.\nexport function withMobileFooterViewportScale(Component){return /*#__PURE__*/forwardRef(function WithMobileFooterViewportScale(props,ref){const measuredRef=useRef(null);const[naturalHeight,setNaturalHeight]=useState(null);const{isMobile,scale}=useMobileScale();const measureHeight=useCallback(()=>{const nextHeight=measuredRef.current?.offsetHeight??null;startTransition(()=>{setNaturalHeight(prev=>prev===nextHeight?prev:nextHeight);});},[]);useEffect(()=>{if(typeof window===\"undefined\"||!isMobile)return;measureHeight();let observer=null;if(typeof ResizeObserver!==\"undefined\"&&measuredRef.current){observer=new ResizeObserver(()=>{measureHeight();});observer.observe(measuredRef.current);}return()=>{observer?.disconnect();};},[isMobile,measureHeight]);const scaledHeight=useMemo(()=>{if(!isMobile||naturalHeight===null)return undefined;return naturalHeight*scale;},[isMobile,naturalHeight,scale]);if(!isMobile){return /*#__PURE__*/_jsx(Component,{ref:ref,...props});}return /*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",width:\"100%\",height:scaledHeight,overflow:\"hidden\"},children:/*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",width:MOBILE_BASE_WIDTH,zoom:scale},children:/*#__PURE__*/_jsx(\"div\",{ref:measuredRef,style:{position:\"relative\"},children:/*#__PURE__*/_jsx(Component,{ref:ref,...props,style:{...props.style,width:MOBILE_BASE_WIDTH,maxWidth:MOBILE_BASE_WIDTH}})})})});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withMobileFooterViewportScale\":{\"type\":\"reactHoc\",\"name\":\"withMobileFooterViewportScale\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withMobileTextViewportScale\":{\"type\":\"reactHoc\",\"name\":\"withMobileTextViewportScale\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextMobileViewportScale.map"],"mappings":"qKAA+L,SAAS,GAAkB,CAAyC,OAA9B,IAAS,OAAmB,EAAS,EAAO,UAAW,CAAC,SAAS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