"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[2045],{62045:(t,e,n)=>{n.r(e),n.d(e,{default:()=>y});var s=n(43323),r=n(15078),o=n.n(r),a=n(45697),i=n.n(a),l=n(67190),c=n(45511),p=n(28062),d=n(21341);const u={data:i().arrayOf(i().shape({country_id:i().string,metric:i().number})),width:i().number,height:i().number,country:i().string,linearColorScheme:i().string,mapBaseUrl:i().string,numberFormat:i().string},h={};function m(t,e){const{data:n,width:s,height:r,country:a,linearColorScheme:i,numberFormat:u,colorScheme:m,sliceId:f}=e,y=t,g=(0,l.JB)(u),v=(0,c.Z)().get(i).createLinearScale(function(t,e){let n,s;if(void 0===e)for(const e of t)null!=e&&(void 0===n?e>=e&&(n=s=e):(n>e&&(n=e),s<e&&(s=e)));else{let r=-1;for(let o of t)null!=(o=e(o,++r))&&(void 0===n?o>=o&&(n=s=o):(n>o&&(n=o),s<o&&(s=o)))}return[n,s]}(n,(t=>t.metric))),b=p.getScale(m),x={};n.forEach((t=>{x[t.country_id]=m?b(t.country_id,f):v(t.metric)}));const $=t=>x[t.properties.ISO]||"none",C=o().geo.path(),k=o().select(y);k.classed("superset-legacy-chart-country-map",!0),k.selectAll("*").remove(),y.style.height=`${r}px`,y.style.width=`${s}px`;const N=k.append("svg:svg").attr("width",s).attr("height",r).attr("preserveAspectRatio","xMidYMid meet"),S=N.append("rect").attr("class","background").attr("width",s).attr("height",r),w=N.append("g"),T=w.append("g").classed("map-layer",!0),_=w.append("g").classed("text-layer",!0).attr("transform",`translate(${s/2}, 45)`),M=_.append("text").classed("big-text",!0),A=_.append("text").classed("result-text",!0).attr("dy","1em");let R;const U=function(t){const e=t&&R!==t;let n,o,a;const i=s/2,l=r/2;if(e){const e=C.centroid(t);[n,o]=e,a=4,R=t}else n=i,o=l,a=1,R=null;w.transition().duration(750).attr("transform",`translate(${i},${l})scale(${a})translate(${-n},${-o})`),_.style("opacity",0).attr("transform",`translate(0,0)translate(${n},${e?o-5:45})`).transition().duration(750).style("opacity",1),M.transition().duration(750).style("font-size",e?6:16),A.transition().duration(750).style("font-size",e?16:24)};S.on("click",U);const Z=function(t){let e=$(t);"none"!==e&&(e=o().rgb(e).darker().toString()),o().select(this).style("fill",e),function(t){let e="";t&&t.properties&&(e=t.properties.ID_2?t.properties.NAME_2:t.properties.NAME_1),M.text(e)}(t);const s=n.filter((e=>e.country_id===t.properties.ISO));var r;(r=s).length>0&&A.text(g(r[0].metric))},I=function(){o().select(this).style("fill",$),M.text(""),A.text("")};function O(t){const{features:e}=t,n=o().geo.centroid(t),a=o().geo.mercator().scale(100).center(n).translate([s/2,r/2]);C.projection(a);const i=C.bounds(t),l=100*s/(i[1][0]-i[0][0]),c=100*r/(i[1][1]-i[0][1]),p=l<c?l:c;a.scale(p);const d=C.bounds(t);a.translate([s-(d[0][0]+d[1][0])/2,r-(d[0][1]+d[1][1])/2]),T.selectAll("path").data(e).enter().append("path").attr("d",C).attr("class","region").attr("vector-effect","non-scaling-stroke").style("fill",$).on("mouseenter",Z).on("mouseout",I).on("click",U)}const P=h[a];if(P)O(P);else{const e=d.ZP[a];o().json(e,((e,n)=>{if(e){var s;const e=(null==(s=d.O$.find((t=>t[0]===a)))?void 0:s[1])||a;o().select(t).html(`<div class="alert alert-danger">Could not load map data for ${e}</div>`)}else h[a]=n,O(n)}))}}m.displayName="CountryMap",m.propTypes=u;const f=m,y=(0,s.Z)(f)},43323:(t,e,n)=>{n.d(e,{Z:()=>o});var s=n(67294),r=n(11965);function o(t,e){class n extends s.Component{constructor(t){super(t),this.container=void 0,this.setContainerRef=this.setContainerRef.bind(this)}componentDidMount(){this.execute()}componentDidUpdate(){this.execute()}componentWillUnmount(){this.container=void 0,null!=e&&e.componentWillUnmount&&e.componentWillUnmount.bind(this)()}setContainerRef(t){this.container=t}execute(){this.container&&t(this.container,this.props)}render(){const{id:t,className:e}=this.props;return(0,r.tZ)("div",{ref:this.setContainerRef,id:t,className:e})}}const o=n;return t.displayName&&(o.displayName=t.displayName),t.propTypes&&(o.propTypes={...o.propTypes,...t.propTypes}),t.defaultProps&&(o.defaultProps=t.defaultProps),n}}}]);