/**
 * AdiaUI optional polyfills — for consumers extending below the
 * library's stated baseline (Chromium 125+, Safari 17.4+, Firefox 129+).
 *
 * Side-effect import — runs feature checks at module-evaluation time
 * and dynamically loads polyfills only when the runtime lacks support:
 *
 *   import '@adia-ai/web-components/core/polyfills.js';
 *   // ↳ before importing components
 *
 * Conditionally loads:
 *   - Popover API (consumers extending to Firefox < 125 / Safari < 17)
 *   - CSS Anchor Positioning (consumers extending to Safari < 26 / Firefox < 147)
 *
 * Browsers with native support skip the download. Packages are
 * optional — if not installed, the import silently fails.
 *
 * Consumers on the stated baseline should NOT import this module —
 * the runtime checks below resolve to no-op on every supported browser
 * but you avoid the conditional `import()` setup entirely by skipping it.
 */

if (typeof window !== 'undefined') {
  // Popover API
  if (!('popover' in HTMLElement.prototype)) {
    import('@oddbird/popover-polyfill').catch(() => {});
  }

  // CSS Anchor Positioning
  if (!CSS?.supports?.('anchor-name: --x')) {
    import('@oddbird/css-anchor-positioning').catch(() => {});
  }
}
