Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nivo/geo

Package Overview
Dependencies
Maintainers
2
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nivo/geo - npm Package Compare versions

Comparing version 0.83.0 to 0.83.1

2

./dist/nivo-geo.cjs.js

@@ -1,2 +0,2 @@

"use strict";var e=require("react"),r=require("@nivo/core"),o=require("@nivo/tooltip"),t=require("prop-types"),i=require("@nivo/colors"),n=require("lodash"),a=require("d3-format"),u=require("d3-geo"),l=require("@nivo/legends"),s=require("react/jsx-runtime");function c(){return c=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&(e[t]=o[t])}return e},c.apply(this,arguments)}var d={azimuthalEqualArea:u.geoAzimuthalEqualArea,azimuthalEquidistant:u.geoAzimuthalEquidistant,gnomonic:u.geoGnomonic,orthographic:u.geoOrthographic,stereographic:u.geoStereographic,equalEarth:u.geoEqualEarth,equirectangular:u.geoEquirectangular,mercator:u.geoMercator,transverseMercator:u.geoTransverseMercator,naturalEarth1:u.geoNaturalEarth1},p=function(o){var t=o.width,n=o.height,a=o.projectionType,l=o.projectionScale,s=o.projectionTranslation,c=o.projectionRotation,p=o.fillColor,h=o.borderWidth,f=o.borderColor,g=e.useMemo((function(){return d[a]().scale(l).translate([t*s[0],n*s[1]]).rotate(c)}),[t,n,a,l,s[0],s[1],c[0],c[1],c[2]]),v=e.useMemo((function(){return u.geoPath(g)}),[g]),C=e.useMemo((function(){return u.geoGraticule()})),m=r.useTheme(),b=e.useMemo((function(){return"function"==typeof h?h:function(){return h}}),[h]),j=i.useInheritedColor(f,m),y=e.useMemo((function(){return"function"==typeof p?p:function(){return p}}),[p]);return{projection:g,path:v,graticule:C,getBorderWidth:b,getBorderColor:j,getFillColor:y}},h=function(o){var t=o.features,i=o.data,u=o.match,s=o.label,d=o.value,p=o.valueFormat,h=o.colors,f=o.unknownColor,g=o.domain,v=e.useMemo((function(){return n.isFunction(u)?u:function(e,r){var o=n.get(e,u),t=n.get(r,u);return o&&o===t}}),[u]),C=e.useMemo((function(){return n.isFunction(s)?s:function(e){return n.get(e,s)}}),[s]),m=e.useMemo((function(){return n.isFunction(d)?d:function(e){return n.get(e,d)}}),[d]),b=e.useMemo((function(){return void 0===p?function(e){return e}:n.isFunction(p)?p:a.format(p)}),[p]),j=e.useMemo((function(){return r.guessQuantizeColorScale(h).domain(g)}),[h,g]),y=e.useMemo((function(){return function(e){return void 0===e.value?f:j(e.value)}}),[j,f]),R=e.useMemo((function(){return t.map((function(e){var r=i.find((function(r){return v(e,r)})),o=m(r);if(r){var t=c({},e,{data:r,value:o,formattedValue:b(o)});return t.color=y(t),t.label=C(t),t}return e}))}),[t,i,v,m,b,y]),q=l.useQuantizeColorScaleLegendData({scale:j,valueFormat:b});return{colorScale:j,getFillColor:y,boundFeatures:R,valueFormatter:b,legendData:q}},f=e.memo((function(e){var r=e.feature;return void 0===r.data?null:s.jsx(o.BasicTooltip,{id:r.label,color:r.color,enableChip:!0,value:r.formattedValue})}));f.propTypes={feature:t.object.isRequired},f.displayName="ChoroplethTooltip";var g={features:t.arrayOf(t.shape({id:t.string.isRequired,type:t.oneOf(["Feature"]).isRequired,properties:t.object,geometry:t.object.isRequired})).isRequired,projectionType:t.oneOf(Object.keys(d)).isRequired,projectionScale:t.number.isRequired,projectionTranslation:t.arrayOf(t.number).isRequired,projectionRotation:t.arrayOf(t.number).isRequired,fillColor:t.oneOfType([t.string,t.func]).isRequired,borderWidth:t.oneOfType([t.number,t.func]).isRequired,borderColor:i.inheritedColorPropType.isRequired,enableGraticule:t.bool.isRequired,graticuleLineWidth:t.number.isRequired,graticuleLineColor:t.string.isRequired,isInteractive:t.bool.isRequired,onMouseEnter:t.func.isRequired,onMouseMove:t.func.isRequired,onMouseLeave:t.func.isRequired,onClick:t.func.isRequired,tooltip:t.any,layers:t.arrayOf(t.oneOfType([t.oneOf(["graticule","features"]),t.func])).isRequired},v=c({},g,{role:t.string.isRequired}),C=c({pixelRatio:t.number.isRequired},g),m={data:t.arrayOf(t.object).isRequired,match:t.oneOfType([t.string,t.func]).isRequired,label:t.oneOfType([t.string,t.func]).isRequired,value:t.oneOfType([t.string,t.func]).isRequired,valueFormat:t.oneOfType([t.string,t.func]),colors:r.quantizeColorScalePropType.isRequired,domain:t.arrayOf(t.number).isRequired,unknownColor:t.string.isRequired,layers:t.arrayOf(t.oneOfType([t.oneOf(["graticule","features","legends"]),t.func])).isRequired},b=c({},v,m,{role:t.string.isRequired}),j=c({},C,m),y={projectionType:"mercator",projectionScale:100,projectionTranslation:[.5,.5],projectionRotation:[0,0,0],enableGraticule:!1,graticuleLineWidth:.5,graticuleLineColor:"#999999",fillColor:"#dddddd",borderWidth:0,borderColor:"#000000",isInteractive:!0,onMouseEnter:function(){},onMouseLeave:function(){},onMouseMove:function(){},onClick:function(){},layers:["graticule","features"],legends:[],fill:[],defs:[]},R=c({},y,{role:"img"}),q=c({},y,{pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1}),M={match:"id",label:"id",value:"value",colors:"PuBuGn",unknownColor:"#999",tooltip:f,layers:["graticule","features","legends"]},T=c({},R,M,{role:"img"}),x=c({},q,M),k=e.memo((function(e){var r=e.path,o=e.graticule,t=e.lineWidth,i=e.lineColor;return s.jsx("path",{fill:"none",strokeWidth:t,stroke:i,d:r(o())})}));k.propTypes={path:t.func.isRequired,graticule:t.func.isRequired,lineWidth:t.number.isRequired,lineColor:t.string.isRequired},k.displayName="GeoGraticule";var W=e.memo((function(e){var r,o=e.feature,t=e.path,i=e.fillColor,n=e.borderWidth,a=e.borderColor,u=e.onClick,l=e.onMouseEnter,c=e.onMouseMove,d=e.onMouseLeave;return s.jsx("path",{fill:null!=(r=null==o?void 0:o.fill)?r:i,strokeWidth:n,stroke:a,strokeLinejoin:"bevel",d:t(o),onMouseEnter:function(e){return l(o,e)},onMouseMove:function(e){return c(o,e)},onMouseLeave:function(e){return d(o,e)},onClick:function(e){return u(o,e)}},o.id)}));W.propTypes={feature:t.shape({id:t.string.isRequired,type:t.oneOf(["Feature"]).isRequired,properties:t.object,geometry:t.object.isRequired}).isRequired,path:t.func.isRequired,fillColor:t.string.isRequired,borderWidth:t.number.isRequired,borderColor:t.string.isRequired,onMouseEnter:t.func.isRequired,onMouseMove:t.func.isRequired,onMouseLeave:t.func.isRequired,onClick:t.func.isRequired},W.displayName="GeoMapFeature";var w=e.memo((function(t){var i=t.width,n=t.height,a=t.margin,u=t.features,l=t.layers,c=t.projectionType,d=t.projectionScale,h=t.projectionTranslation,f=t.projectionRotation,g=t.fillColor,v=t.borderWidth,C=t.borderColor,m=t.enableGraticule,b=t.graticuleLineWidth,j=t.graticuleLineColor,y=t.isInteractive,R=t.onClick,q=t.tooltip,M=t.role,T=r.useDimensions(i,n,a),x=T.margin,w=T.outerWidth,F=T.outerHeight,E=p({width:i,height:n,projectionType:c,projectionScale:d,projectionTranslation:h,projectionRotation:f,fillColor:g,borderWidth:v,borderColor:C}),S=E.graticule,O=E.path,L=E.getFillColor,G=E.getBorderWidth,P=E.getBorderColor,B=r.useTheme(),D=o.useTooltip(),I=D.showTooltipFromEvent,N=D.hideTooltip,z=e.useCallback((function(e,r){return y&&R&&R(e,r)}),[y,R]),H=e.useCallback((function(e,r){return y&&q&&I(s.jsx(q,{feature:e}),r)}),[y,I,q]),A=e.useCallback((function(e,r){return y&&q&&I(s.jsx(q,{feature:e}),r)}),[y,I,q]),K=e.useCallback((function(){return y&&N()}),[y,N]);return s.jsx(r.SvgWrapper,{width:w,height:F,margin:x,theme:B,role:M,children:l.map((function(r,o){return"graticule"===r?!0!==m?null:s.jsx(k,{path:O,graticule:S,lineWidth:b,lineColor:j},"graticule"):"features"===r?s.jsx(e.Fragment,{children:u.map((function(e){return s.jsx(W,{feature:e,path:O,fillColor:L(e),borderWidth:G(e),borderColor:P(e),onMouseEnter:H,onMouseMove:A,onMouseLeave:K,onClick:z},e.id)}))},"features"):s.jsx(e.Fragment,{children:r(t)},o)}))})}));w.displayName="GeoMap",w.propTypes=v,w.defaultProps=R;var F=r.withContainer(w),E=function(e,o,t,i){var n=r.getRelativeCursor(o,e),a=n[0],l=n[1];return t.find((function(e){return u.geoContains(e,i.invert([a,l]))}))},S=e.memo((function(t){var i=t.width,n=t.height,a=t.margin,u=t.pixelRatio,l=t.features,c=t.layers,d=t.projectionType,h=t.projectionScale,f=t.projectionTranslation,g=t.projectionRotation,v=t.fillColor,C=t.borderWidth,m=t.borderColor,b=t.enableGraticule,j=t.graticuleLineWidth,y=t.graticuleLineColor,R=t.isInteractive,q=t.onClick,M=t.onMouseMove,T=t.tooltip,x=e.useRef(null),k=r.useTheme(),W=r.useDimensions(i,n,a),w=W.margin,F=W.outerWidth,S=W.outerHeight,O=p({width:i,height:n,projectionType:d,projectionScale:h,projectionTranslation:f,projectionRotation:g,fillColor:v,borderWidth:C,borderColor:m}),L=O.projection,G=O.graticule,P=O.path,B=O.getFillColor,D=O.getBorderWidth,I=O.getBorderColor;e.useEffect((function(){if(x){x.current.width=F*u,x.current.height=S*u;var e=x.current.getContext("2d");e.scale(u,u),e.fillStyle=k.background,e.fillRect(0,0,F,S),e.translate(w.left,w.top),P.context(e),c.forEach((function(r){"graticule"===r?!0===b&&(e.lineWidth=j,e.strokeStyle=y,e.beginPath(),P(G()),e.stroke()):"features"===r?l.forEach((function(r){e.beginPath(),P(r),e.fillStyle=B(r),e.fill();var o=D(r);o>0&&(e.strokeStyle=I(r),e.lineWidth=o,e.stroke())})):r(e,t)}))}}),[x,F,S,w,u,k,P,G,B,D,I,l,c]);var N=o.useTooltip(),z=N.showTooltipFromEvent,H=N.hideTooltip,A=e.useCallback((function(e){if(R&&T){var r=E(e,x.current,l,L);r?z(s.jsx(T,{feature:r}),e):H(),M&&M(r||null,e)}}),[z,H,R,T,x,l,L]),K=e.useCallback((function(){return R&&H()}),[R,H]),Q=e.useCallback((function(e){if(R&&q){var r=E(e,x.current,l,L);r&&q(r,e)}}),[R,x,l,L,q]);return s.jsx("canvas",{ref:x,width:F*u,height:S*u,style:{width:F,height:S,cursor:R?"auto":"normal"},onMouseMove:A,onMouseLeave:K,onClick:Q})}));S.displatName="GeoMapCanvas",S.propTypes=C,S.defaultProps=q;var O=r.withContainer(S),L=e.memo((function(t){var i=t.width,n=t.height,a=t.margin,u=t.features,d=t.data,f=t.match,g=t.label,v=t.value,C=t.valueFormat,m=t.projectionType,b=t.projectionScale,j=t.projectionTranslation,y=t.projectionRotation,R=t.colors,q=t.domain,M=t.unknownColor,x=t.borderWidth,w=t.borderColor,F=t.enableGraticule,E=t.graticuleLineWidth,S=t.graticuleLineColor,O=t.layers,L=t.legends,G=t.isInteractive,P=t.onClick,B=t.tooltip,D=t.role,I=t.defs,N=void 0===I?T.defs:I,z=t.fill,H=void 0===z?T.fill:z,A=r.useDimensions(i,n,a),K=A.margin,Q=A.outerWidth,V=A.outerHeight,J=p({width:i,height:n,projectionType:m,projectionScale:b,projectionTranslation:j,projectionRotation:y,fillColor:function(){},borderWidth:x,borderColor:w}),U=J.graticule,X=J.path,Y=J.getBorderWidth,Z=J.getBorderColor,$=h({features:u,data:d,match:f,label:g,value:v,valueFormat:C,colors:R,unknownColor:M,domain:q}),_=$.getFillColor,ee=$.boundFeatures,re=$.legendData,oe=r.useTheme(),te=r.bindDefs(N,ee,H,{dataKey:"data",targetKey:"fill"}),ie=o.useTooltip(),ne=ie.showTooltipFromEvent,ae=ie.hideTooltip,ue=e.useCallback((function(e,r){return G&&P&&P(e,r)}),[G,P]),le=e.useCallback((function(e,r){return G&&B&&ne(s.jsx(B,{feature:e}),r)}),[G,ne,B]),se=e.useCallback((function(e,r){return G&&B&&ne(s.jsx(B,{feature:e}),r)}),[G,ne,B]),ce=e.useCallback((function(){return G&&ae()}),[G,ae]);return s.jsx(r.SvgWrapper,{width:Q,height:V,margin:K,theme:oe,defs:te,role:D,children:O.map((function(r,o){return"graticule"===r?!0!==F?null:s.jsx(k,{path:X,graticule:U,lineWidth:E,lineColor:S},"graticule"):"features"===r?s.jsx(e.Fragment,{children:ee.map((function(e){return s.jsx(W,{feature:e,path:X,fillColor:_(e),borderWidth:Y(e),borderColor:Z(e),onMouseEnter:le,onMouseMove:se,onMouseLeave:ce,onClick:ue},e.id)}))},"features"):"legends"===r?L.map((function(e,r){return s.jsx(l.BoxLegendSvg,c({containerWidth:i,containerHeight:n,data:re},e),r)})):s.jsx(e.Fragment,{children:r({})},o)}))})}));L.displayName="Choropleth",L.propTypes=b,L.defaultProps=T;var G=r.withContainer(L),P=function(e,o,t,i){var n=r.getRelativeCursor(o,e),a=n[0],l=n[1];return t.find((function(e){return u.geoContains(e,i.invert([a,l]))}))},B=e.memo((function(t){var i=t.width,n=t.height,a=t.margin,u=t.pixelRatio,d=t.features,f=t.data,g=t.match,v=t.label,C=t.value,m=t.valueFormat,b=t.projectionType,j=t.projectionScale,y=t.projectionTranslation,R=t.projectionRotation,q=t.colors,M=t.domain,T=t.unknownColor,x=t.borderWidth,k=t.borderColor,W=t.enableGraticule,w=t.graticuleLineWidth,F=t.graticuleLineColor,E=t.layers,S=t.legends,O=t.isInteractive,L=t.onClick,G=t.onMouseMove,B=t.tooltip,D=e.useRef(null),I=r.useTheme(),N=r.useDimensions(i,n,a),z=N.margin,H=N.outerWidth,A=N.outerHeight,K=p({width:i,height:n,projectionType:b,projectionScale:j,projectionTranslation:y,projectionRotation:R,fillColor:function(){},borderWidth:x,borderColor:k}),Q=K.projection,V=K.graticule,J=K.path,U=K.getBorderWidth,X=K.getBorderColor,Y=h({features:d,data:f,match:g,label:v,value:C,valueFormat:m,colors:q,unknownColor:T,domain:M}),Z=Y.getFillColor,$=Y.boundFeatures,_=Y.legendData;e.useEffect((function(){if(D){D.current.width=H*u,D.current.height=A*u;var e=D.current.getContext("2d");e.scale(u,u),e.fillStyle=I.background,e.fillRect(0,0,H,A),e.translate(z.left,z.top),J.context(e),E.forEach((function(r){"graticule"===r?!0===W&&(e.lineWidth=w,e.strokeStyle=F,e.beginPath(),J(V()),e.stroke()):"features"===r?$.forEach((function(r){e.beginPath(),J(r),e.fillStyle=Z(r),e.fill();var o=U(r);o>0&&(e.strokeStyle=X(r),e.lineWidth=o,e.stroke())})):"legends"===r&&S.forEach((function(r){l.renderLegendToCanvas(e,c({},r,{data:_,containerWidth:i,containerHeight:n,theme:I}))}))}))}}),[D,H,A,z,u,I,J,V,Z,U,X,$,S,E]);var ee=o.useTooltip(),re=ee.showTooltipFromEvent,oe=ee.hideTooltip,te=e.useCallback((function(e){if(O&&B){var r=P(e,D.current,$,Q);r?re(s.jsx(B,{feature:r}),e):oe(),G&&G(r||null,e)}}),[re,oe,O,B,D,$,Q]),ie=e.useCallback((function(){return O&&oe()}),[O,oe]),ne=e.useCallback((function(e){if(O&&L){var r=P(e,D.current,$,Q);r&&L(r,e)}}),[O,D,$,Q,L]);return s.jsx("canvas",{ref:D,width:H*u,height:A*u,style:{width:H,height:A,cursor:O?"auto":"normal"},onMouseMove:te,onMouseLeave:ie,onClick:ne})}));B.displayName="ChoroplethCanvas",B.propTypes=j,B.defaultProps=x;var D=r.withContainer(B);exports.Choropleth=G,exports.ChoroplethCanvas=D,exports.ChoroplethCanvasDefaultProps=x,exports.ChoroplethCanvasPropTypes=j,exports.ChoroplethDefaultProps=T,exports.ChoroplethPropTypes=b,exports.GeoMap=F,exports.GeoMapCanvas=O,exports.GeoMapCanvasDefaultProps=q,exports.GeoMapCanvasPropTypes=C,exports.GeoMapDefaultProps=R,exports.GeoMapPropTypes=v,exports.ResponsiveChoropleth=function(e){return s.jsx(r.ResponsiveWrapper,{children:function(r){var o=r.width,t=r.height;return s.jsx(G,c({width:o,height:t},e))}})},exports.ResponsiveChoroplethCanvas=function(e){return s.jsx(r.ResponsiveWrapper,{children:function(r){var o=r.width,t=r.height;return s.jsx(D,c({width:o,height:t},e))}})},exports.ResponsiveGeoMap=function(e){return s.jsx(r.ResponsiveWrapper,{children:function(r){var o=r.width,t=r.height;return s.jsx(F,c({width:o,height:t},e))}})},exports.ResponsiveGeoMapCanvas=function(e){return s.jsx(r.ResponsiveWrapper,{children:function(r){var o=r.width,t=r.height;return s.jsx(O,c({width:o,height:t},e))}})},exports.projectionById=d,exports.useChoropleth=h,exports.useGeoMap=p;
"use strict";var e=require("react"),r=require("@nivo/core"),o=require("@nivo/tooltip"),t=require("prop-types"),i=require("@nivo/colors"),n=require("lodash/isFunction"),a=require("lodash/get"),u=require("d3-format"),l=require("d3-geo"),s=require("@nivo/legends"),c=require("react/jsx-runtime");function d(){return d=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&(e[t]=o[t])}return e},d.apply(this,arguments)}var p={azimuthalEqualArea:l.geoAzimuthalEqualArea,azimuthalEquidistant:l.geoAzimuthalEquidistant,gnomonic:l.geoGnomonic,orthographic:l.geoOrthographic,stereographic:l.geoStereographic,equalEarth:l.geoEqualEarth,equirectangular:l.geoEquirectangular,mercator:l.geoMercator,transverseMercator:l.geoTransverseMercator,naturalEarth1:l.geoNaturalEarth1},h=function(o){var t=o.width,n=o.height,a=o.projectionType,u=o.projectionScale,s=o.projectionTranslation,c=o.projectionRotation,d=o.fillColor,h=o.borderWidth,f=o.borderColor,g=e.useMemo((function(){return p[a]().scale(u).translate([t*s[0],n*s[1]]).rotate(c)}),[t,n,a,u,s[0],s[1],c[0],c[1],c[2]]),v=e.useMemo((function(){return l.geoPath(g)}),[g]),C=e.useMemo((function(){return l.geoGraticule()})),m=r.useTheme(),b=e.useMemo((function(){return"function"==typeof h?h:function(){return h}}),[h]),j=i.useInheritedColor(f,m),y=e.useMemo((function(){return"function"==typeof d?d:function(){return d}}),[d]);return{projection:g,path:v,graticule:C,getBorderWidth:b,getBorderColor:j,getFillColor:y}},f=function(o){var t=o.features,i=o.data,l=o.match,c=o.label,p=o.value,h=o.valueFormat,f=o.colors,g=o.unknownColor,v=o.domain,C=e.useMemo((function(){return n(l)?l:function(e,r){var o=a(e,l),t=a(r,l);return o&&o===t}}),[l]),m=e.useMemo((function(){return n(c)?c:function(e){return a(e,c)}}),[c]),b=e.useMemo((function(){return n(p)?p:function(e){return a(e,p)}}),[p]),j=e.useMemo((function(){return void 0===h?function(e){return e}:n(h)?h:u.format(h)}),[h]),y=e.useMemo((function(){return r.guessQuantizeColorScale(f).domain(v)}),[f,v]),R=e.useMemo((function(){return function(e){return void 0===e.value?g:y(e.value)}}),[y,g]),q=e.useMemo((function(){return t.map((function(e){var r=i.find((function(r){return C(e,r)})),o=b(r);if(r){var t=d({},e,{data:r,value:o,formattedValue:j(o)});return t.color=R(t),t.label=m(t),t}return e}))}),[t,i,C,b,j,R]),M=s.useQuantizeColorScaleLegendData({scale:y,valueFormat:j});return{colorScale:y,getFillColor:R,boundFeatures:q,valueFormatter:j,legendData:M}},g=e.memo((function(e){var r=e.feature;return void 0===r.data?null:c.jsx(o.BasicTooltip,{id:r.label,color:r.color,enableChip:!0,value:r.formattedValue})}));g.propTypes={feature:t.object.isRequired},g.displayName="ChoroplethTooltip";var v={features:t.arrayOf(t.shape({id:t.string.isRequired,type:t.oneOf(["Feature"]).isRequired,properties:t.object,geometry:t.object.isRequired})).isRequired,projectionType:t.oneOf(Object.keys(p)).isRequired,projectionScale:t.number.isRequired,projectionTranslation:t.arrayOf(t.number).isRequired,projectionRotation:t.arrayOf(t.number).isRequired,fillColor:t.oneOfType([t.string,t.func]).isRequired,borderWidth:t.oneOfType([t.number,t.func]).isRequired,borderColor:i.inheritedColorPropType.isRequired,enableGraticule:t.bool.isRequired,graticuleLineWidth:t.number.isRequired,graticuleLineColor:t.string.isRequired,isInteractive:t.bool.isRequired,onMouseEnter:t.func.isRequired,onMouseMove:t.func.isRequired,onMouseLeave:t.func.isRequired,onClick:t.func.isRequired,tooltip:t.any,layers:t.arrayOf(t.oneOfType([t.oneOf(["graticule","features"]),t.func])).isRequired},C=d({},v,{role:t.string.isRequired}),m=d({pixelRatio:t.number.isRequired},v),b={data:t.arrayOf(t.object).isRequired,match:t.oneOfType([t.string,t.func]).isRequired,label:t.oneOfType([t.string,t.func]).isRequired,value:t.oneOfType([t.string,t.func]).isRequired,valueFormat:t.oneOfType([t.string,t.func]),colors:r.quantizeColorScalePropType.isRequired,domain:t.arrayOf(t.number).isRequired,unknownColor:t.string.isRequired,layers:t.arrayOf(t.oneOfType([t.oneOf(["graticule","features","legends"]),t.func])).isRequired},j=d({},C,b,{role:t.string.isRequired}),y=d({},m,b),R={projectionType:"mercator",projectionScale:100,projectionTranslation:[.5,.5],projectionRotation:[0,0,0],enableGraticule:!1,graticuleLineWidth:.5,graticuleLineColor:"#999999",fillColor:"#dddddd",borderWidth:0,borderColor:"#000000",isInteractive:!0,onMouseEnter:function(){},onMouseLeave:function(){},onMouseMove:function(){},onClick:function(){},layers:["graticule","features"],legends:[],fill:[],defs:[]},q=d({},R,{role:"img"}),M=d({},R,{pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1}),T={match:"id",label:"id",value:"value",colors:"PuBuGn",unknownColor:"#999",tooltip:g,layers:["graticule","features","legends"]},x=d({},q,T,{role:"img"}),k=d({},M,T),W=e.memo((function(e){var r=e.path,o=e.graticule,t=e.lineWidth,i=e.lineColor;return c.jsx("path",{fill:"none",strokeWidth:t,stroke:i,d:r(o())})}));W.propTypes={path:t.func.isRequired,graticule:t.func.isRequired,lineWidth:t.number.isRequired,lineColor:t.string.isRequired},W.displayName="GeoGraticule";var w=e.memo((function(e){var r,o=e.feature,t=e.path,i=e.fillColor,n=e.borderWidth,a=e.borderColor,u=e.onClick,l=e.onMouseEnter,s=e.onMouseMove,d=e.onMouseLeave;return c.jsx("path",{fill:null!=(r=null==o?void 0:o.fill)?r:i,strokeWidth:n,stroke:a,strokeLinejoin:"bevel",d:t(o),onMouseEnter:function(e){return l(o,e)},onMouseMove:function(e){return s(o,e)},onMouseLeave:function(e){return d(o,e)},onClick:function(e){return u(o,e)}},o.id)}));w.propTypes={feature:t.shape({id:t.string.isRequired,type:t.oneOf(["Feature"]).isRequired,properties:t.object,geometry:t.object.isRequired}).isRequired,path:t.func.isRequired,fillColor:t.string.isRequired,borderWidth:t.number.isRequired,borderColor:t.string.isRequired,onMouseEnter:t.func.isRequired,onMouseMove:t.func.isRequired,onMouseLeave:t.func.isRequired,onClick:t.func.isRequired},w.displayName="GeoMapFeature";var F=e.memo((function(t){var i=t.width,n=t.height,a=t.margin,u=t.features,l=t.layers,s=t.projectionType,d=t.projectionScale,p=t.projectionTranslation,f=t.projectionRotation,g=t.fillColor,v=t.borderWidth,C=t.borderColor,m=t.enableGraticule,b=t.graticuleLineWidth,j=t.graticuleLineColor,y=t.isInteractive,R=t.onClick,q=t.tooltip,M=t.role,T=r.useDimensions(i,n,a),x=T.margin,k=T.outerWidth,F=T.outerHeight,E=h({width:i,height:n,projectionType:s,projectionScale:d,projectionTranslation:p,projectionRotation:f,fillColor:g,borderWidth:v,borderColor:C}),S=E.graticule,O=E.path,L=E.getFillColor,G=E.getBorderWidth,P=E.getBorderColor,B=r.useTheme(),D=o.useTooltip(),I=D.showTooltipFromEvent,N=D.hideTooltip,z=e.useCallback((function(e,r){return y&&R&&R(e,r)}),[y,R]),H=e.useCallback((function(e,r){return y&&q&&I(c.jsx(q,{feature:e}),r)}),[y,I,q]),A=e.useCallback((function(e,r){return y&&q&&I(c.jsx(q,{feature:e}),r)}),[y,I,q]),K=e.useCallback((function(){return y&&N()}),[y,N]);return c.jsx(r.SvgWrapper,{width:k,height:F,margin:x,theme:B,role:M,children:l.map((function(r,o){return"graticule"===r?!0!==m?null:c.jsx(W,{path:O,graticule:S,lineWidth:b,lineColor:j},"graticule"):"features"===r?c.jsx(e.Fragment,{children:u.map((function(e){return c.jsx(w,{feature:e,path:O,fillColor:L(e),borderWidth:G(e),borderColor:P(e),onMouseEnter:H,onMouseMove:A,onMouseLeave:K,onClick:z},e.id)}))},"features"):c.jsx(e.Fragment,{children:r(t)},o)}))})}));F.displayName="GeoMap",F.propTypes=C,F.defaultProps=q;var E=r.withContainer(F),S=function(e,o,t,i){var n=r.getRelativeCursor(o,e),a=n[0],u=n[1];return t.find((function(e){return l.geoContains(e,i.invert([a,u]))}))},O=e.memo((function(t){var i=t.width,n=t.height,a=t.margin,u=t.pixelRatio,l=t.features,s=t.layers,d=t.projectionType,p=t.projectionScale,f=t.projectionTranslation,g=t.projectionRotation,v=t.fillColor,C=t.borderWidth,m=t.borderColor,b=t.enableGraticule,j=t.graticuleLineWidth,y=t.graticuleLineColor,R=t.isInteractive,q=t.onClick,M=t.onMouseMove,T=t.tooltip,x=e.useRef(null),k=r.useTheme(),W=r.useDimensions(i,n,a),w=W.margin,F=W.outerWidth,E=W.outerHeight,O=h({width:i,height:n,projectionType:d,projectionScale:p,projectionTranslation:f,projectionRotation:g,fillColor:v,borderWidth:C,borderColor:m}),L=O.projection,G=O.graticule,P=O.path,B=O.getFillColor,D=O.getBorderWidth,I=O.getBorderColor;e.useEffect((function(){if(x){x.current.width=F*u,x.current.height=E*u;var e=x.current.getContext("2d");e.scale(u,u),e.fillStyle=k.background,e.fillRect(0,0,F,E),e.translate(w.left,w.top),P.context(e),s.forEach((function(r){"graticule"===r?!0===b&&(e.lineWidth=j,e.strokeStyle=y,e.beginPath(),P(G()),e.stroke()):"features"===r?l.forEach((function(r){e.beginPath(),P(r),e.fillStyle=B(r),e.fill();var o=D(r);o>0&&(e.strokeStyle=I(r),e.lineWidth=o,e.stroke())})):r(e,t)}))}}),[x,F,E,w,u,k,P,G,B,D,I,l,s]);var N=o.useTooltip(),z=N.showTooltipFromEvent,H=N.hideTooltip,A=e.useCallback((function(e){if(R&&T){var r=S(e,x.current,l,L);r?z(c.jsx(T,{feature:r}),e):H(),M&&M(r||null,e)}}),[z,H,R,T,x,l,L]),K=e.useCallback((function(){return R&&H()}),[R,H]),Q=e.useCallback((function(e){if(R&&q){var r=S(e,x.current,l,L);r&&q(r,e)}}),[R,x,l,L,q]);return c.jsx("canvas",{ref:x,width:F*u,height:E*u,style:{width:F,height:E,cursor:R?"auto":"normal"},onMouseMove:A,onMouseLeave:K,onClick:Q})}));O.displatName="GeoMapCanvas",O.propTypes=m,O.defaultProps=M;var L=r.withContainer(O),G=e.memo((function(t){var i=t.width,n=t.height,a=t.margin,u=t.features,l=t.data,p=t.match,g=t.label,v=t.value,C=t.valueFormat,m=t.projectionType,b=t.projectionScale,j=t.projectionTranslation,y=t.projectionRotation,R=t.colors,q=t.domain,M=t.unknownColor,T=t.borderWidth,k=t.borderColor,F=t.enableGraticule,E=t.graticuleLineWidth,S=t.graticuleLineColor,O=t.layers,L=t.legends,G=t.isInteractive,P=t.onClick,B=t.tooltip,D=t.role,I=t.defs,N=void 0===I?x.defs:I,z=t.fill,H=void 0===z?x.fill:z,A=r.useDimensions(i,n,a),K=A.margin,Q=A.outerWidth,V=A.outerHeight,J=h({width:i,height:n,projectionType:m,projectionScale:b,projectionTranslation:j,projectionRotation:y,fillColor:function(){},borderWidth:T,borderColor:k}),U=J.graticule,X=J.path,Y=J.getBorderWidth,Z=J.getBorderColor,$=f({features:u,data:l,match:p,label:g,value:v,valueFormat:C,colors:R,unknownColor:M,domain:q}),_=$.getFillColor,ee=$.boundFeatures,re=$.legendData,oe=r.useTheme(),te=r.bindDefs(N,ee,H,{dataKey:"data",targetKey:"fill"}),ie=o.useTooltip(),ne=ie.showTooltipFromEvent,ae=ie.hideTooltip,ue=e.useCallback((function(e,r){return G&&P&&P(e,r)}),[G,P]),le=e.useCallback((function(e,r){return G&&B&&ne(c.jsx(B,{feature:e}),r)}),[G,ne,B]),se=e.useCallback((function(e,r){return G&&B&&ne(c.jsx(B,{feature:e}),r)}),[G,ne,B]),ce=e.useCallback((function(){return G&&ae()}),[G,ae]);return c.jsx(r.SvgWrapper,{width:Q,height:V,margin:K,theme:oe,defs:te,role:D,children:O.map((function(r,o){return"graticule"===r?!0!==F?null:c.jsx(W,{path:X,graticule:U,lineWidth:E,lineColor:S},"graticule"):"features"===r?c.jsx(e.Fragment,{children:ee.map((function(e){return c.jsx(w,{feature:e,path:X,fillColor:_(e),borderWidth:Y(e),borderColor:Z(e),onMouseEnter:le,onMouseMove:se,onMouseLeave:ce,onClick:ue},e.id)}))},"features"):"legends"===r?L.map((function(e,r){return c.jsx(s.BoxLegendSvg,d({containerWidth:i,containerHeight:n,data:re},e),r)})):c.jsx(e.Fragment,{children:r({})},o)}))})}));G.displayName="Choropleth",G.propTypes=j,G.defaultProps=x;var P=r.withContainer(G),B=function(e,o,t,i){var n=r.getRelativeCursor(o,e),a=n[0],u=n[1];return t.find((function(e){return l.geoContains(e,i.invert([a,u]))}))},D=e.memo((function(t){var i=t.width,n=t.height,a=t.margin,u=t.pixelRatio,l=t.features,p=t.data,g=t.match,v=t.label,C=t.value,m=t.valueFormat,b=t.projectionType,j=t.projectionScale,y=t.projectionTranslation,R=t.projectionRotation,q=t.colors,M=t.domain,T=t.unknownColor,x=t.borderWidth,k=t.borderColor,W=t.enableGraticule,w=t.graticuleLineWidth,F=t.graticuleLineColor,E=t.layers,S=t.legends,O=t.isInteractive,L=t.onClick,G=t.onMouseMove,P=t.tooltip,D=e.useRef(null),I=r.useTheme(),N=r.useDimensions(i,n,a),z=N.margin,H=N.outerWidth,A=N.outerHeight,K=h({width:i,height:n,projectionType:b,projectionScale:j,projectionTranslation:y,projectionRotation:R,fillColor:function(){},borderWidth:x,borderColor:k}),Q=K.projection,V=K.graticule,J=K.path,U=K.getBorderWidth,X=K.getBorderColor,Y=f({features:l,data:p,match:g,label:v,value:C,valueFormat:m,colors:q,unknownColor:T,domain:M}),Z=Y.getFillColor,$=Y.boundFeatures,_=Y.legendData;e.useEffect((function(){if(D){D.current.width=H*u,D.current.height=A*u;var e=D.current.getContext("2d");e.scale(u,u),e.fillStyle=I.background,e.fillRect(0,0,H,A),e.translate(z.left,z.top),J.context(e),E.forEach((function(r){"graticule"===r?!0===W&&(e.lineWidth=w,e.strokeStyle=F,e.beginPath(),J(V()),e.stroke()):"features"===r?$.forEach((function(r){e.beginPath(),J(r),e.fillStyle=Z(r),e.fill();var o=U(r);o>0&&(e.strokeStyle=X(r),e.lineWidth=o,e.stroke())})):"legends"===r&&S.forEach((function(r){s.renderLegendToCanvas(e,d({},r,{data:_,containerWidth:i,containerHeight:n,theme:I}))}))}))}}),[D,H,A,z,u,I,J,V,Z,U,X,$,S,E]);var ee=o.useTooltip(),re=ee.showTooltipFromEvent,oe=ee.hideTooltip,te=e.useCallback((function(e){if(O&&P){var r=B(e,D.current,$,Q);r?re(c.jsx(P,{feature:r}),e):oe(),G&&G(r||null,e)}}),[re,oe,O,P,D,$,Q]),ie=e.useCallback((function(){return O&&oe()}),[O,oe]),ne=e.useCallback((function(e){if(O&&L){var r=B(e,D.current,$,Q);r&&L(r,e)}}),[O,D,$,Q,L]);return c.jsx("canvas",{ref:D,width:H*u,height:A*u,style:{width:H,height:A,cursor:O?"auto":"normal"},onMouseMove:te,onMouseLeave:ie,onClick:ne})}));D.displayName="ChoroplethCanvas",D.propTypes=y,D.defaultProps=k;var I=r.withContainer(D);exports.Choropleth=P,exports.ChoroplethCanvas=I,exports.ChoroplethCanvasDefaultProps=k,exports.ChoroplethCanvasPropTypes=y,exports.ChoroplethDefaultProps=x,exports.ChoroplethPropTypes=j,exports.GeoMap=E,exports.GeoMapCanvas=L,exports.GeoMapCanvasDefaultProps=M,exports.GeoMapCanvasPropTypes=m,exports.GeoMapDefaultProps=q,exports.GeoMapPropTypes=C,exports.ResponsiveChoropleth=function(e){return c.jsx(r.ResponsiveWrapper,{children:function(r){var o=r.width,t=r.height;return c.jsx(P,d({width:o,height:t},e))}})},exports.ResponsiveChoroplethCanvas=function(e){return c.jsx(r.ResponsiveWrapper,{children:function(r){var o=r.width,t=r.height;return c.jsx(I,d({width:o,height:t},e))}})},exports.ResponsiveGeoMap=function(e){return c.jsx(r.ResponsiveWrapper,{children:function(r){var o=r.width,t=r.height;return c.jsx(E,d({width:o,height:t},e))}})},exports.ResponsiveGeoMapCanvas=function(e){return c.jsx(r.ResponsiveWrapper,{children:function(r){var o=r.width,t=r.height;return c.jsx(L,d({width:o,height:t},e))}})},exports.projectionById=p,exports.useChoropleth=f,exports.useGeoMap=h;
//# sourceMappingURL=nivo-geo.cjs.js.map

@@ -1,2 +0,2 @@

"use strict";var e=require("react"),r=require("@nivo/core"),o=require("@nivo/tooltip"),t=require("prop-types"),i=require("@nivo/colors"),n=require("lodash"),a=require("d3-format"),u=require("d3-geo"),l=require("@nivo/legends"),s=require("react/jsx-runtime");function c(){return c=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&(e[t]=o[t])}return e},c.apply(this,arguments)}var d={azimuthalEqualArea:u.geoAzimuthalEqualArea,azimuthalEquidistant:u.geoAzimuthalEquidistant,gnomonic:u.geoGnomonic,orthographic:u.geoOrthographic,stereographic:u.geoStereographic,equalEarth:u.geoEqualEarth,equirectangular:u.geoEquirectangular,mercator:u.geoMercator,transverseMercator:u.geoTransverseMercator,naturalEarth1:u.geoNaturalEarth1},p=function(o){var t=o.width,n=o.height,a=o.projectionType,l=o.projectionScale,s=o.projectionTranslation,c=o.projectionRotation,p=o.fillColor,h=o.borderWidth,f=o.borderColor,g=e.useMemo((function(){return d[a]().scale(l).translate([t*s[0],n*s[1]]).rotate(c)}),[t,n,a,l,s[0],s[1],c[0],c[1],c[2]]),v=e.useMemo((function(){return u.geoPath(g)}),[g]),C=e.useMemo((function(){return u.geoGraticule()})),m=r.useTheme(),b=e.useMemo((function(){return"function"==typeof h?h:function(){return h}}),[h]),j=i.useInheritedColor(f,m),y=e.useMemo((function(){return"function"==typeof p?p:function(){return p}}),[p]);return{projection:g,path:v,graticule:C,getBorderWidth:b,getBorderColor:j,getFillColor:y}},h=function(o){var t=o.features,i=o.data,u=o.match,s=o.label,d=o.value,p=o.valueFormat,h=o.colors,f=o.unknownColor,g=o.domain,v=e.useMemo((function(){return n.isFunction(u)?u:function(e,r){var o=n.get(e,u),t=n.get(r,u);return o&&o===t}}),[u]),C=e.useMemo((function(){return n.isFunction(s)?s:function(e){return n.get(e,s)}}),[s]),m=e.useMemo((function(){return n.isFunction(d)?d:function(e){return n.get(e,d)}}),[d]),b=e.useMemo((function(){return void 0===p?function(e){return e}:n.isFunction(p)?p:a.format(p)}),[p]),j=e.useMemo((function(){return r.guessQuantizeColorScale(h).domain(g)}),[h,g]),y=e.useMemo((function(){return function(e){return void 0===e.value?f:j(e.value)}}),[j,f]),R=e.useMemo((function(){return t.map((function(e){var r=i.find((function(r){return v(e,r)})),o=m(r);if(r){var t=c({},e,{data:r,value:o,formattedValue:b(o)});return t.color=y(t),t.label=C(t),t}return e}))}),[t,i,v,m,b,y]),q=l.useQuantizeColorScaleLegendData({scale:j,valueFormat:b});return{colorScale:j,getFillColor:y,boundFeatures:R,valueFormatter:b,legendData:q}},f=e.memo((function(e){var r=e.feature;return void 0===r.data?null:s.jsx(o.BasicTooltip,{id:r.label,color:r.color,enableChip:!0,value:r.formattedValue})}));f.propTypes={feature:t.object.isRequired},f.displayName="ChoroplethTooltip";var g={features:t.arrayOf(t.shape({id:t.string.isRequired,type:t.oneOf(["Feature"]).isRequired,properties:t.object,geometry:t.object.isRequired})).isRequired,projectionType:t.oneOf(Object.keys(d)).isRequired,projectionScale:t.number.isRequired,projectionTranslation:t.arrayOf(t.number).isRequired,projectionRotation:t.arrayOf(t.number).isRequired,fillColor:t.oneOfType([t.string,t.func]).isRequired,borderWidth:t.oneOfType([t.number,t.func]).isRequired,borderColor:i.inheritedColorPropType.isRequired,enableGraticule:t.bool.isRequired,graticuleLineWidth:t.number.isRequired,graticuleLineColor:t.string.isRequired,isInteractive:t.bool.isRequired,onMouseEnter:t.func.isRequired,onMouseMove:t.func.isRequired,onMouseLeave:t.func.isRequired,onClick:t.func.isRequired,tooltip:t.any,layers:t.arrayOf(t.oneOfType([t.oneOf(["graticule","features"]),t.func])).isRequired},v=c({},g,{role:t.string.isRequired}),C=c({pixelRatio:t.number.isRequired},g),m={data:t.arrayOf(t.object).isRequired,match:t.oneOfType([t.string,t.func]).isRequired,label:t.oneOfType([t.string,t.func]).isRequired,value:t.oneOfType([t.string,t.func]).isRequired,valueFormat:t.oneOfType([t.string,t.func]),colors:r.quantizeColorScalePropType.isRequired,domain:t.arrayOf(t.number).isRequired,unknownColor:t.string.isRequired,layers:t.arrayOf(t.oneOfType([t.oneOf(["graticule","features","legends"]),t.func])).isRequired},b=c({},v,m,{role:t.string.isRequired}),j=c({},C,m),y={projectionType:"mercator",projectionScale:100,projectionTranslation:[.5,.5],projectionRotation:[0,0,0],enableGraticule:!1,graticuleLineWidth:.5,graticuleLineColor:"#999999",fillColor:"#dddddd",borderWidth:0,borderColor:"#000000",isInteractive:!0,onMouseEnter:function(){},onMouseLeave:function(){},onMouseMove:function(){},onClick:function(){},layers:["graticule","features"],legends:[],fill:[],defs:[]},R=c({},y,{role:"img"}),q=c({},y,{pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1}),M={match:"id",label:"id",value:"value",colors:"PuBuGn",unknownColor:"#999",tooltip:f,layers:["graticule","features","legends"]},T=c({},R,M,{role:"img"}),x=c({},q,M),k=e.memo((function(e){var r=e.path,o=e.graticule,t=e.lineWidth,i=e.lineColor;return s.jsx("path",{fill:"none",strokeWidth:t,stroke:i,d:r(o())})}));k.propTypes={path:t.func.isRequired,graticule:t.func.isRequired,lineWidth:t.number.isRequired,lineColor:t.string.isRequired},k.displayName="GeoGraticule";var W=e.memo((function(e){var r,o=e.feature,t=e.path,i=e.fillColor,n=e.borderWidth,a=e.borderColor,u=e.onClick,l=e.onMouseEnter,c=e.onMouseMove,d=e.onMouseLeave;return s.jsx("path",{fill:null!=(r=null==o?void 0:o.fill)?r:i,strokeWidth:n,stroke:a,strokeLinejoin:"bevel",d:t(o),onMouseEnter:function(e){return l(o,e)},onMouseMove:function(e){return c(o,e)},onMouseLeave:function(e){return d(o,e)},onClick:function(e){return u(o,e)}},o.id)}));W.propTypes={feature:t.shape({id:t.string.isRequired,type:t.oneOf(["Feature"]).isRequired,properties:t.object,geometry:t.object.isRequired}).isRequired,path:t.func.isRequired,fillColor:t.string.isRequired,borderWidth:t.number.isRequired,borderColor:t.string.isRequired,onMouseEnter:t.func.isRequired,onMouseMove:t.func.isRequired,onMouseLeave:t.func.isRequired,onClick:t.func.isRequired},W.displayName="GeoMapFeature";var w=e.memo((function(t){var i=t.width,n=t.height,a=t.margin,u=t.features,l=t.layers,c=t.projectionType,d=t.projectionScale,h=t.projectionTranslation,f=t.projectionRotation,g=t.fillColor,v=t.borderWidth,C=t.borderColor,m=t.enableGraticule,b=t.graticuleLineWidth,j=t.graticuleLineColor,y=t.isInteractive,R=t.onClick,q=t.tooltip,M=t.role,T=r.useDimensions(i,n,a),x=T.margin,w=T.outerWidth,F=T.outerHeight,E=p({width:i,height:n,projectionType:c,projectionScale:d,projectionTranslation:h,projectionRotation:f,fillColor:g,borderWidth:v,borderColor:C}),S=E.graticule,O=E.path,L=E.getFillColor,G=E.getBorderWidth,P=E.getBorderColor,B=r.useTheme(),D=o.useTooltip(),I=D.showTooltipFromEvent,N=D.hideTooltip,z=e.useCallback((function(e,r){return y&&R&&R(e,r)}),[y,R]),H=e.useCallback((function(e,r){return y&&q&&I(s.jsx(q,{feature:e}),r)}),[y,I,q]),A=e.useCallback((function(e,r){return y&&q&&I(s.jsx(q,{feature:e}),r)}),[y,I,q]),K=e.useCallback((function(){return y&&N()}),[y,N]);return s.jsx(r.SvgWrapper,{width:w,height:F,margin:x,theme:B,role:M,children:l.map((function(r,o){return"graticule"===r?!0!==m?null:s.jsx(k,{path:O,graticule:S,lineWidth:b,lineColor:j},"graticule"):"features"===r?s.jsx(e.Fragment,{children:u.map((function(e){return s.jsx(W,{feature:e,path:O,fillColor:L(e),borderWidth:G(e),borderColor:P(e),onMouseEnter:H,onMouseMove:A,onMouseLeave:K,onClick:z},e.id)}))},"features"):s.jsx(e.Fragment,{children:r(t)},o)}))})}));w.displayName="GeoMap",w.propTypes=v,w.defaultProps=R;var F=r.withContainer(w),E=function(e,o,t,i){var n=r.getRelativeCursor(o,e),a=n[0],l=n[1];return t.find((function(e){return u.geoContains(e,i.invert([a,l]))}))},S=e.memo((function(t){var i=t.width,n=t.height,a=t.margin,u=t.pixelRatio,l=t.features,c=t.layers,d=t.projectionType,h=t.projectionScale,f=t.projectionTranslation,g=t.projectionRotation,v=t.fillColor,C=t.borderWidth,m=t.borderColor,b=t.enableGraticule,j=t.graticuleLineWidth,y=t.graticuleLineColor,R=t.isInteractive,q=t.onClick,M=t.onMouseMove,T=t.tooltip,x=e.useRef(null),k=r.useTheme(),W=r.useDimensions(i,n,a),w=W.margin,F=W.outerWidth,S=W.outerHeight,O=p({width:i,height:n,projectionType:d,projectionScale:h,projectionTranslation:f,projectionRotation:g,fillColor:v,borderWidth:C,borderColor:m}),L=O.projection,G=O.graticule,P=O.path,B=O.getFillColor,D=O.getBorderWidth,I=O.getBorderColor;e.useEffect((function(){if(x){x.current.width=F*u,x.current.height=S*u;var e=x.current.getContext("2d");e.scale(u,u),e.fillStyle=k.background,e.fillRect(0,0,F,S),e.translate(w.left,w.top),P.context(e),c.forEach((function(r){"graticule"===r?!0===b&&(e.lineWidth=j,e.strokeStyle=y,e.beginPath(),P(G()),e.stroke()):"features"===r?l.forEach((function(r){e.beginPath(),P(r),e.fillStyle=B(r),e.fill();var o=D(r);o>0&&(e.strokeStyle=I(r),e.lineWidth=o,e.stroke())})):r(e,t)}))}}),[x,F,S,w,u,k,P,G,B,D,I,l,c]);var N=o.useTooltip(),z=N.showTooltipFromEvent,H=N.hideTooltip,A=e.useCallback((function(e){if(R&&T){var r=E(e,x.current,l,L);r?z(s.jsx(T,{feature:r}),e):H(),M&&M(r||null,e)}}),[z,H,R,T,x,l,L]),K=e.useCallback((function(){return R&&H()}),[R,H]),Q=e.useCallback((function(e){if(R&&q){var r=E(e,x.current,l,L);r&&q(r,e)}}),[R,x,l,L,q]);return s.jsx("canvas",{ref:x,width:F*u,height:S*u,style:{width:F,height:S,cursor:R?"auto":"normal"},onMouseMove:A,onMouseLeave:K,onClick:Q})}));S.displatName="GeoMapCanvas",S.propTypes=C,S.defaultProps=q;var O=r.withContainer(S),L=e.memo((function(t){var i=t.width,n=t.height,a=t.margin,u=t.features,d=t.data,f=t.match,g=t.label,v=t.value,C=t.valueFormat,m=t.projectionType,b=t.projectionScale,j=t.projectionTranslation,y=t.projectionRotation,R=t.colors,q=t.domain,M=t.unknownColor,x=t.borderWidth,w=t.borderColor,F=t.enableGraticule,E=t.graticuleLineWidth,S=t.graticuleLineColor,O=t.layers,L=t.legends,G=t.isInteractive,P=t.onClick,B=t.tooltip,D=t.role,I=t.defs,N=void 0===I?T.defs:I,z=t.fill,H=void 0===z?T.fill:z,A=r.useDimensions(i,n,a),K=A.margin,Q=A.outerWidth,V=A.outerHeight,J=p({width:i,height:n,projectionType:m,projectionScale:b,projectionTranslation:j,projectionRotation:y,fillColor:function(){},borderWidth:x,borderColor:w}),U=J.graticule,X=J.path,Y=J.getBorderWidth,Z=J.getBorderColor,$=h({features:u,data:d,match:f,label:g,value:v,valueFormat:C,colors:R,unknownColor:M,domain:q}),_=$.getFillColor,ee=$.boundFeatures,re=$.legendData,oe=r.useTheme(),te=r.bindDefs(N,ee,H,{dataKey:"data",targetKey:"fill"}),ie=o.useTooltip(),ne=ie.showTooltipFromEvent,ae=ie.hideTooltip,ue=e.useCallback((function(e,r){return G&&P&&P(e,r)}),[G,P]),le=e.useCallback((function(e,r){return G&&B&&ne(s.jsx(B,{feature:e}),r)}),[G,ne,B]),se=e.useCallback((function(e,r){return G&&B&&ne(s.jsx(B,{feature:e}),r)}),[G,ne,B]),ce=e.useCallback((function(){return G&&ae()}),[G,ae]);return s.jsx(r.SvgWrapper,{width:Q,height:V,margin:K,theme:oe,defs:te,role:D,children:O.map((function(r,o){return"graticule"===r?!0!==F?null:s.jsx(k,{path:X,graticule:U,lineWidth:E,lineColor:S},"graticule"):"features"===r?s.jsx(e.Fragment,{children:ee.map((function(e){return s.jsx(W,{feature:e,path:X,fillColor:_(e),borderWidth:Y(e),borderColor:Z(e),onMouseEnter:le,onMouseMove:se,onMouseLeave:ce,onClick:ue},e.id)}))},"features"):"legends"===r?L.map((function(e,r){return s.jsx(l.BoxLegendSvg,c({containerWidth:i,containerHeight:n,data:re},e),r)})):s.jsx(e.Fragment,{children:r({})},o)}))})}));L.displayName="Choropleth",L.propTypes=b,L.defaultProps=T;var G=r.withContainer(L),P=function(e,o,t,i){var n=r.getRelativeCursor(o,e),a=n[0],l=n[1];return t.find((function(e){return u.geoContains(e,i.invert([a,l]))}))},B=e.memo((function(t){var i=t.width,n=t.height,a=t.margin,u=t.pixelRatio,d=t.features,f=t.data,g=t.match,v=t.label,C=t.value,m=t.valueFormat,b=t.projectionType,j=t.projectionScale,y=t.projectionTranslation,R=t.projectionRotation,q=t.colors,M=t.domain,T=t.unknownColor,x=t.borderWidth,k=t.borderColor,W=t.enableGraticule,w=t.graticuleLineWidth,F=t.graticuleLineColor,E=t.layers,S=t.legends,O=t.isInteractive,L=t.onClick,G=t.onMouseMove,B=t.tooltip,D=e.useRef(null),I=r.useTheme(),N=r.useDimensions(i,n,a),z=N.margin,H=N.outerWidth,A=N.outerHeight,K=p({width:i,height:n,projectionType:b,projectionScale:j,projectionTranslation:y,projectionRotation:R,fillColor:function(){},borderWidth:x,borderColor:k}),Q=K.projection,V=K.graticule,J=K.path,U=K.getBorderWidth,X=K.getBorderColor,Y=h({features:d,data:f,match:g,label:v,value:C,valueFormat:m,colors:q,unknownColor:T,domain:M}),Z=Y.getFillColor,$=Y.boundFeatures,_=Y.legendData;e.useEffect((function(){if(D){D.current.width=H*u,D.current.height=A*u;var e=D.current.getContext("2d");e.scale(u,u),e.fillStyle=I.background,e.fillRect(0,0,H,A),e.translate(z.left,z.top),J.context(e),E.forEach((function(r){"graticule"===r?!0===W&&(e.lineWidth=w,e.strokeStyle=F,e.beginPath(),J(V()),e.stroke()):"features"===r?$.forEach((function(r){e.beginPath(),J(r),e.fillStyle=Z(r),e.fill();var o=U(r);o>0&&(e.strokeStyle=X(r),e.lineWidth=o,e.stroke())})):"legends"===r&&S.forEach((function(r){l.renderLegendToCanvas(e,c({},r,{data:_,containerWidth:i,containerHeight:n,theme:I}))}))}))}}),[D,H,A,z,u,I,J,V,Z,U,X,$,S,E]);var ee=o.useTooltip(),re=ee.showTooltipFromEvent,oe=ee.hideTooltip,te=e.useCallback((function(e){if(O&&B){var r=P(e,D.current,$,Q);r?re(s.jsx(B,{feature:r}),e):oe(),G&&G(r||null,e)}}),[re,oe,O,B,D,$,Q]),ie=e.useCallback((function(){return O&&oe()}),[O,oe]),ne=e.useCallback((function(e){if(O&&L){var r=P(e,D.current,$,Q);r&&L(r,e)}}),[O,D,$,Q,L]);return s.jsx("canvas",{ref:D,width:H*u,height:A*u,style:{width:H,height:A,cursor:O?"auto":"normal"},onMouseMove:te,onMouseLeave:ie,onClick:ne})}));B.displayName="ChoroplethCanvas",B.propTypes=j,B.defaultProps=x;var D=r.withContainer(B);exports.Choropleth=G,exports.ChoroplethCanvas=D,exports.ChoroplethCanvasDefaultProps=x,exports.ChoroplethCanvasPropTypes=j,exports.ChoroplethDefaultProps=T,exports.ChoroplethPropTypes=b,exports.GeoMap=F,exports.GeoMapCanvas=O,exports.GeoMapCanvasDefaultProps=q,exports.GeoMapCanvasPropTypes=C,exports.GeoMapDefaultProps=R,exports.GeoMapPropTypes=v,exports.ResponsiveChoropleth=function(e){return s.jsx(r.ResponsiveWrapper,{children:function(r){var o=r.width,t=r.height;return s.jsx(G,c({width:o,height:t},e))}})},exports.ResponsiveChoroplethCanvas=function(e){return s.jsx(r.ResponsiveWrapper,{children:function(r){var o=r.width,t=r.height;return s.jsx(D,c({width:o,height:t},e))}})},exports.ResponsiveGeoMap=function(e){return s.jsx(r.ResponsiveWrapper,{children:function(r){var o=r.width,t=r.height;return s.jsx(F,c({width:o,height:t},e))}})},exports.ResponsiveGeoMapCanvas=function(e){return s.jsx(r.ResponsiveWrapper,{children:function(r){var o=r.width,t=r.height;return s.jsx(O,c({width:o,height:t},e))}})},exports.projectionById=d,exports.useChoropleth=h,exports.useGeoMap=p;
"use strict";var e=require("react"),r=require("@nivo/core"),o=require("@nivo/tooltip"),t=require("prop-types"),i=require("@nivo/colors"),n=require("lodash/isFunction"),a=require("lodash/get"),u=require("d3-format"),l=require("d3-geo"),s=require("@nivo/legends"),c=require("react/jsx-runtime");function d(){return d=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&(e[t]=o[t])}return e},d.apply(this,arguments)}var p={azimuthalEqualArea:l.geoAzimuthalEqualArea,azimuthalEquidistant:l.geoAzimuthalEquidistant,gnomonic:l.geoGnomonic,orthographic:l.geoOrthographic,stereographic:l.geoStereographic,equalEarth:l.geoEqualEarth,equirectangular:l.geoEquirectangular,mercator:l.geoMercator,transverseMercator:l.geoTransverseMercator,naturalEarth1:l.geoNaturalEarth1},h=function(o){var t=o.width,n=o.height,a=o.projectionType,u=o.projectionScale,s=o.projectionTranslation,c=o.projectionRotation,d=o.fillColor,h=o.borderWidth,f=o.borderColor,g=e.useMemo((function(){return p[a]().scale(u).translate([t*s[0],n*s[1]]).rotate(c)}),[t,n,a,u,s[0],s[1],c[0],c[1],c[2]]),v=e.useMemo((function(){return l.geoPath(g)}),[g]),C=e.useMemo((function(){return l.geoGraticule()})),m=r.useTheme(),b=e.useMemo((function(){return"function"==typeof h?h:function(){return h}}),[h]),j=i.useInheritedColor(f,m),y=e.useMemo((function(){return"function"==typeof d?d:function(){return d}}),[d]);return{projection:g,path:v,graticule:C,getBorderWidth:b,getBorderColor:j,getFillColor:y}},f=function(o){var t=o.features,i=o.data,l=o.match,c=o.label,p=o.value,h=o.valueFormat,f=o.colors,g=o.unknownColor,v=o.domain,C=e.useMemo((function(){return n(l)?l:function(e,r){var o=a(e,l),t=a(r,l);return o&&o===t}}),[l]),m=e.useMemo((function(){return n(c)?c:function(e){return a(e,c)}}),[c]),b=e.useMemo((function(){return n(p)?p:function(e){return a(e,p)}}),[p]),j=e.useMemo((function(){return void 0===h?function(e){return e}:n(h)?h:u.format(h)}),[h]),y=e.useMemo((function(){return r.guessQuantizeColorScale(f).domain(v)}),[f,v]),R=e.useMemo((function(){return function(e){return void 0===e.value?g:y(e.value)}}),[y,g]),q=e.useMemo((function(){return t.map((function(e){var r=i.find((function(r){return C(e,r)})),o=b(r);if(r){var t=d({},e,{data:r,value:o,formattedValue:j(o)});return t.color=R(t),t.label=m(t),t}return e}))}),[t,i,C,b,j,R]),M=s.useQuantizeColorScaleLegendData({scale:y,valueFormat:j});return{colorScale:y,getFillColor:R,boundFeatures:q,valueFormatter:j,legendData:M}},g=e.memo((function(e){var r=e.feature;return void 0===r.data?null:c.jsx(o.BasicTooltip,{id:r.label,color:r.color,enableChip:!0,value:r.formattedValue})}));g.propTypes={feature:t.object.isRequired},g.displayName="ChoroplethTooltip";var v={features:t.arrayOf(t.shape({id:t.string.isRequired,type:t.oneOf(["Feature"]).isRequired,properties:t.object,geometry:t.object.isRequired})).isRequired,projectionType:t.oneOf(Object.keys(p)).isRequired,projectionScale:t.number.isRequired,projectionTranslation:t.arrayOf(t.number).isRequired,projectionRotation:t.arrayOf(t.number).isRequired,fillColor:t.oneOfType([t.string,t.func]).isRequired,borderWidth:t.oneOfType([t.number,t.func]).isRequired,borderColor:i.inheritedColorPropType.isRequired,enableGraticule:t.bool.isRequired,graticuleLineWidth:t.number.isRequired,graticuleLineColor:t.string.isRequired,isInteractive:t.bool.isRequired,onMouseEnter:t.func.isRequired,onMouseMove:t.func.isRequired,onMouseLeave:t.func.isRequired,onClick:t.func.isRequired,tooltip:t.any,layers:t.arrayOf(t.oneOfType([t.oneOf(["graticule","features"]),t.func])).isRequired},C=d({},v,{role:t.string.isRequired}),m=d({pixelRatio:t.number.isRequired},v),b={data:t.arrayOf(t.object).isRequired,match:t.oneOfType([t.string,t.func]).isRequired,label:t.oneOfType([t.string,t.func]).isRequired,value:t.oneOfType([t.string,t.func]).isRequired,valueFormat:t.oneOfType([t.string,t.func]),colors:r.quantizeColorScalePropType.isRequired,domain:t.arrayOf(t.number).isRequired,unknownColor:t.string.isRequired,layers:t.arrayOf(t.oneOfType([t.oneOf(["graticule","features","legends"]),t.func])).isRequired},j=d({},C,b,{role:t.string.isRequired}),y=d({},m,b),R={projectionType:"mercator",projectionScale:100,projectionTranslation:[.5,.5],projectionRotation:[0,0,0],enableGraticule:!1,graticuleLineWidth:.5,graticuleLineColor:"#999999",fillColor:"#dddddd",borderWidth:0,borderColor:"#000000",isInteractive:!0,onMouseEnter:function(){},onMouseLeave:function(){},onMouseMove:function(){},onClick:function(){},layers:["graticule","features"],legends:[],fill:[],defs:[]},q=d({},R,{role:"img"}),M=d({},R,{pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1}),T={match:"id",label:"id",value:"value",colors:"PuBuGn",unknownColor:"#999",tooltip:g,layers:["graticule","features","legends"]},x=d({},q,T,{role:"img"}),k=d({},M,T),W=e.memo((function(e){var r=e.path,o=e.graticule,t=e.lineWidth,i=e.lineColor;return c.jsx("path",{fill:"none",strokeWidth:t,stroke:i,d:r(o())})}));W.propTypes={path:t.func.isRequired,graticule:t.func.isRequired,lineWidth:t.number.isRequired,lineColor:t.string.isRequired},W.displayName="GeoGraticule";var w=e.memo((function(e){var r,o=e.feature,t=e.path,i=e.fillColor,n=e.borderWidth,a=e.borderColor,u=e.onClick,l=e.onMouseEnter,s=e.onMouseMove,d=e.onMouseLeave;return c.jsx("path",{fill:null!=(r=null==o?void 0:o.fill)?r:i,strokeWidth:n,stroke:a,strokeLinejoin:"bevel",d:t(o),onMouseEnter:function(e){return l(o,e)},onMouseMove:function(e){return s(o,e)},onMouseLeave:function(e){return d(o,e)},onClick:function(e){return u(o,e)}},o.id)}));w.propTypes={feature:t.shape({id:t.string.isRequired,type:t.oneOf(["Feature"]).isRequired,properties:t.object,geometry:t.object.isRequired}).isRequired,path:t.func.isRequired,fillColor:t.string.isRequired,borderWidth:t.number.isRequired,borderColor:t.string.isRequired,onMouseEnter:t.func.isRequired,onMouseMove:t.func.isRequired,onMouseLeave:t.func.isRequired,onClick:t.func.isRequired},w.displayName="GeoMapFeature";var F=e.memo((function(t){var i=t.width,n=t.height,a=t.margin,u=t.features,l=t.layers,s=t.projectionType,d=t.projectionScale,p=t.projectionTranslation,f=t.projectionRotation,g=t.fillColor,v=t.borderWidth,C=t.borderColor,m=t.enableGraticule,b=t.graticuleLineWidth,j=t.graticuleLineColor,y=t.isInteractive,R=t.onClick,q=t.tooltip,M=t.role,T=r.useDimensions(i,n,a),x=T.margin,k=T.outerWidth,F=T.outerHeight,E=h({width:i,height:n,projectionType:s,projectionScale:d,projectionTranslation:p,projectionRotation:f,fillColor:g,borderWidth:v,borderColor:C}),S=E.graticule,O=E.path,L=E.getFillColor,G=E.getBorderWidth,P=E.getBorderColor,B=r.useTheme(),D=o.useTooltip(),I=D.showTooltipFromEvent,N=D.hideTooltip,z=e.useCallback((function(e,r){return y&&R&&R(e,r)}),[y,R]),H=e.useCallback((function(e,r){return y&&q&&I(c.jsx(q,{feature:e}),r)}),[y,I,q]),A=e.useCallback((function(e,r){return y&&q&&I(c.jsx(q,{feature:e}),r)}),[y,I,q]),K=e.useCallback((function(){return y&&N()}),[y,N]);return c.jsx(r.SvgWrapper,{width:k,height:F,margin:x,theme:B,role:M,children:l.map((function(r,o){return"graticule"===r?!0!==m?null:c.jsx(W,{path:O,graticule:S,lineWidth:b,lineColor:j},"graticule"):"features"===r?c.jsx(e.Fragment,{children:u.map((function(e){return c.jsx(w,{feature:e,path:O,fillColor:L(e),borderWidth:G(e),borderColor:P(e),onMouseEnter:H,onMouseMove:A,onMouseLeave:K,onClick:z},e.id)}))},"features"):c.jsx(e.Fragment,{children:r(t)},o)}))})}));F.displayName="GeoMap",F.propTypes=C,F.defaultProps=q;var E=r.withContainer(F),S=function(e,o,t,i){var n=r.getRelativeCursor(o,e),a=n[0],u=n[1];return t.find((function(e){return l.geoContains(e,i.invert([a,u]))}))},O=e.memo((function(t){var i=t.width,n=t.height,a=t.margin,u=t.pixelRatio,l=t.features,s=t.layers,d=t.projectionType,p=t.projectionScale,f=t.projectionTranslation,g=t.projectionRotation,v=t.fillColor,C=t.borderWidth,m=t.borderColor,b=t.enableGraticule,j=t.graticuleLineWidth,y=t.graticuleLineColor,R=t.isInteractive,q=t.onClick,M=t.onMouseMove,T=t.tooltip,x=e.useRef(null),k=r.useTheme(),W=r.useDimensions(i,n,a),w=W.margin,F=W.outerWidth,E=W.outerHeight,O=h({width:i,height:n,projectionType:d,projectionScale:p,projectionTranslation:f,projectionRotation:g,fillColor:v,borderWidth:C,borderColor:m}),L=O.projection,G=O.graticule,P=O.path,B=O.getFillColor,D=O.getBorderWidth,I=O.getBorderColor;e.useEffect((function(){if(x){x.current.width=F*u,x.current.height=E*u;var e=x.current.getContext("2d");e.scale(u,u),e.fillStyle=k.background,e.fillRect(0,0,F,E),e.translate(w.left,w.top),P.context(e),s.forEach((function(r){"graticule"===r?!0===b&&(e.lineWidth=j,e.strokeStyle=y,e.beginPath(),P(G()),e.stroke()):"features"===r?l.forEach((function(r){e.beginPath(),P(r),e.fillStyle=B(r),e.fill();var o=D(r);o>0&&(e.strokeStyle=I(r),e.lineWidth=o,e.stroke())})):r(e,t)}))}}),[x,F,E,w,u,k,P,G,B,D,I,l,s]);var N=o.useTooltip(),z=N.showTooltipFromEvent,H=N.hideTooltip,A=e.useCallback((function(e){if(R&&T){var r=S(e,x.current,l,L);r?z(c.jsx(T,{feature:r}),e):H(),M&&M(r||null,e)}}),[z,H,R,T,x,l,L]),K=e.useCallback((function(){return R&&H()}),[R,H]),Q=e.useCallback((function(e){if(R&&q){var r=S(e,x.current,l,L);r&&q(r,e)}}),[R,x,l,L,q]);return c.jsx("canvas",{ref:x,width:F*u,height:E*u,style:{width:F,height:E,cursor:R?"auto":"normal"},onMouseMove:A,onMouseLeave:K,onClick:Q})}));O.displatName="GeoMapCanvas",O.propTypes=m,O.defaultProps=M;var L=r.withContainer(O),G=e.memo((function(t){var i=t.width,n=t.height,a=t.margin,u=t.features,l=t.data,p=t.match,g=t.label,v=t.value,C=t.valueFormat,m=t.projectionType,b=t.projectionScale,j=t.projectionTranslation,y=t.projectionRotation,R=t.colors,q=t.domain,M=t.unknownColor,T=t.borderWidth,k=t.borderColor,F=t.enableGraticule,E=t.graticuleLineWidth,S=t.graticuleLineColor,O=t.layers,L=t.legends,G=t.isInteractive,P=t.onClick,B=t.tooltip,D=t.role,I=t.defs,N=void 0===I?x.defs:I,z=t.fill,H=void 0===z?x.fill:z,A=r.useDimensions(i,n,a),K=A.margin,Q=A.outerWidth,V=A.outerHeight,J=h({width:i,height:n,projectionType:m,projectionScale:b,projectionTranslation:j,projectionRotation:y,fillColor:function(){},borderWidth:T,borderColor:k}),U=J.graticule,X=J.path,Y=J.getBorderWidth,Z=J.getBorderColor,$=f({features:u,data:l,match:p,label:g,value:v,valueFormat:C,colors:R,unknownColor:M,domain:q}),_=$.getFillColor,ee=$.boundFeatures,re=$.legendData,oe=r.useTheme(),te=r.bindDefs(N,ee,H,{dataKey:"data",targetKey:"fill"}),ie=o.useTooltip(),ne=ie.showTooltipFromEvent,ae=ie.hideTooltip,ue=e.useCallback((function(e,r){return G&&P&&P(e,r)}),[G,P]),le=e.useCallback((function(e,r){return G&&B&&ne(c.jsx(B,{feature:e}),r)}),[G,ne,B]),se=e.useCallback((function(e,r){return G&&B&&ne(c.jsx(B,{feature:e}),r)}),[G,ne,B]),ce=e.useCallback((function(){return G&&ae()}),[G,ae]);return c.jsx(r.SvgWrapper,{width:Q,height:V,margin:K,theme:oe,defs:te,role:D,children:O.map((function(r,o){return"graticule"===r?!0!==F?null:c.jsx(W,{path:X,graticule:U,lineWidth:E,lineColor:S},"graticule"):"features"===r?c.jsx(e.Fragment,{children:ee.map((function(e){return c.jsx(w,{feature:e,path:X,fillColor:_(e),borderWidth:Y(e),borderColor:Z(e),onMouseEnter:le,onMouseMove:se,onMouseLeave:ce,onClick:ue},e.id)}))},"features"):"legends"===r?L.map((function(e,r){return c.jsx(s.BoxLegendSvg,d({containerWidth:i,containerHeight:n,data:re},e),r)})):c.jsx(e.Fragment,{children:r({})},o)}))})}));G.displayName="Choropleth",G.propTypes=j,G.defaultProps=x;var P=r.withContainer(G),B=function(e,o,t,i){var n=r.getRelativeCursor(o,e),a=n[0],u=n[1];return t.find((function(e){return l.geoContains(e,i.invert([a,u]))}))},D=e.memo((function(t){var i=t.width,n=t.height,a=t.margin,u=t.pixelRatio,l=t.features,p=t.data,g=t.match,v=t.label,C=t.value,m=t.valueFormat,b=t.projectionType,j=t.projectionScale,y=t.projectionTranslation,R=t.projectionRotation,q=t.colors,M=t.domain,T=t.unknownColor,x=t.borderWidth,k=t.borderColor,W=t.enableGraticule,w=t.graticuleLineWidth,F=t.graticuleLineColor,E=t.layers,S=t.legends,O=t.isInteractive,L=t.onClick,G=t.onMouseMove,P=t.tooltip,D=e.useRef(null),I=r.useTheme(),N=r.useDimensions(i,n,a),z=N.margin,H=N.outerWidth,A=N.outerHeight,K=h({width:i,height:n,projectionType:b,projectionScale:j,projectionTranslation:y,projectionRotation:R,fillColor:function(){},borderWidth:x,borderColor:k}),Q=K.projection,V=K.graticule,J=K.path,U=K.getBorderWidth,X=K.getBorderColor,Y=f({features:l,data:p,match:g,label:v,value:C,valueFormat:m,colors:q,unknownColor:T,domain:M}),Z=Y.getFillColor,$=Y.boundFeatures,_=Y.legendData;e.useEffect((function(){if(D){D.current.width=H*u,D.current.height=A*u;var e=D.current.getContext("2d");e.scale(u,u),e.fillStyle=I.background,e.fillRect(0,0,H,A),e.translate(z.left,z.top),J.context(e),E.forEach((function(r){"graticule"===r?!0===W&&(e.lineWidth=w,e.strokeStyle=F,e.beginPath(),J(V()),e.stroke()):"features"===r?$.forEach((function(r){e.beginPath(),J(r),e.fillStyle=Z(r),e.fill();var o=U(r);o>0&&(e.strokeStyle=X(r),e.lineWidth=o,e.stroke())})):"legends"===r&&S.forEach((function(r){s.renderLegendToCanvas(e,d({},r,{data:_,containerWidth:i,containerHeight:n,theme:I}))}))}))}}),[D,H,A,z,u,I,J,V,Z,U,X,$,S,E]);var ee=o.useTooltip(),re=ee.showTooltipFromEvent,oe=ee.hideTooltip,te=e.useCallback((function(e){if(O&&P){var r=B(e,D.current,$,Q);r?re(c.jsx(P,{feature:r}),e):oe(),G&&G(r||null,e)}}),[re,oe,O,P,D,$,Q]),ie=e.useCallback((function(){return O&&oe()}),[O,oe]),ne=e.useCallback((function(e){if(O&&L){var r=B(e,D.current,$,Q);r&&L(r,e)}}),[O,D,$,Q,L]);return c.jsx("canvas",{ref:D,width:H*u,height:A*u,style:{width:H,height:A,cursor:O?"auto":"normal"},onMouseMove:te,onMouseLeave:ie,onClick:ne})}));D.displayName="ChoroplethCanvas",D.propTypes=y,D.defaultProps=k;var I=r.withContainer(D);exports.Choropleth=P,exports.ChoroplethCanvas=I,exports.ChoroplethCanvasDefaultProps=k,exports.ChoroplethCanvasPropTypes=y,exports.ChoroplethDefaultProps=x,exports.ChoroplethPropTypes=j,exports.GeoMap=E,exports.GeoMapCanvas=L,exports.GeoMapCanvasDefaultProps=M,exports.GeoMapCanvasPropTypes=m,exports.GeoMapDefaultProps=q,exports.GeoMapPropTypes=C,exports.ResponsiveChoropleth=function(e){return c.jsx(r.ResponsiveWrapper,{children:function(r){var o=r.width,t=r.height;return c.jsx(P,d({width:o,height:t},e))}})},exports.ResponsiveChoroplethCanvas=function(e){return c.jsx(r.ResponsiveWrapper,{children:function(r){var o=r.width,t=r.height;return c.jsx(I,d({width:o,height:t},e))}})},exports.ResponsiveGeoMap=function(e){return c.jsx(r.ResponsiveWrapper,{children:function(r){var o=r.width,t=r.height;return c.jsx(E,d({width:o,height:t},e))}})},exports.ResponsiveGeoMapCanvas=function(e){return c.jsx(r.ResponsiveWrapper,{children:function(r){var o=r.width,t=r.height;return c.jsx(L,d({width:o,height:t},e))}})},exports.projectionById=p,exports.useChoropleth=f,exports.useGeoMap=h;
//# sourceMappingURL=nivo-geo.cjs.js.map

@@ -1,2 +0,2 @@

import{useMemo as e,memo as r,useCallback as o,Fragment as t,useRef as i,useEffect as n}from"react";import{useTheme as a,guessQuantizeColorScale as u,quantizeColorScalePropType as l,useDimensions as c,SvgWrapper as d,withContainer as s,ResponsiveWrapper as f,getRelativeCursor as h,bindDefs as p}from"@nivo/core";import{BasicTooltip as g,useTooltip as v}from"@nivo/tooltip";import m from"prop-types";import{useInheritedColor as C,inheritedColorPropType as b}from"@nivo/colors";import{isFunction as y,get as R}from"lodash";import{format as j}from"d3-format";import{geoAzimuthalEqualArea as q,geoAzimuthalEquidistant as T,geoGnomonic as M,geoOrthographic as W,geoStereographic as w,geoEqualEarth as k,geoEquirectangular as O,geoMercator as F,geoTransverseMercator as L,geoNaturalEarth1 as E,geoPath as S,geoGraticule as G,geoContains as x}from"d3-geo";import{useQuantizeColorScaleLegendData as B,BoxLegendSvg as P,renderLegendToCanvas as N}from"@nivo/legends";import{jsx as H}from"react/jsx-runtime";function I(){return I=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&(e[t]=o[t])}return e},I.apply(this,arguments)}var D={azimuthalEqualArea:q,azimuthalEquidistant:T,gnomonic:M,orthographic:W,stereographic:w,equalEarth:k,equirectangular:O,mercator:F,transverseMercator:L,naturalEarth1:E},z=function(r){var o=r.width,t=r.height,i=r.projectionType,n=r.projectionScale,u=r.projectionTranslation,l=r.projectionRotation,c=r.fillColor,d=r.borderWidth,s=r.borderColor,f=e((function(){return D[i]().scale(n).translate([o*u[0],t*u[1]]).rotate(l)}),[o,t,i,n,u[0],u[1],l[0],l[1],l[2]]),h=e((function(){return S(f)}),[f]),p=e((function(){return G()})),g=a(),v=e((function(){return"function"==typeof d?d:function(){return d}}),[d]),m=C(s,g),b=e((function(){return"function"==typeof c?c:function(){return c}}),[c]);return{projection:f,path:h,graticule:p,getBorderWidth:v,getBorderColor:m,getFillColor:b}},K=function(r){var o=r.features,t=r.data,i=r.match,n=r.label,a=r.value,l=r.valueFormat,c=r.colors,d=r.unknownColor,s=r.domain,f=e((function(){return y(i)?i:function(e,r){var o=R(e,i),t=R(r,i);return o&&o===t}}),[i]),h=e((function(){return y(n)?n:function(e){return R(e,n)}}),[n]),p=e((function(){return y(a)?a:function(e){return R(e,a)}}),[a]),g=e((function(){return void 0===l?function(e){return e}:y(l)?l:j(l)}),[l]),v=e((function(){return u(c).domain(s)}),[c,s]),m=e((function(){return function(e){return void 0===e.value?d:v(e.value)}}),[v,d]),C=e((function(){return o.map((function(e){var r=t.find((function(r){return f(e,r)})),o=p(r);if(r){var i=I({},e,{data:r,value:o,formattedValue:g(o)});return i.color=m(i),i.label=h(i),i}return e}))}),[o,t,f,p,g,m]),b=B({scale:v,valueFormat:g});return{colorScale:v,getFillColor:m,boundFeatures:C,valueFormatter:g,legendData:b}},V=r((function(e){var r=e.feature;return void 0===r.data?null:H(g,{id:r.label,color:r.color,enableChip:!0,value:r.formattedValue})}));V.propTypes={feature:m.object.isRequired},V.displayName="ChoroplethTooltip";var A={features:m.arrayOf(m.shape({id:m.string.isRequired,type:m.oneOf(["Feature"]).isRequired,properties:m.object,geometry:m.object.isRequired})).isRequired,projectionType:m.oneOf(Object.keys(D)).isRequired,projectionScale:m.number.isRequired,projectionTranslation:m.arrayOf(m.number).isRequired,projectionRotation:m.arrayOf(m.number).isRequired,fillColor:m.oneOfType([m.string,m.func]).isRequired,borderWidth:m.oneOfType([m.number,m.func]).isRequired,borderColor:b.isRequired,enableGraticule:m.bool.isRequired,graticuleLineWidth:m.number.isRequired,graticuleLineColor:m.string.isRequired,isInteractive:m.bool.isRequired,onMouseEnter:m.func.isRequired,onMouseMove:m.func.isRequired,onMouseLeave:m.func.isRequired,onClick:m.func.isRequired,tooltip:m.any,layers:m.arrayOf(m.oneOfType([m.oneOf(["graticule","features"]),m.func])).isRequired},J=I({},A,{role:m.string.isRequired}),Q=I({pixelRatio:m.number.isRequired},A),U={data:m.arrayOf(m.object).isRequired,match:m.oneOfType([m.string,m.func]).isRequired,label:m.oneOfType([m.string,m.func]).isRequired,value:m.oneOfType([m.string,m.func]).isRequired,valueFormat:m.oneOfType([m.string,m.func]),colors:l.isRequired,domain:m.arrayOf(m.number).isRequired,unknownColor:m.string.isRequired,layers:m.arrayOf(m.oneOfType([m.oneOf(["graticule","features","legends"]),m.func])).isRequired},X=I({},J,U,{role:m.string.isRequired}),Y=I({},Q,U),Z={projectionType:"mercator",projectionScale:100,projectionTranslation:[.5,.5],projectionRotation:[0,0,0],enableGraticule:!1,graticuleLineWidth:.5,graticuleLineColor:"#999999",fillColor:"#dddddd",borderWidth:0,borderColor:"#000000",isInteractive:!0,onMouseEnter:function(){},onMouseLeave:function(){},onMouseMove:function(){},onClick:function(){},layers:["graticule","features"],legends:[],fill:[],defs:[]},$=I({},Z,{role:"img"}),_=I({},Z,{pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1}),ee={match:"id",label:"id",value:"value",colors:"PuBuGn",unknownColor:"#999",tooltip:V,layers:["graticule","features","legends"]},re=I({},$,ee,{role:"img"}),oe=I({},_,ee),te=r((function(e){var r=e.path,o=e.graticule,t=e.lineWidth,i=e.lineColor;return H("path",{fill:"none",strokeWidth:t,stroke:i,d:r(o())})}));te.propTypes={path:m.func.isRequired,graticule:m.func.isRequired,lineWidth:m.number.isRequired,lineColor:m.string.isRequired},te.displayName="GeoGraticule";var ie=r((function(e){var r,o=e.feature,t=e.path,i=e.fillColor,n=e.borderWidth,a=e.borderColor,u=e.onClick,l=e.onMouseEnter,c=e.onMouseMove,d=e.onMouseLeave;return H("path",{fill:null!=(r=null==o?void 0:o.fill)?r:i,strokeWidth:n,stroke:a,strokeLinejoin:"bevel",d:t(o),onMouseEnter:function(e){return l(o,e)},onMouseMove:function(e){return c(o,e)},onMouseLeave:function(e){return d(o,e)},onClick:function(e){return u(o,e)}},o.id)}));ie.propTypes={feature:m.shape({id:m.string.isRequired,type:m.oneOf(["Feature"]).isRequired,properties:m.object,geometry:m.object.isRequired}).isRequired,path:m.func.isRequired,fillColor:m.string.isRequired,borderWidth:m.number.isRequired,borderColor:m.string.isRequired,onMouseEnter:m.func.isRequired,onMouseMove:m.func.isRequired,onMouseLeave:m.func.isRequired,onClick:m.func.isRequired},ie.displayName="GeoMapFeature";var ne=r((function(e){var r=e.width,i=e.height,n=e.margin,u=e.features,l=e.layers,s=e.projectionType,f=e.projectionScale,h=e.projectionTranslation,p=e.projectionRotation,g=e.fillColor,m=e.borderWidth,C=e.borderColor,b=e.enableGraticule,y=e.graticuleLineWidth,R=e.graticuleLineColor,j=e.isInteractive,q=e.onClick,T=e.tooltip,M=e.role,W=c(r,i,n),w=W.margin,k=W.outerWidth,O=W.outerHeight,F=z({width:r,height:i,projectionType:s,projectionScale:f,projectionTranslation:h,projectionRotation:p,fillColor:g,borderWidth:m,borderColor:C}),L=F.graticule,E=F.path,S=F.getFillColor,G=F.getBorderWidth,x=F.getBorderColor,B=a(),P=v(),N=P.showTooltipFromEvent,I=P.hideTooltip,D=o((function(e,r){return j&&q&&q(e,r)}),[j,q]),K=o((function(e,r){return j&&T&&N(H(T,{feature:e}),r)}),[j,N,T]),V=o((function(e,r){return j&&T&&N(H(T,{feature:e}),r)}),[j,N,T]),A=o((function(){return j&&I()}),[j,I]);return H(d,{width:k,height:O,margin:w,theme:B,role:M,children:l.map((function(r,o){return"graticule"===r?!0!==b?null:H(te,{path:E,graticule:L,lineWidth:y,lineColor:R},"graticule"):"features"===r?H(t,{children:u.map((function(e){return H(ie,{feature:e,path:E,fillColor:S(e),borderWidth:G(e),borderColor:x(e),onMouseEnter:K,onMouseMove:V,onMouseLeave:A,onClick:D},e.id)}))},"features"):H(t,{children:r(e)},o)}))})}));ne.displayName="GeoMap",ne.propTypes=J,ne.defaultProps=$;var ae=s(ne),ue=function(e){return H(f,{children:function(r){var o=r.width,t=r.height;return H(ae,I({width:o,height:t},e))}})},le=function(e,r,o,t){var i=h(r,e),n=i[0],a=i[1];return o.find((function(e){return x(e,t.invert([n,a]))}))},ce=r((function(e){var r=e.width,t=e.height,u=e.margin,l=e.pixelRatio,d=e.features,s=e.layers,f=e.projectionType,h=e.projectionScale,p=e.projectionTranslation,g=e.projectionRotation,m=e.fillColor,C=e.borderWidth,b=e.borderColor,y=e.enableGraticule,R=e.graticuleLineWidth,j=e.graticuleLineColor,q=e.isInteractive,T=e.onClick,M=e.onMouseMove,W=e.tooltip,w=i(null),k=a(),O=c(r,t,u),F=O.margin,L=O.outerWidth,E=O.outerHeight,S=z({width:r,height:t,projectionType:f,projectionScale:h,projectionTranslation:p,projectionRotation:g,fillColor:m,borderWidth:C,borderColor:b}),G=S.projection,x=S.graticule,B=S.path,P=S.getFillColor,N=S.getBorderWidth,I=S.getBorderColor;n((function(){if(w){w.current.width=L*l,w.current.height=E*l;var r=w.current.getContext("2d");r.scale(l,l),r.fillStyle=k.background,r.fillRect(0,0,L,E),r.translate(F.left,F.top),B.context(r),s.forEach((function(o){"graticule"===o?!0===y&&(r.lineWidth=R,r.strokeStyle=j,r.beginPath(),B(x()),r.stroke()):"features"===o?d.forEach((function(e){r.beginPath(),B(e),r.fillStyle=P(e),r.fill();var o=N(e);o>0&&(r.strokeStyle=I(e),r.lineWidth=o,r.stroke())})):o(r,e)}))}}),[w,L,E,F,l,k,B,x,P,N,I,d,s]);var D=v(),K=D.showTooltipFromEvent,V=D.hideTooltip,A=o((function(e){if(q&&W){var r=le(e,w.current,d,G);r?K(H(W,{feature:r}),e):V(),M&&M(r||null,e)}}),[K,V,q,W,w,d,G]),J=o((function(){return q&&V()}),[q,V]),Q=o((function(e){if(q&&T){var r=le(e,w.current,d,G);r&&T(r,e)}}),[q,w,d,G,T]);return H("canvas",{ref:w,width:L*l,height:E*l,style:{width:L,height:E,cursor:q?"auto":"normal"},onMouseMove:A,onMouseLeave:J,onClick:Q})}));ce.displatName="GeoMapCanvas",ce.propTypes=Q,ce.defaultProps=_;var de=s(ce),se=function(e){return H(f,{children:function(r){var o=r.width,t=r.height;return H(de,I({width:o,height:t},e))}})},fe=r((function(e){var r=e.width,i=e.height,n=e.margin,u=e.features,l=e.data,s=e.match,f=e.label,h=e.value,g=e.valueFormat,m=e.projectionType,C=e.projectionScale,b=e.projectionTranslation,y=e.projectionRotation,R=e.colors,j=e.domain,q=e.unknownColor,T=e.borderWidth,M=e.borderColor,W=e.enableGraticule,w=e.graticuleLineWidth,k=e.graticuleLineColor,O=e.layers,F=e.legends,L=e.isInteractive,E=e.onClick,S=e.tooltip,G=e.role,x=e.defs,B=void 0===x?re.defs:x,N=e.fill,D=void 0===N?re.fill:N,V=c(r,i,n),A=V.margin,J=V.outerWidth,Q=V.outerHeight,U=z({width:r,height:i,projectionType:m,projectionScale:C,projectionTranslation:b,projectionRotation:y,fillColor:function(){},borderWidth:T,borderColor:M}),X=U.graticule,Y=U.path,Z=U.getBorderWidth,$=U.getBorderColor,_=K({features:u,data:l,match:s,label:f,value:h,valueFormat:g,colors:R,unknownColor:q,domain:j}),ee=_.getFillColor,oe=_.boundFeatures,ne=_.legendData,ae=a(),ue=p(B,oe,D,{dataKey:"data",targetKey:"fill"}),le=v(),ce=le.showTooltipFromEvent,de=le.hideTooltip,se=o((function(e,r){return L&&E&&E(e,r)}),[L,E]),fe=o((function(e,r){return L&&S&&ce(H(S,{feature:e}),r)}),[L,ce,S]),he=o((function(e,r){return L&&S&&ce(H(S,{feature:e}),r)}),[L,ce,S]),pe=o((function(){return L&&de()}),[L,de]);return H(d,{width:J,height:Q,margin:A,theme:ae,defs:ue,role:G,children:O.map((function(e,o){return"graticule"===e?!0!==W?null:H(te,{path:Y,graticule:X,lineWidth:w,lineColor:k},"graticule"):"features"===e?H(t,{children:oe.map((function(e){return H(ie,{feature:e,path:Y,fillColor:ee(e),borderWidth:Z(e),borderColor:$(e),onMouseEnter:fe,onMouseMove:he,onMouseLeave:pe,onClick:se},e.id)}))},"features"):"legends"===e?F.map((function(e,o){return H(P,I({containerWidth:r,containerHeight:i,data:ne},e),o)})):H(t,{children:e({})},o)}))})}));fe.displayName="Choropleth",fe.propTypes=X,fe.defaultProps=re;var he=s(fe),pe=function(e){return H(f,{children:function(r){var o=r.width,t=r.height;return H(he,I({width:o,height:t},e))}})},ge=function(e,r,o,t){var i=h(r,e),n=i[0],a=i[1];return o.find((function(e){return x(e,t.invert([n,a]))}))},ve=r((function(e){var r=e.width,t=e.height,u=e.margin,l=e.pixelRatio,d=e.features,s=e.data,f=e.match,h=e.label,p=e.value,g=e.valueFormat,m=e.projectionType,C=e.projectionScale,b=e.projectionTranslation,y=e.projectionRotation,R=e.colors,j=e.domain,q=e.unknownColor,T=e.borderWidth,M=e.borderColor,W=e.enableGraticule,w=e.graticuleLineWidth,k=e.graticuleLineColor,O=e.layers,F=e.legends,L=e.isInteractive,E=e.onClick,S=e.onMouseMove,G=e.tooltip,x=i(null),B=a(),P=c(r,t,u),D=P.margin,V=P.outerWidth,A=P.outerHeight,J=z({width:r,height:t,projectionType:m,projectionScale:C,projectionTranslation:b,projectionRotation:y,fillColor:function(){},borderWidth:T,borderColor:M}),Q=J.projection,U=J.graticule,X=J.path,Y=J.getBorderWidth,Z=J.getBorderColor,$=K({features:d,data:s,match:f,label:h,value:p,valueFormat:g,colors:R,unknownColor:q,domain:j}),_=$.getFillColor,ee=$.boundFeatures,re=$.legendData;n((function(){if(x){x.current.width=V*l,x.current.height=A*l;var e=x.current.getContext("2d");e.scale(l,l),e.fillStyle=B.background,e.fillRect(0,0,V,A),e.translate(D.left,D.top),X.context(e),O.forEach((function(o){"graticule"===o?!0===W&&(e.lineWidth=w,e.strokeStyle=k,e.beginPath(),X(U()),e.stroke()):"features"===o?ee.forEach((function(r){e.beginPath(),X(r),e.fillStyle=_(r),e.fill();var o=Y(r);o>0&&(e.strokeStyle=Z(r),e.lineWidth=o,e.stroke())})):"legends"===o&&F.forEach((function(o){N(e,I({},o,{data:re,containerWidth:r,containerHeight:t,theme:B}))}))}))}}),[x,V,A,D,l,B,X,U,_,Y,Z,ee,F,O]);var oe=v(),te=oe.showTooltipFromEvent,ie=oe.hideTooltip,ne=o((function(e){if(L&&G){var r=ge(e,x.current,ee,Q);r?te(H(G,{feature:r}),e):ie(),S&&S(r||null,e)}}),[te,ie,L,G,x,ee,Q]),ae=o((function(){return L&&ie()}),[L,ie]),ue=o((function(e){if(L&&E){var r=ge(e,x.current,ee,Q);r&&E(r,e)}}),[L,x,ee,Q,E]);return H("canvas",{ref:x,width:V*l,height:A*l,style:{width:V,height:A,cursor:L?"auto":"normal"},onMouseMove:ne,onMouseLeave:ae,onClick:ue})}));ve.displayName="ChoroplethCanvas",ve.propTypes=Y,ve.defaultProps=oe;var me=s(ve),Ce=function(e){return H(f,{children:function(r){var o=r.width,t=r.height;return H(me,I({width:o,height:t},e))}})};export{he as Choropleth,me as ChoroplethCanvas,oe as ChoroplethCanvasDefaultProps,Y as ChoroplethCanvasPropTypes,re as ChoroplethDefaultProps,X as ChoroplethPropTypes,ae as GeoMap,de as GeoMapCanvas,_ as GeoMapCanvasDefaultProps,Q as GeoMapCanvasPropTypes,$ as GeoMapDefaultProps,J as GeoMapPropTypes,pe as ResponsiveChoropleth,Ce as ResponsiveChoroplethCanvas,ue as ResponsiveGeoMap,se as ResponsiveGeoMapCanvas,D as projectionById,K as useChoropleth,z as useGeoMap};
import{useMemo as e,memo as r,useCallback as o,Fragment as t,useRef as i,useEffect as n}from"react";import{useTheme as a,guessQuantizeColorScale as u,quantizeColorScalePropType as l,useDimensions as c,SvgWrapper as d,withContainer as s,ResponsiveWrapper as f,getRelativeCursor as h,bindDefs as p}from"@nivo/core";import{BasicTooltip as g,useTooltip as v}from"@nivo/tooltip";import m from"prop-types";import{useInheritedColor as C,inheritedColorPropType as b}from"@nivo/colors";import y from"lodash/isFunction";import R from"lodash/get";import{format as j}from"d3-format";import{geoAzimuthalEqualArea as q,geoAzimuthalEquidistant as T,geoGnomonic as M,geoOrthographic as W,geoStereographic as w,geoEqualEarth as k,geoEquirectangular as F,geoMercator as O,geoTransverseMercator as L,geoNaturalEarth1 as E,geoPath as S,geoGraticule as G,geoContains as x}from"d3-geo";import{useQuantizeColorScaleLegendData as B,BoxLegendSvg as P,renderLegendToCanvas as N}from"@nivo/legends";import{jsx as H}from"react/jsx-runtime";function I(){return I=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&(e[t]=o[t])}return e},I.apply(this,arguments)}var D={azimuthalEqualArea:q,azimuthalEquidistant:T,gnomonic:M,orthographic:W,stereographic:w,equalEarth:k,equirectangular:F,mercator:O,transverseMercator:L,naturalEarth1:E},z=function(r){var o=r.width,t=r.height,i=r.projectionType,n=r.projectionScale,u=r.projectionTranslation,l=r.projectionRotation,c=r.fillColor,d=r.borderWidth,s=r.borderColor,f=e((function(){return D[i]().scale(n).translate([o*u[0],t*u[1]]).rotate(l)}),[o,t,i,n,u[0],u[1],l[0],l[1],l[2]]),h=e((function(){return S(f)}),[f]),p=e((function(){return G()})),g=a(),v=e((function(){return"function"==typeof d?d:function(){return d}}),[d]),m=C(s,g),b=e((function(){return"function"==typeof c?c:function(){return c}}),[c]);return{projection:f,path:h,graticule:p,getBorderWidth:v,getBorderColor:m,getFillColor:b}},K=function(r){var o=r.features,t=r.data,i=r.match,n=r.label,a=r.value,l=r.valueFormat,c=r.colors,d=r.unknownColor,s=r.domain,f=e((function(){return y(i)?i:function(e,r){var o=R(e,i),t=R(r,i);return o&&o===t}}),[i]),h=e((function(){return y(n)?n:function(e){return R(e,n)}}),[n]),p=e((function(){return y(a)?a:function(e){return R(e,a)}}),[a]),g=e((function(){return void 0===l?function(e){return e}:y(l)?l:j(l)}),[l]),v=e((function(){return u(c).domain(s)}),[c,s]),m=e((function(){return function(e){return void 0===e.value?d:v(e.value)}}),[v,d]),C=e((function(){return o.map((function(e){var r=t.find((function(r){return f(e,r)})),o=p(r);if(r){var i=I({},e,{data:r,value:o,formattedValue:g(o)});return i.color=m(i),i.label=h(i),i}return e}))}),[o,t,f,p,g,m]),b=B({scale:v,valueFormat:g});return{colorScale:v,getFillColor:m,boundFeatures:C,valueFormatter:g,legendData:b}},V=r((function(e){var r=e.feature;return void 0===r.data?null:H(g,{id:r.label,color:r.color,enableChip:!0,value:r.formattedValue})}));V.propTypes={feature:m.object.isRequired},V.displayName="ChoroplethTooltip";var A={features:m.arrayOf(m.shape({id:m.string.isRequired,type:m.oneOf(["Feature"]).isRequired,properties:m.object,geometry:m.object.isRequired})).isRequired,projectionType:m.oneOf(Object.keys(D)).isRequired,projectionScale:m.number.isRequired,projectionTranslation:m.arrayOf(m.number).isRequired,projectionRotation:m.arrayOf(m.number).isRequired,fillColor:m.oneOfType([m.string,m.func]).isRequired,borderWidth:m.oneOfType([m.number,m.func]).isRequired,borderColor:b.isRequired,enableGraticule:m.bool.isRequired,graticuleLineWidth:m.number.isRequired,graticuleLineColor:m.string.isRequired,isInteractive:m.bool.isRequired,onMouseEnter:m.func.isRequired,onMouseMove:m.func.isRequired,onMouseLeave:m.func.isRequired,onClick:m.func.isRequired,tooltip:m.any,layers:m.arrayOf(m.oneOfType([m.oneOf(["graticule","features"]),m.func])).isRequired},J=I({},A,{role:m.string.isRequired}),Q=I({pixelRatio:m.number.isRequired},A),U={data:m.arrayOf(m.object).isRequired,match:m.oneOfType([m.string,m.func]).isRequired,label:m.oneOfType([m.string,m.func]).isRequired,value:m.oneOfType([m.string,m.func]).isRequired,valueFormat:m.oneOfType([m.string,m.func]),colors:l.isRequired,domain:m.arrayOf(m.number).isRequired,unknownColor:m.string.isRequired,layers:m.arrayOf(m.oneOfType([m.oneOf(["graticule","features","legends"]),m.func])).isRequired},X=I({},J,U,{role:m.string.isRequired}),Y=I({},Q,U),Z={projectionType:"mercator",projectionScale:100,projectionTranslation:[.5,.5],projectionRotation:[0,0,0],enableGraticule:!1,graticuleLineWidth:.5,graticuleLineColor:"#999999",fillColor:"#dddddd",borderWidth:0,borderColor:"#000000",isInteractive:!0,onMouseEnter:function(){},onMouseLeave:function(){},onMouseMove:function(){},onClick:function(){},layers:["graticule","features"],legends:[],fill:[],defs:[]},$=I({},Z,{role:"img"}),_=I({},Z,{pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1}),ee={match:"id",label:"id",value:"value",colors:"PuBuGn",unknownColor:"#999",tooltip:V,layers:["graticule","features","legends"]},re=I({},$,ee,{role:"img"}),oe=I({},_,ee),te=r((function(e){var r=e.path,o=e.graticule,t=e.lineWidth,i=e.lineColor;return H("path",{fill:"none",strokeWidth:t,stroke:i,d:r(o())})}));te.propTypes={path:m.func.isRequired,graticule:m.func.isRequired,lineWidth:m.number.isRequired,lineColor:m.string.isRequired},te.displayName="GeoGraticule";var ie=r((function(e){var r,o=e.feature,t=e.path,i=e.fillColor,n=e.borderWidth,a=e.borderColor,u=e.onClick,l=e.onMouseEnter,c=e.onMouseMove,d=e.onMouseLeave;return H("path",{fill:null!=(r=null==o?void 0:o.fill)?r:i,strokeWidth:n,stroke:a,strokeLinejoin:"bevel",d:t(o),onMouseEnter:function(e){return l(o,e)},onMouseMove:function(e){return c(o,e)},onMouseLeave:function(e){return d(o,e)},onClick:function(e){return u(o,e)}},o.id)}));ie.propTypes={feature:m.shape({id:m.string.isRequired,type:m.oneOf(["Feature"]).isRequired,properties:m.object,geometry:m.object.isRequired}).isRequired,path:m.func.isRequired,fillColor:m.string.isRequired,borderWidth:m.number.isRequired,borderColor:m.string.isRequired,onMouseEnter:m.func.isRequired,onMouseMove:m.func.isRequired,onMouseLeave:m.func.isRequired,onClick:m.func.isRequired},ie.displayName="GeoMapFeature";var ne=r((function(e){var r=e.width,i=e.height,n=e.margin,u=e.features,l=e.layers,s=e.projectionType,f=e.projectionScale,h=e.projectionTranslation,p=e.projectionRotation,g=e.fillColor,m=e.borderWidth,C=e.borderColor,b=e.enableGraticule,y=e.graticuleLineWidth,R=e.graticuleLineColor,j=e.isInteractive,q=e.onClick,T=e.tooltip,M=e.role,W=c(r,i,n),w=W.margin,k=W.outerWidth,F=W.outerHeight,O=z({width:r,height:i,projectionType:s,projectionScale:f,projectionTranslation:h,projectionRotation:p,fillColor:g,borderWidth:m,borderColor:C}),L=O.graticule,E=O.path,S=O.getFillColor,G=O.getBorderWidth,x=O.getBorderColor,B=a(),P=v(),N=P.showTooltipFromEvent,I=P.hideTooltip,D=o((function(e,r){return j&&q&&q(e,r)}),[j,q]),K=o((function(e,r){return j&&T&&N(H(T,{feature:e}),r)}),[j,N,T]),V=o((function(e,r){return j&&T&&N(H(T,{feature:e}),r)}),[j,N,T]),A=o((function(){return j&&I()}),[j,I]);return H(d,{width:k,height:F,margin:w,theme:B,role:M,children:l.map((function(r,o){return"graticule"===r?!0!==b?null:H(te,{path:E,graticule:L,lineWidth:y,lineColor:R},"graticule"):"features"===r?H(t,{children:u.map((function(e){return H(ie,{feature:e,path:E,fillColor:S(e),borderWidth:G(e),borderColor:x(e),onMouseEnter:K,onMouseMove:V,onMouseLeave:A,onClick:D},e.id)}))},"features"):H(t,{children:r(e)},o)}))})}));ne.displayName="GeoMap",ne.propTypes=J,ne.defaultProps=$;var ae=s(ne),ue=function(e){return H(f,{children:function(r){var o=r.width,t=r.height;return H(ae,I({width:o,height:t},e))}})},le=function(e,r,o,t){var i=h(r,e),n=i[0],a=i[1];return o.find((function(e){return x(e,t.invert([n,a]))}))},ce=r((function(e){var r=e.width,t=e.height,u=e.margin,l=e.pixelRatio,d=e.features,s=e.layers,f=e.projectionType,h=e.projectionScale,p=e.projectionTranslation,g=e.projectionRotation,m=e.fillColor,C=e.borderWidth,b=e.borderColor,y=e.enableGraticule,R=e.graticuleLineWidth,j=e.graticuleLineColor,q=e.isInteractive,T=e.onClick,M=e.onMouseMove,W=e.tooltip,w=i(null),k=a(),F=c(r,t,u),O=F.margin,L=F.outerWidth,E=F.outerHeight,S=z({width:r,height:t,projectionType:f,projectionScale:h,projectionTranslation:p,projectionRotation:g,fillColor:m,borderWidth:C,borderColor:b}),G=S.projection,x=S.graticule,B=S.path,P=S.getFillColor,N=S.getBorderWidth,I=S.getBorderColor;n((function(){if(w){w.current.width=L*l,w.current.height=E*l;var r=w.current.getContext("2d");r.scale(l,l),r.fillStyle=k.background,r.fillRect(0,0,L,E),r.translate(O.left,O.top),B.context(r),s.forEach((function(o){"graticule"===o?!0===y&&(r.lineWidth=R,r.strokeStyle=j,r.beginPath(),B(x()),r.stroke()):"features"===o?d.forEach((function(e){r.beginPath(),B(e),r.fillStyle=P(e),r.fill();var o=N(e);o>0&&(r.strokeStyle=I(e),r.lineWidth=o,r.stroke())})):o(r,e)}))}}),[w,L,E,O,l,k,B,x,P,N,I,d,s]);var D=v(),K=D.showTooltipFromEvent,V=D.hideTooltip,A=o((function(e){if(q&&W){var r=le(e,w.current,d,G);r?K(H(W,{feature:r}),e):V(),M&&M(r||null,e)}}),[K,V,q,W,w,d,G]),J=o((function(){return q&&V()}),[q,V]),Q=o((function(e){if(q&&T){var r=le(e,w.current,d,G);r&&T(r,e)}}),[q,w,d,G,T]);return H("canvas",{ref:w,width:L*l,height:E*l,style:{width:L,height:E,cursor:q?"auto":"normal"},onMouseMove:A,onMouseLeave:J,onClick:Q})}));ce.displatName="GeoMapCanvas",ce.propTypes=Q,ce.defaultProps=_;var de=s(ce),se=function(e){return H(f,{children:function(r){var o=r.width,t=r.height;return H(de,I({width:o,height:t},e))}})},fe=r((function(e){var r=e.width,i=e.height,n=e.margin,u=e.features,l=e.data,s=e.match,f=e.label,h=e.value,g=e.valueFormat,m=e.projectionType,C=e.projectionScale,b=e.projectionTranslation,y=e.projectionRotation,R=e.colors,j=e.domain,q=e.unknownColor,T=e.borderWidth,M=e.borderColor,W=e.enableGraticule,w=e.graticuleLineWidth,k=e.graticuleLineColor,F=e.layers,O=e.legends,L=e.isInteractive,E=e.onClick,S=e.tooltip,G=e.role,x=e.defs,B=void 0===x?re.defs:x,N=e.fill,D=void 0===N?re.fill:N,V=c(r,i,n),A=V.margin,J=V.outerWidth,Q=V.outerHeight,U=z({width:r,height:i,projectionType:m,projectionScale:C,projectionTranslation:b,projectionRotation:y,fillColor:function(){},borderWidth:T,borderColor:M}),X=U.graticule,Y=U.path,Z=U.getBorderWidth,$=U.getBorderColor,_=K({features:u,data:l,match:s,label:f,value:h,valueFormat:g,colors:R,unknownColor:q,domain:j}),ee=_.getFillColor,oe=_.boundFeatures,ne=_.legendData,ae=a(),ue=p(B,oe,D,{dataKey:"data",targetKey:"fill"}),le=v(),ce=le.showTooltipFromEvent,de=le.hideTooltip,se=o((function(e,r){return L&&E&&E(e,r)}),[L,E]),fe=o((function(e,r){return L&&S&&ce(H(S,{feature:e}),r)}),[L,ce,S]),he=o((function(e,r){return L&&S&&ce(H(S,{feature:e}),r)}),[L,ce,S]),pe=o((function(){return L&&de()}),[L,de]);return H(d,{width:J,height:Q,margin:A,theme:ae,defs:ue,role:G,children:F.map((function(e,o){return"graticule"===e?!0!==W?null:H(te,{path:Y,graticule:X,lineWidth:w,lineColor:k},"graticule"):"features"===e?H(t,{children:oe.map((function(e){return H(ie,{feature:e,path:Y,fillColor:ee(e),borderWidth:Z(e),borderColor:$(e),onMouseEnter:fe,onMouseMove:he,onMouseLeave:pe,onClick:se},e.id)}))},"features"):"legends"===e?O.map((function(e,o){return H(P,I({containerWidth:r,containerHeight:i,data:ne},e),o)})):H(t,{children:e({})},o)}))})}));fe.displayName="Choropleth",fe.propTypes=X,fe.defaultProps=re;var he=s(fe),pe=function(e){return H(f,{children:function(r){var o=r.width,t=r.height;return H(he,I({width:o,height:t},e))}})},ge=function(e,r,o,t){var i=h(r,e),n=i[0],a=i[1];return o.find((function(e){return x(e,t.invert([n,a]))}))},ve=r((function(e){var r=e.width,t=e.height,u=e.margin,l=e.pixelRatio,d=e.features,s=e.data,f=e.match,h=e.label,p=e.value,g=e.valueFormat,m=e.projectionType,C=e.projectionScale,b=e.projectionTranslation,y=e.projectionRotation,R=e.colors,j=e.domain,q=e.unknownColor,T=e.borderWidth,M=e.borderColor,W=e.enableGraticule,w=e.graticuleLineWidth,k=e.graticuleLineColor,F=e.layers,O=e.legends,L=e.isInteractive,E=e.onClick,S=e.onMouseMove,G=e.tooltip,x=i(null),B=a(),P=c(r,t,u),D=P.margin,V=P.outerWidth,A=P.outerHeight,J=z({width:r,height:t,projectionType:m,projectionScale:C,projectionTranslation:b,projectionRotation:y,fillColor:function(){},borderWidth:T,borderColor:M}),Q=J.projection,U=J.graticule,X=J.path,Y=J.getBorderWidth,Z=J.getBorderColor,$=K({features:d,data:s,match:f,label:h,value:p,valueFormat:g,colors:R,unknownColor:q,domain:j}),_=$.getFillColor,ee=$.boundFeatures,re=$.legendData;n((function(){if(x){x.current.width=V*l,x.current.height=A*l;var e=x.current.getContext("2d");e.scale(l,l),e.fillStyle=B.background,e.fillRect(0,0,V,A),e.translate(D.left,D.top),X.context(e),F.forEach((function(o){"graticule"===o?!0===W&&(e.lineWidth=w,e.strokeStyle=k,e.beginPath(),X(U()),e.stroke()):"features"===o?ee.forEach((function(r){e.beginPath(),X(r),e.fillStyle=_(r),e.fill();var o=Y(r);o>0&&(e.strokeStyle=Z(r),e.lineWidth=o,e.stroke())})):"legends"===o&&O.forEach((function(o){N(e,I({},o,{data:re,containerWidth:r,containerHeight:t,theme:B}))}))}))}}),[x,V,A,D,l,B,X,U,_,Y,Z,ee,O,F]);var oe=v(),te=oe.showTooltipFromEvent,ie=oe.hideTooltip,ne=o((function(e){if(L&&G){var r=ge(e,x.current,ee,Q);r?te(H(G,{feature:r}),e):ie(),S&&S(r||null,e)}}),[te,ie,L,G,x,ee,Q]),ae=o((function(){return L&&ie()}),[L,ie]),ue=o((function(e){if(L&&E){var r=ge(e,x.current,ee,Q);r&&E(r,e)}}),[L,x,ee,Q,E]);return H("canvas",{ref:x,width:V*l,height:A*l,style:{width:V,height:A,cursor:L?"auto":"normal"},onMouseMove:ne,onMouseLeave:ae,onClick:ue})}));ve.displayName="ChoroplethCanvas",ve.propTypes=Y,ve.defaultProps=oe;var me=s(ve),Ce=function(e){return H(f,{children:function(r){var o=r.width,t=r.height;return H(me,I({width:o,height:t},e))}})};export{he as Choropleth,me as ChoroplethCanvas,oe as ChoroplethCanvasDefaultProps,Y as ChoroplethCanvasPropTypes,re as ChoroplethDefaultProps,X as ChoroplethPropTypes,ae as GeoMap,de as GeoMapCanvas,_ as GeoMapCanvasDefaultProps,Q as GeoMapCanvasPropTypes,$ as GeoMapDefaultProps,J as GeoMapPropTypes,pe as ResponsiveChoropleth,Ce as ResponsiveChoroplethCanvas,ue as ResponsiveGeoMap,se as ResponsiveGeoMapCanvas,D as projectionById,K as useChoropleth,z as useGeoMap};
//# sourceMappingURL=nivo-geo.es.js.map
{
"name": "@nivo/geo",
"version": "0.83.0",
"version": "0.83.1",
"license": "MIT",

@@ -32,6 +32,6 @@ "author": {

"dependencies": {
"@nivo/colors": "0.83.0",
"@nivo/core": "0.83.0",
"@nivo/legends": "0.83.0",
"@nivo/tooltip": "0.83.0",
"@nivo/colors": "0.83.1",
"@nivo/core": "0.83.1",
"@nivo/legends": "0.83.1",
"@nivo/tooltip": "0.83.1",
"d3-format": "^1.4.4",

@@ -48,3 +48,3 @@ "d3-geo": "^1.11.3",

},
"gitHead": "5ee7cba46ac12deb04095d6555c3d12bc358a211"
"gitHead": "64f4a7d3a7e0c6525d1129648a44f2502c41fb4d"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc