/**
 * `<feed-ui>` — auto-registers the tag on import.
 *
 * For non-side-effect class import (test isolation, tag override), use
 * the `class` subpath:
 *
 *   import { UIFeedContainer, UIFeedItem } from '@adia-ai/web-components/components/feed/class';
 *
 * @see ../../USAGE.md#registration--auto-vs-explicit
 */

import { defineIfFree } from '../../core/register.js';
import { UIFeedContainer, UIFeedItem, UIFeed } from './feed.class.js';

defineIfFree('feed-ui', UIFeedContainer);
defineIfFree('feed-item-ui', UIFeedItem);

/* Global 'feed' CustomEvent listener — same shape as UIFeed.post().
   Idempotent (HMR-safe via window flag). */
if (typeof window !== 'undefined' && !window.__adiaFeedListenerInstalled) {
  window.__adiaFeedListenerInstalled = true;
  window.addEventListener('feed', (e) => {
    if (e?.detail && typeof e.detail === 'object') UIFeed.post(e.detail);
  });
}

export { UIFeedContainer, UIFeedItem, UIFeed };
