{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "social-share-morph",
  "type": "registry:component",
  "title": "Social Share Morph",
  "description": "A Share pill that stretches in place into a toolbar of channels and a copy link field, with the share icon turning into a close icon. Copying sweeps a green fill under the link and confirms with a check.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "buttons",
    "share",
    "morph",
    "copy link",
    "toolbar",
    "social",
    "expand"
  ],
  "docs": "https://hyperblur.dev/effects/social-share-morph",
  "files": [
    {
      "path": "registry/hyperblur/social-share-morph.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/social-share-morph.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type SocialProviderId =\n  | \"google\"\n  | \"github\"\n  | \"apple\"\n  | \"x\"\n  | \"linkedin\"\n  | \"discord\"\n  | \"facebook\"\n  | \"microsoft\"\n  | \"slack\"\n  | \"spotify\"\n  | \"twitch\"\n  | \"figma\"\n  | \"email\"\n  | \"link\";\n\nexport interface SocialProviderConfig {\n  id: string;\n  label?: string;\n  icon?: React.ReactNode;\n  color?: string;\n  bg?: string;\n  fg?: string;\n}\n\nexport type SocialProvider = SocialProviderId | SocialProviderConfig;\n\nconst BRANDS: Record<SocialProviderId, { label: string; color: string; bg: string; fg: string }> = {\n  google: { label: \"Google\", color: \"#4285f4\", bg: \"#ffffff\", fg: \"#1f1f1f\" },\n  github: { label: \"GitHub\", color: \"#c9d1d9\", bg: \"#24292f\", fg: \"#ffffff\" },\n  apple: { label: \"Apple\", color: \"#f5f5f7\", bg: \"#000000\", fg: \"#ffffff\" },\n  x: { label: \"X\", color: \"#e7e9ea\", bg: \"#0f1419\", fg: \"#ffffff\" },\n  linkedin: { label: \"LinkedIn\", color: \"#3b8fe0\", bg: \"#0a66c2\", fg: \"#ffffff\" },\n  discord: { label: \"Discord\", color: \"#7983f5\", bg: \"#5865f2\", fg: \"#ffffff\" },\n  facebook: { label: \"Facebook\", color: \"#4a95f5\", bg: \"#1877f2\", fg: \"#ffffff\" },\n  microsoft: { label: \"Microsoft\", color: \"#36b3f0\", bg: \"#2f2f2f\", fg: \"#ffffff\" },\n  slack: { label: \"Slack\", color: \"#e8587f\", bg: \"#4a154b\", fg: \"#ffffff\" },\n  spotify: { label: \"Spotify\", color: \"#1ed760\", bg: \"#1db954\", fg: \"#04140a\" },\n  twitch: { label: \"Twitch\", color: \"#a970ff\", bg: \"#9146ff\", fg: \"#ffffff\" },\n  figma: { label: \"Figma\", color: \"#b17cff\", bg: \"#1e1e1e\", fg: \"#ffffff\" },\n  email: { label: \"Email\", color: \"#f5b450\", bg: \"#2a2014\", fg: \"#ffe8c2\" },\n  link: { label: \"Copy link\", color: \"#a1a1a1\", bg: \"#262626\", fg: \"#ededed\" },\n};\n\nfunction Glyph({ id }: { id: string }) {\n  let body: React.ReactNode;\n  switch (id) {\n    case \"google\":\n      body = <path d=\"M18.4 7.2A8 8 0 1 0 20 12h-7.4\" />;\n      break;\n    case \"github\":\n      body = (\n        <>\n          <circle cx=\"7\" cy=\"5.5\" r=\"2.1\" />\n          <circle cx=\"7\" cy=\"18.5\" r=\"2.1\" />\n          <circle cx=\"17\" cy=\"7\" r=\"2.1\" />\n          <path d=\"M7 7.6v8.8M17 9.1v1.2a3 3 0 0 1-3 3h-4a3 3 0 0 0-3 3\" />\n        </>\n      );\n      break;\n    case \"apple\":\n      body = (\n        <>\n          <path d=\"M12 8.2c-1.7-1.3-4.7-1.2-6 1.1-1.5 2.6-.5 6.9 1.6 9.4 1.1 1.3 2.2 1.6 3.2 1.1.8-.4 1.6-.4 2.4 0 1 .5 2.1.2 3.2-1.1 2.1-2.5 3.1-6.8 1.6-9.4-1.3-2.3-4.3-2.4-6-1.1z\" />\n          <path d=\"M12 8.2c0-1.7.5-2.9 1.6-3.9\" />\n        </>\n      );\n      break;\n    case \"x\":\n      body = <path d=\"M5.5 5.5l13 13M18.5 5.5l-13 13\" />;\n      break;\n    case \"linkedin\":\n      body = (\n        <>\n          <circle cx=\"6.5\" cy=\"6\" r=\"1.3\" fill=\"currentColor\" stroke=\"none\" />\n          <path d=\"M6.5 10v8.5M11 18.5V10m0 3.4c0-2 1.5-3.4 3.3-3.4s3.2 1.4 3.2 3.4v5.1\" />\n        </>\n      );\n      break;\n    case \"discord\":\n      body = (\n        <>\n          <path d=\"M7.6 7.5h8.8a4 4 0 0 1 3.9 3.1l.9 4.1a2.3 2.3 0 0 1-3.9 2.1l-1.9-1.9H8.6l-1.9 1.9a2.3 2.3 0 0 1-3.9-2.1l.9-4.1a4 4 0 0 1 3.9-3.1z\" />\n          <path d=\"M8.2 10.4v2.8M6.8 11.8h2.8\" />\n          <circle cx=\"15.6\" cy=\"11\" r=\".8\" fill=\"currentColor\" stroke=\"none\" />\n          <circle cx=\"17.2\" cy=\"12.6\" r=\".8\" fill=\"currentColor\" stroke=\"none\" />\n        </>\n      );\n      break;\n    case \"facebook\":\n      body = <path d=\"M15.5 4.5h-1.8a2.7 2.7 0 0 0-2.7 2.7v12.3M8.5 11h6.5\" />;\n      break;\n    case \"microsoft\":\n      body = (\n        <>\n          <rect x=\"4.5\" y=\"4.5\" width=\"6.4\" height=\"6.4\" rx=\"1.4\" />\n          <rect x=\"13.1\" y=\"4.5\" width=\"6.4\" height=\"6.4\" rx=\"1.4\" />\n          <rect x=\"4.5\" y=\"13.1\" width=\"6.4\" height=\"6.4\" rx=\"1.4\" />\n          <rect x=\"13.1\" y=\"13.1\" width=\"6.4\" height=\"6.4\" rx=\"1.4\" />\n        </>\n      );\n      break;\n    case \"slack\":\n      body = <path d=\"M10 4.5 8.4 19.5M15.6 4.5 14 19.5M5 9.2h14.5M4.5 14.8H19\" />;\n      break;\n    case \"spotify\":\n      body = <path d=\"M4.5 10.5v3M8.25 7.5v9M12 4.5v15M15.75 8v8M19.5 10.5v3\" />;\n      break;\n    case \"twitch\":\n      body = (\n        <>\n          <path d=\"M6.5 4.5h11a2 2 0 0 1 2 2V14a2 2 0 0 1-2 2H12l-4 3.5V16H6.5a2 2 0 0 1-2-2V6.5a2 2 0 0 1 2-2z\" />\n          <path d=\"M10.2 8.5v3.2M14.4 8.5v3.2\" />\n        </>\n      );\n      break;\n    case \"figma\":\n      body = (\n        <>\n          <path d=\"M12 3.5 18 11l-6 9.5L6 11z\" />\n          <path d=\"M12 3.5v8\" />\n          <circle cx=\"12\" cy=\"13\" r=\"1.5\" />\n        </>\n      );\n      break;\n    case \"email\":\n      body = (\n        <>\n          <rect x=\"3.5\" y=\"5.5\" width=\"17\" height=\"13\" rx=\"2.5\" />\n          <path d=\"m4.5 7.5 7.5 5.5 7.5-5.5\" />\n        </>\n      );\n      break;\n    case \"link\":\n      body = (\n        <>\n          <path d=\"M10.2 13.8a3.6 3.6 0 0 0 5.1 0l3-3a3.6 3.6 0 0 0-5.1-5.1l-1.1 1.1\" />\n          <path d=\"M13.8 10.2a3.6 3.6 0 0 0-5.1 0l-3 3a3.6 3.6 0 0 0 5.1 5.1l1.1-1.1\" />\n        </>\n      );\n      break;\n    default:\n      body = <circle cx=\"12\" cy=\"12\" r=\"7\" />;\n  }\n  return (\n    <svg\n      viewBox=\"0 0 24 24\"\n      width=\"1em\"\n      height=\"1em\"\n      fill=\"none\"\n      stroke=\"currentColor\"\n      strokeWidth={1.9}\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n      aria-hidden=\"true\"\n      focusable=\"false\"\n    >\n      {body}\n    </svg>\n  );\n}\n\ninterface ResolvedProvider {\n  id: string;\n  label: string;\n  color: string;\n  bg: string;\n  fg: string;\n  icon: React.ReactNode;\n}\n\nfunction resolveProvider(p: SocialProvider): ResolvedProvider {\n  const cfg: SocialProviderConfig = typeof p === \"string\" ? { id: p } : p;\n  const brand = BRANDS[cfg.id as SocialProviderId] as (typeof BRANDS)[SocialProviderId] | undefined;\n  return {\n    id: cfg.id,\n    label: cfg.label ?? brand?.label ?? cfg.id,\n    color: cfg.color ?? brand?.color ?? \"#2f7bff\",\n    bg: cfg.bg ?? brand?.bg ?? cfg.color ?? \"#2f7bff\",\n    fg: cfg.fg ?? brand?.fg ?? \"#ffffff\",\n    icon: cfg.icon ?? <Glyph id={cfg.id} />,\n  };\n}\n\nexport interface SocialShareMorphProps extends React.HTMLAttributes<HTMLDivElement> {\n  providers?: SocialProvider[];\n  url?: string;\n  label?: string;\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  onShare?: (provider: string) => void;\n  onCopyLink?: (url: string) => void;\n}\n\nconst css = `\n.hb-xc9 {\n  position: relative;\n  display: inline-flex;\n  align-items: center;\n  max-width: 100%;\n  height: 46px;\n  padding: 4px;\n  border-radius: 999px;\n  box-sizing: border-box;\n  font-family: inherit;\n  color: #ededed;\n  background: linear-gradient(180deg, #1b1b1b, #121212);\n  box-shadow: inset 0 0 0 1px #2a2a2a, inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 14px 30px -16px rgba(0, 0, 0, 0.9);\n  transition: box-shadow 0.4s ease;\n}\n.hb-xc9 *, .hb-xc9 *::before, .hb-xc9 *::after { box-sizing: border-box; }\n.hb-xc9[data-open=\"true\"] { box-shadow: inset 0 0 0 1px #333, inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 18px 36px -16px rgba(0, 0, 0, 0.95); }\n.hb-xc9-tg {\n  position: relative;\n  display: inline-flex;\n  align-items: center;\n  flex: none;\n  height: 38px;\n  min-width: 38px;\n  margin: 0;\n  padding: 0 11px;\n  border: 0;\n  border-radius: 999px;\n  font: inherit;\n  font-size: 13.5px;\n  font-weight: 600;\n  color: #0a0a0a;\n  background: linear-gradient(180deg, #ffffff, #e2e2e2);\n  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.12), 0 2px 6px -2px rgba(0, 0, 0, 0.5);\n  cursor: pointer;\n  -webkit-tap-highlight-color: transparent;\n  transition: background 0.35s ease, color 0.35s ease, box-shadow 0.35s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), padding 0.45s cubic-bezier(0.65, 0, 0.25, 1);\n}\n.hb-xc9-tg:active { transform: scale(0.94); }\n.hb-xc9-tg:focus-visible { outline: 2px solid #7fb3ff; outline-offset: 2px; }\n.hb-xc9[data-open=\"true\"] .hb-xc9-tg { padding: 0 9px; color: #ededed; background: #222; box-shadow: inset 0 0 0 1px #333; }\n.hb-xc9-ico { position: relative; display: inline-block; width: 18px; height: 18px; flex: none; }\n.hb-xc9-ico svg { position: absolute; inset: 0; width: 18px; height: 18px; transition: transform 0.45s cubic-bezier(0.34, 1.4, 0.5, 1), opacity 0.25s ease; }\n.hb-xc9-ico svg + svg { opacity: 0; transform: rotate(-90deg) scale(0.5); }\n.hb-xc9[data-open=\"true\"] .hb-xc9-ico svg:first-child { opacity: 0; transform: rotate(90deg) scale(0.5); }\n.hb-xc9[data-open=\"true\"] .hb-xc9-ico svg + svg { opacity: 1; transform: none; }\n.hb-xc9-lw { display: grid; grid-template-columns: 1fr; transition: grid-template-columns 0.45s cubic-bezier(0.65, 0, 0.25, 1); }\n.hb-xc9-lw > span { min-width: 0; overflow: hidden; white-space: nowrap; padding-left: 8px; transition: opacity 0.25s ease; }\n.hb-xc9[data-open=\"true\"] .hb-xc9-lw { grid-template-columns: 0fr; }\n.hb-xc9[data-open=\"true\"] .hb-xc9-lw > span { opacity: 0; }\n.hb-xc9-pw { display: grid; grid-template-columns: 0fr; min-width: 0; transition: grid-template-columns 0.5s cubic-bezier(0.65, 0, 0.25, 1); }\n.hb-xc9[data-open=\"true\"] .hb-xc9-pw { grid-template-columns: 1fr; }\n.hb-xc9-p { display: flex; align-items: center; gap: 2px; min-width: 0; overflow: hidden; padding-left: 4px; }\n.hb-xc9-n {\n  --hb-xc9-c: #7fb3ff;\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  flex: none;\n  width: 36px;\n  height: 36px;\n  margin: 0;\n  padding: 0;\n  border: 0;\n  border-radius: 50%;\n  font: inherit;\n  font-size: 17px;\n  color: #a1a1a1;\n  background: transparent;\n  cursor: pointer;\n  opacity: 0;\n  transform: translateX(-10px) scale(0.6);\n  transition: opacity 0.2s ease, transform 0.45s cubic-bezier(0.34, 1.5, 0.5, 1), color 0.2s ease, background 0.2s ease;\n  transition-delay: 0s;\n}\n.hb-xc9-n svg { display: block; }\n.hb-xc9[data-open=\"true\"] .hb-xc9-n { opacity: 1; transform: none; transition-delay: calc(0.12s + var(--hb-xc9-i) * 45ms), calc(0.12s + var(--hb-xc9-i) * 45ms), 0s, 0s; }\n.hb-xc9-n:hover, .hb-xc9-n:focus-visible { color: var(--hb-xc9-c); background: color-mix(in srgb, var(--hb-xc9-c) 13%, transparent); }\n.hb-xc9-n:focus-visible { outline: 2px solid var(--hb-xc9-c); outline-offset: -2px; }\n.hb-xc9-n[data-sent=\"true\"] { color: #3ddc84; }\n.hb-xc9-div { flex: none; width: 1px; height: 20px; margin: 0 6px; background: #2e2e2e; }\n.hb-xc9-cp {\n  position: relative;\n  display: inline-flex;\n  align-items: center;\n  gap: 8px;\n  flex: 0 1 auto;\n  min-width: 0;\n  height: 36px;\n  margin: 0;\n  padding: 0 6px 0 12px;\n  border: 0;\n  border-radius: 999px;\n  font: inherit;\n  font-size: 12px;\n  color: #a1a1a1;\n  background: #0c0c0c;\n  box-shadow: inset 0 0 0 1px #262626;\n  cursor: pointer;\n  overflow: hidden;\n  isolation: isolate;\n  opacity: 0;\n  transform: translateX(-10px);\n  transition: opacity 0.25s ease, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.3s ease;\n}\n.hb-xc9[data-open=\"true\"] .hb-xc9-cp { opacity: 1; transform: none; transition-delay: 0.26s, 0.26s, 0s; }\n.hb-xc9-cp:hover, .hb-xc9-cp:focus-visible { box-shadow: inset 0 0 0 1px #3a3a3a; }\n.hb-xc9-cp:focus-visible { outline: 2px solid #7fb3ff; outline-offset: 1px; }\n.hb-xc9-cp::before { content: \"\"; position: absolute; inset: 0; z-index: -1; background: color-mix(in srgb, #3ddc84 16%, transparent); transform: scaleX(0); transform-origin: left; transition: transform 0.5s cubic-bezier(0.65, 0, 0.25, 1); }\n.hb-xc9-cp[data-copied=\"true\"]::before { transform: scaleX(1); }\n.hb-xc9-url { min-width: 0; max-width: 96px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-family: var(--font-mono, ui-monospace, monospace); font-size: 11px; }\n.hb-xc9-cl { display: inline-flex; align-items: center; gap: 4px; flex: none; height: 26px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; color: #0a0a0a; background: #ededed; transition: background 0.3s ease, color 0.3s ease; }\n.hb-xc9-cp[data-copied=\"true\"] .hb-xc9-cl { color: #04140a; background: #3ddc84; }\n.hb-xc9-cl svg { width: 12px; height: 12px; }\n.hb-xc9-cl span { display: inline-block; animation: hb-xc9-in 0.3s cubic-bezier(0.22, 1, 0.36, 1); }\n@keyframes hb-xc9-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xc9, .hb-xc9-tg, .hb-xc9-ico svg, .hb-xc9-lw, .hb-xc9-lw > span, .hb-xc9-pw, .hb-xc9-n, .hb-xc9-cp, .hb-xc9-cp::before, .hb-xc9-cl { transition: none !important; }\n  .hb-xc9-cl span { animation: none; }\n}\n`;\n\nexport function SocialShareMorph({\n  providers = [\"x\", \"linkedin\", \"email\"],\n  url = \"https://northwind.app/r/q3-report\",\n  label = \"Share\",\n  open: openProp,\n  defaultOpen = false,\n  onOpenChange,\n  onShare,\n  onCopyLink,\n  className = \"\",\n  onKeyDown,\n  ...rest\n}: SocialShareMorphProps) {\n  const items = providers.map(resolveProvider);\n  const [inner, setInner] = React.useState(defaultOpen);\n  const open = openProp ?? inner;\n  const [copied, setCopied] = React.useState(false);\n  const [sent, setSent] = React.useState<string | null>(null);\n  const trigRef = React.useRef<HTMLButtonElement>(null);\n  const firstRef = React.useRef<HTMLButtonElement>(null);\n  const timer = React.useRef<number | undefined>(undefined);\n  const display = url.replace(/^https?:[/][/]/, \"\");\n\n  React.useEffect(() => () => window.clearTimeout(timer.current), []);\n\n  function setOpen(next: boolean, keyboard = false) {\n    if (openProp === undefined) setInner(next);\n    onOpenChange?.(next);\n    if (!next) {\n      setCopied(false);\n      setSent(null);\n    }\n    if (next && keyboard) window.setTimeout(() => firstRef.current?.focus(), 140);\n  }\n\n  function flash(fn: () => void) {\n    window.clearTimeout(timer.current);\n    timer.current = window.setTimeout(fn, 1800);\n  }\n\n  function copy() {\n    if (typeof navigator !== \"undefined\" && navigator.clipboard) navigator.clipboard.writeText(url).catch(() => {});\n    setCopied(true);\n    onCopyLink?.(url);\n    flash(() => setCopied(false));\n  }\n\n  return (\n    <>\n      <style href=\"hb-social-share-morph\" precedence=\"default\">{css}</style>\n      <div\n        className={`hb-xc9 ${className}`}\n        data-open={open ? \"true\" : undefined}\n        role=\"group\"\n        aria-label={label}\n        onKeyDown={(e) => {\n          if (e.key === \"Escape\" && open) {\n            e.preventDefault();\n            setOpen(false);\n            trigRef.current?.focus();\n          }\n          onKeyDown?.(e);\n        }}\n        {...rest}\n      >\n        <button\n          ref={trigRef}\n          type=\"button\"\n          className=\"hb-xc9-tg\"\n          aria-expanded={open}\n          aria-label={open ? \"Close share options\" : label}\n          onClick={(e) => setOpen(!open, e.detail === 0)}\n        >\n          <span className=\"hb-xc9-ico\" aria-hidden=\"true\">\n            <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\">\n              <circle cx=\"18\" cy=\"5.5\" r=\"2.5\" />\n              <circle cx=\"6\" cy=\"12\" r=\"2.5\" />\n              <circle cx=\"18\" cy=\"18.5\" r=\"2.5\" />\n              <path d=\"m8.2 10.8 7.6-4M8.2 13.2l7.6 4\" />\n            </svg>\n            <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2.2} strokeLinecap=\"round\">\n              <path d=\"M6.5 6.5l11 11M17.5 6.5l-11 11\" />\n            </svg>\n          </span>\n          <span className=\"hb-xc9-lw\">\n            <span>{label}</span>\n          </span>\n        </button>\n        <div className=\"hb-xc9-pw\" aria-hidden={open ? undefined : true}>\n          <div className=\"hb-xc9-p\">\n            {items.map((p, i) => (\n              <button\n                key={p.id}\n                ref={i === 0 ? firstRef : undefined}\n                type=\"button\"\n                className=\"hb-xc9-n\"\n                style={{ \"--hb-xc9-c\": p.color, \"--hb-xc9-i\": i } as React.CSSProperties}\n                data-sent={sent === p.id ? \"true\" : undefined}\n                tabIndex={open ? 0 : -1}\n                aria-label={`Share to ${p.label}`}\n                onClick={() => {\n                  setSent(p.id);\n                  onShare?.(p.id);\n                  flash(() => setSent(null));\n                }}\n              >\n                {p.icon}\n              </button>\n            ))}\n            <span className=\"hb-xc9-div\" aria-hidden=\"true\" />\n            <button\n              type=\"button\"\n              className=\"hb-xc9-cp\"\n              data-copied={copied ? \"true\" : undefined}\n              tabIndex={open ? 0 : -1}\n              aria-label={copied ? \"Link copied\" : `Copy link ${display}`}\n              onClick={copy}\n            >\n              <span className=\"hb-xc9-url\">{display}</span>\n              <span className=\"hb-xc9-cl\">\n                <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                  {copied ? <path d=\"m3.5 8.5 3 3 6-6.5\" /> : <path d=\"M5.5 5.5V4a1.5 1.5 0 0 1 1.5-1.5h5A1.5 1.5 0 0 1 13.5 4v5a1.5 1.5 0 0 1-1.5 1.5h-1.5M4 5.5h5A1.5 1.5 0 0 1 10.5 7v5A1.5 1.5 0 0 1 9 13.5H4A1.5 1.5 0 0 1 2.5 12V7A1.5 1.5 0 0 1 4 5.5z\" />}\n                </svg>\n                <span key={copied ? \"c\" : \"n\"}>{copied ? \"Copied\" : \"Copy\"}</span>\n              </span>\n            </button>\n          </div>\n        </div>\n      </div>\n    </>\n  );\n}\n"
    }
  ]
}