{"version":3,"file":"RebateCalculator.ClS5_2Dt.mjs","names":["useState","useRef","useMemo","useCallback"],"sources":["https:/framerusercontent.com/modules/6JlQSHln3TLWL72clyTl/tjmD8dR8Fr2flPX8KBbS/RebateCalculator.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{startTransition,useCallback,useEffect,useMemo,useRef,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";// User request: preload purchase price as a real value (not placeholder), show an immediate computed result on load without requiring a click, and keep editable initial price/result/CTA controls while preserving style.\n/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function RebateCalculator(props){const{examplePurchasePrice,resultLabel,ctaLabel,ctaHref,confirmationText,showCTA,$control__examplePrice,$control__resultLabel,$control__cTALabel,$control__cTAHref,inputId,calculatorAttr,trackingEnabled,$control__inputId,$control__calculatorAttr,$control__trackingEnabled}=props;const resolvedExamplePrice=Number($control__examplePrice??examplePurchasePrice)||3e6;const resolvedResultLabel=$control__resultLabel??resultLabel??\"Estimated return at closing:\";const resolvedCtaLabel=$control__cTALabel??ctaLabel??\"TALK TO A PARTNER →\";const resolvedCtaHref=$control__cTAHref??ctaHref??\"#getintouch\";const resolvedConfirmationText=confirmationText??\"Your exact figure, in writing, before you close.\";const resolvedShowCTA=showCTA??true;const resolvedInputId=($control__inputId??inputId??\"\").trim();const resolvedCalculatorAttr=($control__calculatorAttr??calculatorAttr??\"\").trim();const resolvedTrackingEnabled=$control__trackingEnabled??trackingEnabled??false;const inputElementId=resolvedInputId||\"return-calculator-price\";const[price,setPrice]=useState(()=>String(Math.max(0,resolvedExamplePrice)));const debounceTimerRef=useRef(null);const trackedValuesRef=useRef(new Set);const initialMountedPriceRef=useRef(String(Math.max(0,resolvedExamplePrice)));// Formats input as $1,000, $10,000, etc.\nconst formatCurrencyInput=value=>{const numericValue=value.replace(/[^\\d]/g,\"\");if(!numericValue)return\"\";return new Intl.NumberFormat(\"en-US\",{style:\"currency\",currency:\"USD\",maximumFractionDigits:0}).format(Number(numericValue));};// Formats final output (NO decimals)\nconst formatCurrency=value=>{return new Intl.NumberFormat(\"en-US\",{style:\"currency\",currency:\"USD\",maximumFractionDigits:0}).format(value);};useEffect(()=>{startTransition(()=>{setPrice(String(Math.max(0,resolvedExamplePrice)));});},[resolvedExamplePrice]);const numericPrice=useMemo(()=>Number(price||0),[price]);const rebate=useMemo(()=>Math.max(0,numericPrice)*.015,[numericPrice]);const interpolatedResultLabel=useMemo(()=>resolvedResultLabel.includes(\"{price}\")?resolvedResultLabel.replace(\"{price}\",formatCurrency(numericPrice)):resolvedResultLabel,[resolvedResultLabel,numericPrice]);const hasValidPrice=useMemo(()=>numericPrice>0,[numericPrice]);const inputValue=useMemo(()=>formatCurrencyInput(price),[price]);const estimateState=useMemo(()=>{if(price.trim()===\"\")return\"empty\";if(!Number.isFinite(numericPrice)||numericPrice<=0)return\"invalid\";return\"complete\";},[price,numericPrice]);const trackCompletedEstimate=useCallback(rawValue=>{if(!resolvedTrackingEnabled)return;const normalizedValue=rawValue.replace(/[^\\d]/g,\"\");if(!normalizedValue)return;if(normalizedValue===initialMountedPriceRef.current)return;if(trackedValuesRef.current.has(normalizedValue))return;const numericValue=Number(normalizedValue);if(!Number.isFinite(numericValue)||numericValue<=0)return;const computedBand=numericValue<1e6?\"under_1m\":numericValue<2e6?\"1m_to_2m\":numericValue<4e6?\"2m_to_4m\":numericValue<6e6?\"4m_to_6m\":\"6m_plus\";if(typeof window!==\"undefined\"){window.dataLayer=window.dataLayer||[];window.dataLayer.push({event:\"return_estimator_complete\",calculator_location:\"page_calculator\",price_band:computedBand,amount_changed:\"yes\"});trackedValuesRef.current.add(normalizedValue);}},[resolvedTrackingEnabled]);useEffect(()=>{return()=>{if(debounceTimerRef.current!==null){if(typeof window!==\"undefined\"){window.clearTimeout(debounceTimerRef.current);}debounceTimerRef.current=null;}};},[]);return /*#__PURE__*/_jsxs(\"div\",{\"data-track-component\":\"return-estimator\",\"data-estimate-state\":estimateState,\"data-brn-calculator\":resolvedCalculatorAttr!==\"\"?resolvedCalculatorAttr:undefined,style:{position:\"relative\",padding:0,borderRadius:0,width:\"100%\",fontFamily:\"Inter, sans-serif\"},children:[/*#__PURE__*/_jsx(\"style\",{dangerouslySetInnerHTML:{__html:`\n/* Keep the service-page amount inside the content margins on narrow phones. */\n@media (max-width: 359px) {\n    [data-framer-name=\"rebate\"] [data-track-component=\"return-estimator\"] [data-track=\"calculator-result\"] {\n        font-size: clamp(2rem, 16vw, 3.5rem) !important;\n    }\n}\n/* Keep blog embeds within their article at every viewport width. */\narticle div:has([data-track-component=\"return-estimator\"]),\narticle [data-track-component=\"return-estimator\"] {\n    min-width: 0 !important;\n    max-width: 100% !important;\n}\narticle [data-brn-estimator-note] { display: none; }\narticle div:has(> div > [data-track-component=\"return-estimator\"]) a[href$=\"/contact\"] p { text-transform: none !important; white-space: nowrap !important; }\narticle div:has(> div > [data-track-component=\"return-estimator\"]) a[href$=\"/contact\"] [data-framer-name=\"Arrow\"] { display: none !important; }\narticle div:has(> div > [data-track-component=\"return-estimator\"]) a[href$=\"/contact\"] [data-framer-name=\"button\"] { min-height: 44px; }\narticle [data-track-component=\"return-estimator\"] input {\n    min-width: 0;\n    max-width: 100%;\n    min-height: 48px;\n    font-size: 16px !important;\n}\n@media (max-width: 809px) {\n    article div:has([data-track-component=\"return-estimator\"]) {\n        width: 100% !important;\n    }\n    article div:has(> div > [data-track-component=\"return-estimator\"]) {\n        padding: 32px 20px !important;\n        gap: 20px !important;\n        height: auto !important;\n        box-sizing: border-box;\n    }\n    article div:has(> div > [data-track-component=\"return-estimator\"]) :is(div, p, h2, a) {\n        min-width: 0 !important;\n        max-width: 100% !important;\n        flex-shrink: 1;\n        white-space: normal !important;\n    }\n    article div:has(> div > [data-track-component=\"return-estimator\"]) h2 {\n        font-size: 30px !important;\n        line-height: 1.15 !important;\n        white-space: normal !important;\n        overflow-wrap: break-word;\n    }\n    article div:has(> div > [data-track-component=\"return-estimator\"]) p {\n        font-size: 16px !important;\n        line-height: 1.5 !important;\n        letter-spacing: normal !important;\n        white-space: normal !important;\n        overflow-wrap: break-word;\n    }\n    article [data-track-component=\"return-estimator\"] label,\n    article [data-track-component=\"return-estimator\"] [role=\"status\"] > div:first-child {\n        font-size: 16px !important;\n        line-height: 1.4 !important;\n    }\n    article [data-track-component=\"return-estimator\"] [data-track=\"calculator-result\"] {\n        font-size: clamp(32px, 10vw, 56px) !important;\n        line-height: 1.1 !important;\n        overflow-wrap: anywhere;\n    }\n    article div:has(> div > [data-track-component=\"return-estimator\"]) p a { display: inline-block; }\n    article div:has(> div > [data-track-component=\"return-estimator\"]) a {\n        min-height: 44px;\n        max-width: 100%;\n        box-sizing: border-box;\n    }\n}\n`}}),/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",flexDirection:\"column\"},children:[/*#__PURE__*/_jsx(\"div\",{children:/*#__PURE__*/_jsx(\"label\",{htmlFor:inputElementId,style:{display:\"block\",marginBottom:10,opacity:1,fontSize:\"0.9rem\"},children:\"Expected purchase price:\"})}),/*#__PURE__*/_jsx(\"input\",{id:inputElementId,className:\"priceInput\",\"data-track\":\"calculator-input\",\"data-brn-calculator-input\":\"true\",type:\"text\",inputMode:\"numeric\",autoComplete:\"off\",value:inputValue,onChange:e=>{const raw=e.target.value.replace(/[^\\d]/g,\"\");startTransition(()=>{setPrice(raw);});if(!resolvedTrackingEnabled)return;if(debounceTimerRef.current!==null){if(typeof window!==\"undefined\"){window.clearTimeout(debounceTimerRef.current);}debounceTimerRef.current=null;}if(typeof window!==\"undefined\"){debounceTimerRef.current=window.setTimeout(()=>{trackCompletedEstimate(raw);debounceTimerRef.current=null;},800);}},onBlur:()=>{if(!resolvedTrackingEnabled)return;if(debounceTimerRef.current!==null){if(typeof window!==\"undefined\"){window.clearTimeout(debounceTimerRef.current);}debounceTimerRef.current=null;}trackCompletedEstimate(price);},style:{width:\"100%\",padding:\"10px 16px\",borderRadius:0,border:\"1px solid #1B140E\",backgroundColor:\"#FFFFFF\",marginBottom:30,fontSize:\"1.0rem\",boxSizing:\"border-box\"}}),/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",flexDirection:\"column\",gap:14},children:[/*#__PURE__*/_jsxs(\"div\",{\"aria-live\":\"polite\",role:\"status\",children:[/*#__PURE__*/_jsx(\"div\",{style:{fontSize:\"1.2rem\",color:\"#1B140E\",opacity:1,fontWeight:400,marginBottom:10},children:interpolatedResultLabel}),/*#__PURE__*/_jsx(\"div\",{id:\"return-calculator-result\",\"data-track\":\"calculator-result\",style:{fontSize:\"4.0rem\",fontWeight:700,letterSpacing:\"0em\",marginBottom:4,lineHeight:\"1em\"},children:hasValidPrice?formatCurrency(rebate):\"$0\"})]}),/*#__PURE__*/_jsx(\"div\",{\"data-brn-estimator-note\":\"true\",style:{fontSize:\"1rem\",fontStyle:\"italic\",color:\"#1B140E\",opacity:.9},children:resolvedConfirmationText}),resolvedShowCTA&&/*#__PURE__*/_jsx(\"a\",{href:resolvedCtaHref,rel:\"noopener noreferrer\",style:{width:\"fit-content\",padding:\"10px 16px\",borderRadius:0,border:\"none\",textTransform:\"uppercase\",letterSpacing:\"0.05em\",backgroundColor:\"#563635\",color:\"#FBFAF9\",fontSize:\"1.02rem\",fontWeight:600,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",textDecoration:\"none\",cursor:\"pointer\",marginTop:4},children:resolvedCtaLabel})]})]})]});}addPropertyControls(RebateCalculator,{examplePurchasePrice:{type:ControlType.Number,title:\"Example Price\",defaultValue:3e6,min:0,step:1e5},resultLabel:{type:ControlType.String,title:\"Result Label\",defaultValue:\"Estimated return at closing:\"},ctaLabel:{type:ControlType.String,title:\"CTA Label\",defaultValue:\"TALK TO A PARTNER →\"},ctaHref:{type:ControlType.String,title:\"CTA Href\",defaultValue:\"#getintouch\"},confirmationText:{type:ControlType.String,title:\"Confirmation\",defaultValue:\"Your exact figure, in writing, before you close.\"},showCTA:{type:ControlType.Boolean,title:\"Show CTA\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},inputId:{type:ControlType.String,title:\"Input ID\",defaultValue:\"\"},calculatorAttr:{type:ControlType.String,title:\"Calculator Attr\",defaultValue:\"\"},trackingEnabled:{type:ControlType.Boolean,title:\"Tracking\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"RebateCalculator\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./RebateCalculator.map"],"mappings":"kOAIG,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,uBAAqB,cAAY,WAAS,UAAQ,mBAAiB,UAAQ,yBAAuB,wBAAsB,qBAAmB,oBAAkB,UAAQ,iBAAe,kBAAgB,oBAAkB,2BAAyB,6BAA2B,EAAY,EAAqB,OAAO,GAAwB,CAAoB,GAAG,IAAU,EAAoB,GAAuB,GAAa,+BAAqC,EAAiB,GAAoB,GAAU,sBAA4B,EAAgB,GAAmB,GAAS,cAAoB,EAAyB,GAAkB,mDAAyD,EAAgB,GAAS,GAAW,GAAiB,GAAmB,GAAS,GAAA,CAAI,KAAK,EAAQ,GAAwB,GAA0B,GAAgB,GAAA,CAAI,KAAK,EAAQ,EAAwB,GAA2B,GAAiB,GAAY,EAAe,GAAiB,0BAA+B,CAAC,EAAM,GAAUA,MAAa,OAAO,KAAK,IAAI,EAAE,CAAoB,CAAC,CAAC,EAAQ,EAAiBC,EAAO,IAAI,EAAQ,EAAiBA,EAAO,IAAI,GAAG,EAAQ,EAAuBA,EAAO,OAAO,KAAK,IAAI,EAAE,CAAoB,CAAC,CAAC,EAC7wC,EAAoB,GAAO,CAAC,IAAM,EAAa,EAAM,QAAQ,SAAS,EAAE,EAA4B,OAAtB,EA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