import Highcharts from "highcharts"
import {
  HighchartsReactRefObject,
  HighchartsReact as OriginalHighchartsReact,
  HighchartsReactRefObject as RefObject,
} from "highcharts-react-official"
import React, { ComponentPropsWithoutRef, forwardRef } from "react"
import { classNames } from "../../utils"

const containerProps = {
  // Always hide the tooltip by default.
  className: classNames(
    "size-full [&_.highcharts-halo]:hidden [&_.highcharts-tooltip]:hidden",
  ),
}

const HighchartsReact = forwardRef<
  HighchartsReactRefObject,
  ComponentPropsWithoutRef<typeof OriginalHighchartsReact>
>(function HighchartsReact(args, ref) {
  return (
    <OriginalHighchartsReact
      containerProps={containerProps}
      ref={ref}
      {...args}
    />
  )
})

export { Highcharts, HighchartsReact }
export type { RefObject }
