import { P as ProductIdentifier, h as OpenStoreEventType, E as EventHandler, U as Unsubscribe, M as Middleware, g as OpenStoreEventMap, O as OpenStoreEvent } from './payloads-BYtydfZU.js'; /** * @shopkit/events - EventBus * * Typed, in-memory publish/subscribe singleton. * The single point through which ALL analytics events flow. * * Key behaviors: * - Synchronous dispatch (no await, no microtask scheduling overhead) * - Error isolation (each handler wrapped in try/catch) * - Middleware can block events by not calling next() * - Ring buffer event log (last 100 events) for debugging */ declare class EventBus { private handlers; private wildcardHandlers; private middlewares; private eventLog; private _initialized; private _productIdentifier; /** * Check if the bus has been initialized (middleware pipeline registered). * Used by EventProvider to prevent double-registration on remount. */ get initialized(): boolean; /** * Mark the bus as initialized. Should be called after middleware registration. */ markInitialized(): void; /** * Get the configured product identifier strategy. * Used by emitters to resolve content_ids for Meta Ads catalog matching. */ get productIdentifier(): ProductIdentifier; /** * Set the product identifier strategy. * Called by EventProvider during initialization. */ setProductIdentifier(identifier: ProductIdentifier): void; /** * Subscribe to a specific event type. * Returns an unsubscribe function. */ subscribe(type: K, handler: EventHandler): Unsubscribe; /** * Subscribe to ALL events (used by loggers, debuggers, pixel runtime). */ subscribeAll(handler: EventHandler): Unsubscribe; /** * Add middleware to the processing pipeline. * Middleware runs BEFORE handlers. Order matters. */ use(middleware: Middleware): void; /** * Emit an event. This is the ONLY way events enter the system. * * Automatically generates: event_id, timestamp, session_id, page context. * Runs the middleware chain synchronously, then dispatches to handlers. * * @returns The fully-formed event envelope, or null if blocked by middleware */ emit(type: K, data: K extends keyof OpenStoreEventMap ? OpenStoreEventMap[K] : unknown, overrides?: Partial>): OpenStoreEvent | null; /** * Get the event log (ring buffer of recent events). * Useful for debugging and the Event Inspector. */ getEventLog(): ReadonlyArray; /** * Reset all state. Used in testing. */ reset(): void; private executeMiddlewares; private dispatchToHandlers; private appendToLog; /** * Fallback session ID for when sessionStorage is unavailable. * Cached per EventBus instance to ensure consistent session_id across events. */ private fallbackSessionId; private getSessionId; private getPageContext; } /** * Singleton EventBus instance. * Uses globalThis to guarantee ONE instance across all module loads. * Without this, Next.js webpack can create duplicate singletons when * loading chunks during client-side navigation vs. initial hydration. */ declare const eventBus: EventBus; export { EventBus as E, eventBus as e };