1import{r as t,j as e}from"./index-j7I9Tmll.js";import{a as I,C as B,F as n,f as l,T as Y,P as k,o as M}from"./ui-BrtddqY1.js";/* empty css */function G(){const[o,b]=t.useState("10000000"),[i,j]=t.useState("20"),[c,v]=t.useState("7"),[u,g]=t.useState("8.5"),[h,N]=t.useState("20"),[m,w]=t.useState("25000"),[d,C]=t.useState("5"),[y,R]=t.useState("5"),[x,P]=t.useState("0.5"),[p,S]=t.useState("10"),[r,E]=t.useState("20"),{result:a,error:f}=t.useMemo(()=>I(()=>M({price:Number(o),downPct:Number(i),stampPct:Number(c),annualRatePct:Number(u),tenureYears:Number(h),monthlyRent:Number(m),rentGrowthPct:Number(d),appreciationPct:Number(y),maintenancePct:Number(x),investReturnPct:Number(p),years:Number(r)})),[o,i,c,u,h,m,d,y,x,p,r]);return e.jsxs(B,{slug:"rent-vs-buy-calculator",children:[e.jsxs("div",{className:"calc-layout",children:[e.jsxs("section",{className:"calc-inputs","aria-label":"Buying and renting",children:[e.jsx("h3",{className:"calc-group",children:"Buying"}),e.jsx(n,{label:"Property price",prefix:"â¹",value:o,onChange:b,min:1e6,max:1e8,step:1e5}),e.jsx(n,{label:"Down payment",suffix:"%",value:i,onChange:j,min:10,max:100}),e.jsx(n,{label:"Stamp duty & registration",suffix:"%",value:c,onChange:v,min:0,max:12,step:.5,slider:!1}),e.jsx(n,{label:"Home loan rate",suffix:"% p.a.",value:u,onChange:g,min:6,max:14,step:.05}),e.jsx(n,{label:"Loan tenure",suffix:"years",value:h,onChange:N,min:1,max:30,slider:!1}),e.jsx(n,{label:"Property price growth",suffix:"% a year",value:y,onChange:R,min:0,max:15,step:.5}),e.jsx(n,{label:"Maintenance & property tax",suffix:"% of value a year",value:x,onChange:P,min:0,max:3,step:.1,slider:!1}),e.jsx("h3",{className:"calc-group",children:"Renting"}),e.jsx(n,{label:"Rent for a similar home",prefix:"â¹",suffix:"a month",value:m,onChange:w,min:0,max:5e5,step:1e3}),e.jsx(n,{label:"Rent increase",suffix:"% a year",value:d,onChange:C,min:0,max:15,step:.5,slider:!1}),e.jsx(n,{label:"Return on money you invest instead",suffix:"% a year",value:p,onChange:S,min:0,max:15,step:.5}),e.jsx(n,{label:"Compare over",suffix:"years",value:r,onChange:E,min:1,max:30})]}),e.jsx("section",{className:"calc-results","aria-live":"polite",children:f?e.jsx("p",{className:"calc-error",children:f}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"calc-result-heading",children:[e.jsx("span",{children:"Buy or rent"}),e.jsx("strong",{children:a.breakEvenYear?`Buying ahead from year ${a.breakEvenYear}`:"Renting stays ahead"})]}),e.jsx("div",{className:"calc-verdict",children:e.jsxs("p",{children:[e.jsx("strong",{children:a.better==="buy"?"Buying":"Renting"})," leaves you about ",e.jsx("strong",{children:l(a.difference)})," better off after ",r," years."]})}),e.jsx(Y,{items:[[`Net worth if you buy (after ${r} y)`,a.buyNetWorth,a.better==="buy"],[`Net worth if you rent (after ${r} y)`,a.rentNetWorth,a.better==="rent"],["Paid upfront to buy",a.upfront],["Home loan EMI",a.emi]]}),e.jsx("p",{className:"calc-note",children:a.breakEvenYear?`Buying pulls ahead from year ${a.breakEvenYear}.`:`Renting stays ahead for all ${r} years at these assumptions.`})]})})]}),a&&e.jsxs("section",{className:"calc-schedule",children:[e.jsx("h2",{children:"Net worth year by year"}),e.jsx(k,{label:"Net worth if you buy (blue) and if you rent (green)",years:a.rows.map(s=>s.year),focus:a.breakEvenYear?a.breakEvenYear-1:a.rows.length-1,series:[{label:"If you buy",tone:"a",values:a.rows.map(s=>s.buy)},{label:"If you rent",tone:"b",values:a.rows.map(s=>s.rent)}]}),e.jsx("div",{className:"calc-table-wrap",children:e.jsxs("table",{className:"calc-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Year"}),e.jsx("th",{children:"If you buy"}),e.jsx("th",{children:"If you rent"}),e.jsx("th",{children:"Loan left"})]})}),e.jsx("tbody",{children:a.rows.map(s=>e.jsxs("tr",{children:[e.jsx("td",{children:s.year}),e.jsx("td",{children:l(s.buy)}),e.jsx("td",{children:l(s.rent)}),e.jsx("td",{children:l(s.balance)})]},s.year))})]})})]}),e.jsxs("section",{className:"calc-info",children:[e.jsx("h2",{children:"How the comparison works"}),e.jsx("p",{children:"If you buy, you pay the down payment and stamp duty, then the EMI and upkeep; your wealth is the home's value minus the loan still owed. If you rent, you invest the down payment and stamp duty instead, and each month invest whatever buying would have cost beyond the rent (if rent costs more, the buyer invests the difference). Both sides earn the same investment return."}),e.jsx("p",{children:"Not included: home-loan tax benefits, the cost of selling the home, mov
1ing costs, and the non-money reasons to own or rent. The result is very sensitive to property price growth and investment returns, so try a few values."})]})]})}export{G as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.