(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8977],{4997:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/bitcoin-hashrate",function(){return a(8220)}])},8220:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return BitcoinHashrate}});var i=a(5893),n=a(9008),l=a.n(n),r=a(7294),s=a(7626),o=a(5912),c=a(1526),h=a(6720),d=a(6488);a(4321),a(813);var m=a(6204),g=a(8688);function BitcoinHashrate(){let[e,t]=(0,r.useState)(!1),[a,n]=(0,r.useState)(!0),[o,x]=(0,r.useState)("isInfoVisible"),[f,p]=(0,r.useState)(!1),[u,w]=(0,r.useState)([]),[y,b]=(0,r.useState)("BTC"),[v,j]=(0,r.useState)([]),T=(0,g.eI)("https://swmkwzrguapkaodkgcmt.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InN3bWt3enJndWFwa2FvZGtnY210Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTIxODI1NDMsImV4cCI6MjAyNzc1ODU0M30.At51g7QDyI7Pk-nx_-S5ShAcme7bjhSUqX8YsVvGB9A");(0,r.useEffect)(()=>{let e=window.location.pathname,t="isInfoVisible_".concat(e);x(t);let a=localStorage.getItem(t);null!==a&&n("false"!==a)},[]);let toggleInfo=()=>{let e=!a;localStorage.setItem(o,e.toString()),n(e)};(0,r.useEffect)(()=>{(0,d.ZP)(":not(.sidebar-tooltip)[data-tippy-content]",{placement:"bottom",theme:"customTheme"})},[]);let I=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=new Image;e.src="/assets/images/mainLogoLetters.png",e.onload=()=>{I.current=e,drawChart(u)}},[]);let C=(0,r.useRef)(null),formatAxisLabel=e=>e>=1?e.toFixed(0):e>=.01?e.toFixed(2):e.toFixed(6),formatPrice=e=>e<1e3?e.toFixed(2):e.toFixed(0),fetchBatchedDataInParallel=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2500,a=new Date("2010-07-17"),i=Array.from({length:3},(i,n)=>{let l=n*t,r=l+t-1;return T.from(e).select("date, hashrate").range(l,r).then(e=>{let{data:t,error:i}=e;return i?(console.error("Error fetching batch ".concat(n,": ").concat(i.message)),[]):t.filter(e=>{let{date:t}=e;return new Date(t)>=a})})});return(await Promise.all(i)).flat()};(0,r.useEffect)(()=>{let fetchData=async()=>{t(!0);try{let[e,t]=await Promise.all([T.from("daily_candles").select("candles").eq("token","BTCUSDT").single(),fetchBatchedDataInParallel("btc_hashrate",2500)]),{data:a,error:i}=e;if(i)throw Error("Error fetching BTC data: ".concat(i.message));let n=new Date("2010-07-17"),l=a.candles.map(e=>{let{timestamp:t,close:a}=e;return{timestamp:new Date(t).toISOString().split("T")[0],close:parseFloat(a)}}).filter(e=>new Date(e.timestamp)>=n);w(l);let r=t.map(e=>{let{date:t,hashrate:a}=e;return{date:new Date(t).toISOString().split("T")[0],hashrate:a}});j(r)}catch(e){console.error("Failed to fetch data: ".concat(e.message))}finally{t(!1)}};fetchData()},[]),(0,r.useEffect)(()=>{let handleResize=()=>{drawChart(u)};return window.addEventListener("resize",handleResize),()=>{window.removeEventListener("resize",handleResize)}},[u]),(0,r.useEffect)(()=>{C.current&&u.length>0&&v.length>0&&drawChart(u)},[u,v]);let generateDailyDates=(e,t)=>{let a=[],i=new Date(e),n=new Date(t);for(;i<=n;)a.push(new Date(i).toISOString().split("T")[0]),i.setDate(i.getDate()+1);return a},drawChart=e=>{let t=C.current;if(!t)return;let a=t.getContext("2d");if(!a)return;let i=document.createElement("canvas"),n=i.getContext("2d"),l=t.parentElement,r=l.clientWidth,s=l.clientHeight;t.width=2*r,t.height=2*s,t.style.width="".concat(r,"px"),t.style.height="".concat(s,"px"),a.scale(2,2),i.width=2*r,i.height=2*s,n.scale(2,2);let o=40,c=50;o=r<=1024?35:50,c=50;let h=Math.max(...e.map(e=>e.close)),d=Math.min(...e.map(e=>e.close)),m=Math.min(...v.map(e=>e.hashrate)),g=Math.max(...v.map(e=>e.hashrate));d=Math.max(d,1e-4);let x=(s-0-10-40)/(g-m);if(0===e.length)return;let f=u.map(e=>e.timestamp);n.clearRect(0,0,i.width,i.height);let drawAxes=(e,t)=>{e.fillStyle="lightgrey",e.textAlign="right",r<=1024?e.font="8px Oxanium, Helvetica, Verdana, Tahoma, sans-serif":e.font="10px Oxanium, Helvetica, Verdana, Tahoma, sans-serif",e.textBaseline="middle";for(let t=0;t<=5;t++){let a=.2*t,i=Math.pow(10,Math.log10(d)+a*(Math.log10(h)-Math.log10(d))),n=s-10-20-a*(s-0-10-40);e.fillText("".concat(formatAxisLabel(i)),o-10,n),e.strokeStyle="rgba(255, 255, 255, 0.7)",e.lineWidth=.1,e.beginPath(),e.moveTo(o,n),e.lineTo(r-c,n),e.stroke()}let a=(g-m)/5;e.textAlign="left";for(let t=0;t<=5;t++){let i=m+t*a,n=s-10-20-(i-m)*x,l=(i/1e6).toFixed(2)+"M";e.fillText(l,r-c+10,n)}e.fillStyle="lightgrey",e.textAlign="center",e.textBaseline="middle",e.font="10px Oxanium, Helvetica, Verdana, Tahoma, sans-serif",window.innerWidth;let i=new Date(t[0].timestamp),n=new Date(t[t.length-1].timestamp),l=generateDailyDates(i,n);e.fillText(new Date(i).getFullYear(),o,s-10);for(let t=new Date(i);t<n;t.setFullYear(t.getFullYear()+2)){let a=new Date(t).toISOString().split("T")[0],i=o+l.indexOf(a)*(r-o-c)/(l.length-1);i>o&&i<r-c&&e.fillText(new Date(t).getFullYear(),i,s-10)}};(t=>{t.clearRect(0,0,r,s),t.fillStyle="#171a1e",t.fillRect(0,0,r,s);let a=f.map(e=>{let t=u.find(t=>t.timestamp===e),a=v.find(t=>t.date===e);return{date:e,close:t?t.close:null,hashrate:a?a.hashrate:null}}),normalize=(e,t,a)=>(e-t)/(a-t),i=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:15;if(e.length<t)return e;let a=[];for(let i=0;i<e.length;i++)if(i<t-1)a.push(e[i]);else{let n=e.slice(i-t+1,i+1),l=n.reduce((e,t)=>e+t.hashrate,0)/n.length;a.push({...e[i],hashrate:l})}return a}(v),drawLine=function(e,t,a,i){let n=arguments.length>4&&void 0!==arguments[4]&&arguments[4],l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:[];e.strokeStyle=a,e.lineWidth=i,e.beginPath();let x=!0;l.forEach((a,i)=>{let l=a[t];if(null===l)return;let p=o+i*(r-o-c)/(f.length-1);if(p>=o&&p<=r-c){let t=n?normalize(l,m,g):normalize(Math.log10(l),Math.log10(d),Math.log10(h)),a=s-10-20-t*(s-0-10-40);x?(e.moveTo(p,a),x=!1):e.lineTo(p,a)}}),e.stroke()};drawLine(t,"hashrate","#cbd5e1",1,!0,i),drawLine(t,"close","orange",1,!1,a),drawAxes(t,e)})(n),I.current&&(n.globalAlpha=.5,n.drawImage(I.current,50,10,101.4,30.2),n.globalAlpha=1),a.drawImage(i,0,0,r,s);let p=document.getElementById("cumulative-tooltip"),handleMouseMove=e=>{let n=t.getBoundingClientRect(),l=e.clientX-n.left,x=e.clientY-n.top,f=l<o,w=l>r-c,b=x>s-20;if(f||w||b){p.style.display="none",a.clearRect(0,0,r,s),a.drawImage(i,0,0,r,s);return}if(l<o||l>r-c)return;let j=(l-o)*(u.length-1)/(r-o-c),T=Math.min(Math.max(0,Math.round(j)),u.length-1),I=u[T].timestamp,C=u[T],D=v.find(e=>e.date===I);p.style.display="block",p.style.left="".concat(l+10,"px"),p.style.top="".concat(x+10,"px"),l+50+p.offsetWidth>r?p.style.left="".concat(l-p.offsetWidth-60,"px"):p.style.left="".concat(l+30,"px"),x+10+p.offsetHeight>s?p.style.top="".concat(x-p.offsetHeight-10,"px"):p.style.top="".concat(x+10,"px");let N=C&&C.close?"$".concat(formatPrice(C.close)):"N/A",S=D&&void 0!==D.hashrate?new Intl.NumberFormat("en-US").format(Math.round(parseFloat(D.hashrate))):"N/A";p.innerHTML="\n        Date: ".concat(new Date(I).toLocaleDateString("en-GB",{timeZone:"UTC"}),'<br>\n        <span style="display: flex; align-items: center;">\n          <img src="https://lcw.nyc3.cdn.digitaloceanspaces.com/production/currencies/64/').concat(y.toLowerCase(),'.png" class="w-2" alt="Bitcoin logo" style="width: 16px; vertical-align: middle; margin-right: 4px;" /> \n          ').concat(y," Price: ").concat(N,'\n        </span>\n        <div style="display: flex; justify-content: flex-start; align-items: center;">\n          <div style="width: 10px; height: 10px; background-color: #ccd5e1; margin-right: 6px; margin-bottom: 3px;"></div>\n          <div>Hashrate: ').concat(S,"</div>\n        </div>\n      "),a.clearRect(0,0,r,s),a.drawImage(i,0,0,r,s),a.strokeStyle="rgba(255, 255, 255, 0.5)",a.lineWidth=.7,a.setLineDash([5,5]),a.beginPath(),a.moveTo(l,0),a.lineTo(l,s),a.moveTo(0,x),a.lineTo(r,x),a.stroke(),a.setLineDash([]),a.fillStyle="rgba(63, 63, 70, 1)",a.fillRect(o-70,x-10,70,20),a.fillStyle="white",a.font="10px Oxanium, Helvetica, Verdana, Tahoma, sans-serif",a.textAlign="right";let k=(s-x-20-10)/(s-0-10-40),M=Math.pow(10,Math.log10(d)+k*(Math.log10(h)-Math.log10(d)));a.fillText(formatPrice(M),o-3,x+2.5),a.fillStyle="rgba(63, 63, 70, 1)",a.fillRect(l-35,s-10-10,70,30),a.fillStyle="white",a.textAlign="center",a.fillText(new Date(I).toLocaleDateString("en-GB",{timeZone:"UTC"}),l,s-10+3);let E=m+(s-x-20-10)/(s-0-10-40)*(g-m);a.fillStyle="rgba(63, 63, 70, 1)",a.fillRect(r-c+10,x-10,70,20),a.fillStyle="white",a.font="8px Oxanium, Helvetica, Verdana, Tahoma, sans-serif",a.textAlign="left";let B=(E/1e6).toFixed(2)+"M";a.fillText(B,r-c+15,x+2.5)};return t.addEventListener("mousemove",handleMouseMove),t.addEventListener("mouseout",()=>{p.style.display="none",a.clearRect(0,0,r,s),a.drawImage(i,0,0,r,s)}),()=>{t.removeEventListener("mousemove",handleMouseMove)}},drawExtraContent=(e,t,a)=>{let i,n,l,r;let s=window.innerWidth;s>640?(i=28,n=14,l=75,r=35):(i=18,n=12,l=47,r=20),e.font="".concat(n,"px Oxanium"),e.fillStyle="#e4e4e7";let o="Created at TradingDigits.io",c=e.measureText(o).width;e.fillText(o,(t-c)/2,r),e.font="".concat(i,"px Oxanium");let h="".concat(a,", ").concat(new Date().toLocaleDateString()),d=e.measureText(h).width;e.fillText(h,(t-d)/2,l)},downloadChart=(e,t)=>{let a=e.current;a.getContext("2d");let i=document.createElement("canvas"),n=a.width+40,l=a.height+20+40+100;i.width=n,i.height=l;let r=i.getContext("2d");r.fillStyle="#171a1e",r.fillRect(0,0,i.width,i.height),drawExtraContent(r,i.width,t),r.drawImage(a,20,100);let s=document.createElement("a");s.download="".concat(t.replace(/\s+/g,"_").toLowerCase(),".png"),s.href=i.toDataURL("image/png"),s.click()},copyChartToClipboard=async(e,t)=>{let a=e.current;a.getContext("2d");let i=document.createElement("canvas"),n=a.width+40,l=a.height+20+40+100;i.width=n,i.height=l;let r=i.getContext("2d");r.fillStyle="#171a1e",r.fillRect(0,0,i.width,i.height),drawExtraContent(r,i.width,t),r.drawImage(a,20,100),i.toBlob(async e=>{try{let t=new ClipboardItem({"image/png":e});await navigator.clipboard.write([t]),p(!0),setTimeout(()=>p(!1),1e3)}catch(e){console.error("Failed to copy chart: ",e)}})};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(()=>(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(l(),{children:[(0,i.jsx)("title",{children:"Bitcoin Hashrate Chart: Historical and Real-Time Data"}),(0,i.jsx)("meta",{name:"description",content:"Bitcoin historical hashrate chart provides insights into the BTC network's computational power, helping traders gauge its health and security"}),(0,i.jsx)("meta",{name:"keywords",content:"bitcoin, btc, hashrate, chart, index, crypto, metrics, historical, network, miner"}),(0,i.jsx)("meta",{property:"og:title",content:"Bitcoin Hashrate Chart: Historical and Real-Time Data"}),(0,i.jsx)("meta",{property:"og:description",content:"Bitcoin historical hashrate chart provides insights into the BTC network's computational power, helping traders gauge its health and security"}),(0,i.jsx)("meta",{property:"og:image",content:"https://www.tradingdigits.io/assets/images/ogImage.jpg"}),(0,i.jsx)("meta",{property:"og:url",content:"https://www.tradingdigits.io/bitcoin-hashrate"}),(0,i.jsx)("meta",{name:"twitter:title",content:"Bitcoin Hashrate Chart: Historical and Real-Time Data"}),(0,i.jsx)("meta",{name:"twitter:description",content:"Bitcoin historical hashrate chart provides insights into the BTC network's computational power, helping traders gauge its health and security"}),(0,i.jsx)("meta",{name:"twitter:image",content:"https://www.tradingdigits.io/assets/images/ogImage.jpg"}),(0,i.jsx)("meta",{name:"twitter:card",content:"summary_large_image"}),(0,i.jsx)("meta",{name:"twitter:image:alt",content:"Promotional image with crypto-related illustration on black background, company name, and catchphrase about Trading Digits"}),(0,i.jsx)("meta",{name:"twitter:site",content:"@trading_digits"}),(0,i.jsx)("link",{rel:"canonical",href:"https://www.tradingdigits.io/bitcoin-hashrate"}),(0,i.jsx)("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),(0,i.jsx)("link",{href:"https://fonts.googleapis.com/css2?family=Oxanium:wght@300;400;500;600;700&display=swap",rel:"stylesheet"})]})}),{}),(0,i.jsx)("div",{className:"md:mt-[95px] sm:mt-[90px] mt-[80px]",children:(0,i.jsxs)("div",{className:"pb-3 pt-2 sm:pt-1 ".concat(e?"h-screen":"h-full"," 2.5xl:h-full 3xl:h-screen min-[1540px]:pb-[100px]"),children:[(0,i.jsxs)("div",{className:"flex items-center ".concat(a?"lg:justify-start":"lg:justify-center pb-4"," justify-center my-1.75 text-center"),children:[(0,i.jsx)("h1",{className:"pl-2 sm:text-2xl text-xl font-[Oxanium-Regular]",children:"BITCOIN HASHRATE INDEX"}),(0,i.jsx)(c.M,{children:!a&&(0,i.jsx)(h.E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.5},className:"ml-3",children:(0,i.jsx)("i",{onClick:toggleInfo,className:"fa-solid fa-circle-info fa-lg text-zinc-200 cursor-pointer hover:text-amber-400 transition duration-300"})})})]}),(0,i.jsx)(c.M,{children:a&&(0,i.jsxs)(h.E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.5},className:"relative px-2 py-2 flex items-center mr-0 mb-8 bg-[#363738] justify-center w-full",children:[(0,i.jsx)("i",{className:"fa-solid fa-circle-info fa-2xl mr-3 text-zinc-200"}),(0,i.jsx)("div",{className:"font-[Oxanium-Regular] sm:text-sm text-xs pr-4",children:(0,i.jsx)("p",{children:"The Bitcoin Hashrate chart measures the total computational power used to mine and process transactions on the Bitcoin network. A higher hashrate indicates increased security and network strength, as more miners contribute to verifying transactions. Monitoring hashrate trends can help traders gauge market sentiment, network health, and potential impacts on mining profitability."})}),(0,i.jsx)("div",{onClick:toggleInfo,className:"absolute top-0 right-0 flex items-start hover:bg-zinc-500 cursor-pointer py-0.5 px-1 transition duration-300",children:(0,i.jsx)("i",{className:"fa-solid fa-xmark"})})]})}),e?(0,i.jsx)("div",{className:"flex w-full items-center justify-center mt-32",children:(0,i.jsx)("img",{src:s.Y.logoLoading,className:"quick-pulse w-48 ",alt:"Loading..."})}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"w-full flex items-center justify-between gap-3 text-center sm:text-sm text-xs bg-zinc-800 border-1 border-y border-zinc-700",children:[(0,i.jsxs)("div",{className:"flex gap-3 pl-16 sm:text-presm text-prexs font-[Oxanium-Light]",children:[(0,i.jsx)("div",{className:"flex flex-col justify-center items-center",children:(0,i.jsxs)("div",{className:"flex justify-center items-center",children:[(0,i.jsx)("div",{className:"w-2.5 h-2.5 bg-[#f7a500] mr-1.5 mb-0.75"}),(0,i.jsxs)("div",{children:[y," Price"]})]})}),(0,i.jsx)("div",{className:"flex flex-col justify-center items-center",children:(0,i.jsxs)("div",{className:"flex justify-center items-center",children:[(0,i.jsx)("div",{className:"w-2.5 h-2.5 bg-[#ccd5e1] mr-1.5 mb-0.75"}),(0,i.jsx)("div",{children:"Hashrate"})]})})]}),(0,i.jsxs)("div",{className:"flex pl-[3px] pr-[3px] border-l border-zinc-700",children:[(0,i.jsx)("button",{className:"px-2 py-2 hover:rounded-sm bg-zinc-800 hover:bg-zinc-700 transition duration-300 flex items-center justify-center ".concat(f?"animate-flip":""),onClick:()=>copyChartToClipboard(C,"Bitcoin Hashrate Index"),children:(0,i.jsx)(m.esY,{className:"text-zinc-300 text-base"})}),(0,i.jsx)("button",{className:"px-2 py-2 hover:rounded-sm bg-zinc-800 hover:bg-zinc-700 transition duration-300 flex items-center justify-center",onClick:()=>downloadChart(C,"Bitcoin Hashrate Index"),children:(0,i.jsx)(m.aBF,{className:"text-zinc-300 text-base"})})]})]}),(0,i.jsxs)("div",{className:"h-[500px] sm:w-full w-full relative flex flex-col mb-12 bg-[#171a1e] px-5 border-1 border-b border-zinc-700",children:[(0,i.jsx)("div",{className:"w-full flex max-[1080px]:flex-col flex-row justify-between max-[1080px]:items-center max-[1080px]:gap-3"}),(0,i.jsx)("div",{className:"h-full",children:(0,i.jsx)("canvas",{ref:C,className:""})}),(0,i.jsx)("div",{id:"cumulative-tooltip",style:{position:"absolute",backgroundColor:"rgba(0, 0, 0, 0.7)",color:"white",padding:"5px",borderRadius:"5px",pointerEvents:"none",display:"none"}})]})]})]})})]})}BitcoinHashrate.layout=o.Z}},function(e){e.O(0,[8391,4738,4817,2510,4396,5372,8688,5912,9774,2888,179],function(){return e(e.s=4997)}),_N_E=e.O()}]);