{"version":3,"file":"CartLineProvider.mjs","names":[],"sources":["../../src/CartLineProvider.tsx"],"sourcesContent":["import {useContext, createContext, type ReactNode} from 'react';\nimport {\n  ComponentizableCartLine,\n  type CartLine,\n} from './storefront-api-types.js';\nimport type {PartialDeep} from 'type-fest';\n\ntype CartLinePartialDeep = PartialDeep<\n  CartLine | ComponentizableCartLine,\n  {recurseIntoArrays: true}\n>;\n\nexport const CartLineContext = createContext<CartLinePartialDeep | null>(null);\n\n/**\n * The `useCartLine` hook provides access to the [CartLine object](https://shopify.dev/api/storefront/2026-04/objects/cartline) from the Storefront API. It must be a descendent of a `CartProvider` component.\n * @publicDocs\n */\nexport function useCartLine(): CartLinePartialDeep {\n  const context = useContext(CartLineContext);\n\n  if (context == null) {\n    throw new Error('Expected a cart line context but none was found');\n  }\n\n  return context;\n}\n\ntype CartLineProviderProps = {\n  /** Any `ReactNode` elements. */\n  children: ReactNode;\n  /** A cart line object. */\n  line: CartLinePartialDeep;\n};\n\n/**\n * The `CartLineProvider` component creates a context for using a cart line.\n * @publicDocs\n */\nexport function CartLineProvider({\n  children,\n  line,\n}: CartLineProviderProps): JSX.Element {\n  return (\n    <CartLineContext.Provider value={line}>{children}</CartLineContext.Provider>\n  );\n}\n"],"mappings":";;;AAYA,IAAa,kBAAkB,cAA0C,KAAK;;;;;AAM9E,SAAgB,cAAmC;CACjD,MAAM,UAAU,WAAW,gBAAgB;AAE3C,KAAI,WAAW,KACb,OAAM,IAAI,MAAM,kDAAkD;AAGpE,QAAO;;;;;;AAcT,SAAgB,iBAAiB,EAC/B,UACA,QACqC;AACrC,QACE,oBAAC,gBAAgB,UAAjB;EAA0B,OAAO;EAAO;EAAoC,CAAA"}