(function () { 'use strict'; window.__hkLoaded = true; var MOUNT_ID = 'hk-kalkulacka'; var STYLE_ID = 'hk-styles'; var IDS = ['hk-loan', 'hk-rate', 'hk-rate-num', 'hk-years']; function $(id) { return document.getElementById(id); } function fmt(n) { return Math.round(n).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' '); } function fmtM(n) { return (n / 1e6).toFixed(1) + 'M'; } function comma(n) { return String(n).replace('.', ','); } var CSS = '' + '.hk{--hk-bg:#1a2233;--hk-card:#232c40;--hk-yellow:#f5b800;--hk-blue:#60a5fa;--hk-text:#e2e8f0;--hk-muted:#94a3b8;--hk-track:#3a4258;max-width:1200px;margin:0 auto;background:var(--hk-bg);border-radius:18px;padding:32px;border:1px solid rgba(255,255,255,0.06);color:var(--hk-text);font-family:"Poppins",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;box-sizing:border-box}' + '.hk *,.hk *::before,.hk *::after{box-sizing:border-box}' + '.hk__head{display:flex;align-items:center;justify-content:space-between;padding-bottom:24px;border-bottom:1px solid rgba(255,255,255,0.06);margin-bottom:32px;gap:16px;flex-wrap:wrap}' + '.hk__head-left{display:flex;align-items:center;gap:18px}' + '.hk__icon{width:56px;height:56px;border-radius:14px;background:linear-gradient(135deg,#3b82f6,#1e3a8a);display:flex;align-items:center;justify-content:center;color:#fff;flex-shrink:0}' + '.hk__title{margin:0;font-size:24px;font-weight:700;line-height:1.2;color:#fff}' + '.hk__sub{margin:4px 0 0;font-size:14px;color:var(--hk-muted)}' + '.hk__grid{display:grid;grid-template-columns:1.1fr 1fr;gap:40px}' + '.hk__controls{display:flex;flex-direction:column;gap:36px}' + '.hk__label{font-size:14px;color:var(--hk-muted);margin-bottom:14px;display:block}' + '.hk__slider{-webkit-appearance:none;appearance:none;width:100%;height:6px;border-radius:3px;background:var(--hk-track);outline:none;margin:0}' + '.hk__slider::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:22px;height:22px;border-radius:50%;background:#fff;cursor:pointer;box-shadow:0 0 0 5px var(--hk-yellow);border:none}' + '.hk__slider::-moz-range-thumb{width:22px;height:22px;border-radius:50%;background:#fff;cursor:pointer;box-shadow:0 0 0 5px var(--hk-yellow);border:none}' + '.hk__minmax-row{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;margin-top:14px;gap:8px}' + '.hk__min,.hk__max{font-size:13px;color:var(--hk-muted)}.hk__max{text-align:right}' + '.hk__current{text-align:center;font-size:22px;font-weight:700;color:#fff}' + '.hk__rate-edit{display:flex;align-items:center;justify-content:center;gap:4px}' + '.hk__rate-input{width:78px;text-align:center;font-size:22px;font-weight:700;color:#fff;background:var(--hk-card);border:1px solid rgba(255,255,255,0.12);border-radius:8px;padding:4px 6px;outline:none}' + '.hk__rate-input:focus{border-color:var(--hk-yellow)}' + '.hk__rate-pct{font-size:22px;font-weight:700;color:#fff}' + '.hk__monthly{text-align:right}.hk__monthly-label{font-size:14px;color:var(--hk-muted);margin-bottom:6px}' + '.hk__monthly-value{font-size:46px;font-weight:700;color:var(--hk-yellow);line-height:1;letter-spacing:-1px}' + '.hk__boxes{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-top:18px}' + '.hk__box{background:var(--hk-card);border-radius:14px;padding:18px 20px}' + '.hk__box-label{font-size:13px;color:var(--hk-muted);margin-bottom:8px}' + '.hk__box-value{font-size:20px;font-weight:700;color:#fff}.hk__box--orange .hk__box-value{color:#fbbf24}' + '.hk__chart{margin-top:18px}.hk__chart svg{display:block;width:100%;overflow:visible}' + '.hk__legend{display:flex;gap:24px;justify-content:center;margin-top:14px;font-size:13px;color:var(--hk-muted);flex-wrap:wrap}' + '.hk__legend-dot{display:inline-block;width:10px;height:10px;border-radius:50%;margin-right:8px;vertical-align:middle}' + '@media (max-width:880px){.hk__grid{grid-template-columns:1fr}.hk__monthly{text-align:left}.hk__monthly-value{font-size:38px}.hk{padding:22px}}'; function injectStyle() { if (document.getElementById(STYLE_ID)) return; var s = document.createElement('style'); s.id = STYLE_ID; s.textContent = CSS; (document.head || document.documentElement).appendChild(s); } function markup(loan, rate, years) { return '' + '
' + '
' + '
' + '

Hypoteční kalkulačka

Spočítejte si měsíční splátku hypotéky

' + '
' + '
' + '
' + '' + '
500 000 Kč15 000 000 Kč
' + '
' + '' + '
1 %' + '%' + '10 %
' + '
' + '' + '
5 let35 let
' + '
' + '
Měsíční splátka
' + '
Celkem zaplatíte
' + '
Přeplatíte na úrocích
' + '
' + '' + '' + '' + '' + '
Splacená jistinaZaplacené úroky
' + '
'; } function ensureRendered() { var mount = document.getElementById(MOUNT_ID); if (!mount) return; injectStyle(); if (!mount.querySelector('#hk-loan')) { var loan = parseFloat(mount.getAttribute('data-loan')) || 5000000; var rate = parseFloat(mount.getAttribute('data-rate')) || 4.4; var years = parseFloat(mount.getAttribute('data-years')) || 30; mount.innerHTML = markup(loan, rate, years); calc(); } } function readRate() { var num = $('hk-rate-num'), r = $('hk-rate'); if (num && num.value !== '') { var v = parseFloat(String(num.value).replace(',', '.')); if (!isNaN(v)) return v; } return r ? +r.value : 0; } function syncRate(id) { var num = $('hk-rate-num'), r = $('hk-rate'); if (!r) return; if (id === 'hk-rate') { if (num && document.activeElement !== num) num.value = (+r.value).toFixed(2).replace(/\.?0+$/, '').replace('.', ','); } else if (id === 'hk-rate-num' && num) { var v = parseFloat(String(num.value).replace(',', '.')); if (!isNaN(v)) { var mn = +r.min || 0, mx = +r.max || 100; r.value = Math.min(mx, Math.max(mn, v)); } } } function calc() { var loanEl = $('hk-loan'), rateEl = $('hk-rate'), yearsEl = $('hk-years'); if (!loanEl || !rateEl || !yearsEl) return; var P = +loanEl.value, rate = readRate(), years = +yearsEl.value; var lv = $('hk-loan-val'); if (lv) lv.textContent = fmt(P) + ' Kč'; var yv = $('hk-years-val'); if (yv) yv.textContent = years + ' let'; var r = rate / 100 / 12, n = years * 12; var M = r === 0 ? P / n : P * r * Math.pow(1 + r, n) / (Math.pow(1 + r, n) - 1); var total = M * n; var pe = $('hk-payment'); if (pe) pe.textContent = fmt(M) + ' Kč'; var te = $('hk-total'); if (te) te.textContent = fmt(total) + ' Kč'; var ie = $('hk-interest'); if (ie) ie.textContent = fmt(total - P) + ' Kč'; var bal = P, cP = 0, cI = 0, pts = [{ y: 0, p: 0, i: 0 }]; for (var m = 1; m <= n; m++) { var ip = bal * r, pp = M - ip; bal -= pp; cP += pp; cI += ip; if (m % 12 === 0 || m === n) pts.push({ y: m / 12, p: cP, i: cI }); } var W = 600, H = 260, pL = 40, pR = 10, pT = 10, pB = 30, iW = W - pL - pR, iH = H - pT - pB, yMax = Math.max(P, cI) * 1.15; function xs(x) { return pL + (x / years) * iW; } function ys(y) { return pT + iH - (y / yMax) * iH; } function line(pr) { return 'M ' + pts.map(function (d) { return xs(d.y).toFixed(1) + ',' + ys(d[pr]).toFixed(1); }).join(' L '); } function area(pr) { return line(pr) + ' L ' + xs(years).toFixed(1) + ',' + ys(0).toFixed(1) + ' L ' + xs(0).toFixed(1) + ',' + ys(0).toFixed(1) + ' Z'; } var pp1 = $('hk-pp'); if (pp1) pp1.setAttribute('d', line('p')); var ip1 = $('hk-ip'); if (ip1) ip1.setAttribute('d', line('i')); var ppf = $('hk-pp-fill'); if (ppf) ppf.setAttribute('d', area('p')); var ipf = $('hk-ip-fill'); if (ipf) ipf.setAttribute('d', area('i')); var grid = $('hk-ygrid'), ylab = $('hk-ylabels'); if (grid && ylab) { var gh = '', yh = '', step = yMax / 4; for (var i = 0; i <= 4; i++) { var yV = step * i, y = ys(yV); gh += ''; yh += '' + fmtM(yV) + ''; } grid.innerHTML = gh; ylab.innerHTML = yh; } var xlab = $('hk-xlabels'); if (xlab) { var xh = '', xStep = years <= 10 ? 2 : (years <= 20 ? 4 : 5); for (var x = 0; x <= years; x += xStep) { xh += '' + x + ''; } xlab.innerHTML = xh; } } document.addEventListener('input', function (e) { var t = e.target; if (t && IDS.indexOf(t.id) !== -1) { if (t.id === 'hk-rate' || t.id === 'hk-rate-num') syncRate(t.id); calc(); } }, true); function scheduleAfterHydration() { setTimeout(ensureRendered, 700); setTimeout(function () { if (!document.getElementById('hk-loan')) ensureRendered(); }, 1800); setTimeout(function () { if (!document.getElementById('hk-loan')) ensureRendered(); }, 3500); } if (document.readyState === 'complete') scheduleAfterHydration(); else window.addEventListener('load', scheduleAfterHydration); })();