1import{r as h,j as e,L as y}from"./index-MMs8uNES.js";import{u as C}from"./useQuery-unwT2NKV.js";import{L as S}from"./Layout-B-HLhgsi.js";import{S as M}from"./SEO-C3VXpLBL.js";import"./useTranslation-D6MbF_l4.js";import"./index-DmWAuN3B.js";import"./globe-BybOCho1.js";import"./check-9wyDBs9m.js";const F="/api";function b(t,a=2){return t>=1e12?(t/1e12).toFixed(a)+"T":t>=1e9?(t/1e9).toFixed(a)+"B":t>=1e6?(t/1e6).toFixed(a)+"M":t>=1e3?(t/1e3).toFixed(a)+"K":t.toFixed(a)}function L(t){return t>=1e3?"$"+t.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}):t>=1?"$"+t.toFixed(2):t>=.01?"$"+t.toFixed(4):"$"+t.toFixed(8)}function P({data:t,isPositive:a}){if(!t||t.length<2)return null;const l=Math.min(...t),c=Math.max(...t)-l||1,o=t.map((p,d)=>{const x=d/(t.length-1)*100,g=100-(p-l)/c*100;return`${x},${g}`}).join(" ");return e.jsx("svg",{viewBox:"0 0 100 100",className:"w-24 h-10",preserveAspectRatio:"none",children:e.jsx("polyline",{points:o,fill:"none",stroke:a?"#10B981":"#EF4444",strokeWidth:"2",vectorEffect:"non-scaling-stroke"})})}function B({coins:t}){const[a,l]=h.useState("bitcoin"),[i,c]=h.useState("usd"),[o,p]=h.useState("1"),d=t.find(r=>r.id===a),x=t.find(r=>r.id===i),g=h.useMemo(()=>{const r=(d==null?void 0:d.current_price)||0,u=i==="usd"?1:(x==null?void 0:x.current_price)||1;return(parseFloat(o)||0)*r/u},[o,a,i,d,x]);return e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[e.jsxs("h3",{className:"font-bold text-gray-900 mb-4 flex items-center gap-2",children:[e.jsx("span",{className:"text-xl",children:"ð"}),"Crypto Calculator"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"From"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"number",value:o,onChange:r=>p(r.target.value),className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-sky-500 focus:border-sky-500",placeholder:"Amount"}),e.jsx("select",{value:a,onChange:r=>l(r.target.value),className:"px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-sky-500 focus:border-sky-500",children:t.slice(0,50).map(r=>e.jsx("option",{value:r.id,children:r.symbol.toUpperCase()},r.id))})]})]}),e.jsx("div",{className:"flex justify-center",children:e.jsx("button",{onClick:()=>{i!=="usd"&&(l(i),c(a))},className:"p-2 rounded-full hover:bg-gray-100 transition",children:e.jsx("svg",{className:"w-6 h-6 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4"})})})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"To"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:i==="usd"?L(g):g.toFixed(8),readOnly:!0,className:"flex-1 px-4 py-2 border border-gray-200 rounded-lg bg-gray-50 font-medium"}),e.jsxs("select",{value:i,onChange:r=>c(r.target.value),className:"px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-sky-500 focus:border-sky-500",children:[e.jsx("option",{value:"usd",children:"USD"}),t.slice(0,50).map(r=>e.jsx("option",{value:r.id,children:r.symbol.toUpperCase()},r.id))]})]})]})]})]})}function U(){var N,k,w;const[t,a]=h.useState(""),[l,i]=h.useState("market_cap_rank"),[c,o]=h.useState("asc"),{data:p,isLoading:d,error:x,refetch:g}=C({queryKey:["crypto-prices"],queryFn:async()=>{const s=await fetch(`${F}/crypto/prices`);if(!s.ok)throw new Error("Failed to fetch crypto prices");return s.json()},refetchInterval:5*60*1e3,staleTime:5*60*1e3,refetchOnWindowFocus:!1}),{data:r}=C({queryKey:["crypto-market"],queryFn:async()=>{const s=await fetch(`${F}/crypto/market`);if(!s.ok)throw new Error("Failed to fetch market data");return s.json()},refetchInterval:5*60*1e3,staleTime:5*60*1e3,refetchOnWindowFocus:!1}),u=(p==null?void 0:p.data)||[],m=(r==null?void 0:r.data)||null,$=h.useMemo(()=>{let s=u.filter(n=>n.name.toLowerCase().includes(t.toLowerCase())||n.symbol.toLowerCase().includes(t.toLowerCase()));return s.sort((n,j)=>{let f=n[l]||0,_=j[l]||0;return c==="asc"?f-_:_-f}),s},[u,t,l,c]),v=s=>{l===s?o(c==="asc"?"desc":"asc"):(i(s),o(s==="market_cap_rank"?"asc":"desc"))};return e.jsxs(S,{children:[e.jsx(M,{title:"Crypto Prices & Market Data",description:"Live cryptocurrency prices, market caps, and 24-hour price changes for Bitcoin, Ethereum, and thousands of altcoins. Updated
1in real time.",canonicalPath:"/crypto-prices",keywords:["crypto prices","bitcoin price","ethereum price","cryptocurrency market cap","live crypto data","altcoin prices"]}),e.jsx("div",{className:"bg-gradient-to-br from-emerald-600 to-teal-700 text-white py-12",children:e.jsx("div",{className:"container mx-auto px-4 sm:px-6",children:e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center lg:justify-between gap-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl sm:text-4xl font-bold mb-2",children:"Crypto Prices"}),e.jsx("p",{className:"text-emerald-100",children:"Live cryptocurrency prices powered by CoinGecko"})]}),m&&e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-white/10 rounded-lg p-3",children:[e.jsx("div",{className:"text-emerald-200 text-xs mb-1",children:"Total Market Cap"}),e.jsxs("div",{className:"font-bold",children:["$",b(((N=m.total_market_cap)==null?void 0:N.usd)||0)]})]}),e.jsxs("div",{className:"bg-white/10 rounded-lg p-3",children:[e.jsx("div",{className:"text-emerald-200 text-xs mb-1",children:"24h Volume"}),e.jsxs("div",{className:"font-bold",children:["$",b(((k=m.total_volume)==null?void 0:k.usd)||0)]})]}),e.jsxs("div",{className:"bg-white/10 rounded-lg p-3",children:[e.jsx("div",{className:"text-emerald-200 text-xs mb-1",children:"BTC Dominance"}),e.jsxs("div",{className:"font-bold",children:[(((w=m.market_cap_percentage)==null?void 0:w.btc)||0).toFixed(1),"%"]})]}),e.jsxs("div",{className:"bg-white/10 rounded-lg p-3",children:[e.jsx("div",{className:"text-emerald-200 text-xs mb-1",children:"24h Change"}),e.jsxs("div",{className:`font-bold ${(m.market_cap_change_percentage_24h_usd||0)>=0?"text-green-300":"text-red-300"}`,children:[(m.market_cap_change_percentage_24h_usd||0)>=0?"+":"",(m.market_cap_change_percentage_24h_usd||0).toFixed(2),"%"]})]})]})]})})}),e.jsx("div",{className:"container mx-auto px-4 sm:px-6 py-8",children:e.jsxs("div",{className:"grid lg:grid-cols-4 gap-6",children:[e.jsxs("div",{className:"lg:col-span-3",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 mb-6",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("input",{type:"text",placeholder:"Search coins...",value:t,onChange:s=>a(s.target.value),className:"w-full px-4 py-2 pl-10 border border-gray-300 rounded-lg focus:ring-2 focus:ring-emerald-500 focus:border-emerald-500"}),e.jsx("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})]}),e.jsxs("button",{onClick:()=>g(),className:"px-4 py-2 bg-emerald-600 text-white rounded-lg hover:bg-emerald-700 transition flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"Refresh"]})]}),d?e.jsx("div",{className:"space-y-4",children:[...Array(10)].map((s,n)=>e.jsx("div",{className:"bg-white rounded-lg border border-gray-200 p-4 animate-pulse",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-10 h-10 bg-gray-200 rounded-full"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"h-4 bg-gray-200 rounded w-24 mb-2"}),e.jsx("div",{className:"h-3 bg-gray-200 rounded w-16"})]}),e.jsx("div",{className:"h-6 bg-gray-200 rounded w-20"})]})}
1,n))}):x?e.jsxs("div",{className:"text-center py-12 bg-white rounded-xl border border-gray-200",children:[e.jsx("div",{className:"text-5xl mb-4",children:"â ï¸"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-800 mb-2",children:"Failed to load prices"}),e.jsx("p",{className:"text-gray-600 mb-4",children:"Please try again later"}),e.jsx("button",{onClick:()=>g(),className:"px-4 py-2 bg-emerald-600 text-white rounded-lg hover:bg-emerald-700",children:"Retry"})]}):e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 overflow-hidden",children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider cursor-pointer hover:bg-gray-100",onClick:()=>v("market_cap_rank"),children:"#"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider",children:"Coin"}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-semibold text-gray-600 uppercase tracking-wider",children:"Price"}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-semibold text-gray-600 uppercase tracking-wider cursor-pointer hover:bg-gray-100",onClick:()=>v("price_change_percentage_24h"),children:"24h %"}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-semibold text-gray-600 uppercase tracking-wider hidden md:table-cell",children:"7d Chart"}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-semibold text-gray-600 uppercase tracking-wider hidden lg:table-cell cursor-pointer hover:bg-gray-100",onClick:()=>v("total_volume"),children:"Volume"}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-semibold text-gray-600 uppercase tracking-wider hidden lg:table-cell",children:"Market Cap"}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-semibold text-gray-600 uppercase tracking-wider hidden xl:table-cell"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100",children:$.map(s=>{var n,j;return e.jsxs("tr",{className:"hover:bg-gray-50 transition cursor-pointer",onClick:()=>window.location.href=`/crypto/${s.id}`,children:[e.jsx("td",{className:"px-4 py-4 text-sm text-gray-500",children:s.market_cap_rank}),e.jsx("td",{className:"px-4 py-4",children:e.jsxs(y,{to:`/crypto/${s.id}`,className:"flex items-center gap-3 hover:text-emerald-600",children:[e.jsx("img",{src:s.image,alt:s.name,className:"w-8 h-8 rounded-full"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900",children:s.name}),e.jsx("div",{className:"text-xs text-gray-500 uppercase",children:s.symbol})]})]})}),e.jsx("td",{className:"px-4 py-4 text-right font-medium text-gray-900",children:L(s.current_price)}),e.jsxs("td",{className:`px-4 py-4 text-right font-medium ${s.price_change_percentage_24h>=0?"text-green-600":"text-red-600"}`,children:[s.price_change_percentage_24h>=0?"+":"",(n=s.price_change_percentage_24h)==null?void 0:n.toFixed(2),"%"]}),e.jsx("td",{className:"px-4 py-4 hidden md:table-cell",children:e.jsx("div",{className:"flex justify-end",children:e.jsx(P,{data:((j=s.sparkline_in_7d)==null?void 0:j.price)||[],isPositive:(s.price_change_percentage_7d_in_currency||0)>=0})})}),e.jsxs("td",{className:"px-4 py-4 text-right text-gray-600 hidden lg:table-cell",children:["$",b(s.total_volume)]}),e.jsxs("td",{className:"px-4 py-4 text-right text-gray-600 hidden lg:table-cell",children:["$",b(s.market_cap)]}),e.jsx("td",{className:"px-4 py-4 text-right hidden xl:table-cell",children:e.jsx(y,{to:`/crypto/${s.id}`,className:"text-emerald-600 hover:text-emerald-700 text-sm font-medium",onClick:f=>f.stopPropagation(),children:"View â"})})]},s.id)})})]})}),e.jsxs("div",{className:"px-4 py-3 bg-gray-50 text-center text-sm text-gray-500",children:["Data provided by ",e.jsx("a",{href:"https://www.coingecko.com",target:"_blank",rel:"noopener noreferrer",className:"text-emerald-600 hover:underline",children:"CoinGecko"})]})]})]}),e.jsxs("div",{className:"space-y-6",children:[u.length>0&&e.jsx(B,{coins:u}),e.jsxs("div",{className:"bg-gradient-to-br from-emerald-500 to-teal-600 rounded-xl p-6 text-white",children:[e.jsx("h3",{className:"font-bold mb-2",children:"Accept Crypto Payments"}),e.jsx("p",{className:"text-emerald-100 text-sm mb-4",children:"List your business on WhoTakesCoin and reach crypto-paying customers."}),e.jsx(y,{to:"/create-listing",className:"block w-full py-2 bg-white text-emerald-600 rounded-lg font-medium hover:bg-emerald-50 transition text-center",children:"Get Listed Free"})]}),e.jsxs("div",{className:"bg-gray-50 rounded-xl p-6",children:[e.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"Learn More"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs(y,{to:"/glossary",className:"flex items-center gap-3 text-gray-700 hover:text-emerald-600 transition",children:[e.jsx("span",{className:"text-xl",children:"ð"}),e.jsx("span",{className:"text-sm font-medium",children:"Blockchain Glossary"})]}),e.jsxs(y,{to:"/insights",className:"flex items-center gap-3 text-gray-700 hover:text-emerald-600 transition",children:[e.jsx("span",{className:"text-xl",children:"ð¡"}),e.jsx("span",{className:"text-sm font-medium",children:"Guides & Insights"})]}),e.jsxs(y,{to:"/news",className:"flex items-center gap-3 text-gray-700 hover:text-emerald-600 transition",children:[e.jsx("span",{className:"text-xl",children:"ð°"}),e.jsx("span",{className:"text-sm font-medium",children:"Crypto News"})]})]})]})]})]})})]})}export{U as CryptoPrices};
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.