import { createContext, useContext } from 'react';
import { assertContextValue } from '../createContext';
import { TagsWidgetState } from '@wix/bex-core';

export const tagsWidgetContext = createContext<TagsWidgetState | null>(null);

export const TagsWidgetContextProvider = tagsWidgetContext.Provider;
export const TagsWidgetContextConsumer = tagsWidgetContext.Consumer;

export const useTagsWidgetContext = () => {
  const value = useContext(tagsWidgetContext);
  assertContextValue('TagsWidgetProvider', value);
  return value as TagsWidgetState;
};
