{"version":3,"file":"TrendsEmbed.ViILbQR9.mjs","names":["useRef","useState","useMemo","__esmMin","pe","init_npm_react_18_3_1","window","_e","c","init_jsx_runtime","ce","de","init_ssg_sandbox_shims","addPropertyControls","init_framer_BL9pqxmF","ControlType","cleanProperties","out","raw","key","value","MAX_PROPERTIES","EVENT_NAME","MAX_STRING","withEmbedFlag","u","url","TrendsEmbed","props","frameRef","height","setHeight","minHeight","origin","src","scrollToFrameOffset","frame","frameTop","offset","scrollOffset","smooth","onMessage","event","data","HEIGHT_MESSAGE","NAVIGATE_MESSAGE","SCROLL_TO_MESSAGE","TRACK_MESSAGE","analytics","site","init_TrendsEmbed"],"sources":["https:/framerusercontent.com/modules/sCeg62STnjz0roQEBC6N/XAGm4RElvyYYY0gCYW31/TrendsEmbed.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useMemo,useRef,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Embeds one page of a Bigdata Trends site (e.g. https://rare-earth-trends.fly.dev)\n * on bigdata.com. One Framer page per app page: the app links between pages with\n * target=\"_top\", so the visitor never navigates inside the frame and every view\n * is a normal bigdata.com page view.\n *\n * The app talks to this component with postMessage:\n *   bigdata-trends:height     { height }      -> resize the frame, no inner scrollbar\n *   bigdata-trends:navigate                   -> bring the top of the frame into view\n *   bigdata-trends:scroll-to  { top, smooth } -> scroll the page to an anchor in the app\n *   bigdata-trends:track      { event, properties } -> record the app's custom event with\n *                                                     bigdata.com's Customer.io tracker\n * Only messages from the URL's origin AND from this exact frame are trusted.\n *\n * Tracked events go through the page's own tracker, so they share the visitor's\n * anonymous ID and consent. If analytics was rejected the tracker never loads and\n * the queued call is never sent.\n *\n * `?embed=1` is appended so the app can drop its own header, footer, cookie\n * banner and tracking on first render. bigdata.com's own consent and tracking\n * cover the page.\n */const HEIGHT_MESSAGE=\"bigdata-trends:height\";const NAVIGATE_MESSAGE=\"bigdata-trends:navigate\";const SCROLL_TO_MESSAGE=\"bigdata-trends:scroll-to\";const TRACK_MESSAGE=\"bigdata-trends:track\";const EVENT_NAME=/^[a-z][a-z0-9_]{0,63}$/;const MAX_PROPERTIES=20;const MAX_STRING=200;// Keep only flat, primitive properties: the frame is trusted by origin, but the\n// payload still lands in Mixpanel, so it stays small and predictable.\nfunction cleanProperties(raw){const out={};if(!raw||typeof raw!==\"object\")return out;for(const[key,value]of Object.entries(raw).slice(0,MAX_PROPERTIES)){if(!EVENT_NAME.test(key))continue;if(typeof value===\"string\")out[key]=value.slice(0,MAX_STRING);else if(typeof value===\"number\"&&Number.isFinite(value))out[key]=value;else if(typeof value===\"boolean\"||value===null)out[key]=value;}return out;}function withEmbedFlag(url){try{const u=new URL(url);u.searchParams.set(\"embed\",\"1\");return u.toString();}catch{return url;}}/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight auto\n */export default function TrendsEmbed(props){const{url,title,site,minHeight,scrollOffset}=props;const frameRef=useRef(null);const[height,setHeight]=useState(minHeight);const origin=useMemo(()=>{try{return new URL(url).origin;}catch{return\"\";}},[url]);const src=useMemo(()=>withEmbedFlag(url),[url]);useEffect(()=>{function scrollToFrameOffset(offset,smooth){const frame=frameRef.current;if(!frame)return;const frameTop=frame.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:Math.max(0,frameTop+offset-scrollOffset),behavior:smooth?\"smooth\":\"auto\"});}function onMessage(event){const frame=frameRef.current;if(!frame||!origin)return;if(event.origin!==origin)return;if(event.source!==frame.contentWindow)return;const data=event.data;if(!data||typeof data!==\"object\")return;if(data.type===HEIGHT_MESSAGE&&typeof data.height===\"number\"){setHeight(Math.max(minHeight,Math.ceil(data.height)));}else if(data.type===NAVIGATE_MESSAGE){// Only scroll up when the top of the frame is out of view.\nif(frame.getBoundingClientRect().top<scrollOffset){scrollToFrameOffset(0,true);}}else if(data.type===SCROLL_TO_MESSAGE&&typeof data.top===\"number\"){scrollToFrameOffset(data.top,data.smooth!==false);}else if(data.type===TRACK_MESSAGE&&typeof data.event===\"string\"){if(!EVENT_NAME.test(data.event))return;const analytics=window.cioanalytics;if(!analytics||typeof analytics.track!==\"function\")return;analytics.track(data.event,{...cleanProperties(data.properties),site,page_path:window.location.pathname});}}window.addEventListener(\"message\",onMessage);return()=>window.removeEventListener(\"message\",onMessage);},[origin,site,minHeight,scrollOffset]);return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height,overflow:\"hidden\"},children:/*#__PURE__*/_jsx(\"iframe\",{ref:frameRef,src:src,title:title,scrolling:\"no\",style:{display:\"block\",width:\"100%\",height:\"100%\",border:0,overflow:\"hidden\"}})});}TrendsEmbed.defaultProps={url:\"https://rare-earth-trends.fly.dev/\",title:\"Rare Earth Trends\",site:\"rare-earth-trends\",minHeight:800,scrollOffset:80};addPropertyControls(TrendsEmbed,{url:{type:ControlType.String,title:\"URL\",defaultValue:\"https://rare-earth-trends.fly.dev/\"},title:{type:ControlType.String,title:\"Title\",defaultValue:\"Rare Earth Trends\"},site:{type:ControlType.String,title:\"Site\",defaultValue:\"rare-earth-trends\",description:\"Stamped as `site` on every event the app sends up.\"},minHeight:{type:ControlType.Number,title:\"Min height\",defaultValue:800,min:200,max:3e3,step:50,unit:\"px\"},scrollOffset:{type:ControlType.Number,title:\"Top offset\",defaultValue:80,min:0,max:300,unit:\"px\",description:\"Height of the fixed site nav, so scrolled-to content is not hidden under it.\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TrendsEmbed\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TrendsEmbed.map"],"mappings":"A,6MAuBA,SAASgB,EAAgB,EAAI,CAAC,IAAMC,EAAI,CAAC,EAAE,GAAG,CAACC,GAAK,OAAOA,GAAM,SAAS,OAAOD,EAAI,IAAI,GAAK,CAACE,EAAIC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