{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "node-canvas",
  "type": "registry:ui",
  "title": "Node Canvas",
  "description": "A thin React Flow viewport and view controls for caller-owned nodes and edges.",
  "dependencies": [
    "@xyflow/react@12.12.1",
    "lucide-react@0.561.0"
  ],
  "registryDependencies": [
    "https://ghost-ui.com/r/ghost-tokens.json",
    "https://ghost-ui.com/r/button.json",
    "https://ghost-ui.com/r/tooltip.json",
    "https://ghost-ui.com/r/button-group.json"
  ],
  "files": [
    {
      "path": "src/components/ui/node-canvas.tsx",
      "type": "registry:component",
      "target": "@ui/node-canvas.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport {\n  ReactFlow,\n  useReactFlow,\n  useViewport,\n  type Edge,\n  type Node,\n  type ReactFlowProps,\n} from \"@xyflow/react\";\nimport { Icon, Maximize, Minus, Plus, type IconNode } from \"lucide-react\";\nimport { Button, IconButton } from \"./button\";\nimport { ButtonGroup } from \"./button-group\";\nimport { TooltipHint } from \"./tooltip\";\nimport \"./node-canvas.css\";\n\n/*!\n * Official Lucide 1.15.0 SVG: https://lucide.dev/icons/sticky-note-plus\n * ISC License\n * \n * Copyright (c) 2026 Lucide Icons and Contributors\n * \n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n// Vendored because the installed Lucide predates this icon; upgrading removes existing brand icons.\nconst stickyNotePlusIcon: IconNode = [\n  [\"path\", { d: \"M15 3v5a1 1 0 0 0 1 1h5\", key: \"6s6qgf\" }],\n  [\"path\", { d: \"M18 15v6\", key: \"9wciyi\" }],\n  [\n    \"path\",\n    {\n      d: \"M21 12.356V9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7.355\",\n      key: \"12ish9\"\n    }\n  ],\n  [\"path\", { d: \"M21 18h-6\", key: \"139f0c\" }]\n];\nexport type NodeCanvasProps<NodeType extends Node = Node, EdgeType extends Edge = Edge> =\n  ReactFlowProps<NodeType, EdgeType>;\n\n/** Port-count ceilings. Omitted directions are unlimited; state stays caller-owned. */\nexport interface NodeCanvasPortLimits { inputs?: number; outputs?: number; }\n\nexport function canAddNodeCanvasPort(ports: readonly { direction: \"input\" | \"output\" }[], direction: \"input\" | \"output\", limits: NodeCanvasPortLimits = {}) {\n  for (const limit of [limits.inputs, limits.outputs]) {\n    if (limit !== undefined && (!Number.isSafeInteger(limit) || limit < 0)) throw new Error(\"Node port limits must be nonnegative safe integers.\");\n  }\n  const maximum = direction === \"input\" ? limits.inputs : limits.outputs;\n  return maximum === undefined || ports.filter(port => port.direction === direction).length < maximum;\n}\n\nfunction NodeCanvasInner<NodeType extends Node, EdgeType extends Edge>(\n  { className, style, proOptions, ...props }: NodeCanvasProps<NodeType, EdgeType>,\n  ref: React.ForwardedRef<HTMLDivElement>,\n) {\n  return (\n    <ReactFlow<NodeType, EdgeType>\n      {...props}\n      proOptions={{ hideAttribution: true, ...proOptions }}\n      ref={ref}\n      className={[\"ui-node-canvas\", className].filter(Boolean).join(\" \")}\n      style={{ minHeight: 260, ...style }}\n    />\n  );\n}\n\nexport const NodeCanvas = React.forwardRef(NodeCanvasInner) as <\n  NodeType extends Node = Node,\n  EdgeType extends Edge = Edge,\n>(props: NodeCanvasProps<NodeType, EdgeType> & React.RefAttributes<HTMLDivElement>) => React.ReactElement;\n\nexport interface NodeCanvasControlsProps extends React.HTMLAttributes<HTMLDivElement> {\n  onAddCard?: () => void;\n  /** @deprecated Use onAddCard. */\n  onAddNode?: () => void;\n}\n\nexport function NodeCanvasControls({ className, onAddCard, onAddNode, ...props }: NodeCanvasControlsProps) {\n  const { zoom } = useViewport();\n  const { zoomIn, zoomOut, fitView } = useReactFlow();\n  return (\n    <div {...props} className={[\"ui-graph-controls\", className].filter(Boolean).join(\" \")} role={props.role ?? \"group\"} aria-label={props[\"aria-label\"] ?? \"Canvas view\"}>\n      {(onAddCard || onAddNode) && <Button data-add-card leadingIcon={<Icon iconNode={stickyNotePlusIcon} className=\"lucide-sticky-note-plus\" />} variant=\"ghost\" onClick={onAddCard ?? onAddNode}>Add card</Button>}\n      <ButtonGroup aria-label=\"Zoom controls\">\n        <TooltipHint content=\"Zoom in\"><IconButton icon={<Plus />} size=\"icon\" variant=\"ghost\" aria-label=\"Zoom in\" onClick={() => void zoomIn()} /></TooltipHint>\n        <TooltipHint content=\"Zoom out\"><IconButton icon={<Minus />} size=\"icon\" variant=\"ghost\" aria-label=\"Zoom out\" onClick={() => void zoomOut()} /></TooltipHint>\n      </ButtonGroup>\n      <TooltipHint content=\"Fit view\"><IconButton icon={<Maximize />} size=\"icon\" variant=\"ghost\" aria-label=\"Fit view\" onClick={() => void fitView({ padding: 0.15 })} /></TooltipHint>\n      <span className=\"ui-graph-zoom\">{Math.round(zoom * 100)}%</span>\n    </div>\n  );\n}\n\nexport default NodeCanvas;\n"
    },
    {
      "path": "src/components/ui/node-canvas.css",
      "type": "registry:file",
      "target": "@ui/node-canvas.css",
      "content": "@import \"@xyflow/react/dist/base.css\";\n.ui-node-canvas{width:100%;min-width:0;min-height:260px;color:var(--foreground);font-family:var(--font-sans);font-size:14px;font-weight:var(--font-weight-regular,400)}\n.ui-node-canvas.react-flow{background:var(--background)}\n.ui-graph-surface--viewport>.ui-node-canvas{flex:1;min-height:0}\n.ui-node-canvas .react-flow__node:focus:has(>.ui-graph-node),.ui-node-canvas .react-flow__node:focus-visible:has(>.ui-graph-node){outline:none}\n.ui-node-canvas .react-flow__node:focus-visible:has(>.ui-graph-node)>.ui-graph-node{border-color:var(--muted-foreground)}\n.ui-graph-surface .react-flow__edge:is(.selected,:focus-within) .ui-graph-edge-path{stroke:color-mix(in srgb,var(--graph-edge-color,var(--border)),var(--foreground) 40%)}\n@media(hover:hover) and (pointer:fine){.ui-graph-surface .react-flow__edge:hover .ui-graph-edge-path{stroke:color-mix(in srgb,var(--graph-edge-color,var(--border)),var(--foreground) 40%)}}\n.ui-graph-node__canvas-card .react-flow__handle{pointer-events:auto}\n.ui-graph-surface .react-flow__node:has(.ui-graph-node[data-port-highlighted=true]){z-index:1001!important}\n.ui-node-port__indicator:has(>.react-flow__handle){position:relative}\n/* React Flow derives edge endpoints from handle bounds. Keep the measured box\n   at the port point; the 44px hit area lives on ::after so pointer size cannot\n   push the visible path away from the circle. */\n.ui-node-port .react-flow__handle{top:50%!important;right:auto!important;bottom:auto!important;left:50%!important;width:0;height:0;min-width:0;min-height:0;transform:translate(-50%,-50%);border:0;border-radius:50%;background:transparent;opacity:1;z-index:2}\n.ui-node-port--input .react-flow__handle,.ui-node-port--output .react-flow__handle{left:50%!important;right:auto!important}\n.ui-node-port:is(.ui-node-port--left,.ui-node-port--right,.ui-node-port--top,.ui-node-port--bottom) .react-flow__handle{top:50%!important;right:auto!important;bottom:auto!important;left:50%!important;transform:translate(-50%,-50%)}\n.ui-node-port.ui-node-port--left .ui-node-port__indicator,.ui-node-port.ui-node-port--right .ui-node-port__indicator,.ui-node-port.ui-node-port--top .ui-node-port__indicator,.ui-node-port.ui-node-port--bottom .ui-node-port__indicator{position:absolute}\n.ui-node-port[data-disabled] .react-flow__handle{pointer-events:none}\n.ui-node-port .react-flow__handle::after{content:\"\";position:absolute;top:50%;left:50%;width:44px;height:44px;transform:translate(-50%,-50%);border-radius:50%;background:transparent}\n.ui-node-port .react-flow__handle:focus-visible{outline:2px solid var(--ring);outline-offset:1px}\n.ui-node-canvas .ui-graph-node__connect{z-index:3;width:8px;height:8px;min-width:8px;min-height:8px;border:1px solid var(--border);background:var(--background);opacity:0;transition:opacity 100ms ease}\n.ui-node-canvas .ui-graph-node__connect::after{content:\"\";position:absolute;inset:-8px;border-radius:50%}\n.ui-node-canvas .ui-graph-node:has(.ui-graph-node__action-zone:focus-within,.ui-graph-node__action-zone[data-active=\"true\"]) .ui-graph-node__connect{opacity:1;border-color:var(--muted-foreground)}\n@media(hover:hover) and (pointer:fine){.ui-node-canvas .ui-graph-node:has(.ui-graph-node__action-zone:hover) .ui-graph-node__connect{opacity:1;border-color:var(--muted-foreground)}}\n.ui-node-canvas .ui-graph-node__port:focus-within>.ui-graph-node__connect{opacity:1;border-color:var(--muted-foreground)}\n@media(hover:hover) and (pointer:fine){.ui-node-canvas .ui-graph-node__port:hover>.ui-graph-node__connect{opacity:1;border-color:var(--muted-foreground)}}\n.ui-graph-controls{display:flex;flex:0 0 40px;box-sizing:border-box;align-items:center;gap:2px;padding:3px 8px;background:var(--background);border-top:1px solid var(--border)}\n.ui-graph-controls svg.lucide{width:var(--icon-size);height:var(--icon-size);stroke-width:var(--icon-stroke)}\n.ui-graph-zoom{display:flex;align-items:center;justify-content:center;min-width:48px;padding-inline:6px;font-size:12px;color:var(--muted-foreground);background:var(--background)}\n@media(max-width:520px){.ui-node-canvas .react-flow__controls-button{width:28px;height:28px}}\n@media(pointer:coarse){.ui-graph-surface .ui-graph-node[data-editable] .ui-graph-node__connect{opacity:1;pointer-events:auto}}\n@media(prefers-reduced-motion:reduce){.ui-node-canvas .ui-graph-node__connect{transition:none}}\n\n.ui-node-canvas{overscroll-behavior:contain}\n.ui-graph-controls .ui-button{touch-action:manipulation;-webkit-user-select:none;user-select:none}\n.ui-graph-controls{flex-basis:40px;min-height:40px}\n.ui-graph-controls .ui-button{min-width:var(--space-8);min-height:var(--space-8)}\n@media(pointer:coarse){.ui-node-canvas :is(input,textarea,select){font-size:16px}.ui-node-canvas .react-flow__edge-interaction{stroke-width:44}}\n\n.ui-node-canvas .react-flow__edge-interaction{vector-effect:non-scaling-stroke}\n"
    }
  ]
}
