import { FirebaseApp, initializeApp } from 'firebase/app';
import { getFirestore } from 'firebase/firestore';
import { getAuth, initializeAuth } from 'firebase/auth';
import AsyncStorage from '@react-native-async-storage/async-storage';
import * as firebaseAuth from 'firebase/auth';
const reactNativePersistence = (firebaseAuth as any).getReactNativePersistence;

// Configuration Firebase
const firebaseConfig = {
  apiKey: 'AIzaSyDHoF8Eahk60s3APh7WxohL1bya_44v39k',
  authDomain: 'brix-cafe-2ddf1.firebaseapp.com',
  projectId: 'brix-cafe-2ddf1',
  storageBucket: 'brix-cafe-2ddf1.appspot.com',
  messagingSenderId: '577471189504',
  appId: '1:577471189504:web:7bf8819223bf0d4cf03ee5',
  measurementId: 'G-FSV5ZQBJS3',
};

const app: FirebaseApp = initializeApp(firebaseConfig);

// Initialiser Auth avec persistance
const auth = initializeAuth(app, {
  persistence: reactNativePersistence(AsyncStorage),
});


// Initialiser Firestore
const db = getFirestore(app);

export { app, db, auth };
