{"version":3,"file":"GraphNodeHost.js","names":[],"sources":["esm/react-flow/GraphNodeHost.js"],"sourcesContent":["import { createContext, memo, useContext, useEffect, useMemo } from \"react\";\nimport { nodeKindSpec } from \"../model/index\";\nimport { lodForZoom } from \"../nodes/lod\";\nimport { registerMountedNode } from \"./nodeCensus\";\nimport { useStore } from \"./xy\";\nimport { jsx } from \"react/jsx-runtime\";\nconst GraphHostContext = createContext(null);\nconst GraphHostProvider = GraphHostContext.Provider;\nfunction useGraphHost() {\n  const value = useContext(GraphHostContext);\n  if (!value) {\n    throw new Error(\n      \"[@multiplatform.one/node-graph] a graph node rendered outside <NodeGraph>. The node type is registered by the canvas and cannot be used on its own.\"\n    );\n  }\n  return value;\n}\nfunction GraphNodeHostComponent({ id, data, selected, dragging }) {\n  const host = useGraphHost();\n  const nodeData = data;\n  const zoom = useStore((state) => state.transform[2]);\n  const spec = nodeKindSpec(host.schema, nodeData.kind);\n  useEffect(() => registerMountedNode(id), [id]);\n  const setData = useMemo(\n    () => (patch) => host.setNodeData(id, patch),\n    [host, id]\n  );\n  if (!spec) {\n    return /* @__PURE__ */ jsx(\"div\", { \"data-graph-node-unknown\": nodeData.kind, role: \"alert\", children: `unknown node kind: ${nodeData.kind}` });\n  }\n  const Render = spec.render;\n  return /* @__PURE__ */ jsx(\n    Render,\n    {\n      id,\n      data: nodeData.data,\n      selected: selected ?? false,\n      dragging: dragging ?? false,\n      renderMode: lodForZoom(zoom, host.overviewZoom),\n      readOnlyFields: host.readOnly || host.coarsePointer,\n      ports: nodeData.ports,\n      measure: spec.measure,\n      setData\n    }\n  );\n}\nconst GraphNodeHost = memo(GraphNodeHostComponent);\nexport {\n  GraphHostProvider,\n  GraphNodeHost,\n  useGraphHost\n};\n//# sourceMappingURL=GraphNodeHost.js.map\n"],"mappings":";;;;;;;;AAMA,MAAM,mBAAmB,cAAc,IAAI;AAC3C,MAAM,oBAAoB,iBAAiB;AAC3C,SAAS,eAAe;CACtB,MAAM,QAAQ,WAAW,gBAAgB;CACzC,IAAI,CAAC,OAAO;EACV,MAAM,IAAI,MACR,qJACF;CACF;CACA,OAAO;AACT;AACA,SAAS,uBAAuB,EAAE,IAAI,MAAM,UAAU,YAAY;CAChE,MAAM,OAAO,aAAa;CAC1B,MAAM,WAAW;CACjB,MAAM,OAAO,UAAU,UAAU,MAAM,UAAU,EAAE;CACnD,MAAM,OAAO,aAAa,KAAK,QAAQ,SAAS,IAAI;CACpD,gBAAgB,oBAAoB,EAAE,GAAG,CAAC,EAAE,CAAC;CAC7C,MAAM,UAAU,eACP,UAAU,KAAK,YAAY,IAAI,KAAK,GAC3C,CAAC,MAAM,EAAE,CACX;CACA,IAAI,CAAC,MAAM;EACT,OAAuB,oBAAI,OAAO;GAAE,2BAA2B,SAAS;GAAM,MAAM;GAAS,UAAU,sBAAsB,SAAS;EAAO,CAAC;CAChJ;CACA,MAAM,SAAS,KAAK;CACpB,OAAuB,oBACrB,QACA;EACE;EACA,MAAM,SAAS;EACf,UAAU,YAAY;EACtB,UAAU,YAAY;EACtB,YAAY,WAAW,MAAM,KAAK,YAAY;EAC9C,gBAAgB,KAAK,YAAY,KAAK;EACtC,OAAO,SAAS;EAChB,SAAS,KAAK;EACd;CACF,CACF;AACF;AACA,MAAM,gBAAgB,KAAK,sBAAsB"}