← back to Boomer Calculator
out/_next/static/chunks/app/page-1dfce1602fdbe058.js
1 lines
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{9018:function(e,t,l){Promise.resolve().then(l.bind(l,9982))},9982:function(e,t,l){"use strict";l.r(t),l.d(t,{default:function(){return d}});var s=l(7437),r=l(2265);function n(e){if(!Number.isFinite(e))throw Error("Result is too large or undefined.");return e}function a(e,t){if(!e.trim())throw Error("Enter ".concat(t,"."));let l=Number(e);if(!Number.isFinite(l))throw Error("Enter a valid ".concat(t,"."));return l}function o(){let[e,t]=(0,r.useState)("0"),[l,a]=(0,r.useState)(!1),[o,i]=(0,r.useState)(""),x=s=>{if(i(""),"C"===s)t("0"),a(!1);else if("="===s)try{t(String(Number((function(e){if(!e.trim()||e.length>500)throw Error("Enter an expression up to 500 characters.");let t=e.replace(/\s+/g,""),l=0;function s(){let e=r();for(;"+"===t[l]||"-"===t[l];){let s=t[l++],a=r();e=n("+"===s?e+a:e-a)}return e}function r(){let e=a();for(;"*"===t[l]||"/"===t[l];){let s=t[l++],r=a();if("/"===s&&0===r)throw Error("Cannot divide by zero.");e=n("*"===s?e*r:e/r)}return e}function a(){if("+"===t[l])return l++,a();if("-"===t[l])return l++,-a();if(t.startsWith("sin(",l)){l+=4;let e=s();if(")"!==t[l++])throw Error("Close every parenthesis.");let r=Math.sin(e%360*Math.PI/180);return 1e-15>Math.abs(r)?0:r}if("("===t[l]){l++;let e=s();if(")"!==t[l++])throw Error("Close every parenthesis.");return e}let e=t.slice(l).match(/^(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/);if(!e)throw Error("Check the expression and parentheses.");return l+=e[0].length,n(Number(e[0]))}let o=s();if(l!==t.length)throw Error("Check the expression and parentheses.");return n(o)})(e).toPrecision(12)))),a(!0)}catch(e){i(e.message)}else{let r="sin"===s?"sin(":s,n=["+","-","*","/"].includes(s);t(("0"===e||l)&&!n?r:e+r),a(!1)}};return(0,s.jsxs)("div",{className:"bg-white rounded-xl shadow-2xl p-3 sm:p-4 max-w-2xl mx-auto",children:[(0,s.jsxs)("div",{className:"mb-3 sm:mb-4",children:[(0,s.jsx)("div",{className:"bg-gray-900 text-white p-4 sm:p-5 rounded-lg",children:(0,s.jsx)("div",{role:"status","aria-label":"Calculator display",className:"text-3xl sm:text-4xl md:text-5xl font-bold font-mono px-2 text-center break-words",children:e})}),o&&(0,s.jsx)("p",{role:"alert",className:"mt-2 text-center text-red-700",children:o})]}),(0,s.jsx)("div",{className:"grid grid-cols-4 gap-2 sm:gap-3",children:[["C","(",")","/"],["7","8","9","*"],["4","5","6","-"],["1","2","3","+"],["0",".","sin","="]].flat().map((e,t)=>(0,s.jsx)("button",{onClick:t=>{t.preventDefault(),x(e)},className:"p-4 sm:p-5 md:p-6 rounded-lg font-bold text-xl sm:text-2xl md:text-3xl select-none cursor-pointer shadow-lg ".concat("="===e?"bg-gradient-to-r from-purple-500 to-pink-500 text-white col-span-1":"C"===e?"bg-red-500 text-white":["+","-","*","/"].includes(e)?"bg-blue-500 text-white":"bg-gray-200"),style:{WebkitTapHighlightColor:"transparent"},children:e},t))}),(0,s.jsx)("div",{className:"mt-3 text-center text-sm sm:text-base text-gray-600 font-semibold",children:(0,s.jsx)("p",{children:"Arithmetic and sine \xb7 sin uses degrees"})})]})}function i(){let[e,t]=(0,r.useState)(""),[l,o]=(0,r.useState)(""),[i,x]=(0,r.useState)("30"),[c,d]=(0,r.useState)(""),[m,p]=(0,r.useState)(null),[u,h]=(0,r.useState)(""),g=()=>{h(""),p(null);try{let t=function(e,t,l,s){if([e,t,l,s].forEach(n),e<=0||t<0||t>e)throw Error("Enter a positive home price and a down payment from zero to the home price.");if(l<=0||!Number.isInteger(12*l)||s<0)throw Error("Enter a positive loan term and a rate of zero or more.");let r=e-t,a=12*l,o=s/1200;return r?n(0===o?r/a:-(r*o/Math.expm1(-a*Math.log1p(o)))):0}(a(e,"home price"),a(l,"down payment (use 0 for none)"),a(i,"loan term"),a(c,"interest rate (use 0 for no interest)"));p(t.toFixed(2))}catch(e){h(e.message)}},b=()=>{t(""),o(""),x("30"),d(""),p(null),h("")};return(0,s.jsxs)("div",{className:"bg-white rounded-xl shadow-2xl p-3 sm:p-4 max-w-2xl mx-auto",children:[(0,s.jsx)("h2",{className:"text-2xl sm:text-3xl md:text-4xl font-bold text-gray-800 mb-3 text-center",children:"\uD83C\uDFE0 Mortgage"}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2 sm:gap-3 mb-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"homePrice",className:"block text-sm sm:text-base font-bold text-gray-700 mb-1",children:"Home Price ($)"}),(0,s.jsx)("input",{type:"number",id:"homePrice",value:e,onChange:e=>{t(e.target.value),p(null),h("")},placeholder:"500000",className:"w-full p-2 sm:p-3 border-3 border-gray-300 rounded-lg focus:border-purple-500 focus:outline-none text-lg sm:text-xl font-bold"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"downPayment",className:"block text-sm sm:text-base font-bold text-gray-700 mb-1",children:"Down Payment ($)"}),(0,s.jsx)("input",{type:"number",id:"downPayment",value:l,onChange:e=>{o(e.target.value),p(null),h("")},placeholder:"100000",className:"w-full p-2 sm:p-3 border-3 border-gray-300 rounded-lg focus:border-purple-500 focus:outline-none text-lg sm:text-xl font-bold"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"loanTerm",className:"block text-sm sm:text-base font-bold text-gray-700 mb-1",children:"Loan Term"}),(0,s.jsxs)("select",{id:"loanTerm",value:i,onChange:e=>{x(e.target.value),p(null),h("")},className:"w-full p-2 sm:p-3 border-3 border-gray-300 rounded-lg focus:border-purple-500 focus:outline-none text-lg sm:text-xl font-bold",children:[(0,s.jsx)("option",{value:"15",children:"15 years"}),(0,s.jsx)("option",{value:"20",children:"20 years"}),(0,s.jsx)("option",{value:"30",children:"30 years"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"interestRate",className:"block text-sm sm:text-base font-bold text-gray-700 mb-1",children:"Rate (%)"}),(0,s.jsx)("input",{type:"number",step:"0.01",id:"interestRate",value:c,onChange:e=>{d(e.target.value),p(null),h("")},placeholder:"6.5",className:"w-full p-2 sm:p-3 border-3 border-gray-300 rounded-lg focus:border-purple-500 focus:outline-none text-lg sm:text-xl font-bold"})]})]}),u&&(0,s.jsx)("p",{role:"alert",className:"mb-3 text-center text-red-700",children:u}),null!==m&&(0,s.jsxs)("div",{className:"mb-3 p-3 sm:p-4 bg-gradient-to-r from-green-50 to-blue-50 rounded-lg border-3 border-green-200",children:[(0,s.jsx)("p",{className:"text-center text-gray-700 mb-1 text-sm sm:text-base font-bold",children:"Estimated Monthly Payment:"}),(0,s.jsxs)("p",{className:"text-center text-3xl sm:text-4xl md:text-5xl font-bold text-green-600",children:["$",m]}),(0,s.jsx)("p",{className:"text-center text-sm sm:text-base text-gray-600 mt-1 font-semibold",children:"Principal and interest only. Taxes, insurance and fees excluded."})]}),(0,s.jsxs)("div",{className:"flex gap-2 sm:gap-3 mb-2",children:[(0,s.jsx)("button",{onClick:e=>{e.preventDefault(),g()},className:"flex-1 bg-gradient-to-r from-purple-500 to-pink-500 text-white py-3 sm:py-4 rounded-lg font-bold text-lg sm:text-xl shadow-lg select-none cursor-pointer",style:{WebkitTapHighlightColor:"transparent"},children:"Calculate"}),(0,s.jsx)("button",{onClick:e=>{e.preventDefault(),b()},className:"flex-1 bg-gray-200 py-3 sm:py-4 rounded-lg font-bold text-lg sm:text-xl select-none cursor-pointer shadow-lg",style:{WebkitTapHighlightColor:"transparent"},children:"Reset"})]}),(0,s.jsxs)("div",{className:"text-center space-y-1",children:[(0,s.jsx)("p",{className:"text-xs sm:text-sm text-gray-600 font-semibold",children:"Fixed-rate loan estimate"}),(0,s.jsx)("p",{className:"text-xs text-gray-500",children:"Enter your own price, down payment and rate."})]})]})}function x(){let[e,t]=(0,r.useState)(""),[l,o]=(0,r.useState)(""),[i,x]=(0,r.useState)("imperial"),[c,d]=(0,r.useState)(null),[m,p]=(0,r.useState)(""),u=()=>{p(""),d(null);try{d((function(e,t,l){if([e,t].forEach(n),e<=0||t<=0)throw Error("Enter a weight and height greater than zero.");let s="imperial"===l?.0254*t:t/100;return n(("imperial"===l?.45359237*e:e)/(s*s))})(a(e,"weight"),a(l,"height"),i).toFixed(1))}catch(e){p(e.message)}},h=()=>{t(""),o(""),d(null),p("")};return(0,s.jsxs)("div",{className:"bg-white rounded-xl shadow-2xl p-3 sm:p-4 max-w-2xl mx-auto",children:[(0,s.jsx)("h2",{className:"text-2xl sm:text-3xl md:text-4xl font-bold text-gray-800 mb-3 text-center",children:"\uD83D\uDCAA BMI"}),(0,s.jsxs)("div",{className:"mb-3",children:[(0,s.jsxs)("div",{className:"flex justify-center gap-2 mb-3",children:[(0,s.jsx)("button",{onClick:e=>{e.preventDefault(),x("imperial"),h()},className:"px-4 sm:px-6 py-2 sm:py-3 rounded-lg font-bold text-base sm:text-lg shadow-lg select-none cursor-pointer ".concat("imperial"===i?"bg-purple-500 text-white":"bg-gray-200"),style:{WebkitTapHighlightColor:"transparent"},children:"lbs / inches"}),(0,s.jsx)("button",{onClick:e=>{e.preventDefault(),x("metric"),h()},className:"px-4 sm:px-6 py-2 sm:py-3 rounded-lg font-bold text-base sm:text-lg shadow-lg select-none cursor-pointer ".concat("metric"===i?"bg-purple-500 text-white":"bg-gray-200"),style:{WebkitTapHighlightColor:"transparent"},children:"kg / cm"})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2 sm:gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{htmlFor:"weight",className:"block text-sm sm:text-base font-bold text-gray-700 mb-1",children:["Weight (","imperial"===i?"lbs":"kg",")"]}),(0,s.jsx)("input",{type:"number",id:"weight",value:e,onChange:e=>{t(e.target.value),d(null),p("")},placeholder:"imperial"===i?"150":"68",className:"w-full p-2 sm:p-3 border-3 border-gray-300 rounded-lg focus:border-purple-500 focus:outline-none text-lg sm:text-xl font-bold"})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{htmlFor:"height",className:"block text-sm sm:text-base font-bold text-gray-700 mb-1",children:["Height (","imperial"===i?"in":"cm",")"]}),(0,s.jsx)("input",{type:"number",id:"height",value:l,onChange:e=>{o(e.target.value),d(null),p("")},placeholder:"imperial"===i?"67":"170",className:"w-full p-2 sm:p-3 border-3 border-gray-300 rounded-lg focus:border-purple-500 focus:outline-none text-lg sm:text-xl font-bold"})]})]})]}),m&&(0,s.jsx)("p",{role:"alert",className:"mb-3 text-center text-red-700",children:m}),null!==c&&(0,s.jsxs)("div",{className:"mb-3 p-3 sm:p-4 bg-gradient-to-r from-purple-50 to-pink-50 rounded-lg border-3 border-purple-200",children:[(0,s.jsx)("p",{className:"text-center text-gray-700 mb-1 text-sm sm:text-base font-bold",children:"Your BMI:"}),(0,s.jsx)("p",{className:"text-center text-3xl sm:text-4xl md:text-5xl font-bold text-purple-600",children:c}),(0,s.jsx)("div",{className:"mt-2 text-center text-sm sm:text-base text-gray-600 font-semibold",children:"A numerical estimate, not a diagnosis."})]}),(0,s.jsxs)("div",{className:"flex gap-2 sm:gap-3 mb-2",children:[(0,s.jsx)("button",{onClick:e=>{e.preventDefault(),u()},className:"flex-1 bg-gradient-to-r from-purple-500 to-pink-500 text-white py-3 sm:py-4 rounded-lg font-bold text-lg sm:text-xl shadow-lg select-none cursor-pointer",style:{WebkitTapHighlightColor:"transparent"},children:"Calculate"}),(0,s.jsx)("button",{onClick:e=>{e.preventDefault(),h()},className:"flex-1 bg-gray-200 py-3 sm:py-4 rounded-lg font-bold text-lg sm:text-xl select-none cursor-pointer shadow-lg",style:{WebkitTapHighlightColor:"transparent"},children:"Reset"})]}),(0,s.jsx)("div",{className:"text-center text-xs sm:text-sm text-gray-600 font-semibold",children:(0,s.jsx)("p",{children:"BMI = weight in kilograms \xf7 height in metres squared."})})]})}function c(){let[e,t]=(0,r.useState)(""),[l,o]=(0,r.useState)("15"),[i,x]=(0,r.useState)("1"),[c,d]=(0,r.useState)(null),[m,p]=(0,r.useState)(""),u=()=>{p(""),d(null);try{let t=function(e,t,l){if([e,t,l].forEach(n),e<0||t<0)throw Error("Bill and tip percentage must be zero or more.");if(!Number.isSafeInteger(l)||l<1)throw Error("Enter a whole number of people, at least one.");let s=Math.round(100*e),r=Math.round(s*t/100),a=s+r;if(!Number.isSafeInteger(a))throw Error("Bill or tip is too large.");return{tip:r/100,total:a/100,perPerson:Math.round(a/l)/100}}(a(e,"bill amount"),a(l,"tip percentage"),a(i,"number of people"));d({tip:t.tip.toFixed(2),total:t.total.toFixed(2),perPerson:t.perPerson.toFixed(2)})}catch(e){p(e.message)}},h=()=>{t(""),o("15"),x("1"),d(null),p("")};return(0,s.jsxs)("div",{className:"bg-white rounded-xl shadow-2xl p-3 sm:p-4 max-w-2xl mx-auto",children:[(0,s.jsx)("h2",{className:"text-2xl sm:text-3xl md:text-4xl font-bold text-gray-800 mb-3 text-center",children:"\uD83D\uDCB5 Tip"}),(0,s.jsxs)("div",{className:"space-y-2 sm:space-y-3 mb-3",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2 sm:gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"billAmount",className:"block text-sm sm:text-base font-bold text-gray-700 mb-1",children:"Bill ($)"}),(0,s.jsx)("input",{type:"number",id:"billAmount",value:e,onChange:e=>{t(e.target.value),d(null),p("")},placeholder:"100",className:"w-full p-2 sm:p-3 border-3 border-gray-300 rounded-lg focus:border-purple-500 focus:outline-none text-lg sm:text-xl font-bold"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"numPeople",className:"block text-sm sm:text-base font-bold text-gray-700 mb-1",children:"People"}),(0,s.jsx)("input",{type:"number",min:"1",id:"numPeople",value:i,onChange:e=>{x(e.target.value),d(null),p("")},placeholder:"1",className:"w-full p-2 sm:p-3 border-3 border-gray-300 rounded-lg focus:border-purple-500 focus:outline-none text-lg sm:text-xl font-bold"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{htmlFor:"tipPercent",className:"block text-sm sm:text-base font-bold text-gray-700 mb-1",children:["Tip: ",l,"%"]}),(0,s.jsx)("div",{className:"flex gap-2 mb-2 flex-wrap justify-center",children:["10","15","18","20","25"].map(e=>(0,s.jsxs)("button",{onClick:t=>{t.preventDefault(),o(e),d(null),p("")},className:"px-3 sm:px-4 py-2 rounded-lg font-bold text-base sm:text-lg shadow-lg select-none cursor-pointer ".concat(l===e?"bg-purple-500 text-white scale-105":"bg-gray-200"),style:{WebkitTapHighlightColor:"transparent"},children:[e,"%"]},e))}),(0,s.jsx)("input",{type:"range",min:"0",max:"50",id:"tipPercent",value:l,onChange:e=>{o(e.target.value),d(null),p("")},className:"w-full h-3 accent-purple-500"})]})]}),m&&(0,s.jsx)("p",{role:"alert",className:"mb-3 text-center text-red-700",children:m}),null!==c&&(0,s.jsxs)("div",{className:"mb-3 p-3 bg-gradient-to-r from-green-50 to-emerald-50 rounded-lg border-3 border-green-200",children:[(0,s.jsxs)("div",{className:"grid grid-cols-3 gap-2",children:[(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("p",{className:"text-xs sm:text-sm text-gray-600 font-bold",children:"Tip"}),(0,s.jsxs)("p",{className:"text-xl sm:text-2xl font-bold text-green-600",children:["$",c.tip]})]}),(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("p",{className:"text-xs sm:text-sm text-gray-600 font-bold",children:"Total"}),(0,s.jsxs)("p",{className:"text-xl sm:text-2xl font-bold text-blue-600",children:["$",c.total]})]}),(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("p",{className:"text-xs sm:text-sm text-gray-600 font-bold",children:"Each"}),(0,s.jsxs)("p",{className:"text-xl sm:text-2xl font-bold text-purple-600",children:["$",c.perPerson]})]})]}),(0,s.jsx)("p",{className:"text-center text-sm sm:text-base text-gray-600 mt-2 font-semibold",children:"Amounts rounded to cents; split totals may differ by a few cents."})]}),(0,s.jsxs)("div",{className:"flex gap-2 sm:gap-3 mb-2",children:[(0,s.jsx)("button",{onClick:e=>{e.preventDefault(),u()},className:"flex-1 bg-gradient-to-r from-purple-500 to-pink-500 text-white py-3 sm:py-4 rounded-lg font-bold text-lg sm:text-xl shadow-lg select-none cursor-pointer",style:{WebkitTapHighlightColor:"transparent"},children:"Calculate"}),(0,s.jsx)("button",{onClick:e=>{e.preventDefault(),h()},className:"flex-1 bg-gray-200 py-3 sm:py-4 rounded-lg font-bold text-lg sm:text-xl select-none cursor-pointer shadow-lg",style:{WebkitTapHighlightColor:"transparent"},children:"Reset"})]}),(0,s.jsx)("div",{className:"text-center text-xs sm:text-sm text-gray-600 font-semibold",children:(0,s.jsx)("p",{children:"Easy Tip Calculator"})})]})}function d(){let[e,t]=(0,r.useState)("scientific"),[l,n]=(0,r.useState)(!1);return(0,s.jsx)("main",{className:"min-h-screen bg-gradient-to-br from-purple-500 via-pink-500 to-red-500 p-2 sm:p-3 pt-safe pb-safe",children:(0,s.jsxs)("div",{className:"max-w-4xl mx-auto pt-4",children:[(0,s.jsxs)("div",{className:"text-center mb-3 sm:mb-4",children:[(0,s.jsx)("h1",{className:"text-3xl sm:text-4xl md:text-5xl font-bold text-white mb-2",children:"\uD83E\uDDEE Boomer Calc"}),(0,s.jsx)("p",{className:"text-base sm:text-lg md:text-xl text-white/90 font-semibold",children:"Simple. Easy. Clear."})]}),(0,s.jsxs)("div",{className:"flex flex-wrap justify-center gap-2 sm:gap-3 mb-3 sm:mb-4",children:[(0,s.jsx)("button",{onClick:e=>{e.preventDefault(),t("scientific")},onTouchEnd:e=>{e.preventDefault(),t("scientific")},className:"px-4 sm:px-6 py-2 sm:py-3 rounded-lg font-bold select-none cursor-pointer text-base sm:text-lg md:text-xl shadow-lg ".concat("scientific"===e?"bg-white text-purple-600 scale-105":"bg-white/20 text-white"),style:{WebkitTapHighlightColor:"transparent"},children:"\uD83D\uDD2C Calculator"}),(0,s.jsx)("button",{onClick:e=>{e.preventDefault(),t("mortgage")},onTouchEnd:e=>{e.preventDefault(),t("mortgage")},className:"px-4 sm:px-6 py-2 sm:py-3 rounded-lg font-bold select-none cursor-pointer text-base sm:text-lg md:text-xl shadow-lg ".concat("mortgage"===e?"bg-white text-purple-600 scale-105":"bg-white/20 text-white"),style:{WebkitTapHighlightColor:"transparent"},children:"\uD83C\uDFE0 Mortgage"}),(0,s.jsx)("button",{onClick:e=>{e.preventDefault(),t("bmi")},onTouchEnd:e=>{e.preventDefault(),t("bmi")},className:"px-4 sm:px-6 py-2 sm:py-3 rounded-lg font-bold select-none cursor-pointer text-base sm:text-lg md:text-xl shadow-lg ".concat("bmi"===e?"bg-white text-purple-600 scale-105":"bg-white/20 text-white"),style:{WebkitTapHighlightColor:"transparent"},children:"\uD83D\uDCAA BMI"}),(0,s.jsx)("button",{onClick:e=>{e.preventDefault(),t("tip")},onTouchEnd:e=>{e.preventDefault(),t("tip")},className:"px-4 sm:px-6 py-2 sm:py-3 rounded-lg font-bold select-none cursor-pointer text-base sm:text-lg md:text-xl shadow-lg ".concat("tip"===e?"bg-white text-purple-600 scale-105":"bg-white/20 text-white"),style:{WebkitTapHighlightColor:"transparent"},children:"\uD83D\uDCB5 Tip"})]}),(0,s.jsxs)("div",{className:"mb-3 sm:mb-4",children:["scientific"===e&&(0,s.jsx)(o,{}),"mortgage"===e&&(0,s.jsx)(i,{}),"bmi"===e&&(0,s.jsx)(x,{}),"tip"===e&&(0,s.jsx)(c,{})]}),(0,s.jsxs)("div",{className:"text-center text-white/60 text-sm sm:text-base",children:[(0,s.jsx)("p",{className:"mb-1",children:"\uD83D\uDE0A Easy to use. Easy to read."}),(0,s.jsx)("p",{children:"Made with ❤️ for everyone"})]})]})})}}},function(e){e.O(0,[971,117,744],function(){return e(e.s=9018)}),_N_E=e.O()}]);