{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "modal-zoom-origin",
  "type": "registry:component",
  "title": "Zoom Origin Dialog",
  "description": "A centered dialog that grows out of the exact button that opened it and shrinks back into it on close. Ships as a deploy confirmation with branch, checks and a publish button that fills while it works.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "modals",
    "dialog",
    "modal",
    "zoom",
    "flip",
    "deploy",
    "confirm"
  ],
  "docs": "https://hyperblur.dev/effects/modal-zoom-origin",
  "files": [
    {
      "path": "registry/hyperblur/modal-zoom-origin.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/modal-zoom-origin.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ModalZoomCheck {\n  label: string;\n  detail: string;\n  state?: \"pass\" | \"warn\";\n}\n\nexport interface ModalZoomOriginProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\"> {\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  embedded?: boolean;\n  trigger?: React.ReactNode;\n  title?: string;\n  description?: string;\n  branch?: string;\n  target?: string;\n  checks?: ModalZoomCheck[];\n  confirmLabel?: string;\n  onConfirm?: () => void;\n  accent?: string;\n}\n\nconst defaultChecks: ModalZoomCheck[] = [\n  { label: \"Build passed\", detail: \"42s · 318 modules\", state: \"pass\" },\n  { label: \"Preview approved\", detail: \"Maya Chen · 6 min ago\", state: \"pass\" },\n  { label: \"2 environment variables changed\", detail: \"STRIPE_KEY, WEBHOOK_URL\", state: \"warn\" },\n];\n\nconst css = `\n.hb-xe1 { --hb-xe1-accent: #2f7bff; display: inline-block; box-sizing: border-box; color: #ededed; font-family: var(--font-sans, ui-sans-serif, system-ui, sans-serif); }\n.hb-xe1 *, .hb-xe1 *::before, .hb-xe1 *::after { box-sizing: border-box; }\n.hb-xe1[data-embedded] { position: relative; display: grid; place-items: center; width: 100%; height: 100%; min-height: 190px; border-radius: 16px; overflow: hidden; isolation: isolate; background: radial-gradient(120% 90% at 50% 120%, rgba(47, 123, 255, 0.10), transparent 60%), #0b0b0c; }\n.hb-xe1-trigger { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px 0 12px; border: 1px solid rgba(255, 255, 255, 0.10); border-radius: 10px; background: linear-gradient(180deg, #1c1c1f, #141416); color: #ededed; font: inherit; font-size: 13px; font-weight: 550; cursor: pointer; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 6px 18px -8px rgba(0, 0, 0, 0.8); transition: transform 0.18s cubic-bezier(0.3, 0.7, 0.4, 1), border-color 0.2s ease, opacity 0.2s ease; }\n.hb-xe1-trigger:hover { border-color: rgba(255, 255, 255, 0.18); }\n.hb-xe1-trigger:active { transform: scale(0.97); }\n.hb-xe1-trigger[data-open=\"true\"] { opacity: 0; }\n.hb-xe1-trigger svg { width: 14px; height: 14px; color: var(--hb-xe1-accent); }\n.hb-xe1-trigger:focus-visible, .hb-xe1-btn:focus-visible, .hb-xe1-x:focus-visible { outline: 2px solid var(--hb-xe1-accent); outline-offset: 2px; }\n.hb-xe1-layer { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; height: 100dvh; padding: 16px; }\n.hb-xe1[data-embedded] .hb-xe1-layer { position: absolute; height: auto; padding: 10px; z-index: 2; }\n.hb-xe1-scrim { position: absolute; inset: 0; background: rgba(4, 4, 6, 0.62); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); animation: hb-xe1-fade 0.32s ease both; }\n.hb-xe1-layer[data-closing=\"true\"] .hb-xe1-scrim { animation: hb-xe1-fade-out 0.3s ease both; }\n.hb-xe1-panel { position: relative; width: 100%; max-width: 420px; max-height: 100%; overflow: auto; border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 16px; background: linear-gradient(180deg, #161618 0%, #111112 100%); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 40px 80px -24px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(0, 0, 0, 0.6); outline: none; transform-origin: center; will-change: transform; }\n.hb-xe1-content { animation: hb-xe1-in 0.38s 0.14s cubic-bezier(0.22, 1, 0.36, 1) both; }\n.hb-xe1-layer[data-closing=\"true\"] .hb-xe1-content { animation: hb-xe1-fade-out 0.12s ease both; }\n.hb-xe1-head { display: flex; gap: 12px; padding: 18px 18px 0; }\n.hb-xe1-mark { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--hb-xe1-accent) 55%, #fff 0%), var(--hb-xe1-accent)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 8px 20px -6px color-mix(in srgb, var(--hb-xe1-accent) 70%, transparent); color: #fff; }\n.hb-xe1-mark svg { width: 17px; height: 17px; }\n.hb-xe1-title { margin: 0; font-size: 15.5px; font-weight: 600; letter-spacing: -0.012em; line-height: 1.3; }\n.hb-xe1-desc { margin: 3px 0 0; color: #9a9a9e; font-size: 12.5px; line-height: 1.45; }\n.hb-xe1-x { position: absolute; top: 12px; right: 12px; display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: #7c7c80; cursor: pointer; transition: background-color 0.15s ease, color 0.15s ease; }\n.hb-xe1-x:hover { background: rgba(255, 255, 255, 0.07); color: #ededed; }\n.hb-xe1-x svg { width: 13px; height: 13px; }\n.hb-xe1-branch { display: flex; align-items: center; gap: 8px; margin: 14px 18px 0; padding: 9px 11px; border: 1px solid #232326; border-radius: 10px; background: #0c0c0d; font-family: var(--font-mono, ui-monospace, monospace); font-size: 11.5px; color: #c9c9cc; }\n.hb-xe1-chip { padding: 2px 7px; border-radius: 6px; background: #1b1b1e; box-shadow: inset 0 0 0 1px #2a2a2e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }\n.hb-xe1-chip[data-target=\"true\"] { color: #fff; background: color-mix(in srgb, var(--hb-xe1-accent) 22%, #111); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--hb-xe1-accent) 45%, transparent); }\n.hb-xe1-arrow { flex: none; color: #5d5d62; }\n.hb-xe1-checks { list-style: none; margin: 10px 0 0; padding: 0 18px; display: grid; gap: 2px; }\n.hb-xe1-check { display: grid; grid-template-columns: 18px 1fr; gap: 10px; align-items: start; padding: 7px 0; border-bottom: 1px dashed #222225; }\n.hb-xe1-check:last-child { border-bottom: 0; }\n.hb-xe1-dot { display: grid; place-items: center; width: 18px; height: 18px; margin-top: 1px; border-radius: 50%; background: rgba(70, 200, 130, 0.14); color: #4fd18b; }\n.hb-xe1-dot[data-state=\"warn\"] { background: rgba(245, 180, 60, 0.14); color: #f5b63c; }\n.hb-xe1-dot svg { width: 10px; height: 10px; }\n.hb-xe1-label { display: block; font-size: 13px; font-weight: 500; line-height: 1.35; }\n.hb-xe1-detail { display: block; margin-top: 1px; color: #85858a; font-size: 11.5px; }\n.hb-xe1-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px 18px; }\n.hb-xe1-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 14px; overflow: hidden; border: 1px solid #2a2a2e; border-radius: 9px; background: #18181b; color: #d4d4d8; font: inherit; font-size: 13px; font-weight: 550; cursor: pointer; transition: background-color 0.15s ease, transform 0.15s cubic-bezier(0.3, 0.7, 0.4, 1); }\n.hb-xe1-btn:hover { background: #202024; }\n.hb-xe1-btn:active { transform: scale(0.97); }\n.hb-xe1-btn[data-primary] { min-width: 128px; border-color: transparent; background: var(--hb-xe1-accent); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 6px 16px -6px color-mix(in srgb, var(--hb-xe1-accent) 80%, transparent); }\n.hb-xe1-btn[data-primary]:hover { background: color-mix(in srgb, var(--hb-xe1-accent) 88%, #fff); }\n.hb-xe1-btn[data-status=\"busy\"] { cursor: progress; }\n.hb-xe1-btn[data-status=\"done\"] { background: #1f9d5b; }\n.hb-xe1-fill { position: absolute; font-style: normal; inset: 0; background: rgba(255, 255, 255, 0.18); transform-origin: left; transform: scaleX(0); animation: hb-xe1-fill 1.4s cubic-bezier(0.65, 0, 0.35, 1) forwards; }\n.hb-xe1-btn span { position: relative; display: inline-flex; align-items: center; gap: 7px; }\n.hb-xe1-btn svg { width: 13px; height: 13px; }\n.hb-xe1-tick { stroke-dasharray: 20; stroke-dashoffset: 20; animation: hb-xe1-draw 0.4s 0.05s ease-out forwards; }\n@keyframes hb-xe1-fade { from { opacity: 0; } to { opacity: 1; } }\n@keyframes hb-xe1-fade-out { from { opacity: 1; } to { opacity: 0; } }\n@keyframes hb-xe1-in { from { opacity: 0; transform: translateY(6px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }\n@keyframes hb-xe1-fill { to { transform: scaleX(1); } }\n@keyframes hb-xe1-draw { to { stroke-dashoffset: 0; } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xe1-scrim, .hb-xe1-content, .hb-xe1-fill, .hb-xe1-tick { animation: none; }\n  .hb-xe1-tick { stroke-dashoffset: 0; }\n  .hb-xe1-fill { transform: scaleX(1); }\n  .hb-xe1-trigger, .hb-xe1-btn, .hb-xe1-x { transition: none; }\n}\n`;\n\nconst focusable =\n  'a[href],button:not(:disabled),input:not(:disabled),select:not(:disabled),textarea:not(:disabled),[tabindex]:not([tabindex=\"-1\"])';\n\nfunction useLayer(\n  open: boolean,\n  embedded: boolean,\n  panel: React.RefObject<HTMLElement | null>,\n  onClose: () => void,\n  userOpened: React.RefObject<boolean>,\n) {\n  const closeRef = React.useRef(onClose);\n  React.useEffect(() => {\n    closeRef.current = onClose;\n  });\n  React.useEffect(() => {\n    if (!open) return;\n    const node = panel.current;\n    const steal = !embedded || userOpened.current;\n    const previous = document.activeElement as HTMLElement | null;\n    const html = document.documentElement;\n    const overflow = html.style.overflow;\n    if (!embedded) html.style.overflow = \"hidden\";\n    if (steal && node) {\n      const target = node.querySelector<HTMLElement>(\"[data-autofocus]\") ?? node.querySelector<HTMLElement>(focusable) ?? node;\n      target.focus({ preventScroll: true });\n    }\n    const onKey = (e: KeyboardEvent) => {\n      if (!node) return;\n      if (embedded && !node.contains(document.activeElement)) return;\n      if (e.key === \"Escape\") {\n        e.preventDefault();\n        closeRef.current();\n        return;\n      }\n      if (e.key !== \"Tab\") return;\n      const items = Array.from(node.querySelectorAll<HTMLElement>(focusable)).filter((el) => el.getClientRects().length > 0);\n      if (!items.length) {\n        e.preventDefault();\n        node.focus();\n        return;\n      }\n      const first = items[0];\n      const last = items[items.length - 1];\n      const active = document.activeElement;\n      if (!node.contains(active)) {\n        e.preventDefault();\n        first.focus();\n      } else if (e.shiftKey && (active === first || active === node)) {\n        e.preventDefault();\n        last.focus();\n      } else if (!e.shiftKey && active === last) {\n        e.preventDefault();\n        first.focus();\n      }\n    };\n    document.addEventListener(\"keydown\", onKey);\n    return () => {\n      document.removeEventListener(\"keydown\", onKey);\n      if (!embedded) html.style.overflow = overflow;\n      if (steal && previous && previous.isConnected && previous !== document.body) previous.focus({ preventScroll: true });\n    };\n  }, [open, embedded, panel, userOpened]);\n}\n\nfunction reduced() {\n  return typeof window !== \"undefined\" && window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n}\n\nexport function ModalZoomOrigin({\n  open,\n  defaultOpen,\n  onOpenChange,\n  embedded = false,\n  trigger = \"Publish\",\n  title = \"Publish to production\",\n  description = \"This replaces the live site for 14,203 monthly visitors. You can roll back from Deployments.\",\n  branch = \"feat/billing-v2\",\n  target = \"main\",\n  checks = defaultChecks,\n  confirmLabel = \"Publish now\",\n  onConfirm,\n  accent = \"#2f7bff\",\n  className = \"\",\n  style,\n  ...rest\n}: ModalZoomOriginProps) {\n  const [inner, setInner] = React.useState(defaultOpen ?? embedded);\n  const isOpen = open ?? inner;\n  const [closing, setClosing] = React.useState(false);\n  const [status, setStatus] = React.useState<\"idle\" | \"busy\" | \"done\">(\"idle\");\n  const userOpened = React.useRef(false);\n  const panel = React.useRef<HTMLDivElement>(null);\n  const triggerRef = React.useRef<HTMLButtonElement>(null);\n  const timers = React.useRef<number[]>([]);\n  const id = React.useId();\n\n  React.useEffect(() => {\n    const list = timers.current;\n    return () => list.forEach((t) => clearTimeout(t));\n  }, []);\n\n  const setOpen = React.useCallback(\n    (next: boolean) => {\n      if (next) userOpened.current = true;\n      if (open === undefined) setInner(next);\n      onOpenChange?.(next);\n    },\n    [open, onOpenChange],\n  );\n\n  const geometry = React.useCallback(() => {\n    const p = panel.current;\n    const t = triggerRef.current;\n    if (!p) return null;\n    const pr = p.getBoundingClientRect();\n    if (!t || pr.width === 0) return { from: \"translate(0px, 8px) scale(0.92)\", radius: \"16px\" };\n    const tr = t.getBoundingClientRect();\n    const dx = tr.left + tr.width / 2 - (pr.left + pr.width / 2);\n    const dy = tr.top + tr.height / 2 - (pr.top + pr.height / 2);\n    const sx = Math.max(tr.width / pr.width, 0.05);\n    const sy = Math.max(tr.height / pr.height, 0.05);\n    return {\n      from: `translate(${dx.toFixed(1)}px, ${dy.toFixed(1)}px) scale(${sx.toFixed(3)}, ${sy.toFixed(3)})`,\n      radius: `${(10 / sx).toFixed(1)}px / ${(10 / sy).toFixed(1)}px`,\n    };\n  }, []);\n\n  React.useLayoutEffect(() => {\n    if (!isOpen || reduced()) return;\n    const p = panel.current;\n    const g = geometry();\n    if (!p || !g || typeof p.animate !== \"function\") return;\n    p.animate(\n      [\n        { transform: g.from, borderRadius: g.radius, opacity: 0.5 },\n        { transform: \"translate(0px, 0px) scale(1, 1)\", borderRadius: \"16px\", opacity: 1 },\n      ],\n      { duration: 480, easing: \"cubic-bezier(0.22, 1, 0.36, 1)\" },\n    );\n  }, [isOpen, geometry]);\n\n  const requestClose = React.useCallback(() => {\n    if (closing) return;\n    const p = panel.current;\n    const g = geometry();\n    setStatus(\"idle\");\n    if (!p || !g || reduced() || typeof p.animate !== \"function\") {\n      setOpen(false);\n      return;\n    }\n    setClosing(true);\n    const anim = p.animate(\n      [\n        { transform: \"translate(0px, 0px) scale(1, 1)\", borderRadius: \"16px\", opacity: 1 },\n        { transform: g.from, borderRadius: g.radius, opacity: 0 },\n      ],\n      { duration: 340, easing: \"cubic-bezier(0.55, 0, 0.75, 0.2)\", fill: \"forwards\" },\n    );\n    anim.onfinish = () => {\n      setClosing(false);\n      setOpen(false);\n    };\n  }, [closing, geometry, setOpen]);\n\n  useLayer(isOpen, embedded, panel, requestClose, userOpened);\n\n  function publish() {\n    if (status !== \"idle\") return;\n    setStatus(\"busy\");\n    timers.current.push(\n      window.setTimeout(() => {\n        setStatus(\"done\");\n        onConfirm?.();\n        timers.current.push(window.setTimeout(() => requestClose(), 900));\n      }, 1400),\n    );\n  }\n\n  const vars = { \"--hb-xe1-accent\": accent, ...style } as React.CSSProperties;\n\n  return (\n    <div className={`hb-xe1 ${className}`} data-embedded={embedded || undefined} style={vars} {...rest}>\n      <style href=\"hb-xe1-css\" precedence=\"default\">{css}</style>\n      {trigger !== null && (\n        <button\n          ref={triggerRef}\n          type=\"button\"\n          className=\"hb-xe1-trigger\"\n          aria-haspopup=\"dialog\"\n          aria-expanded={isOpen}\n          data-open={isOpen && !closing ? \"true\" : undefined}\n          onClick={() => setOpen(true)}\n        >\n          <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n            <path d=\"M8 13V3m0 0L4 7m4-4 4 4\" />\n          </svg>\n          {trigger}\n        </button>\n      )}\n      {isOpen && (\n        <div className=\"hb-xe1-layer\" data-closing={closing ? \"true\" : undefined}>\n          <div\n            className=\"hb-xe1-scrim\"\n            onClick={requestClose}\n            aria-hidden=\"true\"\n          />\n          <div\n            ref={panel}\n            role=\"dialog\"\n            aria-modal=\"true\"\n            aria-labelledby={`${id}-t`}\n            aria-describedby={`${id}-d`}\n            tabIndex={-1}\n            className=\"hb-xe1-panel\"\n          >\n            <div className=\"hb-xe1-content\">\n              <div className=\"hb-xe1-head\">\n                <span className=\"hb-xe1-mark\" aria-hidden=\"true\">\n                  <svg viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n                    <path d=\"M10 2.5 17 15H3L10 2.5Z\" />\n                  </svg>\n                </span>\n                <div style={{ minWidth: 0, paddingRight: 24 }}>\n                  <h2 id={`${id}-t`} className=\"hb-xe1-title\">{title}</h2>\n                  <p id={`${id}-d`} className=\"hb-xe1-desc\">{description}</p>\n                </div>\n              </div>\n              <button type=\"button\" className=\"hb-xe1-x\" aria-label=\"Close\" onClick={requestClose}>\n                <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" aria-hidden=\"true\">\n                  <path d=\"m3.5 3.5 9 9m0-9-9 9\" />\n                </svg>\n              </button>\n              <div className=\"hb-xe1-branch\">\n                <span className=\"hb-xe1-chip\">{branch}</span>\n                <svg className=\"hb-xe1-arrow\" width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" aria-hidden=\"true\">\n                  <path d=\"M3 8h10m-3-3 3 3-3 3\" />\n                </svg>\n                <span className=\"hb-xe1-chip\" data-target=\"true\">{target}</span>\n              </div>\n              <ul className=\"hb-xe1-checks\">\n                {checks.map((c) => (\n                  <li key={c.label} className=\"hb-xe1-check\">\n                    <span className=\"hb-xe1-dot\" data-state={c.state ?? \"pass\"} aria-hidden=\"true\">\n                      {c.state === \"warn\" ? (\n                        <svg viewBox=\"0 0 10 10\" fill=\"currentColor\"><rect x=\"4.2\" y=\"1.5\" width=\"1.6\" height=\"4.6\" rx=\"0.8\" /><circle cx=\"5\" cy=\"8\" r=\"0.95\" /></svg>\n                      ) : (\n                        <svg viewBox=\"0 0 10 10\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\"><path d=\"m2.2 5.2 1.9 1.9L7.8 3\" /></svg>\n                      )}\n                    </span>\n                    <span>\n                      <span className=\"hb-xe1-label\">{c.label}</span>\n                      <span className=\"hb-xe1-detail\">{c.detail}</span>\n                    </span>\n                  </li>\n                ))}\n              </ul>\n              <div className=\"hb-xe1-foot\">\n                <button type=\"button\" className=\"hb-xe1-btn\" onClick={requestClose}>Cancel</button>\n                <button\n                  type=\"button\"\n                  className=\"hb-xe1-btn\"\n                  data-primary=\"\"\n                  data-autofocus=\"\"\n                  data-status={status}\n                  aria-busy={status === \"busy\" || undefined}\n                  onClick={publish}\n                >\n                  {status === \"busy\" && <i className=\"hb-xe1-fill\" aria-hidden=\"true\" />}\n                  <span aria-live=\"polite\">\n                    {status === \"done\" && (\n                      <svg viewBox=\"0 0 14 14\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path className=\"hb-xe1-tick\" d=\"m3 7.4 2.6 2.6L11 4.4\" /></svg>\n                    )}\n                    {status === \"idle\" ? confirmLabel : status === \"busy\" ? \"Publishing\" : \"Published\"}\n                  </span>\n                </button>\n              </div>\n            </div>\n          </div>\n        </div>\n      )}\n    </div>\n  );\n}\n"
    }
  ]
}