import React, { createContext, useContext } from 'react';

/**
 * IsActive Context
 * 用于在 TicketBooking 组件树中提供 isActive 状态
 * isActive 用于标识当前组件是否处于激活状态
 */

var IsActiveContext = /*#__PURE__*/createContext({
  isActive: true
});
/**
 * IsActive Provider
 * 提供 isActive 给子组件使用
 */
export var IsActiveProvider = function IsActiveProvider(_ref) {
  var isActive = _ref.isActive,
    children = _ref.children;
  return /*#__PURE__*/React.createElement(IsActiveContext.Provider, {
    value: {
      isActive: isActive
    }
  }, children);
};

/**
 * useIsActive Hook
 * 在子组件中使用此 hook 获取 isActive 状态
 */
export var useIsActive = function useIsActive() {
  var context = useContext(IsActiveContext);
  if (!context) {
    throw new Error('useIsActive must be used within an IsActiveProvider');
  }
  return context.isActive;
};
export default IsActiveContext;