!function(){"use strict";function t(t,e,a=""){if(t.innerHTML="",e.length<3)return void t.classList.add("crtoday-chart-empty");t.classList.remove("crtoday-chart-empty");const r=e.map(t=>t.rate),c=Math.min(...r),o=Math.max(...r)-c||1,n=t=>t/(e.length-1)*300,s=t=>56-(t-c)/o*52;let i="";for(let t=0;t<e.length;t++){const a=n(t).toFixed(2),r=s(e[t].rate).toFixed(2);i+=0===t?`M${a},${r}`:` L${a},${r}`}const d=n(0).toFixed(2),l=`${i} L${n(e.length-1).toFixed(2)},60 L${d},60 Z`,u=e[0].rate,h=e[e.length-1].rate>=u?"up":"down",y="http://www.w3.org/2000/svg",b=document.createElementNS(y,"svg");b.setAttribute("viewBox","0 0 300 60"),b.setAttribute("preserveAspectRatio","none"),b.setAttribute("role","img"),a&&b.setAttribute("aria-label",a),b.classList.add("crtoday-sparkline",`crtoday-sparkline-${h}`);const f=document.createElementNS(y,"defs"),p=`crtoday-sg-${Math.random().toString(36).slice(2,8)}`,A=document.createElementNS(y,"linearGradient");A.setAttribute("id",p),A.setAttribute("x1","0"),A.setAttribute("y1","0"),A.setAttribute("x2","0"),A.setAttribute("y2","1");const m=document.createElementNS(y,"stop");m.setAttribute("offset","0%"),m.setAttribute("class","crtoday-sparkline-grad-start");const g=document.createElementNS(y,"stop");g.setAttribute("offset","100%"),g.setAttribute("class","crtoday-sparkline-grad-end"),A.appendChild(m),A.appendChild(g),f.appendChild(A),b.appendChild(f);const w=document.createElementNS(y,"path");w.setAttribute("d",l),w.setAttribute("fill",`url(#${p})`),w.classList.add("crtoday-sparkline-fill"),b.appendChild(w);const L=document.createElementNS(y,"path");L.setAttribute("d",i),L.setAttribute("fill","none"),L.classList.add("crtoday-sparkline-line"),b.appendChild(L),t.appendChild(b)}async function e(e,a){const r=e.getAttribute("data-crtoday-chart-api")||"",c=e.getAttribute("data-crtoday-chart-source")||"",o=e.getAttribute("data-crtoday-chart-deal")||"",n=e.getAttribute("data-crtoday-chart-from")||"",s=e.getAttribute("data-crtoday-chart-to")||"";if(!r)return;const i=new URL(r,window.location.origin);i.searchParams.set("source",c),i.searchParams.set("deal",o),i.searchParams.set("from",n),i.searchParams.set("to",s),i.searchParams.set("period",a);const d=e.querySelector(".crtoday-chart-area");if(d){d.classList.add("crtoday-chart-loading");try{const a=await fetch(i.toString());if(!a.ok)return;t(d,await a.json(),e.getAttribute("data-crtoday-i18n-chart")||"")}catch{}finally{d.classList.remove("crtoday-chart-loading")}}}const a="data-crtoday-chart-init";function r(r){if(r.hasAttribute(a))return;r.setAttribute(a,"1");const c=r.querySelector(".crtoday-chart-area"),o=r.getAttribute("data-crtoday-chart-points"),n=r.getAttribute("data-crtoday-i18n-chart")||"",s=r.getAttribute("data-crtoday-i18n-loading")||"";let i=!1;if(c&&o)try{const e=JSON.parse(o);e.length>=3&&(t(c,e,n),i=!0)}catch{}if(!i){const t=r.querySelector(".crtoday-chart-tab-active");if(t){const a=t.getAttribute("data-crtoday-period");a&&e(r,a)}}const d=r.querySelectorAll(".crtoday-chart-tab"),l=r.querySelector(".crtoday-chart-sr-status"),u=t=>{const a=t.getAttribute("data-crtoday-period");a&&(d.forEach(t=>{t.classList.remove("crtoday-chart-tab-active"),t.setAttribute("aria-selected","false"),t.setAttribute("tabindex","-1")}),t.classList.add("crtoday-chart-tab-active"),t.setAttribute("aria-selected","true"),t.setAttribute("tabindex","0"),t.focus(),l&&(l.textContent=s),e(r,a).then(()=>{l&&(l.textContent="")}))};d.forEach(t=>{t.addEventListener("click",()=>u(t))});const h=r.querySelector(".crtoday-chart-tabs");h&&h.addEventListener("keydown",t=>{const e=Array.from(d),a=e.indexOf(t.target);if(a<0)return;let r=-1;"ArrowRight"===t.key||"ArrowDown"===t.key?(t.preventDefault(),r=(a+1)%e.length):"ArrowLeft"===t.key||"ArrowUp"===t.key?(t.preventDefault(),r=(a-1+e.length)%e.length):"Home"===t.key?(t.preventDefault(),r=0):"End"===t.key&&(t.preventDefault(),r=e.length-1),r>=0&&u(e[r])})}const c=new MutationObserver(t=>{for(const e of t)for(const t of e.addedNodes)t instanceof HTMLElement&&(t.matches(".crtoday-chart-wrap")?r(t):t.querySelectorAll(".crtoday-chart-wrap").forEach(r))});function o(){!function(t=document){t.querySelectorAll(".crtoday-chart-wrap").forEach(r)}(),c.observe(document.body,{childList:!0,subtree:!0})}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",o):o()}();