1import{a$ as ae,bk as ne,bu as le,bm as ce,b1 as l,b6 as c,b8 as r,b5 as t,ba as n,bb as W,be as C,bc as b,bd as k,bG as $,bv as ie,cs as ue,bY as pe,b2 as de,bg as ge,bh as f,a_ as m,bB as he}from"./V5jIPbSn.js";const ve={class:"gp-calc"},me={class:"gp-card"},ye={key:0,class:"gp-loading"},fe={key:1,class:"gp-error"},_e={key:2,class:"gp-body"},xe={key:0,class:"gp-live-badge"},be={key:1,class:"gp-main-price"},ke={class:"gp-price-value"},we={class:"gp-price-unit"},Ce={class:"gp-selector-row"},Me={class:"gp-selector-group"},$e={class:"gp-label"},Pe={class:"gp-pills"},Fe=["onClick"],ze={class:"gp-pill-flag"},Ae={class:"gp-selector-group"},Ge={class:"gp-label"},Oe={class:"gp-pills"},Re=["onClick"],Se={class:"gp-prices-table"},De=["onClick"],Ne={class:"gp-price-row-left"},Te={class:"gp-flag"},He={class:"gp-code"},Ie={class:"gp-price-row-values"},Je={class:"gp-price-oz"},Le=["title"],Ue={key:2,class:"gp-chart-section"},Be={class:"gp-chart-label"},Ee={class:"gp-chart-wrap"},Ve=["viewBox"],je=["x1","y1","x2","y2"],Ke=["x","y"],Ye=["x","y"],We=["d"],Xe=["d"],qe=["cx","cy","onMouseenter"],Ze=["cx","cy","r","stroke","stroke-width"],Qe={key:0},et=["x","y"],tt=["x","y"],ot={key:3,class:"gp-chart-loading"},rt={class:"gp-calculator"},st={class:"gp-calc-label"},at={class:"gp-calc-row"},nt={class:"gp-calc-input-group"},lt={class:"gp-calc-suffix"},ct=["title"],it={class:"gp-source"},H=31.1035,x=480,M=160,ut=ae({__name:"GoldPrice",setup(pt){const{locale:X}=ne(),I={en:{perOunce:"per troy oz",perGram:"per gram",perKg:"per kg",currency:"Currency",loading:"Fetching live gold prices...",error:"Could not load gold prices",retry:"Retry",livePrice:"Live price",source:"Source: Currency API",weight:"Weight unit",copied:"copied",calculate:"Calculate value",grams:"grams",history:"12-month gold price history",months:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]},de:{perOunce:"pro Feinunze",perGram:"pro Gramm",perKg:"pro kg",currency:"Währung",loading:"Lade aktuelle Goldpreise...",error:"Goldpreise konnten nicht geladen werden",retry:"Erneut versuchen",livePrice:"Aktueller Preis",source:"Quelle: Currency API",weight:"Gewichtseinheit",copied:"kopiert",calculate:"Wert berechnen",grams:"Gramm",history:"12-Monats Goldpreis-Verlauf",months:["Jan","Feb","Mär","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"]},fr:{perOunce:"par once troy",perGram:"par gramme",perKg:"par kg",currency:"Devise",loading:"Chargement des prix de l'or...",error:"Impossible de charger les prix",retry:"Réessayer",livePrice:"Prix actuel",source:"Source : Currency API",weight:"Unité de poids",copied:"copié",calculate:"Calculer la valeur",grams:"grammes",history:"Historique prix de l'or 12 mois",months:["Jan","Fév","Mar","Avr","Mai","Jun","Jul","Aoû","Sep","Oct","Nov","Déc"]},it:{perOunce:"per oncia troy",perGram:"per grammo",perKg:"per kg",currency:"Valuta",loading:"Caricamento prezzi dell'oro...",error:"Impossibile caricare i prezzi",retry:"Riprova",livePrice:"Prezzo attuale",source:"Fonte: Currency API",weight:"Unità di peso",copied:"copiato",calculate:"Calcola il valore",grams:"grammi",history:"Storico prezzo oro 12 mesi",months:["Gen","Feb","Mar","Apr","Mag","Giu","Lug","Ago","Set","Ott","Nov","Dic"]},es:{perOunce:"por onza troy",perGram:"por gramo",perKg:"por kg",currency:"Divisa",loading:"Cargando precios del oro...",error:"No se pudieron cargar los precios",retry:"Reintentar",livePrice:"Precio actual",source:"Fuente: Currency API",weight:"Unidad de peso",copied:"copiado",calculate:"Calcular valor",grams:"gramos",history:"Historial precio del oro 12 meses",months:["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"]},pt:{perOunce:"por onça troy",perGram:"por grama",perKg:"por kg",currency:"Moeda",loading:"A carregar preços do ouro...",error:"Não foi possÃvel carregar os preços",retry:"Tentar novamente",livePrice:"Preço atual",source:"Fonte: Currency API",weight:"Unidade de peso",copied:"copiado",calculate:"Calcular valor",grams:"gramas",history:"Histórico preço do ouro 12 meses",months:["Jan","Fev","Mar","Abr","Mai","Jun","Jul","Ago","Set","Out","Nov","Dez"]}},p=f(()=>
1I[X.value]||I.en),J=[{code:"CHF",flag:"ð¨ð",symbol:"CHF"},{code:"EUR",flag:"ðªðº",symbol:"EUR"},{code:"USD",flag:"ðºð¸",symbol:"USD"}],L=[{key:"oz",divisor:1},{key:"g",divisor:H},{key:"kg",divisor:H/1e3}],h=m("CHF"),P=m("oz"),G=m({}),O=m(!0),F=m(""),z=m("100"),y=m([]),A=m(!1),d=m(null),U=m(""),R=m(!1);let B;function q(o){return`${o.getFullYear()}-${String(o.getMonth()+1).padStart(2,"0")}-${String(o.getDate()).padStart(2,"0")}`}async function E(){O.value=!0,F.value="";try{const o=await $fetch("https://latest.currency-api.pages.dev/v1/currencies/xau.json");if(o?.xau)G.value=o.xau;else throw new Error("Invalid response")}catch{try{const o=await $fetch("https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/xau.min.json");if(o?.xau)G.value=o.xau;else throw new Error("Invalid response")}catch{F.value=p.value.error}}finally{O.value=!1}}async function V(){A.value=!0;const o=[],s=new Date,e=[];for(let g=11;g>=0;g--){const i=new Date(s.getFullYear(),s.getMonth()-g,1);e.push(i)}const u=await Promise.allSettled(e.map(g=>$fetch(`https://${q(g)}.currency-api.pages.dev/v1/currencies/xau.json`))),v=h.value.toLowerCase();e.forEach((g,i)=>{const _=u[i];_.status==="fulfilled"&&_.value?.xau?.[v]&&o.push({date:g,rate:_.value.xau[v]})}),y.value=o,A.value=!1}function S(o){return G.value[o.toLowerCase()]??null}const D=f(()=>{const o=S(h.value);if(!o)return null;const s=L.find(e=>e.key===P.value);return o/s.divisor}),Z=f(()=>J.map(o=>{const s=S(o.code);return{...o,priceOz:s}})),Q=f(()=>({oz:p.value.perOunce,g:p.value.perGram,kg:p.value.perKg})[P.value]),w=f(()=>{const o=Number.parseFloat(z.value);if(Number.isNaN(o)||o<=0)return null;const s=S(h.value);return s?o*(s/H):null}),a={top:10,right:10,bottom:28,left:55},N=f(()=>{if(y.value.length<2)return"";const o=y.value,s=Math.min(...o.map(i=>i.rate)),u=Math.max(...o.map(i=>i.rate))-s||1,v=x-a.left-a.right,g=M-a.top-a.bottom;return o.map((i,_)=>{const re=a.left+_/(o.length-1)*v,se=a.top+g-(i.rate-s)/u*g;return`${_===0?"M":"L"}${re.toFixed(1)},${se.toFixed(1)}`}).join(" ")}),ee=f(()=>{if(!N.value)return"";const o=x-a.left-a.right,s=a.left+o,e=a.left,u=M-a.bottom;return`${N.value} L${s},${u} L${e},${u} Z`}),te=f(()=>{if(y.value.length<2)return[];const o=y.value,s=Math.min(...o.map(i=>i.rate)),u=Math.max(...o.map(i=>i.rate))-s||1,v=x-a.left-a.right,g=M-a.top-a.bottom;return o.map((i,_)=>({x:a.left+_/(o.length-1)*v,y:a.top+g-(i.rate-s)/u*g,rate:i.rate,label:`${p.value.months[i.date.getMonth()]} ${i.date.getFullYear()}`}))}),j=f(()=>{if(y.value.length<2)return[];const o=y.value,s=Math.min(...o.map(v=>v.rate)),e=Math.max(...o.map(v=>v.rate)),u=M-a.top-a.bottom;return Array.from({length:5},(v,g)=>{const i=s+(e-s)*(g/4);return{y:a.top+u-g/4*u,label:i>=100?i.toFixed(0):i.toFixed(2)}})}),oe=f(()=>{if(y.value.length<2)return[];const o=y.value,s=x-a.left-a.right;return o.map((e,u)=>({x:a.left+u/(o.length-1)*s,label:p.value.months[e.date.getMonth()],show:u%3===0||u===o.length-1})).filter(e=>e.show)});function K(o){d.value=o?{x:o.x,y:o.y,rate:o.rate,date:o.label}:null}function T(o,s){const e=o>=10?o.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g,"â"):o.toFixed(4);return`${s} ${e}`}function Y(o,s){const e=o.toFixed(2);navigator.clipboard.writeText(e).catch(()=>{}),U.value=`${s} ${e} ${p.value.copied}!`,R.value=!0,clearTimeout(B),B=setTimeout(()=>{R.value=!1},1800)}return le(h,()=>{A.value||V()}),ce(()=>{E(),V()}),(o,s)=>(l(),c("div",ve,[r("div",me,[t(O)?(l(),c("div",ye,[s[3]||(s[3]=r("div",{class:"gp-spinner"},null,-1)),r("span",null,n(t(p).loading),1)])):t(F)?(l(),c("div",fe,[r("span",null,n(t(F)),1),r("button",{class:"gp-retry-btn",onClick:E},n(t(p).retry),1)])):(l(),c("div",_e,[t(D)?(l(),c("div",xe,[s[4]||(s[4]=r("span",{class:"gp-live-dot"},null,-1)),W(" "+n(t(p).livePrice),1)])):C("",!0),t(D)?(l(),c("div",be,[r("span",ke,n(T(t(D),t(h))),1),r("span",we,n(t(Q)),1)])):C("",!0),r("div",Ce,[r("div",Me,[r("label",$e,n(t(p).currency),1),r("div",Pe,[(l(),c(b,null,k(J,e=>r("button",{key:e.code,class:$(["gp-pill",{active:t(h)===e.code}]),onClick:u=>h.value=e.code},[r("span",ze,n(e.flag),1),W(" "+n(e.code),1)],10,Fe)),64))])]),r("div",Ae,[r("label",Ge,n(t(p).weight),1),r("div",Oe,[(l(),c(b,null,k(L,e=>
1r("button",{key:e.key,class:$(["gp-pill",{active:t(P)===e.key}]),onClick:u=>P.value=e.key},n(e.key),11,Re)),64))])])]),r("div",Se,[(l(!0),c(b,null,k(t(Z),e=>(l(),c("div",{key:e.code,class:$(["gp-price-row",{highlight:e.code===t(h)}]),onClick:u=>e.priceOz&&Y(e.priceOz,e.code)},[r("span",Ne,[r("span",Te,n(e.flag),1),r("span",He,n(e.code),1)]),r("span",Ie,[r("span",Je,n(e.priceOz?T(e.priceOz,e.symbol):"â"),1),s[5]||(s[5]=r("span",{class:"gp-price-label"},"/ oz",-1))]),e.priceOz?(l(),c("button",{key:0,class:"gp-copy-btn",title:t(p).copied},[...s[6]||(s[6]=[r("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[r("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),r("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})],-1)])],8,Le)):C("",!0)],10,De))),128))]),t(y).length>=2?(l(),c("div",Ue,[r("div",Be,n(t(p).history)+" ("+n(t(h))+") ",1),r("div",Ee,[(l(),c("svg",{viewBox:`0 0 ${x} ${M}`,class:"gp-chart-svg",onMouseleave:s[0]||(s[0]=e=>K(null))},[(l(!0),c(b,null,k(t(j),e=>(l(),c("line",{key:e.label,x1:a.left,y1:e.y,x2:x-a.right,y2:e.y,stroke:"#e5e7eb","stroke-width":"0.5"},null,8,je))),128)),(l(!0),c(b,null,k(t(j),e=>(l(),c("text",{key:`yl-${e.label}`,x:a.left-6,y:e.y+3,"text-anchor":"end",class:"gp-chart-text"},n(e.label),9,Ke))),128)),(l(!0),c(b,null,k(t(oe),e=>(l(),c("text",{key:`xl-${e.x}`,x:e.x,y:M-4,"text-anchor":"middle",class:"gp-chart-text"},n(e.label),9,Ye))),128)),r("path",{d:t(ee),fill:"url(#gpGrad)"},null,8,We),r("path",{d:t(N),fill:"none",stroke:"#b8860b","stroke-width":"2","stroke-linejoin":"round"},null,8,Xe),s[7]||(s[7]=r("defs",null,[r("linearGradient",{id:"gpGrad",x1:"0",y1:"0",x2:"0",y2:"1"},[r("stop",{offset:"0%","stop-color":"#b8860b","stop-opacity":"0.15"}),r("stop",{offset:"100%","stop-color":"#b8860b","stop-opacity":"0.01"})])],-1)),(l(!0),c(b,null,k(t(te),(e,u)=>(l(),c("g",{key:u},[r("circle",{cx:e.x,cy:e.y,r:"12",fill:"transparent",onMouseenter:v=>K(e)},null,40,qe),r("circle",{cx:e.x,cy:e.y,r:t(d)&&t(d).x===e.x?4:2.5,fill:"#b8860b",stroke:t(d)&&t(d).x===e.x?"#fff":"none","stroke-width":t(d)&&t(d).x===e.x?2:0,class:"gp-chart-dot"},null,8,Ze)]))),128)),t(d)?(l(),c("g",Qe,[r("rect",{x:Math.min(Math.max(t(d).x-55,0),x-a.right-110),y:t(d).y-34,width:"110",height:"24",rx:"4",fill:"#1a1a1a"},null,8,et),r("text",{x:Math.min(Math.max(t(d).x,55),x-a.right-55),y:t(d).y-18,"text-anchor":"middle",fill:"#fff","font-size":"10","font-weight":"600","font-family":"ui-monospace, monospace"},n(t(d).date)+": "+n(t(h))+" "+n(t(d).rate>=100?t(d).rate.toFixed(0):t(d).rate.toFixed(2)),9,tt)])):C("",!0)],40,Ve))])])):t(A)?(l(),c("div",ot,[...s[8]||(s[8]=[r("div",{class:"gp-spinner-sm"},null,-1)])])):C("",!0),r("div",rt,[r("div",st,n(t(p).calculate),1),r("div",at,[r("div",nt,[ie(r("input",{"onUpdate:modelValue":s[1]||(s[1]=e=>pe(z)?z.value=e:null),class:"gp-calc-input",type:"number",min:"0",step:"1",placeholder:"100",autocomplete:"off"},null,512),[[ue,t(z)]]),r("span",lt,n(t(p).grams),1)]),s[10]||(s[10]=r("div",{class:"gp-calc-equals"}," = ",-1)),r("div",{class:$(["gp-calc-result",{"has-value":t(w)}]),onClick:s[2]||(s[2]=e=>t(w)&&Y(t(w),t(h)))},[r("span",null,n(t(w)?T(t(w),t(h)):`${t(h)}Â 0.00`),1),t(w)?(l(),c("button",{key:0,class:"gp-copy-btn",title:t(p).copied},[...s[9]||(s[9]=[r("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[r("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),r("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})],-1)])],8,ct)):C("",!0)],2)])]),r("div",it,n(t(p).source),1)]))]),(l(),de(ge,{to:"body"},[r("div",{class:$(["gp-toast",{show:t(R)}])},n(t(U)),3)]))]))}}),gt=Object.assign(he(ut,[["__scopeId","data-v-65f5d1d5"]]),{__name:"GoldPrice"});export{gt as default};
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.