{"version":3,"file":"FitHeadline.DaOlMaSn.mjs","names":["useRef","useCallback"],"sources":["https:/framerusercontent.com/modules/P2ClkBMPWqQFzDUbtG9c/UwXNOqNp2xJnvdLETCo5/FitHeadline.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useCallback,useEffect,useRef}from\"react\";// Width-aware headline sizing for the contact page hero.\n//\n// The shared `responsiveHeading` override (Text_size.tsx) sizes purely from\n// viewport width, effectively min(0.13 * innerWidth, 250), and only shrinks when\n// the block grows past 80% of viewport HEIGHT. It never checks whether a single\n// word still fits across the box, which is fine for the shorter Careers, Results\n// and Insights headlines but splits \"CONVERSATION\" mid-word here.\n//\n// This variant sizes so the longest word always fits, capping at the design's\n// 150px.\n//\n// Measurement uses a Range over the real text nodes rather than a probe element\n// carrying copied styles. That matters: the runs in this headline are bold, so\n// the painted glyphs are weight 700 while the element's own computed weight is\n// 400. PP Formula is 7.113em per \"conversation\" at 400 and 7.283em at 700 — only\n// 2.4% apart, but at a 390px viewport that is the difference between 48.4px and\n// 47.3px, and the word overflowed by 6px and wrapped. A Range measures whatever\n// is actually rendered, including weight, tracking and text-transform.\n//\n// Measurement happens with wrapping switched off. Framer applies\n// `word-break: break-word` to text, so at a size that does not fit, the word\n// actually breaks and a Range then reports the union of its line boxes — roughly\n// the container width — instead of the word's true width. Feeding that back in\n// produces a ratio of about 1 and the headline stays enormous. Forcing nowrap for\n// the duration of the measurement is what makes the number mean anything.\n//\n// A verification pass then steps the size down until the longest word genuinely\n// fits, so any residual measurement error self-corrects rather than shipping as\n// a broken word.\n//\n// It deliberately does NOT reproduce the 100vw breakout wrapper that\n// `responsiveHeading` adds: on this page the headline should sit on the section's\n// own 22px margin and inherit the site-wide 1920px cap.\nconst MAX_PX=150;const MIN_PX=18;const SAFETY=.99;const MAX_HEIGHT_RATIO=.85;export function withFitHeadline(Component){return /*#__PURE__*/forwardRef((props,forwardedRef)=>{const host=useRef(null);// Widest single word as actually rendered, in px at the current size.\n// Lines can rewrap; a word cannot, so this is the binding constraint.\nconst widestWordPx=useCallback(function(el){if(typeof document===\"undefined\")return 0;const walker=document.createTreeWalker(el,NodeFilter.SHOW_TEXT,null);const range=document.createRange();let widest=0;let node=walker.nextNode();while(node){const text=node.nodeValue||\"\";let i=0;while(i<text.length){while(i<text.length&&/\\s/.test(text.charAt(i)))i++;const start=i;while(i<text.length&&!/\\s/.test(text.charAt(i)))i++;if(i>start){try{range.setStart(node,start);range.setEnd(node,i);const w=range.getBoundingClientRect().width;if(w>widest)widest=w;}catch(err){// Ignore any node that cannot be ranged.\n}}}node=walker.nextNode();}return widest;},[]);// Framer's word-break would let a too-large word split, and a Range over a\n// split word measures its line-box union rather than its real width. Wrapping\n// is disabled for the measurement so the number reflects one unbroken line.\nconst measureWidest=useCallback(function(el){const style=el.style;const prevWhiteSpace=style.getPropertyValue(\"white-space\");const prevWordBreak=style.getPropertyValue(\"word-break\");const prevOverflowWrap=style.getPropertyValue(\"overflow-wrap\");style.setProperty(\"white-space\",\"nowrap\",\"important\");style.setProperty(\"word-break\",\"keep-all\",\"important\");style.setProperty(\"overflow-wrap\",\"normal\",\"important\");const width=widestWordPx(el);if(prevWhiteSpace)style.setProperty(\"white-space\",prevWhiteSpace);else style.removeProperty(\"white-space\");if(prevWordBreak)style.setProperty(\"word-break\",prevWordBreak);else style.removeProperty(\"word-break\");if(prevOverflowWrap)style.setProperty(\"overflow-wrap\",prevOverflowWrap);else style.removeProperty(\"overflow-wrap\");return width;},[widestWordPx]);const fit=useCallback(()=>{if(typeof window===\"undefined\")return;const root=host.current;if(!root)return;const el=root.querySelector(\"h1, h2, h3, p, [class*='framer-text']\");if(!el)return;const avail=el.clientWidth||root.clientWidth;if(!avail)return;// Arrow rather than a function declaration: TypeScript does not carry the\n// `if (!el) return` narrowing into a hoisted declaration.\nconst setSize=px=>{el.style.setProperty(\"--framer-font-size\",Math.round(px)+\"px\",\"important\");el.style.setProperty(\"--framer-line-height\",\"90%\",\"important\");};// Measure at a known size, then scale from the ratio.\nsetSize(MAX_PX);const atMax=measureWidest(el);if(!atMax)return;let size=Math.min(MAX_PX,avail*SAFETY*MAX_PX/atMax);if(size<MIN_PX)size=MIN_PX;setSize(size);// Verify against what actually rendered and step down if needed.\nlet guard=0;while(measureWidest(el)>avail&&size>MIN_PX&&guard<60){size-=1;setSize(size);guard++;}// Keep the same height courtesy as the shared override, so a very\n// short viewport cannot let the headline swallow the fold.\nconst maxH=window.innerHeight*MAX_HEIGHT_RATIO;guard=0;while(root.scrollHeight>maxH&&size>MIN_PX&&guard<60){size-=2;setSize(size);guard++;}},[measureWidest]);useEffect(()=>{if(typeof window===\"undefined\")return;fit();let raf=0;const onResize=()=>{cancelAnimationFrame(raf);raf=requestAnimationFrame(fit);};window.addEventListener(\"resize\",onResize);let cancelled=false;if(document.fonts&&document.fonts.ready){document.fonts.ready.then(function(){if(!cancelled)fit();});}return()=>{cancelled=true;cancelAnimationFrame(raf);window.removeEventListener(\"resize\",onResize);};},[fit]);return /*#__PURE__*/_jsx(\"div\",{ref:host,style:{width:\"100%\"},children:/*#__PURE__*/_jsx(Component,{ref:forwardedRef,...props})});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withFitHeadline\":{\"type\":\"reactHoc\",\"name\":\"withFitHeadline\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FitHeadline.map"],"mappings":"qJAiC6E,SAAgB,EAAgB,EAAU,CAAC,OAAoB,GAAY,EAAM,IAAe,CAAC,IAAM,EAAKA,EAAO,IAAI,EAE9L,EAAaC,EAAY,SAAS,EAAG,CAAC,GAAG,OAAO,SAAW,IAAY,MAAO,GAAE,IAAM,EAAO,SAAS,iBAAiB,EAAG,WAAW,UAAU,IAAI,EAAQ,EAAM,SAAS,YAAY,EAAM,EAAO,EAAM,EAAK,EAAO,SAAS,EAAE,KAAM,GAAK,CAAC,IAAM,EAAK,EAAK,WAAW,GAAO,EAAE,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