{"version":3,"file":"CaseStudyEmbed.D3-xg_9g.mjs","names":["useRef","useState","useCallback"],"sources":["https:/framerusercontent.com/modules/RL53zcqI3lJOlZLeuNuZ/JahifYtFksF1NmfKZ9IU/CaseStudyEmbed.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect,useRef,useCallback}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * CaseStudyEmbed  —  v2 (cold-load safe)\n * ----------------------------------------------------------------------------\n * An auto-hugging HTML embed for Framer.\n *\n * WHY v2: on a cold load (URL typed into a search bar, tapped from a LinkedIn\n * post, hard refresh) the iframe frequently finishes loading and posts its\n * height BEFORE React has hydrated and attached the \"message\" listener. That\n * single message is lost, the frame stays at Min height, and everything below\n * the header is clipped. Client-side navigation inside Framer hid the bug,\n * because React was already hydrated before the iframe loaded.\n *\n * The fix is a two-way handshake instead of a one-shot broadcast:\n *   • the parent asks   -> postMessage({type:\"request-embed-size\"}) into the frame\n *     on load, and repeatedly for the first few seconds\n *   • the document answers -> postMessage({type:\"embed-size\", height}) up to the parent\n * Either side can be late; the height still lands.\n *\n * Also: `scrolling` is left at its default so that if a message is ever lost,\n * the content is still reachable by scrolling instead of being cut off.\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */export default function CaseStudyEmbed(props){const{sourceType,url,html,minHeight,background,title}=props;const iframeRef=useRef(null);const[height,setHeight]=useState(minHeight);// Ask the embedded document for its height.\nconst requestSize=useCallback(()=>{const win=iframeRef.current?.contentWindow;if(!win)return;try{win.postMessage({type:\"request-embed-size\"},\"*\");}catch(e){}},[]);useEffect(()=>{function onMessage(event){// Only trust messages coming from our own frame.\nif(iframeRef.current&&event.source&&event.source!==iframeRef.current.contentWindow){return;}const data=event.data;// 1) Native message from the Framer-ready document\nif(data&&data.type===\"embed-size\"&&typeof data.height===\"number\"){setHeight(Math.max(data.height,minHeight));return;}// 2) iFrameSizer-style string fallback (\"[iFrameSizer]height:1234\")\nif(typeof data===\"string\"&&data.indexOf(\"[iFrameSizer]height:\")===0){const h=parseInt(data.split(\":\")[1],10);if(!isNaN(h))setHeight(Math.max(h,minHeight));}}window.addEventListener(\"message\",onMessage);// Poll for the height until we get one: covers the case where the frame\n// loaded and broadcast before this listener existed. Dense for 8s, then\n// a slow keepalive for late web-font / image reflows.\nconst start=Date.now();const poll=window.setInterval(()=>{requestSize();if(Date.now()-start>8e3){window.clearInterval(poll);const slow=window.setInterval(requestSize,2e3);window.setTimeout(()=>window.clearInterval(slow),3e4);}},300);requestSize();// Viewport changes (breakpoint switches, orientation) re-hug too.\nwindow.addEventListener(\"resize\",requestSize);return()=>{window.removeEventListener(\"message\",onMessage);window.removeEventListener(\"resize\",requestSize);window.clearInterval(poll);};},[minHeight,requestSize,url,html,sourceType]);const iframeStyle={display:\"block\",width:\"100%\",height:height,border:\"none\",background:background};const common={ref:iframeRef,style:iframeStyle,title:title,loading:\"eager\",onLoad:requestSize};return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:height,background:background},children:sourceType===\"url\"?/*#__PURE__*/_jsx(\"iframe\",{...common,src:url}):/*#__PURE__*/_jsx(\"iframe\",{...common,srcDoc:html})});}CaseStudyEmbed.defaultProps={sourceType:\"url\",url:\"\",html:\"<!doctype html><html><body style='background:#000;color:#fff'>Paste the full Framer-ready HTML here.</body></html>\",minHeight:600,background:\"#000000\",title:\"Untitled embed\"};addPropertyControls(CaseStudyEmbed,{sourceType:{type:ControlType.Enum,title:\"Source\",options:[\"url\",\"code\"],optionTitles:[\"URL\",\"Code\"],displaySegmentedControl:true},url:{type:ControlType.String,title:\"URL\",hidden:props=>props.sourceType!==\"url\"},html:{type:ControlType.String,title:\"HTML\",displayTextArea:true,hidden:props=>props.sourceType!==\"code\"},minHeight:{type:ControlType.Number,title:\"Min height\",min:0,max:2e4,step:50,unit:\"px\"},background:{type:ControlType.Color,title:\"Background\",defaultValue:\"#000000\"},title:{type:ControlType.String,title:\"A11y title\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CaseStudyEmbed\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CaseStudyEmbed.map"],"mappings":"6MAuBG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,aAAW,MAAI,OAAK,YAAU,aAAW,SAAO,EAAY,EAAUA,EAAO,IAAI,EAAO,CAAC,EAAO,GAAWC,EAAS,CAAS,EAC9K,EAAYC,MAAgB,CAAC,IAAM,EAAI,EAAU,SAAS,cAAkB,KAAW,GAAG,CAAC,EAAI,YAAY,CAAC,KAAK,oBAAoB,EAAE,GAAG,CAAE,MAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAc,CAAC,SAAS,EAAU,EAAM,CAC3M,GAAG,EAAU,SAAS,EAAM,QAAQ,EAAM,SAAS,EAAU,QAAQ,cAAe,OAAQ,IAAM,EAAK,EAAM,KAC7G,GAAG,GAAM,EAAK,OAAO,cAAc,OAAO,EAAK,QAAS,SAAS,CAAC,EAAU,KAAK,IAAI,EAAK,OAAO,CAAS,CAAC,EAAE,MAAO,CACpH,GAAG,OAAO,GAAO,UAAU,EAAK,QAAQ,sBAAsB,IAAI,EAAE,CAAC,IAAM,EAAE,SAAS,EAAK,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,EAAM,MAAM,CAAC,GAAE,EAAU,KAAK,IAAI,EAAE,CAAS,CAAC,CAAE,CAAC,CAAC,EAAO,iBAAiB,UAAU,CAAS,EAGxM,IAAM,EAAM,KAAK,IAAI,EAAQ,EAAK,EAAO,gBAAgB,CAAe,GAAd,EAAY,EAAK,KAAK,IAAI,EAAE,EAAM,IAAI,CAAC,EAAO,cAAc,CAAI,EAAE,IAAM,EAAK,EAAO,YAAY,EAAY,GAAG,EAAE,EAAO,eAAe,EAA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