import React from 'react';
import type { ViewProps, ColorValue } from 'react-native';
import NativeBBCastButtonView from './specs/BBCastButtonViewNativeComponent';
import { isCastViewAvailable } from './castAvailability';

export interface BBCastButtonProps extends ViewProps {
  /**
   * Tint color for the cast button icon.
   * Accepts any React Native color value.
   */
  tintColor?: ColorValue;
}

/**
 * BBCastButton - A native ChromeCast button that auto-shows/hides based on device availability.
 *
 * Renders the native Google Cast SDK button (GCKUICastButton on iOS, MediaRouteButton on Android).
 * Automatically visible when a Cast device is discovered on the network.
 * Renders nothing if the native Cast SDK is not available.
 */
const BBCastButton: React.FC<BBCastButtonProps> = (props) => {
  if (!isCastViewAvailable('BBCastButtonView')) return null;
  return <NativeBBCastButtonView {...props} />;
};

BBCastButton.displayName = 'BBCastButton';

export default BBCastButton;
