import"./index-BWkEuLx1.js";import{w}from"./world.zh-BRcXWZRO.js";import{d as S,aB as _,r as p,U as k,a as f,i as x,at as D,aW as R,b as $,o as q,aG as B,k as I}from"./index-DGnN4tUo.js";import{e8 as G,e9 as j,i as J}from"./installCanvasRenderer-DwMtZqT-.js";const O=S({__name:"earth-2d",setup(T){const u=_("dashboard"),l=p(null),r=p(null),n=k(),F=e=>{const a=Number.parseInt(e.slice(1),16),s=a>>16&255,o=a>>8&255,t=a&255;return`${s},${o},${t}`},h=(e,a)=>{const s={},o=e.map(i=>i.countRequests),t=Math.max(...o),c=Math.min(...o),g=F(a);for(const{name:i,countRequests:M}of e){const b=.2+(t===c?1:(M-c)/(t-c))*.7;s[i]=`rgba(${g},${b.toFixed(2)})`}return s},v=new Map(u.value.topCountryStats.map(e=>[e.name,e.countRequests])),d=f(()=>({areaColor:n.darkMode?"#333333":"#F8F8FF",borderColor:n.darkMode?"#FFFFFF":"#DCDCDC"})),m=f(()=>({areaColor:n.darkMode?"#333333":"#F8F8FF",borderColor:n.darkMode?"#FFFFFF":"#DCDCDC"})),C=async()=>{var s;if(!l.value)return;if(await B(),!((s=G("world"))!=null&&s.geoJson)){const t=await(await fetch(w)).json();j("world",t)}r.value=J(l.value,void 0,{renderer:"canvas"});const e=h(u.value.topCountryStats,"#FF7F24"),a=Object.entries(e).map(([o,t])=>({name:o,itemStyle:{areaColor:t}}));r.value.setOption({tooltip:{trigger:"item",formatter:o=>{const t=o.name,c=v.get(t)??0;return`${t}<br/>请求次数: ${c}`}},geo:{map:"world",roam:!1,label:{show:!1},itemStyle:d.value},series:[{type:"map",map:"world",selectedMode:!1,itemStyle:m.value,emphasis:{itemStyle:{areaColor:"#87CEFA"}},data:a}]})},y=()=>{r.value&&r.value.setOption({geo:{itemStyle:d.value},series:[{itemStyle:m.value}]},!1,!1)};return x(()=>{C()}),D(()=>n.darkMode,()=>{y()}),R(()=>{var e;(e=r.value)==null||e.dispose(),r.value=null}),(e,a)=>(q(),$("div",{ref_key:"chartRef",ref:l,class:"map-chart"},null,512))}}),W=I(O,[["__scopeId","data-v-ccd96acd"]]);export{W as default};
