{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "hexbin-map",
  "title": "Hexbin Map",
  "type": "registry:ui",
  "files": [
    {
      "path": "packages/registry-react/components/charts/hexbin-map/HexbinMap.tsx",
      "content": "'use client'\n\nimport * as React from 'react'\nimport { Map, MapMarker, type MapVariant } from '@/components/ui/map'\nimport { cn } from '@/lib/utils'\nimport { Globe } from 'lucide-react'\n\nexport interface HexState {\n  id: string\n  name: string\n  col: number\n  row: number\n}\n\nexport interface HexbinDatum {\n  value: number\n  status?: 'leader' | 'active' | 'growing' | 'developing' | 'neutral'\n  description?: string\n  color?: string\n}\n\nexport interface HexbinMapProps {\n  shape?: 'hexagon' | 'square'\n  preset?: 'us-states' | 'world-regions'\n  items?: HexState[]\n  data?: Record<string, HexbinDatum>\n  selected?: string\n  onSelectedChange?: (id: string | undefined) => void\n  onSelect?: (payload: { id: string; name: string; datum?: HexbinDatum }) => void\n  showLabels?: boolean\n  showValues?: boolean\n  valueFormatter?: (value: number) => string\n  colorRamp?: string[]\n  emptyColor?: string\n  height?: number | string\n  interactive?: boolean\n  className?: string\n  ariaLabel?: string\n}\n\nexport const US_HEX_STATES: HexState[] = [\n  { id: 'AK', name: 'Alaska', col: 0, row: 0 },\n  { id: 'ME', name: 'Maine', col: 11, row: 0 },\n  { id: 'WA', name: 'Washington', col: 1, row: 1 },\n  { id: 'ID', name: 'Idaho', col: 2, row: 1 },\n  { id: 'MT', name: 'Montana', col: 3, row: 1 },\n  { id: 'ND', name: 'North Dakota', col: 4, row: 1 },\n  { id: 'MN', name: 'Minnesota', col: 5, row: 1 },\n  { id: 'IL', name: 'Illinois', col: 6, row: 1 },\n  { id: 'WI', name: 'Wisconsin', col: 7, row: 1 },\n  { id: 'MI', name: 'Michigan', col: 8, row: 1 },\n  { id: 'NY', name: 'New York', col: 9, row: 1 },\n  { id: 'VT', name: 'Vermont', col: 10, row: 1 },\n  { id: 'NH', name: 'New Hampshire', col: 11, row: 1 },\n  { id: 'OR', name: 'Oregon', col: 1, row: 2 },\n  { id: 'NV', name: 'Nevada', col: 2, row: 2 },\n  { id: 'WY', name: 'Wyoming', col: 3, row: 2 },\n  { id: 'SD', name: 'South Dakota', col: 4, row: 2 },\n  { id: 'IA', name: 'Iowa', col: 5, row: 2 },\n  { id: 'IN', name: 'Indiana', col: 6, row: 2 },\n  { id: 'OH', name: 'Ohio', col: 7, row: 2 },\n  { id: 'PA', name: 'Pennsylvania', col: 8, row: 2 },\n  { id: 'NJ', name: 'New Jersey', col: 9, row: 2 },\n  { id: 'MA', name: 'Massachusetts', col: 10, row: 2 },\n  { id: 'RI', name: 'Rhode Island', col: 11, row: 2 },\n  { id: 'CA', name: 'California', col: 1, row: 3 },\n  { id: 'UT', name: 'Utah', col: 2, row: 3 },\n  { id: 'CO', name: 'Colorado', col: 3, row: 3 },\n  { id: 'NE', name: 'Nebraska', col: 4, row: 3 },\n  { id: 'MO', name: 'Missouri', col: 5, row: 3 },\n  { id: 'KY', name: 'Kentucky', col: 6, row: 3 },\n  { id: 'WV', name: 'West Virginia', col: 7, row: 3 },\n  { id: 'VA', name: 'Virginia', col: 8, row: 3 },\n  { id: 'MD', name: 'Maryland', col: 9, row: 3 },\n  { id: 'DE', name: 'Delaware', col: 10, row: 3 },\n  { id: 'AZ', name: 'Arizona', col: 2, row: 4 },\n  { id: 'NM', name: 'New Mexico', col: 3, row: 4 },\n  { id: 'KS', name: 'Kansas', col: 4, row: 4 },\n  { id: 'AR', name: 'Arkansas', col: 5, row: 4 },\n  { id: 'TN', name: 'Tennessee', col: 6, row: 4 },\n  { id: 'NC', name: 'North Carolina', col: 7, row: 4 },\n  { id: 'SC', name: 'South Carolina', col: 8, row: 4 },\n  { id: 'DC', name: 'District of Columbia', col: 9, row: 4 },\n  { id: 'CT', name: 'Connecticut', col: 10, row: 4 },\n  { id: 'OK', name: 'Oklahoma', col: 4, row: 5 },\n  { id: 'LA', name: 'Louisiana', col: 5, row: 5 },\n  { id: 'MS', name: 'Mississippi', col: 6, row: 5 },\n  { id: 'AL', name: 'Alabama', col: 7, row: 5 },\n  { id: 'GA', name: 'Georgia', col: 8, row: 5 },\n  { id: 'HI', name: 'Hawaii', col: 0, row: 6 },\n  { id: 'TX', name: 'Texas', col: 4, row: 6 },\n  { id: 'FL', name: 'Florida', col: 8, row: 6 },\n]\n\nexport const WORLD_HEX_REGIONS: HexState[] = [\n  { id: 'CA', name: 'Canada', col: 2, row: 0 },\n  { id: 'GL', name: 'Greenland', col: 4, row: 0 },\n  { id: 'NO', name: 'Nordics', col: 6, row: 0 },\n  { id: 'US-W', name: 'US West', col: 1, row: 1 },\n  { id: 'US-E', name: 'US East', col: 2, row: 1 },\n  { id: 'UK', name: 'United Kingdom', col: 5, row: 1 },\n  { id: 'EU-W', name: 'Western Europe', col: 6, row: 1 },\n  { id: 'EU-E', name: 'Eastern Europe', col: 7, row: 1 },\n  { id: 'RU', name: 'Northern Eurasia', col: 8, row: 1 },\n  { id: 'MX', name: 'Mexico', col: 1, row: 2 },\n  { id: 'MED', name: 'Mediterranean', col: 6, row: 2 },\n  { id: 'ME', name: 'Middle East', col: 7, row: 2 },\n  { id: 'CN', name: 'East Asia', col: 8, row: 2 },\n  { id: 'JP', name: 'Japan', col: 9, row: 2 },\n  { id: 'BR', name: 'Brazil', col: 2, row: 3 },\n  { id: 'AF-N', name: 'North Africa', col: 5, row: 3 },\n  { id: 'IN', name: 'South Asia', col: 7, row: 3 },\n  { id: 'SEA', name: 'Southeast Asia', col: 8, row: 3 },\n  { id: 'AR', name: 'South Cone', col: 2, row: 4 },\n  { id: 'AF-S', name: 'Sub-Saharan', col: 5, row: 4 },\n  { id: 'AU', name: 'Australia & Oceania', col: 8, row: 4 },\n]\n\nconst US_CENTROIDS: Record<string, [number, number]> = {\n  AK: [-152.4, 64.2],\n  ME: [-69.4, 45.3],\n  WA: [-120.7, 47.7],\n  ID: [-114.7, 44.1],\n  MT: [-110.4, 46.9],\n  ND: [-100.5, 47.5],\n  MN: [-94.6, 46.7],\n  IL: [-89.4, 40.6],\n  WI: [-89.6, 43.8],\n  MI: [-85.6, 44.3],\n  NY: [-74.2, 43.3],\n  VT: [-72.6, 44.6],\n  NH: [-71.6, 43.2],\n  OR: [-120.5, 43.8],\n  NV: [-116.4, 38.8],\n  WY: [-107.3, 43.1],\n  SD: [-99.9, 44.3],\n  IA: [-93.5, 42.0],\n  IN: [-86.1, 40.3],\n  OH: [-82.9, 40.4],\n  PA: [-77.2, 41.2],\n  NJ: [-74.4, 40.1],\n  MA: [-71.4, 42.4],\n  RI: [-71.5, 41.6],\n  CA: [-119.4, 36.8],\n  UT: [-111.1, 39.3],\n  CO: [-105.8, 39.5],\n  NE: [-99.9, 41.5],\n  MO: [-91.8, 37.9],\n  KY: [-84.3, 37.8],\n  WV: [-80.4, 38.6],\n  VA: [-78.7, 37.4],\n  MD: [-76.6, 39.0],\n  DE: [-75.5, 39.0],\n  AZ: [-111.1, 34.0],\n  NM: [-106.0, 34.5],\n  KS: [-98.5, 38.5],\n  AR: [-92.3, 34.8],\n  TN: [-86.6, 35.5],\n  NC: [-79.0, 35.8],\n  SC: [-81.2, 33.8],\n  DC: [-77.0, 38.9],\n  CT: [-72.7, 41.6],\n  OK: [-97.5, 35.0],\n  LA: [-91.9, 30.9],\n  MS: [-89.7, 32.4],\n  AL: [-86.9, 32.3],\n  GA: [-83.6, 32.2],\n  HI: [-157.8, 21.3],\n  TX: [-99.9, 31.9],\n  FL: [-81.5, 27.6],\n}\n\nfunction getCoords(item: HexState): [number, number] {\n  if (US_CENTROIDS[item.id]) return US_CENTROIDS[item.id]\n  const lng = -120 + item.col * 14\n  const lat = 50 - item.row * 8\n  return [lng, lat]\n}\n\nexport function HexbinMap({\n  shape = 'hexagon',\n  preset = 'us-states',\n  items,\n  data = {},\n  selected: controlledSelected,\n  onSelectedChange,\n  onSelect,\n  showLabels = true,\n  showValues = false,\n  valueFormatter = (v: number) => v.toLocaleString(),\n  colorRamp = [\n    'oklch(0.92 0.05 162)',\n    'oklch(0.82 0.10 162)',\n    'oklch(0.72 0.14 162)',\n    'oklch(0.62 0.17 162)',\n    'oklch(0.50 0.18 162)',\n    'oklch(0.38 0.16 162)',\n  ],\n  emptyColor = 'rgba(255, 255, 255, 0.08)',\n  height = 480,\n  interactive = true,\n  className,\n}: HexbinMapProps) {\n  const [internalSelected, setInternalSelected] = React.useState<string | undefined>(controlledSelected)\n  const [projection, setProjection] = React.useState<'globe' | 'mercator'>(\n    preset === 'world-regions' ? 'globe' : 'mercator',\n  )\n\n  const activeSelected = controlledSelected !== undefined ? controlledSelected : internalSelected\n\n  const activeItems = React.useMemo(() => {\n    if (items && items.length > 0) return items\n    return preset === 'world-regions' ? WORLD_HEX_REGIONS : US_HEX_STATES\n  }, [items, preset])\n\n  const values = React.useMemo(() => {\n    return Object.values(data)\n      .map((d) => d.value)\n      .filter((v) => typeof v === 'number')\n  }, [data])\n\n  const minValue = React.useMemo(() => (values.length ? Math.min(...values) : 0), [values])\n  const maxValue = React.useMemo(() => (values.length ? Math.max(...values) : 100), [values])\n\n  const getColor = React.useCallback(\n    (datum?: HexbinDatum): string => {\n      if (!datum) return emptyColor\n      if (datum.color) return datum.color\n\n      const val = datum.value\n      const span = maxValue - minValue\n      const normalized = span > 0 ? (val - minValue) / span : 0.5\n      const idx = Math.min(colorRamp.length - 1, Math.floor(normalized * colorRamp.length))\n      return colorRamp[idx]\n    },\n    [emptyColor, maxValue, minValue, colorRamp],\n  )\n\n  const activeStateItem = React.useMemo(\n    () => activeItems.find((it) => it.id === activeSelected),\n    [activeItems, activeSelected],\n  )\n  const activeStateDatum = React.useMemo(\n    () => (activeSelected ? data[activeSelected] : undefined),\n    [activeSelected, data],\n  )\n\n  const handleSelect = (item: HexState) => {\n    if (!interactive) return\n    setInternalSelected(item.id)\n    onSelectedChange?.(item.id)\n    onSelect?.({ id: item.id, name: item.name, datum: data[item.id] })\n  }\n\n  const mapCenter: [number, number] = React.useMemo(() => {\n    return preset === 'world-regions' ? [0, 20] : [-97, 39]\n  }, [preset])\n\n  const mapZoom = React.useMemo(() => {\n    return preset === 'world-regions' ? 1.5 : 3.6\n  }, [preset])\n\n  const toggleProjection = () => {\n    setProjection((prev) => (prev === 'globe' ? 'mercator' : 'globe'))\n  }\n\n  return (\n    <div\n      className={cn(\n        'border-border bg-card group relative w-full overflow-hidden rounded-xl border shadow-xs',\n        className,\n      )}\n      style={{ height: typeof height === 'number' ? `${height}px` : height }}\n    >\n      <Map variant=\"dark\" projection={projection} center={mapCenter} zoom={mapZoom} className=\"size-full\">\n        {activeItems.map((item) => {\n          const coords = getCoords(item)\n          const isSelected = activeSelected === item.id\n          const color = getColor(data[item.id])\n\n          return (\n            <MapMarker\n              key={item.id}\n              longitude={coords[0]}\n              latitude={coords[1]}\n              anchor=\"center\"\n              className={cn(\n                'cursor-pointer transition-transform select-none',\n                isSelected ? 'z-30 scale-115' : 'z-20 hover:scale-105',\n              )}\n            >\n              <button\n                type=\"button\"\n                className=\"group/hex relative flex size-10 items-center justify-center font-mono\"\n                onClick={() => handleSelect(item)}\n              >\n                <div\n                  className=\"absolute inset-0 flex items-center justify-center\"\n                  style={{\n                    clipPath:\n                      shape === 'hexagon' ? 'polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%)' : 'none',\n                    backgroundColor: color,\n                    border: isSelected ? '2px solid white' : '1px solid rgba(255,255,255,0.2)',\n                    boxShadow: isSelected ? `0 0 14px ${color}` : 'none',\n                  }}\n                />\n\n                <div className=\"relative z-10 flex flex-col items-center justify-center text-center\">\n                  <span className=\"text-[10px] font-bold text-white drop-shadow-sm\">{item.id}</span>\n                  {showValues && data[item.id] && (\n                    <span className=\"text-[8px] font-semibold text-white/90\">{Math.round(data[item.id].value)}</span>\n                  )}\n                </div>\n              </button>\n            </MapMarker>\n          )\n        })}\n      </Map>\n\n      <div className=\"border-border/70 bg-card/85 absolute top-3 right-3 z-10 flex items-center gap-1 rounded-lg border p-1 shadow-xs backdrop-blur-md\">\n        <button\n          type=\"button\"\n          className=\"text-muted-foreground hover:bg-muted hover:text-foreground flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs font-medium transition\"\n          onClick={toggleProjection}\n        >\n          <Globe className=\"size-3.5\" />\n          <span className=\"capitalize\">{projection}</span>\n        </button>\n      </div>\n\n      {activeStateItem && (\n        <div className=\"border-border/80 bg-card/95 animate-in fade-in slide-in-from-bottom-2 absolute bottom-3 left-3 z-10 max-w-sm rounded-xl border p-3.5 shadow-lg backdrop-blur-md duration-150\">\n          <div className=\"flex items-start justify-between gap-3\">\n            <div>\n              <div className=\"flex items-center gap-2\">\n                <span className=\"size-2 rounded-full\" style={{ backgroundColor: getColor(activeStateDatum) }} />\n                <span className=\"text-muted-foreground font-mono text-xs tracking-wider uppercase\">\n                  {activeStateDatum?.status || 'Region'}\n                </span>\n              </div>\n              <h4 className=\"text-foreground mt-0.5 text-sm font-semibold\">\n                {activeStateItem.name} ({activeStateItem.id})\n              </h4>\n            </div>\n            <button\n              type=\"button\"\n              className=\"text-muted-foreground hover:text-foreground text-xs\"\n              onClick={() => {\n                setInternalSelected(undefined)\n                onSelectedChange?.(undefined)\n              }}\n            >\n              ✕\n            </button>\n          </div>\n\n          {activeStateDatum && (\n            <div className=\"border-border/60 mt-2.5 flex items-baseline justify-between border-t pt-2 font-mono text-xs\">\n              <span className=\"text-muted-foreground\">Adoption Metric</span>\n              <span className=\"text-foreground font-semibold\">{valueFormatter(activeStateDatum.value)}%</span>\n            </div>\n          )}\n\n          {activeStateDatum?.description && (\n            <p className=\"text-muted-foreground mt-1.5 text-xs leading-relaxed\">{activeStateDatum.description}</p>\n          )}\n        </div>\n      )}\n\n      {values.length > 0 && (\n        <div className=\"border-border/70 bg-card/85 absolute right-3 bottom-3 z-10 hidden items-center gap-2 rounded-lg border px-3 py-2 text-xs shadow-xs backdrop-blur-md sm:flex\">\n          <span className=\"text-muted-foreground font-mono text-[10px]\">{minValue}</span>\n          <div className=\"flex h-2.5 gap-0.5 overflow-hidden rounded-xs\">\n            {colorRamp.map((c, i) => (\n              <div key={i} className=\"w-3\" style={{ backgroundColor: c }} />\n            ))}\n          </div>\n          <span className=\"text-foreground font-mono text-[10px] font-semibold\">{maxValue}</span>\n        </div>\n      )}\n    </div>\n  )\n}\n\nexport default HexbinMap\n",
      "type": "registry:ui",
      "target": "~/components/ui/charts/hexbin-map/HexbinMap.tsx"
    },
    {
      "path": "packages/registry-react/components/charts/hexbin-map/index.ts",
      "content": "export {\n  HexbinMap,\n  US_HEX_STATES,\n  WORLD_HEX_REGIONS,\n  type HexbinMapProps,\n  type HexbinDatum,\n  type HexState,\n} from './HexbinMap'\nexport { default } from './HexbinMap'\n",
      "type": "registry:ui",
      "target": "~/components/ui/charts/hexbin-map/index.ts"
    }
  ],
  "dependencies": [
    "lucide-react"
  ],
  "devDependencies": [],
  "registryDependencies": [
    "https://uipkge.dev/r/react/map.json"
  ],
  "description": "React mirror of @uipkge/hexbin-map — see the Vue registry item for the canonical description.",
  "categories": [
    "chart"
  ]
}