/**
 * Main API exports for clean imports
 * Export all services, types, and hooks
 */

// Client
export { apiClient } from './client';
export type { ApiError } from './client';

// Services
export { authService } from './services/auth';
export { userService } from './services/user';
export { onboardingService } from './services/onboarding';
export { tenantService } from './services/tenant';
export { subscriptionService } from './services/subscription';
export { salesService } from './services/sales';
export { inventoryService } from './services/inventory';

// New API Services
export { trainingService } from './services/training';
export { alertService as alertProcessorService } from './services/alertService';
export { suppliersService } from './services/suppliers';
export { OrdersService } from './services/orders';
export { forecastingService } from './services/forecasting';
export { productionService } from './services/production';
export { posService } from './services/pos';
export { recipesService } from './services/recipes';

// NEW: Sprint 2 & 3 Services
export { ProcurementService } from './services/procurement-service';
export * as orchestratorService from './services/orchestrator';

// Types - Auth
export type {
  User,
  UserRegistration,
  UserLogin,
  TokenResponse,
  RefreshTokenRequest,
  PasswordChange,
  PasswordReset,
  UserResponse,
  UserUpdate as AuthUserUpdate,
  TokenVerificationResponse,
  AuthHealthResponse,
} from './types/auth';

// Types - User
export type {
  UserUpdate,
  AdminDeleteRequest,
  AdminDeleteResponse,
} from './types/user';

// Types - Onboarding
export type {
  OnboardingStepStatus,
  UserProgress,
  UpdateStepRequest,
} from './types/onboarding';

// Types - Tenant
export type {
  BakeryRegistration,
  TenantResponse,
  TenantAccessResponse,
  TenantUpdate,
  TenantMemberResponse,
  TenantStatistics,
  TenantSearchParams,
  TenantNearbyParams,
} from './types/tenant';

// Types - Subscription
export type {
  SubscriptionLimits,
  FeatureCheckResponse,
  UsageCheckResponse,
  UsageSummary,
  AvailablePlans,
  Plan,
  PlanUpgradeValidation,
  PlanUpgradeResult,
  SubscriptionTier,
  BillingCycle,
  PlanMetadata
} from './types/subscription';

export {
  SUBSCRIPTION_TIERS,
  BILLING_CYCLES,
  ANALYTICS_LEVELS
} from './types/subscription';

// Types - Sales
export type {
  SalesDataCreate,
  SalesDataUpdate,
  SalesDataResponse,
  SalesDataQuery,
  SalesAnalytics,
  SalesValidationRequest,
} from './types/sales';

// Types - Data Import
export type {
  ImportValidationRequest,
  ImportValidationResponse,
  ImportProcessRequest,
  ImportProcessResponse,
  ImportStatusResponse,
} from './types/dataImport';

// Types - Inventory
export type {
  IngredientCreate,
  IngredientUpdate,
  IngredientResponse,
  StockCreate,
  StockUpdate,
  StockResponse,
  StockMovementCreate,
  StockMovementResponse,
  InventoryFilter,
  StockFilter,
  StockConsumptionRequest,
  StockConsumptionResponse,
  PaginatedResponse,
} from './types/inventory';

export { ProductType } from './types/inventory';

// Types - Classification
export type {
  ProductClassificationRequest,
  BatchClassificationRequest,
  ProductSuggestionResponse,
  BusinessModelAnalysisResponse,
  ClassificationApprovalRequest,
  ClassificationApprovalResponse,
} from './types/classification';

// Types - Dashboard
export type {
  InventoryDashboardSummary,
  InventoryAnalytics,
  BusinessModelInsights,
  DashboardFilter,
  AlertsFilter,
  RecentActivity,
  StockMovementSummary,
  CategorySummary,
  AlertSummary,
  StockStatusSummary,
} from './types/dashboard';

// Types - Food Safety
export type {
  FoodSafetyComplianceCreate,
  FoodSafetyComplianceUpdate,
  FoodSafetyComplianceResponse,
  TemperatureLogCreate,
  BulkTemperatureLogCreate,
  TemperatureLogResponse,
  FoodSafetyAlertCreate,
  FoodSafetyAlertUpdate,
  FoodSafetyAlertResponse,
  FoodSafetyFilter,
  TemperatureMonitoringFilter,
  FoodSafetyMetrics,
  TemperatureAnalytics,
  FoodSafetyDashboard,
} from './types/foodSafety';

// Types - Training
export type {
  TrainingJobRequest,
  TrainingJobResponse,
  TrainingJobStatus,
  SingleProductTrainingRequest,
  TrainingResults,
  TrainingMetrics,
  ActiveModelResponse,
  ModelMetricsResponse,
  TrainedModelResponse,
  TenantStatistics as TrainingTenantStatistics,
  ModelPerformanceResponse,
  TrainingProgressMessage,
  TrainingCompletedMessage,
  TrainingErrorMessage,
  TrainingWebSocketMessage,
  ModelsQueryParams,
} from './types/training';

export { TrainingStatus } from './types/training';

// Types - Alert Processor
export type {
  EventResponse as AlertResponse,
  EventQueryParams as AlertQueryParams,
  NotificationSettings,
  ChannelRoutingConfig,
  WebhookConfig,
  AlertProcessingStatus,
  ProcessingMetrics,
  AlertAction,
  BusinessHours,
} from './types/events';

// No need for additional enums as they are included in events.ts

// Types - Suppliers
export type {
  SupplierCreate,
  SupplierUpdate,
  SupplierResponse,
  SupplierSummary,
  SupplierApproval,
  SupplierQueryParams,
  SupplierStatistics,
  TopSuppliersResponse,
  PurchaseOrderCreate,
  PurchaseOrderUpdate,
  PurchaseOrderResponse,
  PurchaseOrderApproval,
  PurchaseOrderQueryParams,
  DeliveryCreate,
  DeliveryUpdate,
  DeliveryResponse,
  DeliveryReceiptConfirmation,
  DeliveryQueryParams,
  PerformanceCalculationRequest,
  PerformanceMetrics,
  PerformanceAlert,
  PurchaseOrderItem,
  DeliveryItem,
} from './types/suppliers';

export {
  SupplierType,
  SupplierStatus,
  PaymentTerms,
  PurchaseOrderStatus,
  DeliveryStatus,
  OrderPriority,
  PerformanceMetricType,
} from './types/suppliers';

// Types - Orders
export type {
  CustomerType,
  DeliveryMethod,
  PaymentTerms as OrdersPaymentTerms,
  PaymentMethod,
  PaymentStatus,
  CustomerSegment,
  PriorityLevel,
  OrderType,
  OrderStatus,
  OrderSource,
  SalesChannel,
  BusinessModel,
  CustomerBase,
  CustomerCreate,
  CustomerUpdate,
  CustomerResponse,
  OrderItemBase,
  OrderItemCreate,
  OrderItemUpdate,
  OrderItemResponse,
  OrderBase,
  OrderCreate,
  OrderUpdate,
  OrderResponse,
  OrdersDashboardSummary,
  DemandRequirements,
  BusinessModelDetection,
  ServiceStatus,
  GetOrdersParams,
  GetCustomersParams,
  UpdateOrderStatusParams,
  GetDemandRequirementsParams,
} from './types/orders';

// Types - Procurement
export type {
  // Enums
  ProcurementPlanType,
  ProcurementStrategy,
  RiskLevel,
  RequirementStatus,
  PlanStatus,
  DeliveryStatus as ProcurementDeliveryStatus,
  PriorityLevel as ProcurementPriorityLevel,
  BusinessModel as ProcurementBusinessModel,

  // Requirement types
  ProcurementRequirementBase,
  ProcurementRequirementCreate,
  ProcurementRequirementUpdate,
  ProcurementRequirementResponse,

  // Plan types
  ProcurementPlanBase,
  ProcurementPlanCreate,
  ProcurementPlanUpdate,
  ProcurementPlanResponse,
  ApprovalWorkflowEntry,

  // Dashboard & Analytics
  ProcurementSummary,
  ProcurementDashboardData,

  // Request/Response types
  GeneratePlanRequest,
  GeneratePlanResponse,
  AutoGenerateProcurementRequest,
  AutoGenerateProcurementResponse,
  CreatePOsResult,
  LinkRequirementToPORequest,
  UpdateDeliveryStatusRequest,
  ApprovalRequest,
  RejectionRequest,
  PaginatedProcurementPlans,
  ForecastRequest as ProcurementForecastRequest,

  // Query params
  GetProcurementPlansParams,
  GetPlanRequirementsParams,
  UpdatePlanStatusParams,
} from './types/procurement';

// Types - Forecasting
export type {
  ForecastRequest,
  ForecastResponse,
  BatchForecastRequest,
  BatchForecastResponse,
  ForecastStatistics,
  ForecastListResponse,
  ForecastByIdResponse,
  DeleteForecastResponse,
  GetForecastsParams,
  ForecastingHealthResponse,
} from './types/forecasting';

export { BusinessType } from './types/forecasting';

// Types - Production
export type {
  ProductionBatchBase,
  ProductionBatchCreate,
  ProductionBatchUpdate,
  ProductionBatchStatusUpdate,
  ProductionBatchResponse,
  ProductionScheduleBase,
  ProductionScheduleCreate,
  ProductionScheduleUpdate,
  ProductionScheduleResponse,
  QualityCheckBase,
  QualityCheckCreate,
  QualityCheckResponse,
  ProductionDashboardSummary,
  DailyProductionRequirements,
  ProductionMetrics,
  ProductionBatchListResponse,
  ProductionScheduleListResponse,
  QualityCheckListResponse,
  ProductionScheduleData,
  ProductionCapacityStatus,
  ProductionRequirements,
  ProductionYieldMetrics,
} from './types/production';

export {
  ProductionStatusEnum,
  ProductionPriorityEnum,
  ProductionBatchStatus,
  QualityCheckStatus,
} from './types/production';

// Types - POS
export type {
  POSConfiguration,
  POSTransaction,
  POSTransactionItem,
  POSWebhookLog,
  POSSyncLog,
  POSSystemInfo,
  POSProviderConfig,
  POSCredentialsField,
  GetPOSConfigurationsRequest,
  GetPOSConfigurationsResponse,
  CreatePOSConfigurationRequest,
  CreatePOSConfigurationResponse,
  UpdatePOSConfigurationRequest,
  UpdatePOSConfigurationResponse,
  TestPOSConnectionRequest,
  TestPOSConnectionResponse,
  POSSyncSettings,
  SyncHealth,
  SyncAnalytics,
  TransactionSummary,
  WebhookStatus,
  POSSystem,
  POSEnvironment,
} from './types/pos';

// Types - Recipes
export type {
  RecipeStatus,
  MeasurementUnit,
  ProductionStatus as RecipeProductionStatus,
  ProductionPriority as RecipeProductionPriority,
  RecipeIngredientCreate,
  RecipeIngredientUpdate,
  RecipeIngredientResponse,
  RecipeCreate,
  RecipeUpdate,
  RecipeResponse,
  RecipeSearchRequest,
  RecipeSearchParams,
  RecipeDuplicateRequest,
  RecipeFeasibilityResponse,
  RecipeStatisticsResponse,
  RecipeCategoriesResponse,
  ProductionBatchCreate as RecipeProductionBatchCreate,
  ProductionBatchUpdate as RecipeProductionBatchUpdate,
  ProductionBatchResponse as RecipeProductionBatchResponse,
  RecipeFormData,
  RecipeUpdateFormData,
} from './types/recipes';

// Hooks - Auth
export {
  useAuthProfile,
  useAuthHealth,
  useVerifyToken,
  useLogin,
  useRefreshToken,
  useLogout,
  useChangePassword,
  useRequestPasswordReset,
  useResetPasswordWithToken,
  useUpdateProfile,
  useVerifyEmail,
  authKeys,
} from './hooks/auth';

// Hooks - User
export {
  useCurrentUser,
  useAllUsers,
  useUserById,
  useUpdateUser,
  useDeleteUser,
  useAdminDeleteUser,
  userKeys,
} from './hooks/user';

// Hooks - Onboarding
export {
  useUserProgress,
  useAllSteps,
  useStepDetails,
  useUpdateStep,
  useMarkStepCompleted,
  useResetProgress,
  onboardingKeys,
} from './hooks/onboarding';

// Hooks - Tenant
export {
  useTenant,
  useTenantBySubdomain,
  useUserTenants,
  useUserOwnedTenants,
  useTenantAccess,
  useSearchTenants,
  useNearbyTenants,
  useTeamMembers,
  useTenantStatistics,
  useRegisterBakery,
  useUpdateTenant,
  useDeactivateTenant,
  useActivateTenant,
  useUpdateModelStatus,
  useAddTeamMember,
  useUpdateMemberRole,
  useRemoveTeamMember,
  tenantKeys,
} from './hooks/tenant';

// Hooks - Sales
export {
  useSalesRecords,
  useSalesRecord,
  useSalesAnalytics,
  useProductSales,
  useProductCategories,
  useCreateSalesRecord,
  useUpdateSalesRecord,
  useDeleteSalesRecord,
  useValidateSalesRecord,
  salesKeys,
} from './hooks/sales';

// Hooks - Inventory
export {
  useIngredients,
  useIngredient,
  useIngredientsByCategory,
  useLowStockIngredients,
  useStock,
  useStockByIngredient,
  useExpiringStock,
  useExpiredStock,
  useStockMovements,
  useStockAnalytics,
  useCreateIngredient,
  useUpdateIngredient,
  useSoftDeleteIngredient,
  useHardDeleteIngredient,
  useAddStock,
  useUpdateStock,
  useConsumeStock,
  useCreateStockMovement,
  inventoryKeys,
} from './hooks/inventory';

// Note: Classification hooks consolidated into inventory.ts hooks (useClassifyBatch)
// Note: Data Import hooks consolidated into sales.ts hooks (useValidateImportFile, useImportSalesData)
// Note: Inventory Dashboard and Food Safety hooks consolidated into inventory.ts hooks

// Hooks - Training
export {
  useTrainingJobStatus,
  useActiveModel,
  useModels,
  useModelMetrics,
  useModelPerformance,
  useTenantTrainingStatistics,
  useCreateTrainingJob,
  useTrainSingleProduct,
  useDeleteAllTenantModels,
  useTrainingWebSocket,
  useIsTrainingInProgress,
  useTrainingProgress,
  trainingKeys,
} from './hooks/training';

// Hooks - Alert Processor
export {
  useEvents as useAlerts,
  useEvent as useAlert,
  useEventsSummary as useAlertDashboardData,
  useAcknowledgeAlert,
  useResolveAlert,
  useCancelAutoAction,
  useDismissRecommendation,
  useBulkAcknowledgeAlerts,
  useBulkResolveAlerts,
  useRecordInteraction,
  alertKeys as alertProcessorKeys,
} from './hooks/useAlerts';

// Hooks - Unified Alerts
export {
  useUnifiedAlerts,
  useSingleAlert,
  useAlertStats,
  useRealTimeAlerts,
} from './hooks/useUnifiedAlerts';

// Hooks - Suppliers
export {
  useSuppliers,
  useSupplier,
  useSupplierStatistics,
  useActiveSuppliers,
  useTopSuppliers,
  usePendingApprovalSuppliers,
  useSuppliersByType,
  useDeliveries,
  useDelivery,
  useSupplierPerformanceMetrics,
  usePerformanceAlerts,
  useCreateSupplier,
  useUpdateSupplier,
  useDeleteSupplier,
  useApproveSupplier,
  useCreateDelivery,
  useUpdateDelivery,
  useConfirmDeliveryReceipt,
  useCalculateSupplierPerformance,
  useEvaluatePerformanceAlerts,
  useSuppliersByStatus,
  useSuppliersCount,
  useActiveSuppliersCount,
  usePendingOrdersCount,
  suppliersKeys,
} from './hooks/suppliers';

// Hooks - Orders
export {
  useOrders,
  useOrder,
  useCustomers,
  useCustomer,
  useOrdersDashboard,
  useDemandRequirements,
  useBusinessModelDetection,
  useOrdersServiceStatus,
  useCreateOrder,
  useUpdateOrder,
  useUpdateOrderStatus,
  useCreateCustomer,
  useUpdateCustomer,
  useInvalidateOrders,
  ordersKeys,
} from './hooks/orders';

// Hooks - Procurement
export {
  // Queries
  useProcurementDashboard,
  useProcurementPlans,
  useProcurementPlan,
  useProcurementPlanByDate,
  useCurrentProcurementPlan,
  usePlanRequirements,
  useCriticalRequirements,

  // Mutations
  useGenerateProcurementPlan,
  useAutoGenerateProcurement,
  useUpdateProcurementPlanStatus,
  useRecalculateProcurementPlan,
  useApproveProcurementPlan,
  useRejectProcurementPlan,
  useCreatePurchaseOrdersFromPlan,
  useLinkRequirementToPurchaseOrder,
  useUpdateRequirementDeliveryStatus,

  // Query keys
  procurementKeys,
} from './hooks/procurement';

// Hooks - Forecasting
export {
  useTenantForecasts,
  useForecastById,
  useForecastStatistics,
  useForecastingHealth,
  useInfiniteTenantForecasts,
  useCreateSingleForecast,
  useCreateBatchForecast,
  useDeleteForecast,
  usePrefetchForecast,
  useInvalidateForecasting,
  forecastingKeys,
} from './hooks/forecasting';

// Hooks - Production
export {
  useProductionDashboard,
  useDailyProductionRequirements,
  useProductionRequirements,
  useActiveBatches,
  useBatchDetails,
  useProductionSchedule,
  useCapacityStatus,
  useYieldMetrics,
  useCreateProductionBatch,
  useUpdateBatchStatus,
  useProductionDashboardData,
  useProductionPlanningData,
  useTriggerProductionScheduler,
  productionKeys,
} from './hooks/production';

// Hooks - POS
export {
  usePOSConfigurations,
  usePOSConfiguration,
  useSupportedPOSSystems,
  useCreatePOSConfiguration,
  useUpdatePOSConfiguration,
  useDeletePOSConfiguration,
  useTestPOSConnection,
  usePOSTransactions,
  usePOSTransaction,
  useTriggerManualSync,
  usePOSSyncStatus,
  useDetailedSyncLogs,
  useSyncSingleTransaction,
  usePOSSyncAnalytics,
  useResyncFailedTransactions,
  usePOSSyncLogs,
  usePOSWebhookLogs,
  useWebhookStatus,
  usePOSUtils,
  usePOSConfigurationData,
  usePOSConfigurationManager,
  posKeys,
} from './hooks/pos';

// Hooks - Recipes
export {
  useRecipe,
  useRecipes,
  useInfiniteRecipes,
  useRecipeStatistics,
  useRecipeCategories,
  useRecipeFeasibility,
  useCreateRecipe,
  useUpdateRecipe,
  useDeleteRecipe,
  useDuplicateRecipe,
  useActivateRecipe,
  recipesKeys,
} from './hooks/recipes';

// Hooks - Orchestrator
export {
  useRunDailyWorkflow,
} from './hooks/orchestrator';

// Hooks - Professional Dashboard (JTBD-aligned)
export {
  useBakeryHealthStatus,
  useOrchestrationSummary,
  useProductionTimeline,
  useApprovePurchaseOrder as useApprovePurchaseOrderDashboard,
  useStartProductionBatch,
  usePauseProductionBatch,
  useExecutionProgress,
  useUnifiedActionQueue,
} from './hooks/useProfessionalDashboard';

export type {
  BakeryHealthStatus,
  HealthChecklistItem,
  HeadlineData,
  ReasoningInputs,
  PurchaseOrderSummary,
  ProductionBatchSummary,
  OrchestrationSummary,
  ActionButton,
  ActionItem,
  ActionQueue,
  ProductionTimeline,
  ProductionTimelineItem,
  InsightCard,
  Insights,
  UnifiedActionQueue,
  EnrichedAlert,
} from './hooks/useProfessionalDashboard';

// Hooks - Enterprise Dashboard
export {
  useNetworkSummary,
  useChildrenPerformance,
  useDistributionOverview,
  useForecastSummary,
  useChildSales,
  useChildInventory,
  useChildProduction,
  useChildTenants,
} from './hooks/useEnterpriseDashboard';

export type {
  NetworkSummary,
  PerformanceRankings,
  ChildPerformance,
  DistributionOverview,
  ForecastSummary,
  ChildTenant,
  SalesSummary,
  InventorySummary,
  ProductionSummary,
} from './hooks/useEnterpriseDashboard';

// Note: All query key factories are already exported in their respective hook sections above

