{"version":3,"file":"use-graph-store.cjs","sources":["../../../src/hooks/use-graph-store.ts"],"sourcesContent":["import { useContext } from 'react';\nimport { GraphStoreContext } from '../context';\nimport type { GraphStore } from '../store';\nimport type { ElementJSONInit, LinkJSONInit } from '../types/cell.types';\n\n/**\n * Hook for accessing the `GraphStore` from a {@link GraphProvider}.\n * Each call site narrows the store's record shape via its own generics.\n * @template Element - element record shape (must extend `ElementAttributes`)\n * @template Link - link record shape (must extend `LinkAttributes`)\n * @group Hooks\n * @returns The JointJS graph store narrowed to the consumer's record shape.\n * @throws {Error} If used outside of a {@link GraphProvider}.\n */\nexport function useGraphStore<\n  Element extends ElementJSONInit = ElementJSONInit,\n  Link extends LinkJSONInit = LinkJSONInit,\n>(): GraphStore<Element, Link> {\n  const store = useContext(GraphStoreContext);\n  if (!store) {\n    throw new Error('useGraphStore must be used within a GraphProvider');\n  }\n  // Boundary downcast through `unknown` is required: `GraphStore<E, L>` is\n  // invariant in its generic parameters (methods both consume and produce E\n  // and L), so TS rejects a direct cast between two parameterisations of\n  // the same class. Each call site re-binds the generics to its own record\n  // shape; the runtime value is the same store instance — see\n  // `context/index.ts` for the unparameterised context declaration.\n  return store as unknown as GraphStore<Element, Link>;\n}\n"],"names":["useContext","GraphStoreContext"],"mappings":";;;;;;;;;;;;AAcO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,aAAA,CAAA,CAAA,CAGe,CAAA;AAC7B,CAAA,CAAA,MAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAQA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAWC,uBAAiB,CAAA,CAAA;AAC1C,CAAA,CAAA,CAAA,CAAA,CAAA,CAAI,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA;AACV,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAI,CAAA,CAAA,CAAA,CAAA,EAAM,mDAAmD,CAAA,CAAA;AAAA,CAAA,CACrE,CAAA;AAOA,CAAA,CAAA,OAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACT,CAAA;;"}