<commit_before>import {APP_INITIALIZER, Inject, Injectable, OpaqueToken, provide, Provider} from '@angular/core';
import {AngularFireAuth, firebaseAuthConfig, FirebaseAuth} from './providers/auth';
import { initializeApp } from 'firebase';
import {FirebaseListObservable} from './utils/firebase_list_observable';
import {FirebaseObjectObservable} from './utils/firebase_object_observable';
import {FirebaseListFactory, FirebaseListFactoryOpts} from './utils/firebase_list_factory';
import {
  FirebaseObjectFactoryOpts,
  FirebaseObjectFactory
} from './utils/firebase_object_factory';
import * as utils from './utils/utils';
import { FirebaseConfig, FirebaseApp, WindowLocation } from './tokens';
import { FirebaseAppConfig } from './interfaces';
import {
  AuthBackend,
  AuthMethods,
  AuthProviders,
  FirebaseAuthState
} from './providers/auth_backend';
import {FirebaseSdkAuthBackend} from './providers/firebase_sdk_auth_backend';
import {FirebaseDatabase} from './database/database';

@Injectable()
export class AngularFire {
  list: (url:string, opts?:FirebaseListFactoryOpts) => FirebaseListObservable<any[]>;
  object: (url: string, opts?:FirebaseObjectFactoryOpts) => FirebaseObjectObservable<any>;
  constructor(
    @Inject(FirebaseConfig) private fbUrl:string,
    public auth: AngularFireAuth,
    public database: FirebaseDatabase) {}
}

export const COMMON_PROVIDERS: any[] = [
  // TODO: Deprecate
  provide(FirebaseAuth, {
    useExisting: AngularFireAuth
  }),
  {
    provide: FirebaseApp,
    useFactory: _getFirebase,
    deps: [FirebaseConfig]
  },
  AngularFireAuth,
  AngularFire,
  FirebaseDatabase
];

function _getFirebase(config: FirebaseAppConfig): firebase.app.App {
  return initializeApp(config);
}

export const FIREBASE_PROVIDERS:any[] = [
  COMMON_PROVIDERS,
  {
    provide: AuthBackend,
    useFactory: _getAuthBackend,
    deps: [FirebaseApp]
  },
  {
    provide: WindowLocation,
    useValue: window.location
  },
];

function _getAuthBackend(app: firebase.app.App): FirebaseSdkAuthBackend {
  return new FirebaseSdkAuthBackend(app, false);
}

/**
 * Used to define the default Firebase root location to be
 * used throughout an application.
 */
export const defaultFirebase = (config: FirebaseAppConfig): Provider => {
  // remove a trailing slash from the Database URL if it exists
  config.databaseURL = utils.stripTrailingSlash(config.databaseURL);
  return provide(FirebaseConfig, {
    useValue: config
  });
};

export {
  AngularFireAuth,
  // TODO: Deprecate
  FirebaseAuth,
  FirebaseDatabase,
  FirebaseListObservable,
  FirebaseObjectObservable,
  FirebaseListFactory,
  FirebaseObjectFactory,
  firebaseAuthConfig,
  FirebaseAuthState,
  AuthMethods,
  AuthProviders,
  WindowLocation
}

export { FirebaseConfig, FirebaseApp, FirebaseAuthConfig, FirebaseRef, FirebaseUrl } from './tokens';
export { FirebaseAppConfig } from './interfaces';

// Helps Angular-CLI automatically add providers
export default {
  providers: FIREBASE_PROVIDERS
}
<commit_msg>chore(modules): Organize modules<commit_after>import {APP_INITIALIZER, Inject, Injectable, OpaqueToken, provide, Provider} from '@angular/core';
import {AngularFireAuth, firebaseAuthConfig, FirebaseAuth} from './providers/auth';
import { initializeApp } from 'firebase';
import {FirebaseListObservable} from './utils/firebase_list_observable';
import {FirebaseObjectObservable} from './utils/firebase_object_observable';
import {FirebaseListFactory, FirebaseListFactoryOpts} from './utils/firebase_list_factory';
import {
  FirebaseObjectFactoryOpts,
  FirebaseObjectFactory
} from './utils/firebase_object_factory';
import * as utils from './utils/utils';
import { FirebaseConfig, FirebaseApp, WindowLocation } from './tokens';
import { FirebaseAppConfig } from './interfaces';
import {
  AuthBackend,
  AuthMethods,
  AuthProviders,
  FirebaseAuthState
} from './providers/auth_backend';
import {FirebaseSdkAuthBackend} from './providers/firebase_sdk_auth_backend';
import {FirebaseDatabase} from './database/database';

@Injectable()
export class AngularFire {
  constructor(
    @Inject(FirebaseConfig) private fbUrl:string,
    public auth: AngularFireAuth,
    public database: FirebaseDatabase) {}
}

export const COMMON_PROVIDERS: any[] = [
  // TODO: Deprecate
  provide(FirebaseAuth, {
    useExisting: AngularFireAuth
  }),
  {
    provide: FirebaseApp,
    useFactory: _getFirebase,
    deps: [FirebaseConfig]
  },
  AngularFireAuth,
  AngularFire,
  FirebaseDatabase
];

function _getFirebase(config: FirebaseAppConfig): firebase.app.App {
  return initializeApp(config);
}

export const FIREBASE_PROVIDERS:any[] = [
  COMMON_PROVIDERS,
  {
    provide: AuthBackend,
    useFactory: _getAuthBackend,
    deps: [FirebaseApp]
  },
  {
    provide: WindowLocation,
    useValue: window.location
  },
];

function _getAuthBackend(app: firebase.app.App): FirebaseSdkAuthBackend {
  return new FirebaseSdkAuthBackend(app, false);
}

/**
 * Used to define the default Firebase root location to be
 * used throughout an application.
 */
export const defaultFirebase = (config: FirebaseAppConfig): Provider => {
  // remove a trailing slash from the Database URL if it exists
  config.databaseURL = utils.stripTrailingSlash(config.databaseURL);
  return provide(FirebaseConfig, {
    useValue: config
  });
};

export {
  AngularFireAuth,
  // TODO: Deprecate
  FirebaseAuth,
  FirebaseDatabase,
  FirebaseListObservable,
  FirebaseObjectObservable,
  FirebaseListFactory,
  FirebaseObjectFactory,
  firebaseAuthConfig,
  FirebaseAuthState,
  AuthMethods,
  AuthProviders,
  WindowLocation
}

export { FirebaseConfig, FirebaseApp, FirebaseAuthConfig, FirebaseRef, FirebaseUrl } from './tokens';
export { FirebaseAppConfig } from './interfaces';

// Helps Angular-CLI automatically add providers
export default {
  providers: FIREBASE_PROVIDERS
}

{'fraction_non_alphanumeric': 0.10122908842608398, 'fraction_numerical': 0.0, 'mean_word_length': 5.313577586206897, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '468491', 'n_tokens_mistral': 1781, 'n_tokens_neox': 1794, 'n_words': 411}