import React, { type ReactNode, useRef } from 'react'
import type { DominoStore } from './domino-store'
import { DominoContext, DominoDOMContext } from './domino-hooks'

export function DominoProvider({
  children,
  store,
}: {
  children: ReactNode
  store: DominoStore
}) {
  const containerRef = useRef<HTMLElement | null>(null)

  return (
    <DominoContext.Provider value={store}>
      <DominoDOMContext.Provider value={containerRef}>
        {children}
      </DominoDOMContext.Provider>
    </DominoContext.Provider>
  )
}
