{"version":3,"file":"index.mjs","sources":["../../../src/lib/coordination/index.tsx"],"sourcesContent":["/* eslint-disable react-refresh/only-export-components */\n/* @refresh reset */\n/**\n * @file Coordination System Public API\n * @module coordination\n * @description PhD-level intra-library coordination system for seamless library integration.\n *\n * This module provides comprehensive coordination infrastructure for the Harbor\n * React library ecosystem including:\n *\n * - **Event Bus**: Type-safe cross-library event communication\n * - **Dependency Injection**: IoC container with lifecycle management\n * - **Lifecycle Manager**: Phased initialization with dependency ordering\n * - **State Coordinator**: Cross-library state synchronization\n * - **Feature Bridge**: Module interconnection layer\n * - **Hook Composer**: Multi-library hook composition\n * - **Provider Orchestrator**: Automated provider nesting\n * - **Context Bridge**: Cross-boundary context access\n *\n * @author Agent 5 - PhD TypeScript Architect\n * @version 1.0.0\n *\n * @example Quick Start\n * ```tsx\n * import {\n *   CoordinationProvider,\n *   useCoordination,\n *   useCoordinationEvent,\n * } from '@/lib/coordination';\n *\n * function App() {\n *   return (\n *     <CoordinationProvider onReady={() => console.log('Ready!')}>\n *       <MyApp />\n *     </CoordinationProvider>\n *   );\n * }\n *\n * function MyComponent() {\n *   const { eventBus, lifecycle, isReady } = useCoordination();\n *\n *   // Subscribe to events\n *   useCoordinationEvent('auth:login', (event) => {\n *     console.log('User logged in:', event.payload.userId);\n *   });\n *\n *   return <div>Ready: {isReady ? 'Yes' : 'No'}</div>;\n * }\n * ```\n */\n\n// ============================================================================\n// React Imports for Provider/Hook Implementation\n// ============================================================================\n\nimport {\n  useContext,\n  useState,\n  useEffect,\n  useMemo,\n  useCallback,\n  useRef,\n  createContext,\n  type ReactNode,\n  type FC,\n  type ComponentType,\n} from 'react';\n// import { CoordinationContext } from '../contexts/CoordinationContext';\n\n// ============================================================================\n// Type Exports\n// ============================================================================\n\nexport type {\n  // Branded types\n  LibraryId,\n  EventId,\n  ServiceId,\n  StateSliceId,\n  SubscriptionId,\n  PhaseId,\n\n  // Event types\n  CoordinationEvent,\n  EventHandler,\n  EventSubscription,\n  EventSubscriptionOptions,\n  EventBusConfig,\n  EventBusStats,\n  CoordinationEventBus,\n  KnownEventType,\n  KnownEvents,\n  EventPayload,\n\n  // Known event interfaces\n  AuthEvents,\n  NetworkEvents,\n  StateEvents,\n  SystemEvents,\n  ThemeEvents,\n  FeatureFlagEvents,\n  HydrationEvents,\n  StreamingEvents,\n  RealtimeEvents,\n  LifecycleEvents,\n\n  // Service types\n  ServiceScope,\n  ServiceLifecycle,\n  ServiceContract,\n  ServiceRegistration,\n  ServiceRegistrationOptions,\n  ServiceFactory,\n  DependencyContainer,\n\n  // Lifecycle types\n  LibraryState,\n  LibraryRegistration,\n  LifecyclePhase,\n  LifecycleManager,\n  LifecycleManagerConfig,\n\n  // State types\n  StateChange,\n  StateSubscriber,\n  StateSliceRegistration,\n  StateSyncRule,\n  StateCoordinator,\n  StateCoordinatorConfig,\n\n  // Provider types\n  ProviderDefinition,\n  ProviderOrchestratorConfig,\n\n  // Context bridge types\n  ContextBridgeDefinition,\n\n  // Coordination context\n  CoordinationContextValue,\n  CoordinationProviderProps,\n\n  // Utility types\n  DeepPartial,\n  PartialBy,\n  Disposable,\n  Result,\n} from './types';\n\nexport {\n  // Enums\n  EventPriority,\n\n  // Type creators\n  createLibraryId,\n  createEventId,\n  createServiceId,\n  createStateSliceId,\n  createSubscriptionId,\n  createPhaseId,\n\n  // Type guards\n  isLibraryId,\n  isEventId,\n  isCoordinationEvent,\n  isKnownEventType,\n\n  // Result utilities\n  ok,\n  err,\n\n  // Default configurations\n  DEFAULT_EVENT_BUS_CONFIG,\n  DEFAULT_LIFECYCLE_CONFIG,\n  DEFAULT_LIFECYCLE_PHASES,\n  DEFAULT_STATE_COORDINATOR_CONFIG,\n} from './types';\n\n// ============================================================================\n// Event Bus Exports\n// ============================================================================\n\nexport {\n  // CoordinationEventBusImpl,\n  getCoordinationEventBus,\n  setCoordinationEventBus,\n  resetCoordinationEventBus,\n  publishEvent,\n  subscribeToEvent,\n  // createLibraryScopedBus,\n} from './event-bus';\n\n// ============================================================================\n// Dependency Injection Exports\n// ============================================================================\n\nexport {\n  DependencyInjectorImpl,\n  createServiceContract,\n  getGlobalContainer,\n  setGlobalContainer,\n  resetGlobalContainer,\n  registerService,\n  resolveService,\n  tryResolveService,\n\n  // Pre-defined contracts\n  LoggerContract,\n  ConfigContract,\n  TelemetryContract,\n  type ILogger,\n  type IConfigService,\n  type ITelemetryService,\n} from './dependency-injector';\n\n// ============================================================================\n// Lifecycle Manager Exports\n// ============================================================================\n\nexport {\n  LifecycleManagerImpl,\n  getLifecycleManager,\n  setLifecycleManager,\n  resetLifecycleManager,\n  registerLibrary,\n  initializeLibraries,\n  shutdownLibraries,\n\n  // Pre-defined IDs\n  LIBRARY_IDS,\n  PHASE_IDS,\n} from './lifecycle-manager';\n\n// ============================================================================\n// State Coordinator Exports\n// ============================================================================\n\nexport {\n  StateCoordinatorImpl,\n  getStateCoordinator,\n  setStateCoordinator,\n  resetStateCoordinator,\n  registerStateSlice,\n\n  // Pre-defined IDs\n  SLICE_IDS,\n} from './state-coordinator';\n\n// ============================================================================\n// Feature Bridge Exports\n// ============================================================================\n\nexport {\n  FeatureBridgeImpl,\n  createFeatureId,\n  getFeatureBridge,\n  setFeatureBridge,\n  resetFeatureBridge,\n  registerFeature,\n  invokeCapability,\n  invokeAnyCapability,\n  type FeatureId,\n  type FeatureCapability,\n  type FeatureRegistration,\n  type InvocationOptions,\n  type InvocationResult,\n  type FeatureBridgeConfig,\n} from './feature-bridge';\n\n// ============================================================================\n// Hook Composer Exports\n// ============================================================================\n\nexport {\n  useComposedHooks,\n  useSelectiveHooks,\n  useConditionalHook,\n  useMemoizedComposition,\n  useParallelHooks,\n  useHookSequence,\n  defineHook,\n  defineAsyncHook,\n  type HookState,\n  type ComposedResult,\n  type HookDef,\n  type AsyncHookResult,\n  type CompositionOptions,\n} from './hook-composer';\n\n// ============================================================================\n// Provider Orchestrator Exports\n// ============================================================================\n\nexport {\n  ProviderOrchestratorImpl,\n  OrchestratedProviders,\n  getProviderOrchestrator,\n  setProviderOrchestrator,\n  resetProviderOrchestrator,\n  registerProvider,\n  getGlobalProviderTree,\n  DefaultLoadingFallback,\n  DefaultErrorFallback,\n  type OrchestratedProvidersProps,\n} from './provider-orchestrator';\n\n// ============================================================================\n// Context Bridge Exports\n// ============================================================================\n\nexport {\n  ContextBridgeImpl,\n  ContextBridgeProvider,\n  useBridgeManager,\n  useBridgedContext,\n  BridgeSource,\n  BridgeConsumer,\n  createComposedContext,\n  useMultiContextSelector,\n  withBridgedContext,\n  getContextBridgeManager,\n  setContextBridgeManager,\n  resetContextBridgeManager,\n  type BridgeOptions,\n  type ContextBridgeProviderProps,\n  type BridgeSourceProps,\n  type BridgeConsumerProps,\n  type WithBridgedContextProps,\n} from './context-bridge';\n\n// ============================================================================\n// Coordination Context\n// ============================================================================\n\nimport type {\n  CoordinationContextValue,\n  KnownEventType,\n  EventPayload,\n  EventHandler,\n  EventSubscriptionOptions,\n  ServiceContract,\n} from './types';\nimport { createLibraryId } from './types';\nimport { getCoordinationEventBus } from './event-bus';\nimport { getGlobalContainer } from './dependency-injector';\nimport { getLifecycleManager } from './lifecycle-manager';\nimport { getStateCoordinator } from './state-coordinator';\n\n/**\n * Coordination context for React.\n */\nconst CoordinationContext = createContext<CoordinationContextValue | null>(null);\nCoordinationContext.displayName = 'CoordinationContext';\n\n/**\n * Props for CoordinationProvider component.\n */\nexport interface CoordinationProviderComponentProps {\n  /** Child components */\n  children: ReactNode;\n  /** Debug mode */\n  debug?: boolean;\n  /** Callback when coordination is ready */\n  onReady?: () => void;\n  /** Error handler */\n  onError?: (error: Error) => void;\n  /** Whether to auto-initialize libraries */\n  autoInitialize?: boolean;\n}\n\n/**\n * Provider component for the coordination system.\n *\n * @example\n * ```tsx\n * function App() {\n *   return (\n *     <CoordinationProvider\n *       debug={process.env.NODE_ENV === 'development'}\n *       onReady={() => console.log('Coordination ready')}\n *       autoInitialize\n *     >\n *       <AppContent />\n *     </CoordinationProvider>\n *   );\n * }\n * ```\n */\nexport const CoordinationProvider: FC<CoordinationProviderComponentProps> = ({\n  children,\n  debug = false,\n  onReady,\n  onError,\n  autoInitialize = true,\n}) => {\n  const [isInitialized, setIsInitialized] = useState(false);\n  const initRef = useRef(false);\n\n  // Initialize coordination system\n  useEffect(() => {\n    if (initRef.current) return;\n    initRef.current = true;\n\n    const initialize = async (): Promise<void> => {\n      try {\n        if (autoInitialize) {\n          const lifecycle = getLifecycleManager();\n          await lifecycle.initialize();\n        }\n\n        setIsInitialized(true);\n        onReady?.();\n\n        if (debug) {\n          console.info('[Coordination] System initialized');\n        }\n      } catch (error) {\n        const err = error instanceof Error ? error : new Error(String(error));\n        onError?.(err);\n\n        if (debug) {\n          console.error('[Coordination] Initialization failed:', error);\n        }\n      }\n    };\n\n    void initialize();\n\n    // Cleanup on unmount\n    return () => {\n      const lifecycle = getLifecycleManager();\n      void lifecycle.shutdown().catch(console.error);\n    };\n  }, [autoInitialize, debug, onError, onReady]);\n\n  // Create context value\n  const contextValue = useMemo<CoordinationContextValue>(\n    () => ({\n      eventBus: getCoordinationEventBus() as unknown as import('./types').CoordinationEventBus,\n      container: getGlobalContainer(),\n      lifecycle: getLifecycleManager(),\n      stateCoordinator: getStateCoordinator({ debug }),\n      isInitialized,\n      version: '1.0.0',\n    }),\n    [debug, isInitialized]\n  );\n\n  return (\n    <CoordinationContext.Provider value={contextValue}>{children}</CoordinationContext.Provider>\n  );\n};\n\nCoordinationProvider.displayName = 'CoordinationProvider';\n\n// ============================================================================\n// Core Hook: useCoordination\n// ============================================================================\n\n/**\n * Hook to access the coordination system.\n *\n * @returns Coordination context value\n * @throws Error if used outside CoordinationProvider\n *\n * @example\n * ```tsx\n * function MyComponent() {\n *   const { eventBus, lifecycle, isInitialized } = useCoordination();\n *\n *   const handleClick = () => {\n *     eventBus.publish('theme:changed', {\n *       mode: 'dark',\n *       resolvedMode: 'dark',\n *       source: 'user',\n *     });\n *   };\n *\n *   return (\n *     <button onClick={handleClick} disabled={!isInitialized}>\n *       Toggle Theme\n *     </button>\n *   );\n * }\n * ```\n */\nexport function useCoordination(): CoordinationContextValue {\n  const context = useContext(CoordinationContext);\n\n  if (!context) {\n    throw new Error(\n      'useCoordination must be used within a CoordinationProvider. ' +\n        'Wrap your component tree with <CoordinationProvider>.'\n    );\n  }\n\n  return context;\n}\n\n/**\n * Hook to optionally access the coordination system.\n * Returns null if outside CoordinationProvider.\n */\nexport function useOptionalCoordination(): CoordinationContextValue | null {\n  return useContext(CoordinationContext);\n}\n\n// ============================================================================\n// Event Hooks\n// ============================================================================\n\n/**\n * Hook to subscribe to coordination events.\n *\n * @template T - Event type\n * @param type - Event type to subscribe to\n * @param handler - Event handler\n * @param options - Subscription options\n *\n * @example\n * ```tsx\n * function AuthListener() {\n *   useCoordinationEvent('auth:login', (event) => {\n *     console.log('User logged in:', event.payload.userId);\n *   });\n *\n *   useCoordinationEvent('auth:logout', (event) => {\n *     console.log('User logged out:', event.payload.reason);\n *   });\n *\n *   return null;\n * }\n * ```\n */\nexport function useCoordinationEvent<T extends KnownEventType>(\n  type: T,\n  handler: EventHandler<EventPayload<T>>,\n  options?: EventSubscriptionOptions\n): void {\n  const { eventBus } = useCoordination();\n\n  useEffect(() => {\n    const subscription = eventBus.subscribe(type, handler, options);\n    return () => subscription.unsubscribe();\n  }, [eventBus, type, handler, options]);\n}\n\n/**\n * Hook to publish coordination events.\n *\n * @returns Publish function\n *\n * @example\n * ```tsx\n * function ThemeToggle() {\n *   const publish = useCoordinationPublish();\n *\n *   const toggleTheme = () => {\n *     publish('theme:changed', {\n *       mode: 'dark',\n *       resolvedMode: 'dark',\n *       source: 'user',\n *     });\n *   };\n *\n *   return <button onClick={toggleTheme}>Toggle Theme</button>;\n * }\n * ```\n */\nexport function useCoordinationPublish(): <T extends KnownEventType>(\n  type: T,\n  payload: EventPayload<T>\n) => string {\n  const { eventBus } = useCoordination();\n\n  return useCallback(\n    <T extends KnownEventType>(type: T, payload: EventPayload<T>) => {\n      return eventBus.publish(type, payload);\n    },\n    [eventBus]\n  );\n}\n\n// ============================================================================\n// Lifecycle Hooks\n// ============================================================================\n\n/**\n * Hook to check if all libraries are initialized.\n *\n * @returns Whether all libraries are initialized\n */\nexport function useIsCoordinationReady(): boolean {\n  const { isInitialized, lifecycle } = useCoordination();\n  return isInitialized && lifecycle.isFullyInitialized();\n}\n\n/**\n * Hook to get library initialization state.\n *\n * @param libraryId - Library ID\n * @returns Library state or undefined\n */\nexport function useLibraryState(libraryId: string): string | undefined {\n  const { lifecycle } = useCoordination();\n  const brandedId = createLibraryId(libraryId);\n  const [state, setState] = useState(() => lifecycle.getLibraryState(brandedId));\n\n  useEffect(() => {\n    // Poll for state changes (could be improved with event subscription)\n    const interval = setInterval(() => {\n      const newState = lifecycle.getLibraryState(brandedId);\n      setState(newState);\n    }, 100);\n\n    return () => clearInterval(interval);\n  }, [lifecycle, brandedId]);\n\n  return state;\n}\n\n// ============================================================================\n// Service Hooks\n// ============================================================================\n\n/**\n * Hook to resolve a service from the DI container.\n *\n * @template T - Service type\n * @param contract - Service contract\n * @returns Resolved service\n */\nexport function useService<T>(contract: ServiceContract<T>): T {\n  const { container } = useCoordination();\n  return useMemo(() => container.resolve(contract), [container, contract]);\n}\n\n/**\n * Hook to try resolving a service.\n *\n * @template T - Service type\n * @param contract - Service contract\n * @returns Service or undefined\n */\nexport function useTryService<T>(contract: ServiceContract<T>): T | undefined {\n  const { container } = useCoordination();\n  return useMemo(() => container.tryResolve(contract), [container, contract]);\n}\n\n// ============================================================================\n// Higher-Order Component: withCoordination\n// ============================================================================\n\n/**\n * Props injected by withCoordination HOC.\n */\nexport interface WithCoordinationProps {\n  coordination: CoordinationContextValue;\n}\n\n/**\n * Higher-order component to inject coordination context.\n *\n * @template P - Component props\n * @param Component - Component to wrap\n * @returns Wrapped component\n *\n * @example\n * ```tsx\n * interface MyComponentProps extends WithCoordinationProps {\n *   title: string;\n * }\n *\n * class MyComponent extends React.Component<MyComponentProps> {\n *   handleClick = () => {\n *     this.props.coordination.eventBus.publish('theme:changed', {\n *       mode: 'dark',\n *       resolvedMode: 'dark',\n *       source: 'user',\n *     });\n *   };\n *\n *   render() {\n *     return (\n *       <button onClick={this.handleClick}>\n *         {this.props.title}\n *       </button>\n *     );\n *   }\n * }\n *\n * export default withCoordination(MyComponent);\n * ```\n */\nexport function withCoordination<P extends WithCoordinationProps>(\n  Component: ComponentType<P>\n): FC<Omit<P, keyof WithCoordinationProps>> {\n  const WrappedComponent: FC<Omit<P, keyof WithCoordinationProps>> = (props) => {\n    const coordination = useCoordination();\n    return <Component {...(props as P)} coordination={coordination} />;\n  };\n\n  WrappedComponent.displayName = `withCoordination(${Component.displayName ?? Component.name ?? 'Component'})`;\n\n  return WrappedComponent;\n}\n\n// ============================================================================\n// Convenience Utilities\n// ============================================================================\n\n/**\n * Initializes the coordination system outside of React.\n *\n * @param options - Initialization options\n * @returns Cleanup function\n *\n * @example\n * ```typescript\n * // In main.ts\n * import { initCoordination } from '@/lib/coordination';\n *\n * const cleanup = await initCoordination({\n *   debug: import.meta.env.DEV,\n * });\n *\n * // On app shutdown\n * cleanup();\n * ```\n */\nexport async function initCoordination(\n  options: {\n    debug?: boolean;\n  } = {}\n): Promise<() => Promise<void>> {\n  const { debug = false } = options;\n\n  // Initialize event bus\n  const eventBus = getCoordinationEventBus();\n\n  // Initialize lifecycle\n  const lifecycle = getLifecycleManager();\n  await lifecycle.initialize();\n\n  if (debug) {\n    console.info('[Coordination] System initialized outside React');\n  }\n\n  // Return cleanup function\n  return async () => {\n    await lifecycle.shutdown();\n    eventBus.clear();\n\n    if (debug) {\n      console.info('[Coordination] System shut down');\n    }\n  };\n}\n\n/**\n * Gets the coordination system version.\n */\nexport function getCoordinationVersion(): string {\n  return '1.0.0';\n}\n\n// ============================================================================\n// Export Context for Advanced Usage\n// ============================================================================\n\nexport { CoordinationContext };\n"],"names":["CoordinationContext","createContext","CoordinationProvider","children","debug","onReady","onError","autoInitialize","isInitialized","setIsInitialized","useState","initRef","useRef","useEffect","getLifecycleManager","error","err","contextValue","useMemo","getCoordinationEventBus","getGlobalContainer","getStateCoordinator","useCoordination","context","useContext","useOptionalCoordination","useCoordinationEvent","type","handler","options","eventBus","subscription","useCoordinationPublish","useCallback","payload","useIsCoordinationReady","lifecycle","useLibraryState","libraryId","brandedId","createLibraryId","state","setState","interval","newState","useService","contract","container","useTryService","withCoordination","Component","WrappedComponent","props","coordination","jsx","initCoordination","getCoordinationVersion"],"mappings":";;;;;;;;;;;;;;;;;;AA8VA,MAAMA,IAAsBC,EAA+C,IAAI;AAC/ED,EAAoB,cAAc;AAoC3B,MAAME,IAA+D,CAAC;AAAA,EAC3E,UAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,SAAAC;AAAA,EACA,SAAAC;AAAA,EACA,gBAAAC,IAAiB;AACnB,MAAM;AACJ,QAAM,CAACC,GAAeC,CAAgB,IAAIC,EAAS,EAAK,GAClDC,IAAUC,EAAO,EAAK;AAG5B,EAAAC,EAAU,MACJF,EAAQ,UAAS,UACrBA,EAAQ,UAAU,KAEC,YAA2B;AAC5C,QAAI;AACF,MAAIJ,KAEF,MADkBO,EAAAA,EACF,WAAA,GAGlBL,EAAiB,EAAI,GACrBJ,IAAA,GAEID,KACF,QAAQ,KAAK,mCAAmC;AAAA,IAEpD,SAASW,GAAO;AACd,YAAMC,IAAMD,aAAiB,QAAQA,IAAQ,IAAI,MAAM,OAAOA,CAAK,CAAC;AACpE,MAAAT,IAAUU,CAAG,GAETZ,KACF,QAAQ,MAAM,yCAAyCW,CAAK;AAAA,IAEhE;AAAA,EACF,GAEK,GAGE,MAAM;AAEX,IADkBD,EAAAA,EACH,SAAA,EAAW,MAAM,QAAQ,KAAK;AAAA,EAC/C,IACC,CAACP,GAAgBH,GAAOE,GAASD,CAAO,CAAC;AAG5C,QAAMY,IAAeC;AAAA,IACnB,OAAO;AAAA,MACL,UAAUC,EAAAA;AAAAA,MACV,WAAWC,EAAAA;AAAAA,MACX,WAAWN,EAAAA;AAAAA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