// IMPORTANT: DOM polyfill must be imported FIRST, before any browser-dependent libraries
import './ssr-dom-polyfill';

import { bootstrapApplication, BootstrapContext } from '@angular/platform-browser';
import { AppComponent } from './app/app.component';
import { config } from './app/app.config.server';

const bootstrap = (context: BootstrapContext) => {
  console.log('[SSR] Bootstrap function called');
  const appRef = bootstrapApplication(AppComponent, config, context);
  appRef.then(() => {
    console.log('[SSR] Application bootstrapped successfully');
  }).catch((err) => {
    console.error('[SSR] Bootstrap error:', err);
    console.error('[SSR] Error stack:', err.stack);
  });
  return appRef;
};

export default bootstrap;
