import {
  requireNativeComponent,
  UIManager,
  Platform,
  type ViewStyle,
} from 'react-native';

const LINKING_ERROR =
  `The package 'react-native-hubble-react-sdk2' doesn't seem to be linked. Make sure: \n\n` +
  Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
  '- You rebuilt the app after installing the package\n' +
  '- You are not using Expo Go\n';

type HubbleReactSdk2Props = {
  color: string;
  style: ViewStyle;
};

const ComponentName = 'HubbleReactSdk2View';

export const HubbleReactSdk2View =
  UIManager.getViewManagerConfig(ComponentName) != null
    ? requireNativeComponent<HubbleReactSdk2Props>(ComponentName)
    : () => {
        throw new Error(LINKING_ERROR);
      };
