{"version":3,"file":"API_Title_1.FSPMNoTt.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/o9J63C2Gfvp2SadOka5I/ZSBEWqji7d0vRNdANKWl/API_Title_1.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{ControlType,addPropertyControls}from\"framer\";import{useEffect,useState}from\"react\";// Add this custom hook at the top of your file\nfunction useWindowSize(){const[windowSize,setWindowSize]=useState({width:typeof window!==\"undefined\"?window.innerWidth:0,height:typeof window!==\"undefined\"?window.innerHeight:0});useEffect(()=>{function handleResize(){setWindowSize({width:window.innerWidth,height:window.innerHeight});}window.addEventListener(\"resize\",handleResize);return()=>window.removeEventListener(\"resize\",handleResize);},[]);return windowSize;}export default function API_Title(props){const[city,setCity]=useState(\"\");const[state,setState]=useState(\"\");const[savings,setSavings]=useState(null);const[loading,setLoading]=useState(true);const[error,setError]=useState(null);const[showPopup,setShowPopup]=useState(false);const[animatedSavings,setAnimatedSavings]=useState(0);const[intervalId,setIntervalId]=useState(null);const{width}=useWindowSize();const roundToNearestHundred=value=>{const remainder=value%100;return remainder>=50?Math.ceil(value/100)*100:Math.floor(value/100)*100;};const generateRandomNumber=()=>{return Math.floor(Math.random()*9e3)+1e3;};const startAnimation=()=>{const id=setInterval(()=>{setAnimatedSavings(generateRandomNumber());},100);setIntervalId(id);};const stopAnimation=finalValue=>{clearInterval(intervalId);setAnimatedSavings(finalValue);};// Responsive popup styles based on window width\nconst getPopupStyle=()=>{const baseStyle={position:\"absolute\",left:\"50%\",transform:\"translateX(-50%)\",backgroundColor:\"#09090B\",color:\"#fff\",padding:\"12px 8px\",borderRadius:\"10px\",whiteSpace:\"wrap\",boxShadow:\"0 2px 8px rgba(0, 0, 0, 0.15)\",zIndex:10,marginBottom:\"8px\",lineHeight:\"1.5em\",fontFamily:props.popupFontStyle.fontFamily,fontSize:props.popupFontStyle.fontSize,textAlign:props.popupFontStyle.textAlign,fontWeight:props.popupFontStyle.fontWeight};if(width<=480){// Mobile (small)\nreturn{...baseStyle,width:\"180px\",bottom:\"-250%\",fontSize:\"10px\"};}else if(width<=768){// Mobile\nreturn{...baseStyle,width:\"200px\",bottom:\"-250%\",fontSize:\"11px\"};}else if(width<=1024){// Tablet\nreturn{...baseStyle,width:\"220px\",bottom:\"-200%\"};}else{// Desktop\nreturn{...baseStyle,width:\"250px\",bottom:\"-175%\"};}};useEffect(()=>{const fetchLocationAndSavings=async()=>{try{setLoading(true);startAnimation();const[locationResponse,savingsResponse]=await Promise.all([fetch(\"https://ipapi.co/json/?key=NjLoegtgqZsZDVhXuStXToqId6EFztHnSedAFRxKhO4PBQKqCd\"),fetch(\"https://d10097iyq0q28w.cloudfront.net/realEstateSavings.json\")]);if(!locationResponse.ok||!savingsResponse.ok){throw new Error(`Failed to fetch data: ${locationResponse.status}, ${savingsResponse.status}`);}const[locationData,savingsData]=await Promise.all([locationResponse.json(),savingsResponse.json()]);setCity(locationData.city);setState(locationData.region_code);const stateSavings=savingsData.filter(item=>item.State===locationData.region_code);const citySavings=stateSavings.find(item=>item.City===locationData.city);const userSavings=citySavings?citySavings.Savings:stateSavings.length>0?stateSavings[0].Savings:4253;setSavings(userSavings);localStorage.setItem(\"userSavings\",JSON.stringify(userSavings));window.dispatchEvent(new Event(\"savingsUpdated\"));stopAnimation(userSavings);setLoading(false);}catch(err){console.error(\"Error:\",err);setError(`Failed to fetch data: ${err.message}`);setLoading(false);stopAnimation(0);}};fetchLocationAndSavings();},[]);return /*#__PURE__*/_jsx(\"div\",{style:containerStyle,children:loading?/*#__PURE__*/_jsxs(\"p\",{style:{fontFamily:props.fontStyle.fontFamily,fontSize:props.fontStyle.fontSize,textAlign:props.fontStyle.textAlign,fontWeight:props.fontStyle.fontWeight,color:props.textColor,lineHeight:\"1.4em\",overflow:\"visible\"},children:[props.prefixTitle,\" \",/*#__PURE__*/_jsxs(\"span\",{style:{color:props.savedColor},children:[\"$\",roundToNearestHundred(animatedSavings).toLocaleString()]}),\" \",props.suffixTitle]}):error?/*#__PURE__*/_jsx(\"p\",{}):/*#__PURE__*/_jsxs(\"p\",{style:{fontFamily:props.fontStyle.fontFamily,fontSize:props.fontStyle.fontSize,textAlign:props.fontStyle.textAlign,fontWeight:props.fontStyle.fontWeight,color:props.textColor,lineHeight:\"1.4em\",overflow:\"visible\"},children:[props.prefixTitle,\" \",/*#__PURE__*/_jsxs(\"span\",{style:{color:props.savedColor},children:[\"$\",roundToNearestHundred(savings).toLocaleString()]}),\" \",props.suffixTitle,/*#__PURE__*/_jsxs(\"span\",{style:buttonContainerStyle,children:[/*#__PURE__*/_jsx(\"button\",{style:buttonStyle,onMouseEnter:()=>setShowPopup(true),onMouseLeave:()=>setShowPopup(false),children:\"ⓘ\"}),showPopup&&/*#__PURE__*/_jsxs(\"span\",{style:getPopupStyle(),children:[\"Estimated savings when buying without a buyer's agent based on the average home price in \",city,\",\",\" \",state,\" and a seller contribution of 2.5%. Actual savings may vary based on purchase price and other factors.\"]})]})]})});}addPropertyControls(API_Title,{prefixTitle:{type:ControlType.String,defaultValue:\"Save\",placeholder:\"Prefix Title\",description:\"The title snippet that comes before the number\"},savedDollars:{type:ControlType.String,defaultValue:\"$9,500\",placeholder:\"Amount of money saved\",description:\"The saved amount in $.\"},suffixTitle:{type:ControlType.String,defaultValue:\"and stay in control of your home buying process\",placeholder:\"Suffix Title\",description:\"The title snippet that comes after the number\"},savedColor:{type:ControlType.Color,defaultValue:\"#F4AA69\",optional:true},textColor:{type:ControlType.Color,defaultValue:\"#000000\",optional:true},fontStyle:{type:ControlType.Font,defaulFontSize:\"42px\",displayFontSize:true,displayTextAlignment:true,displaySegmentedControl:true},popupFontStyle:{type:ControlType.Font,defaulFontSize:\"12px\",displayFontSize:true,displayTextAlignment:true,displaySegmentedControl:true}});const containerStyle={display:\"flex\",justifyContent:\"left\",alignItems:\"center\",overflow:\"visible\",padding:\"0px\",margin:\"0px\"};const buttonContainerStyle={position:\"relative\",display:\"inline-block\"};const buttonStyle={background:\"none\",border:\"none\",cursor:\"pointer\",fontSize:\"14px\",color:\"#fff\",padding:\"0\"};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"API_Title\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./API_Title_1.map"],"mappings":"uMACA,SAAS,GAAe,CAAC,GAAK,CAAC,EAAW,GAAeA,EAAS,CAAC,MAAa,IAAS,OAA8B,EAAlB,EAAO,WAAa,OAAc,IAAS,OAA+B,EAAnB,EAAO,YAAc,CAAC,CAA6N,OAA5N,MAAc,CAAC,SAAS,GAAc,CAAC,EAAc,CAAC,MAAM,EAAO,WAAW,OAAO,EAAO,YAAY,CAAC,CAAiD,OAA/C,EAAO,iBAAiB,SAAS,EAAa,KAAW,EAAO,oBAAoB,SAAS,EAAa,EAAG,EAAE,CAAC,CAAQ,EAAY,SAAwB,EAAU,EAAM,CAAC,GAAK,CAAC,EAAK,GAASA,EAAS,GAAG,CAAM,CAAC,EAAM,GAAUA,EAAS,GAAG,CAAM,CAAC,EAAQ,GAAYA,EAAS,KAAK,CAAM,CAAC,EAAQ,GAAYA,EAAS,GAAK,CAAM,CAAC,EAAM,GAAUA,EAAS,KAAK,CAAM,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAM,CAAC,EAAgB,GAAoBA,EAAS,EAAE,CAAM,CAAC,EAAW,GAAeA,EAAS,KAAK,CAAM,CAAC,SAAO,GAAe,CAAO,EAAsB,GAAwB,EAAM,KAAsB,GAAG,KAAK,KAAK,EAAM,IAAI,CAAC,IAAI,KAAK,MAAM,EAAM,IAAI,CAAC,IAAY,MAAiC,KAAK,MAAM,KAAK,QAAQ,CAAC,IAAI,CAAC,IAAY,MAAmB,CAA6E,EAAnE,gBAAgB,CAAC,EAAmB,GAAsB,CAAC,EAAG,IAAI,CAAkB,EAAS,EAAc,GAAY,CAAC,cAAc,EAAW,CAAC,EAAmB,EA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